Skip to content

Commit 10e14f5

Browse files
Lukas OppermannLukas Oppermann
authored andcommitted
Adding addRule function
1 parent 44070e1 commit 10e14f5

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,24 @@ gulp.task('lint', function() {
8989
});
9090
```
9191

92+
## Custom Rules
93+
94+
The plugin exposes the csslint `addRule` method which allows you to define custom rules that are run in addition to the included rules. [Creating your own rules](https://github.com/CSSLint/csslint/wiki/Working-with-Rules) works exactly like when using csslint directly.
95+
96+
```javascript
97+
var csslint = require(‘gulp-csslint’);
98+
99+
csslint.addRule({
100+
// rule object
101+
});
102+
103+
gulp.task(‘lint’, function() {
104+
gulp.files('lib/*.css')
105+
.pipe(csslint())
106+
.pipe(csslint.reporter())
107+
});
108+
```
109+
92110
## Fail on errors
93111

94112
Pipe the file stream to `csslint.failReporter()` to fail on errors.

index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ cssLintPlugin.reporter = function(customReporter) {
122122
});
123123
};
124124

125+
cssLintPlugin.addRule = function(rule) {
126+
if(typeof rule !== 'object') {
127+
throw new Error('Invalid rule: rules need to be objects.');
128+
}
129+
csslint.addRule(rule);
130+
};
131+
125132
cssLintPlugin.failReporter = function() {
126133
return es.map(function(file, cb) {
127134
// Nothing to report or no errors

0 commit comments

Comments
 (0)