From 07386919df2ff1b651c7ebbccfd99c23c1302f38 Mon Sep 17 00:00:00 2001 From: Lyrkan Date: Tue, 8 May 2018 09:39:21 +0200 Subject: [PATCH] Use the apply-options-callback method for the eslint-loader --- lib/loaders/eslint.js | 9 ++------- test/loaders/eslint.js | 12 ++++++++++++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/loaders/eslint.js b/lib/loaders/eslint.js index 2fbd0d6c..fd1ae18d 100644 --- a/lib/loaders/eslint.js +++ b/lib/loaders/eslint.js @@ -10,6 +10,7 @@ 'use strict'; const loaderFeatures = require('../features'); +const applyOptionsCallback = require('../utils/apply-options-callback'); /** * @param {WebpackConfig} webpackConfig @@ -29,12 +30,6 @@ module.exports = { } }; - webpackConfig.eslintLoaderOptionsCallback.apply( - // use eslintLoaderOptions as the this variable - eslintLoaderOptions, - [eslintLoaderOptions] - ); - - return eslintLoaderOptions; + return applyOptionsCallback(webpackConfig.eslintLoaderOptionsCallback, eslintLoaderOptions); } }; diff --git a/test/loaders/eslint.js b/test/loaders/eslint.js index 8837252b..deffe18a 100644 --- a/test/loaders/eslint.js +++ b/test/loaders/eslint.js @@ -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 }); + }); });