@dlzn-ui/eslint-config 2.0.16 → 2.0.22

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,5 @@
1
+ import { Linter } from 'eslint';
2
+
3
+ declare const eslintConfig: Linter.Config[];
4
+
5
+ export { eslintConfig as default };
@@ -0,0 +1,5 @@
1
+ import { Linter } from 'eslint';
2
+
3
+ declare const eslintConfig: Linter.Config[];
4
+
5
+ export { eslintConfig as default };
package/dist/index.mjs ADDED
@@ -0,0 +1,230 @@
1
+ import antfu, { perfectionist } from '@antfu/eslint-config';
2
+ import { getDirectDirs } from '@dlzn-ui/node-utils';
3
+ import prettierOptions from '@dlzn-ui/prettier-config';
4
+ import perfectionist$1 from 'eslint-plugin-perfectionist';
5
+ import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
6
+ import { upperFirst, camelCase } from 'lodash-es';
7
+
8
+ const dlznUIComponentDirs = await getDirectDirs("node_modules/dlzn-ui/components/*");
9
+ const perfectionistConfig = await perfectionist({});
10
+ const eslintConfig = await antfu(
11
+ {
12
+ formatters: {
13
+ // 都默认开启了
14
+ css: true,
15
+ // 与 stylelint 一起
16
+ html: true,
17
+ markdown: true,
18
+ // 使用 prettier 格式化 markdown 文件,搭配 davidAnson.vscode-markdownlint 插件一起使用
19
+ prettierOptions: {
20
+ ...prettierOptions,
21
+ xmlQuoteAttributes: "preserve",
22
+ xmlSelfClosingSpace: true,
23
+ // 在自闭合标签之间添加空格
24
+ xmlSortAttributesByKey: true,
25
+ // 按属性键排序XML元素
26
+ xmlWhitespaceSensitivity: "ignore"
27
+ // 对XML全局空白敏感
28
+ },
29
+ // 配置 prettier 的配置,这里不会读 ignorePath 这个配置,否则 ignorePath 里面配置的文件都不会被 prettier 格式化了
30
+ svg: true,
31
+ xml: true
32
+ },
33
+ // `.eslintignore` is no longer supported in Flat config, use `ignores` instead
34
+ // GLOB_EXCLUDE 已经包括了大部分的忽略文件,遵守 gitignore 规则
35
+ ignores: ["folder-alias.json", "**/echarts/china.json", "**/vueBits/**/*.vue"],
36
+ jsonc: {
37
+ overrides: {
38
+ "jsonc/sort-array-values": [
39
+ "error",
40
+ {
41
+ minValues: 2,
42
+ order: {
43
+ caseSensitive: true,
44
+ natural: true,
45
+ type: "asc"
46
+ },
47
+ pathPattern: ".*"
48
+ }
49
+ ],
50
+ "jsonc/sort-keys": [
51
+ "error",
52
+ "asc",
53
+ {
54
+ allowLineSeparatedGroups: false,
55
+ caseSensitive: true,
56
+ minKeys: 2,
57
+ natural: true
58
+ }
59
+ ]
60
+ }
61
+ },
62
+ // jsonc: true, // 配合 vscode.json-language-features 一起使用 (默认为true) [jsonc: true 排序, vscode.json-language-features 截断好一点]
63
+ // 1、 Enable linting for **code snippets** in Markdown.
64
+ // 2. 也会把上面的 formatters.markdown 设置为true
65
+ // 3. 默认为true
66
+ // 4. 这里设置为false 是因为 现在格式化错误 https://github.com/antfu/eslint-config/discussions/851
67
+ markdown: false,
68
+ perfectionist: true,
69
+ // https://eslint.style/packages/default#rules
70
+ stylistic: {
71
+ indent: 2,
72
+ jsx: true,
73
+ overrides: {
74
+ "style/padding-line-between-statements": [
75
+ "error",
76
+ { blankLine: "never", next: "*", prev: "*" },
77
+ {
78
+ blankLine: "always",
79
+ next: "*",
80
+ prev: [
81
+ "import",
82
+ "export",
83
+ "class",
84
+ "function",
85
+ "multiline-block-like",
86
+ "const",
87
+ "let",
88
+ "var"
89
+ ]
90
+ },
91
+ {
92
+ blankLine: "always",
93
+ next: ["export", "class", "function", "multiline-block-like", "const", "let", "var"],
94
+ prev: "*"
95
+ },
96
+ { blankLine: "never", next: "import", prev: "import" },
97
+ { blankLine: "never", next: "export", prev: "export" },
98
+ {
99
+ blankLine: "never",
100
+ next: ["const", "let", "var"],
101
+ prev: ["const", "let", "var"]
102
+ }
103
+ ]
104
+ },
105
+ quotes: "single",
106
+ semi: false
107
+ },
108
+ // https://typescript-eslint.io/rules/
109
+ typescript: {
110
+ // other rules
111
+ overrides: {
112
+ "prefer-promise-reject-errors": "off"
113
+ },
114
+ // type checked rules
115
+ overridesTypeAware: {
116
+ "ts/no-floating-promises": "off",
117
+ "ts/no-unsafe-assignment": "off",
118
+ "ts/promise-function-async": "off",
119
+ "ts/strict-boolean-expressions": [
120
+ "error",
121
+ {
122
+ allowAny: false,
123
+ allowNullableBoolean: true,
124
+ allowNullableEnum: false,
125
+ allowNullableNumber: false,
126
+ allowNullableObject: false,
127
+ allowNullableString: true,
128
+ allowNumber: false,
129
+ allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: false,
130
+ allowString: true
131
+ }
132
+ ],
133
+ "ts/unbound-method": "off"
134
+ },
135
+ tsconfigPath: "tsconfig.json"
136
+ // Linting with Type Information https://typescript-eslint.io/getting-started/typed-linting/
137
+ },
138
+ vue: {
139
+ overrides: {
140
+ "vue/attributes-order": [
141
+ "error",
142
+ {
143
+ alphabetical: true,
144
+ ignoreVBindObject: false,
145
+ order: [
146
+ "DEFINITION",
147
+ "LIST_RENDERING",
148
+ "CONDITIONALS",
149
+ "RENDER_MODIFIERS",
150
+ "GLOBAL",
151
+ ["UNIQUE", "SLOT"],
152
+ "TWO_WAY_BINDING",
153
+ "OTHER_DIRECTIVES",
154
+ "OTHER_ATTR",
155
+ "EVENTS",
156
+ "CONTENT"
157
+ ],
158
+ sortLineLength: false
159
+ }
160
+ ],
161
+ "vue/component-name-in-template-casing": [
162
+ "error",
163
+ "PascalCase",
164
+ {
165
+ registeredComponentsOnly: false
166
+ }
167
+ ],
168
+ // 组件名必须为PascalCase
169
+ "vue/html-self-closing": [
170
+ "error",
171
+ {
172
+ html: {
173
+ component: "never",
174
+ normal: "never",
175
+ void: "always"
176
+ // 常见的 HTML 空元素 br, hr...
177
+ },
178
+ math: "always",
179
+ svg: "always"
180
+ }
181
+ ],
182
+ // html标签不要自闭合
183
+ "vue/padding-line-between-tags": ["error", [{ blankLine: "never", next: "*", prev: "*" }]],
184
+ "vue/prop-name-casing": [
185
+ "error",
186
+ "camelCase",
187
+ {
188
+ ignoreProps: ["/^onUpdate:*/"]
189
+ }
190
+ ],
191
+ "vue/singleline-html-element-content-newline": "off"
192
+ }
193
+ }
194
+ },
195
+ {
196
+ rules: {
197
+ "e18e/ban-dependencies": [
198
+ "error",
199
+ {
200
+ allowed: ["crypto-js", "lodash-es", "rimraf"]
201
+ }
202
+ ],
203
+ "no-console": "off",
204
+ "no-restricted-imports": [
205
+ "error",
206
+ {
207
+ paths: [
208
+ {
209
+ importNames: dlznUIComponentDirs.map((dir) => `${upperFirst(camelCase(dir))}`),
210
+ message: "dlzn-ui \u4E2D\u5DF2\u7ECF\u5B9A\u4E49\u4E86\u8BE5\u7EC4\u4EF6\uFF0C\u8BF7\u4E0D\u8981\u4ECE tdesign-vue-next \u4E2D\u5BFC\u5165",
211
+ name: "tdesign-vue-next"
212
+ }
213
+ ]
214
+ }
215
+ ],
216
+ "pnpm/json-enforce-catalog": "off"
217
+ }
218
+ }
219
+ ).override(perfectionistConfig[0].name, {
220
+ rules: {
221
+ ...perfectionist$1.configs["recommended-natural"].rules,
222
+ ...perfectionistConfig[0].rules
223
+ }
224
+ }).append({
225
+ ignores: ["**/*.md", "**/*.html", "**/*.xml", "**/*.svg", "**/*.jsonc"],
226
+ // https://github.com/prettier/eslint-plugin-prettier
227
+ ...eslintPluginPrettierRecommended
228
+ });
229
+
230
+ export { eslintConfig as default };
package/package.json CHANGED
@@ -1,16 +1,20 @@
1
1
  {
2
2
  "name": "@dlzn-ui/eslint-config",
3
3
  "type": "module",
4
- "version": "2.0.16",
4
+ "version": "2.0.22",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
9
9
  "exports": {
10
10
  ".": {
11
- "import": "./index.ts"
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.mjs"
12
13
  }
13
14
  },
15
+ "files": [
16
+ "dist"
17
+ ],
14
18
  "peerDependencies": {
15
19
  "eslint": "^10.8.1"
16
20
  },
@@ -21,6 +25,15 @@
21
25
  "eslint-plugin-format": "^2.0.1",
22
26
  "eslint-plugin-prettier": "^5.5.6",
23
27
  "jiti": "^2.7.0",
24
- "@dlzn-ui/prettier-config": "2.0.16"
28
+ "@dlzn-ui/node-utils": "2.0.22",
29
+ "@dlzn-ui/prettier-config": "2.0.22"
30
+ },
31
+ "devDependencies": {
32
+ "rimraf": "^6.1.3",
33
+ "unbuild": "^3.6.1"
34
+ },
35
+ "scripts": {
36
+ "build": "unbuild",
37
+ "stub": "unbuild --stub"
25
38
  }
26
39
  }
package/index.ts DELETED
@@ -1,209 +0,0 @@
1
- /* eslint-disable antfu/no-top-level-await */
2
- import type { Linter } from 'eslint'
3
- import antfu, { perfectionist as perfectionistConfigFn } from '@antfu/eslint-config'
4
- import prettierOptions from '@dlzn-ui/prettier-config'
5
- import perfectionist from 'eslint-plugin-perfectionist'
6
- import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
7
-
8
- const perfectionistConfig = await perfectionistConfigFn({})
9
- const eslintConfig: Linter.Config[] = await antfu(
10
- {
11
- formatters: {
12
- // 都默认开启了
13
- css: true, // 与 stylelint 一起
14
- html: true,
15
- markdown: true, // 使用 prettier 格式化 markdown 文件,搭配 davidAnson.vscode-markdownlint 插件一起使用
16
- prettierOptions: {
17
- ...prettierOptions,
18
- xmlQuoteAttributes: 'preserve',
19
- xmlSelfClosingSpace: true, // 在自闭合标签之间添加空格
20
- xmlSortAttributesByKey: true, // 按属性键排序XML元素
21
- xmlWhitespaceSensitivity: 'ignore', // 对XML全局空白敏感
22
- }, // 配置 prettier 的配置,这里不会读 ignorePath 这个配置,否则 ignorePath 里面配置的文件都不会被 prettier 格式化了
23
- svg: true,
24
- xml: true,
25
- },
26
- // `.eslintignore` is no longer supported in Flat config, use `ignores` instead
27
- // GLOB_EXCLUDE 已经包括了大部分的忽略文件,遵守 gitignore 规则
28
- ignores: ['folder-alias.json', '**/echarts/china.json', '**/vueBits/**/*.vue'],
29
- jsonc: {
30
- overrides: {
31
- 'jsonc/sort-array-values': [
32
- 'error',
33
- {
34
- minValues: 2,
35
- order: {
36
- caseSensitive: true,
37
- natural: true,
38
- type: 'asc',
39
- },
40
- pathPattern: '.*',
41
- },
42
- ],
43
- 'jsonc/sort-keys': [
44
- 'error',
45
- 'asc',
46
- {
47
- allowLineSeparatedGroups: false,
48
- caseSensitive: true,
49
- minKeys: 2,
50
- natural: true,
51
- },
52
- ],
53
- },
54
- },
55
- // jsonc: true, // 配合 vscode.json-language-features 一起使用 (默认为true) [jsonc: true 排序, vscode.json-language-features 截断好一点]
56
- // 1、 Enable linting for **code snippets** in Markdown.
57
- // 2. 也会把上面的 formatters.markdown 设置为true
58
- // 3. 默认为true
59
- // 4. 这里设置为false 是因为 现在格式化错误 https://github.com/antfu/eslint-config/discussions/851
60
- markdown: false,
61
- perfectionist: true,
62
- // https://eslint.style/packages/default#rules
63
- stylistic: {
64
- indent: 2,
65
- jsx: true,
66
- overrides: {
67
- 'style/padding-line-between-statements': [
68
- 'error',
69
- { blankLine: 'never', next: '*', prev: '*' },
70
- {
71
- blankLine: 'always',
72
- next: '*',
73
- prev: [
74
- 'import',
75
- 'export',
76
- 'class',
77
- 'function',
78
- 'multiline-block-like',
79
- 'const',
80
- 'let',
81
- 'var',
82
- ],
83
- },
84
- {
85
- blankLine: 'always',
86
- next: ['export', 'class', 'function', 'multiline-block-like', 'const', 'let', 'var'],
87
- prev: '*',
88
- },
89
- { blankLine: 'never', next: 'import', prev: 'import' },
90
- { blankLine: 'never', next: 'export', prev: 'export' },
91
- {
92
- blankLine: 'never',
93
- next: ['const', 'let', 'var'],
94
- prev: ['const', 'let', 'var'],
95
- },
96
- ],
97
- },
98
- quotes: 'single',
99
- semi: false,
100
- },
101
- // https://typescript-eslint.io/rules/
102
- typescript: {
103
- // other rules
104
- overrides: {
105
- 'prefer-promise-reject-errors': 'off',
106
- },
107
- // type checked rules
108
- overridesTypeAware: {
109
- 'ts/no-floating-promises': 'off',
110
- 'ts/no-unsafe-assignment': 'off',
111
- 'ts/promise-function-async': 'off',
112
- 'ts/strict-boolean-expressions': [
113
- 'error',
114
- {
115
- allowAny: false,
116
- allowNullableBoolean: true,
117
- allowNullableEnum: false,
118
- allowNullableNumber: false,
119
- allowNullableObject: false,
120
- allowNullableString: true,
121
- allowNumber: false,
122
- allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: false,
123
- allowString: true,
124
- },
125
- ],
126
- 'ts/unbound-method': 'off',
127
- },
128
- tsconfigPath: 'tsconfig.json', // Linting with Type Information https://typescript-eslint.io/getting-started/typed-linting/
129
- },
130
- vue: {
131
- overrides: {
132
- 'vue/attributes-order': [
133
- 'error',
134
- {
135
- alphabetical: true,
136
- ignoreVBindObject: false,
137
- order: [
138
- 'DEFINITION',
139
- 'LIST_RENDERING',
140
- 'CONDITIONALS',
141
- 'RENDER_MODIFIERS',
142
- 'GLOBAL',
143
- ['UNIQUE', 'SLOT'],
144
- 'TWO_WAY_BINDING',
145
- 'OTHER_DIRECTIVES',
146
- 'OTHER_ATTR',
147
- 'EVENTS',
148
- 'CONTENT',
149
- ],
150
- sortLineLength: false,
151
- },
152
- ],
153
- 'vue/component-name-in-template-casing': [
154
- 'error',
155
- 'PascalCase',
156
- {
157
- registeredComponentsOnly: false,
158
- },
159
- ], // 组件名必须为PascalCase
160
- 'vue/html-self-closing': [
161
- 'error',
162
- {
163
- html: {
164
- component: 'never',
165
- normal: 'never',
166
- void: 'always', // 常见的 HTML 空元素 br, hr...
167
- },
168
- math: 'always',
169
- svg: 'always',
170
- },
171
- ], // html标签不要自闭合
172
- 'vue/padding-line-between-tags': ['error', [{ blankLine: 'never', next: '*', prev: '*' }]],
173
- 'vue/prop-name-casing': [
174
- 'error',
175
- 'camelCase',
176
- {
177
- ignoreProps: ['/^onUpdate:*/'],
178
- },
179
- ],
180
- 'vue/singleline-html-element-content-newline': 'off',
181
- },
182
- },
183
- },
184
- {
185
- rules: {
186
- 'e18e/ban-dependencies': [
187
- 'error',
188
- {
189
- allowed: ['crypto-js', 'lodash-es', 'rimraf'],
190
- },
191
- ],
192
- 'no-console': 'off',
193
- 'pnpm/json-enforce-catalog': 'off',
194
- },
195
- },
196
- )
197
- .override(perfectionistConfig[0].name!, {
198
- rules: {
199
- ...perfectionist.configs['recommended-natural'].rules,
200
- ...perfectionistConfig[0].rules,
201
- },
202
- })
203
- .append({
204
- ignores: ['**/*.md', '**/*.html', '**/*.xml', '**/*.svg', '**/*.jsonc'],
205
- // https://github.com/prettier/eslint-plugin-prettier
206
- ...eslintPluginPrettierRecommended,
207
- })
208
-
209
- export default eslintConfig