From a3e2f7738f9e78df7573cd07d2f9cafce4d4f456 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Sun, 12 Feb 2017 16:19:18 -0500 Subject: [PATCH 1/6] Update top-level lint deps --- package.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index a9262568d25..63f413e4d6d 100644 --- a/package.json +++ b/package.json @@ -11,13 +11,13 @@ "test": "node packages/react-scripts/scripts/test.js --env=jsdom" }, "devDependencies": { - "babel-eslint": "6.1.2", - "eslint": "3.5.0", - "eslint-config-react-app": "0.2.1", - "eslint-plugin-flowtype": "2.18.1", - "eslint-plugin-import": "1.12.0", - "eslint-plugin-jsx-a11y": "2.2.2", - "eslint-plugin-react": "6.3.0", + "babel-eslint": "7.1.0", + "eslint": "3.8.1", + "eslint-config-react-app": "0.5.1", + "eslint-plugin-flowtype": "2.21.0", + "eslint-plugin-import": "2.0.1", + "eslint-plugin-jsx-a11y": "2.2.3", + "eslint-plugin-react": "6.4.1", "lerna": "^2.0.0-beta.37", "lerna-changelog": "^0.2.3" } From 0e8b15999b8056af3974c2ad534898c0292977cf Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Sun, 12 Feb 2017 23:23:06 -0500 Subject: [PATCH 2/6] Bump x2 --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 63f413e4d6d..f010a4aa68e 100644 --- a/package.json +++ b/package.json @@ -11,13 +11,13 @@ "test": "node packages/react-scripts/scripts/test.js --env=jsdom" }, "devDependencies": { - "babel-eslint": "7.1.0", - "eslint": "3.8.1", + "babel-eslint": "^7.1.1", + "eslint": "^3.15.0", "eslint-config-react-app": "0.5.1", - "eslint-plugin-flowtype": "2.21.0", - "eslint-plugin-import": "2.0.1", + "eslint-plugin-flowtype": "^2.30.0", + "eslint-plugin-import": "^2.2.0", "eslint-plugin-jsx-a11y": "2.2.3", - "eslint-plugin-react": "6.4.1", + "eslint-plugin-react": "^6.9.0", "lerna": "^2.0.0-beta.37", "lerna-changelog": "^0.2.3" } From 8e1e2242fdd245cb19cdf8423caf7cd63b7f245e Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Mon, 13 Feb 2017 10:36:07 -0500 Subject: [PATCH 3/6] Bump deps, treat warnings as failures, and fix linter problems --- package.json | 4 ++-- packages/babel-preset-react-app/index.js | 2 ++ packages/create-react-app/index.js | 1 + packages/react-dev-utils/InterpolateHtmlPlugin.js | 1 + packages/react-dev-utils/WatchMissingNodeModulesPlugin.js | 1 + packages/react-dev-utils/formatWebpackMessages.js | 2 +- packages/react-scripts/bin/react-scripts.js | 4 ++-- packages/react-scripts/config/webpack.config.prod.js | 1 - .../react-scripts/fixtures/kitchensink/integration/initDOM.js | 2 +- tasks/e2e-simple.sh | 2 +- tasks/replace-own-deps.js | 2 ++ 11 files changed, 14 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index f010a4aa68e..48773ac0167 100644 --- a/package.json +++ b/package.json @@ -13,10 +13,10 @@ "devDependencies": { "babel-eslint": "^7.1.1", "eslint": "^3.15.0", - "eslint-config-react-app": "0.5.1", + "eslint-config-react-app": "^0.5.1", "eslint-plugin-flowtype": "^2.30.0", "eslint-plugin-import": "^2.2.0", - "eslint-plugin-jsx-a11y": "2.2.3", + "eslint-plugin-jsx-a11y": "^2.2.3", "eslint-plugin-react": "^6.9.0", "lerna": "^2.0.0-beta.37", "lerna-changelog": "^0.2.3" diff --git a/packages/babel-preset-react-app/index.js b/packages/babel-preset-react-app/index.js index 8a42f885e31..885cf4be345 100644 --- a/packages/babel-preset-react-app/index.js +++ b/packages/babel-preset-react-app/index.js @@ -6,6 +6,8 @@ * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ + +// eslint-disable-next-line 'use strict'; var path = require('path'); diff --git a/packages/create-react-app/index.js b/packages/create-react-app/index.js index 4dbb37f4969..d03bdf53555 100644 --- a/packages/create-react-app/index.js +++ b/packages/create-react-app/index.js @@ -36,6 +36,7 @@ // /!\ DO NOT MODIFY THIS FILE /!\ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// eslint-disable-next-line 'use strict'; var chalk = require('chalk'); diff --git a/packages/react-dev-utils/InterpolateHtmlPlugin.js b/packages/react-dev-utils/InterpolateHtmlPlugin.js index 07558f47830..a50df3e2d11 100644 --- a/packages/react-dev-utils/InterpolateHtmlPlugin.js +++ b/packages/react-dev-utils/InterpolateHtmlPlugin.js @@ -15,6 +15,7 @@ // Learn more about creating plugins like this: // https://github.com/ampedandwired/html-webpack-plugin#events +// eslint-disable-next-line 'use strict'; const escapeStringRegexp = require('escape-string-regexp'); diff --git a/packages/react-dev-utils/WatchMissingNodeModulesPlugin.js b/packages/react-dev-utils/WatchMissingNodeModulesPlugin.js index 91b089c05ef..fb8d2a8f3b1 100644 --- a/packages/react-dev-utils/WatchMissingNodeModulesPlugin.js +++ b/packages/react-dev-utils/WatchMissingNodeModulesPlugin.js @@ -11,6 +11,7 @@ // We’re not sure why this isn't Webpack's default behavior. // See https://github.com/facebookincubator/create-react-app/issues/186. +// eslint-disable-next-line 'use strict'; class WatchMissingNodeModulesPlugin { diff --git a/packages/react-dev-utils/formatWebpackMessages.js b/packages/react-dev-utils/formatWebpackMessages.js index 88834a9fc62..bb0d0e8dae4 100644 --- a/packages/react-dev-utils/formatWebpackMessages.js +++ b/packages/react-dev-utils/formatWebpackMessages.js @@ -106,7 +106,7 @@ function formatMessage(message) { // from user code generated by WebPack. For more information see // https://github.com/facebookincubator/create-react-app/pull/1050 message = message.replace( - /^\s*at\s((?!webpack:).)*:\d+:\d+[\s\)]*(\n|$)/gm, '' + /^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm, '' ); // at ... ...:x:y return message; diff --git a/packages/react-scripts/bin/react-scripts.js b/packages/react-scripts/bin/react-scripts.js index 5ed9b244ca6..e614d9b598e 100755 --- a/packages/react-scripts/bin/react-scripts.js +++ b/packages/react-scripts/bin/react-scripts.js @@ -14,13 +14,13 @@ case 'test': {stdio: 'inherit'} ); if (result.signal) { - if (result.signal == 'SIGKILL') { + if (result.signal === 'SIGKILL') { console.log( 'The build failed because the process exited too early. ' + 'This probably means the system ran out of memory or someone called ' + '`kill -9` on the process.' ); - } else if (result.signal == 'SIGTERM') { + } else if (result.signal === 'SIGTERM') { console.log( 'The build failed because the process exited too early. ' + 'Someone might have called `kill` or `killall`, or the system could ' + diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 86d87d39211..3debc4d01c1 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -15,7 +15,6 @@ var HtmlWebpackPlugin = require('html-webpack-plugin'); var ExtractTextPlugin = require('extract-text-webpack-plugin'); var ManifestPlugin = require('webpack-manifest-plugin'); var InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin'); -var url = require('url'); var paths = require('./paths'); var getClientEnvironment = require('./env'); diff --git a/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js b/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js index 7cf8134b79f..9b6049104f9 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js @@ -15,7 +15,7 @@ if (process.env.E2E_FILE) { const markup = fs.readFileSync(file, 'utf8') getMarkup = () => markup - const pathPrefix = process.env.PUBLIC_URL.replace(/^https?:\/\/[^\/]+\/?/, '') + const pathPrefix = process.env.PUBLIC_URL.replace(/^https?:\/\/[^/]+\/?/, '') resourceLoader = (resource, callback) => callback( null, diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index 20aa16293e0..c8304878c3e 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -83,7 +83,7 @@ then fi # Lint own code -./node_modules/.bin/eslint --ignore-path .gitignore ./ +./node_modules/.bin/eslint --max-warnings 0 --ignore-path .gitignore ./ # ****************************************************************************** # First, test the create-react-app development environment. diff --git a/tasks/replace-own-deps.js b/tasks/replace-own-deps.js index 23a3f4a01fe..0a0018f76e8 100755 --- a/tasks/replace-own-deps.js +++ b/tasks/replace-own-deps.js @@ -7,6 +7,8 @@ * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ + +// eslint-disable-next-line 'use strict'; // Replaces internal dependencies in package.json with local package paths. From 4a472ca1149e6d2740b584c70914fa9f151e00ea Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Mon, 13 Feb 2017 13:48:20 -0500 Subject: [PATCH 4/6] Switch to default mode --- .eslintrc | 3 --- .eslintrc.json | 14 ++++++++++++++ packages/babel-preset-react-app/index.js | 1 - packages/eslint-config-react-app/index.js | 2 ++ packages/react-dev-utils/InterpolateHtmlPlugin.js | 2 +- .../WatchMissingNodeModulesPlugin.js | 1 - packages/react-dev-utils/checkRequiredFiles.js | 2 ++ packages/react-dev-utils/clearConsole.js | 2 ++ packages/react-dev-utils/formatWebpackMessages.js | 2 ++ packages/react-dev-utils/getProcessForPort.js | 3 ++- packages/react-dev-utils/openBrowser.js | 2 ++ packages/react-dev-utils/prompt.js | 2 ++ packages/react-dev-utils/webpackHotDevClient.js | 4 +++- tasks/replace-own-deps.js | 1 - 14 files changed, 32 insertions(+), 9 deletions(-) delete mode 100644 .eslintrc create mode 100644 .eslintrc.json diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 5e603ecd193..00000000000 --- a/.eslintrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "react-app" -} diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 00000000000..1c62c3b8508 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,14 @@ +{ + "extends": "react-app", + "parserOptions": { + "ecmaVersion": 5, + "sourceType": "default", + "ecmaFeatures": { + "jsx": false, + "generators": true + } + }, + "rules": { + "strict": ["warn", "safe"] + } +} diff --git a/packages/babel-preset-react-app/index.js b/packages/babel-preset-react-app/index.js index 885cf4be345..2c326694bf1 100644 --- a/packages/babel-preset-react-app/index.js +++ b/packages/babel-preset-react-app/index.js @@ -7,7 +7,6 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -// eslint-disable-next-line 'use strict'; var path = require('path'); diff --git a/packages/eslint-config-react-app/index.js b/packages/eslint-config-react-app/index.js index d93478bc8c9..0d787a67fc5 100644 --- a/packages/eslint-config-react-app/index.js +++ b/packages/eslint-config-react-app/index.js @@ -16,6 +16,8 @@ // In the future, we might create a separate list of rules for production. // It would probably be more strict. +'use strict'; + module.exports = { root: true, diff --git a/packages/react-dev-utils/InterpolateHtmlPlugin.js b/packages/react-dev-utils/InterpolateHtmlPlugin.js index a50df3e2d11..d9f5aae00d3 100644 --- a/packages/react-dev-utils/InterpolateHtmlPlugin.js +++ b/packages/react-dev-utils/InterpolateHtmlPlugin.js @@ -15,8 +15,8 @@ // Learn more about creating plugins like this: // https://github.com/ampedandwired/html-webpack-plugin#events -// eslint-disable-next-line 'use strict'; + const escapeStringRegexp = require('escape-string-regexp'); class InterpolateHtmlPlugin { diff --git a/packages/react-dev-utils/WatchMissingNodeModulesPlugin.js b/packages/react-dev-utils/WatchMissingNodeModulesPlugin.js index fb8d2a8f3b1..91b089c05ef 100644 --- a/packages/react-dev-utils/WatchMissingNodeModulesPlugin.js +++ b/packages/react-dev-utils/WatchMissingNodeModulesPlugin.js @@ -11,7 +11,6 @@ // We’re not sure why this isn't Webpack's default behavior. // See https://github.com/facebookincubator/create-react-app/issues/186. -// eslint-disable-next-line 'use strict'; class WatchMissingNodeModulesPlugin { diff --git a/packages/react-dev-utils/checkRequiredFiles.js b/packages/react-dev-utils/checkRequiredFiles.js index 69233db4837..55139b0b870 100644 --- a/packages/react-dev-utils/checkRequiredFiles.js +++ b/packages/react-dev-utils/checkRequiredFiles.js @@ -7,6 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +'use strict'; + var fs = require('fs'); var path = require('path'); var chalk = require('chalk'); diff --git a/packages/react-dev-utils/clearConsole.js b/packages/react-dev-utils/clearConsole.js index cfd10155167..74336284723 100644 --- a/packages/react-dev-utils/clearConsole.js +++ b/packages/react-dev-utils/clearConsole.js @@ -7,6 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +'use strict'; + function clearConsole() { process.stdout.write(process.platform === 'win32' ? '\x1Bc' : '\x1B[2J\x1B[3J\x1B[H'); } diff --git a/packages/react-dev-utils/formatWebpackMessages.js b/packages/react-dev-utils/formatWebpackMessages.js index bb0d0e8dae4..c697efc9fc0 100644 --- a/packages/react-dev-utils/formatWebpackMessages.js +++ b/packages/react-dev-utils/formatWebpackMessages.js @@ -14,6 +14,8 @@ // This is quite hacky and hopefully won't be needed when Webpack fixes this. // https://github.com/webpack/webpack/issues/2878 +'use strict'; + var friendlySyntaxErrorLabel = 'Syntax error:'; function isLikelyASyntaxError(message) { diff --git a/packages/react-dev-utils/getProcessForPort.js b/packages/react-dev-utils/getProcessForPort.js index 5540fbad47a..80e78848d68 100644 --- a/packages/react-dev-utils/getProcessForPort.js +++ b/packages/react-dev-utils/getProcessForPort.js @@ -1,3 +1,5 @@ +'use strict'; + var chalk = require('chalk'); var execSync = require('child_process').execSync; var path = require('path'); @@ -58,4 +60,3 @@ function getProcessForPort(port) { } module.exports = getProcessForPort; - diff --git a/packages/react-dev-utils/openBrowser.js b/packages/react-dev-utils/openBrowser.js index a3623515e0a..6041dc4ffbc 100644 --- a/packages/react-dev-utils/openBrowser.js +++ b/packages/react-dev-utils/openBrowser.js @@ -7,6 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ + 'use strict'; + var execSync = require('child_process').execSync; var opn = require('opn'); diff --git a/packages/react-dev-utils/prompt.js b/packages/react-dev-utils/prompt.js index 4b1faf9bac8..fd0ca46e5d9 100644 --- a/packages/react-dev-utils/prompt.js +++ b/packages/react-dev-utils/prompt.js @@ -7,6 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +'use strict'; + var rl = require('readline'); // Convention: "no" should be the conservative choice. diff --git a/packages/react-dev-utils/webpackHotDevClient.js b/packages/react-dev-utils/webpackHotDevClient.js index 7b1768d8fa0..c2ab5b12953 100644 --- a/packages/react-dev-utils/webpackHotDevClient.js +++ b/packages/react-dev-utils/webpackHotDevClient.js @@ -16,6 +16,8 @@ // that looks similar to our console output. The error overlay is inspired by: // https://github.com/glenjamin/webpack-hot-middleware +'use strict'; + var ansiHTML = require('ansi-html'); var SockJS = require('sockjs-client'); var stripAnsi = require('strip-ansi'); @@ -123,7 +125,7 @@ function showErrorOverlay(message) { }); } -function destroyErrorOverlay() { +function destroyErrorOverlay() { if (!overlayDiv) { // It is not there in the first place. return; diff --git a/tasks/replace-own-deps.js b/tasks/replace-own-deps.js index 0a0018f76e8..1e3acd9cfb2 100755 --- a/tasks/replace-own-deps.js +++ b/tasks/replace-own-deps.js @@ -8,7 +8,6 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -// eslint-disable-next-line 'use strict'; // Replaces internal dependencies in package.json with local package paths. From 8a8ffc128dc53d961b6e525cd2d2d73986314ed0 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Mon, 13 Feb 2017 13:55:01 -0500 Subject: [PATCH 5/6] Drop unneeded line --- packages/create-react-app/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/create-react-app/index.js b/packages/create-react-app/index.js index d03bdf53555..4dbb37f4969 100644 --- a/packages/create-react-app/index.js +++ b/packages/create-react-app/index.js @@ -36,7 +36,6 @@ // /!\ DO NOT MODIFY THIS FILE /!\ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// eslint-disable-next-line 'use strict'; var chalk = require('chalk'); From 1e7d163becb24977087f8a77545015ef2a854380 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Mon, 13 Feb 2017 16:11:34 -0500 Subject: [PATCH 6/6] implied strict: false --- .eslintrc.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 1c62c3b8508..a1d904f65bd 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -2,10 +2,11 @@ "extends": "react-app", "parserOptions": { "ecmaVersion": 5, - "sourceType": "default", + "sourceType": "script", "ecmaFeatures": { "jsx": false, - "generators": true + "generators": true, + "impliedStrict": false } }, "rules": {