Skip to content

Commit 10fe441

Browse files
committed
moved to eslint
1 parent f82b535 commit 10fe441

File tree

10 files changed

+101
-69
lines changed

10 files changed

+101
-69
lines changed

.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
artifacts
2+
build
3+
coverage

.eslintrc.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"root": true,
3+
"extends": "eslint:recommended",
4+
"parserOptions": {
5+
"ecmaVersion": 6,
6+
"sourceType": "script"
7+
},
8+
"globals": {
9+
"YUI_config": true
10+
},
11+
"rules": {
12+
"no-unused-vars": ["error", { "args": "after-used" }],
13+
"semi": 2,
14+
"eqeqeq": [2, "always"],
15+
"no-console": 0,
16+
"no-irregular-whitespace": 2,
17+
"indent": ["error", 4],
18+
"space-before-function-paren": ["error", "never"],
19+
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
20+
"arrow-body-style": [2, "always"],
21+
"array-bracket-spacing": [2, "never"],
22+
"object-curly-spacing": [2, "always"],
23+
"key-spacing": ["error", { "beforeColon": false }]
24+
},
25+
"env": {
26+
"node": true,
27+
"browser": true
28+
}
29+
}

.travis.yml

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
language: node_js
2-
before_install:
3-
- npm -g install npm@latest-2
42
node_js:
5-
- "0.12"
63
- "4"
74
- "6"

lib/args.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,20 @@ var nopt = require('nopt'),
2727
files: require('path')
2828
},
2929
shorts = {
30-
"v" : ["--version"],
31-
"h" : ["--help"]
30+
"v": ["--version"],
31+
"h": ["--help"]
3232
};
3333

34-
var raw = function (args) {
34+
var raw = function(args) {
3535
return nopt(known, shorts, (args || process.argv));
3636
};
3737

3838
/*istanbul ignore next */
39-
var has = function (a) {
39+
var has = function(a) {
4040
var cooked = raw().argv.cooked,
41-
ret = false;
41+
ret = false;
4242

43-
cooked.forEach(function (o) {
43+
cooked.forEach(function(o) {
4444
if ((o === '--' + a) || (o === '--no-' + a)) {
4545
ret = true;
4646
}
@@ -72,7 +72,7 @@ var setDefaults = function(parsed) {
7272
return parsed;
7373
};
7474

75-
var parse = function (args) {
75+
var parse = function(args) {
7676
var parsed = clean(args);
7777
return setDefaults(parsed);
7878
};

lib/index.js

+10-11
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,12 @@ var flatten = function(options) {
158158
var content;
159159
if (!moduleInfo.licenses || moduleInfo.licenses.indexOf(UNKNOWN) > -1) {
160160
//Only re-check the license if we didn't get it from elsewhere
161-
content = fs.readFileSync(licenseFile, {encoding: 'utf8'});
161+
content = fs.readFileSync(licenseFile, { encoding: 'utf8' });
162162
moduleInfo.licenses = license(content);
163163
}
164164
moduleInfo.licenseFile = options.basePath ? path.relative(options.basePath, licenseFile) : licenseFile;
165165
if (!content) {
166-
content = fs.readFileSync(moduleInfo.licenseFile, {encoding: 'utf8'});
166+
content = fs.readFileSync(moduleInfo.licenseFile, { encoding: 'utf8' });
167167
}
168168
if (options.customFormat) {
169169
moduleInfo.licenseText = content.replace(/"/g, '\'').replace(/\r?\n|\r/g, " ").trim();
@@ -183,7 +183,7 @@ var flatten = function(options) {
183183
if (json.dependencies) {
184184
Object.keys(json.dependencies).forEach(function(name) {
185185
var childDependency = json.dependencies[name],
186-
dependencyId = childDependency.name + '@' + childDependency.version;
186+
dependencyId = childDependency.name + '@' + childDependency.version;
187187
if (data[dependencyId]) { // already exists
188188
return;
189189
}
@@ -306,12 +306,12 @@ exports.asTree = function(sorted) {
306306
};
307307

308308
exports.asCSV = function(sorted, customFormat, csvComponentPrefix) {
309-
var text = [ ], textArr = [ ], lineArr = [ ];
309+
var text = [], textArr = [], lineArr = [];
310310
var prefixName = '"component"';
311311
var prefix = csvComponentPrefix;
312312

313313
if (customFormat && Object.keys(customFormat).length > 0) {
314-
textArr = [ ];
314+
textArr = [];
315315
if (csvComponentPrefix) { textArr.push(prefixName); }
316316
textArr.push('"module name"');
317317
Object.keys(customFormat).forEach(function forEachCallback(item) {
@@ -329,8 +329,8 @@ exports.asCSV = function(sorted, customFormat, csvComponentPrefix) {
329329

330330
Object.keys(sorted).forEach(function(key) {
331331
var module = sorted[key],
332-
line = '';
333-
lineArr = [ ];
332+
line = '';
333+
lineArr = [];
334334

335335
//Grab the custom keys from the custom format
336336
if (customFormat && Object.keys(customFormat).length > 0) {
@@ -397,18 +397,17 @@ exports.parseJson = function(jsonPath) {
397397
result = { };
398398

399399
try {
400-
jsonFileContents = fs.readFileSync(jsonPath, {encoding: 'utf8'});
400+
jsonFileContents = fs.readFileSync(jsonPath, { encoding: 'utf8' });
401401
result = JSON.parse(jsonFileContents);
402402
} catch (err) {
403403
result = err;
404-
} finally {
405-
return result;
406404
}
405+
return result;
407406
};
408407

409408
exports.asFiles = function(json, outDir) {
410409
mkdirp.sync(outDir);
411-
Object.keys(json).forEach(function (moduleName) {
410+
Object.keys(json).forEach(function(moduleName) {
412411
var licenseFile = json[moduleName].licenseFile,
413412
fileContents, outFileName, outPath;
414413

lib/stack.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@ Copyright (c) 2012, Yahoo! Inc. All rights reserved.
33
Code licensed under the BSD License:
44
http://yuilibrary.com/license/
55
*/
6-
var Stack = function () {
6+
var Stack = function() {
77
this.errors = [];
88
this.finished = 0;
99
this.results = [];
1010
this.total = 0;
1111
};
1212

1313
Stack.prototype = {
14-
add: function (fn) {
14+
add: function(fn) {
1515
var self = this,
1616
index = self.total;
1717

1818
self.total += 1;
1919

20-
return function (err) {
20+
return function(err) {
2121
if (err) { self.errors[index] = err; }
2222

2323
self.finished += 1;
@@ -26,14 +26,14 @@ Stack.prototype = {
2626
};
2727
},
2828

29-
test: function () {
29+
test: function() {
3030
if (this.finished >= this.total && this.callback) {
3131
this.callback.call(null, this.errors.length ? this.errors : null,
3232
this.results, this.data);
3333
}
3434
},
3535

36-
done: function (callback, data) {
36+
done: function(callback, data) {
3737
this.callback = callback;
3838
this.data = data;
3939
this.test();

package.json

+4-5
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,17 @@
4444
"treeify": "^1.0.1"
4545
},
4646
"devDependencies": {
47-
"camden.jshint": "cfjedimaster/brackets-jshint",
47+
"camden.jshint": "github:cfjedimaster/brackets-jshint",
4848
"detectionizr": "*",
49+
"eslint": "^3.19.0",
4950
"format-package-json": "^0.2.0",
5051
"git-contributors": "^0.2.3",
5152
"github-changes": "^1.0.4",
5253
"istanbul": "^0.4.3",
5354
"jenkins-mocha": "^2.6.0",
54-
"jshint": "^2.9.4",
5555
"queue": "^1.0.0",
5656
"request": "^2.34.0",
57-
"rimraf": "^2.5.4",
58-
"yui-lint": "~0.1.1"
57+
"rimraf": "^2.5.4"
5958
},
6059
"keywords": [
6160
"license",
@@ -70,7 +69,7 @@
7069
"scripts": {
7170
"changes": "github-changes -o davglass -r license-checker",
7271
"contrib": "./scripts/contrib.js",
73-
"pretest": "jshint --config ./node_modules/yui-lint/jshint.json ./lib/",
72+
"pretest": "eslint --fix .",
7473
"test": "jenkins-mocha ./tests/*.js",
7574
"posttest": "istanbul check-coverage"
7675
},

scripts/contrib.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var json = require(pkg);
99

1010
json.contributors = []; //clear it
1111

12-
GitContributors.list(opts, function (err, result) {
12+
GitContributors.list(opts, function(err, result) {
1313
result.forEach(function(item) {
1414
json.contributors.push([item.name, '<' + item.email + '>'].join(' '));
1515
});

tests/.eslintrc.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"env": {
3+
"mocha": true
4+
}
5+
}

0 commit comments

Comments
 (0)