@lqbach/eslint-config 0.6.0 โ 0.7.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/CHANGELOG.md +32 -0
- package/README.md +19 -0
- package/dist/index.cjs +105 -20
- package/dist/index.d.cts +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.js +139 -54
- package/package.json +14 -14
- package/src/index.ts +62 -8
- package/src/libs.ts +2 -1
- package/src/types.ts +17 -3
- package/test/ignore.spec.ts +39 -0
- package/test/next.spec.ts +56 -0
- package/test/utils.ts +16 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.7.0](https://github.com/lqbach/eslint-prettier-config/compare/eslint-config-v0.6.1...eslint-config-v0.7.0) (2024-12-22)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features ๐
|
|
7
|
+
|
|
8
|
+
* add nextjs config ([#18](https://github.com/lqbach/eslint-prettier-config/issues/18)) ([423b1b2](https://github.com/lqbach/eslint-prettier-config/commit/423b1b28dc519ff24d5824e7e1c0d3f60db083df))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes ๐
|
|
12
|
+
|
|
13
|
+
* add `composite=true` to tsconfig files ([#15](https://github.com/lqbach/eslint-prettier-config/issues/15)) ([965d40e](https://github.com/lqbach/eslint-prettier-config/commit/965d40eac4ac5c1071c421aadd5e54c6c2e634be))
|
|
14
|
+
* remove `remove` package ([5655b9b](https://github.com/lqbach/eslint-prettier-config/commit/5655b9bf822c8fc8ff27b66e13c7170ccfca534b))
|
|
15
|
+
* remove composite true setting ([e604a78](https://github.com/lqbach/eslint-prettier-config/commit/e604a78fe24f417fcc4c82d678ebc4be7fd8e1d5))
|
|
16
|
+
* update types in eslint-config ([0f3afd4](https://github.com/lqbach/eslint-prettier-config/commit/0f3afd405bd1b930c74ad3272d113de0639e073e))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Chores ๐งน
|
|
20
|
+
|
|
21
|
+
* upgrade prettier in subpackages ([3e60af5](https://github.com/lqbach/eslint-prettier-config/commit/3e60af54a2d7e79cfc1b9c6ee3901db88d9161b3))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Tests ๐งช
|
|
25
|
+
|
|
26
|
+
* add ignore tests ([#17](https://github.com/lqbach/eslint-prettier-config/issues/17)) ([503837b](https://github.com/lqbach/eslint-prettier-config/commit/503837b49572bb8a5108f8f4316907ebdca7e83b))
|
|
27
|
+
|
|
28
|
+
## [0.6.1](https://github.com/lqbach/eslint-prettier-config/compare/eslint-config-v0.6.0...eslint-config-v0.6.1) (2024-10-02)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Bug Fixes ๐
|
|
32
|
+
|
|
33
|
+
* update recommended rules for react ([2ae610f](https://github.com/lqbach/eslint-prettier-config/commit/2ae610f9106287dbd9be8e16ef58c8e5f8248eb6))
|
|
34
|
+
|
|
3
35
|
## [0.6.0](https://github.com/lqbach/eslint-prettier-config/compare/eslint-config-v0.5.0...eslint-config-v0.6.0) (2024-08-26)
|
|
4
36
|
|
|
5
37
|
|
package/README.md
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
- [Features](#features)
|
|
22
22
|
- [Ignoring Files](#ignoring-files)
|
|
23
23
|
- [React and Vue](#react-and-vue)
|
|
24
|
+
- [NextJS](#nextjs)
|
|
24
25
|
|
|
25
26
|
## Usage
|
|
26
27
|
|
|
@@ -110,3 +111,21 @@ export default eslintConfig({
|
|
|
110
111
|
// react: true,
|
|
111
112
|
})
|
|
112
113
|
```
|
|
114
|
+
|
|
115
|
+
### NextJS
|
|
116
|
+
|
|
117
|
+
NextJS has options for parameters. The following parameters are supported:
|
|
118
|
+
|
|
119
|
+
```js
|
|
120
|
+
// eslint.config.js
|
|
121
|
+
import eslintConfig from "@lqbach/eslint-config"
|
|
122
|
+
|
|
123
|
+
export default eslintConfig({
|
|
124
|
+
next: {
|
|
125
|
+
rootDir: "packages/example", //set the root directory of next project, useful for monorepo
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
// can also use boolean for default configuration
|
|
129
|
+
// next: true,
|
|
130
|
+
})
|
|
131
|
+
```
|
package/dist/index.cjs
CHANGED
|
@@ -30,9 +30,50 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
));
|
|
31
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
32
|
|
|
33
|
-
// ../../node_modules/.pnpm/@eslint+js@
|
|
33
|
+
// ../../node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/package.json
|
|
34
|
+
var require_package = __commonJS({
|
|
35
|
+
"../../node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/package.json"(exports2, module2) {
|
|
36
|
+
module2.exports = {
|
|
37
|
+
name: "@eslint/js",
|
|
38
|
+
version: "9.17.0",
|
|
39
|
+
description: "ESLint JavaScript language implementation",
|
|
40
|
+
main: "./src/index.js",
|
|
41
|
+
types: "./types/index.d.ts",
|
|
42
|
+
scripts: {
|
|
43
|
+
"test:types": "tsc -p tests/types/tsconfig.json"
|
|
44
|
+
},
|
|
45
|
+
files: [
|
|
46
|
+
"LICENSE",
|
|
47
|
+
"README.md",
|
|
48
|
+
"src",
|
|
49
|
+
"types"
|
|
50
|
+
],
|
|
51
|
+
publishConfig: {
|
|
52
|
+
access: "public"
|
|
53
|
+
},
|
|
54
|
+
repository: {
|
|
55
|
+
type: "git",
|
|
56
|
+
url: "https://github.com/eslint/eslint.git",
|
|
57
|
+
directory: "packages/js"
|
|
58
|
+
},
|
|
59
|
+
homepage: "https://eslint.org",
|
|
60
|
+
bugs: "https://github.com/eslint/eslint/issues/",
|
|
61
|
+
keywords: [
|
|
62
|
+
"javascript",
|
|
63
|
+
"eslint-plugin",
|
|
64
|
+
"eslint"
|
|
65
|
+
],
|
|
66
|
+
license: "MIT",
|
|
67
|
+
engines: {
|
|
68
|
+
node: "^18.18.0 || ^20.9.0 || >=21.1.0"
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// ../../node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/src/configs/eslint-all.js
|
|
34
75
|
var require_eslint_all = __commonJS({
|
|
35
|
-
"../../node_modules/.pnpm/@eslint+js@
|
|
76
|
+
"../../node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/src/configs/eslint-all.js"(exports2, module2) {
|
|
36
77
|
"use strict";
|
|
37
78
|
module2.exports = Object.freeze({
|
|
38
79
|
"rules": {
|
|
@@ -64,7 +105,6 @@ var require_eslint_all = __commonJS({
|
|
|
64
105
|
"id-length": "error",
|
|
65
106
|
"id-match": "error",
|
|
66
107
|
"init-declarations": "error",
|
|
67
|
-
"line-comment-position": "error",
|
|
68
108
|
"logical-assignment-operators": "error",
|
|
69
109
|
"max-classes-per-file": "error",
|
|
70
110
|
"max-depth": "error",
|
|
@@ -73,7 +113,6 @@ var require_eslint_all = __commonJS({
|
|
|
73
113
|
"max-nested-callbacks": "error",
|
|
74
114
|
"max-params": "error",
|
|
75
115
|
"max-statements": "error",
|
|
76
|
-
"multiline-comment-style": "error",
|
|
77
116
|
"new-cap": "error",
|
|
78
117
|
"no-alert": "error",
|
|
79
118
|
"no-array-constructor": "error",
|
|
@@ -142,7 +181,6 @@ var require_eslint_all = __commonJS({
|
|
|
142
181
|
"no-new": "error",
|
|
143
182
|
"no-new-func": "error",
|
|
144
183
|
"no-new-native-nonconstructor": "error",
|
|
145
|
-
"no-new-symbol": "error",
|
|
146
184
|
"no-new-wrappers": "error",
|
|
147
185
|
"no-nonoctal-decimal-escape": "error",
|
|
148
186
|
"no-obj-calls": "error",
|
|
@@ -191,6 +229,7 @@ var require_eslint_all = __commonJS({
|
|
|
191
229
|
"no-unused-private-class-members": "error",
|
|
192
230
|
"no-unused-vars": "error",
|
|
193
231
|
"no-use-before-define": "error",
|
|
232
|
+
"no-useless-assignment": "error",
|
|
194
233
|
"no-useless-backreference": "error",
|
|
195
234
|
"no-useless-call": "error",
|
|
196
235
|
"no-useless-catch": "error",
|
|
@@ -240,9 +279,9 @@ var require_eslint_all = __commonJS({
|
|
|
240
279
|
}
|
|
241
280
|
});
|
|
242
281
|
|
|
243
|
-
// ../../node_modules/.pnpm/@eslint+js@
|
|
282
|
+
// ../../node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/src/configs/eslint-recommended.js
|
|
244
283
|
var require_eslint_recommended = __commonJS({
|
|
245
|
-
"../../node_modules/.pnpm/@eslint+js@
|
|
284
|
+
"../../node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/src/configs/eslint-recommended.js"(exports2, module2) {
|
|
246
285
|
"use strict";
|
|
247
286
|
module2.exports = Object.freeze({
|
|
248
287
|
rules: Object.freeze({
|
|
@@ -255,6 +294,7 @@ var require_eslint_recommended = __commonJS({
|
|
|
255
294
|
"no-compare-neg-zero": "error",
|
|
256
295
|
"no-cond-assign": "error",
|
|
257
296
|
"no-const-assign": "error",
|
|
297
|
+
"no-constant-binary-expression": "error",
|
|
258
298
|
"no-constant-condition": "error",
|
|
259
299
|
"no-control-regex": "error",
|
|
260
300
|
"no-debugger": "error",
|
|
@@ -267,20 +307,18 @@ var require_eslint_recommended = __commonJS({
|
|
|
267
307
|
"no-empty": "error",
|
|
268
308
|
"no-empty-character-class": "error",
|
|
269
309
|
"no-empty-pattern": "error",
|
|
310
|
+
"no-empty-static-block": "error",
|
|
270
311
|
"no-ex-assign": "error",
|
|
271
312
|
"no-extra-boolean-cast": "error",
|
|
272
|
-
"no-extra-semi": "error",
|
|
273
313
|
"no-fallthrough": "error",
|
|
274
314
|
"no-func-assign": "error",
|
|
275
315
|
"no-global-assign": "error",
|
|
276
316
|
"no-import-assign": "error",
|
|
277
|
-
"no-inner-declarations": "error",
|
|
278
317
|
"no-invalid-regexp": "error",
|
|
279
318
|
"no-irregular-whitespace": "error",
|
|
280
319
|
"no-loss-of-precision": "error",
|
|
281
320
|
"no-misleading-character-class": "error",
|
|
282
|
-
"no-
|
|
283
|
-
"no-new-symbol": "error",
|
|
321
|
+
"no-new-native-nonconstructor": "error",
|
|
284
322
|
"no-nonoctal-decimal-escape": "error",
|
|
285
323
|
"no-obj-calls": "error",
|
|
286
324
|
"no-octal": "error",
|
|
@@ -299,6 +337,7 @@ var require_eslint_recommended = __commonJS({
|
|
|
299
337
|
"no-unsafe-negation": "error",
|
|
300
338
|
"no-unsafe-optional-chaining": "error",
|
|
301
339
|
"no-unused-labels": "error",
|
|
340
|
+
"no-unused-private-class-members": "error",
|
|
302
341
|
"no-unused-vars": "error",
|
|
303
342
|
"no-useless-backreference": "error",
|
|
304
343
|
"no-useless-catch": "error",
|
|
@@ -312,11 +351,16 @@ var require_eslint_recommended = __commonJS({
|
|
|
312
351
|
}
|
|
313
352
|
});
|
|
314
353
|
|
|
315
|
-
// ../../node_modules/.pnpm/@eslint+js@
|
|
354
|
+
// ../../node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/src/index.js
|
|
316
355
|
var require_src = __commonJS({
|
|
317
|
-
"../../node_modules/.pnpm/@eslint+js@
|
|
356
|
+
"../../node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/src/index.js"(exports2, module2) {
|
|
318
357
|
"use strict";
|
|
358
|
+
var { version } = require_package();
|
|
319
359
|
module2.exports = {
|
|
360
|
+
meta: {
|
|
361
|
+
name: "@eslint/js",
|
|
362
|
+
version
|
|
363
|
+
},
|
|
320
364
|
configs: {
|
|
321
365
|
all: require_eslint_all(),
|
|
322
366
|
recommended: require_eslint_recommended()
|
|
@@ -326,21 +370,23 @@ var require_src = __commonJS({
|
|
|
326
370
|
});
|
|
327
371
|
|
|
328
372
|
// src/index.ts
|
|
329
|
-
var
|
|
330
|
-
__export(
|
|
373
|
+
var index_exports = {};
|
|
374
|
+
__export(index_exports, {
|
|
331
375
|
default: () => config
|
|
332
376
|
});
|
|
333
|
-
module.exports = __toCommonJS(
|
|
377
|
+
module.exports = __toCommonJS(index_exports);
|
|
334
378
|
var import_globals = __toESM(require("globals"), 1);
|
|
335
379
|
|
|
336
380
|
// src/libs.ts
|
|
337
381
|
var import_js = __toESM(require_src(), 1);
|
|
382
|
+
var import_eslint_plugin_next = __toESM(require("@next/eslint-plugin-next"), 1);
|
|
338
383
|
var import_eslint_plugin = __toESM(require("@typescript-eslint/eslint-plugin"), 1);
|
|
339
384
|
var import_parser = __toESM(require("@typescript-eslint/parser"), 1);
|
|
340
385
|
var import_eslint_config_prettier = __toESM(require("eslint-config-prettier"), 1);
|
|
341
386
|
var import_eslint_plugin_jsonc = __toESM(require("eslint-plugin-jsonc"), 1);
|
|
342
387
|
var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"), 1);
|
|
343
388
|
var import_eslint_plugin_react = __toESM(require("eslint-plugin-react"), 1);
|
|
389
|
+
var import_eslint_plugin_react_hooks = __toESM(require("eslint-plugin-react-hooks"), 1);
|
|
344
390
|
var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"), 1);
|
|
345
391
|
var import_eslint_plugin_vue = __toESM(require("eslint-plugin-vue"), 1);
|
|
346
392
|
var import_eslint_plugin_yml = __toESM(require("eslint-plugin-yml"), 1);
|
|
@@ -373,8 +419,10 @@ function config(params = {}) {
|
|
|
373
419
|
"**/web/public",
|
|
374
420
|
"**/studio/build",
|
|
375
421
|
"**/studio/.sanity",
|
|
422
|
+
...params.next ? ["**/.next"] : [],
|
|
376
423
|
...params.ignores ? params.ignores : []
|
|
377
|
-
]
|
|
424
|
+
],
|
|
425
|
+
name: "lqbach/ignores"
|
|
378
426
|
};
|
|
379
427
|
const javascriptConfig = [
|
|
380
428
|
// Default
|
|
@@ -386,13 +434,13 @@ function config(params = {}) {
|
|
|
386
434
|
globals: {
|
|
387
435
|
...import_globals.default.browser,
|
|
388
436
|
...import_globals.default.node,
|
|
389
|
-
...import_globals.default.es6,
|
|
390
437
|
...import_globals.default.commonjs
|
|
391
438
|
},
|
|
392
439
|
parserOptions: {
|
|
393
440
|
sourceType: "module"
|
|
394
441
|
}
|
|
395
442
|
},
|
|
443
|
+
name: "lqbach/javascript",
|
|
396
444
|
plugins: {
|
|
397
445
|
"unused-imports": import_eslint_plugin_unused_imports.default
|
|
398
446
|
},
|
|
@@ -418,6 +466,7 @@ function config(params = {}) {
|
|
|
418
466
|
sourceType: "module"
|
|
419
467
|
}
|
|
420
468
|
},
|
|
469
|
+
name: "lqbach/typescript",
|
|
421
470
|
plugins: {
|
|
422
471
|
"@typescript-eslint": import_eslint_plugin.default
|
|
423
472
|
},
|
|
@@ -425,7 +474,7 @@ function config(params = {}) {
|
|
|
425
474
|
...import_eslint_plugin.default.configs.recommended.rules
|
|
426
475
|
}
|
|
427
476
|
} : {};
|
|
428
|
-
const reactConfig = params.react ?? false ? {
|
|
477
|
+
const reactConfig = (params.next || params.react) ?? false ? {
|
|
429
478
|
files: ["**/*.{js,jsx,mjs,cjs,ts,tsx}"],
|
|
430
479
|
languageOptions: {
|
|
431
480
|
globals: {
|
|
@@ -438,15 +487,26 @@ function config(params = {}) {
|
|
|
438
487
|
}
|
|
439
488
|
}
|
|
440
489
|
},
|
|
490
|
+
name: "lqbach/react",
|
|
441
491
|
plugins: {
|
|
442
492
|
react: import_eslint_plugin_react.default
|
|
443
493
|
},
|
|
444
494
|
rules: {
|
|
445
|
-
...import_eslint_plugin_react.default.configs.recommended.rules,
|
|
495
|
+
...import_eslint_plugin_react.default.configs.flat?.recommended.rules,
|
|
446
496
|
// ignore `css` for emotion usage
|
|
447
497
|
"react/no-unknown-property": ["error", { ignore: ["css"] }]
|
|
448
498
|
}
|
|
449
499
|
} : {};
|
|
500
|
+
const reactHooksConfig = (params.next || typeof params.react !== "boolean" && params.react?.hooks === true) ?? false ? {
|
|
501
|
+
files: ["**/*.{js,jsx,mjs,cjs,ts,tsx}"],
|
|
502
|
+
name: "lqbach/react-hooks",
|
|
503
|
+
plugins: {
|
|
504
|
+
"react-hooks": import_eslint_plugin_react_hooks.default
|
|
505
|
+
},
|
|
506
|
+
rules: {
|
|
507
|
+
...import_eslint_plugin_react_hooks.default.configs.recommended.rules
|
|
508
|
+
}
|
|
509
|
+
} : {};
|
|
450
510
|
const vueConfig = params.vue ?? false ? {
|
|
451
511
|
files: ["**/*.vue"],
|
|
452
512
|
languageOptions: {
|
|
@@ -456,6 +516,7 @@ function config(params = {}) {
|
|
|
456
516
|
sourceType: "module"
|
|
457
517
|
}
|
|
458
518
|
},
|
|
519
|
+
name: "lqbach/vue",
|
|
459
520
|
plugins: {
|
|
460
521
|
vue: import_eslint_plugin_vue.default
|
|
461
522
|
},
|
|
@@ -466,11 +527,30 @@ function config(params = {}) {
|
|
|
466
527
|
...import_eslint_plugin_vue.default.configs["vue3-strongly-recommended"].rules
|
|
467
528
|
}
|
|
468
529
|
} : {};
|
|
530
|
+
const nextConfig = params.next ?? false ? {
|
|
531
|
+
files: ["**/*.{js,jsx,ts,tsx}"],
|
|
532
|
+
name: "lqbach/next",
|
|
533
|
+
plugins: {
|
|
534
|
+
"@next/next": import_eslint_plugin_next.default
|
|
535
|
+
},
|
|
536
|
+
rules: {
|
|
537
|
+
...import_eslint_plugin_next.default.configs.recommended.rules,
|
|
538
|
+
...import_eslint_plugin_next.default.configs["core-web-vitals"].rules
|
|
539
|
+
},
|
|
540
|
+
...typeof params.next !== "boolean" && params.next?.rootDir && {
|
|
541
|
+
settings: {
|
|
542
|
+
nextjs: {
|
|
543
|
+
rootDir: params.next.rootDir
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
} : {};
|
|
469
548
|
const yamlConfig = params.yaml ?? true ? {
|
|
470
549
|
files: ["**/*.{yaml, yml}"],
|
|
471
550
|
languageOptions: {
|
|
472
551
|
parser: import_yaml_eslint_parser.default
|
|
473
552
|
},
|
|
553
|
+
name: "lqbach/yaml",
|
|
474
554
|
plugins: {
|
|
475
555
|
yml: import_eslint_plugin_yml.default
|
|
476
556
|
},
|
|
@@ -481,6 +561,7 @@ function config(params = {}) {
|
|
|
481
561
|
} : {};
|
|
482
562
|
const jsoncConfig = params.json ?? true ? [
|
|
483
563
|
{
|
|
564
|
+
name: "lqbach/jsonc-plugin",
|
|
484
565
|
plugins: {
|
|
485
566
|
jsonc: import_eslint_plugin_jsonc.default
|
|
486
567
|
}
|
|
@@ -490,6 +571,7 @@ function config(params = {}) {
|
|
|
490
571
|
languageOptions: {
|
|
491
572
|
parser: import_jsonc_eslint_parser.default
|
|
492
573
|
},
|
|
574
|
+
name: "lqbach/json",
|
|
493
575
|
rules: {
|
|
494
576
|
...import_eslint_plugin_jsonc.default.configs["recommended-with-json"].rules,
|
|
495
577
|
...import_eslint_plugin_jsonc.default.configs["recommended-with-jsonc"].rules,
|
|
@@ -500,6 +582,7 @@ function config(params = {}) {
|
|
|
500
582
|
}
|
|
501
583
|
] : [];
|
|
502
584
|
const perfectionistConfig = params.perfectionist ?? true ? {
|
|
585
|
+
name: "lqbach/perfectionist",
|
|
503
586
|
plugins: {
|
|
504
587
|
perfectionist: import_eslint_plugin_perfectionist.default
|
|
505
588
|
},
|
|
@@ -513,7 +596,9 @@ function config(params = {}) {
|
|
|
513
596
|
config2.push(...javascriptConfig);
|
|
514
597
|
config2.push(typescriptConfig);
|
|
515
598
|
config2.push(reactConfig);
|
|
599
|
+
config2.push(reactHooksConfig);
|
|
516
600
|
config2.push(vueConfig);
|
|
601
|
+
config2.push(nextConfig);
|
|
517
602
|
config2.push(yamlConfig);
|
|
518
603
|
config2.push(...jsoncConfig);
|
|
519
604
|
config2.push(perfectionistConfig);
|
package/dist/index.d.cts
CHANGED
|
@@ -2,14 +2,15 @@ interface ConfigParams {
|
|
|
2
2
|
ignores?: Array<string>;
|
|
3
3
|
json?: boolean;
|
|
4
4
|
markdown?: boolean;
|
|
5
|
+
next?: boolean | NextJSConfigParams;
|
|
5
6
|
perfectionist?: boolean;
|
|
6
|
-
react?: boolean;
|
|
7
|
+
react?: boolean | ReactJSConfigParams;
|
|
7
8
|
typescript?: boolean;
|
|
8
9
|
vue?: boolean;
|
|
9
10
|
yaml?: boolean;
|
|
10
11
|
}
|
|
11
12
|
interface LanguageOptions {
|
|
12
|
-
ecmaVersion?: string;
|
|
13
|
+
ecmaVersion?: number | string;
|
|
13
14
|
globals?: object;
|
|
14
15
|
parser?: object;
|
|
15
16
|
parserOptions?: object;
|
|
@@ -24,10 +25,20 @@ interface ConfigObject {
|
|
|
24
25
|
ignores?: Array<string>;
|
|
25
26
|
languageOptions?: LanguageOptions;
|
|
26
27
|
linterOptions?: LinterOptions;
|
|
28
|
+
name?: string;
|
|
27
29
|
plugins?: object;
|
|
28
30
|
processor?: object;
|
|
29
31
|
rules?: object;
|
|
30
|
-
settings?:
|
|
32
|
+
settings?: any;
|
|
33
|
+
}
|
|
34
|
+
interface NextJSConfigParams {
|
|
35
|
+
rootDir?: string;
|
|
36
|
+
}
|
|
37
|
+
interface ReactJSConfigParams {
|
|
38
|
+
/**
|
|
39
|
+
* use react hooks
|
|
40
|
+
*/
|
|
41
|
+
hooks?: boolean;
|
|
31
42
|
}
|
|
32
43
|
|
|
33
44
|
declare function config(params?: ConfigParams): Array<ConfigObject>;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,14 +2,15 @@ interface ConfigParams {
|
|
|
2
2
|
ignores?: Array<string>;
|
|
3
3
|
json?: boolean;
|
|
4
4
|
markdown?: boolean;
|
|
5
|
+
next?: boolean | NextJSConfigParams;
|
|
5
6
|
perfectionist?: boolean;
|
|
6
|
-
react?: boolean;
|
|
7
|
+
react?: boolean | ReactJSConfigParams;
|
|
7
8
|
typescript?: boolean;
|
|
8
9
|
vue?: boolean;
|
|
9
10
|
yaml?: boolean;
|
|
10
11
|
}
|
|
11
12
|
interface LanguageOptions {
|
|
12
|
-
ecmaVersion?: string;
|
|
13
|
+
ecmaVersion?: number | string;
|
|
13
14
|
globals?: object;
|
|
14
15
|
parser?: object;
|
|
15
16
|
parserOptions?: object;
|
|
@@ -24,10 +25,20 @@ interface ConfigObject {
|
|
|
24
25
|
ignores?: Array<string>;
|
|
25
26
|
languageOptions?: LanguageOptions;
|
|
26
27
|
linterOptions?: LinterOptions;
|
|
28
|
+
name?: string;
|
|
27
29
|
plugins?: object;
|
|
28
30
|
processor?: object;
|
|
29
31
|
rules?: object;
|
|
30
|
-
settings?:
|
|
32
|
+
settings?: any;
|
|
33
|
+
}
|
|
34
|
+
interface NextJSConfigParams {
|
|
35
|
+
rootDir?: string;
|
|
36
|
+
}
|
|
37
|
+
interface ReactJSConfigParams {
|
|
38
|
+
/**
|
|
39
|
+
* use react hooks
|
|
40
|
+
*/
|
|
41
|
+
hooks?: boolean;
|
|
31
42
|
}
|
|
32
43
|
|
|
33
44
|
declare function config(params?: ConfigParams): Array<ConfigObject>;
|
package/dist/index.js
CHANGED
|
@@ -24,9 +24,50 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
mod
|
|
25
25
|
));
|
|
26
26
|
|
|
27
|
-
// ../../node_modules/.pnpm/@eslint+js@
|
|
27
|
+
// ../../node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/package.json
|
|
28
|
+
var require_package = __commonJS({
|
|
29
|
+
"../../node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/package.json"(exports, module) {
|
|
30
|
+
module.exports = {
|
|
31
|
+
name: "@eslint/js",
|
|
32
|
+
version: "9.17.0",
|
|
33
|
+
description: "ESLint JavaScript language implementation",
|
|
34
|
+
main: "./src/index.js",
|
|
35
|
+
types: "./types/index.d.ts",
|
|
36
|
+
scripts: {
|
|
37
|
+
"test:types": "tsc -p tests/types/tsconfig.json"
|
|
38
|
+
},
|
|
39
|
+
files: [
|
|
40
|
+
"LICENSE",
|
|
41
|
+
"README.md",
|
|
42
|
+
"src",
|
|
43
|
+
"types"
|
|
44
|
+
],
|
|
45
|
+
publishConfig: {
|
|
46
|
+
access: "public"
|
|
47
|
+
},
|
|
48
|
+
repository: {
|
|
49
|
+
type: "git",
|
|
50
|
+
url: "https://github.com/eslint/eslint.git",
|
|
51
|
+
directory: "packages/js"
|
|
52
|
+
},
|
|
53
|
+
homepage: "https://eslint.org",
|
|
54
|
+
bugs: "https://github.com/eslint/eslint/issues/",
|
|
55
|
+
keywords: [
|
|
56
|
+
"javascript",
|
|
57
|
+
"eslint-plugin",
|
|
58
|
+
"eslint"
|
|
59
|
+
],
|
|
60
|
+
license: "MIT",
|
|
61
|
+
engines: {
|
|
62
|
+
node: "^18.18.0 || ^20.9.0 || >=21.1.0"
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// ../../node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/src/configs/eslint-all.js
|
|
28
69
|
var require_eslint_all = __commonJS({
|
|
29
|
-
"../../node_modules/.pnpm/@eslint+js@
|
|
70
|
+
"../../node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/src/configs/eslint-all.js"(exports, module) {
|
|
30
71
|
"use strict";
|
|
31
72
|
module.exports = Object.freeze({
|
|
32
73
|
"rules": {
|
|
@@ -58,7 +99,6 @@ var require_eslint_all = __commonJS({
|
|
|
58
99
|
"id-length": "error",
|
|
59
100
|
"id-match": "error",
|
|
60
101
|
"init-declarations": "error",
|
|
61
|
-
"line-comment-position": "error",
|
|
62
102
|
"logical-assignment-operators": "error",
|
|
63
103
|
"max-classes-per-file": "error",
|
|
64
104
|
"max-depth": "error",
|
|
@@ -67,7 +107,6 @@ var require_eslint_all = __commonJS({
|
|
|
67
107
|
"max-nested-callbacks": "error",
|
|
68
108
|
"max-params": "error",
|
|
69
109
|
"max-statements": "error",
|
|
70
|
-
"multiline-comment-style": "error",
|
|
71
110
|
"new-cap": "error",
|
|
72
111
|
"no-alert": "error",
|
|
73
112
|
"no-array-constructor": "error",
|
|
@@ -136,7 +175,6 @@ var require_eslint_all = __commonJS({
|
|
|
136
175
|
"no-new": "error",
|
|
137
176
|
"no-new-func": "error",
|
|
138
177
|
"no-new-native-nonconstructor": "error",
|
|
139
|
-
"no-new-symbol": "error",
|
|
140
178
|
"no-new-wrappers": "error",
|
|
141
179
|
"no-nonoctal-decimal-escape": "error",
|
|
142
180
|
"no-obj-calls": "error",
|
|
@@ -185,6 +223,7 @@ var require_eslint_all = __commonJS({
|
|
|
185
223
|
"no-unused-private-class-members": "error",
|
|
186
224
|
"no-unused-vars": "error",
|
|
187
225
|
"no-use-before-define": "error",
|
|
226
|
+
"no-useless-assignment": "error",
|
|
188
227
|
"no-useless-backreference": "error",
|
|
189
228
|
"no-useless-call": "error",
|
|
190
229
|
"no-useless-catch": "error",
|
|
@@ -234,9 +273,9 @@ var require_eslint_all = __commonJS({
|
|
|
234
273
|
}
|
|
235
274
|
});
|
|
236
275
|
|
|
237
|
-
// ../../node_modules/.pnpm/@eslint+js@
|
|
276
|
+
// ../../node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/src/configs/eslint-recommended.js
|
|
238
277
|
var require_eslint_recommended = __commonJS({
|
|
239
|
-
"../../node_modules/.pnpm/@eslint+js@
|
|
278
|
+
"../../node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/src/configs/eslint-recommended.js"(exports, module) {
|
|
240
279
|
"use strict";
|
|
241
280
|
module.exports = Object.freeze({
|
|
242
281
|
rules: Object.freeze({
|
|
@@ -249,6 +288,7 @@ var require_eslint_recommended = __commonJS({
|
|
|
249
288
|
"no-compare-neg-zero": "error",
|
|
250
289
|
"no-cond-assign": "error",
|
|
251
290
|
"no-const-assign": "error",
|
|
291
|
+
"no-constant-binary-expression": "error",
|
|
252
292
|
"no-constant-condition": "error",
|
|
253
293
|
"no-control-regex": "error",
|
|
254
294
|
"no-debugger": "error",
|
|
@@ -261,20 +301,18 @@ var require_eslint_recommended = __commonJS({
|
|
|
261
301
|
"no-empty": "error",
|
|
262
302
|
"no-empty-character-class": "error",
|
|
263
303
|
"no-empty-pattern": "error",
|
|
304
|
+
"no-empty-static-block": "error",
|
|
264
305
|
"no-ex-assign": "error",
|
|
265
306
|
"no-extra-boolean-cast": "error",
|
|
266
|
-
"no-extra-semi": "error",
|
|
267
307
|
"no-fallthrough": "error",
|
|
268
308
|
"no-func-assign": "error",
|
|
269
309
|
"no-global-assign": "error",
|
|
270
310
|
"no-import-assign": "error",
|
|
271
|
-
"no-inner-declarations": "error",
|
|
272
311
|
"no-invalid-regexp": "error",
|
|
273
312
|
"no-irregular-whitespace": "error",
|
|
274
313
|
"no-loss-of-precision": "error",
|
|
275
314
|
"no-misleading-character-class": "error",
|
|
276
|
-
"no-
|
|
277
|
-
"no-new-symbol": "error",
|
|
315
|
+
"no-new-native-nonconstructor": "error",
|
|
278
316
|
"no-nonoctal-decimal-escape": "error",
|
|
279
317
|
"no-obj-calls": "error",
|
|
280
318
|
"no-octal": "error",
|
|
@@ -293,6 +331,7 @@ var require_eslint_recommended = __commonJS({
|
|
|
293
331
|
"no-unsafe-negation": "error",
|
|
294
332
|
"no-unsafe-optional-chaining": "error",
|
|
295
333
|
"no-unused-labels": "error",
|
|
334
|
+
"no-unused-private-class-members": "error",
|
|
296
335
|
"no-unused-vars": "error",
|
|
297
336
|
"no-useless-backreference": "error",
|
|
298
337
|
"no-useless-catch": "error",
|
|
@@ -306,11 +345,16 @@ var require_eslint_recommended = __commonJS({
|
|
|
306
345
|
}
|
|
307
346
|
});
|
|
308
347
|
|
|
309
|
-
// ../../node_modules/.pnpm/@eslint+js@
|
|
348
|
+
// ../../node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/src/index.js
|
|
310
349
|
var require_src = __commonJS({
|
|
311
|
-
"../../node_modules/.pnpm/@eslint+js@
|
|
350
|
+
"../../node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/src/index.js"(exports, module) {
|
|
312
351
|
"use strict";
|
|
352
|
+
var { version } = require_package();
|
|
313
353
|
module.exports = {
|
|
354
|
+
meta: {
|
|
355
|
+
name: "@eslint/js",
|
|
356
|
+
version
|
|
357
|
+
},
|
|
314
358
|
configs: {
|
|
315
359
|
all: require_eslint_all(),
|
|
316
360
|
recommended: require_eslint_recommended()
|
|
@@ -324,18 +368,20 @@ import globals from "globals";
|
|
|
324
368
|
|
|
325
369
|
// src/libs.ts
|
|
326
370
|
var import_js = __toESM(require_src(), 1);
|
|
327
|
-
import { default as default3 } from "@
|
|
328
|
-
import { default as default4 } from "@typescript-eslint/
|
|
329
|
-
import { default as default5 } from "eslint
|
|
330
|
-
import { default as default6 } from "eslint-
|
|
331
|
-
import { default as default7 } from "eslint-plugin-
|
|
332
|
-
import { default as default8 } from "eslint-plugin-
|
|
333
|
-
import { default as default9 } from "eslint-plugin-
|
|
334
|
-
import { default as default10 } from "eslint-plugin-
|
|
335
|
-
import { default as default11 } from "eslint-plugin-
|
|
336
|
-
import { default as default12 } from "
|
|
337
|
-
import { default as default13 } from "
|
|
338
|
-
import { default as default14 } from "
|
|
371
|
+
import { default as default3 } from "@next/eslint-plugin-next";
|
|
372
|
+
import { default as default4 } from "@typescript-eslint/eslint-plugin";
|
|
373
|
+
import { default as default5 } from "@typescript-eslint/parser";
|
|
374
|
+
import { default as default6 } from "eslint-config-prettier";
|
|
375
|
+
import { default as default7 } from "eslint-plugin-jsonc";
|
|
376
|
+
import { default as default8 } from "eslint-plugin-perfectionist";
|
|
377
|
+
import { default as default9 } from "eslint-plugin-react";
|
|
378
|
+
import { default as default10 } from "eslint-plugin-react-hooks";
|
|
379
|
+
import { default as default11 } from "eslint-plugin-unused-imports";
|
|
380
|
+
import { default as default12 } from "eslint-plugin-vue";
|
|
381
|
+
import { default as default13 } from "eslint-plugin-yml";
|
|
382
|
+
import { default as default14 } from "jsonc-eslint-parser";
|
|
383
|
+
import { default as default15 } from "vue-eslint-parser";
|
|
384
|
+
import { default as default16 } from "yaml-eslint-parser";
|
|
339
385
|
|
|
340
386
|
// src/index.ts
|
|
341
387
|
function config(params = {}) {
|
|
@@ -362,8 +408,10 @@ function config(params = {}) {
|
|
|
362
408
|
"**/web/public",
|
|
363
409
|
"**/studio/build",
|
|
364
410
|
"**/studio/.sanity",
|
|
411
|
+
...params.next ? ["**/.next"] : [],
|
|
365
412
|
...params.ignores ? params.ignores : []
|
|
366
|
-
]
|
|
413
|
+
],
|
|
414
|
+
name: "lqbach/ignores"
|
|
367
415
|
};
|
|
368
416
|
const javascriptConfig = [
|
|
369
417
|
// Default
|
|
@@ -375,15 +423,15 @@ function config(params = {}) {
|
|
|
375
423
|
globals: {
|
|
376
424
|
...globals.browser,
|
|
377
425
|
...globals.node,
|
|
378
|
-
...globals.es6,
|
|
379
426
|
...globals.commonjs
|
|
380
427
|
},
|
|
381
428
|
parserOptions: {
|
|
382
429
|
sourceType: "module"
|
|
383
430
|
}
|
|
384
431
|
},
|
|
432
|
+
name: "lqbach/javascript",
|
|
385
433
|
plugins: {
|
|
386
|
-
"unused-imports":
|
|
434
|
+
"unused-imports": default11
|
|
387
435
|
},
|
|
388
436
|
rules: {
|
|
389
437
|
"unused-imports/no-unused-imports": "error",
|
|
@@ -402,19 +450,20 @@ function config(params = {}) {
|
|
|
402
450
|
const typescriptConfig = params.typescript ?? true ? {
|
|
403
451
|
files: ["**/*.{ts,tsx}"],
|
|
404
452
|
languageOptions: {
|
|
405
|
-
parser:
|
|
453
|
+
parser: default5,
|
|
406
454
|
parserOptions: {
|
|
407
455
|
sourceType: "module"
|
|
408
456
|
}
|
|
409
457
|
},
|
|
458
|
+
name: "lqbach/typescript",
|
|
410
459
|
plugins: {
|
|
411
|
-
"@typescript-eslint":
|
|
460
|
+
"@typescript-eslint": default4
|
|
412
461
|
},
|
|
413
462
|
rules: {
|
|
414
|
-
...
|
|
463
|
+
...default4.configs.recommended.rules
|
|
415
464
|
}
|
|
416
465
|
} : {};
|
|
417
|
-
const reactConfig = params.react ?? false ? {
|
|
466
|
+
const reactConfig = (params.next || params.react) ?? false ? {
|
|
418
467
|
files: ["**/*.{js,jsx,mjs,cjs,ts,tsx}"],
|
|
419
468
|
languageOptions: {
|
|
420
469
|
globals: {
|
|
@@ -427,82 +476,118 @@ function config(params = {}) {
|
|
|
427
476
|
}
|
|
428
477
|
}
|
|
429
478
|
},
|
|
479
|
+
name: "lqbach/react",
|
|
430
480
|
plugins: {
|
|
431
|
-
react:
|
|
481
|
+
react: default9
|
|
432
482
|
},
|
|
433
483
|
rules: {
|
|
434
|
-
...
|
|
484
|
+
...default9.configs.flat?.recommended.rules,
|
|
435
485
|
// ignore `css` for emotion usage
|
|
436
486
|
"react/no-unknown-property": ["error", { ignore: ["css"] }]
|
|
437
487
|
}
|
|
438
488
|
} : {};
|
|
489
|
+
const reactHooksConfig = (params.next || typeof params.react !== "boolean" && params.react?.hooks === true) ?? false ? {
|
|
490
|
+
files: ["**/*.{js,jsx,mjs,cjs,ts,tsx}"],
|
|
491
|
+
name: "lqbach/react-hooks",
|
|
492
|
+
plugins: {
|
|
493
|
+
"react-hooks": default10
|
|
494
|
+
},
|
|
495
|
+
rules: {
|
|
496
|
+
...default10.configs.recommended.rules
|
|
497
|
+
}
|
|
498
|
+
} : {};
|
|
439
499
|
const vueConfig = params.vue ?? false ? {
|
|
440
500
|
files: ["**/*.vue"],
|
|
441
501
|
languageOptions: {
|
|
442
|
-
parser:
|
|
502
|
+
parser: default15,
|
|
443
503
|
parserOptions: {
|
|
444
|
-
parser: params.typescript ?
|
|
504
|
+
parser: params.typescript ? default5 : null,
|
|
445
505
|
sourceType: "module"
|
|
446
506
|
}
|
|
447
507
|
},
|
|
508
|
+
name: "lqbach/vue",
|
|
509
|
+
plugins: {
|
|
510
|
+
vue: default12
|
|
511
|
+
},
|
|
512
|
+
processor: default12.processors[".vue"],
|
|
513
|
+
rules: {
|
|
514
|
+
...default12.configs["base"].rules,
|
|
515
|
+
...default12.configs["vue3-essential"].rules,
|
|
516
|
+
...default12.configs["vue3-strongly-recommended"].rules
|
|
517
|
+
}
|
|
518
|
+
} : {};
|
|
519
|
+
const nextConfig = params.next ?? false ? {
|
|
520
|
+
files: ["**/*.{js,jsx,ts,tsx}"],
|
|
521
|
+
name: "lqbach/next",
|
|
448
522
|
plugins: {
|
|
449
|
-
|
|
523
|
+
"@next/next": default3
|
|
450
524
|
},
|
|
451
|
-
processor: default10.processors[".vue"],
|
|
452
525
|
rules: {
|
|
453
|
-
...
|
|
454
|
-
...
|
|
455
|
-
|
|
526
|
+
...default3.configs.recommended.rules,
|
|
527
|
+
...default3.configs["core-web-vitals"].rules
|
|
528
|
+
},
|
|
529
|
+
...typeof params.next !== "boolean" && params.next?.rootDir && {
|
|
530
|
+
settings: {
|
|
531
|
+
nextjs: {
|
|
532
|
+
rootDir: params.next.rootDir
|
|
533
|
+
}
|
|
534
|
+
}
|
|
456
535
|
}
|
|
457
536
|
} : {};
|
|
458
537
|
const yamlConfig = params.yaml ?? true ? {
|
|
459
538
|
files: ["**/*.{yaml, yml}"],
|
|
460
539
|
languageOptions: {
|
|
461
|
-
parser:
|
|
540
|
+
parser: default16
|
|
462
541
|
},
|
|
542
|
+
name: "lqbach/yaml",
|
|
463
543
|
plugins: {
|
|
464
|
-
yml:
|
|
544
|
+
yml: default13
|
|
465
545
|
},
|
|
466
546
|
rules: {
|
|
467
|
-
...
|
|
468
|
-
...
|
|
547
|
+
...default13.configs["standard"].rules,
|
|
548
|
+
...default13.configs["prettier"].rules
|
|
469
549
|
}
|
|
470
550
|
} : {};
|
|
471
551
|
const jsoncConfig = params.json ?? true ? [
|
|
472
552
|
{
|
|
553
|
+
name: "lqbach/jsonc-plugin",
|
|
473
554
|
plugins: {
|
|
474
|
-
jsonc:
|
|
555
|
+
jsonc: default7
|
|
475
556
|
}
|
|
476
557
|
},
|
|
477
558
|
{
|
|
478
559
|
files: ["**/*.{json, json5, jsonc}"],
|
|
479
560
|
languageOptions: {
|
|
480
|
-
parser:
|
|
561
|
+
parser: default14
|
|
481
562
|
},
|
|
563
|
+
name: "lqbach/json",
|
|
482
564
|
rules: {
|
|
483
|
-
...
|
|
484
|
-
...
|
|
485
|
-
...
|
|
486
|
-
...
|
|
565
|
+
...default7.configs["recommended-with-json"].rules,
|
|
566
|
+
...default7.configs["recommended-with-jsonc"].rules,
|
|
567
|
+
...default7.configs["recommended-with-json5"].rules,
|
|
568
|
+
...default7.configs["prettier"].rules,
|
|
487
569
|
"jsonc/no-comments": "off"
|
|
488
570
|
}
|
|
489
571
|
}
|
|
490
572
|
] : [];
|
|
491
573
|
const perfectionistConfig = params.perfectionist ?? true ? {
|
|
574
|
+
name: "lqbach/perfectionist",
|
|
492
575
|
plugins: {
|
|
493
|
-
perfectionist:
|
|
576
|
+
perfectionist: default8
|
|
494
577
|
},
|
|
495
578
|
rules: {
|
|
496
|
-
...
|
|
579
|
+
...default8.configs["recommended-natural"].rules
|
|
497
580
|
}
|
|
498
581
|
} : {};
|
|
499
|
-
const prettierConfig =
|
|
582
|
+
const prettierConfig = default6;
|
|
500
583
|
let config2 = [];
|
|
501
584
|
config2.push(ignoresConfig);
|
|
502
585
|
config2.push(...javascriptConfig);
|
|
503
586
|
config2.push(typescriptConfig);
|
|
504
587
|
config2.push(reactConfig);
|
|
588
|
+
config2.push(reactHooksConfig);
|
|
505
589
|
config2.push(vueConfig);
|
|
590
|
+
config2.push(nextConfig);
|
|
506
591
|
config2.push(yamlConfig);
|
|
507
592
|
config2.push(...jsoncConfig);
|
|
508
593
|
config2.push(perfectionistConfig);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lqbach/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.7.0",
|
|
5
5
|
"description": "lqbach's Personal Eslint Config",
|
|
6
6
|
"private": false,
|
|
7
7
|
"license": "MIT",
|
|
@@ -18,24 +18,24 @@
|
|
|
18
18
|
"main": "./dist/index.js",
|
|
19
19
|
"types": "./dist/index.d.ts",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@
|
|
22
|
-
"@typescript-eslint/
|
|
23
|
-
"eslint
|
|
24
|
-
"eslint-
|
|
25
|
-
"eslint-plugin-
|
|
26
|
-
"eslint-plugin-
|
|
27
|
-
"eslint-plugin-
|
|
28
|
-
"eslint-plugin-
|
|
29
|
-
"eslint-plugin-
|
|
30
|
-
"
|
|
21
|
+
"@next/eslint-plugin-next": "^15.1.2",
|
|
22
|
+
"@typescript-eslint/eslint-plugin": "^8.18.0",
|
|
23
|
+
"@typescript-eslint/parser": "^8.18.0",
|
|
24
|
+
"eslint-config-prettier": "^9.1.0",
|
|
25
|
+
"eslint-plugin-jsonc": "^2.16.0",
|
|
26
|
+
"eslint-plugin-perfectionist": "^3.8.0",
|
|
27
|
+
"eslint-plugin-react": "^7.37.1",
|
|
28
|
+
"eslint-plugin-react-hooks": "^5.1.0",
|
|
29
|
+
"eslint-plugin-unused-imports": "^4.1.4",
|
|
30
|
+
"eslint-plugin-vue": "^9.28.0",
|
|
31
|
+
"eslint-plugin-yml": "^1.14.0",
|
|
32
|
+
"globals": "^15.0.0",
|
|
31
33
|
"jsonc-eslint-parser": "^2.4.0",
|
|
32
|
-
"remove": "^0.1.5",
|
|
33
|
-
"typescript": "^5.2.2",
|
|
34
34
|
"vue-eslint-parser": "^9.3.2",
|
|
35
35
|
"yaml-eslint-parser": "^1.2.2"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"eslint": "^
|
|
38
|
+
"eslint": "^9.11.0"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "tsup src/index.ts --format esm,cjs --clean --dts"
|
package/src/index.ts
CHANGED
|
@@ -8,8 +8,10 @@ import {
|
|
|
8
8
|
parserVue,
|
|
9
9
|
parserYaml,
|
|
10
10
|
pluginJsonc,
|
|
11
|
+
pluginNext,
|
|
11
12
|
pluginPerfectionist,
|
|
12
13
|
pluginReact,
|
|
14
|
+
pluginReactHooks,
|
|
13
15
|
pluginTypeScript,
|
|
14
16
|
pluginUnusedImports,
|
|
15
17
|
pluginVue,
|
|
@@ -45,8 +47,11 @@ export default function config(params: ConfigParams = {}): Array<ConfigObject> {
|
|
|
45
47
|
"**/web/public",
|
|
46
48
|
"**/studio/build",
|
|
47
49
|
"**/studio/.sanity",
|
|
50
|
+
|
|
51
|
+
...(params.next ? ["**/.next"] : []),
|
|
48
52
|
...(params.ignores ? params.ignores : []),
|
|
49
53
|
],
|
|
54
|
+
name: "lqbach/ignores",
|
|
50
55
|
}
|
|
51
56
|
|
|
52
57
|
//JavaScript Config
|
|
@@ -60,13 +65,13 @@ export default function config(params: ConfigParams = {}): Array<ConfigObject> {
|
|
|
60
65
|
globals: {
|
|
61
66
|
...globals.browser,
|
|
62
67
|
...globals.node,
|
|
63
|
-
...globals.es6,
|
|
64
68
|
...globals.commonjs,
|
|
65
69
|
},
|
|
66
70
|
parserOptions: {
|
|
67
71
|
sourceType: "module",
|
|
68
72
|
},
|
|
69
73
|
},
|
|
74
|
+
name: "lqbach/javascript",
|
|
70
75
|
plugins: {
|
|
71
76
|
"unused-imports": pluginUnusedImports,
|
|
72
77
|
},
|
|
@@ -87,7 +92,7 @@ export default function config(params: ConfigParams = {}): Array<ConfigObject> {
|
|
|
87
92
|
|
|
88
93
|
// TypeScript Config
|
|
89
94
|
const typescriptConfig: ConfigObject =
|
|
90
|
-
params.typescript ?? true
|
|
95
|
+
(params.typescript ?? true)
|
|
91
96
|
? {
|
|
92
97
|
files: ["**/*.{ts,tsx}"],
|
|
93
98
|
languageOptions: {
|
|
@@ -96,6 +101,7 @@ export default function config(params: ConfigParams = {}): Array<ConfigObject> {
|
|
|
96
101
|
sourceType: "module",
|
|
97
102
|
},
|
|
98
103
|
},
|
|
104
|
+
name: "lqbach/typescript",
|
|
99
105
|
plugins: {
|
|
100
106
|
"@typescript-eslint": pluginTypeScript,
|
|
101
107
|
},
|
|
@@ -107,7 +113,7 @@ export default function config(params: ConfigParams = {}): Array<ConfigObject> {
|
|
|
107
113
|
|
|
108
114
|
// React Config: turned off by default
|
|
109
115
|
const reactConfig: ConfigObject =
|
|
110
|
-
params.react ?? false
|
|
116
|
+
((params.next || params.react) ?? false)
|
|
111
117
|
? {
|
|
112
118
|
files: ["**/*.{js,jsx,mjs,cjs,ts,tsx}"],
|
|
113
119
|
languageOptions: {
|
|
@@ -121,20 +127,37 @@ export default function config(params: ConfigParams = {}): Array<ConfigObject> {
|
|
|
121
127
|
},
|
|
122
128
|
},
|
|
123
129
|
},
|
|
130
|
+
name: "lqbach/react",
|
|
124
131
|
plugins: {
|
|
125
132
|
react: pluginReact,
|
|
126
133
|
},
|
|
127
134
|
rules: {
|
|
128
|
-
...pluginReact.configs.recommended.rules,
|
|
135
|
+
...pluginReact.configs.flat?.recommended.rules,
|
|
129
136
|
// ignore `css` for emotion usage
|
|
130
137
|
"react/no-unknown-property": ["error", { ignore: ["css"] }],
|
|
131
138
|
},
|
|
132
139
|
}
|
|
133
140
|
: {}
|
|
134
141
|
|
|
142
|
+
const reactHooksConfig: ConfigObject =
|
|
143
|
+
((params.next ||
|
|
144
|
+
(typeof params.react !== "boolean" && params.react?.hooks === true)) ??
|
|
145
|
+
false)
|
|
146
|
+
? {
|
|
147
|
+
files: ["**/*.{js,jsx,mjs,cjs,ts,tsx}"],
|
|
148
|
+
name: "lqbach/react-hooks",
|
|
149
|
+
plugins: {
|
|
150
|
+
"react-hooks": pluginReactHooks,
|
|
151
|
+
},
|
|
152
|
+
rules: {
|
|
153
|
+
...pluginReactHooks.configs.recommended.rules,
|
|
154
|
+
},
|
|
155
|
+
}
|
|
156
|
+
: {}
|
|
157
|
+
|
|
135
158
|
// Vue Config: turned off by default
|
|
136
159
|
const vueConfig: ConfigObject =
|
|
137
|
-
params.vue ?? false
|
|
160
|
+
(params.vue ?? false)
|
|
138
161
|
? {
|
|
139
162
|
files: ["**/*.vue"],
|
|
140
163
|
languageOptions: {
|
|
@@ -144,6 +167,7 @@ export default function config(params: ConfigParams = {}): Array<ConfigObject> {
|
|
|
144
167
|
sourceType: "module",
|
|
145
168
|
},
|
|
146
169
|
},
|
|
170
|
+
name: "lqbach/vue",
|
|
147
171
|
plugins: {
|
|
148
172
|
vue: pluginVue,
|
|
149
173
|
},
|
|
@@ -156,14 +180,39 @@ export default function config(params: ConfigParams = {}): Array<ConfigObject> {
|
|
|
156
180
|
}
|
|
157
181
|
: {}
|
|
158
182
|
|
|
183
|
+
// NextJS Config
|
|
184
|
+
const nextConfig: ConfigObject =
|
|
185
|
+
(params.next ?? false)
|
|
186
|
+
? {
|
|
187
|
+
files: ["**/*.{js,jsx,ts,tsx}"],
|
|
188
|
+
name: "lqbach/next",
|
|
189
|
+
plugins: {
|
|
190
|
+
"@next/next": pluginNext,
|
|
191
|
+
},
|
|
192
|
+
rules: {
|
|
193
|
+
...pluginNext.configs.recommended.rules,
|
|
194
|
+
...pluginNext.configs["core-web-vitals"].rules,
|
|
195
|
+
},
|
|
196
|
+
...(typeof params.next !== "boolean" &&
|
|
197
|
+
params.next?.rootDir && {
|
|
198
|
+
settings: {
|
|
199
|
+
nextjs: {
|
|
200
|
+
rootDir: params.next.rootDir,
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
}),
|
|
204
|
+
}
|
|
205
|
+
: {}
|
|
206
|
+
|
|
159
207
|
// YAML Config
|
|
160
208
|
const yamlConfig: ConfigObject =
|
|
161
|
-
params.yaml ?? true
|
|
209
|
+
(params.yaml ?? true)
|
|
162
210
|
? {
|
|
163
211
|
files: ["**/*.{yaml, yml}"],
|
|
164
212
|
languageOptions: {
|
|
165
213
|
parser: parserYaml,
|
|
166
214
|
},
|
|
215
|
+
name: "lqbach/yaml",
|
|
167
216
|
plugins: {
|
|
168
217
|
yml: pluginYaml,
|
|
169
218
|
},
|
|
@@ -176,9 +225,10 @@ export default function config(params: ConfigParams = {}): Array<ConfigObject> {
|
|
|
176
225
|
|
|
177
226
|
// JSONC Config
|
|
178
227
|
const jsoncConfig: Array<ConfigObject> =
|
|
179
|
-
params.json ?? true
|
|
228
|
+
(params.json ?? true)
|
|
180
229
|
? [
|
|
181
230
|
{
|
|
231
|
+
name: "lqbach/jsonc-plugin",
|
|
182
232
|
plugins: {
|
|
183
233
|
jsonc: pluginJsonc,
|
|
184
234
|
},
|
|
@@ -188,6 +238,7 @@ export default function config(params: ConfigParams = {}): Array<ConfigObject> {
|
|
|
188
238
|
languageOptions: {
|
|
189
239
|
parser: parserJsonc,
|
|
190
240
|
},
|
|
241
|
+
name: "lqbach/json",
|
|
191
242
|
rules: {
|
|
192
243
|
...pluginJsonc.configs["recommended-with-json"].rules,
|
|
193
244
|
...pluginJsonc.configs["recommended-with-jsonc"].rules,
|
|
@@ -201,8 +252,9 @@ export default function config(params: ConfigParams = {}): Array<ConfigObject> {
|
|
|
201
252
|
|
|
202
253
|
// Perfectionist Config
|
|
203
254
|
const perfectionistConfig: ConfigObject =
|
|
204
|
-
params.perfectionist ?? true
|
|
255
|
+
(params.perfectionist ?? true)
|
|
205
256
|
? {
|
|
257
|
+
name: "lqbach/perfectionist",
|
|
206
258
|
plugins: {
|
|
207
259
|
perfectionist: pluginPerfectionist,
|
|
208
260
|
},
|
|
@@ -219,7 +271,9 @@ export default function config(params: ConfigParams = {}): Array<ConfigObject> {
|
|
|
219
271
|
config.push(...javascriptConfig)
|
|
220
272
|
config.push(typescriptConfig)
|
|
221
273
|
config.push(reactConfig)
|
|
274
|
+
config.push(reactHooksConfig)
|
|
222
275
|
config.push(vueConfig)
|
|
276
|
+
config.push(nextConfig)
|
|
223
277
|
config.push(yamlConfig)
|
|
224
278
|
config.push(...jsoncConfig)
|
|
225
279
|
config.push(perfectionistConfig)
|
package/src/libs.ts
CHANGED
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
|
|
5
5
|
export { default as jsConfig } from "@eslint/js"
|
|
6
|
+
export { default as pluginNext } from "@next/eslint-plugin-next"
|
|
6
7
|
export { default as pluginTypeScript } from "@typescript-eslint/eslint-plugin"
|
|
7
8
|
export { default as parserTypeScript } from "@typescript-eslint/parser"
|
|
8
9
|
export { default as configPrettier } from "eslint-config-prettier"
|
|
9
10
|
export { default as pluginJsonc } from "eslint-plugin-jsonc"
|
|
10
11
|
export { default as pluginPerfectionist } from "eslint-plugin-perfectionist"
|
|
11
12
|
export { default as pluginReact } from "eslint-plugin-react"
|
|
12
|
-
|
|
13
|
+
export { default as pluginReactHooks } from "eslint-plugin-react-hooks"
|
|
13
14
|
export { default as pluginUnusedImports } from "eslint-plugin-unused-imports"
|
|
14
15
|
export { default as pluginVue } from "eslint-plugin-vue"
|
|
15
16
|
export { default as pluginYaml } from "eslint-plugin-yml"
|
package/src/types.ts
CHANGED
|
@@ -2,15 +2,16 @@ export interface ConfigParams {
|
|
|
2
2
|
ignores?: Array<string>
|
|
3
3
|
json?: boolean
|
|
4
4
|
markdown?: boolean
|
|
5
|
+
next?: boolean | NextJSConfigParams
|
|
5
6
|
perfectionist?: boolean
|
|
6
|
-
react?: boolean
|
|
7
|
+
react?: boolean | ReactJSConfigParams
|
|
7
8
|
typescript?: boolean
|
|
8
9
|
vue?: boolean
|
|
9
10
|
yaml?: boolean
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
export interface LanguageOptions {
|
|
13
|
-
ecmaVersion?: string
|
|
14
|
+
ecmaVersion?: number | string
|
|
14
15
|
globals?: object
|
|
15
16
|
parser?: object
|
|
16
17
|
parserOptions?: object
|
|
@@ -27,8 +28,21 @@ export interface ConfigObject {
|
|
|
27
28
|
ignores?: Array<string>
|
|
28
29
|
languageOptions?: LanguageOptions
|
|
29
30
|
linterOptions?: LinterOptions
|
|
31
|
+
name?: string
|
|
30
32
|
plugins?: object
|
|
31
33
|
processor?: object
|
|
32
34
|
rules?: object
|
|
33
|
-
|
|
35
|
+
// eslint-disable-next-line
|
|
36
|
+
settings?: any
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface NextJSConfigParams {
|
|
40
|
+
rootDir?: string
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface ReactJSConfigParams {
|
|
44
|
+
/**
|
|
45
|
+
* use react hooks
|
|
46
|
+
*/
|
|
47
|
+
hooks?: boolean
|
|
34
48
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest"
|
|
2
|
+
|
|
3
|
+
import eslintConfig from "../src"
|
|
4
|
+
|
|
5
|
+
// test tailwind configuration
|
|
6
|
+
describe("test ignore list in eslint configuration", () => {
|
|
7
|
+
describe("if ignores array is populated", () => {
|
|
8
|
+
const IGNORE_FILE_NAME = "**/.ignorethisfile"
|
|
9
|
+
|
|
10
|
+
const IGNORE_LOCK_FILES = [
|
|
11
|
+
"**/package-lock.json",
|
|
12
|
+
"**/yarn.lock",
|
|
13
|
+
"**/pnpm-lock.yaml",
|
|
14
|
+
"**/bun.lockb",
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
const config = eslintConfig({ ignores: [IGNORE_FILE_NAME] })
|
|
18
|
+
|
|
19
|
+
test("should include the ignored file name in an `ignores` object", () => {
|
|
20
|
+
expect(
|
|
21
|
+
config.some((obj) => obj.ignores?.includes(IGNORE_FILE_NAME)),
|
|
22
|
+
).toBe(true)
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
test("edge case test for random files", () => {
|
|
26
|
+
expect(config.some((obj) => obj.ignores?.includes("fakefile"))).toBe(
|
|
27
|
+
false,
|
|
28
|
+
)
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
test("test lock files are included", () => {
|
|
32
|
+
expect(
|
|
33
|
+
IGNORE_LOCK_FILES.every((lock) =>
|
|
34
|
+
config.some((obj) => obj.ignores?.includes(lock)),
|
|
35
|
+
),
|
|
36
|
+
).toBe(true)
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
})
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest"
|
|
2
|
+
|
|
3
|
+
import eslintConfig from "../src"
|
|
4
|
+
import { getConfigObjectByName } from "./utils"
|
|
5
|
+
|
|
6
|
+
const NEXT_CONFIG_OBJECT_NAME = "lqbach/next"
|
|
7
|
+
|
|
8
|
+
// test tailwind configuration
|
|
9
|
+
describe("test nextjs eslint configuration", () => {
|
|
10
|
+
describe("if next parameter is not true", () => {
|
|
11
|
+
const config = eslintConfig({ next: false })
|
|
12
|
+
|
|
13
|
+
test("should not include the ignored folder **/.next in the `ignores` object", () => {
|
|
14
|
+
expect(config.some((obj) => obj.ignores?.includes("**/.next"))).toBe(true)
|
|
15
|
+
})
|
|
16
|
+
test("should not have a configuration object lqbach/next", () => {
|
|
17
|
+
expect(getConfigObjectByName(NEXT_CONFIG_OBJECT_NAME, config)).toBe(
|
|
18
|
+
undefined,
|
|
19
|
+
)
|
|
20
|
+
})
|
|
21
|
+
})
|
|
22
|
+
describe("if next parameter is true", () => {
|
|
23
|
+
const config = eslintConfig({ next: true })
|
|
24
|
+
|
|
25
|
+
test("should include react config", () => {
|
|
26
|
+
expect(getConfigObjectByName("lqbach/react", config)).toBeTruthy()
|
|
27
|
+
})
|
|
28
|
+
test("should include react hooks config", () => {
|
|
29
|
+
expect(getConfigObjectByName("lqbach/react-hooks", config)).toBeTruthy()
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
test("should include the ignored folder **/.next in the `ignores` object", () => {
|
|
33
|
+
expect(
|
|
34
|
+
getConfigObjectByName("lqbach/ignores", config)?.ignores?.includes(
|
|
35
|
+
"**/.next",
|
|
36
|
+
),
|
|
37
|
+
).toBe(true)
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
describe("if next parameter is a config object", () => {
|
|
41
|
+
test("should include react config", () => {
|
|
42
|
+
const config = eslintConfig({ next: { rootDir: "packages/example" } })
|
|
43
|
+
expect(getConfigObjectByName("lqbach/react", config)).toBeTruthy()
|
|
44
|
+
})
|
|
45
|
+
test("should include react hooks config", () => {
|
|
46
|
+
const config = eslintConfig({ next: { rootDir: "packages/example" } })
|
|
47
|
+
expect(getConfigObjectByName("lqbach/react-hooks", config)).toBeTruthy()
|
|
48
|
+
})
|
|
49
|
+
test("should parse rootDir properly", () => {
|
|
50
|
+
const config = eslintConfig({ next: { rootDir: "packages/example" } })
|
|
51
|
+
expect(
|
|
52
|
+
getConfigObjectByName("lqbach/next", config)?.settings?.nextjs?.rootDir,
|
|
53
|
+
).toEqual("packages/example")
|
|
54
|
+
})
|
|
55
|
+
})
|
|
56
|
+
})
|
package/test/utils.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ConfigObject } from "../src/types"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param name A name for the configuration object. Use naming convention recommended by ESLint (https://eslint.org/docs/latest/use/configure/configuration-files#configuration-naming-conventions)
|
|
6
|
+
* @param config ESLint config
|
|
7
|
+
* @returns config object based on the configuration object name
|
|
8
|
+
*/
|
|
9
|
+
export const getConfigObjectByName = (
|
|
10
|
+
name: string,
|
|
11
|
+
config: Array<ConfigObject>,
|
|
12
|
+
) => {
|
|
13
|
+
return config.find((configObj) => {
|
|
14
|
+
return configObj.name === name
|
|
15
|
+
})
|
|
16
|
+
}
|