Skip to content
This repository was archived by the owner on Aug 15, 2024. It is now read-only.

Commit 12a1ca1

Browse files
soda0289JamesHenry
authored andcommitted
Add Makefile.js and eslint (#15)
1 parent 7d23f8e commit 12a1ca1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1725
-1595
lines changed

.eslintrc.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
env:
2+
node: true
3+
es6: true
4+
parserOptions:
5+
ecmaVersion: 6
6+
7+
extends: eslint

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ node_modules/
88
npm-debug.log
99

1010
# Cover
11-
.coverage_data/
12-
cover_html/
11+
/coverage/
1312

1413
npm-debug.log
1514
.vimrc.local

.jshintrc

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

Makefile.js

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
/**
2+
* @fileoverview Build file
3+
* @author nzakas
4+
* @copyright jQuery Foundation and other contributors, https://jquery.org/
5+
* MIT License
6+
*/
7+
/* global echo, exec, exit, set, target */
8+
9+
"use strict";
10+
11+
/* eslint no-console: 0*/
12+
//------------------------------------------------------------------------------
13+
// Requirements
14+
//------------------------------------------------------------------------------
15+
16+
require("shelljs/make");
17+
set("+e");
18+
19+
const checker = require("npm-license");
20+
21+
//------------------------------------------------------------------------------
22+
// Settings
23+
//------------------------------------------------------------------------------
24+
25+
const OPEN_SOURCE_LICENSES = [
26+
/MIT/, /BSD/, /Apache/, /ISC/, /WTF/, /Public Domain/
27+
];
28+
29+
//------------------------------------------------------------------------------
30+
// Data
31+
//------------------------------------------------------------------------------
32+
33+
const NODE = "node",
34+
NODE_MODULES = "./node_modules/",
35+
36+
// Utilities - intentional extra space at the end of each string
37+
MOCHA = NODE_MODULES + "mocha/bin/_mocha ",
38+
ESLINT = `${NODE} ${NODE_MODULES}/eslint/bin/eslint `,
39+
ISTANBUL = `${NODE} ${NODE_MODULES}/istanbul/lib/cli.js `,
40+
41+
// Files
42+
MAKEFILE = "./Makefile.js",
43+
JS_FILES = "src/**/*.js",
44+
TEST_FILES = "test/**/*.js";
45+
46+
//------------------------------------------------------------------------------
47+
// Tasks
48+
//------------------------------------------------------------------------------
49+
50+
target.all = function() {
51+
target.test();
52+
};
53+
54+
target.lint = function() {
55+
var errors = 0,
56+
lastReturn;
57+
58+
echo("Validating Makefile.js");
59+
lastReturn = exec(ESLINT + MAKEFILE);
60+
if (lastReturn.code !== 0) {
61+
errors++;
62+
}
63+
64+
echo("Validating JavaScript files");
65+
lastReturn = exec(ESLINT + JS_FILES);
66+
if (lastReturn.code !== 0) {
67+
errors++;
68+
}
69+
70+
echo("Validating JavaScript test files");
71+
lastReturn = exec(ESLINT + TEST_FILES);
72+
if (lastReturn.code !== 0) {
73+
errors++;
74+
}
75+
76+
if (errors) {
77+
exit(1);
78+
}
79+
};
80+
81+
target.test = function() {
82+
target.lint();
83+
84+
var errors = 0,
85+
lastReturn;
86+
87+
lastReturn = exec(`${ISTANBUL} cover ${MOCHA} -- -R progress -c ${TEST_FILES}`);
88+
89+
if (lastReturn.code !== 0) {
90+
errors++;
91+
}
92+
93+
if (errors) {
94+
exit(1);
95+
}
96+
97+
target.checkLicenses();
98+
};
99+
100+
target.checkLicenses = function() {
101+
102+
/**
103+
* Returns true if the given dependency's licenses are all permissable for use in OSS
104+
* @param {object} dependency object containing the name and licenses of the given dependency
105+
* @returns {boolean} is permissable dependency
106+
*/
107+
function isPermissible(dependency) {
108+
var licenses = dependency.licenses;
109+
110+
if (Array.isArray(licenses)) {
111+
return licenses.some(function(license) {
112+
return isPermissible({
113+
name: dependency.name,
114+
licenses: license
115+
});
116+
});
117+
}
118+
119+
return OPEN_SOURCE_LICENSES.some(function(license) {
120+
return license.test(licenses);
121+
});
122+
}
123+
124+
echo("Validating licenses");
125+
126+
checker.init({
127+
start: __dirname
128+
}, function(deps) {
129+
var impermissible = Object.keys(deps).map(function(dependency) {
130+
return {
131+
name: dependency,
132+
licenses: deps[dependency].licenses
133+
};
134+
}).filter(function(dependency) {
135+
return !isPermissible(dependency);
136+
});
137+
138+
if (impermissible.length) {
139+
impermissible.forEach(function(dependency) {
140+
console.error("%s license for %s is impermissible.",
141+
dependency.licenses,
142+
dependency.name
143+
);
144+
});
145+
exit(1);
146+
}
147+
});
148+
};

gulpfile.js

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

package.json

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@
55
"main": "src/index.js",
66
"version": "3.6.0",
77
"engines": {
8-
"node": ">=0.4.0"
8+
"node": ">=4.0.0"
99
},
1010
"repository": "eslint/eslint-scope",
1111
"bugs": {
1212
"url": "https://github.com/eslint/eslint-scope/issues"
1313
},
1414
"license": "BSD-2-Clause",
1515
"scripts": {
16-
"test": "gulp travis",
17-
"unit-test": "gulp test",
18-
"lint": "gulp lint",
16+
"test": "node Makefile.js test",
17+
"lint": "node Makefile.js lint",
1918
"release": "eslint-release",
2019
"ci-release": "eslint-ci-release",
2120
"gh-release": "eslint-gh-release",
@@ -28,22 +27,16 @@
2827
},
2928
"devDependencies": {
3029
"chai": "^3.4.1",
30+
"eslint": "^3.15.0",
31+
"eslint-config-eslint": "^3.0.0",
3132
"eslint-release": "^0.10.1",
3233
"espree": "^3.1.1",
3334
"esprima": "^2.7.1",
34-
"gulp": "^3.9.0",
35-
"gulp-bump": "^1.0.0",
36-
"gulp-eslint": "^1.1.1",
37-
"gulp-espower": "^1.0.2",
38-
"gulp-filter": "^3.0.1",
39-
"gulp-git": "^1.6.1",
40-
"gulp-mocha": "^2.2.0",
41-
"gulp-plumber": "^1.0.1",
42-
"gulp-sourcemaps": "^1.6.0",
43-
"gulp-tag-version": "^1.3.0",
44-
"lazypipe": "^1.0.1",
45-
"vinyl-source-stream": "^1.1.0",
35+
"istanbul": "^0.4.5",
36+
"mocha": "^3.2.0",
37+
"npm-license": "^0.3.3",
38+
"shelljs": "^0.7.6",
4639
"typescript": "~2.0.10",
4740
"typescript-eslint-parser": "^1.0.0"
4841
}
49-
}
42+
}

src/definition.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*/
2424
"use strict";
2525

26-
const Variable = require('./variable');
26+
const Variable = require("./variable");
2727

2828
/**
2929
* @class Definition

0 commit comments

Comments
 (0)