@zpcscc/configs 2.0.1 → 2.0.2

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.
@@ -25,8 +25,10 @@ module.exports = {
25
25
  'plugin:promise/recommended',
26
26
  // sonarjs的推荐配置
27
27
  'plugin:sonarjs/recommended',
28
- // eslint-plugin-prettier的推荐配置,需要放在最后一位,内部启用了eslint-plugin-prettier插件
29
- // 用于关闭eslint中的所有格式化配置,全部在.prettierrc中进行格式化配置
28
+ /**
29
+ * eslint-plugin-prettier的推荐配置,需要放在最后一位,内部启用了eslint-plugin-prettier插件
30
+ * 用于关闭eslint中的所有格式化配置,全部在.prettierrc中进行格式化配置
31
+ */
30
32
  'plugin:prettier/recommended'],
31
33
  // 如果要在rules中针对某个插件做具体配置,则需要在plugins里先引入对应插件
32
34
  plugins: ['@typescript-eslint', 'sonarjs', 'unicorn', 'promise', 'import'],
@@ -51,47 +53,49 @@ module.exports = {
51
53
  rules: {
52
54
  // 数组类型。这里不限制写法
53
55
  '@typescript-eslint/array-type': 'off',
54
- // 限制命名规则。这里关闭。命名希望灵活些
55
- '@typescript-eslint/naming-convention': 'off',
56
- // 限制模板表达式。关闭此校验,希望模板表达式更加灵活
57
- '@typescript-eslint/restrict-template-expressions': 'off',
58
- // ts不允许有any类型。关闭此校验,特殊情况,需要any类型
59
- '@typescript-eslint/no-explicit-any': 'off',
56
+ // 强制使用一致性类型断言。<>语法,或者as语法
57
+ '@typescript-eslint/consistent-type-assertions': 'off',
58
+ // 强制ts类型使用type关键字,好处是,type关键字可以让ts类型更加明确,鼠标悬浮可以显示具体类型,且有interface的所有功能;
59
+ '@typescript-eslint/consistent-type-definitions': ['error', 'type'],
60
+ // import 类型时,需要加 type
61
+ '@typescript-eslint/consistent-type-imports': 'error',
60
62
  // 显示函数返回类型。关闭此校验,部分函数没有返回值。无需每个都显示类型
61
63
  '@typescript-eslint/explicit-function-return-type': 'off',
62
- // 严格的逻辑表达式。关闭此选项,可以使用 !value 的方式来进行判断;
63
- '@typescript-eslint/strict-boolean-expressions': 'off',
64
- // 为了安全使用 ?? 替换 ||。关闭此选项,部分场景,需要手动选择??还是||; ??会把空字符串也认为是true
65
- '@typescript-eslint/prefer-nullish-coalescing': 'off',
66
- // 无混淆空表达式。默认所有void都不能直接返回,需要用{}包裹。这里排除掉箭头函数。
67
- // 可以直接写成 onchange={(value)=> onChange(value) }
68
- // 而不是 onchange={(value)=>{ onChange(value) }}
69
- '@typescript-eslint/no-confusing-void-expression': ['warn', {
64
+ /**
65
+ * 无混淆空表达式。默认所有void都不能直接返回,需要用{}包裹。这里排除掉箭头函数。
66
+ * 可以直接写成 onchange={(value)=> onChange(value) }
67
+ * 而不是 onchange={(value)=>{ onChange(value) }}
68
+ */
69
+ '@typescript-eslint/no-confusing-void-expression': ['error', {
70
70
  ignoreArrowShorthand: true
71
71
  }],
72
- // import 类型时,需要加 type
73
- '@typescript-eslint/consistent-type-imports': 'warn',
74
- // 禁止变量重新声明
75
- '@typescript-eslint/no-redeclare': 'warn',
72
+ // ts不允许有any类型。关闭此校验,特殊情况,需要any类型
73
+ '@typescript-eslint/no-explicit-any': 'off',
76
74
  // 无浮动的promise,要求处理每个promise的then和catch。
77
75
  '@typescript-eslint/no-floating-promises': 'off',
78
- // 强制使用一致性类型断言。<>语法,或者as语法
79
- '@typescript-eslint/consistent-type-assertions': 'off',
80
76
  // 不得滥用promise,这里关闭
81
77
  '@typescript-eslint/no-misused-promises': 'off',
82
- // 限制 + 操作符,两边必须相同。这里关闭
83
- '@typescript-eslint/restrict-plus-operands': 'off',
78
+ // 禁止变量重新声明
79
+ '@typescript-eslint/no-redeclare': 'error',
84
80
  // 禁止未使用的表达式
85
- 'no-unused-expressions': 'off',
86
81
  '@typescript-eslint/no-unused-expressions': ['error', {
87
82
  allowShortCircuit: true,
88
83
  allowTernary: true
89
84
  }],
90
- 'no-return-await': 'off',
91
- // 若函数是async,则返回值需要有await
92
- '@typescript-eslint/return-await': ['error'],
85
+ // 限制命名规则。这里关闭。命名希望灵活些
86
+ '@typescript-eslint/naming-convention': 'off',
87
+ // 为了安全使用 ?? 替换 ||。关闭此选项,部分场景,需要手动选择??还是||; ??会把空字符串也认为是true
88
+ '@typescript-eslint/prefer-nullish-coalescing': 'off',
93
89
  // promise函数都需要使用async。这里关闭。
94
90
  '@typescript-eslint/promise-function-async': 'off',
91
+ // 限制 + 操作符,两边必须相同。这里关闭
92
+ '@typescript-eslint/restrict-plus-operands': 'off',
93
+ // 限制模板表达式。关闭此校验,希望模板表达式更加灵活
94
+ '@typescript-eslint/restrict-template-expressions': 'off',
95
+ // 若函数是async,则返回值需要有await
96
+ '@typescript-eslint/return-await': ['error'],
97
+ // 严格的逻辑表达式。关闭此选项,可以使用 !value 的方式来进行判断;
98
+ '@typescript-eslint/strict-boolean-expressions': 'off',
95
99
  // 禁止某些支持 ES6 样式导入声明的三重斜杠指令
96
100
  '@typescript-eslint/triple-slash-reference': 'off',
97
101
  // 函数体周围是否强制使用大括号。这里关闭,不强制。部分小函数,单行可以实现时,无需大括号限制
@@ -99,42 +103,46 @@ module.exports = {
99
103
  // if语句是否需要加括号。设置为多行加括号,单行不需要加括号
100
104
  curly: ['error', 'multi-line'],
101
105
  'default-param-last': 'off',
102
- // 禁止速记类型转换
103
- 'no-implicit-coercion': ['error'],
106
+ // 禁止整个文件的注释,只允许注释文件块。这里关闭。
107
+ 'eslint-comments/disable-enable-pair': 'off',
108
+ // 名称校验,这里关闭
109
+ 'import/named': 'off',
104
110
  // 禁止console输入。这里关闭
105
111
  'no-console': 'off',
106
112
  // 禁止使用continue跳出循环。这里关闭
107
113
  'no-continue': 'off',
108
- // 使用更具有描述性的名称。这里关闭
109
- 'unicorn/prevent-abbreviations': 'off',
110
- // 不允许使用 array的reduce方法。这里关闭
111
- 'unicorn/no-array-reduce': 'off',
112
- // 不允许使用 new Array()声明数组。这里关闭
113
- 'unicorn/no-new-array': 'off',
114
- // 不允许使用 新的特性。这里关闭
115
- 'unicorn/new-for-builtins': 'off',
116
- // 不允许使用 array的forEach。这里管理
117
- 'unicorn/no-array-for-each': 'off',
114
+ // 禁止速记类型转换
115
+ 'no-implicit-coercion': ['error'],
116
+ // 若函数是async,则返回值需要有await,这里关闭,使用typescript的同名规则;
117
+ 'no-return-await': 'off',
118
+ // 禁止未使用的表达式
119
+ 'no-unused-expressions': 'off',
120
+ // 函数名称后需要跟一个空格。这里关闭
121
+ 'space-before-function-paren': 'off',
122
+ // 返回值必须被使用。这里关闭
123
+ 'sonarjs/no-ignored-return': 'off',
118
124
  // 在属性上使用析构函数变量。这里关闭
119
125
  'unicorn/consistent-destructuring': 'off',
120
- // 使用esm的格式,而不是commonjs。这里关闭。部分模块还是需要使用commonjs保证兼容性
121
- 'unicorn/prefer-module': 'off',
122
126
  // 箭头函数移动到外部作用于。这里关闭。在react组件内,经常会使用到箭头函数
123
127
  'unicorn/consistent-function-scoping': 'off',
128
+ // 使用更具有描述性的名称。这里关闭
129
+ 'unicorn/prevent-abbreviations': 'off',
130
+ // 不允许使用 新的特性。这里关闭
131
+ 'unicorn/new-for-builtins': 'off',
124
132
  // 禁止将函数直接传给方法。这里关闭。
125
133
  'unicorn/no-array-callback-reference': 'off',
134
+ // 不允许使用 array的forEach。这里管理
135
+ 'unicorn/no-array-for-each': 'off',
136
+ // 不允许使用 array的reduce方法。这里关闭
137
+ 'unicorn/no-array-reduce': 'off',
138
+ // 不允许使用 new Array()声明数组。这里关闭
139
+ 'unicorn/no-new-array': 'off',
126
140
  // 不使用 null。这里关闭。实际上,与后台交互时,经常需要用到null。也更有语义化。
127
141
  'unicorn/no-null': 'off',
128
142
  // 强制使用数字分隔符。这里关闭。
129
143
  'unicorn/numeric-separators-style': 'off',
130
- // 名称校验,这里关闭
131
- 'import/named': 'off',
132
- // 禁止整个文件的注释,只允许注释文件块。这里关闭。
133
- 'eslint-comments/disable-enable-pair': 'off',
134
- // 函数名称后需要跟一个空格。这里关闭
135
- 'space-before-function-paren': 'off',
136
- // 返回值必须被使用。这里关闭
137
- 'sonarjs/no-ignored-return': 'off',
144
+ // 使用esm的格式,而不是commonjs。这里关闭。部分模块还是需要使用commonjs保证兼容性
145
+ 'unicorn/prefer-module': 'off',
138
146
  // 以下配置待整理完善,以上配置已整理,尽量不要动了。
139
147
  'array-bracket-spacing': ['error', 'never'],
140
148
  'arrow-parens': ['error', 'always'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zpcscc/configs",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "项目通用配置",
5
5
  "keywords": [
6
6
  "commitlint",
@@ -43,25 +43,25 @@
43
43
  "start": "dumi dev"
44
44
  },
45
45
  "dependencies": {
46
- "@babel/core": "7.23.3",
46
+ "@babel/core": "7.23.5",
47
47
  "@babel/plugin-syntax-flow": "7.23.3",
48
- "@babel/plugin-transform-react-jsx": "7.22.15",
49
- "@babel/runtime": "7.23.2",
50
- "@commitlint/cz-commitlint": "18.4.1",
51
- "@rushstack/eslint-patch": "1.5.1",
52
- "@types/node": "20.9.0",
53
- "@types/react": "18.2.37",
54
- "@types/react-dom": "18.2.15",
55
- "@typescript-eslint/eslint-plugin": "6.10.0",
56
- "@typescript-eslint/parser": "6.10.0",
48
+ "@babel/plugin-transform-react-jsx": "7.23.4",
49
+ "@babel/runtime": "7.23.5",
50
+ "@commitlint/cz-commitlint": "18.4.3",
51
+ "@rushstack/eslint-patch": "1.6.0",
52
+ "@types/node": "20.10.1",
53
+ "@types/react": "18.2.39",
54
+ "@types/react-dom": "18.2.17",
55
+ "@typescript-eslint/eslint-plugin": "6.13.1",
56
+ "@typescript-eslint/parser": "6.13.1",
57
57
  "@vue/eslint-config-prettier": "8.0.0",
58
58
  "@vue/eslint-config-typescript": "12.0.0",
59
- "commitizen": "4.0.3",
60
- "cosmiconfig": "8.3.6",
61
- "eslint": "8.53.0",
59
+ "commitizen": "4.3.0",
60
+ "cosmiconfig": "9.0.0",
61
+ "eslint": "8.54.0",
62
62
  "eslint-config-prettier": "9.0.0",
63
63
  "eslint-config-standard": "17.1.0",
64
- "eslint-config-standard-with-typescript": "39.1.1",
64
+ "eslint-config-standard-with-typescript": "40.0.0",
65
65
  "eslint-import-resolver-typescript": "3.6.1",
66
66
  "eslint-plugin-eslint-comments": "3.2.0",
67
67
  "eslint-plugin-import": "2.29.0",
@@ -73,10 +73,10 @@
73
73
  "eslint-plugin-react-hooks": "4.6.0",
74
74
  "eslint-plugin-sonarjs": "0.23.0",
75
75
  "eslint-plugin-unicorn": "49.0.0",
76
- "eslint-plugin-vue": "9.18.1",
76
+ "eslint-plugin-vue": "9.19.2",
77
77
  "inquirer": "8.2.5",
78
78
  "postcss": "8.4.31",
79
- "prettier": "3.0.3",
79
+ "prettier": "3.1.0",
80
80
  "prettier-plugin-organize-imports": "3.2.4",
81
81
  "prettier-plugin-packagejson": "2.4.6",
82
82
  "stylelint": "14.16.1",
@@ -87,13 +87,13 @@
87
87
  "devDependencies": {
88
88
  "dumi": "2.2.14",
89
89
  "father": "4.3.7",
90
- "gh-pages": "6.0.0",
90
+ "gh-pages": "6.1.0",
91
91
  "react": "18.2.0",
92
92
  "react-dom": "18.2.0",
93
93
  "react-is": "18.2.0",
94
94
  "styled-components": "6.1.1",
95
95
  "tslib": "2.6.2",
96
- "typescript": "5.2.2",
96
+ "typescript": "5.3.2",
97
97
  "webpack": "5.89.0"
98
98
  },
99
99
  "publishConfig": {
package/types/any.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ // * 一些通用any类型定义
2
+
3
+ // 任意函数类型
4
+ type AnyFunction = (...args: any[]) => any;
5
+ // 任意对象类型
6
+ type AnyObject = Record<string, any>;
package/types/index.d.ts CHANGED
@@ -2,3 +2,4 @@
2
2
  /* eslint-disable multiline-comment-style */
3
3
  /// <reference types="node" />
4
4
  /// <reference types="./files" />
5
+ /// <reference types="./any" />