@fast-china/eslint-config 1.0.24 → 1.0.26

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.
@@ -1,158 +0,0 @@
1
- import * as _typescript_eslint_utils_dist_ts_eslint from '@typescript-eslint/utils/dist/ts-eslint';
2
-
3
- /**
4
- * 公共配置
5
- * @description 最佳实践
6
- */
7
- declare const commonConfigs: _typescript_eslint_utils_dist_ts_eslint.FlatConfig.ConfigArray;
8
-
9
- /**
10
- * 忽略配置
11
- */
12
- declare const ignoresConfigs: _typescript_eslint_utils_dist_ts_eslint.FlatConfig.ConfigArray;
13
-
14
- /**
15
- * import配置
16
- */
17
- declare const importConfigs: _typescript_eslint_utils_dist_ts_eslint.FlatConfig.ConfigArray;
18
-
19
- /**
20
- * JavaScript配置
21
- */
22
- declare const javascriptConfigs: _typescript_eslint_utils_dist_ts_eslint.FlatConfig.ConfigArray;
23
-
24
- /**
25
- * Json配置
26
- */
27
- declare const jsonConfigs: _typescript_eslint_utils_dist_ts_eslint.FlatConfig.ConfigArray;
28
-
29
- /**
30
- * markdown配置
31
- */
32
- declare const markdownConfigs: _typescript_eslint_utils_dist_ts_eslint.FlatConfig.ConfigArray;
33
-
34
- /**
35
- * prettier配置
36
- */
37
- declare const prettierConfigs: _typescript_eslint_utils_dist_ts_eslint.FlatConfig.ConfigArray;
38
-
39
- /**
40
- * regexp配置
41
- */
42
- declare const regexpConfigs: _typescript_eslint_utils_dist_ts_eslint.FlatConfig.ConfigArray;
43
-
44
- /**
45
- * package.json 属性排序
46
- */
47
- declare const packageJsonSortConfigs: _typescript_eslint_utils_dist_ts_eslint.FlatConfig.ConfigArray;
48
-
49
- /**
50
- * tsconfig.json 属性排序
51
- */
52
- declare const tsconfigJsonSortConfigs: _typescript_eslint_utils_dist_ts_eslint.FlatConfig.ConfigArray;
53
-
54
- /**
55
- * TypeScript 核心配置
56
- */
57
- declare const typescriptCoreConfigs: _typescript_eslint_utils_dist_ts_eslint.FlatConfig.ConfigArray;
58
- /**
59
- * TypeScript配置
60
- */
61
- declare const typescriptConfigs: _typescript_eslint_utils_dist_ts_eslint.FlatConfig.ConfigArray;
62
-
63
- /**
64
- * vue配置
65
- */
66
- declare const vueConfigs: _typescript_eslint_utils_dist_ts_eslint.FlatConfig.ConfigArray;
67
-
68
- /**
69
- * JS
70
- */
71
- declare const CONST_JS = "**/*.?([cm])js";
72
- /**
73
- * JSX
74
- */
75
- declare const CONST_JSX = "**/*.?([cm])jsx";
76
- /**
77
- * TS
78
- */
79
- declare const CONST_TS = "**/*.?([cm])ts";
80
- /**
81
- * TSX
82
- */
83
- declare const CONST_TSX = "**/*.?([cm])tsx";
84
- /**
85
- * .d.ts
86
- */
87
- declare const CONST_DTS = "**/*.d.ts";
88
- /**
89
- * JSON
90
- */
91
- declare const CONST_JSON = "**/*.json";
92
- /**
93
- * JSONC
94
- */
95
- declare const CONST_JSONC = "**/*.jsonc";
96
- /**
97
- * JSON5
98
- */
99
- declare const CONST_JSON5 = "**/*.json5";
100
- /**
101
- * JSON6
102
- */
103
- declare const CONST_JSON6 = "**/*.json6";
104
- /**
105
- * MD
106
- */
107
- declare const CONST_MD = "**/*.md";
108
- /**
109
- * VUE
110
- */
111
- declare const CONST_VUE = "**/*.vue";
112
- /**
113
- * YAML
114
- */
115
- declare const CONST_YAML = "**/*.y?(a)ml";
116
- /**
117
- * node_modules
118
- */
119
- declare const CONST_NODE_MODULES = "**/node_modules";
120
- /**
121
- * 打包目录 dist
122
- */
123
- declare const CONST_DIST = "**/dist";
124
- /**
125
- * 包管理 lock 文件
126
- */
127
- declare const CONST_LOCKFILE: string[];
128
- /**
129
- * public
130
- */
131
- declare const CONST_PUBLIC = "**/public";
132
- /**
133
- * TS 配置文件
134
- */
135
- declare const CONST_TSCONFIG: string[];
136
-
137
- /**
138
- * JavaScript 预置配置
139
- *
140
- * @description ignores,common,javascript,import,regexp
141
- */
142
- declare const PresetJavascriptConfigs: _typescript_eslint_utils_dist_ts_eslint.FlatConfig.Config[];
143
- /**
144
- * JSON 预置配置
145
- */
146
- declare const PresetJsonConfigs: _typescript_eslint_utils_dist_ts_eslint.FlatConfig.Config[];
147
- /**
148
- * 基础预置配置
149
- *
150
- * @description javascript,typescript,json
151
- */
152
- declare const PresetBasicConfigs: _typescript_eslint_utils_dist_ts_eslint.FlatConfig.Config[];
153
- /**
154
- * 默认最全的配置
155
- */
156
- declare const _default: _typescript_eslint_utils_dist_ts_eslint.FlatConfig.Config[];
157
-
158
- export { CONST_DIST, CONST_DTS, CONST_JS, CONST_JSON, CONST_JSON5, CONST_JSON6, CONST_JSONC, CONST_JSX, CONST_LOCKFILE, CONST_MD, CONST_NODE_MODULES, CONST_PUBLIC, CONST_TS, CONST_TSCONFIG, CONST_TSX, CONST_VUE, CONST_YAML, PresetBasicConfigs, PresetJavascriptConfigs, PresetJsonConfigs, commonConfigs, _default as default, ignoresConfigs, importConfigs, javascriptConfigs, jsonConfigs, markdownConfigs, packageJsonSortConfigs, prettierConfigs, regexpConfigs, tsconfigJsonSortConfigs, typescriptConfigs, typescriptCoreConfigs, vueConfigs };
@@ -1,178 +0,0 @@
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
- });
@@ -1,178 +0,0 @@
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
- });