@nelsonlaidev/eslint-config 0.0.2 → 1.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 +41 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +118 -78
- package/dist/index.js.map +1 -1
- package/package.json +7 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,46 +1,74 @@
|
|
|
1
|
-
import { Linter
|
|
1
|
+
import { Linter } from "eslint";
|
|
2
2
|
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/types.d.ts
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* ESLint configuration options.
|
|
7
7
|
*/
|
|
8
|
-
type
|
|
8
|
+
type ConfigOptions = {
|
|
9
9
|
/**
|
|
10
10
|
* The absolute or relative path to the root directory that contains
|
|
11
11
|
* the `tsconfig.json`. Used to resolve TypeScript configuration.
|
|
12
12
|
*/
|
|
13
|
-
tsconfigRootDir
|
|
13
|
+
tsconfigRootDir?: string;
|
|
14
14
|
/**
|
|
15
|
-
* Enable additional
|
|
15
|
+
* Enable additional ESLint rules optimized for React projects.
|
|
16
16
|
*/
|
|
17
17
|
react?: boolean;
|
|
18
18
|
/**
|
|
19
|
-
* Enable additional
|
|
20
|
-
*
|
|
19
|
+
* Enable additional ESLint rules optimized for Next.js projects.
|
|
20
|
+
* This option also automatically enables React rules.
|
|
21
21
|
*/
|
|
22
22
|
nextjs?: boolean;
|
|
23
23
|
/**
|
|
24
|
-
* Path to the main entry
|
|
24
|
+
* Path to the main entry point of your Tailwind CSS setup.
|
|
25
25
|
* Enabling this also turns on ESLint rules related to Tailwind CSS.
|
|
26
26
|
*/
|
|
27
27
|
tailwindEntryPoint?: string;
|
|
28
28
|
/**
|
|
29
|
-
* Glob patterns
|
|
29
|
+
* Glob patterns for your Vitest test files.
|
|
30
30
|
* When provided, ESLint rules for Vitest will be enabled.
|
|
31
31
|
*/
|
|
32
32
|
vitestGlob?: string;
|
|
33
33
|
/**
|
|
34
|
-
* Glob patterns
|
|
34
|
+
* Glob patterns for your Playwright test files.
|
|
35
35
|
* When provided, ESLint rules for Playwright will be enabled.
|
|
36
36
|
*/
|
|
37
37
|
playwrightGlob?: string;
|
|
38
38
|
/**
|
|
39
|
-
* A list of file paths or glob patterns
|
|
39
|
+
* A list of file paths or glob patterns that ESLint should ignore.
|
|
40
40
|
*/
|
|
41
41
|
ignores?: string[];
|
|
42
|
+
/**
|
|
43
|
+
* Override specific ESLint rules for each plugin.
|
|
44
|
+
*/
|
|
45
|
+
overrides?: Overrides;
|
|
42
46
|
};
|
|
43
|
-
|
|
47
|
+
type RuleOverrides = Linter.Config['rules'];
|
|
48
|
+
type Overrides = {
|
|
49
|
+
javascript?: RuleOverrides;
|
|
50
|
+
sonarjs?: RuleOverrides;
|
|
51
|
+
importSort?: RuleOverrides;
|
|
52
|
+
deMorgan?: RuleOverrides;
|
|
53
|
+
comments?: RuleOverrides;
|
|
54
|
+
node?: RuleOverrides;
|
|
55
|
+
jsdoc?: RuleOverrides;
|
|
56
|
+
imports?: RuleOverrides;
|
|
57
|
+
unicorn?: RuleOverrides;
|
|
58
|
+
jsx?: RuleOverrides;
|
|
59
|
+
typescript?: RuleOverrides;
|
|
60
|
+
regexp?: RuleOverrides;
|
|
61
|
+
vitest?: RuleOverrides;
|
|
62
|
+
playwright?: RuleOverrides;
|
|
63
|
+
react?: RuleOverrides;
|
|
64
|
+
nextjs?: RuleOverrides;
|
|
65
|
+
tailwindcss?: RuleOverrides;
|
|
66
|
+
prettier?: RuleOverrides;
|
|
67
|
+
};
|
|
68
|
+
type FlatConfig = Linter.Config;
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/base.d.ts
|
|
71
|
+
declare const defineConfig: (options?: ConfigOptions, ...userConfigs: FlatConfig[]) => FlatConfig[];
|
|
44
72
|
//#endregion
|
|
45
73
|
//#region src/globs.d.ts
|
|
46
74
|
declare const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
@@ -50,5 +78,5 @@ declare const GLOB_JSX = "**/*.?([cm])jsx";
|
|
|
50
78
|
declare const GLOB_TS = "**/*.?([cm])ts";
|
|
51
79
|
declare const GLOB_TSX = "**/*.?([cm])tsx";
|
|
52
80
|
//#endregion
|
|
53
|
-
export { GLOB_JS, GLOB_JSX, GLOB_SRC, GLOB_SRC_EXT, GLOB_TS, GLOB_TSX,
|
|
81
|
+
export { ConfigOptions, FlatConfig, GLOB_JS, GLOB_JSX, GLOB_SRC, GLOB_SRC_EXT, GLOB_TS, GLOB_TSX, Overrides, RuleOverrides, defineConfig };
|
|
54
82
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/base.ts","../src/globs.ts"],"sourcesContent":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/base.ts","../src/globs.ts"],"sourcesContent":[],"mappings":";;;;;;AAKA;AAwCY,KAxCA,aAAA,GAwCa;EAEb;;;;iBAGG,CAAA,EAAA,MAAA;;;;OAIL,CAAA,EAAA,OAAA;;;;;QAKC,CAAA,EAAA,OAAA;;;;;oBAKK,CAAA,EAAA,MAAA;;;AAIhB;;;;ACvCA;;;gBAA0E,CAAA,EAAA,MAAA;;;;;;AC7B1E;AACA;EAEa,SAAA,CAAO,EFuCN,SEvCM;AACpB,CAAA;AAEa,KFuCD,aAAA,GAAgB,MAAA,CAAO,MEvCf,CAAA,OAAA,CAAA;AACP,KFwCD,SAAA,GExCS;eFyCN;YACH;eACG;aACF;aACA;SACJ;UACC;YACE;YACA;QACJ;eACO;WACJ;WACA;eACI;UACL;WACC;gBACK;aACH;;KAGD,UAAA,GAAa,MAAA,CAAO;;;cCvCnB,yBAAyB,+BAAoC,iBAAe;;;cC7B5E,YAAA;cACA,QAAA;cAEA,OAAA;AFED,cEDC,QAAA,GFsCC,iBAAA;AAGF,cEvCC,OAAA,GFuCe,gBAAO;AAEvB,cExCC,QAAA,GFwCQ,iBAAA"}
|
package/dist/index.js
CHANGED
|
@@ -15,7 +15,6 @@ import playwrightPlugin from "eslint-plugin-playwright";
|
|
|
15
15
|
import prettierPlugin from "eslint-plugin-prettier";
|
|
16
16
|
import prettierPluginRecommended from "eslint-plugin-prettier/recommended";
|
|
17
17
|
import reactHooksPlugin from "eslint-plugin-react-hooks";
|
|
18
|
-
import reactRefreshPlugin from "eslint-plugin-react-refresh";
|
|
19
18
|
import regexpPlugin from "eslint-plugin-regexp";
|
|
20
19
|
import importSortPlugin from "eslint-plugin-simple-import-sort";
|
|
21
20
|
import sonarjsPlugin from "eslint-plugin-sonarjs";
|
|
@@ -24,18 +23,18 @@ import unusedImportsPlugin from "eslint-plugin-unused-imports";
|
|
|
24
23
|
import gitignorePlugin from "eslint-config-flat-gitignore";
|
|
25
24
|
import eslint from "@eslint/js";
|
|
26
25
|
import globals from "globals";
|
|
26
|
+
import process from "node:process";
|
|
27
27
|
import parser from "@typescript-eslint/parser";
|
|
28
|
-
import { Linter } from "eslint";
|
|
29
28
|
|
|
30
29
|
//#region src/configs/command.ts
|
|
31
|
-
const command = [{
|
|
30
|
+
const command = () => [{
|
|
32
31
|
...commandPlugin(),
|
|
33
32
|
name: "nelsonlaidev/command/rules"
|
|
34
33
|
}];
|
|
35
34
|
|
|
36
35
|
//#endregion
|
|
37
36
|
//#region src/configs/comments.ts
|
|
38
|
-
const comments = [{
|
|
37
|
+
const comments = (overrides) => [{
|
|
39
38
|
name: "nelsonlaidev/eslint-comments/rules",
|
|
40
39
|
plugins: { "@eslint-community/eslint-comments": commentsPlugin },
|
|
41
40
|
rules: {
|
|
@@ -43,32 +42,36 @@ const comments = [{
|
|
|
43
42
|
"@eslint-community/eslint-comments/require-description": "error",
|
|
44
43
|
"@eslint-community/eslint-comments/no-unused-disable": "error",
|
|
45
44
|
"@eslint-community/eslint-comments/no-restricted-disable": "error",
|
|
46
|
-
"@eslint-community/eslint-comments/no-use": "error"
|
|
45
|
+
"@eslint-community/eslint-comments/no-use": ["error", { allow: ["eslint-disable-next-line"] }],
|
|
46
|
+
...overrides
|
|
47
47
|
}
|
|
48
48
|
}];
|
|
49
49
|
|
|
50
50
|
//#endregion
|
|
51
51
|
//#region src/configs/de-morgan.ts
|
|
52
|
-
const deMorgan = [{
|
|
52
|
+
const deMorgan = (overrides) => [{
|
|
53
53
|
name: "nelsonlaidev/de-morgan/rules",
|
|
54
54
|
plugins: { "de-morgan": deMorganPlugin },
|
|
55
|
-
rules: {
|
|
55
|
+
rules: {
|
|
56
|
+
...deMorganPlugin.configs.recommended.rules,
|
|
57
|
+
...overrides
|
|
58
|
+
}
|
|
56
59
|
}];
|
|
57
60
|
|
|
58
61
|
//#endregion
|
|
59
62
|
//#region src/configs/gitignore.ts
|
|
60
|
-
const gitignore = [gitignorePlugin({ name: "nelsonlaidev/gitignore" })];
|
|
63
|
+
const gitignore = () => [gitignorePlugin({ name: "nelsonlaidev/gitignore" })];
|
|
61
64
|
|
|
62
65
|
//#endregion
|
|
63
66
|
//#region src/configs/ignores.ts
|
|
64
|
-
const ignores = (userIgnores) => [{
|
|
67
|
+
const ignores = (userIgnores = []) => [{
|
|
65
68
|
name: "nelsonlaidev/ignores",
|
|
66
69
|
ignores: [...userIgnores]
|
|
67
70
|
}];
|
|
68
71
|
|
|
69
72
|
//#endregion
|
|
70
73
|
//#region src/configs/import-sort.ts
|
|
71
|
-
const importSort = [{
|
|
74
|
+
const importSort = (overrides) => [{
|
|
72
75
|
name: "nelsonlaidev/import-sort/rules",
|
|
73
76
|
plugins: { "import-sort": importSortPlugin },
|
|
74
77
|
rules: {
|
|
@@ -87,28 +90,29 @@ const importSort = [{
|
|
|
87
90
|
[String.raw`^\.\.`],
|
|
88
91
|
[String.raw`^\.`]
|
|
89
92
|
] }],
|
|
90
|
-
"import-sort/exports": "error"
|
|
93
|
+
"import-sort/exports": "error",
|
|
94
|
+
...overrides
|
|
91
95
|
}
|
|
92
96
|
}];
|
|
93
97
|
|
|
94
98
|
//#endregion
|
|
95
99
|
//#region src/configs/imports.ts
|
|
96
|
-
const imports = [{
|
|
100
|
+
const imports = (overrides) => [{
|
|
97
101
|
name: "nelsonlaidev/imports/rules",
|
|
98
102
|
plugins: { "import-lite": importLitePlugin },
|
|
99
103
|
rules: {
|
|
100
|
-
"import-lite/consistent-type-specifier-style": ["error", "top-level"],
|
|
101
104
|
"import-lite/first": "error",
|
|
102
105
|
"import-lite/newline-after-import": ["error", { count: 1 }],
|
|
103
106
|
"import-lite/no-duplicates": "error",
|
|
104
107
|
"import-lite/no-mutable-exports": "error",
|
|
105
|
-
"import-lite/no-named-default": "error"
|
|
108
|
+
"import-lite/no-named-default": "error",
|
|
109
|
+
...overrides
|
|
106
110
|
}
|
|
107
111
|
}];
|
|
108
112
|
|
|
109
113
|
//#endregion
|
|
110
114
|
//#region src/configs/javascript.ts
|
|
111
|
-
const javascript = [{
|
|
115
|
+
const javascript = (overrides) => [{
|
|
112
116
|
name: "nelsonlaidev/javascript/setup",
|
|
113
117
|
languageOptions: {
|
|
114
118
|
ecmaVersion: 2022,
|
|
@@ -144,16 +148,20 @@ const javascript = [{
|
|
|
144
148
|
varsIgnorePattern: "^_",
|
|
145
149
|
args: "after-used",
|
|
146
150
|
argsIgnorePattern: "^_"
|
|
147
|
-
}]
|
|
151
|
+
}],
|
|
152
|
+
...overrides
|
|
148
153
|
}
|
|
149
154
|
}];
|
|
150
155
|
|
|
151
156
|
//#endregion
|
|
152
157
|
//#region src/configs/jsdoc.ts
|
|
153
|
-
const jsdoc = [{
|
|
158
|
+
const jsdoc = (overrides) => [{
|
|
154
159
|
name: "nelsonlaidev/jsdoc/rules",
|
|
155
160
|
plugins: { jsdoc: jsdocPlugin },
|
|
156
|
-
rules: {
|
|
161
|
+
rules: {
|
|
162
|
+
...jsdocPlugin.configs["flat/recommended"].rules,
|
|
163
|
+
...overrides
|
|
164
|
+
}
|
|
157
165
|
}];
|
|
158
166
|
|
|
159
167
|
//#endregion
|
|
@@ -167,7 +175,7 @@ const GLOB_TSX = "**/*.?([cm])tsx";
|
|
|
167
175
|
|
|
168
176
|
//#endregion
|
|
169
177
|
//#region src/configs/jsx.ts
|
|
170
|
-
const jsx = [{
|
|
178
|
+
const jsx = (overrides) => [{
|
|
171
179
|
name: "nelsonlaidev/jsx/setup",
|
|
172
180
|
files: [GLOB_JSX, GLOB_TSX],
|
|
173
181
|
languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } }
|
|
@@ -180,7 +188,8 @@ const jsx = [{
|
|
|
180
188
|
"jsx-a11y/anchor-ambiguous-text": "error",
|
|
181
189
|
"jsx-a11y/lang": "error",
|
|
182
190
|
"jsx-a11y/no-aria-hidden-on-focusable": "error",
|
|
183
|
-
"jsx-a11y/prefer-tag-over-role": "error"
|
|
191
|
+
"jsx-a11y/prefer-tag-over-role": "error",
|
|
192
|
+
...overrides
|
|
184
193
|
},
|
|
185
194
|
settings: { "jsx-a11y": { components: {
|
|
186
195
|
Button: "button",
|
|
@@ -193,108 +202,126 @@ const jsx = [{
|
|
|
193
202
|
|
|
194
203
|
//#endregion
|
|
195
204
|
//#region src/configs/nextjs.ts
|
|
196
|
-
const nextjs = [{
|
|
205
|
+
const nextjs = (overrides) => [{
|
|
197
206
|
name: "nelsonlaidev/nextjs/rules",
|
|
198
207
|
plugins: { "@next/next": nextPlugin },
|
|
199
208
|
rules: {
|
|
200
209
|
...nextPlugin.configs.recommended.rules,
|
|
201
|
-
...nextPlugin.configs["core-web-vitals"].rules
|
|
210
|
+
...nextPlugin.configs["core-web-vitals"].rules,
|
|
211
|
+
...overrides
|
|
202
212
|
}
|
|
203
213
|
}];
|
|
204
214
|
|
|
205
215
|
//#endregion
|
|
206
216
|
//#region src/configs/node.ts
|
|
207
|
-
const node = [{
|
|
217
|
+
const node = (overrides) => [{
|
|
208
218
|
name: "nelsonlaidev/node/rules",
|
|
209
219
|
plugins: { n: nodePlugin },
|
|
210
220
|
rules: {
|
|
211
|
-
|
|
212
|
-
"n/no-
|
|
213
|
-
"n/no-
|
|
214
|
-
"n/no-
|
|
215
|
-
"n/no-
|
|
216
|
-
"n/
|
|
217
|
-
"n/
|
|
218
|
-
|
|
219
|
-
"n/no-unsupported-features/node-builtins": "off"
|
|
221
|
+
"n/handle-callback-err": ["error", "^(err|error)$"],
|
|
222
|
+
"n/no-deprecated-api": "error",
|
|
223
|
+
"n/no-exports-assign": "error",
|
|
224
|
+
"n/no-new-require": "error",
|
|
225
|
+
"n/no-path-concat": "error",
|
|
226
|
+
"n/prefer-promises/fs": "error",
|
|
227
|
+
"n/process-exit-as-throw": "error",
|
|
228
|
+
...overrides
|
|
220
229
|
}
|
|
221
230
|
}];
|
|
222
231
|
|
|
223
232
|
//#endregion
|
|
224
233
|
//#region src/configs/playwright.ts
|
|
225
|
-
const playwright = (glob) => [{
|
|
234
|
+
const playwright = (glob, overrides) => [{
|
|
226
235
|
name: "nelsonlaidev/playwright/setup",
|
|
227
236
|
languageOptions: { globals: globals["shared-node-browser"] }
|
|
228
237
|
}, {
|
|
229
238
|
name: "nelsonlaidev/playwright/rules",
|
|
230
239
|
files: [glob],
|
|
231
240
|
plugins: { playwright: playwrightPlugin },
|
|
232
|
-
rules: {
|
|
241
|
+
rules: {
|
|
242
|
+
...playwrightPlugin.configs.recommended.rules,
|
|
243
|
+
...overrides
|
|
244
|
+
}
|
|
233
245
|
}];
|
|
234
246
|
|
|
235
247
|
//#endregion
|
|
236
248
|
//#region src/configs/prettier.ts
|
|
237
|
-
const prettier = [{
|
|
249
|
+
const prettier = (overrides) => [{
|
|
238
250
|
name: "nelsonlaidev/prettier/rules",
|
|
239
251
|
plugins: { prettier: prettierPlugin },
|
|
240
|
-
rules: {
|
|
252
|
+
rules: {
|
|
253
|
+
...prettierPluginRecommended.rules,
|
|
254
|
+
...overrides
|
|
255
|
+
}
|
|
241
256
|
}];
|
|
242
257
|
|
|
243
258
|
//#endregion
|
|
244
259
|
//#region src/configs/react.ts
|
|
245
|
-
const react = [{
|
|
260
|
+
const react = (overrides) => [{
|
|
246
261
|
name: "nelsonlaidev/react/rules",
|
|
247
262
|
files: [GLOB_SRC],
|
|
248
263
|
plugins: {
|
|
249
264
|
...reactPlugin.configs.all.plugins,
|
|
250
|
-
"react-hooks": reactHooksPlugin
|
|
251
|
-
"react-refresh": reactRefreshPlugin
|
|
265
|
+
"react-hooks": reactHooksPlugin
|
|
252
266
|
},
|
|
253
267
|
rules: {
|
|
254
268
|
...reactPlugin.configs.all.rules,
|
|
255
269
|
...reactHooksPlugin.configs["recommended-latest"].rules,
|
|
256
|
-
|
|
270
|
+
"@eslint-react/naming-convention/filename": ["error", "kebab-case"],
|
|
271
|
+
"@eslint-react/avoid-shorthand-boolean": "off",
|
|
272
|
+
"@eslint-react/avoid-shorthand-fragment": "off",
|
|
273
|
+
"@eslint-react/no-complex-conditional-rendering": "off",
|
|
274
|
+
"@eslint-react/no-array-index-key": "off",
|
|
275
|
+
...overrides
|
|
257
276
|
}
|
|
258
277
|
}];
|
|
259
278
|
|
|
260
279
|
//#endregion
|
|
261
280
|
//#region src/configs/regexp.ts
|
|
262
|
-
const regexp = [{
|
|
281
|
+
const regexp = (overrides) => [{
|
|
263
282
|
name: "nelsonlaidev/regexp/rules",
|
|
264
283
|
plugins: { regexp: regexpPlugin },
|
|
265
|
-
rules: {
|
|
284
|
+
rules: {
|
|
285
|
+
...regexpPlugin.configs["flat/recommended"].rules,
|
|
286
|
+
...overrides
|
|
287
|
+
}
|
|
266
288
|
}];
|
|
267
289
|
|
|
268
290
|
//#endregion
|
|
269
291
|
//#region src/configs/sonarjs.ts
|
|
270
|
-
const sonarjs = [{
|
|
292
|
+
const sonarjs = (overrides) => [{
|
|
271
293
|
name: "nelsonlaidev/sonarjs/rules",
|
|
272
294
|
plugins: { sonarjs: sonarjsPlugin },
|
|
273
295
|
rules: {
|
|
274
296
|
...sonarjsPlugin.configs.recommended.rules,
|
|
275
|
-
"sonarjs/no-commented-code": "off"
|
|
297
|
+
"sonarjs/no-commented-code": "off",
|
|
298
|
+
...overrides
|
|
276
299
|
}
|
|
277
300
|
}];
|
|
278
301
|
|
|
279
302
|
//#endregion
|
|
280
303
|
//#region src/configs/tailwindcss.ts
|
|
281
|
-
const tailwindcss = (entryPoint) => [{
|
|
304
|
+
const tailwindcss = (entryPoint, overrides) => [{
|
|
282
305
|
name: "nelsonlaidev/tailwindcss/rules",
|
|
283
306
|
plugins: { "better-tailwindcss": tailwindcssPlugin },
|
|
284
307
|
rules: {
|
|
285
|
-
|
|
308
|
+
"better-tailwindcss/enforce-consistent-class-order": "error",
|
|
309
|
+
"better-tailwindcss/enforce-consistent-important-position": "error",
|
|
286
310
|
"better-tailwindcss/enforce-consistent-variable-syntax": "error",
|
|
287
|
-
"better-tailwindcss/no-deprecated-classes": "error",
|
|
288
|
-
"better-tailwindcss/no-restricted-classes": "error",
|
|
289
311
|
"better-tailwindcss/enforce-shorthand-classes": "error",
|
|
290
|
-
"better-tailwindcss/
|
|
312
|
+
"better-tailwindcss/no-conflicting-classes": "error",
|
|
313
|
+
"better-tailwindcss/no-deprecated-classes": "error",
|
|
314
|
+
"better-tailwindcss/no-duplicate-classes": "error",
|
|
315
|
+
"better-tailwindcss/no-unnecessary-whitespace": "error",
|
|
316
|
+
"better-tailwindcss/no-unregistered-classes": "error",
|
|
317
|
+
...overrides
|
|
291
318
|
},
|
|
292
|
-
settings: { tailwindcss: { entryPoint } }
|
|
319
|
+
settings: { "better-tailwindcss": { entryPoint } }
|
|
293
320
|
}];
|
|
294
321
|
|
|
295
322
|
//#endregion
|
|
296
323
|
//#region src/configs/typescript.ts
|
|
297
|
-
const typescript = (tsconfigRootDir) => [{
|
|
324
|
+
const typescript = (tsconfigRootDir = process.cwd(), overrides) => [{
|
|
298
325
|
name: "nelsonlaidev/typescript/setup",
|
|
299
326
|
files: [GLOB_TS, GLOB_TSX],
|
|
300
327
|
languageOptions: {
|
|
@@ -321,63 +348,76 @@ const typescript = (tsconfigRootDir) => [{
|
|
|
321
348
|
fixStyle: "inline-type-imports"
|
|
322
349
|
}],
|
|
323
350
|
"@typescript-eslint/restrict-template-expressions": ["error", { allowNumber: true }],
|
|
324
|
-
"@typescript-eslint/
|
|
351
|
+
"@typescript-eslint/no-misused-promises": ["error", { checksVoidReturn: false }],
|
|
352
|
+
"@typescript-eslint/no-floating-promises": "off",
|
|
353
|
+
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
354
|
+
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
355
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
|
356
|
+
"@typescript-eslint/consistent-type-definitions": "off",
|
|
357
|
+
...overrides
|
|
325
358
|
}
|
|
326
359
|
}];
|
|
327
360
|
|
|
328
361
|
//#endregion
|
|
329
362
|
//#region src/configs/unicorn.ts
|
|
330
|
-
const unicorn = [{
|
|
363
|
+
const unicorn = (overrides) => [{
|
|
331
364
|
name: "nelsonlaidev/unicorn/rules",
|
|
332
365
|
plugins: { unicorn: unicornPlugin },
|
|
333
366
|
rules: {
|
|
334
367
|
...unicornPlugin.configs.recommended.rules,
|
|
335
|
-
"unicorn/prevent-abbreviations": "off"
|
|
368
|
+
"unicorn/prevent-abbreviations": "off",
|
|
369
|
+
"unicorn/no-null": "off",
|
|
370
|
+
...overrides
|
|
336
371
|
}
|
|
337
372
|
}];
|
|
338
373
|
|
|
339
374
|
//#endregion
|
|
340
375
|
//#region src/configs/vitest.ts
|
|
341
|
-
const vitest = (glob) => [{
|
|
376
|
+
const vitest = (glob, overrides) => [{
|
|
342
377
|
name: "nelsonlaidev/vitest/rules",
|
|
343
378
|
files: [glob],
|
|
344
379
|
plugins: { vitest: vitestPlugin },
|
|
345
|
-
rules: {
|
|
380
|
+
rules: {
|
|
381
|
+
...vitestPlugin.configs.recommended.rules,
|
|
382
|
+
...overrides
|
|
383
|
+
}
|
|
346
384
|
}];
|
|
347
385
|
|
|
348
386
|
//#endregion
|
|
349
387
|
//#region src/base.ts
|
|
350
388
|
const isReactInstalled = isPackageExists("react");
|
|
351
389
|
const isNextjsInstalled = isPackageExists("next");
|
|
352
|
-
const defineConfig = (options) => {
|
|
390
|
+
const defineConfig = (options = {}, ...userConfigs) => {
|
|
391
|
+
const { overrides = {} } = options;
|
|
353
392
|
const configs = [
|
|
354
|
-
...gitignore,
|
|
393
|
+
...gitignore(),
|
|
355
394
|
...ignores(options.ignores ?? []),
|
|
356
|
-
...javascript,
|
|
357
|
-
...sonarjs,
|
|
358
|
-
...importSort,
|
|
359
|
-
...deMorgan,
|
|
360
|
-
...comments,
|
|
361
|
-
...node,
|
|
362
|
-
...jsdoc,
|
|
363
|
-
...imports,
|
|
364
|
-
...command,
|
|
365
|
-
...unicorn,
|
|
366
|
-
...jsx,
|
|
367
|
-
...typescript(options.tsconfigRootDir),
|
|
368
|
-
...regexp
|
|
395
|
+
...javascript(overrides.javascript),
|
|
396
|
+
...sonarjs(overrides.sonarjs),
|
|
397
|
+
...importSort(overrides.importSort),
|
|
398
|
+
...deMorgan(overrides.deMorgan),
|
|
399
|
+
...comments(overrides.comments),
|
|
400
|
+
...node(overrides.node),
|
|
401
|
+
...jsdoc(overrides.jsdoc),
|
|
402
|
+
...imports(overrides.imports),
|
|
403
|
+
...command(),
|
|
404
|
+
...unicorn(overrides.unicorn),
|
|
405
|
+
...jsx(overrides.jsx),
|
|
406
|
+
...typescript(options.tsconfigRootDir, overrides.typescript),
|
|
407
|
+
...regexp(overrides.regexp)
|
|
369
408
|
];
|
|
370
409
|
const isNextjsEnabled = options.nextjs ?? isNextjsInstalled;
|
|
371
410
|
const isReactEnabled = (options.react ?? isReactInstalled) || isNextjsEnabled;
|
|
372
|
-
if (options.vitestGlob) configs.push(...vitest(options.vitestGlob));
|
|
373
|
-
if (options.playwrightGlob) configs.push(...playwright(options.playwrightGlob));
|
|
374
|
-
if (isReactEnabled) configs.push(...react);
|
|
375
|
-
if (isNextjsEnabled) configs.push(...nextjs);
|
|
376
|
-
if (options.tailwindEntryPoint) configs.push(...tailwindcss(options.tailwindEntryPoint));
|
|
377
|
-
configs.push(...
|
|
411
|
+
if (options.vitestGlob) configs.push(...vitest(options.vitestGlob, overrides.vitest));
|
|
412
|
+
if (options.playwrightGlob) configs.push(...playwright(options.playwrightGlob, overrides.playwright));
|
|
413
|
+
if (isReactEnabled) configs.push(...react(overrides.react));
|
|
414
|
+
if (isNextjsEnabled) configs.push(...nextjs(overrides.nextjs));
|
|
415
|
+
if (options.tailwindEntryPoint) configs.push(...tailwindcss(options.tailwindEntryPoint, overrides.tailwindcss));
|
|
416
|
+
configs.push(...userConfigs);
|
|
417
|
+
configs.push(...prettier(overrides.prettier));
|
|
378
418
|
return configs;
|
|
379
419
|
};
|
|
380
420
|
|
|
381
421
|
//#endregion
|
|
382
|
-
export { GLOB_JS, GLOB_JSX, GLOB_SRC, GLOB_SRC_EXT, GLOB_TS, GLOB_TSX,
|
|
422
|
+
export { GLOB_JS, GLOB_JSX, GLOB_SRC, GLOB_SRC_EXT, GLOB_TS, GLOB_TSX, defineConfig };
|
|
383
423
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["command: Linter.Config[]","comments: Linter.Config[]","deMorgan: Linter.Config[]","gitignore: Linter.Config[]","importSort: Linter.Config[]","imports: Linter.Config[]","javascript: Linter.Config[]","jsdoc: Linter.Config[]","jsx: Linter.Config[]","nextjs: Linter.Config[]","node: Linter.Config[]","prettier: Linter.Config[]","react: Linter.Config[]","regexp: Linter.Config[]","sonarjs: Linter.Config[]","unicorn: Linter.Config[]"],"sources":["../src/configs/command.ts","../src/configs/comments.ts","../src/configs/de-morgan.ts","../src/configs/gitignore.ts","../src/configs/ignores.ts","../src/configs/import-sort.ts","../src/configs/imports.ts","../src/configs/javascript.ts","../src/configs/jsdoc.ts","../src/globs.ts","../src/configs/jsx.ts","../src/configs/nextjs.ts","../src/configs/node.ts","../src/configs/playwright.ts","../src/configs/prettier.ts","../src/configs/react.ts","../src/configs/regexp.ts","../src/configs/sonarjs.ts","../src/configs/tailwindcss.ts","../src/configs/typescript.ts","../src/configs/unicorn.ts","../src/configs/vitest.ts","../src/base.ts"],"sourcesContent":["import type { Linter } from 'eslint'\n\nimport { commandPlugin } from '../plugins'\n\nexport const command: Linter.Config[] = [\n {\n ...commandPlugin(),\n name: 'nelsonlaidev/command/rules'\n }\n]\n","import type { Linter } from 'eslint'\n\nimport { commentsPlugin } from '../plugins'\n\nexport const comments: Linter.Config[] = [\n {\n name: 'nelsonlaidev/eslint-comments/rules',\n plugins: {\n '@eslint-community/eslint-comments': commentsPlugin\n },\n rules: {\n ...commentsPlugin.configs.recommended.rules,\n\n '@eslint-community/eslint-comments/require-description': 'error',\n '@eslint-community/eslint-comments/no-unused-disable': 'error',\n '@eslint-community/eslint-comments/no-restricted-disable': 'error',\n '@eslint-community/eslint-comments/no-use': 'error'\n }\n }\n]\n","import type { Linter } from 'eslint'\n\nimport { deMorganPlugin } from '../plugins'\n\nexport const deMorgan: Linter.Config[] = [\n {\n name: 'nelsonlaidev/de-morgan/rules',\n plugins: {\n 'de-morgan': deMorganPlugin\n },\n rules: {\n ...deMorganPlugin.configs.recommended.rules\n }\n }\n]\n","import type { Linter } from 'eslint'\n\nimport gitignorePlugin from 'eslint-config-flat-gitignore'\n\nexport const gitignore: Linter.Config[] = [\n gitignorePlugin({\n name: 'nelsonlaidev/gitignore'\n })\n]\n","import type { Linter } from 'eslint'\n\nexport const ignores = (userIgnores: string[]): Linter.Config[] => [\n {\n name: 'nelsonlaidev/ignores',\n ignores: [...userIgnores]\n }\n]\n","import type { Linter } from 'eslint'\n\nimport { importSortPlugin } from '../plugins'\n\nexport const importSort: Linter.Config[] = [\n {\n name: 'nelsonlaidev/import-sort/rules',\n plugins: {\n 'import-sort': importSortPlugin\n },\n rules: {\n 'import-sort/imports': [\n 'error',\n {\n groups: [\n // Type imports\n [\n String.raw`^.*\\u0000$`,\n String.raw`^node:.*\\u0000$`,\n String.raw`^@?\\w.*\\u0000$`,\n String.raw`^\\.\\..*\\u0000$`,\n String.raw`^\\..*\\u0000$`\n ],\n\n // Side effect imports (e.g., `import 'some-module'`)\n [String.raw`^\\u0000`],\n\n // Node.js builtins prefixed with `node:`\n ['^node:'],\n\n // Things that start with a letter (or digit or underscore), or `@` followed by a letter\n [String.raw`^@?\\w`],\n\n // Absolute imports (e.g., `import something from 'src/utils'`)\n ['^[^.]'],\n\n // Parent directory relative imports (e.g., `import something from '../utils'`)\n [String.raw`^\\.\\.`],\n\n // Current directory relative imports (e.g., `import something from './utils'`)\n [String.raw`^\\.`]\n ]\n }\n ],\n 'import-sort/exports': 'error'\n }\n }\n]\n","import type { Linter } from 'eslint'\n\nimport { importLitePlugin } from '../plugins'\n\nexport const imports: Linter.Config[] = [\n {\n name: 'nelsonlaidev/imports/rules',\n plugins: {\n 'import-lite': importLitePlugin\n },\n rules: {\n 'import-lite/consistent-type-specifier-style': ['error', 'top-level'],\n 'import-lite/first': 'error',\n 'import-lite/newline-after-import': ['error', { count: 1 }],\n 'import-lite/no-duplicates': 'error',\n 'import-lite/no-mutable-exports': 'error',\n 'import-lite/no-named-default': 'error'\n }\n }\n]\n","import type { Linter } from 'eslint'\n\nimport eslint from '@eslint/js'\nimport globals from 'globals'\n\nimport { unusedImportsPlugin } from '../plugins'\n\nexport const javascript: Linter.Config[] = [\n {\n name: 'nelsonlaidev/javascript/setup',\n languageOptions: {\n ecmaVersion: 2022,\n globals: {\n ...globals.browser,\n ...globals.es2021,\n ...globals.node,\n document: 'readonly',\n navigator: 'readonly',\n window: 'readonly'\n },\n parserOptions: {\n ecmaFeatures: {\n jsx: true\n },\n ecmaVersion: 2022,\n sourceType: 'module'\n },\n sourceType: 'module'\n },\n linterOptions: {\n reportUnusedDisableDirectives: 'error',\n reportUnusedInlineConfigs: 'error'\n }\n },\n {\n name: 'nelsonlaidev/javascript/rules',\n plugins: {\n 'unused-imports': unusedImportsPlugin\n },\n rules: {\n ...eslint.configs.recommended.rules,\n\n // Recommended to disable\n // https://github.com/sweepline/eslint-plugin-unused-imports?tab=readme-ov-file#usage\n 'no-unused-vars': 'off',\n '@typescript-eslint/no-unused-vars': 'off',\n\n 'unused-imports/no-unused-imports': 'error',\n 'unused-imports/no-unused-vars': [\n 'error',\n {\n vars: 'all',\n varsIgnorePattern: '^_',\n args: 'after-used',\n argsIgnorePattern: '^_'\n }\n ]\n }\n }\n]\n","import type { Linter } from 'eslint'\n\nimport { jsdocPlugin } from '../plugins'\n\nexport const jsdoc: Linter.Config[] = [\n {\n name: 'nelsonlaidev/jsdoc/rules',\n plugins: {\n jsdoc: jsdocPlugin\n },\n rules: {\n ...jsdocPlugin.configs['flat/recommended'].rules\n }\n }\n]\n","export const GLOB_SRC_EXT = '?([cm])[jt]s?(x)'\nexport const GLOB_SRC = '**/*.?([cm])[jt]s?(x)'\n\nexport const GLOB_JS = '**/*.?([cm])js'\nexport const GLOB_JSX = '**/*.?([cm])jsx'\n\nexport const GLOB_TS = '**/*.?([cm])ts'\nexport const GLOB_TSX = '**/*.?([cm])tsx'\n","import type { Linter } from 'eslint'\n\nimport { GLOB_JSX, GLOB_TSX } from '../globs'\nimport { jsxA11yPlugin } from '../plugins'\n\nexport const jsx: Linter.Config[] = [\n {\n name: 'nelsonlaidev/jsx/setup',\n files: [GLOB_JSX, GLOB_TSX],\n languageOptions: {\n parserOptions: {\n ecmaFeatures: {\n jsx: true\n }\n }\n }\n },\n {\n name: 'nelsonlaidev/jsx/rules',\n files: [GLOB_JSX, GLOB_TSX],\n plugins: {\n 'jsx-a11y': jsxA11yPlugin\n },\n rules: {\n ...jsxA11yPlugin.flatConfigs.strict.rules,\n\n 'jsx-a11y/anchor-ambiguous-text': 'error',\n 'jsx-a11y/lang': 'error',\n 'jsx-a11y/no-aria-hidden-on-focusable': 'error',\n 'jsx-a11y/prefer-tag-over-role': 'error'\n },\n settings: {\n 'jsx-a11y': {\n components: {\n Button: 'button',\n Image: 'img',\n Input: 'input',\n Textarea: 'textarea',\n Link: 'a'\n }\n }\n }\n }\n]\n","import type { Linter } from 'eslint'\n\nimport { nextPlugin } from '../plugins'\n\nexport const nextjs: Linter.Config[] = [\n {\n name: 'nelsonlaidev/nextjs/rules',\n plugins: {\n '@next/next': nextPlugin\n },\n rules: {\n ...nextPlugin.configs.recommended.rules,\n ...nextPlugin.configs['core-web-vitals'].rules\n }\n }\n]\n","import type { Linter } from 'eslint'\n\nimport { nodePlugin } from '../plugins'\n\nexport const node: Linter.Config[] = [\n {\n name: 'nelsonlaidev/node/rules',\n plugins: {\n n: nodePlugin\n },\n rules: {\n ...nodePlugin.configs['flat/recommended-module'].rules,\n\n // Handled by TypeScript\n 'n/no-missing-import': 'off',\n 'n/no-missing-require': 'off',\n 'n/no-unpublished-bin': 'off',\n 'n/no-unpublished-import': 'off',\n 'n/no-unpublished-require': 'off',\n 'n/no-unsupported-features/es-builtins': 'off',\n 'n/no-unsupported-features/es-syntax': 'off',\n 'n/no-unsupported-features/node-builtins': 'off'\n }\n }\n]\n","import type { Linter } from 'eslint'\n\nimport globals from 'globals'\n\nimport { playwrightPlugin } from '../plugins'\n\nexport const playwright = (glob: string): Linter.Config[] => [\n {\n name: 'nelsonlaidev/playwright/setup',\n languageOptions: {\n globals: globals['shared-node-browser']\n }\n },\n {\n name: 'nelsonlaidev/playwright/rules',\n files: [glob],\n plugins: {\n playwright: playwrightPlugin\n },\n rules: {\n ...playwrightPlugin.configs.recommended.rules\n }\n }\n]\n","import type { Linter } from 'eslint'\n\nimport { prettierPlugin, prettierPluginRecommended } from '../plugins'\n\nexport const prettier: Linter.Config[] = [\n {\n name: 'nelsonlaidev/prettier/rules',\n plugins: {\n prettier: prettierPlugin\n },\n rules: {\n ...prettierPluginRecommended.rules\n }\n }\n]\n","import type { Linter } from 'eslint'\n\nimport { GLOB_SRC } from '../globs'\nimport { reactHooksPlugin, reactPlugin, reactRefreshPlugin } from '../plugins'\n\nexport const react: Linter.Config[] = [\n {\n name: 'nelsonlaidev/react/rules',\n files: [GLOB_SRC],\n plugins: {\n ...reactPlugin.configs.all.plugins,\n 'react-hooks': reactHooksPlugin,\n 'react-refresh': reactRefreshPlugin\n },\n rules: {\n ...reactPlugin.configs.all.rules,\n ...reactHooksPlugin.configs['recommended-latest'].rules,\n ...reactRefreshPlugin.configs.recommended.rules\n }\n }\n]\n","import type { Linter } from 'eslint'\n\nimport { regexpPlugin } from '../plugins'\n\nexport const regexp: Linter.Config[] = [\n {\n name: 'nelsonlaidev/regexp/rules',\n plugins: {\n regexp: regexpPlugin\n },\n rules: {\n ...regexpPlugin.configs['flat/recommended'].rules\n }\n }\n]\n","import type { Linter } from 'eslint'\n\nimport { sonarjsPlugin } from '../plugins'\n\nexport const sonarjs: Linter.Config[] = [\n {\n name: 'nelsonlaidev/sonarjs/rules',\n plugins: {\n sonarjs: sonarjsPlugin\n },\n rules: {\n ...sonarjsPlugin.configs.recommended.rules,\n\n // Disable due to poor performance\n // https://community.sonarsource.com/t/eslint-plugin-sonarjs-performance-issues-on-large-codebase/138392\n 'sonarjs/no-commented-code': 'off'\n }\n }\n]\n","import type { Linter } from 'eslint'\n\nimport { tailwindcssPlugin } from '../plugins'\n\nexport const tailwindcss = (entryPoint: string): Linter.Config[] => [\n {\n name: 'nelsonlaidev/tailwindcss/rules',\n plugins: {\n 'better-tailwindcss': tailwindcssPlugin\n },\n rules: {\n ...tailwindcssPlugin.configs['recommended-error'].rules,\n\n 'better-tailwindcss/enforce-consistent-variable-syntax': 'error',\n 'better-tailwindcss/no-deprecated-classes': 'error',\n 'better-tailwindcss/no-restricted-classes': 'error',\n 'better-tailwindcss/enforce-shorthand-classes': 'error',\n 'better-tailwindcss/enforce-consistent-important-position': 'error'\n },\n settings: {\n tailwindcss: {\n entryPoint\n }\n }\n }\n]\n","import type { Linter } from 'eslint'\n\nimport parser from '@typescript-eslint/parser'\n\nimport { GLOB_TS, GLOB_TSX } from '../globs'\nimport { typescriptPlugin } from '../plugins'\n\nexport const typescript = (tsconfigRootDir: string): Linter.Config[] => [\n {\n name: 'nelsonlaidev/typescript/setup',\n files: [GLOB_TS, GLOB_TSX],\n languageOptions: {\n parser,\n parserOptions: {\n projectService: true,\n tsconfigRootDir\n },\n sourceType: 'module'\n },\n plugins: {\n '@typescript-eslint': typescriptPlugin\n }\n },\n {\n name: 'nelsonlaidev/typescript/rules',\n files: [GLOB_TS, GLOB_TSX],\n rules: {\n ...typescriptPlugin.configs['eslint-recommended'].overrides[0].rules,\n ...typescriptPlugin.configs['strict-type-checked'].rules,\n ...typescriptPlugin.configs['stylistic-type-checked'].rules,\n\n '@typescript-eslint/array-type': ['error', { default: 'array-simple' }],\n '@typescript-eslint/no-invalid-this': 'error',\n '@typescript-eslint/no-shadow': 'error',\n '@typescript-eslint/consistent-type-imports': [\n 'error',\n {\n prefer: 'type-imports',\n fixStyle: 'inline-type-imports'\n }\n ],\n '@typescript-eslint/restrict-template-expressions': ['error', { allowNumber: true }],\n '@typescript-eslint/consistent-type-definitions': ['error', 'type']\n }\n }\n]\n","import type { Linter } from 'eslint'\n\nimport { unicornPlugin } from '../plugins'\n\nexport const unicorn: Linter.Config[] = [\n {\n name: 'nelsonlaidev/unicorn/rules',\n plugins: {\n unicorn: unicornPlugin\n },\n rules: {\n ...unicornPlugin.configs.recommended.rules,\n\n 'unicorn/prevent-abbreviations': 'off'\n }\n }\n]\n","import type { Linter } from 'eslint'\n\nimport { vitestPlugin } from '../plugins'\n\nexport const vitest = (glob: string): Linter.Config[] => [\n {\n name: 'nelsonlaidev/vitest/rules',\n files: [glob],\n plugins: {\n vitest: vitestPlugin\n },\n rules: {\n ...vitestPlugin.configs.recommended.rules\n }\n }\n]\n","import type { Linter } from 'eslint'\n\nimport { isPackageExists } from 'local-pkg'\n\nimport { command } from './configs/command'\nimport { comments } from './configs/comments'\nimport { deMorgan } from './configs/de-morgan'\nimport { gitignore } from './configs/gitignore'\nimport { ignores } from './configs/ignores'\nimport { importSort } from './configs/import-sort'\nimport { imports } from './configs/imports'\nimport { javascript } from './configs/javascript'\nimport { jsdoc } from './configs/jsdoc'\nimport { jsx } from './configs/jsx'\nimport { nextjs } from './configs/nextjs'\nimport { node } from './configs/node'\nimport { playwright } from './configs/playwright'\nimport { prettier } from './configs/prettier'\nimport { react } from './configs/react'\nimport { regexp } from './configs/regexp'\nimport { sonarjs } from './configs/sonarjs'\nimport { tailwindcss } from './configs/tailwindcss'\nimport { typescript } from './configs/typescript'\nimport { unicorn } from './configs/unicorn'\nimport { vitest } from './configs/vitest'\n\n/**\n * ESLint configuration options.\n */\nexport type Options = {\n /**\n * The absolute or relative path to the root directory that contains\n * the `tsconfig.json`. Used to resolve TypeScript configuration.\n */\n tsconfigRootDir: string\n /**\n * Enable additional linting rules optimized for React projects.\n */\n react?: boolean\n /**\n * Enable additional linting rules optimized for Next.js projects.\n * Automatically implies React linting as well.\n */\n nextjs?: boolean\n /**\n * Path to the main entry file of your Tailwind CSS setup.\n * Enabling this also turns on ESLint rules related to Tailwind CSS.\n */\n tailwindEntryPoint?: string\n /**\n * Glob patterns that match your Vitest test files.\n * When provided, ESLint rules for Vitest will be enabled.\n */\n vitestGlob?: string\n /**\n * Glob patterns that match your Playwright test files.\n * When provided, ESLint rules for Playwright will be enabled.\n */\n playwrightGlob?: string\n /**\n * A list of file paths or glob patterns to be ignored by ESLint.\n */\n ignores?: string[]\n}\n\nconst isReactInstalled = isPackageExists('react')\nconst isNextjsInstalled = isPackageExists('next')\n\nexport const defineConfig = (options: Options): Linter.Config[] => {\n const configs = [\n ...gitignore,\n ...ignores(options.ignores ?? []),\n ...javascript,\n ...sonarjs,\n ...importSort,\n ...deMorgan,\n ...comments,\n ...node,\n ...jsdoc,\n ...imports,\n ...command,\n ...unicorn,\n ...jsx,\n ...typescript(options.tsconfigRootDir),\n ...regexp\n ]\n\n const isNextjsEnabled = options.nextjs ?? isNextjsInstalled\n const isReactEnabled = (options.react ?? isReactInstalled) || isNextjsEnabled\n\n if (options.vitestGlob) {\n configs.push(...vitest(options.vitestGlob))\n }\n\n if (options.playwrightGlob) {\n configs.push(...playwright(options.playwrightGlob))\n }\n\n if (isReactEnabled) {\n configs.push(...react)\n }\n\n if (isNextjsEnabled) {\n configs.push(...nextjs)\n }\n\n if (options.tailwindEntryPoint) {\n configs.push(...tailwindcss(options.tailwindEntryPoint))\n }\n\n // Must be added as the last item\n // https://github.com/prettier/eslint-plugin-prettier?tab=readme-ov-file#configuration-new-eslintconfigjs\n configs.push(...prettier)\n\n return configs\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAaA,UAA2B,CACtC;CACE,GAAG;CACH,MAAM;;;;;ACHV,MAAaC,WAA4B,CACvC;CACE,MAAM;CACN,SAAS,EACP,qCAAqC;CAEvC,OAAO;EACL,GAAG,eAAe,QAAQ,YAAY;EAEtC,yDAAyD;EACzD,uDAAuD;EACvD,2DAA2D;EAC3D,4CAA4C;;;;;;ACZlD,MAAaC,WAA4B,CACvC;CACE,MAAM;CACN,SAAS,EACP,aAAa;CAEf,OAAO,EACL,GAAG,eAAe,QAAQ,YAAY;;;;;ACP5C,MAAaC,YAA6B,CACxC,gBAAgB,EACd,MAAM;;;;ACJV,MAAa,WAAW,gBAA2C,CACjE;CACE,MAAM;CACN,SAAS,CAAC,GAAG;;;;;ACDjB,MAAaC,aAA8B,CACzC;CACE,MAAM;CACN,SAAS,EACP,eAAe;CAEjB,OAAO;EACL,uBAAuB,CACrB,SACA,EACE,QAAQ;GAEN;IACE,OAAO,GAAG;IACV,OAAO,GAAG;IACV,OAAO,GAAG;IACV,OAAO,GAAG;IACV,OAAO,GAAG;;GAIZ,CAAC,OAAO,GAAG;GAGX,CAAC;GAGD,CAAC,OAAO,GAAG;GAGX,CAAC;GAGD,CAAC,OAAO,GAAG;GAGX,CAAC,OAAO,GAAG;;EAIjB,uBAAuB;;;;;;ACxC7B,MAAaC,UAA2B,CACtC;CACE,MAAM;CACN,SAAS,EACP,eAAe;CAEjB,OA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BAAkB,QAAQ,SAAS,qBAAqB;AAE9D,KAAI,QAAQ,WACV,SAAQ,KAAK,GAAG,OAAO,QAAQ;AAGjC,KAAI,QAAQ,eACV,SAAQ,KAAK,GAAG,WAAW,QAAQ;AAGrC,KAAI,eACF,SAAQ,KAAK,GAAG;AAGlB,KAAI,gBACF,SAAQ,KAAK,GAAG;AAGlB,KAAI,QAAQ,mBACV,SAAQ,KAAK,GAAG,YAAY,QAAQ;AAKtC,SAAQ,KAAK,GAAG;AAEhB,QAAO"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/configs/command.ts","../src/configs/comments.ts","../src/configs/de-morgan.ts","../src/configs/gitignore.ts","../src/configs/ignores.ts","../src/configs/import-sort.ts","../src/configs/imports.ts","../src/configs/javascript.ts","../src/configs/jsdoc.ts","../src/globs.ts","../src/configs/jsx.ts","../src/configs/nextjs.ts","../src/configs/node.ts","../src/configs/playwright.ts","../src/configs/prettier.ts","../src/configs/react.ts","../src/configs/regexp.ts","../src/configs/sonarjs.ts","../src/configs/tailwindcss.ts","../src/configs/typescript.ts","../src/configs/unicorn.ts","../src/configs/vitest.ts","../src/base.ts"],"sourcesContent":["import type { FlatConfig } from '../types'\n\nimport { commandPlugin } from '../plugins'\n\nexport const command = (): FlatConfig[] => [\n {\n ...commandPlugin(),\n name: 'nelsonlaidev/command/rules'\n }\n]\n","import type { FlatConfig, RuleOverrides } from '../types'\n\nimport { commentsPlugin } from '../plugins'\n\nexport const comments = (overrides?: RuleOverrides): FlatConfig[] => [\n {\n name: 'nelsonlaidev/eslint-comments/rules',\n plugins: {\n '@eslint-community/eslint-comments': commentsPlugin\n },\n rules: {\n ...commentsPlugin.configs.recommended.rules,\n\n '@eslint-community/eslint-comments/require-description': 'error',\n '@eslint-community/eslint-comments/no-unused-disable': 'error',\n '@eslint-community/eslint-comments/no-restricted-disable': 'error',\n '@eslint-community/eslint-comments/no-use': ['error', { allow: ['eslint-disable-next-line'] }],\n\n ...overrides\n }\n }\n]\n","import type { FlatConfig, RuleOverrides } from '../types'\n\nimport { deMorganPlugin } from '../plugins'\n\nexport const deMorgan = (overrides?: RuleOverrides): FlatConfig[] => [\n {\n name: 'nelsonlaidev/de-morgan/rules',\n plugins: {\n 'de-morgan': deMorganPlugin\n },\n rules: {\n ...deMorganPlugin.configs.recommended.rules,\n\n ...overrides\n }\n }\n]\n","import type { FlatConfig } from '../types'\n\nimport gitignorePlugin from 'eslint-config-flat-gitignore'\n\nexport const gitignore = (): FlatConfig[] => [\n gitignorePlugin({\n name: 'nelsonlaidev/gitignore'\n })\n]\n","import type { FlatConfig } from '../types'\n\nexport const ignores = (userIgnores: string[] = []): FlatConfig[] => [\n {\n name: 'nelsonlaidev/ignores',\n ignores: [...userIgnores]\n }\n]\n","import type { FlatConfig, RuleOverrides } from '../types'\n\nimport { importSortPlugin } from '../plugins'\n\nexport const importSort = (overrides?: RuleOverrides): FlatConfig[] => [\n {\n name: 'nelsonlaidev/import-sort/rules',\n plugins: {\n 'import-sort': importSortPlugin\n },\n rules: {\n 'import-sort/imports': [\n 'error',\n {\n groups: [\n // Type imports\n [\n String.raw`^.*\\u0000$`,\n String.raw`^node:.*\\u0000$`,\n String.raw`^@?\\w.*\\u0000$`,\n String.raw`^\\.\\..*\\u0000$`,\n String.raw`^\\..*\\u0000$`\n ],\n\n // Side effect imports (e.g., `import 'some-module'`)\n [String.raw`^\\u0000`],\n\n // Node.js builtins prefixed with `node:`\n ['^node:'],\n\n // Things that start with a letter (or digit or underscore), or `@` followed by a letter\n [String.raw`^@?\\w`],\n\n // Absolute imports (e.g., `import something from 'src/utils'`)\n ['^[^.]'],\n\n // Parent directory relative imports (e.g., `import something from '../utils'`)\n [String.raw`^\\.\\.`],\n\n // Current directory relative imports (e.g., `import something from './utils'`)\n [String.raw`^\\.`]\n ]\n }\n ],\n 'import-sort/exports': 'error',\n\n ...overrides\n }\n }\n]\n","import type { FlatConfig, RuleOverrides } from '../types'\n\nimport { importLitePlugin } from '../plugins'\n\nexport const imports = (overrides?: RuleOverrides): FlatConfig[] => [\n {\n name: 'nelsonlaidev/imports/rules',\n plugins: {\n 'import-lite': importLitePlugin\n },\n rules: {\n 'import-lite/first': 'error',\n 'import-lite/newline-after-import': ['error', { count: 1 }],\n 'import-lite/no-duplicates': 'error',\n 'import-lite/no-mutable-exports': 'error',\n 'import-lite/no-named-default': 'error',\n\n ...overrides\n }\n }\n]\n","import type { FlatConfig, RuleOverrides } from '../types'\n\nimport eslint from '@eslint/js'\nimport globals from 'globals'\n\nimport { unusedImportsPlugin } from '../plugins'\n\nexport const javascript = (overrides?: RuleOverrides): FlatConfig[] => [\n {\n name: 'nelsonlaidev/javascript/setup',\n languageOptions: {\n ecmaVersion: 2022,\n globals: {\n ...globals.browser,\n ...globals.es2021,\n ...globals.node,\n document: 'readonly',\n navigator: 'readonly',\n window: 'readonly'\n },\n parserOptions: {\n ecmaFeatures: {\n jsx: true\n },\n ecmaVersion: 2022,\n sourceType: 'module'\n },\n sourceType: 'module'\n },\n linterOptions: {\n reportUnusedDisableDirectives: 'error',\n reportUnusedInlineConfigs: 'error'\n }\n },\n {\n name: 'nelsonlaidev/javascript/rules',\n plugins: {\n 'unused-imports': unusedImportsPlugin\n },\n rules: {\n ...eslint.configs.recommended.rules,\n\n // Recommended to disable\n // https://github.com/sweepline/eslint-plugin-unused-imports?tab=readme-ov-file#usage\n 'no-unused-vars': 'off',\n '@typescript-eslint/no-unused-vars': 'off',\n\n 'unused-imports/no-unused-imports': 'error',\n 'unused-imports/no-unused-vars': [\n 'error',\n {\n vars: 'all',\n varsIgnorePattern: '^_',\n args: 'after-used',\n argsIgnorePattern: '^_'\n }\n ],\n\n ...overrides\n }\n }\n]\n","import type { FlatConfig, RuleOverrides } from '../types'\n\nimport { jsdocPlugin } from '../plugins'\n\nexport const jsdoc = (overrides?: RuleOverrides): FlatConfig[] => [\n {\n name: 'nelsonlaidev/jsdoc/rules',\n plugins: {\n jsdoc: jsdocPlugin\n },\n rules: {\n ...jsdocPlugin.configs['flat/recommended'].rules,\n\n ...overrides\n }\n }\n]\n","export const GLOB_SRC_EXT = '?([cm])[jt]s?(x)'\nexport const GLOB_SRC = '**/*.?([cm])[jt]s?(x)'\n\nexport const GLOB_JS = '**/*.?([cm])js'\nexport const GLOB_JSX = '**/*.?([cm])jsx'\n\nexport const GLOB_TS = '**/*.?([cm])ts'\nexport const GLOB_TSX = '**/*.?([cm])tsx'\n","import type { FlatConfig, RuleOverrides } from '../types'\n\nimport { GLOB_JSX, GLOB_TSX } from '../globs'\nimport { jsxA11yPlugin } from '../plugins'\n\nexport const jsx = (overrides?: RuleOverrides): FlatConfig[] => [\n {\n name: 'nelsonlaidev/jsx/setup',\n files: [GLOB_JSX, GLOB_TSX],\n languageOptions: {\n parserOptions: {\n ecmaFeatures: {\n jsx: true\n }\n }\n }\n },\n {\n name: 'nelsonlaidev/jsx/rules',\n files: [GLOB_JSX, GLOB_TSX],\n plugins: {\n 'jsx-a11y': jsxA11yPlugin\n },\n rules: {\n ...jsxA11yPlugin.flatConfigs.strict.rules,\n\n 'jsx-a11y/anchor-ambiguous-text': 'error',\n 'jsx-a11y/lang': 'error',\n 'jsx-a11y/no-aria-hidden-on-focusable': 'error',\n 'jsx-a11y/prefer-tag-over-role': 'error',\n\n ...overrides\n },\n settings: {\n 'jsx-a11y': {\n components: {\n Button: 'button',\n Image: 'img',\n Input: 'input',\n Textarea: 'textarea',\n Link: 'a'\n }\n }\n }\n }\n]\n","import type { FlatConfig, RuleOverrides } from '../types'\n\nimport { nextPlugin } from '../plugins'\n\nexport const nextjs = (overrides?: RuleOverrides): FlatConfig[] => [\n {\n name: 'nelsonlaidev/nextjs/rules',\n plugins: {\n '@next/next': nextPlugin\n },\n rules: {\n ...nextPlugin.configs.recommended.rules,\n ...nextPlugin.configs['core-web-vitals'].rules,\n\n ...overrides\n }\n }\n]\n","import type { FlatConfig, RuleOverrides } from '../types'\n\nimport { nodePlugin } from '../plugins'\n\nexport const node = (overrides?: RuleOverrides): FlatConfig[] => [\n {\n name: 'nelsonlaidev/node/rules',\n plugins: {\n n: nodePlugin\n },\n rules: {\n 'n/handle-callback-err': ['error', '^(err|error)$'],\n 'n/no-deprecated-api': 'error',\n 'n/no-exports-assign': 'error',\n 'n/no-new-require': 'error',\n 'n/no-path-concat': 'error',\n 'n/prefer-promises/fs': 'error',\n 'n/process-exit-as-throw': 'error',\n\n ...overrides\n }\n }\n]\n","import type { FlatConfig, RuleOverrides } from '../types'\n\nimport globals from 'globals'\n\nimport { playwrightPlugin } from '../plugins'\n\nexport const playwright = (glob: string, overrides?: RuleOverrides): FlatConfig[] => [\n {\n name: 'nelsonlaidev/playwright/setup',\n languageOptions: {\n globals: globals['shared-node-browser']\n }\n },\n {\n name: 'nelsonlaidev/playwright/rules',\n files: [glob],\n plugins: {\n playwright: playwrightPlugin\n },\n rules: {\n ...playwrightPlugin.configs.recommended.rules,\n\n ...overrides\n }\n }\n]\n","import type { FlatConfig, RuleOverrides } from '../types'\n\nimport { prettierPlugin, prettierPluginRecommended } from '../plugins'\n\nexport const prettier = (overrides?: RuleOverrides): FlatConfig[] => [\n {\n name: 'nelsonlaidev/prettier/rules',\n plugins: {\n prettier: prettierPlugin\n },\n rules: {\n ...prettierPluginRecommended.rules,\n\n ...overrides\n }\n }\n]\n","import type { FlatConfig, RuleOverrides } from '../types'\n\nimport { GLOB_SRC } from '../globs'\nimport { reactHooksPlugin, reactPlugin } from '../plugins'\n\nexport const react = (overrides?: RuleOverrides): FlatConfig[] => [\n {\n name: 'nelsonlaidev/react/rules',\n files: [GLOB_SRC],\n plugins: {\n ...reactPlugin.configs.all.plugins,\n 'react-hooks': reactHooksPlugin\n },\n rules: {\n ...reactPlugin.configs.all.rules,\n ...reactHooksPlugin.configs['recommended-latest'].rules,\n\n '@eslint-react/naming-convention/filename': ['error', 'kebab-case'],\n\n // Unnecessary\n '@eslint-react/avoid-shorthand-boolean': 'off',\n '@eslint-react/avoid-shorthand-fragment': 'off',\n '@eslint-react/no-complex-conditional-rendering': 'off',\n '@eslint-react/no-array-index-key': 'off',\n\n ...overrides\n }\n }\n]\n","import type { FlatConfig, RuleOverrides } from '../types'\n\nimport { regexpPlugin } from '../plugins'\n\nexport const regexp = (overrides?: RuleOverrides): FlatConfig[] => [\n {\n name: 'nelsonlaidev/regexp/rules',\n plugins: {\n regexp: regexpPlugin\n },\n rules: {\n ...regexpPlugin.configs['flat/recommended'].rules,\n\n ...overrides\n }\n }\n]\n","import type { FlatConfig, RuleOverrides } from '../types'\n\nimport { sonarjsPlugin } from '../plugins'\n\nexport const sonarjs = (overrides?: RuleOverrides): FlatConfig[] => [\n {\n name: 'nelsonlaidev/sonarjs/rules',\n plugins: {\n sonarjs: sonarjsPlugin\n },\n rules: {\n ...sonarjsPlugin.configs.recommended.rules,\n\n // Disable due to poor performance\n // https://community.sonarsource.com/t/eslint-plugin-sonarjs-performance-issues-on-large-codebase/138392\n 'sonarjs/no-commented-code': 'off',\n\n ...overrides\n }\n }\n]\n","import type { FlatConfig, RuleOverrides } from '../types'\n\nimport { tailwindcssPlugin } from '../plugins'\n\nexport const tailwindcss = (entryPoint: string, overrides?: RuleOverrides): FlatConfig[] => [\n {\n name: 'nelsonlaidev/tailwindcss/rules',\n plugins: {\n 'better-tailwindcss': tailwindcssPlugin\n },\n rules: {\n 'better-tailwindcss/enforce-consistent-class-order': 'error',\n 'better-tailwindcss/enforce-consistent-important-position': 'error',\n 'better-tailwindcss/enforce-consistent-variable-syntax': 'error',\n 'better-tailwindcss/enforce-shorthand-classes': 'error',\n 'better-tailwindcss/no-conflicting-classes': 'error',\n 'better-tailwindcss/no-deprecated-classes': 'error',\n 'better-tailwindcss/no-duplicate-classes': 'error',\n 'better-tailwindcss/no-unnecessary-whitespace': 'error',\n 'better-tailwindcss/no-unregistered-classes': 'error',\n\n ...overrides\n },\n settings: {\n 'better-tailwindcss': {\n entryPoint\n }\n }\n }\n]\n","import type { FlatConfig, RuleOverrides } from '../types'\n\nimport process from 'node:process'\n\nimport parser from '@typescript-eslint/parser'\n\nimport { GLOB_TS, GLOB_TSX } from '../globs'\nimport { typescriptPlugin } from '../plugins'\n\nexport const typescript = (tsconfigRootDir: string = process.cwd(), overrides?: RuleOverrides): FlatConfig[] => [\n {\n name: 'nelsonlaidev/typescript/setup',\n files: [GLOB_TS, GLOB_TSX],\n languageOptions: {\n parser,\n parserOptions: {\n projectService: true,\n tsconfigRootDir\n },\n sourceType: 'module'\n },\n plugins: {\n '@typescript-eslint': typescriptPlugin\n }\n },\n {\n name: 'nelsonlaidev/typescript/rules',\n files: [GLOB_TS, GLOB_TSX],\n rules: {\n ...typescriptPlugin.configs['eslint-recommended'].overrides[0].rules,\n ...typescriptPlugin.configs['strict-type-checked'].rules,\n ...typescriptPlugin.configs['stylistic-type-checked'].rules,\n\n '@typescript-eslint/array-type': ['error', { default: 'array-simple' }],\n '@typescript-eslint/no-invalid-this': 'error',\n '@typescript-eslint/no-shadow': 'error',\n '@typescript-eslint/consistent-type-imports': [\n 'error',\n {\n prefer: 'type-imports',\n fixStyle: 'inline-type-imports'\n }\n ],\n '@typescript-eslint/restrict-template-expressions': ['error', { allowNumber: true }],\n '@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: false }],\n\n // Too opinionated\n '@typescript-eslint/no-floating-promises': 'off',\n '@typescript-eslint/no-unsafe-member-access': 'off',\n '@typescript-eslint/no-unsafe-assignment': 'off',\n '@typescript-eslint/no-non-null-assertion': 'off',\n\n '@typescript-eslint/consistent-type-definitions': 'off',\n\n ...overrides\n }\n }\n]\n","import type { FlatConfig, RuleOverrides } from '../types'\n\nimport { unicornPlugin } from '../plugins'\n\nexport const unicorn = (overrides?: RuleOverrides): FlatConfig[] => [\n {\n name: 'nelsonlaidev/unicorn/rules',\n plugins: {\n unicorn: unicornPlugin\n },\n rules: {\n ...unicornPlugin.configs.recommended.rules,\n\n // Too opinionated\n 'unicorn/prevent-abbreviations': 'off',\n 'unicorn/no-null': 'off',\n\n ...overrides\n }\n }\n]\n","import type { FlatConfig, RuleOverrides } from '../types'\n\nimport { vitestPlugin } from '../plugins'\n\nexport const vitest = (glob: string, overrides?: RuleOverrides): FlatConfig[] => [\n {\n name: 'nelsonlaidev/vitest/rules',\n files: [glob],\n plugins: {\n vitest: vitestPlugin\n },\n rules: {\n ...vitestPlugin.configs.recommended.rules,\n\n ...overrides\n }\n }\n]\n","import type { ConfigOptions, FlatConfig } from './types'\n\nimport { isPackageExists } from 'local-pkg'\n\nimport { command } from './configs/command'\nimport { comments } from './configs/comments'\nimport { deMorgan } from './configs/de-morgan'\nimport { gitignore } from './configs/gitignore'\nimport { ignores } from './configs/ignores'\nimport { importSort } from './configs/import-sort'\nimport { imports } from './configs/imports'\nimport { javascript } from './configs/javascript'\nimport { jsdoc } from './configs/jsdoc'\nimport { jsx } from './configs/jsx'\nimport { nextjs } from './configs/nextjs'\nimport { node } from './configs/node'\nimport { playwright } from './configs/playwright'\nimport { prettier } from './configs/prettier'\nimport { react } from './configs/react'\nimport { regexp } from './configs/regexp'\nimport { sonarjs } from './configs/sonarjs'\nimport { tailwindcss } from './configs/tailwindcss'\nimport { typescript } from './configs/typescript'\nimport { unicorn } from './configs/unicorn'\nimport { vitest } from './configs/vitest'\n\nconst isReactInstalled = isPackageExists('react')\nconst isNextjsInstalled = isPackageExists('next')\n\nexport const defineConfig = (options: ConfigOptions = {}, ...userConfigs: FlatConfig[]): FlatConfig[] => {\n const { overrides = {} } = options\n\n const configs = [\n ...gitignore(),\n ...ignores(options.ignores ?? []),\n ...javascript(overrides.javascript),\n ...sonarjs(overrides.sonarjs),\n ...importSort(overrides.importSort),\n ...deMorgan(overrides.deMorgan),\n ...comments(overrides.comments),\n ...node(overrides.node),\n ...jsdoc(overrides.jsdoc),\n ...imports(overrides.imports),\n ...command(),\n ...unicorn(overrides.unicorn),\n ...jsx(overrides.jsx),\n ...typescript(options.tsconfigRootDir, overrides.typescript),\n ...regexp(overrides.regexp)\n ]\n\n const isNextjsEnabled = options.nextjs ?? isNextjsInstalled\n const isReactEnabled = (options.react ?? isReactInstalled) || isNextjsEnabled\n\n if (options.vitestGlob) {\n configs.push(...vitest(options.vitestGlob, overrides.vitest))\n }\n\n if (options.playwrightGlob) {\n configs.push(...playwright(options.playwrightGlob, overrides.playwright))\n }\n\n if (isReactEnabled) {\n configs.push(...react(overrides.react))\n }\n\n if (isNextjsEnabled) {\n configs.push(...nextjs(overrides.nextjs))\n }\n\n if (options.tailwindEntryPoint) {\n configs.push(...tailwindcss(options.tailwindEntryPoint, overrides.tailwindcss))\n }\n\n configs.push(...userConfigs)\n\n // Must be added as the last item\n // https://github.com/prettier/eslint-plugin-prettier?tab=readme-ov-file#configuration-new-eslintconfigjs\n // eslint-disable-next-line unicorn/prefer-single-call -- For better readability\n configs.push(...prettier(overrides.prettier))\n\n return configs\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAa,gBAA8B,CACzC;CACE,GAAG;CACH,MAAM;;;;;ACHV,MAAa,YAAY,cAA4C,CACnE;CACE,MAAM;CACN,SAAS,EACP,qCAAqC;CAEvC,OAAO;EACL,GAAG,eAAe,QAAQ,YAAY;EAEtC,yDAAyD;EACzD,uDAAuD;EACvD,2DAA2D;EAC3D,4CAA4C,CAAC,SAAS,EAAE,OAAO,CAAC;EAEhE,GAAG;;;;;;ACdT,MAAa,YAAY,cAA4C,CACnE;CACE,MAAM;CACN,SAAS,EACP,aAAa;CAEf,OAAO;EACL,GAAG,eAAe,QAAQ,YAAY;EAEtC,GAAG;;;;;;ACTT,MAAa,kBAAgC,CAC3C,gBAAgB,EACd,MAAM;;;;ACJV,MAAa,WAAW,cAAwB,OAAqB,CACnE;CACE,MAAM;CACN,SAAS,CAAC,GAAG;;;;;ACDjB,MAAa,cAAc,cAA4C,CACrE;CACE,MAAM;CACN,SAAS,EACP,eAAe;CAEjB,OAAO;EACL,uBAAuB,CACrB,SACA,EACE,QAAQ;GAEN;IACE,OAAO,GAAG;IACV,OAAO,GAAG;IACV,OAAO,G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Q,KAAK,GAAG;AAKhB,SAAQ,KAAK,GAAG,SAAS,UAAU;AAEnC,QAAO"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nelsonlaidev/eslint-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"homepage": "https://github.com/nelsonlaidev/config/blob/main/packages/eslint-config/README.md",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/nelsonlaidev/config/issues"
|
|
@@ -11,10 +11,12 @@
|
|
|
11
11
|
"directory": "packages/eslint-config"
|
|
12
12
|
},
|
|
13
13
|
"license": "MIT",
|
|
14
|
-
"author": "Nelson Lai <me@nelsonlai.
|
|
14
|
+
"author": "Nelson Lai <me@nelsonlai.dev> (https://github.com/nelsonlaidev/)",
|
|
15
15
|
"type": "module",
|
|
16
|
-
"
|
|
17
|
-
|
|
16
|
+
"exports": {
|
|
17
|
+
"import": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts"
|
|
19
|
+
},
|
|
18
20
|
"files": [
|
|
19
21
|
"dist"
|
|
20
22
|
],
|
|
@@ -41,7 +43,6 @@
|
|
|
41
43
|
"eslint-plugin-playwright": "^2.2.2",
|
|
42
44
|
"eslint-plugin-prettier": "^5.5.4",
|
|
43
45
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
44
|
-
"eslint-plugin-react-refresh": "^0.4.20",
|
|
45
46
|
"eslint-plugin-regexp": "^2.10.0",
|
|
46
47
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
47
48
|
"eslint-plugin-sonarjs": "^3.0.5",
|
|
@@ -55,7 +56,7 @@
|
|
|
55
56
|
"@types/node": "^22.18.0",
|
|
56
57
|
"eslint": "^9.34.0",
|
|
57
58
|
"tsdown": "^0.14.2",
|
|
58
|
-
"@nelsonlaidev/typescript-config": "0.0.
|
|
59
|
+
"@nelsonlaidev/typescript-config": "0.0.3"
|
|
59
60
|
},
|
|
60
61
|
"peerDependencies": {
|
|
61
62
|
"eslint": ">=9.0.0"
|