Skip to content

Commit bc81331

Browse files
committed
eslintrc
1 parent 33afd1a commit bc81331

File tree

5 files changed

+42
-6
lines changed

5 files changed

+42
-6
lines changed

.eslintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"es6": true
88
},
99
"parserOptions": {
10-
"ecmaVersion": 6
10+
"ecmaVersion": 9
1111
},
1212
"rules": {
1313
"no-console": "off",

packages/react-scripts/config/paths.js

+4
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ module.exports = {
8989
customWebpackProdConfig: resolveApp('config/webpack.config.prod.js'),
9090
// rewired webpack devServer config
9191
customWebpackDevServerConfig: resolveApp('config/webpackDevServer.config.js'),
92+
// eslintrc
93+
eslintrcPath: resolveApp('.'),
9294
};
9395

9496
const ownPackageJson = require('../package.json');
@@ -129,6 +131,8 @@ if (
129131
customWebpackDevServerConfig: resolveOwn(
130132
'template/config/webpackDevServer.config.js'
131133
),
134+
// eslintrc
135+
eslintrcPath: resolveOwn('template'),
132136
};
133137
}
134138
// @remove-on-eject-end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// @remove-file-on-eject
2+
'use strict';
3+
const fs = require('fs');
4+
const path = require('path');
5+
const paths = require('../paths');
6+
7+
const CONFIG_FILES = [
8+
'.eslintrc.js',
9+
'.eslintrc.yaml',
10+
'.eslintrc.yml',
11+
'.eslintrc.json',
12+
'.eslintrc',
13+
];
14+
15+
function existsConfigFile() {
16+
return CONFIG_FILES.some(configFile => {
17+
const filename = path.resolve(paths.eslintrcPath, configFile);
18+
19+
return fs.existsSync(filename) && fs.statSync(filename).isFile();
20+
});
21+
}
22+
23+
module.exports = !!(
24+
existsConfigFile() || require(paths.appPackageJson).eslintConfig
25+
);

packages/react-scripts/config/webpack.config.dev.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,15 @@ module.exports = {
132132
formatter: eslintFormatter,
133133
eslintPath: require.resolve('eslint'),
134134
// @remove-on-eject-begin
135-
baseConfig: {
136-
extends: [require.resolve('eslint-config-react-app')],
137-
},
138-
ignore: false,
139-
useEslintrc: false,
135+
...(require('./utils/useEslintrc')
136+
? undefined
137+
: {
138+
baseConfig: {
139+
extends: [require.resolve('eslint-config-react-app')],
140+
},
141+
ignore: false,
142+
useEslintrc: false,
143+
}),
140144
// @remove-on-eject-end
141145
},
142146
loader: require.resolve('eslint-loader'),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "react-app"
3+
}

0 commit comments

Comments
 (0)