@daopk/eslint-config 0.2.0 → 0.3.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.
Files changed (3) hide show
  1. package/dist/index.d.ts +5521 -6058
  2. package/dist/index.js +197 -201
  3. package/package.json +18 -18
package/dist/index.js CHANGED
@@ -1,231 +1,227 @@
1
- // src/configs/antfu.ts
2
1
  import antfuPlugin from "eslint-plugin-antfu";
2
+ import gitignore from "eslint-config-flat-gitignore";
3
+ import importX from "eslint-plugin-import-x";
4
+ import unusedImports from "eslint-plugin-unused-imports";
5
+ import nodePlugin from "eslint-plugin-n";
6
+ import perfectionistPlugin from "eslint-plugin-perfectionist";
7
+ import stylisticPlugin from "@stylistic/eslint-plugin";
8
+ import typescriptPlugin from "@typescript-eslint/eslint-plugin";
9
+ import tsParser from "@typescript-eslint/parser";
10
+
11
+ //#region src/configs/antfu.ts
3
12
  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
- };
13
+ return {
14
+ name: "daopk/antfu",
15
+ plugins: { antfu: antfuPlugin },
16
+ rules: {
17
+ "antfu/consistent-chaining": "error",
18
+ "antfu/consistent-list-newline": "error",
19
+ "antfu/import-dedupe": "error"
20
+ }
21
+ };
15
22
  }
16
23
 
17
- // src/configs/builtin.ts
24
+ //#endregion
25
+ //#region src/configs/builtin.ts
18
26
  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
- };
27
+ return {
28
+ name: "daopk/eslint",
29
+ rules: {
30
+ "eqeqeq": "error",
31
+ "no-cond-assign": ["error", "always"],
32
+ "no-extra-boolean-cast": "error",
33
+ "no-regex-spaces": "error",
34
+ "no-unused-labels": "error",
35
+ "no-unused-vars": "off",
36
+ "yoda": ["error", "never"]
37
+ }
38
+ };
32
39
  }
33
40
 
34
- // src/configs/ignores.ts
35
- import gitignore from "eslint-config-flat-gitignore";
41
+ //#endregion
42
+ //#region src/configs/ignores.ts
36
43
  function ignores(userIgnores = []) {
37
- return {
38
- name: "daopk/ignores",
39
- ignores: [
40
- ...gitignore().ignores,
41
- ...userIgnores ?? []
42
- ]
43
- };
44
+ return {
45
+ name: "daopk/ignores",
46
+ ignores: [...gitignore().ignores, ...userIgnores ?? []]
47
+ };
44
48
  }
45
49
 
46
- // src/configs/imports.ts
47
- import importX from "eslint-plugin-import-x";
48
- import unusedImports from "eslint-plugin-unused-imports";
50
+ //#endregion
51
+ //#region src/configs/imports.ts
49
52
  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
- };
53
+ return {
54
+ name: "daopk/imports",
55
+ plugins: {
56
+ "import": importX,
57
+ "unused-imports": unusedImports
58
+ },
59
+ rules: {
60
+ "import/consistent-type-specifier-style": ["error", "prefer-top-level"],
61
+ "import/first": "error",
62
+ "import/no-duplicates": "error",
63
+ "import/no-mutable-exports": "error",
64
+ "import/no-named-default": "error",
65
+ "import/no-self-import": "error",
66
+ "import/no-webpack-loader-syntax": "error",
67
+ "unused-imports/no-unused-imports": "error",
68
+ "unused-imports/no-unused-vars": ["warn", {
69
+ args: "after-used",
70
+ argsIgnorePattern: "^_",
71
+ vars: "all",
72
+ varsIgnorePattern: "^_"
73
+ }]
74
+ }
75
+ };
76
76
  }
77
77
 
78
- // src/configs/node.ts
79
- import nodePlugin from "eslint-plugin-n";
78
+ //#endregion
79
+ //#region src/configs/node.ts
80
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
- };
81
+ return {
82
+ name: "daopk/node",
83
+ plugins: { node: nodePlugin },
84
+ rules: { "node/prefer-node-protocol": "error" }
85
+ };
90
86
  }
91
87
 
92
- // src/configs/perfectionist.ts
93
- import perfectionistPlugin from "eslint-plugin-perfectionist";
88
+ //#endregion
89
+ //#region src/configs/perfectionist.ts
94
90
  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
- };
91
+ return {
92
+ name: "daopk/perfectionist",
93
+ plugins: { perfectionist: perfectionistPlugin },
94
+ rules: {
95
+ "perfectionist/sort-exports": ["error", {
96
+ order: "asc",
97
+ type: "natural"
98
+ }],
99
+ "perfectionist/sort-imports": ["error", {
100
+ groups: [
101
+ "type",
102
+ [
103
+ "parent-type",
104
+ "sibling-type",
105
+ "index-type",
106
+ "internal-type"
107
+ ],
108
+ "builtin",
109
+ "external",
110
+ "internal",
111
+ [
112
+ "parent",
113
+ "sibling",
114
+ "index"
115
+ ],
116
+ "side-effect",
117
+ "object",
118
+ "unknown"
119
+ ],
120
+ newlinesBetween: "ignore",
121
+ order: "asc",
122
+ type: "natural"
123
+ }],
124
+ "perfectionist/sort-named-exports": ["error", {
125
+ order: "asc",
126
+ type: "natural"
127
+ }],
128
+ "perfectionist/sort-named-imports": ["error", {
129
+ order: "asc",
130
+ type: "natural"
131
+ }]
132
+ }
133
+ };
122
134
  }
123
135
 
124
- // src/configs/stylistic.ts
125
- import stylisticPlugin from "@stylistic/eslint-plugin";
136
+ //#endregion
137
+ //#region src/configs/stylistic.ts
126
138
  function stylistic(options = {}) {
127
- const stylisticConfig = stylisticPlugin.configs.customize({
128
- arrowParens: options.arrowParens ?? true,
129
- blockSpacing: options.blockSpacing,
130
- braceStyle: options.braceStyle,
131
- commaDangle: options.commaDangle,
132
- indent: options.indent ?? 4,
133
- jsx: options.jsx,
134
- pluginName: "stylistic",
135
- quoteProps: options.quoteProps,
136
- quotes: options.quotes ?? "single",
137
- semi: options.semi ?? false
138
- });
139
- return {
140
- name: "daopk/stylistic",
141
- plugins: {
142
- stylistic: {
143
- rules: stylisticPlugin.rules
144
- }
145
- },
146
- rules: {
147
- ...stylisticConfig.rules,
148
- "stylistic/array-bracket-newline": ["error", "consistent"],
149
- "stylistic/array-element-newline": ["error", "consistent"]
150
- }
151
- };
139
+ const stylisticConfig = stylisticPlugin.configs.customize({
140
+ arrowParens: options.arrowParens ?? true,
141
+ blockSpacing: options.blockSpacing,
142
+ braceStyle: options.braceStyle,
143
+ commaDangle: options.commaDangle,
144
+ indent: options.indent ?? 4,
145
+ jsx: options.jsx,
146
+ pluginName: "stylistic",
147
+ quoteProps: options.quoteProps,
148
+ quotes: options.quotes ?? "single",
149
+ semi: options.semi ?? false
150
+ });
151
+ return {
152
+ name: "daopk/stylistic",
153
+ plugins: { stylistic: { rules: stylisticPlugin.rules } },
154
+ rules: {
155
+ ...stylisticConfig.rules,
156
+ "stylistic/array-bracket-newline": ["error", "consistent"],
157
+ "stylistic/array-element-newline": ["error", "consistent"]
158
+ }
159
+ };
152
160
  }
153
161
 
154
- // src/configs/typescript.ts
155
- import typescriptPlugin from "@typescript-eslint/eslint-plugin";
156
- import tsParser from "@typescript-eslint/parser";
162
+ //#endregion
163
+ //#region src/configs/typescript.ts
157
164
  function typescript({ rules } = {}) {
158
- return {
159
- files: ["**/*.ts"],
160
- languageOptions: {
161
- ecmaVersion: "latest",
162
- parser: tsParser,
163
- sourceType: "module"
164
- },
165
- name: "daopk/typescript",
166
- plugins: {
167
- typescript: typescriptPlugin
168
- },
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",
176
- ...rules
177
- }
178
- };
165
+ return {
166
+ files: ["**/*.ts"],
167
+ languageOptions: {
168
+ ecmaVersion: "latest",
169
+ parser: tsParser,
170
+ sourceType: "module"
171
+ },
172
+ name: "daopk/typescript",
173
+ plugins: { typescript: typescriptPlugin },
174
+ rules: {
175
+ "typescript/consistent-type-imports": ["error", {
176
+ disallowTypeAnnotations: false,
177
+ fixStyle: "separate-type-imports",
178
+ prefer: "type-imports"
179
+ }],
180
+ "typescript/no-unused-vars": "off",
181
+ ...rules
182
+ }
183
+ };
179
184
  }
180
185
 
181
- // src/presets/nestjs.ts
186
+ //#endregion
187
+ //#region src/presets/nestjs.ts
182
188
  function presetNestjs(options = {}) {
183
- return [
184
- ignores(options.ignores),
185
- builtin(),
186
- stylistic({
187
- semi: true,
188
- jsx: false,
189
- ...options.stylistic
190
- }),
191
- typescript({
192
- rules: {
193
- "typescript/consistent-type-imports": ["warn", { prefer: "no-type-imports" }]
194
- }
195
- }),
196
- imports(),
197
- antfu(),
198
- node(),
199
- perfectionist()
200
- ];
189
+ return [
190
+ ignores(options.ignores),
191
+ builtin(),
192
+ stylistic({
193
+ semi: true,
194
+ jsx: false,
195
+ ...options.stylistic
196
+ }),
197
+ typescript({ rules: { "typescript/consistent-type-imports": ["warn", { prefer: "no-type-imports" }] } }),
198
+ imports(),
199
+ antfu(),
200
+ node(),
201
+ perfectionist()
202
+ ];
201
203
  }
202
204
 
203
- // src/index.ts
205
+ //#endregion
206
+ //#region src/index.ts
204
207
  function daopk(options = {}, ...userConfigs) {
205
- const configs = [
206
- ignores(options.ignores),
207
- builtin(),
208
- stylistic(options.stylistic),
209
- typescript(),
210
- imports(),
211
- antfu(),
212
- node(),
213
- perfectionist()
214
- ];
215
- if (options.rules) {
216
- configs.push({
217
- name: "daopk/rules",
218
- rules: {
219
- ...options.rules
220
- }
221
- });
222
- }
223
- if (userConfigs.length > 0) {
224
- configs.push(...userConfigs);
225
- }
226
- return configs;
208
+ const configs = [
209
+ ignores(options.ignores),
210
+ builtin(),
211
+ stylistic(options.stylistic),
212
+ typescript(),
213
+ imports(),
214
+ antfu(),
215
+ node(),
216
+ perfectionist()
217
+ ];
218
+ if (options.rules) configs.push({
219
+ name: "daopk/rules",
220
+ rules: { ...options.rules }
221
+ });
222
+ if (userConfigs.length > 0) configs.push(...userConfigs);
223
+ return configs;
227
224
  }
228
- export {
229
- daopk as default,
230
- presetNestjs
231
- };
225
+
226
+ //#endregion
227
+ export { daopk as default, presetNestjs };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@daopk/eslint-config",
3
3
  "type": "module",
4
- "version": "0.2.0",
4
+ "version": "0.3.0",
5
5
  "license": "ISC",
6
6
  "repository": "github:daopk/eslint-config",
7
7
  "exports": {
@@ -13,31 +13,31 @@
13
13
  "dist"
14
14
  ],
15
15
  "dependencies": {
16
- "@stylistic/eslint-plugin": "^4.2.0",
17
- "@typescript-eslint/eslint-plugin": "^8.32.0",
18
- "@typescript-eslint/parser": "^8.32.0",
16
+ "@stylistic/eslint-plugin": "^5.3.1",
17
+ "@typescript-eslint/eslint-plugin": "^8.43.0",
18
+ "@typescript-eslint/parser": "^8.43.0",
19
19
  "eslint-config-flat-gitignore": "^2.1.0",
20
20
  "eslint-plugin-antfu": "^3.1.1",
21
- "eslint-plugin-import-x": "^4.11.0",
22
- "eslint-plugin-n": "^17.17.0",
23
- "eslint-plugin-perfectionist": "^4.12.3",
24
- "eslint-plugin-unused-imports": "^4.1.4"
21
+ "eslint-plugin-import-x": "^4.16.1",
22
+ "eslint-plugin-n": "^17.21.3",
23
+ "eslint-plugin-perfectionist": "^4.15.0",
24
+ "eslint-plugin-unused-imports": "^4.2.0"
25
25
  },
26
26
  "devDependencies": {
27
- "@eslint/config-inspector": "^1.0.2",
28
- "@types/node": "^22.15.16",
29
- "bumpp": "^10.1.0",
30
- "eslint": "^9.26.0",
31
- "eslint-typegen": "^2.1.0",
32
- "jiti": "^2.4.2",
33
- "tsup": "^8.4.0",
34
- "tsx": "^4.19.4",
35
- "typescript": "^5.8.3"
27
+ "@eslint/config-inspector": "^1.2.0",
28
+ "@types/node": "^22.18.1",
29
+ "bumpp": "^10.2.3",
30
+ "eslint": "^9.35.0",
31
+ "eslint-typegen": "^2.3.0",
32
+ "jiti": "^2.5.1",
33
+ "tsdown": "^0.15.0",
34
+ "tsx": "^4.20.5",
35
+ "typescript": "^5.9.2"
36
36
  },
37
37
  "scripts": {
38
38
  "dev": "eslint-config-inspector",
39
39
  "typegen": "tsx scripts/typegen.ts",
40
- "build": "pnpm typegen && tsup",
40
+ "build": "pnpm typegen && tsdown",
41
41
  "build:inspector": "pnpm build && eslint-config-inspector build",
42
42
  "lint": "eslint .",
43
43
  "release": "bumpp && pnpm publish"