Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit fe89b4d

Browse files
committed
Chore: Refactor the codebase (fixes #220)
1 parent c8e881a commit fe89b4d

17 files changed

+2646
-2670
lines changed

Diff for: .eslintrc.yml

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
root: true
22

3-
env:
4-
node: true
5-
6-
extends: eslint
3+
plugins:
4+
- node
5+
extends:
6+
- "eslint"
7+
- "plugin:node/recommended"
8+
rules:
9+
no-undefined: "off"
10+
lines-around-comment: "off"
11+
newline-after-var: "off"

Diff for: .travis.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
language: node_js
22
sudo: false
33
node_js:
4-
- "0.12"
5-
- 4
6-
- 6
4+
- "4"
5+
- "5"
6+
- "6"
7+
- "7"
78
after_success:
89
- npm run coveralls

Diff for: Makefile.js

+21-31
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,30 @@
1515

1616
require("shelljs/make");
1717

18-
var checker = require("npm-license"),
18+
const checker = require("npm-license"),
1919
nodeCLI = require("shelljs-nodecli");
2020

2121
//------------------------------------------------------------------------------
2222
// Settings
2323
//------------------------------------------------------------------------------
2424

25-
var OPEN_SOURCE_LICENSES = [
25+
const OPEN_SOURCE_LICENSES = [
2626
/MIT/, /BSD/, /Apache/, /ISC/, /WTF/, /Public Domain/
2727
];
2828

2929
//------------------------------------------------------------------------------
3030
// Data
3131
//------------------------------------------------------------------------------
3232

33-
var NODE_MODULES = "./node_modules/",
33+
const NODE_MODULES = "./node_modules/",
3434

3535
// Utilities - intentional extra space at the end of each string
36-
MOCHA = NODE_MODULES + "mocha/bin/_mocha ",
36+
MOCHA = `${NODE_MODULES}mocha/bin/_mocha `,
3737

3838
// Files
3939
MAKEFILE = "./Makefile.js",
4040
/* eslint-disable no-use-before-define */
41-
JS_FILES = find("lib/").filter(fileType("js")).join(" ") + " parser.js",
41+
JS_FILES = `${find("lib/").filter(fileType("js")).join(" ")} parser.js`,
4242
TEST_FILES = find("tests/lib/").filter(fileType("js")).join(" ");
4343
/* eslint-enable no-use-before-define */
4444

@@ -67,7 +67,7 @@ target.all = function() {
6767
};
6868

6969
target.lint = function() {
70-
var errors = 0,
70+
let errors = 0,
7171
lastReturn;
7272

7373
echo("Validating Makefile.js");
@@ -96,10 +96,8 @@ target.lint = function() {
9696
target.test = function() {
9797
target.lint();
9898

99-
var errors = 0,
100-
lastReturn;
101-
102-
lastReturn = nodeCLI.exec("istanbul", "cover", MOCHA, "-- -c", TEST_FILES);
99+
const lastReturn = nodeCLI.exec("istanbul", "cover", MOCHA, "-- -c", TEST_FILES);
100+
let errors = 0;
103101

104102
if (lastReturn.code !== 0) {
105103
errors++;
@@ -122,42 +120,34 @@ target.checkLicenses = function() {
122120

123121
/**
124122
* Returns true if the given dependency's licenses are all permissable for use in OSS
125-
* @param {object} dependency object containing the name and licenses of the given dependency
123+
* @param {Object} dependency object containing the name and licenses of the given dependency
126124
* @returns {boolean} is permissable dependency
127125
*/
128126
function isPermissible(dependency) {
129-
var licenses = dependency.licenses;
127+
const licenses = dependency.licenses;
130128

131129
if (Array.isArray(licenses)) {
132-
return licenses.some(function(license) {
133-
return isPermissible({
134-
name: dependency.name,
135-
licenses: license
136-
});
137-
});
130+
return licenses.some(license => isPermissible({
131+
name: dependency.name,
132+
licenses: license
133+
}));
138134
}
139135

140-
return OPEN_SOURCE_LICENSES.some(function(license) {
141-
return license.test(licenses);
142-
});
136+
return OPEN_SOURCE_LICENSES.some(license => license.test(licenses));
143137
}
144138

145139
echo("Validating licenses");
146140

147141
checker.init({
148142
start: __dirname
149-
}, function(deps) {
150-
var impermissible = Object.keys(deps).map(function(dependency) {
151-
return {
152-
name: dependency,
153-
licenses: deps[dependency].licenses
154-
};
155-
}).filter(function(dependency) {
156-
return !isPermissible(dependency);
157-
});
143+
}, deps => {
144+
const impermissible = Object.keys(deps).map(dependency => ({
145+
name: dependency,
146+
licenses: deps[dependency].licenses
147+
})).filter(dependency => !isPermissible(dependency));
158148

159149
if (impermissible.length) {
160-
impermissible.forEach(function(dependency) {
150+
impermissible.forEach(dependency => {
161151
console.error("%s license for %s is impermissible.",
162152
dependency.licenses,
163153
dependency.name

0 commit comments

Comments
 (0)