@daopk/eslint-config 0.0.4 → 0.1.0
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.
- package/dist/index.d.ts +926 -195
- package/dist/index.js +171 -130
- package/package.json +16 -16
package/dist/index.js
CHANGED
|
@@ -1,20 +1,134 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
// src/configs/antfu.ts
|
|
2
|
+
import antfuPlugin from "eslint-plugin-antfu";
|
|
3
|
+
function antfu() {
|
|
4
|
+
return {
|
|
5
|
+
name: "daopk/antfu",
|
|
6
|
+
plugins: {
|
|
7
|
+
antfu: antfuPlugin
|
|
8
|
+
},
|
|
9
|
+
rules: {
|
|
10
|
+
"antfu/consistent-chaining": "error",
|
|
11
|
+
"antfu/consistent-list-newline": "error",
|
|
12
|
+
"antfu/import-dedupe": "error"
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// src/configs/builtin.ts
|
|
18
|
+
function builtin() {
|
|
19
|
+
return {
|
|
20
|
+
name: "daopk/eslint",
|
|
21
|
+
rules: {
|
|
22
|
+
"eqeqeq": "error",
|
|
23
|
+
"no-cond-assign": ["error", "always"],
|
|
24
|
+
"no-extra-boolean-cast": "error",
|
|
25
|
+
"no-regex-spaces": "error",
|
|
26
|
+
"no-unused-labels": "error",
|
|
27
|
+
"no-unused-vars": "off",
|
|
28
|
+
"object-curly-newline": "off",
|
|
29
|
+
"yoda": ["error", "never"]
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// src/configs/ignores.ts
|
|
5
35
|
import gitignore from "eslint-config-flat-gitignore";
|
|
6
|
-
|
|
36
|
+
function ignores(userIgnores = []) {
|
|
37
|
+
return {
|
|
38
|
+
name: "daopk/ignores",
|
|
39
|
+
ignores: [
|
|
40
|
+
...gitignore().ignores,
|
|
41
|
+
...userIgnores ?? []
|
|
42
|
+
]
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// src/configs/imports.ts
|
|
7
47
|
import importX from "eslint-plugin-import-x";
|
|
8
|
-
import node from "eslint-plugin-n";
|
|
9
|
-
import perfectionist from "eslint-plugin-perfectionist";
|
|
10
48
|
import unusedImports from "eslint-plugin-unused-imports";
|
|
11
|
-
function
|
|
12
|
-
|
|
49
|
+
function imports() {
|
|
50
|
+
return {
|
|
51
|
+
name: "daopk/imports",
|
|
52
|
+
plugins: {
|
|
53
|
+
"import": importX,
|
|
54
|
+
"unused-imports": unusedImports
|
|
55
|
+
},
|
|
56
|
+
rules: {
|
|
57
|
+
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
|
|
58
|
+
"import/first": "error",
|
|
59
|
+
"import/no-duplicates": "error",
|
|
60
|
+
"import/no-mutable-exports": "error",
|
|
61
|
+
"import/no-named-default": "error",
|
|
62
|
+
"import/no-self-import": "error",
|
|
63
|
+
"import/no-webpack-loader-syntax": "error",
|
|
64
|
+
"unused-imports/no-unused-imports": "error",
|
|
65
|
+
"unused-imports/no-unused-vars": [
|
|
66
|
+
"warn",
|
|
67
|
+
{
|
|
68
|
+
args: "after-used",
|
|
69
|
+
argsIgnorePattern: "^_",
|
|
70
|
+
vars: "all",
|
|
71
|
+
varsIgnorePattern: "^_"
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// src/configs/node.ts
|
|
79
|
+
import nodePlugin from "eslint-plugin-n";
|
|
80
|
+
function node() {
|
|
81
|
+
return {
|
|
82
|
+
name: "daopk/node",
|
|
83
|
+
plugins: {
|
|
84
|
+
node: nodePlugin
|
|
85
|
+
},
|
|
86
|
+
rules: {
|
|
87
|
+
"node/prefer-node-protocol": "error"
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// src/configs/perfectionist.ts
|
|
93
|
+
import perfectionistPlugin from "eslint-plugin-perfectionist";
|
|
94
|
+
function perfectionist() {
|
|
95
|
+
return {
|
|
96
|
+
name: "daopk/perfectionist",
|
|
97
|
+
plugins: {
|
|
98
|
+
perfectionist: perfectionistPlugin
|
|
99
|
+
},
|
|
100
|
+
rules: {
|
|
101
|
+
"perfectionist/sort-exports": ["error", { order: "asc", type: "natural" }],
|
|
102
|
+
"perfectionist/sort-imports": ["error", {
|
|
103
|
+
groups: [
|
|
104
|
+
"type",
|
|
105
|
+
["parent-type", "sibling-type", "index-type", "internal-type"],
|
|
106
|
+
"builtin",
|
|
107
|
+
"external",
|
|
108
|
+
"internal",
|
|
109
|
+
["parent", "sibling", "index"],
|
|
110
|
+
"side-effect",
|
|
111
|
+
"object",
|
|
112
|
+
"unknown"
|
|
113
|
+
],
|
|
114
|
+
newlinesBetween: "ignore",
|
|
115
|
+
order: "asc",
|
|
116
|
+
type: "natural"
|
|
117
|
+
}],
|
|
118
|
+
"perfectionist/sort-named-exports": ["error", { order: "asc", type: "natural" }],
|
|
119
|
+
"perfectionist/sort-named-imports": ["error", { order: "asc", type: "natural" }]
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// src/configs/stylistic.ts
|
|
125
|
+
import stylisticPlugin from "@stylistic/eslint-plugin";
|
|
126
|
+
function stylistic(options = {}) {
|
|
127
|
+
const stylisticConfig = stylisticPlugin.configs.customize({
|
|
13
128
|
arrowParens: options.arrowParens ?? true,
|
|
14
129
|
blockSpacing: options.blockSpacing,
|
|
15
130
|
braceStyle: options.braceStyle,
|
|
16
131
|
commaDangle: options.commaDangle,
|
|
17
|
-
flat: true,
|
|
18
132
|
indent: options.indent ?? 4,
|
|
19
133
|
jsx: options.jsx,
|
|
20
134
|
pluginName: "stylistic",
|
|
@@ -22,131 +136,58 @@ function daopk(options = {}, ...userConfigs) {
|
|
|
22
136
|
quotes: options.quotes ?? "single",
|
|
23
137
|
semi: options.semi ?? false
|
|
24
138
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
],
|
|
31
|
-
name: "daopk/ignores"
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
name: "daopk/eslint",
|
|
35
|
-
rules: {
|
|
36
|
-
"eqeqeq": "error",
|
|
37
|
-
"no-cond-assign": ["error", "always"],
|
|
38
|
-
"no-extra-boolean-cast": "error",
|
|
39
|
-
"no-regex-spaces": "error",
|
|
40
|
-
"no-unused-labels": "error",
|
|
41
|
-
"no-unused-vars": "off",
|
|
42
|
-
"object-curly-newline": "off",
|
|
43
|
-
"yoda": ["error", "never"]
|
|
139
|
+
return {
|
|
140
|
+
name: "daopk/stylistic",
|
|
141
|
+
plugins: {
|
|
142
|
+
stylistic: {
|
|
143
|
+
rules: stylisticPlugin.rules
|
|
44
144
|
}
|
|
45
145
|
},
|
|
46
|
-
{
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
name: "daopk/typescript",
|
|
65
|
-
plugins: {
|
|
66
|
-
typescript
|
|
67
|
-
},
|
|
68
|
-
rules: {
|
|
69
|
-
"typescript/consistent-type-imports": ["error", {
|
|
70
|
-
disallowTypeAnnotations: false,
|
|
71
|
-
fixStyle: "separate-type-imports",
|
|
72
|
-
prefer: "type-imports"
|
|
73
|
-
}],
|
|
74
|
-
"typescript/no-unused-vars": "off"
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
name: "daopk/imports",
|
|
79
|
-
plugins: {
|
|
80
|
-
"import": importX,
|
|
81
|
-
"unused-imports": unusedImports
|
|
82
|
-
},
|
|
83
|
-
rules: {
|
|
84
|
-
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
|
|
85
|
-
"import/first": "error",
|
|
86
|
-
"import/no-duplicates": "error",
|
|
87
|
-
"import/no-mutable-exports": "error",
|
|
88
|
-
"import/no-named-default": "error",
|
|
89
|
-
"import/no-self-import": "error",
|
|
90
|
-
"import/no-webpack-loader-syntax": "error",
|
|
91
|
-
"unused-imports/no-unused-imports": "error",
|
|
92
|
-
"unused-imports/no-unused-vars": [
|
|
93
|
-
"warn",
|
|
94
|
-
{
|
|
95
|
-
args: "after-used",
|
|
96
|
-
argsIgnorePattern: "^_",
|
|
97
|
-
vars: "all",
|
|
98
|
-
varsIgnorePattern: "^_"
|
|
99
|
-
}
|
|
100
|
-
]
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
name: "daopk/antfu",
|
|
105
|
-
plugins: {
|
|
106
|
-
antfu
|
|
107
|
-
},
|
|
108
|
-
rules: {
|
|
109
|
-
"antfu/consistent-chaining": "error",
|
|
110
|
-
"antfu/consistent-list-newline": "error",
|
|
111
|
-
"antfu/import-dedupe": "error"
|
|
112
|
-
}
|
|
146
|
+
rules: {
|
|
147
|
+
...stylisticConfig.rules,
|
|
148
|
+
"stylistic/array-bracket-newline": ["error", "consistent"],
|
|
149
|
+
"stylistic/array-element-newline": ["error", "consistent"]
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// src/configs/typescript.ts
|
|
155
|
+
import typescriptPlugin from "@typescript-eslint/eslint-plugin";
|
|
156
|
+
import tsParser from "@typescript-eslint/parser";
|
|
157
|
+
function typescript() {
|
|
158
|
+
return {
|
|
159
|
+
files: ["**/*.ts"],
|
|
160
|
+
languageOptions: {
|
|
161
|
+
ecmaVersion: "latest",
|
|
162
|
+
parser: tsParser,
|
|
163
|
+
sourceType: "module"
|
|
113
164
|
},
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
node
|
|
118
|
-
},
|
|
119
|
-
rules: {
|
|
120
|
-
"node/prefer-node-protocol": "error"
|
|
121
|
-
}
|
|
165
|
+
name: "daopk/typescript",
|
|
166
|
+
plugins: {
|
|
167
|
+
typescript: typescriptPlugin
|
|
122
168
|
},
|
|
123
|
-
{
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
"perfectionist/sort-imports": ["error", {
|
|
131
|
-
groups: [
|
|
132
|
-
"type",
|
|
133
|
-
["parent-type", "sibling-type", "index-type", "internal-type"],
|
|
134
|
-
"builtin",
|
|
135
|
-
"external",
|
|
136
|
-
"internal",
|
|
137
|
-
["parent", "sibling", "index"],
|
|
138
|
-
"side-effect",
|
|
139
|
-
"object",
|
|
140
|
-
"unknown"
|
|
141
|
-
],
|
|
142
|
-
newlinesBetween: "ignore",
|
|
143
|
-
order: "asc",
|
|
144
|
-
type: "natural"
|
|
145
|
-
}],
|
|
146
|
-
"perfectionist/sort-named-exports": ["error", { order: "asc", type: "natural" }],
|
|
147
|
-
"perfectionist/sort-named-imports": ["error", { order: "asc", type: "natural" }]
|
|
148
|
-
}
|
|
169
|
+
rules: {
|
|
170
|
+
"typescript/consistent-type-imports": ["error", {
|
|
171
|
+
disallowTypeAnnotations: false,
|
|
172
|
+
fixStyle: "separate-type-imports",
|
|
173
|
+
prefer: "type-imports"
|
|
174
|
+
}],
|
|
175
|
+
"typescript/no-unused-vars": "off"
|
|
149
176
|
}
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// src/index.ts
|
|
181
|
+
function daopk(options = {}, ...userConfigs) {
|
|
182
|
+
const configs = [
|
|
183
|
+
ignores(options.ignores),
|
|
184
|
+
builtin(),
|
|
185
|
+
stylistic(options.stylistic),
|
|
186
|
+
typescript(),
|
|
187
|
+
imports(),
|
|
188
|
+
antfu(),
|
|
189
|
+
node(),
|
|
190
|
+
perfectionist()
|
|
150
191
|
];
|
|
151
192
|
if (options.rules) {
|
|
152
193
|
configs.push({
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@daopk/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0
|
|
4
|
+
"version": "0.1.0",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "github:daopk/eslint-config",
|
|
7
7
|
"exports": {
|
|
@@ -13,26 +13,26 @@
|
|
|
13
13
|
"dist"
|
|
14
14
|
],
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@stylistic/eslint-plugin": "^
|
|
17
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
18
|
-
"@typescript-eslint/parser": "^8.
|
|
19
|
-
"eslint-config-flat-gitignore": "^2.
|
|
20
|
-
"eslint-plugin-antfu": "^3.
|
|
16
|
+
"@stylistic/eslint-plugin": "^4.2.0",
|
|
17
|
+
"@typescript-eslint/eslint-plugin": "^8.26.0",
|
|
18
|
+
"@typescript-eslint/parser": "^8.26.0",
|
|
19
|
+
"eslint-config-flat-gitignore": "^2.1.0",
|
|
20
|
+
"eslint-plugin-antfu": "^3.1.0",
|
|
21
21
|
"eslint-plugin-import-x": "^4.6.1",
|
|
22
|
-
"eslint-plugin-n": "^17.
|
|
23
|
-
"eslint-plugin-perfectionist": "^4.
|
|
22
|
+
"eslint-plugin-n": "^17.16.2",
|
|
23
|
+
"eslint-plugin-perfectionist": "^4.9.0",
|
|
24
24
|
"eslint-plugin-unused-imports": "^4.1.4"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@eslint/config-inspector": "^1.0.
|
|
28
|
-
"@types/node": "^22.13.
|
|
29
|
-
"bumpp": "^10.0.
|
|
30
|
-
"eslint": "^9.
|
|
31
|
-
"eslint-typegen": "^1.0
|
|
27
|
+
"@eslint/config-inspector": "^1.0.2",
|
|
28
|
+
"@types/node": "^22.13.9",
|
|
29
|
+
"bumpp": "^10.0.3",
|
|
30
|
+
"eslint": "^9.26.0",
|
|
31
|
+
"eslint-typegen": "^2.1.0",
|
|
32
32
|
"jiti": "^2.4.2",
|
|
33
|
-
"tsup": "^8.
|
|
34
|
-
"tsx": "^4.19.
|
|
35
|
-
"typescript": "^5.
|
|
33
|
+
"tsup": "^8.4.0",
|
|
34
|
+
"tsx": "^4.19.3",
|
|
35
|
+
"typescript": "^5.8.2"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"dev": "eslint-config-inspector",
|