Skip to content

Commit

Permalink
Lint internal scripts with eslint:recommended (facebook#1729)
Browse files Browse the repository at this point in the history
* Lint internal scripts with eslint:recommended

* Warnings r bad
  • Loading branch information
gaearon authored and randycoulman committed May 8, 2017
1 parent 22f40e4 commit 51b6886
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 14 deletions.
15 changes: 14 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
{
"extends": "react-app"
"extends": "eslint:recommended",
"env": {
"browser": true,
"commonjs": true,
"node": true,
"es6": true
},
"parserOptions": {
"ecmaVersion": 6
},
"rules": {
"no-console": "off",
"strict": ["error", "global"]
}
}
6 changes: 0 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@
"test": "node packages/react-scripts/scripts/test.js --env=jsdom"
},
"devDependencies": {
"babel-eslint": "7.1.0",
"eslint": "3.16.1",
"eslint-config-react-app": "0.5.1",
"eslint-plugin-flowtype": "2.21.0",
"eslint-plugin-import": "2.0.1",
"eslint-plugin-jsx-a11y": "4.0.0",
"eslint-plugin-react": "6.4.1",
"lerna": "2.0.0-beta.38",
"lerna-changelog": "^0.2.3"
}
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-config-react-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/

'use strict';

// Inspired by https://github.com/airbnb/javascript but less opinionated.

// We use eslint-loader so even warnings are very visible.
Expand Down
2 changes: 2 additions & 0 deletions packages/react-dev-utils/checkRequiredFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 2 additions & 0 deletions packages/react-dev-utils/clearConsole.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
2 changes: 2 additions & 0 deletions packages/react-dev-utils/formatWebpackMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/

'use strict';

// WARNING: this code is untranspiled and is used in browser too.
// Please make sure any changes are in ES5 or contribute a Babel compile step.

Expand Down
11 changes: 11 additions & 0 deletions packages/react-dev-utils/getProcessForPort.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* 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.
*/

'use strict';

var chalk = require('chalk');
var execSync = require('child_process').execSync;
var path = require('path');
Expand Down
2 changes: 2 additions & 0 deletions packages/react-dev-utils/openBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
4 changes: 3 additions & 1 deletion packages/react-dev-utils/prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -37,6 +39,6 @@ function prompt(question, isYesDefault) {
return resolve(isYes);
});
});
};
}

module.exports = prompt;
4 changes: 3 additions & 1 deletion packages/react-dev-utils/webpackHotDevClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/

'use strict';

// This alternative WebpackDevServer combines the functionality of:
// https://github.com/webpack/webpack-dev-server/blob/webpack-1/client/index.js
// https://github.com/webpack/webpack/blob/webpack-1/hot/dev-server.js
Expand Down Expand Up @@ -319,4 +321,4 @@ function tryApplyUpdates(onHotUpdateSuccess) {
}
);
}
};
}
4 changes: 2 additions & 2 deletions packages/react-scripts/bin/react-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ' +
Expand Down
1 change: 0 additions & 1 deletion packages/react-scripts/config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tasks/e2e-simple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,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.
Expand Down

0 comments on commit 51b6886

Please sign in to comment.