Skip to content

Commit

Permalink
feat: update config
Browse files Browse the repository at this point in the history
  • Loading branch information
CyanSalt committed Jan 31, 2023
1 parent 16a1ebf commit 0000605
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 30 deletions.
2 changes: 2 additions & 0 deletions galaxy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ module.exports = {
'galaxy/max-nested-destructuring': ['error', { max: 3 }],
// 禁止使用 for-in 结构
'galaxy/no-for-in': 'error',
// 禁止可能是误用的全局变量
'galaxy/no-misused-globals': 'error',
// 自动为非控制语句的 if 结构增加花括号
'galaxy/non-control-statement-curly': 'warn',
},
Expand Down
12 changes: 8 additions & 4 deletions import/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,25 @@ module.exports = {
'import',
],
rules: {
// 禁止导出 let 和 var 声明的可变变量
'import/no-mutable-exports': 'error',
// 自动将类型导入修改为 import type 语句
'import/consistent-type-specifier-style': ['warn', 'prefer-top-level'],
// import 语句必须在最前
'import/first': 'error',
// 自动为 import 之后添加空行
'import/newline-after-import': 'warn',
// 自动修复重复的 import
'no-duplicate-imports': 'off',
'import/no-duplicates': 'warn',
// 自动去除空的导入块
'import/no-empty-named-blocks': 'warn',
// 禁止导出 let 和 var 声明的可变变量
'import/no-mutable-exports': 'error',
// 必须按照 内置 > 外部模块 > aliases > '../' > './' 声明 import 顺序
'import/order': ['warn', {
groups: ['builtin', 'external', 'internal', 'parent', 'sibling'],
pathGroups: [{ pattern: '@/**', group: 'internal' }],
pathGroupsExcludedImportTypes: ['builtin'],
alphabetize: { order: 'asc' },
}],
// 自动为 import 之后添加空行
'import/newline-after-import': 'warn',
},
}
24 changes: 1 addition & 23 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = {
extends: [
'eslint:recommended',
],
reportUnusedDisableDirectives: true,
rules: {
/** Possible Problems */
// map等数组方法的回调函数必须有返回值
Expand Down Expand Up @@ -83,29 +84,6 @@ module.exports = {
'no-octal-escape': 'error',
// 禁止使用 __proto__ 魔术属性(已弃用)
'no-proto': 'error',
// 禁止使用可能是错误的全局变量,例如 event
'no-restricted-globals': [
'error',
// builtin
...Object.getOwnPropertyNames(Object.prototype),
// dom
'blur',
'close',
'closed',
'event',
'external',
'find',
'focus',
'length',
'name',
'open',
'origin',
'parent',
'scroll',
'status',
'stop',
'top',
],
// 禁止返回赋值语句
'no-return-assign': 'error',
// 禁止 for 循环之外的地方使用逗号表达式
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
"@typescript-eslint/eslint-plugin": ">=5.43.0",
"@typescript-eslint/parser": ">=5.43.0",
"eslint": ">=8.27.0",
"eslint-plugin-galaxy": ">=1.15.0",
"eslint-plugin-import": ">=2.22.1",
"eslint-plugin-galaxy": ">=1.17.0",
"eslint-plugin-import": ">=2.27.0",
"eslint-plugin-react": ">=7.29.0",
"eslint-plugin-react-hooks": ">=3.0.0",
"eslint-plugin-unicorn": ">=43.0.0",
"eslint-plugin-vue": ">=9.6.0",
"eslint-plugin-vue": ">=9.9.0",
"eslint-plugin-vue-scoped-css": ">=2.0.0"
},
"peerDependenciesMeta": {
Expand Down
2 changes: 2 additions & 0 deletions vue/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ module.exports = {
'vue/array-bracket-newline': config.rules['array-bracket-newline'],
// 自动删除数组的括号内侧的空格
'vue/array-bracket-spacing': config.rules['array-bracket-spacing'],
// 自动优化数组的元素换行(所有元素保持一致)
'vue/array-element-newline': config.rules['array-element-newline'],
// 自动在箭头函数的箭头前后添加空格
'vue/arrow-spacing': config.rules['arrow-spacing'],
// 自动优化花括号为 one true 风格(左侧花括号前不换行,else 前也不换行)
Expand Down

0 comments on commit 0000605

Please sign in to comment.