Skip to content

Commit 0738691

Browse files
committed
Use the apply-options-callback method for the eslint-loader
1 parent 87e1a02 commit 0738691

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

lib/loaders/eslint.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
'use strict';
1111

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

1415
/**
1516
* @param {WebpackConfig} webpackConfig
@@ -29,12 +30,6 @@ module.exports = {
2930
}
3031
};
3132

32-
webpackConfig.eslintLoaderOptionsCallback.apply(
33-
// use eslintLoaderOptions as the this variable
34-
eslintLoaderOptions,
35-
[eslintLoaderOptions]
36-
);
37-
38-
return eslintLoaderOptions;
33+
return applyOptionsCallback(webpackConfig.eslintLoaderOptionsCallback, eslintLoaderOptions);
3934
}
4035
};

test/loaders/eslint.js

+12
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,16 @@ describe('loaders/eslint', () => {
5454
expect(Object.keys(actualOptions)).to.have.lengthOf(3);
5555
expect(actualOptions.emitWarning).to.equal(false);
5656
});
57+
58+
it('getOptions() with a callback that returns an object', () => {
59+
const config = createConfig();
60+
config.enableEslintLoader((options) => {
61+
options.custom_option = 'foo';
62+
63+
return { foo: true };
64+
});
65+
66+
const actualOptions = eslintLoader.getOptions(config);
67+
expect(actualOptions).to.deep.equals({ foo: true });
68+
});
5769
});

0 commit comments

Comments
 (0)