Skip to content

Commit

Permalink
feature #774 feat: add support for ESLint 7, drop support ESLint 5 (K…
Browse files Browse the repository at this point in the history
…ocal)

This PR was squashed before being merged into the main branch.

Discussion
----------

feat: add support for ESLint 7, drop support ESLint 5

- bump eslint from `^5.15.2 || ^6.0.0` to `^6.0.0 || ^7.0.0`: https://eslint.org/blog/2020/05/eslint-v7.0.0-released
- bump eslint-loader from `^3.0.0` to `^4.0.0`, which drop support for Node <10.13.0 and set minimum ESLint support to version 6: https://github.com/webpack-contrib/eslint-loader/blob/master/CHANGELOG.md#400-2020-04-03
- had to fix some linting issues

**EDIT:** Ok so ESLint 7 is not compatible with Node 11.
This version is in end of life ([End-of-Life releasese](https://github.com/nodejs/Release#end-of-life-releases), should we drop support for Node 11 too? And maybe add support for Node 13 and Node 14?
WDYT?

**EDIT 2:** PR opened at #775

**EDIT 3:** PR rebased since #775 has been merged

Commits
-------

5a1cfb6 feat: add support for ESLint 7, drop support ESLint 5
  • Loading branch information
weaverryan committed Dec 3, 2020
2 parents 65e2b64 + 5a1cfb6 commit 9f24246
Show file tree
Hide file tree
Showing 5 changed files with 199 additions and 78 deletions.
23 changes: 20 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* This file is part of the Symfony Webpack Encore package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

module.exports = {
"root": true,
"plugins": ["node", "header"],
Expand Down Expand Up @@ -39,7 +48,7 @@ module.exports = {
"after": true
}],
"no-console": "off",
"valid-jsdoc": ["error", {"requireParamDescription": false, "requireReturnDescription": false}],
"valid-jsdoc": ["error", { "requireParamDescription": false, "requireReturnDescription": false }],
"node/no-unsupported-features": ["error", { version: 8 }],
"node/no-deprecated-api": "error",
"node/no-missing-import": "error",
Expand All @@ -54,6 +63,14 @@ module.exports = {
"node/no-unpublished-bin": "error",
"node/no-unpublished-require": "error",
"node/process-exit-as-throw": "error",
"header/header": [2, "block", {"pattern": "This file is part of the Symfony Webpack Encore package"}]
}
"header/header": [2, "block", { "pattern": "This file is part of the Symfony Webpack Encore package" }]
},
"overrides": [
{
"files": [".eslintrc.js"],
"rules": {
"quotes": ["error", "double"],
},
}
],
};
9 changes: 1 addition & 8 deletions lib/loaders/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
const WebpackConfig = require('../WebpackConfig'); //eslint-disable-line no-unused-vars
const loaderFeatures = require('../features');
const applyOptionsCallback = require('../utils/apply-options-callback');
const logger = require('../logger');

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

try {
if (typeof engine.getConfigForFile === 'function') {
logger.debug('Checking ESLint 6+ configuration...');
engine.getConfigForFile('webpack.config.js');
} else {
logger.debug('Checking ESLint 5 configuration...');
engine.config.getConfigHierarchy(webpackConfig.runtimeConfig.context);
}
engine.getConfigForFile('webpack.config.js');
} catch (e) {
if (isMissingConfigError(e)) {
const chalk = require('chalk');
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"test": "mocha --reporter spec test --recursive",
"lint": "eslint lib test index.js",
"lint": "eslint lib test index.js .eslintrc.js",
"travis:lint": "npm run lint"
},
"bin": {
Expand Down Expand Up @@ -72,8 +72,8 @@
"chai-fs": "^2.0.0",
"chai-subset": "^1.6.0",
"core-js": "^3.0.0",
"eslint": "^5.15.2 || ^6.0.0",
"eslint-loader": "^3.0.0",
"eslint": "^6.0.0 || ^7.0.0",
"eslint-loader": "^4.0.0",
"eslint-plugin-header": "^1.0.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-node": "^8.0.1",
Expand Down
9 changes: 9 additions & 0 deletions test/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* This file is part of the Symfony Webpack Encore package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

module.exports = {
"env": {
"node": true,
Expand Down
Loading

0 comments on commit 9f24246

Please sign in to comment.