Skip to content

Commit

Permalink
moved to eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
davglass committed May 17, 2017
1 parent f82b535 commit 10fe441
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 69 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
artifacts
build
coverage
29 changes: 29 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"root": true,
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "script"
},
"globals": {
"YUI_config": true
},
"rules": {
"no-unused-vars": ["error", { "args": "after-used" }],
"semi": 2,
"eqeqeq": [2, "always"],
"no-console": 0,
"no-irregular-whitespace": 2,
"indent": ["error", 4],
"space-before-function-paren": ["error", "never"],
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
"arrow-body-style": [2, "always"],
"array-bracket-spacing": [2, "never"],
"object-curly-spacing": [2, "always"],
"key-spacing": ["error", { "beforeColon": false }]
},
"env": {
"node": true,
"browser": true
}
}
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
language: node_js
before_install:
- npm -g install npm@latest-2
node_js:
- "0.12"
- "4"
- "6"
14 changes: 7 additions & 7 deletions lib/args.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ var nopt = require('nopt'),
files: require('path')
},
shorts = {
"v" : ["--version"],
"h" : ["--help"]
"v": ["--version"],
"h": ["--help"]
};

var raw = function (args) {
var raw = function(args) {
return nopt(known, shorts, (args || process.argv));
};

/*istanbul ignore next */
var has = function (a) {
var has = function(a) {
var cooked = raw().argv.cooked,
ret = false;
ret = false;

cooked.forEach(function (o) {
cooked.forEach(function(o) {
if ((o === '--' + a) || (o === '--no-' + a)) {
ret = true;
}
Expand Down Expand Up @@ -72,7 +72,7 @@ var setDefaults = function(parsed) {
return parsed;
};

var parse = function (args) {
var parse = function(args) {
var parsed = clean(args);
return setDefaults(parsed);
};
Expand Down
21 changes: 10 additions & 11 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ var flatten = function(options) {
var content;
if (!moduleInfo.licenses || moduleInfo.licenses.indexOf(UNKNOWN) > -1) {
//Only re-check the license if we didn't get it from elsewhere
content = fs.readFileSync(licenseFile, {encoding: 'utf8'});
content = fs.readFileSync(licenseFile, { encoding: 'utf8' });
moduleInfo.licenses = license(content);
}
moduleInfo.licenseFile = options.basePath ? path.relative(options.basePath, licenseFile) : licenseFile;
if (!content) {
content = fs.readFileSync(moduleInfo.licenseFile, {encoding: 'utf8'});
content = fs.readFileSync(moduleInfo.licenseFile, { encoding: 'utf8' });
}
if (options.customFormat) {
moduleInfo.licenseText = content.replace(/"/g, '\'').replace(/\r?\n|\r/g, " ").trim();
Expand All @@ -183,7 +183,7 @@ var flatten = function(options) {
if (json.dependencies) {
Object.keys(json.dependencies).forEach(function(name) {
var childDependency = json.dependencies[name],
dependencyId = childDependency.name + '@' + childDependency.version;
dependencyId = childDependency.name + '@' + childDependency.version;
if (data[dependencyId]) { // already exists
return;
}
Expand Down Expand Up @@ -306,12 +306,12 @@ exports.asTree = function(sorted) {
};

exports.asCSV = function(sorted, customFormat, csvComponentPrefix) {
var text = [ ], textArr = [ ], lineArr = [ ];
var text = [], textArr = [], lineArr = [];
var prefixName = '"component"';
var prefix = csvComponentPrefix;

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

Object.keys(sorted).forEach(function(key) {
var module = sorted[key],
line = '';
lineArr = [ ];
line = '';
lineArr = [];

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

try {
jsonFileContents = fs.readFileSync(jsonPath, {encoding: 'utf8'});
jsonFileContents = fs.readFileSync(jsonPath, { encoding: 'utf8' });
result = JSON.parse(jsonFileContents);
} catch (err) {
result = err;
} finally {
return result;
}
return result;
};

exports.asFiles = function(json, outDir) {
mkdirp.sync(outDir);
Object.keys(json).forEach(function (moduleName) {
Object.keys(json).forEach(function(moduleName) {
var licenseFile = json[moduleName].licenseFile,
fileContents, outFileName, outPath;

Expand Down
10 changes: 5 additions & 5 deletions lib/stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ Copyright (c) 2012, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://yuilibrary.com/license/
*/
var Stack = function () {
var Stack = function() {
this.errors = [];
this.finished = 0;
this.results = [];
this.total = 0;
};

Stack.prototype = {
add: function (fn) {
add: function(fn) {
var self = this,
index = self.total;

self.total += 1;

return function (err) {
return function(err) {
if (err) { self.errors[index] = err; }

self.finished += 1;
Expand All @@ -26,14 +26,14 @@ Stack.prototype = {
};
},

test: function () {
test: function() {
if (this.finished >= this.total && this.callback) {
this.callback.call(null, this.errors.length ? this.errors : null,
this.results, this.data);
}
},

done: function (callback, data) {
done: function(callback, data) {
this.callback = callback;
this.data = data;
this.test();
Expand Down
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,17 @@
"treeify": "^1.0.1"
},
"devDependencies": {
"camden.jshint": "cfjedimaster/brackets-jshint",
"camden.jshint": "github:cfjedimaster/brackets-jshint",
"detectionizr": "*",
"eslint": "^3.19.0",
"format-package-json": "^0.2.0",
"git-contributors": "^0.2.3",
"github-changes": "^1.0.4",
"istanbul": "^0.4.3",
"jenkins-mocha": "^2.6.0",
"jshint": "^2.9.4",
"queue": "^1.0.0",
"request": "^2.34.0",
"rimraf": "^2.5.4",
"yui-lint": "~0.1.1"
"rimraf": "^2.5.4"
},
"keywords": [
"license",
Expand All @@ -70,7 +69,7 @@
"scripts": {
"changes": "github-changes -o davglass -r license-checker",
"contrib": "./scripts/contrib.js",
"pretest": "jshint --config ./node_modules/yui-lint/jshint.json ./lib/",
"pretest": "eslint --fix .",
"test": "jenkins-mocha ./tests/*.js",
"posttest": "istanbul check-coverage"
},
Expand Down
2 changes: 1 addition & 1 deletion scripts/contrib.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var json = require(pkg);

json.contributors = []; //clear it

GitContributors.list(opts, function (err, result) {
GitContributors.list(opts, function(err, result) {
result.forEach(function(item) {
json.contributors.push([item.name, '<' + item.email + '>'].join(' '));
});
Expand Down
5 changes: 5 additions & 0 deletions tests/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"env": {
"mocha": true
}
}
Loading

0 comments on commit 10fe441

Please sign in to comment.