From d7dc53640b01c1422f85b1c03b80938b3fe7f4f7 Mon Sep 17 00:00:00 2001 From: Nex Zhu <4370605+NexZhu@users.noreply.github.com> Date: Mon, 27 Dec 2021 17:37:41 +0800 Subject: [PATCH] feat: add eslint-webpack-plugin --- .fes.js | 6 +++ package-lock.json | 95 +++++++++++++++++++++++++++++++++++++++++++++-- package.json | 1 + 3 files changed, 99 insertions(+), 3 deletions(-) diff --git a/.fes.js b/.fes.js index 0145f1c..8e0fd2e 100644 --- a/.fes.js +++ b/.fes.js @@ -1,4 +1,5 @@ // .fes.js 只负责管理编译时配置,只能使用plain Object +import ESLintPlugin from 'eslint-webpack-plugin' import StylelintPlugin from 'stylelint-webpack-plugin' export default { @@ -32,6 +33,11 @@ export default { ], }, chainWebpack(config) { + config.plugin('eslint').use(ESLintPlugin, [ + { + files: 'src/**/*.{js,ts,tsx,vue}', + }, + ]) config.plugin('stylelint').use(StylelintPlugin, [ { extensions: ['css', 'scss', 'vue', 'tsx'], diff --git a/package-lock.json b/package-lock.json index 488de95..ab9ef1d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,6 +24,7 @@ "@fesjs/plugin-sass": "^2.0.0", "@vue/compiler-sfc": "^3.2.26", "cross-env": "^7.0.3", + "eslint-webpack-plugin": "^3.1.1", "husky": "^7.0.4", "lint-staged": "^12.1.4", "postcss-html": "^1.3.0", @@ -5500,6 +5501,58 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, + "node_modules/eslint-webpack-plugin": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/eslint-webpack-plugin/-/eslint-webpack-plugin-3.1.1.tgz", + "integrity": "sha512-xSucskTN9tOkfW7so4EaiFIkulWLXwCB/15H917lR6pTv0Zot6/fetFucmENRb7J5whVSFKIvwnrnsa78SG2yg==", + "dev": true, + "dependencies": { + "@types/eslint": "^7.28.2", + "jest-worker": "^27.3.1", + "micromatch": "^4.0.4", + "normalize-path": "^3.0.0", + "schema-utils": "^3.1.1" + }, + "engines": { + "node": ">= 12.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0", + "webpack": "^5.0.0" + } + }, + "node_modules/eslint-webpack-plugin/node_modules/@types/eslint": { + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-7.29.0.tgz", + "integrity": "sha512-VNcvioYDH8/FxaeTKkM4/TiTwt6pBV9E3OfGmvaw8tPl0rrHCJ4Ll15HRT+pMiFAf/MLQvAzC+6RzUMEL9Ceng==", + "dev": true, + "dependencies": { + "@types/estree": "*", + "@types/json-schema": "*" + } + }, + "node_modules/eslint-webpack-plugin/node_modules/schema-utils": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.1.1.tgz", + "integrity": "sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw==", + "dev": true, + "dependencies": { + "@types/json-schema": "^7.0.8", + "ajv": "^6.12.5", + "ajv-keywords": "^3.5.2" + }, + "engines": { + "node": ">= 10.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + } + }, "node_modules/eslint/node_modules/ansi-styles": { "version": "4.3.0", "dev": true, @@ -12479,7 +12532,6 @@ "integrity": "sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg==", "dev": true, "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -17938,6 +17990,42 @@ "version": "3.1.0", "dev": true }, + "eslint-webpack-plugin": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/eslint-webpack-plugin/-/eslint-webpack-plugin-3.1.1.tgz", + "integrity": "sha512-xSucskTN9tOkfW7so4EaiFIkulWLXwCB/15H917lR6pTv0Zot6/fetFucmENRb7J5whVSFKIvwnrnsa78SG2yg==", + "dev": true, + "requires": { + "@types/eslint": "^7.28.2", + "jest-worker": "^27.3.1", + "micromatch": "^4.0.4", + "normalize-path": "^3.0.0", + "schema-utils": "^3.1.1" + }, + "dependencies": { + "@types/eslint": { + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-7.29.0.tgz", + "integrity": "sha512-VNcvioYDH8/FxaeTKkM4/TiTwt6pBV9E3OfGmvaw8tPl0rrHCJ4Ll15HRT+pMiFAf/MLQvAzC+6RzUMEL9Ceng==", + "dev": true, + "requires": { + "@types/estree": "*", + "@types/json-schema": "*" + } + }, + "schema-utils": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.1.1.tgz", + "integrity": "sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.8", + "ajv": "^6.12.5", + "ajv-keywords": "^3.5.2" + } + } + } + }, "espree": { "version": "9.2.0", "dev": true, @@ -22821,8 +22909,9 @@ }, "typescript": { "version": "4.5.4", - "dev": true, - "peer": true + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.4.tgz", + "integrity": "sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg==", + "dev": true }, "unicode-canonical-property-names-ecmascript": { "version": "2.0.0", diff --git a/package.json b/package.json index 2a46f6a..46a59b7 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "@fesjs/plugin-sass": "^2.0.0", "@vue/compiler-sfc": "^3.2.26", "cross-env": "^7.0.3", + "eslint-webpack-plugin": "^3.1.1", "husky": "^7.0.4", "lint-staged": "^12.1.4", "postcss-html": "^1.3.0",