|
12 | 12 | const expect = require('chai').expect; |
13 | 13 | const WebpackConfig = require('../../lib/WebpackConfig'); |
14 | 14 | const RuntimeConfig = require('../../lib/config/RuntimeConfig'); |
| 15 | +const configGenerator = require('../../lib/config-generator'); |
15 | 16 | const eslintLoader = require('../../lib/loaders/eslint'); |
| 17 | +const isWindows = (process.platform === 'win32'); |
16 | 18 |
|
17 | 19 | function createConfig() { |
18 | 20 | const runtimeConfig = new RuntimeConfig(); |
@@ -77,4 +79,29 @@ describe('loaders/eslint', () => { |
77 | 79 | const actualOptions = eslintLoader.getOptions(config); |
78 | 80 | expect(actualOptions).to.deep.equals({ foo: true }); |
79 | 81 | }); |
| 82 | + |
| 83 | + it('configure ESLint loader rule', () => { |
| 84 | + const config = createConfig(); |
| 85 | + config.outputPath = isWindows ? 'C:\\tmp\\public' : '/tmp/public'; |
| 86 | + config.setPublicPath('/'); |
| 87 | + config.enableEslintLoader(); |
| 88 | + config.configureLoaderRule('eslint', (loader) => { |
| 89 | + loader.test = /\.(jsx?|vue)/; |
| 90 | + }); |
| 91 | + |
| 92 | + const webpackConfig = configGenerator(config); |
| 93 | + const eslintLoader = webpackConfig.module.rules.find(rule => rule.loader === 'eslint-loader'); |
| 94 | + |
| 95 | + expect(eslintLoader).to.deep.equals({ |
| 96 | + test: /\.(jsx?|vue)/, |
| 97 | + enforce: 'pre', |
| 98 | + exclude: /node_modules/, |
| 99 | + loader: 'eslint-loader', |
| 100 | + options: { |
| 101 | + cache: true, |
| 102 | + emitWarning: true, |
| 103 | + parser: 'babel-eslint' |
| 104 | + } |
| 105 | + }); |
| 106 | + }); |
80 | 107 | }); |
0 commit comments