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