Skip to content

Commit aba83cf

Browse files
committed
bug #732 feat: add ESLint 6 support (Kocal)
This PR was squashed before being merged into the master branch. Discussion ---------- feat: add ESLint 6 support Someone on Slack had an issue with Encore and ESLint 6: ![Capture d’écran de 2020-04-17 22-12-29](https://user-images.githubusercontent.com/2103975/79610285-8df35280-80f8-11ea-8175-5c9962478a69.png) `CLIEngine#config` does not exists on ESLint 6 anymore, since [6ae21a4b](eslint/eslint@6ae21a4#diff-3daec82d5218d64d8f2fed4d21f8e6ccL472-L486). Now we can use [`CLIEngine#getConfigForFile`](https://eslint.org/docs/developer-guide/nodejs-api#cliengine-getconfigforfile) to get the ESLint configuration. Encore now supports both ESLint 5 and 6. cc @a-menshchikov 😄 Commits ------- aa8353f feat: add ESLint 6 support
2 parents bdd6908 + aa8353f commit aba83cf

File tree

3 files changed

+207
-91
lines changed

3 files changed

+207
-91
lines changed

lib/loaders/eslint.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
const WebpackConfig = require('../WebpackConfig'); //eslint-disable-line no-unused-vars
1313
const loaderFeatures = require('../features');
1414
const applyOptionsCallback = require('../utils/apply-options-callback');
15+
const logger = require('../logger');
1516

1617
function isMissingConfigError(e) {
1718
if (!e.message || !e.message.includes('No ESLint configuration found')) {
@@ -35,7 +36,13 @@ module.exports = {
3536
});
3637

3738
try {
38-
engine.config.getConfigHierarchy(webpackConfig.runtimeConfig.context);
39+
if (typeof engine.getConfigForFile === 'function') {
40+
logger.debug('Checking ESLint 6+ configuration...');
41+
engine.getConfigForFile('webpack.config.js');
42+
} else {
43+
logger.debug('Checking ESLint 5 configuration...');
44+
engine.config.getConfigHierarchy(webpackConfig.runtimeConfig.context);
45+
}
3946
} catch (e) {
4047
if (isMissingConfigError(e)) {
4148
const chalk = require('chalk').default;

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"chai-fs": "^1.0.0",
6767
"chai-subset": "^1.6.0",
6868
"core-js": "^3.0.0",
69-
"eslint": "^5.15.2",
69+
"eslint": "^5.15.2 || ^6.0.0",
7070
"eslint-loader": "^2.1.2",
7171
"eslint-plugin-header": "^1.0.0",
7272
"eslint-plugin-import": "^2.8.0",

0 commit comments

Comments
 (0)