Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to load custom rules #59

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ Default value: `false`

Set `force` to `true` to report CoffeeLint errors but not fail the task.

### rules
Type: `Array`
Default value: `[]`

List of npm packages to be loaded as custom rules. They have to be requirable so included in project's package.json or available as global package.

## Configuration

`coffeelint` is a multitask, so you can use it similary to `lint`, `watch` etc...
Expand Down Expand Up @@ -75,6 +81,18 @@ grunt.initConfig({
});
````

### Custom rules

````javascript
grunt.initConfig({
...
coffeelint: {
rules: ['coffeelint-complex-conditions']
},
...
});
````

### Loading external config

````javascript
Expand Down
9 changes: 9 additions & 0 deletions tasks/coffeelint.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ module.exports = function(grunt) {
options = config;
}

(options.rules || []).forEach(function(rule) {
try {
var RuleProcessor = require(rule);
coffeelint.registerRule(RuleProcessor);
} catch (e) {
return grunt.log.error(e);
}
});

files.forEach(function(file) {
grunt.verbose.writeln('Linting ' + file + '...');

Expand Down