Skip to content

Commit bc0e9bf

Browse files
committed
chore(cr): add shortcut function applyRuleConfigurationCallback
1 parent bc1d025 commit bc0e9bf

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/config-generator.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,14 @@ class ConfigGenerator {
221221
}
222222

223223
buildRulesConfig() {
224+
const applyRuleConfigurationCallback = (name, defaultRules) => {
225+
if (!(name in this.webpackConfig.loaderConfigurationCallbacks)) {
226+
throw new Error(`Loader "${name}" is not configurable. Valid loaders are "${Object.keys(this.webpackConfig.loaderConfigurationCallbacks).join('", "')}".`);
227+
}
228+
229+
return applyOptionsCallback(this.webpackConfig.loaderConfigurationCallbacks[name], defaultRules);
230+
};
231+
224232
let rules = [
225233
{
226234
// match .js and .jsx
@@ -357,7 +365,7 @@ class ConfigGenerator {
357365
}
358366

359367
if (this.webpackConfig.useEslintLoader) {
360-
rules.push(applyOptionsCallback(this.webpackConfig.loaderConfigurationCallbacks['eslint'], {
368+
rules.push(applyRuleConfigurationCallback('eslint', {
361369
test: /\.jsx?$/,
362370
loader: 'eslint-loader',
363371
exclude: /node_modules/,

0 commit comments

Comments
 (0)