Skip to content

Commit

Permalink
Deprecate Encore.enableEslintLoader('extends-name')
Browse files Browse the repository at this point in the history
  • Loading branch information
Kocal committed Jan 12, 2020
1 parent 9f31d95 commit c828b32
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
6 changes: 1 addition & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1070,18 +1070,14 @@ class Encore {
* // enables the eslint loaded using the default eslint configuration.
* Encore.enableEslintLoader();
*
* // Optionally, you can pass in the configuration eslint should extend.
* Encore.enableEslintLoader('airbnb');
*
* // You can also pass in an object of options
* // that will be passed on to the eslint-loader
* Encore.enableEslintLoader({
* extends: 'airbnb',
* emitWarning: false
* });
*
* // For a more advanced usage you can pass in a callback
* // https://github.com/MoOx/eslint-loader#options
* // https://github.com/webpack-contrib/eslint-loader#options
* Encore.enableEslintLoader((options) => {
* options.extends = 'airbnb';
* options.emitWarning = false;
Expand Down
2 changes: 2 additions & 0 deletions lib/WebpackConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,8 @@ class WebpackConfig {
}

if (typeof eslintLoaderOptionsOrCallback === 'string') {
logger.deprecation('enableEslintLoader: Extending from a configuration is deprecated, please use a configuration file instead. See https://eslint.org/docs/user-guide/configuring for more information.');

this.eslintLoaderOptionsCallback = (options) => {
options.extends = eslintLoaderOptionsOrCallback;
};
Expand Down
5 changes: 5 additions & 0 deletions test/config-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,10 @@ describe('The config-generator function', () => {
});

it('enableEslintLoader("extends-name")', () => {
before(() => {
logger.reset();
});

const config = createConfig();
config.addEntry('main', './main');
config.publicPath = '/';
Expand All @@ -380,6 +384,7 @@ describe('The config-generator function', () => {

const actualConfig = configGenerator(config);

expect(JSON.stringify(logger.getMessages().deprecation)).to.contain('enableEslintLoader: Extending from a configuration is deprecated, please use a configuration file instead. See https://eslint.org/docs/user-guide/configuring for more information.');
expect(JSON.stringify(actualConfig.module.rules)).to.contain('eslint-loader');
expect(JSON.stringify(actualConfig.module.rules)).to.contain('extends-name');
});
Expand Down

0 comments on commit c828b32

Please sign in to comment.