@mpxjs/vue-cli-plugin-mpx-eslint 2.1.9 → 2.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +24 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
const ESLintPlugin = require('eslint-webpack-plugin')
|
|
2
2
|
|
|
3
3
|
module.exports = function (api, options, webpackConfig) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
if (options.lintOnSave) {
|
|
5
|
+
api.chainWebpack((webpackConfig) => {
|
|
6
|
+
const { lintOnSave } = options
|
|
7
|
+
const extensions = ['js', 'ts', 'mpx']
|
|
8
|
+
const treatAllAsWarnings = lintOnSave === true || lintOnSave === 'warning'
|
|
9
|
+
const treatAllAsErrors = lintOnSave === 'error'
|
|
10
|
+
|
|
11
|
+
const failOnWarning = treatAllAsErrors
|
|
12
|
+
const failOnError = !treatAllAsWarnings
|
|
13
|
+
|
|
14
|
+
/** @type {import('eslint-webpack-plugin').Options & import('eslint').ESLint.Options} */
|
|
15
|
+
const eslintWebpackPluginOptions = {
|
|
16
|
+
// common to both plugin and ESlint
|
|
17
|
+
extensions,
|
|
18
|
+
// ESlint options
|
|
19
|
+
failOnWarning,
|
|
20
|
+
failOnError
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
webpackConfig
|
|
24
|
+
.plugin('eslint-webpack-plugin')
|
|
25
|
+
.use(ESLintPlugin, [eslintWebpackPluginOptions])
|
|
26
|
+
})
|
|
27
|
+
}
|
|
9
28
|
}
|