From a452a0fb9fa7e67fcdca075d2598958162f2636a Mon Sep 17 00:00:00 2001 From: Devon Jue Date: Thu, 6 Jul 2017 01:09:07 -0700 Subject: [PATCH] added react-scripts lint & e2e test --- packages/react-scripts/bin/react-scripts.js | 26 +++++++++++++++++++++ tasks/e2e-simple.sh | 6 +++++ 2 files changed, 32 insertions(+) diff --git a/packages/react-scripts/bin/react-scripts.js b/packages/react-scripts/bin/react-scripts.js index cb52fe71b09..5e9a65d800e 100755 --- a/packages/react-scripts/bin/react-scripts.js +++ b/packages/react-scripts/bin/react-scripts.js @@ -43,6 +43,32 @@ switch (script) { process.exit(result.status); break; } + case 'lint': { + let eslintConfigPath; + + try { + eslintConfigPath = require.resolve('eslint-config-react-app'); + } catch (e) { + eslintConfigPath = require.resolve('../../../package.json'); + } + + const results = spawn( + 'node', + [ + require.resolve('eslint/bin/eslint'), + '--config', + eslintConfigPath, + 'src/**/*.{js,jsx}', + ], + { stdio: 'inherit' } + ); + + results.on('error', err => { + console.log('Error running ESLint: ' + err); + process.exit(results.status); + }); + break; + } default: console.log('Unknown script "' + script + '".'); console.log('Perhaps you need to update react-scripts?'); diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index 48d705eef4c..ee010f372d7 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -278,6 +278,9 @@ function verify_module_scope { # Enter the app directory cd test-app +# Test lint +./node_modules/.bin/react-scripts lint + # Test the build npm run build # Check for expected output @@ -314,6 +317,9 @@ npm link "$root_path"/packages/eslint-config-react-app npm link "$root_path"/packages/react-dev-utils npm link "$root_path"/packages/react-scripts +# Test lint +"$root_path"/packages/react-scripts/bin/react-scripts.js lint + # Test the build npm run build # Check for expected output