Skip to content

Commit 7a4810c

Browse files
committed
Move eslint to jest
1 parent ff3ef5e commit 7a4810c

File tree

6 files changed

+291
-38
lines changed

6 files changed

+291
-38
lines changed

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
**/*.*
33

44
# Enable prettier for the following paths.
5+
!*.js
56
!setup/**/*.js
67
!lib/**/*.js
78
!bin/*.js

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ cache:
1111
yarn: true
1212
directories:
1313
- ".jest-cache"
14-
- ".eslintcache"
1514

1615
stages:
1716
- basic

lint-jest.config.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
const base = {
2+
watchPathIgnorePatterns: [
3+
"<rootDir>/.git",
4+
"<rootDir>/node_modules",
5+
"<rootDir>/test/js",
6+
"<rootDir>/test/browsertest/js",
7+
"<rootDir>/test/fixtures",
8+
"<rootDir>/benchmark",
9+
"<rootDir>/examples/*/dist",
10+
"<rootDir>/coverage",
11+
"<rootDir>/.eslintcache"
12+
],
13+
modulePathIgnorePatterns: [
14+
"<rootDir>/.git",
15+
"<rootDir>/node_modules/webpack/node_modules",
16+
"<rootDir>/test/js",
17+
"<rootDir>/test/browsertest/js",
18+
"<rootDir>/test/fixtures/temp-cache-fixture",
19+
"<rootDir>/test/fixtures/temp-",
20+
"<rootDir>/benchmark",
21+
"<rootDir>/examples/*/dist",
22+
"<rootDir>/coverage",
23+
"<rootDir>/.eslintcache"
24+
],
25+
transformIgnorePatterns: ["<rootDir>"]
26+
};
27+
28+
module.exports = {
29+
reporters: ["<rootDir>/tooling/DotReporter.js"],
30+
projects: [
31+
Object.assign({}, base, {
32+
runner: "jest-runner-eslint",
33+
displayName: "eslint",
34+
testMatch: [
35+
"<rootDir>/*.js",
36+
"<rootDir>/setup/**/*.js",
37+
"<rootDir>/lib/**/*.js",
38+
"<rootDir>/bin/**/*.js",
39+
"<rootDir>/hot/**/*.js",
40+
"<rootDir>/buildin/**/*.js",
41+
"<rootDir>/benchmark/**/*.js",
42+
"<rootDir>/tooling/**/*.js",
43+
"<rootDir>/test/*.js",
44+
"<rootDir>/test/**/webpack.config.js",
45+
"<rootDir>/examples/**/webpack.config.js",
46+
"<rootDir>/schemas/**/*.js"
47+
]
48+
}),
49+
Object.assign({}, base, {
50+
displayName: "lint",
51+
testMatch: ["<rootDir>/test/*.lint.js"]
52+
})
53+
]
54+
};

package.json

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"jade": "^1.11.0",
5858
"jade-loader": "~0.8.0",
5959
"jest": "^23.4.1",
60+
"jest-runner-eslint": "^0.6.0",
6061
"jest-silent-reporter": "^0.0.5",
6162
"json-loader": "^0.5.7",
6263
"less": "^2.5.1",
@@ -120,11 +121,10 @@
120121
"pretest": "yarn lint",
121122
"prelint": "yarn setup",
122123
"lint": "yarn code-lint && yarn schema-lint && yarn type-lint",
123-
"code-lint": "eslint --cache setup lib bin hot buildin benchmark tooling \"test/*.js\" \"test/**/webpack.config.js\" \"examples/**/webpack.config.js\" \"schemas/**/*.js\"",
124+
"code-lint": "yarn jest --config lint-jest.config.js",
124125
"type-lint": "tsc --pretty",
125126
"fix": "yarn code-lint --fix",
126127
"pretty": "prettier --write \"setup/**/*.js\" \"lib/**/*.js\" \"bin/*.js\" \"hot/*.js\" \"buildin/*.js\" \"benchmark/**/*.js\" \"tooling/*.js\" \"test/*.js\" \"test/**/webpack.config.js\" \"examples/**/webpack.config.js\" \"schemas/**/*.js\" \"declarations.d.ts\" \"tsconfig.json\"",
127-
"schema-lint": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.lint.js\" --no-verbose",
128128
"benchmark": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.benchmark.js\" --runInBand",
129129
"cover": "yarn cover:init && yarn cover:all && yarn cover:report",
130130
"cover:init": "rimraf coverage",
@@ -139,9 +139,15 @@
139139
}
140140
},
141141
"lint-staged": {
142-
"lib/**/*.js": [
143-
"eslint --cache"
144-
]
142+
"linters": {
143+
"*.js|{lib,setup,bin,hot,buildin,tooling,schemas}/**/*.js|test/*.js|{test,examples}/**/webpack.config.js}": [
144+
"node node_modules/jest-cli/bin/jest --config lint-jest.config.js --findRelatedTests"
145+
]
146+
},
147+
"globOptions": {
148+
"unixify": true,
149+
"dot": true
150+
}
145151
},
146152
"jest": {
147153
"forceExit": true,
@@ -151,36 +157,38 @@
151157
"<rootDir>/test/*.unittest.js"
152158
],
153159
"watchPathIgnorePatterns": [
154-
"<rootDir>/node_modules/webpack/node_modules/",
155-
"<rootDir>/test/js/",
156-
"<rootDir>/test/browsertest/js/",
157-
"<rootDir>/test/fixtures/temp-cache-fixture/",
160+
"<rootDir>/.git",
161+
"<rootDir>/node_modules",
162+
"<rootDir>/test/js",
163+
"<rootDir>/test/browsertest/js",
164+
"<rootDir>/test/fixtures/temp-cache-fixture",
158165
"<rootDir>/test/fixtures/temp-",
159-
"<rootDir>/benchmark/",
166+
"<rootDir>/benchmark",
160167
"<rootDir>/examples/*/dist",
161-
"<rootDir>/coverage/",
162-
"<rootDir>/.eslintcache/"
168+
"<rootDir>/coverage",
169+
"<rootDir>/.eslintcache"
163170
],
164171
"modulePathIgnorePatterns": [
165-
"<rootDir>/node_modules/webpack/node_modules/",
166-
"<rootDir>/test/js/",
167-
"<rootDir>/test/browsertest/js/",
168-
"<rootDir>/test/fixtures/temp-cache-fixture/",
172+
"<rootDir>/.git",
173+
"<rootDir>/node_modules/webpack/node_modules",
174+
"<rootDir>/test/js",
175+
"<rootDir>/test/browsertest/js",
176+
"<rootDir>/test/fixtures/temp-cache-fixture",
169177
"<rootDir>/test/fixtures/temp-",
170-
"<rootDir>/benchmark/",
178+
"<rootDir>/benchmark",
171179
"<rootDir>/examples/*/dist",
172-
"<rootDir>/coverage/",
173-
"<rootDir>/.eslintcache/"
180+
"<rootDir>/coverage",
181+
"<rootDir>/.eslintcache"
174182
],
175183
"transformIgnorePatterns": [
176-
"<rootDir>/"
184+
"<rootDir>"
177185
],
178186
"coverageDirectory": "<rootDir>/coverage",
179187
"coveragePathIgnorePatterns": [
180188
"\\.runtime\\.js$",
181-
"<rootDir>/test/",
182-
"<rootDir>/schemas/",
183-
"<rootDir>/node_modules/"
189+
"<rootDir>/test",
190+
"<rootDir>/schemas",
191+
"<rootDir>/node_modules"
184192
],
185193
"testEnvironment": "node",
186194
"coverageReporters": [

tooling/DotReporter.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
const lastResults = new Map();
2+
3+
class DotReporter {
4+
constructor() {
5+
this.lineStarted = true;
6+
}
7+
8+
onRunStart() {
9+
process.stdout.write("\nRunning...");
10+
}
11+
12+
onRunComplete() {
13+
if (this.lineStarted) {
14+
console.log();
15+
this.lineStarted = false;
16+
}
17+
}
18+
19+
onTestResult(test, testResult, aggregatedResult) {
20+
const lastResult = lastResults.get(test.path);
21+
if (testResult.failureMessage) {
22+
if (this.lineStarted) {
23+
console.log();
24+
this.lineStarted = false;
25+
}
26+
console.log(testResult.failureMessage);
27+
lastResults.set(test.path, testResult.failureMessage);
28+
} else {
29+
if (lastResult) {
30+
if (this.lineStarted) {
31+
console.log();
32+
this.lineStarted = false;
33+
}
34+
console.log(`\u001b[1m\u001b[32m${test.path} ok\u001b[39m\u001b[22m`);
35+
} else {
36+
process.stdout.write(".");
37+
this.lineStarted = true;
38+
}
39+
}
40+
}
41+
}
42+
43+
module.exports = DotReporter;

0 commit comments

Comments
 (0)