@dlzn-ui/eslint-config 0.0.1

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 (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -0
  3. package/index.ts +209 -0
  4. package/package.json +26 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dlzn-ui
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ - `@prettier/plugin-xml` 格式化xml、svg文件
2
+ - `eslint-plugin-format` 格式化css, html 等文件
3
+ - `jiti` [eslint 配置相关](https://eslint.org/docs/latest/use/configure/configuration-files#typescript-configuration-files)
package/index.ts ADDED
@@ -0,0 +1,209 @@
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', 'src/plugins/echarts/china.json', 'src/layout/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
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@dlzn-ui/eslint-config",
3
+ "type": "module",
4
+ "version": "0.0.1",
5
+ "license": "MIT",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "exports": {
10
+ ".": {
11
+ "import": "./index.ts"
12
+ }
13
+ },
14
+ "peerDependencies": {
15
+ "eslint": "^10.8.1"
16
+ },
17
+ "dependencies": {
18
+ "@antfu/eslint-config": "^9.3.0",
19
+ "@prettier/plugin-xml": "^3.4.2",
20
+ "eslint-config-prettier": "^10.1.8",
21
+ "eslint-plugin-format": "^2.0.1",
22
+ "eslint-plugin-prettier": "^5.5.6",
23
+ "jiti": "^2.7.0",
24
+ "@dlzn-ui/prettier-config": "0.0.1"
25
+ }
26
+ }