Skip to content

Commit

Permalink
test: 自定义complexity规则,屏蔽掉switchcase类型的复杂度错误
Browse files Browse the repository at this point in the history
  • Loading branch information
eyea committed Mar 12, 2024
1 parent efd5903 commit 99732d2
Show file tree
Hide file tree
Showing 15 changed files with 618 additions and 161 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ jobs:
registry-url: 'https://registry.npmjs.org'
- run: npm install -g npm
- run: npm ci
- run: npm publish --provenance --access public --tag beta-3
- run: npm publish --provenance --access public --tag beta-4
env:
NODE_AUTH_TOKEN: ${{secrets.AFUTEAM_LINT_PUBLISH_NPM_TOKEN}}
4 changes: 2 additions & 2 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ async function lintFiles(filePaths) {
// 复杂度
if(results?.length > 0) {
results.forEach(result => {
const messageWhichRuleId = 'complexity'
const messageWhichRuleId = '@afuteam/fe/complexity-without-switchcase'
const complexityMsg = result?.messages?.filter(item => item.ruleId === messageWhichRuleId)
complexityData.push(...complexityMsg)
})
Expand Down Expand Up @@ -191,7 +191,7 @@ function handleProcessArgv() {
if (argv.path) {
targetPath = argv.path;
}
// TODO type 考虑是否支持组合,默认支持一种
// type 默认支持一种
if (argv.type) {
if(argv.type.startsWith('error-')) {
type = 'js'
Expand Down
3 changes: 2 additions & 1 deletion lib/configs/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const BaseOptions = require('./base.js');

module.exports = {
...BaseOptions,
plugins: ['@afuteam/fe'],
rules: {
'no-unused-vars': 1, // 非TS项目,此项需设为1
'no-undef': 0,
Expand All @@ -12,7 +13,7 @@ module.exports = {
'block-scoped-var': 2,
'default-case': 2,
'complexity': 0,
'@afuteam/fe/complexity-without-switchcase': ['error', { 'max': 10 }],
'@afuteam/fe/complexity-without-switchcase': ['error', { 'max': 20 }],
'no-console': 0,
'no-await-in-loop': 2,
'no-prototype-builtins': 0,
Expand Down
2 changes: 1 addition & 1 deletion lib/configs/react-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = {
ecmaVersion: "latest",
sourceType: "module",
},
plugins: ['react', 'react-hooks', 'jsx-a11y'],
plugins: ['react', 'react-hooks', 'jsx-a11y', '@afuteam/fe'],
rules: {
...JSRules.rules,
// Basic react-hookes rules 2条
Expand Down
2 changes: 1 addition & 1 deletion lib/configs/react-ts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = {
sourceType: "module",
tsconfigRootDir: __dirname,
},
plugins: ["react", '@typescript-eslint'],
plugins: ["react", '@typescript-eslint', '@afuteam/fe'],
rules: {
...JSRules.rules,

Expand Down
2 changes: 1 addition & 1 deletion lib/configs/ts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
'plugin:@typescript-eslint/eslint-recommended',
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
plugins: ['@typescript-eslint', '@afuteam/fe'],
rules: {
...JSRules.rules,

Expand Down
1 change: 1 addition & 0 deletions lib/configs/vue2-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = {
...BaseOptions,
extends: ["plugin:vue/essential"],
parser: "vue-eslint-parser",
plugins: ['@afuteam/fe'],
rules: {
...JSRules.rules,
},
Expand Down
2 changes: 1 addition & 1 deletion lib/configs/vue2-ts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
parser: "@typescript-eslint/parser",
},
extends: ["plugin:vue/essential", "@vue/typescript/recommended"],
plugins: ["@typescript-eslint"],
plugins: ["@typescript-eslint", '@afuteam/fe'],
rules: {
...JSRules.rules,

Expand Down
1 change: 1 addition & 0 deletions lib/configs/vue3-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = {
extends: [
'plugin:vue/vue3-essential'
],
plugins: ['@afuteam/fe'],
rules: {
...JSRules.rules,
},
Expand Down
2 changes: 1 addition & 1 deletion lib/configs/vue3-ts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
parser: "@typescript-eslint/parser",
},
extends: ["plugin:vue/vue3-essential", "@vue/typescript/recommended"],
plugins: ["@typescript-eslint"],
plugins: ["@typescript-eslint", '@afuteam/fe'],
rules: {
...JSRules.rules,
// not needed for vue 3
Expand Down
Loading

0 comments on commit 99732d2

Please sign in to comment.