Skip to content

Commit a452a0f

Browse files
author
Devon Jue
committed
added react-scripts lint & e2e test
1 parent f495c15 commit a452a0f

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

packages/react-scripts/bin/react-scripts.js

+26
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,32 @@ switch (script) {
4343
process.exit(result.status);
4444
break;
4545
}
46+
case 'lint': {
47+
let eslintConfigPath;
48+
49+
try {
50+
eslintConfigPath = require.resolve('eslint-config-react-app');
51+
} catch (e) {
52+
eslintConfigPath = require.resolve('../../../package.json');
53+
}
54+
55+
const results = spawn(
56+
'node',
57+
[
58+
require.resolve('eslint/bin/eslint'),
59+
'--config',
60+
eslintConfigPath,
61+
'src/**/*.{js,jsx}',
62+
],
63+
{ stdio: 'inherit' }
64+
);
65+
66+
results.on('error', err => {
67+
console.log('Error running ESLint: ' + err);
68+
process.exit(results.status);
69+
});
70+
break;
71+
}
4672
default:
4773
console.log('Unknown script "' + script + '".');
4874
console.log('Perhaps you need to update react-scripts?');

tasks/e2e-simple.sh

+6
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,9 @@ function verify_module_scope {
278278
# Enter the app directory
279279
cd test-app
280280

281+
# Test lint
282+
./node_modules/.bin/react-scripts lint
283+
281284
# Test the build
282285
npm run build
283286
# Check for expected output
@@ -314,6 +317,9 @@ npm link "$root_path"/packages/eslint-config-react-app
314317
npm link "$root_path"/packages/react-dev-utils
315318
npm link "$root_path"/packages/react-scripts
316319

320+
# Test lint
321+
"$root_path"/packages/react-scripts/bin/react-scripts.js lint
322+
317323
# Test the build
318324
npm run build
319325
# Check for expected output

0 commit comments

Comments
 (0)