Skip to content

Commit

Permalink
Use the apply-options-callback method for the eslint-loader
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyrkan committed May 8, 2018
1 parent 87e1a02 commit 0738691
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
9 changes: 2 additions & 7 deletions lib/loaders/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
'use strict';

const loaderFeatures = require('../features');
const applyOptionsCallback = require('../utils/apply-options-callback');

/**
* @param {WebpackConfig} webpackConfig
Expand All @@ -29,12 +30,6 @@ module.exports = {
}
};

webpackConfig.eslintLoaderOptionsCallback.apply(
// use eslintLoaderOptions as the this variable
eslintLoaderOptions,
[eslintLoaderOptions]
);

return eslintLoaderOptions;
return applyOptionsCallback(webpackConfig.eslintLoaderOptionsCallback, eslintLoaderOptions);
}
};
12 changes: 12 additions & 0 deletions test/loaders/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,16 @@ describe('loaders/eslint', () => {
expect(Object.keys(actualOptions)).to.have.lengthOf(3);
expect(actualOptions.emitWarning).to.equal(false);
});

it('getOptions() with a callback that returns an object', () => {
const config = createConfig();
config.enableEslintLoader((options) => {
options.custom_option = 'foo';

return { foo: true };
});

const actualOptions = eslintLoader.getOptions(config);
expect(actualOptions).to.deep.equals({ foo: true });
});
});

0 comments on commit 0738691

Please sign in to comment.