Skip to content

Commit fa74626

Browse files
committed
Switch to ESLint
Use SemiStandard with a small tweak to spaces
1 parent f39a4c6 commit fa74626

File tree

7 files changed

+31
-51
lines changed

7 files changed

+31
-51
lines changed

.eslintrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "semistandard",
3+
"rules": {
4+
"brace-style": [2, "stroustrup", { "allowSingleLine": true }],
5+
"space-before-function-paren": [2, "never"]
6+
}
7+
}

.jscsrc

Lines changed: 0 additions & 18 deletions
This file was deleted.

.jshintrc

Lines changed: 0 additions & 6 deletions
This file was deleted.

index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

33
var gutil = require('gulp-util');
4-
var error = gutil.PluginError;
54
var through = require('through2');
65
var csslint = require('csslint').CSSLint;
76
var RcLoader = require('rcloader');
@@ -46,7 +45,7 @@ var cssLintPlugin = function(options) {
4645

4746
return through.obj(function(file, enc, cb) {
4847
if (file.isNull()) return cb(null, file); // pass along
49-
if (file.isStream()) return cb(new error('gulp-csslint: Streaming not supported'), file);
48+
if (file.isStream()) return cb(new gutil.PluginError('gulp-csslint: Streaming not supported'), file);
5049

5150
var content = file.contents.toString(enc);
5251

@@ -127,7 +126,7 @@ cssLintPlugin.reporter = function(customReporter) {
127126
};
128127

129128
cssLintPlugin.addRule = function(rule) {
130-
if(typeof rule !== 'object') {
129+
if (typeof rule !== 'object') {
131130
throw new Error('Invalid rule: rules need to be objects.');
132131
}
133132
csslint.addRule(rule);
@@ -140,7 +139,7 @@ cssLintPlugin.failReporter = function() {
140139
return cb(null, file);
141140
}
142141

143-
return cb(new gutil.PluginError('gulp-csslint', 'CSSLint failed for '+file.relative), file);
142+
return cb(new gutil.PluginError('gulp-csslint', 'CSSLint failed for ' + file.relative), file);
144143
});
145144
};
146145

package.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,31 @@
1414
},
1515
"devDependencies": {
1616
"coveralls": "^2.11.2",
17+
"eslint": "^1.1.0",
18+
"eslint-config-semistandard": "^5.0.0",
19+
"eslint-config-standard": "^4.1.0",
20+
"eslint-plugin-standard": "^1.2.0",
1721
"istanbul": "^0.3.14",
18-
"jscs": "^1.13.1",
19-
"jshint": "^2.7.0",
2022
"mocha": "^2.2.5",
2123
"rimraf": "^2.3.4",
2224
"should": "^7.0.3",
2325
"sinon": "^1.15.4"
2426
},
2527
"scripts": {
2628
"clean": "rimraf coverage/",
27-
"lint": "jscs index.js test/ && jshint index.js test/",
28-
"pretest": "npm run lint",
29-
"test": "mocha",
29+
"cover": "istanbul cover _mocha",
30+
"lint": "eslint index.js test/main.js",
3031
"precover": "npm run lint && npm run clean",
31-
"cover": "istanbul cover _mocha"
32+
"pretest": "npm run lint",
33+
"test": "mocha"
3234
},
3335
"repository": {
3436
"type": "git",
3537
"url": "git://github.com/lazd/gulp-csslint.git"
3638
},
3739
"keywords": [
38-
"gulpplugin",
39-
"csslint"
40+
"csslint",
41+
"gulpplugin"
4042
],
4143
"author": "Larry Davis <[email protected]>",
4244
"license": "MIT",

test/.jshintrc

Lines changed: 0 additions & 4 deletions
This file was deleted.

test/main.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*jshint expr: true*/
1+
/* eslint-env mocha */
22

33
var cssLintPlugin = require('../');
44
var should = require('should');
@@ -8,7 +8,7 @@ var path = require('path');
88
var sinon = require('sinon');
99

1010
var getFile = function(filePath) {
11-
filePath = 'test/'+filePath;
11+
filePath = 'test/' + filePath;
1212
return new gutil.File({
1313
path: filePath,
1414
cwd: 'test/',
@@ -18,7 +18,7 @@ var getFile = function(filePath) {
1818
};
1919

2020
var getContents = function(filePath) {
21-
filePath = 'test/'+filePath;
21+
filePath = 'test/' + filePath;
2222
return fs.readFileSync(filePath, 'utf8');
2323
};
2424

@@ -191,23 +191,23 @@ describe('gulp-csslint', function() {
191191
desc: 'Class names must follow pattern',
192192
browsers: 'All',
193193

194-
//initialization
194+
// initialization
195195
init: function(parser, reporter) {
196196
'use strict';
197197
var rule = this;
198198
parser.addListener('startrule', function(event) {
199-
var line = event.line,
200-
col = event.col;
199+
var line = event.line;
200+
var col = event.col;
201201

202-
for (var i=0,len=event.selectors.length; i < len; i++) {
202+
for (var i = 0, len = event.selectors.length; i < len; i++) {
203203
var selectors = event.selectors[i].text.split(/(?=\.)/);
204-
for (var s=0,l=selectors.length; s < l; s++){
204+
for (var s = 0, l = selectors.length; s < l; s++) {
205205
var selector = selectors[s].trim();
206-
if(selector.charAt(0) !== '.'){
206+
if (selector.charAt(0) !== '.') {
207207
return;
208208
}
209-
if(!selector.match(/^\.(_)?(o|c|u|is|has|js|qa)-[a-z0-9]+$/)){
210-
reporter.warn('Bad naming: '+selector, line, col, rule);
209+
if (!selector.match(/^\.(_)?(o|c|u|is|has|js|qa)-[a-z0-9]+$/)) {
210+
reporter.warn('Bad naming: ' + selector, line, col, rule);
211211
}
212212
}
213213
}

0 commit comments

Comments
 (0)