@fast-china/eslint-config 1.0.23 → 1.0.25

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/dist/v8/index.d.cts +178 -0
  2. package/package.json +1 -1
@@ -0,0 +1,178 @@
1
+ const { defineConfig } = require("eslint-define-config");
2
+ const {
3
+ CONST_JS,
4
+ CONST_JSX,
5
+ CONST_TS,
6
+ CONST_TSX,
7
+ CONST_DTS,
8
+ CONST_TSCONFIG,
9
+ CONST_VUE,
10
+ CONST_JSON,
11
+ CONST_JSONC,
12
+ CONST_JSON5,
13
+ CONST_JSON6,
14
+ } = require("../constants/index");
15
+ const { isVue3 } = require("../env/index");
16
+ const { commonRules } = require("../rules/common");
17
+ const { importRules, importUseLodashUnifiedRules } = require("../rules/import");
18
+ const { javascriptRules } = require("../rules/javascript");
19
+ const { packageJsonSortRules } = require("../rules/sort-package");
20
+ const { tsconfigJsonSortRules } = require("../rules/sort-tsconfig");
21
+ const { typescriptRules } = require("../rules/typescript");
22
+ const { vueRules } = require("../rules/vue");
23
+
24
+ // @see: http://eslint.cn
25
+ module.exports = defineConfig({
26
+ env: {
27
+ es6: true,
28
+ browser: true,
29
+ node: true,
30
+ },
31
+ plugins: ["regexp", "@typescript-eslint", "prettier"],
32
+ // 继承某些已有的规则
33
+ extends: [
34
+ "eslint:recommended",
35
+ "plugin:import/recommended",
36
+ "plugin:regexp/recommended",
37
+ "plugin:@typescript-eslint/recommended",
38
+ "plugin:jsonc/recommended-with-jsonc",
39
+ isVue3 ? "plugin:vue/recommended" : "plugin:vue/vue2-recommended",
40
+ "plugin:prettier/recommended",
41
+ "plugin:markdown/recommended-legacy",
42
+ ],
43
+ globals: {
44
+ $: "readonly",
45
+ $$: "readonly",
46
+ $computed: "readonly",
47
+ $customRef: "readonly",
48
+ $ref: "readonly",
49
+ $shallowRef: "readonly",
50
+ $toRef: "readonly",
51
+ },
52
+ parserOptions: {
53
+ ecmaFeatures: {
54
+ // 允许使用 JSX 语法,适用于 Vue 组件中的 JSX 代码。
55
+ jsx: true,
56
+ },
57
+ sourceType: "module",
58
+ },
59
+ settings: {
60
+ // 确保 ESLint 和 eslint-plugin-import 能够正确解析项目中的所有相关文件类型
61
+ "import/resolver": {
62
+ node: {
63
+ extensions: [CONST_JS, CONST_JSX, CONST_TS, CONST_TSX, CONST_DTS],
64
+ },
65
+ },
66
+ },
67
+ overrides: [
68
+ {
69
+ files: ["**/*.md/*.js"],
70
+ rules: {
71
+ // 使用使用控制台
72
+ "no-console": "off",
73
+ // 关闭 - 禁止使用未声明的变量,除非/*global *\/注释中提到
74
+ "no-undef": "off",
75
+ // 关闭 - 禁用对无法解析的模块导入的检查
76
+ "import/no-unresolved": "off",
77
+ // 关闭 - 禁止在文件中重复导入相同的模块
78
+ "import/no-duplicates": "off",
79
+ },
80
+ },
81
+ {
82
+ files: ["**/scripts/*", "**/cli.*"],
83
+ rules: {
84
+ // 使用使用控制台
85
+ "no-console": "off",
86
+ },
87
+ },
88
+ {
89
+ files: [CONST_TS, CONST_TSX],
90
+ parserOptions: {
91
+ ecmaFeatures: {
92
+ // 允许使用 TSX 语法,适用于 Vue 组件中的 TSX 代码。
93
+ tsx: true,
94
+ },
95
+ sourceType: "module",
96
+ },
97
+ },
98
+ {
99
+ files: [CONST_DTS],
100
+ rules: {
101
+ // 关闭 - 一致地使用 TypeScript 类型导入
102
+ "@typescript-eslint/consistent-type-imports": "off",
103
+ },
104
+ },
105
+ {
106
+ files: ["**/vite.config.*"],
107
+ rules: {
108
+ // 关闭 - 要求在 TypeScript 函数和方法中显式地指定返回类型
109
+ "@typescript-eslint/explicit-function-return-type": "off",
110
+ },
111
+ },
112
+ {
113
+ files: ["**/*.md/*.ts"],
114
+ rules: {
115
+ // 允许定义未使用的变量
116
+ "@typescript-eslint/no-unused-vars": "off",
117
+ },
118
+ },
119
+ {
120
+ files: [CONST_JSON, CONST_JSONC, CONST_JSON5, CONST_JSON6],
121
+ // 允许 ESLint 处理 JSON 文件中的模板和脚本
122
+ parser: "jsonc-eslint-parser",
123
+ },
124
+ {
125
+ files: ["**/package.json"],
126
+ rules: packageJsonSortRules,
127
+ },
128
+ {
129
+ files: CONST_TSCONFIG,
130
+ rules: tsconfigJsonSortRules,
131
+ },
132
+ {
133
+ files: [CONST_VUE],
134
+ // 允许 ESLint 处理 Vue 文件中的模板和脚本
135
+ parser: "vue-eslint-parser",
136
+ parserOptions: {
137
+ // 允许在 Vue 文件中的脚本部分使用 TypeScript 语法
138
+ parser: "@typescript-eslint/parser",
139
+ // 指定额外的文件扩展名,告诉解析器 .vue 文件也需要处理
140
+ extraFileExtensions: [".vue"],
141
+ // 允许使用 JSX/TSX 语法,适用于 Vue 组件中的 JSX/TSX 代码。
142
+ ecmaFeatures: {
143
+ jsx: true,
144
+ tsx: true,
145
+ },
146
+ sourceType: "module",
147
+ },
148
+ rules: {
149
+ // 关闭 - 禁止使用未声明的变量,以避免在 .vue 文件中出现关于未定义变量的警告,这在 Vue 单文件组件中可能不适用或会导致不必要的警告
150
+ "no-undef": "off",
151
+
152
+ // 关闭 - 要求在 TypeScript 函数和方法中显式地指定返回类型
153
+ "@typescript-eslint/explicit-function-return-type": "off",
154
+ },
155
+ },
156
+ ],
157
+ /**
158
+ * "off" 或 0 ==> 关闭规则
159
+ * "warn" 或 1 ==> 打开的规则作为警告(不影响代码执行)
160
+ * "error" 或 2 ==> 规则作为一个错误(代码不能执行,界面报错)
161
+ */
162
+ rules: {
163
+ ...commonRules,
164
+
165
+ ...javascriptRules,
166
+
167
+ ...importRules,
168
+
169
+ ...importUseLodashUnifiedRules,
170
+
171
+ ...typescriptRules,
172
+
173
+ ...vueRules,
174
+
175
+ // 确保 Prettier 错误被 ESLint 捕获
176
+ "prettier/prettier": "error",
177
+ },
178
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fast-china/eslint-config",
3
- "version": "1.0.23",
3
+ "version": "1.0.25",
4
4
  "description": "Fast ESLint 规则库.",
5
5
  "type": "module",
6
6
  "keywords": [