Skip to content

Commit

Permalink
feature #1309 Drop ESLint integration (Kocal)
Browse files Browse the repository at this point in the history
This PR was merged into the main branch.

Discussion
----------

Drop ESLint integration

Close #1282, see #1267 (comment) for more information.

Removing `Encore.enableEslintPlugin()` from user-land. It will ease Encore maintenance a lot!

Users have three options to migrate:
1. Either re-install `eslint-webpack-plugin` and add the plugin back through `Encore.addPlugin(new EslintPlugin())`
2. **Recommended:** Either use ESLint in a dedicated task, ex: a git hook pre-commit, a dedicated npm script, a step in their CI, ...
3. Use alternative (and faster) tools like Biome.js or Oxlint

Commits
-------

ef70c34 Drop ESLint integration
  • Loading branch information
Kocal committed Aug 30, 2024
2 parents a39f4a0 + ef70c34 commit 3056c2a
Show file tree
Hide file tree
Showing 13 changed files with 11 additions and 519 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ This is a new major version that contains several backwards-compatibility breaks

* #1308 Drop Vue 2 support (End-Of-Life), only Vue 3 is supported (@Kocal)

* #1309 Drop ESLint integration (@Kocal)

## 4.7.0

### Features
Expand Down
32 changes: 0 additions & 32 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1263,38 +1263,6 @@ class Encore {
return this;
}

/**
* If enabled, the eslint-webpack-plugin is enabled.
*
* https://github.com/webpack-contrib/eslint-webpack-plugin
*
* ```
* // enables the eslint plugin using the default eslint configuration.
* Encore.enableEslintPlugin();
*
* // You can also pass in an object of options
* // that will be passed on to the eslint-webpack-plugin
* Encore.enableEslintPlugin({
* emitWarning: false
* });
*
* // For a more advanced usage you can pass in a callback
* // https://github.com/webpack-contrib/eslint-webpack-plugin#options
* Encore.enableEslintPlugin((options) => {
* options.extensions.push('vue'); // to lint Vue files
* options.emitWarning = false;
* });
* ```
*
* @param {string|object|function} eslintPluginOptionsOrCallback
* @returns {Encore}
*/
enableEslintPlugin(eslintPluginOptionsOrCallback = () => {}) {
webpackConfig.enableEslintPlugin(eslintPluginOptionsOrCallback);

return this;
}

/**
* If enabled, display build notifications using
* webpack-notifier.
Expand Down
19 changes: 0 additions & 19 deletions lib/WebpackConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class WebpackConfig {
this.useReact = false;
this.usePreact = false;
this.useVueLoader = false;
this.useEslintPlugin = false;
this.useTypeScriptLoader = false;
this.useForkedTypeScriptTypeChecking = false;
this.useBabelTypeScriptPreset = false;
Expand Down Expand Up @@ -134,7 +133,6 @@ class WebpackConfig {
this.watchOptionsConfigurationCallback = () => {};
this.devServerOptionsConfigurationCallback = () => {};
this.vueLoaderOptionsCallback = () => {};
this.eslintPluginOptionsCallback = () => {};
this.tsConfigurationCallback = () => {};
this.handlebarsConfigurationCallback = () => {};
this.miniCssExtractLoaderConfigurationCallback = () => {};
Expand All @@ -148,7 +146,6 @@ class WebpackConfig {
less: () => {},
stylus: () => {},
vue: () => {},
eslint: () => {},
typescript: () => {},
handlebars: () => {},
svelte: () => {},
Expand Down Expand Up @@ -765,22 +762,6 @@ class WebpackConfig {
}
}

enableEslintPlugin(eslintPluginOptionsOrCallback = () => {}) {
logger.deprecation('The ESLint integration is now deprecated and will be removed in the next major release. Please use the standalone ESLint CLI instead, or use the ESLint Webpack plugin directly.');

this.useEslintPlugin = true;

if (typeof eslintPluginOptionsOrCallback === 'function') {
this.eslintPluginOptionsCallback = eslintPluginOptionsOrCallback;
} else if (typeof eslintPluginOptionsOrCallback === 'object') {
this.eslintPluginOptionsCallback = (options) => {
Object.assign(options, eslintPluginOptionsOrCallback);
};
} else {
throw new Error('Argument 1 to enableEslintPlugin() must be either an object or callback function.');
}
}

enableBuildNotifications(enabled = true, notifierPluginOptionsCallback = () => {}) {
if (typeof notifierPluginOptionsCallback !== 'function') {
throw new Error('Argument 2 to enableBuildNotifications() must be a callback function.');
Expand Down
3 changes: 0 additions & 3 deletions lib/config-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const vuePluginUtil = require('./plugins/vue');
const friendlyErrorPluginUtil = require('./plugins/friendly-errors');
const assetOutputDisplay = require('./plugins/asset-output-display');
const notifierPluginUtil = require('./plugins/notifier');
const eslintPluginUtil = require('./plugins/eslint');
const PluginPriorities = require('./plugins/plugin-priorities');
const applyOptionsCallback = require('./utils/apply-options-callback');
const copyEntryTmpName = require('./utils/copyEntryTmpName');
Expand Down Expand Up @@ -466,8 +465,6 @@ class ConfigGenerator {

vuePluginUtil(plugins, this.webpackConfig);

eslintPluginUtil(plugins, this.webpackConfig);

if (!this.webpackConfig.runtimeConfig.outputJson) {
const friendlyErrorPlugin = friendlyErrorPluginUtil(this.webpackConfig);
plugins.push({
Expand Down
9 changes: 0 additions & 9 deletions lib/features.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,6 @@ const features = {
],
description: 'use Vue with JSX support'
},
eslint_plugin: {
method: 'enableEslintPlugin()',
// eslint is needed so the end-user can do things
packages: [
{ name: 'eslint' },
{ name: 'eslint-webpack-plugin', enforce_version: true },
],
description: 'Enable ESLint checks'
},
copy_files: {
method: 'copyFiles()',
packages: [
Expand Down
113 changes: 0 additions & 113 deletions lib/plugins/eslint.js

This file was deleted.

43 changes: 0 additions & 43 deletions lib/utils/has-eslint-configuration.js

This file was deleted.

10 changes: 0 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"resolve-url-loader": "^5.0.0",
"semver": "^7.3.2",
"style-loader": "^3.3.0",
"sync-rpc": "^1.3.6",
"tapable": "^2.2.1",
"terser-webpack-plugin": "^5.3.0",
"tmp": "^0.2.1",
Expand Down Expand Up @@ -70,7 +69,6 @@
"eslint-plugin-header": "^3.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-node": "^11.1.0",
"eslint-webpack-plugin": "^3.1.0 || ^4.0.0",
"file-loader": "^6.0.0",
"fork-ts-checker-webpack-plugin": "^7.0.0 || ^8.0.0 || ^9.0.0",
"fs-extra": "^10.0.0",
Expand Down Expand Up @@ -112,8 +110,6 @@
"@vue/babel-plugin-jsx": "^1.0.0",
"@vue/babel-preset-jsx": "^1.0.0",
"@vue/compiler-sfc": "^2.6 || ^3.0.2",
"eslint": "^8.0.0",
"eslint-webpack-plugin": "^3.1.0 || ^4.0.0",
"file-loader": "^6.0.0",
"fork-ts-checker-webpack-plugin": "^7.0.0 || ^8.0.0 || ^9.0.0",
"handlebars": "^4.7.7",
Expand Down Expand Up @@ -165,12 +161,6 @@
"@vue/compiler-sfc": {
"optional": true
},
"eslint": {
"optional": true
},
"eslint-webpack-plugin": {
"optional": true
},
"file-loader": {
"optional": true
},
Expand Down
12 changes: 6 additions & 6 deletions test/WebpackConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -1483,29 +1483,29 @@ describe('WebpackConfig object', () => {
const config = createConfig();
const callback = (loader) => {};

expect(config.loaderConfigurationCallbacks['eslint']).to.not.equal(callback);
expect(config.loaderConfigurationCallbacks['javascript']).to.not.equal(callback);

config.configureLoaderRule('eslint', callback);
expect(config.loaderConfigurationCallbacks['eslint']).to.equal(callback);
config.configureLoaderRule('javascript', callback);
expect(config.loaderConfigurationCallbacks['javascript']).to.equal(callback);
});

it('Call method with a not supported loader', () => {
const config = createConfig();

expect(() => {
config.configureLoaderRule('reason');
}).to.throw('Loader "reason" is not configurable. Valid loaders are "javascript", "css", "images", "fonts", "sass", "less", "stylus", "vue", "eslint", "typescript", "handlebars", "svelte" and the aliases "js", "ts", "scss".');
}).to.throw('Loader "reason" is not configurable. Valid loaders are "javascript", "css", "images", "fonts", "sass", "less", "stylus", "vue", "typescript", "handlebars", "svelte" and the aliases "js", "ts", "scss".');
});

it('Call method with not a valid callback', () => {
const config = createConfig();

expect(() => {
config.configureLoaderRule('eslint');
config.configureLoaderRule('javascript');
}).to.throw('Argument 2 to configureLoaderRule() must be a callback function.');

expect(() => {
config.configureLoaderRule('eslint', {});
config.configureLoaderRule('javascript', {});
}).to.throw('Argument 2 to configureLoaderRule() must be a callback function.');
});
});
Expand Down
Loading

0 comments on commit 3056c2a

Please sign in to comment.