@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.
Files changed (2) hide show
  1. package/index.js +24 -5
  2. 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
- api.chainWebpack(webpackConfig => {
5
- webpackConfig.plugin('eslint-webpack-plugin').use(ESLintPlugin, [{
6
- extensions: ['js', 'ts', 'mpx']
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/vue-cli-plugin-mpx-eslint",
3
- "version": "2.1.9",
3
+ "version": "2.1.11",
4
4
  "description": "eslint plugin for mpx-cli",
5
5
  "main": "index.js",
6
6
  "scripts": {