Skip to content

Commit 6ffacd0

Browse files
Use ESLint cache to speedup watch (#1746)
1 parent 072b14d commit 6ffacd0

File tree

2 files changed

+4
-25
lines changed

2 files changed

+4
-25
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# https://www.gitignore.io/
77

88
.nyc_output
9+
.eslintcache
910
node_modules
1011
coverage
1112
dist

resources/watch.js

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function checkFiles(filepaths) {
9696

9797
return runTests(filepaths)
9898
.then(testSuccess =>
99-
lintFiles(filepaths).then(lintSuccess =>
99+
lintFiles().then(lintSuccess =>
100100
typecheckStatus().then(
101101
typecheckSuccess => testSuccess && lintSuccess && typecheckSuccess
102102
)
@@ -124,27 +124,9 @@ function runTests(filepaths) {
124124
).catch(() => false);
125125
}
126126

127-
function lintFiles(filepaths) {
127+
function lintFiles() {
128128
console.log('Linting Code\n');
129-
130-
return filepaths.reduce(
131-
(prev, filepath) =>
132-
prev.then(prevSuccess => {
133-
if (isJS(filepath)) {
134-
process.stdout.write(' ' + filepath + ' ...');
135-
return exec('eslint', [srcPath(filepath)])
136-
.catch(() => false)
137-
.then(success => {
138-
console.log(
139-
CLEARLINE + ' ' + (success ? CHECK : X) + ' ' + filepath
140-
);
141-
return prevSuccess && success;
142-
});
143-
}
144-
return prevSuccess;
145-
}),
146-
Promise.resolve(true)
147-
);
129+
return exec('eslint', ['--cache', 'src/']).catch(() => false);
148130
}
149131

150132
function typecheckStatus() {
@@ -160,10 +142,6 @@ function srcPath(filepath) {
160142

161143
// Predicates
162144

163-
function isJS(filepath) {
164-
return filepath.indexOf('.js') === filepath.length - 3;
165-
}
166-
167145
function allTests(filepaths) {
168146
return filepaths.length > 0 && filepaths.every(isTest);
169147
}

0 commit comments

Comments
 (0)