@fast-china/eslint-config 2.0.0 → 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.
@@ -0,0 +1,309 @@
1
+ import { t as RuleOptions } from "../typegen.mjs";
2
+ //#region src/rules/angular.d.ts
3
+ /**
4
+ * Angular TypeScript 推荐规则。
5
+ *
6
+ * Angular ESLint 的拆分插件不直接导出 Flat Config 预置;本记录与 angular-eslint
7
+ * 22.x 的 `tsRecommended` 保持一致,并逐条说明启用理由。
8
+ */
9
+ declare const angularRules: {
10
+ "@angular-eslint/contextual-lifecycle": "error";
11
+ "@angular-eslint/no-empty-lifecycle-method": "error";
12
+ "@angular-eslint/no-input-rename": "error";
13
+ "@angular-eslint/no-inputs-metadata-property": "error";
14
+ "@angular-eslint/no-output-native": "error";
15
+ "@angular-eslint/no-output-on-prefix": "error";
16
+ "@angular-eslint/no-output-rename": "error";
17
+ "@angular-eslint/no-outputs-metadata-property": "error";
18
+ "@angular-eslint/prefer-inject": "error";
19
+ "@angular-eslint/prefer-on-push-component-change-detection": "error";
20
+ "@angular-eslint/prefer-standalone": "error";
21
+ "@angular-eslint/use-pipe-transform-interface": "error";
22
+ "@angular-eslint/use-lifecycle-interface": "warn";
23
+ };
24
+ /** Angular HTML 模板推荐规则,与 angular-eslint 22.x 的 `templateRecommended` 对齐。 */
25
+ declare const angularTemplateRules: {
26
+ "@angular-eslint/template/banana-in-box": "error";
27
+ "@angular-eslint/template/eqeqeq": "error";
28
+ "@angular-eslint/template/no-negated-async": "error";
29
+ "@angular-eslint/template/prefer-control-flow": "error";
30
+ };
31
+ /** Angular 模板无障碍规则;可通过 `angular.templateAccessibility` 整组关闭。 */
32
+ declare const angularTemplateAccessibilityRules: {
33
+ "@angular-eslint/template/alt-text": "error";
34
+ "@angular-eslint/template/click-events-have-key-events": "error";
35
+ "@angular-eslint/template/elements-content": "error";
36
+ "@angular-eslint/template/interactive-supports-focus": "error";
37
+ "@angular-eslint/template/label-has-associated-control": "error";
38
+ "@angular-eslint/template/mouse-events-have-key-events": "error";
39
+ "@angular-eslint/template/no-autofocus": "error";
40
+ "@angular-eslint/template/no-distracting-elements": "error";
41
+ "@angular-eslint/template/role-has-required-aria": "error";
42
+ "@angular-eslint/template/table-scope": "error";
43
+ "@angular-eslint/template/valid-aria": "error";
44
+ };
45
+ //#endregion
46
+ //#region src/rules/common.d.ts
47
+ /**
48
+ * 跨 JavaScript、TypeScript 与 Vue 脚本生效的公共规则。
49
+ *
50
+ * 维护约定:每条本地覆写都要说明启用原因;可能造成大面积改动、采用成本或
51
+ * 行为变化的规则使用 `[高影响]` 标记,并同步维护 `docs/rules-risk.zh.md`。
52
+ */
53
+ declare const commonRules: {
54
+ "array-callback-return": "error";
55
+ "no-alert": "warn";
56
+ "no-case-declarations": "error";
57
+ "no-multi-str": "error";
58
+ "no-with": "error";
59
+ "no-void": ["error", {
60
+ allowAsStatement: true;
61
+ }];
62
+ eqeqeq: ["error", "always", {
63
+ null: "ignore";
64
+ }];
65
+ "prefer-exponentiation-operator": "error";
66
+ "prefer-object-has-own": "error";
67
+ "sort-imports": ["warn", {
68
+ ignoreCase: false;
69
+ ignoreDeclarationSort: true;
70
+ ignoreMemberSort: false;
71
+ memberSyntaxSortOrder: ["none", "all", "multiple", "single"];
72
+ allowSeparatedGroups: false;
73
+ }];
74
+ };
75
+ //#endregion
76
+ //#region src/rules/import.d.ts
77
+ /** 默认启用的模块导入正确性与排序规则。 */
78
+ declare const importRules: {
79
+ "import-x/first": "error";
80
+ "import-x/no-duplicates": "error";
81
+ "import-x/order": ["error", {
82
+ groups: string[];
83
+ "newlines-between": "always";
84
+ alphabetize: {
85
+ order: "asc";
86
+ caseInsensitive: true;
87
+ };
88
+ warnOnUnassignedImports: true;
89
+ }];
90
+ "import-x/no-unresolved": "off";
91
+ "import-x/namespace": "off";
92
+ "import-x/default": "off";
93
+ "import-x/no-named-as-default": "off";
94
+ "import-x/no-named-as-default-member": "off";
95
+ "import-x/named": "off";
96
+ };
97
+ //#endregion
98
+ //#region src/rules/javascript.d.ts
99
+ /**
100
+ * JavaScript 本地覆写规则。
101
+ * 高影响规则的解释与关闭方式见 `docs/rules-risk.zh.md`。
102
+ */
103
+ declare const javascriptRules: {
104
+ "no-console": ["warn", {
105
+ allow: [string, string];
106
+ }];
107
+ "no-debugger": "error";
108
+ "no-constant-condition": ["error", {
109
+ checkLoops: false;
110
+ }];
111
+ "no-restricted-syntax": ["error", string];
112
+ "no-var": "error";
113
+ "no-empty": ["error", {
114
+ allowEmptyCatch: true;
115
+ }];
116
+ "no-irregular-whitespace": "error";
117
+ "no-use-before-define": ["warn", {
118
+ classes: true;
119
+ functions: false;
120
+ variables: true;
121
+ }];
122
+ "prefer-const": ["warn", {
123
+ destructuring: "all";
124
+ ignoreReadBeforeAssign: true;
125
+ }];
126
+ "prefer-arrow-callback": ["error", {
127
+ allowNamedFunctions: false;
128
+ allowUnboundThis: true;
129
+ }];
130
+ "object-shorthand": ["error", "always", {
131
+ ignoreConstructors: false;
132
+ avoidQuotes: true;
133
+ }];
134
+ "logical-assignment-operators": ["error", "always", {
135
+ enforceForIfStatements: true;
136
+ }];
137
+ "prefer-object-spread": "error";
138
+ "prefer-rest-params": "error";
139
+ "prefer-spread": "error";
140
+ "prefer-template": "error";
141
+ "no-redeclare": "error";
142
+ };
143
+ //#endregion
144
+ //#region src/rules/lodash.d.ts
145
+ /**
146
+ * 统一使用 `lodash-unified` 的可选导入策略。
147
+ *
148
+ * 该规则只约束静态 import/export 的模块来源,不会安装依赖,也不会检查动态
149
+ * `import()` 或 CommonJS `require()`。选择此策略的项目应自行安装 `lodash-unified`。
150
+ */
151
+ declare const preferLodashUnifiedRules: {
152
+ "no-restricted-imports": ["error", {
153
+ paths: {
154
+ name: string;
155
+ message: string;
156
+ }[];
157
+ patterns: {
158
+ group: string[];
159
+ message: string;
160
+ }[];
161
+ }];
162
+ };
163
+ /**
164
+ * 统一使用 `lodash` 的可选导入策略。
165
+ *
166
+ * 根入口和 `lodash/*` 子路径都允许使用;规则只负责避免与 `lodash-es` 或
167
+ * `lodash-unified` 混用,不替项目决定整包导入或按方法导入。
168
+ */
169
+ declare const preferLodashRules: {
170
+ "no-restricted-imports": ["error", {
171
+ paths: {
172
+ name: string;
173
+ message: string;
174
+ }[];
175
+ patterns: {
176
+ group: string[];
177
+ message: string;
178
+ }[];
179
+ }];
180
+ };
181
+ //#endregion
182
+ //#region src/rules/react.d.ts
183
+ /**
184
+ * React 本地覆写规则。
185
+ *
186
+ * `@eslint-react/recommended*` 负责组件、JSX、DOM 与 Web API 正确性,
187
+ * `react-hooks/recommended` 负责 React 官方 Hooks 与 Compiler 诊断。这里关闭两套
188
+ * 预置间的重复诊断,并补充少量明确的 DOM 安全约束。
189
+ */
190
+ declare const reactRules: {
191
+ "@eslint-react/error-boundaries": "off";
192
+ "@eslint-react/exhaustive-deps": "off";
193
+ "@eslint-react/purity": "off";
194
+ "@eslint-react/rules-of-hooks": "off";
195
+ "@eslint-react/set-state-in-effect": "off";
196
+ "@eslint-react/set-state-in-render": "off";
197
+ "@eslint-react/static-components": "off";
198
+ "@eslint-react/unsupported-syntax": "off";
199
+ "@eslint-react/use-memo": "off";
200
+ "@eslint-react/dom-no-missing-button-type": "error";
201
+ "@eslint-react/dom-no-missing-iframe-sandbox": "warn";
202
+ "@eslint-react/dom-no-unknown-property": "error";
203
+ "@eslint-react/dom-no-unsafe-target-blank": "error";
204
+ };
205
+ //#endregion
206
+ //#region src/rules/sort-package.d.ts
207
+ /**
208
+ * package.json 属性排序规则。
209
+ *
210
+ * `[高影响][可自动修复]`:仅在 `sortPackageJson: true` 时启用,首次修复可能重排大量字段。
211
+ * 注意:这里故意不排序 `exports` 内部键;条件导出的键顺序具有模块解析语义。
212
+ */
213
+ declare const packageJsonSortRules: {
214
+ "jsonc/sort-array-values": ["error", {
215
+ order: {
216
+ type: "asc";
217
+ };
218
+ pathPattern: string;
219
+ }];
220
+ "jsonc/sort-keys": ["error", {
221
+ order: string[];
222
+ pathPattern: string;
223
+ }, {
224
+ order: {
225
+ type: "asc";
226
+ };
227
+ pathPattern: string;
228
+ }, {
229
+ order: {
230
+ type: "asc";
231
+ };
232
+ pathPattern: string;
233
+ }];
234
+ };
235
+ //#endregion
236
+ //#region src/rules/sort-tsconfig.d.ts
237
+ /**
238
+ * tsconfig.json 属性排序规则。
239
+ *
240
+ * `[高影响][可自动修复]`:仅在 `sortTsconfig: true` 时启用,首次修复会重排大量字段,
241
+ * 但只改变 JSONC 的阅读顺序,不改变 TypeScript 编译选项值。
242
+ */
243
+ declare const tsconfigJsonSortRules: {
244
+ "jsonc/no-comments": "off";
245
+ "jsonc/sort-keys": ["error", {
246
+ order: string[];
247
+ pathPattern: string;
248
+ }, {
249
+ order: string[];
250
+ pathPattern: string;
251
+ }];
252
+ };
253
+ //#endregion
254
+ //#region src/rules/typescript.d.ts
255
+ /**
256
+ * TypeScript 本地覆写规则。
257
+ * 这里补充 typescript-eslint 预置;高影响规则需同步维护风险文档。
258
+ */
259
+ declare const typescriptRules: {
260
+ "@typescript-eslint/no-redeclare": "error";
261
+ "@typescript-eslint/no-unused-vars": ["error", {
262
+ args: "after-used";
263
+ argsIgnorePattern: string;
264
+ caughtErrors: "all";
265
+ caughtErrorsIgnorePattern: string;
266
+ ignoreRestSiblings: true;
267
+ varsIgnorePattern: string;
268
+ }];
269
+ "@typescript-eslint/no-namespace": "off";
270
+ "@typescript-eslint/no-explicit-any": "warn";
271
+ "@typescript-eslint/no-require-imports": "error";
272
+ "@typescript-eslint/no-unused-expressions": ["error", {
273
+ allowShortCircuit: true;
274
+ allowTernary: true;
275
+ }];
276
+ "@typescript-eslint/no-inferrable-types": "error";
277
+ "@typescript-eslint/no-non-null-assertion": "warn";
278
+ "@typescript-eslint/no-non-null-asserted-optional-chain": "error";
279
+ "@typescript-eslint/consistent-type-imports": ["error", {
280
+ disallowTypeAnnotations: false;
281
+ fixStyle: "inline-type-imports";
282
+ prefer: "type-imports";
283
+ }];
284
+ };
285
+ //#endregion
286
+ //#region src/rules/vue.d.ts
287
+ /**
288
+ * Vue SFC 本地覆写规则。
289
+ * 上游 `flat/recommended` 已覆盖基础正确性,这里只记录项目取舍与附加约束。
290
+ */
291
+ declare const vueRules: {
292
+ "vue/no-v-html": "warn";
293
+ "vue/require-default-prop": "off";
294
+ "vue/require-explicit-emits": "error";
295
+ "vue/multi-word-component-names": "off";
296
+ "vue/prefer-import-from-vue": "warn";
297
+ "vue/no-dupe-keys": "error";
298
+ "vue/no-mutating-props": "error";
299
+ "vue/no-reserved-component-names": "error";
300
+ "vue/no-v-text-v-html-on-component": "error";
301
+ "vue/custom-event-name-casing": ["error", "camelCase"];
302
+ "vue/one-component-per-file": "off";
303
+ "vue/attributes-order": ["error", {
304
+ order: ("DEFINITION" | "LIST_RENDERING" | "CONDITIONALS" | "RENDER_MODIFIERS" | "GLOBAL" | "UNIQUE" | "OTHER_ATTR" | "EVENTS" | "CONTENT")[];
305
+ }];
306
+ };
307
+ //#endregion
308
+ export { type RuleOptions, angularRules, angularTemplateAccessibilityRules, angularTemplateRules, commonRules, importRules, javascriptRules, packageJsonSortRules, preferLodashRules, preferLodashUnifiedRules, reactRules, tsconfigJsonSortRules, typescriptRules, vueRules };
309
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/rules/angular.ts","../../src/rules/common.ts","../../src/rules/import.ts","../../src/rules/javascript.ts","../../src/rules/lodash.ts","../../src/rules/react.ts","../../src/rules/sort-package.ts","../../src/rules/sort-tsconfig.ts","../../src/rules/typescript.ts","../../src/rules/vue.ts"],"mappings":";;;;;;;;cAQa;;;;;;;;;;;;;;;;cA8BA;;;;;;;cAYA;;;;;;;;;;;;;;;;;;;;;cC1CA;;;;;;;;;;;;;;;;;;;;;;;;;cCLA;;;;;;;;;;;;;;;;;;;;;;;;;cCGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cCEA;;;;;;;;;;;;;;;;;;cA+BA;;;;;;;;;;;;;;;;;;;;;cC9BA;;;;;;;;;;;;;;;;;;;;;;;cCDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cCAA;;;;;;;;;;;;;;;;cCFA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cCAA"}
@@ -0,0 +1,2 @@
1
+ import { a as reactRules, c as javascriptRules, d as angularRules, f as angularTemplateAccessibilityRules, i as packageJsonSortRules, l as importRules, n as typescriptRules, o as preferLodashRules, p as angularTemplateRules, r as tsconfigJsonSortRules, s as preferLodashUnifiedRules, t as vueRules, u as commonRules } from "../rules.mjs";
2
+ export { angularRules, angularTemplateAccessibilityRules, angularTemplateRules, commonRules, importRules, javascriptRules, packageJsonSortRules, preferLodashRules, preferLodashUnifiedRules, reactRules, tsconfigJsonSortRules, typescriptRules, vueRules };