@lqbach/eslint-config 0.6.1 โ 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 +25 -0
- package/README.md +19 -0
- package/dist/index.cjs +100 -12
- package/dist/index.d.cts +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.js +134 -46
- package/package.json +5 -4
- package/src/index.ts +62 -7
- 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,30 @@
|
|
|
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
|
+
|
|
3
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)
|
|
4
29
|
|
|
5
30
|
|
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@9.
|
|
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@9.
|
|
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": {
|
|
@@ -238,9 +279,9 @@ var require_eslint_all = __commonJS({
|
|
|
238
279
|
}
|
|
239
280
|
});
|
|
240
281
|
|
|
241
|
-
// ../../node_modules/.pnpm/@eslint+js@9.
|
|
282
|
+
// ../../node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/src/configs/eslint-recommended.js
|
|
242
283
|
var require_eslint_recommended = __commonJS({
|
|
243
|
-
"../../node_modules/.pnpm/@eslint+js@9.
|
|
284
|
+
"../../node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/src/configs/eslint-recommended.js"(exports2, module2) {
|
|
244
285
|
"use strict";
|
|
245
286
|
module2.exports = Object.freeze({
|
|
246
287
|
rules: Object.freeze({
|
|
@@ -310,11 +351,16 @@ var require_eslint_recommended = __commonJS({
|
|
|
310
351
|
}
|
|
311
352
|
});
|
|
312
353
|
|
|
313
|
-
// ../../node_modules/.pnpm/@eslint+js@9.
|
|
354
|
+
// ../../node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/src/index.js
|
|
314
355
|
var require_src = __commonJS({
|
|
315
|
-
"../../node_modules/.pnpm/@eslint+js@9.
|
|
356
|
+
"../../node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/src/index.js"(exports2, module2) {
|
|
316
357
|
"use strict";
|
|
358
|
+
var { version } = require_package();
|
|
317
359
|
module2.exports = {
|
|
360
|
+
meta: {
|
|
361
|
+
name: "@eslint/js",
|
|
362
|
+
version
|
|
363
|
+
},
|
|
318
364
|
configs: {
|
|
319
365
|
all: require_eslint_all(),
|
|
320
366
|
recommended: require_eslint_recommended()
|
|
@@ -324,21 +370,23 @@ var require_src = __commonJS({
|
|
|
324
370
|
});
|
|
325
371
|
|
|
326
372
|
// src/index.ts
|
|
327
|
-
var
|
|
328
|
-
__export(
|
|
373
|
+
var index_exports = {};
|
|
374
|
+
__export(index_exports, {
|
|
329
375
|
default: () => config
|
|
330
376
|
});
|
|
331
|
-
module.exports = __toCommonJS(
|
|
377
|
+
module.exports = __toCommonJS(index_exports);
|
|
332
378
|
var import_globals = __toESM(require("globals"), 1);
|
|
333
379
|
|
|
334
380
|
// src/libs.ts
|
|
335
381
|
var import_js = __toESM(require_src(), 1);
|
|
382
|
+
var import_eslint_plugin_next = __toESM(require("@next/eslint-plugin-next"), 1);
|
|
336
383
|
var import_eslint_plugin = __toESM(require("@typescript-eslint/eslint-plugin"), 1);
|
|
337
384
|
var import_parser = __toESM(require("@typescript-eslint/parser"), 1);
|
|
338
385
|
var import_eslint_config_prettier = __toESM(require("eslint-config-prettier"), 1);
|
|
339
386
|
var import_eslint_plugin_jsonc = __toESM(require("eslint-plugin-jsonc"), 1);
|
|
340
387
|
var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"), 1);
|
|
341
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);
|
|
342
390
|
var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"), 1);
|
|
343
391
|
var import_eslint_plugin_vue = __toESM(require("eslint-plugin-vue"), 1);
|
|
344
392
|
var import_eslint_plugin_yml = __toESM(require("eslint-plugin-yml"), 1);
|
|
@@ -371,8 +419,10 @@ function config(params = {}) {
|
|
|
371
419
|
"**/web/public",
|
|
372
420
|
"**/studio/build",
|
|
373
421
|
"**/studio/.sanity",
|
|
422
|
+
...params.next ? ["**/.next"] : [],
|
|
374
423
|
...params.ignores ? params.ignores : []
|
|
375
|
-
]
|
|
424
|
+
],
|
|
425
|
+
name: "lqbach/ignores"
|
|
376
426
|
};
|
|
377
427
|
const javascriptConfig = [
|
|
378
428
|
// Default
|
|
@@ -390,6 +440,7 @@ function config(params = {}) {
|
|
|
390
440
|
sourceType: "module"
|
|
391
441
|
}
|
|
392
442
|
},
|
|
443
|
+
name: "lqbach/javascript",
|
|
393
444
|
plugins: {
|
|
394
445
|
"unused-imports": import_eslint_plugin_unused_imports.default
|
|
395
446
|
},
|
|
@@ -415,6 +466,7 @@ function config(params = {}) {
|
|
|
415
466
|
sourceType: "module"
|
|
416
467
|
}
|
|
417
468
|
},
|
|
469
|
+
name: "lqbach/typescript",
|
|
418
470
|
plugins: {
|
|
419
471
|
"@typescript-eslint": import_eslint_plugin.default
|
|
420
472
|
},
|
|
@@ -422,7 +474,7 @@ function config(params = {}) {
|
|
|
422
474
|
...import_eslint_plugin.default.configs.recommended.rules
|
|
423
475
|
}
|
|
424
476
|
} : {};
|
|
425
|
-
const reactConfig = params.react ?? false ? {
|
|
477
|
+
const reactConfig = (params.next || params.react) ?? false ? {
|
|
426
478
|
files: ["**/*.{js,jsx,mjs,cjs,ts,tsx}"],
|
|
427
479
|
languageOptions: {
|
|
428
480
|
globals: {
|
|
@@ -435,15 +487,26 @@ function config(params = {}) {
|
|
|
435
487
|
}
|
|
436
488
|
}
|
|
437
489
|
},
|
|
490
|
+
name: "lqbach/react",
|
|
438
491
|
plugins: {
|
|
439
492
|
react: import_eslint_plugin_react.default
|
|
440
493
|
},
|
|
441
494
|
rules: {
|
|
442
|
-
...import_eslint_plugin_react.default.configs.flat
|
|
495
|
+
...import_eslint_plugin_react.default.configs.flat?.recommended.rules,
|
|
443
496
|
// ignore `css` for emotion usage
|
|
444
497
|
"react/no-unknown-property": ["error", { ignore: ["css"] }]
|
|
445
498
|
}
|
|
446
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
|
+
} : {};
|
|
447
510
|
const vueConfig = params.vue ?? false ? {
|
|
448
511
|
files: ["**/*.vue"],
|
|
449
512
|
languageOptions: {
|
|
@@ -453,6 +516,7 @@ function config(params = {}) {
|
|
|
453
516
|
sourceType: "module"
|
|
454
517
|
}
|
|
455
518
|
},
|
|
519
|
+
name: "lqbach/vue",
|
|
456
520
|
plugins: {
|
|
457
521
|
vue: import_eslint_plugin_vue.default
|
|
458
522
|
},
|
|
@@ -463,11 +527,30 @@ function config(params = {}) {
|
|
|
463
527
|
...import_eslint_plugin_vue.default.configs["vue3-strongly-recommended"].rules
|
|
464
528
|
}
|
|
465
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
|
+
} : {};
|
|
466
548
|
const yamlConfig = params.yaml ?? true ? {
|
|
467
549
|
files: ["**/*.{yaml, yml}"],
|
|
468
550
|
languageOptions: {
|
|
469
551
|
parser: import_yaml_eslint_parser.default
|
|
470
552
|
},
|
|
553
|
+
name: "lqbach/yaml",
|
|
471
554
|
plugins: {
|
|
472
555
|
yml: import_eslint_plugin_yml.default
|
|
473
556
|
},
|
|
@@ -478,6 +561,7 @@ function config(params = {}) {
|
|
|
478
561
|
} : {};
|
|
479
562
|
const jsoncConfig = params.json ?? true ? [
|
|
480
563
|
{
|
|
564
|
+
name: "lqbach/jsonc-plugin",
|
|
481
565
|
plugins: {
|
|
482
566
|
jsonc: import_eslint_plugin_jsonc.default
|
|
483
567
|
}
|
|
@@ -487,6 +571,7 @@ function config(params = {}) {
|
|
|
487
571
|
languageOptions: {
|
|
488
572
|
parser: import_jsonc_eslint_parser.default
|
|
489
573
|
},
|
|
574
|
+
name: "lqbach/json",
|
|
490
575
|
rules: {
|
|
491
576
|
...import_eslint_plugin_jsonc.default.configs["recommended-with-json"].rules,
|
|
492
577
|
...import_eslint_plugin_jsonc.default.configs["recommended-with-jsonc"].rules,
|
|
@@ -497,6 +582,7 @@ function config(params = {}) {
|
|
|
497
582
|
}
|
|
498
583
|
] : [];
|
|
499
584
|
const perfectionistConfig = params.perfectionist ?? true ? {
|
|
585
|
+
name: "lqbach/perfectionist",
|
|
500
586
|
plugins: {
|
|
501
587
|
perfectionist: import_eslint_plugin_perfectionist.default
|
|
502
588
|
},
|
|
@@ -510,7 +596,9 @@ function config(params = {}) {
|
|
|
510
596
|
config2.push(...javascriptConfig);
|
|
511
597
|
config2.push(typescriptConfig);
|
|
512
598
|
config2.push(reactConfig);
|
|
599
|
+
config2.push(reactHooksConfig);
|
|
513
600
|
config2.push(vueConfig);
|
|
601
|
+
config2.push(nextConfig);
|
|
514
602
|
config2.push(yamlConfig);
|
|
515
603
|
config2.push(...jsoncConfig);
|
|
516
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@9.
|
|
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@9.
|
|
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": {
|
|
@@ -232,9 +273,9 @@ var require_eslint_all = __commonJS({
|
|
|
232
273
|
}
|
|
233
274
|
});
|
|
234
275
|
|
|
235
|
-
// ../../node_modules/.pnpm/@eslint+js@9.
|
|
276
|
+
// ../../node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/src/configs/eslint-recommended.js
|
|
236
277
|
var require_eslint_recommended = __commonJS({
|
|
237
|
-
"../../node_modules/.pnpm/@eslint+js@9.
|
|
278
|
+
"../../node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/src/configs/eslint-recommended.js"(exports, module) {
|
|
238
279
|
"use strict";
|
|
239
280
|
module.exports = Object.freeze({
|
|
240
281
|
rules: Object.freeze({
|
|
@@ -304,11 +345,16 @@ var require_eslint_recommended = __commonJS({
|
|
|
304
345
|
}
|
|
305
346
|
});
|
|
306
347
|
|
|
307
|
-
// ../../node_modules/.pnpm/@eslint+js@9.
|
|
348
|
+
// ../../node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/src/index.js
|
|
308
349
|
var require_src = __commonJS({
|
|
309
|
-
"../../node_modules/.pnpm/@eslint+js@9.
|
|
350
|
+
"../../node_modules/.pnpm/@eslint+js@9.17.0/node_modules/@eslint/js/src/index.js"(exports, module) {
|
|
310
351
|
"use strict";
|
|
352
|
+
var { version } = require_package();
|
|
311
353
|
module.exports = {
|
|
354
|
+
meta: {
|
|
355
|
+
name: "@eslint/js",
|
|
356
|
+
version
|
|
357
|
+
},
|
|
312
358
|
configs: {
|
|
313
359
|
all: require_eslint_all(),
|
|
314
360
|
recommended: require_eslint_recommended()
|
|
@@ -322,18 +368,20 @@ import globals from "globals";
|
|
|
322
368
|
|
|
323
369
|
// src/libs.ts
|
|
324
370
|
var import_js = __toESM(require_src(), 1);
|
|
325
|
-
import { default as default3 } from "@
|
|
326
|
-
import { default as default4 } from "@typescript-eslint/
|
|
327
|
-
import { default as default5 } from "eslint
|
|
328
|
-
import { default as default6 } from "eslint-
|
|
329
|
-
import { default as default7 } from "eslint-plugin-
|
|
330
|
-
import { default as default8 } from "eslint-plugin-
|
|
331
|
-
import { default as default9 } from "eslint-plugin-
|
|
332
|
-
import { default as default10 } from "eslint-plugin-
|
|
333
|
-
import { default as default11 } from "eslint-plugin-
|
|
334
|
-
import { default as default12 } from "
|
|
335
|
-
import { default as default13 } from "
|
|
336
|
-
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";
|
|
337
385
|
|
|
338
386
|
// src/index.ts
|
|
339
387
|
function config(params = {}) {
|
|
@@ -360,8 +408,10 @@ function config(params = {}) {
|
|
|
360
408
|
"**/web/public",
|
|
361
409
|
"**/studio/build",
|
|
362
410
|
"**/studio/.sanity",
|
|
411
|
+
...params.next ? ["**/.next"] : [],
|
|
363
412
|
...params.ignores ? params.ignores : []
|
|
364
|
-
]
|
|
413
|
+
],
|
|
414
|
+
name: "lqbach/ignores"
|
|
365
415
|
};
|
|
366
416
|
const javascriptConfig = [
|
|
367
417
|
// Default
|
|
@@ -379,8 +429,9 @@ function config(params = {}) {
|
|
|
379
429
|
sourceType: "module"
|
|
380
430
|
}
|
|
381
431
|
},
|
|
432
|
+
name: "lqbach/javascript",
|
|
382
433
|
plugins: {
|
|
383
|
-
"unused-imports":
|
|
434
|
+
"unused-imports": default11
|
|
384
435
|
},
|
|
385
436
|
rules: {
|
|
386
437
|
"unused-imports/no-unused-imports": "error",
|
|
@@ -399,19 +450,20 @@ function config(params = {}) {
|
|
|
399
450
|
const typescriptConfig = params.typescript ?? true ? {
|
|
400
451
|
files: ["**/*.{ts,tsx}"],
|
|
401
452
|
languageOptions: {
|
|
402
|
-
parser:
|
|
453
|
+
parser: default5,
|
|
403
454
|
parserOptions: {
|
|
404
455
|
sourceType: "module"
|
|
405
456
|
}
|
|
406
457
|
},
|
|
458
|
+
name: "lqbach/typescript",
|
|
407
459
|
plugins: {
|
|
408
|
-
"@typescript-eslint":
|
|
460
|
+
"@typescript-eslint": default4
|
|
409
461
|
},
|
|
410
462
|
rules: {
|
|
411
|
-
...
|
|
463
|
+
...default4.configs.recommended.rules
|
|
412
464
|
}
|
|
413
465
|
} : {};
|
|
414
|
-
const reactConfig = params.react ?? false ? {
|
|
466
|
+
const reactConfig = (params.next || params.react) ?? false ? {
|
|
415
467
|
files: ["**/*.{js,jsx,mjs,cjs,ts,tsx}"],
|
|
416
468
|
languageOptions: {
|
|
417
469
|
globals: {
|
|
@@ -424,82 +476,118 @@ function config(params = {}) {
|
|
|
424
476
|
}
|
|
425
477
|
}
|
|
426
478
|
},
|
|
479
|
+
name: "lqbach/react",
|
|
427
480
|
plugins: {
|
|
428
|
-
react:
|
|
481
|
+
react: default9
|
|
429
482
|
},
|
|
430
483
|
rules: {
|
|
431
|
-
...
|
|
484
|
+
...default9.configs.flat?.recommended.rules,
|
|
432
485
|
// ignore `css` for emotion usage
|
|
433
486
|
"react/no-unknown-property": ["error", { ignore: ["css"] }]
|
|
434
487
|
}
|
|
435
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
|
+
} : {};
|
|
436
499
|
const vueConfig = params.vue ?? false ? {
|
|
437
500
|
files: ["**/*.vue"],
|
|
438
501
|
languageOptions: {
|
|
439
|
-
parser:
|
|
502
|
+
parser: default15,
|
|
440
503
|
parserOptions: {
|
|
441
|
-
parser: params.typescript ?
|
|
504
|
+
parser: params.typescript ? default5 : null,
|
|
442
505
|
sourceType: "module"
|
|
443
506
|
}
|
|
444
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",
|
|
445
522
|
plugins: {
|
|
446
|
-
|
|
523
|
+
"@next/next": default3
|
|
447
524
|
},
|
|
448
|
-
processor: default10.processors[".vue"],
|
|
449
525
|
rules: {
|
|
450
|
-
...
|
|
451
|
-
...
|
|
452
|
-
|
|
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
|
+
}
|
|
453
535
|
}
|
|
454
536
|
} : {};
|
|
455
537
|
const yamlConfig = params.yaml ?? true ? {
|
|
456
538
|
files: ["**/*.{yaml, yml}"],
|
|
457
539
|
languageOptions: {
|
|
458
|
-
parser:
|
|
540
|
+
parser: default16
|
|
459
541
|
},
|
|
542
|
+
name: "lqbach/yaml",
|
|
460
543
|
plugins: {
|
|
461
|
-
yml:
|
|
544
|
+
yml: default13
|
|
462
545
|
},
|
|
463
546
|
rules: {
|
|
464
|
-
...
|
|
465
|
-
...
|
|
547
|
+
...default13.configs["standard"].rules,
|
|
548
|
+
...default13.configs["prettier"].rules
|
|
466
549
|
}
|
|
467
550
|
} : {};
|
|
468
551
|
const jsoncConfig = params.json ?? true ? [
|
|
469
552
|
{
|
|
553
|
+
name: "lqbach/jsonc-plugin",
|
|
470
554
|
plugins: {
|
|
471
|
-
jsonc:
|
|
555
|
+
jsonc: default7
|
|
472
556
|
}
|
|
473
557
|
},
|
|
474
558
|
{
|
|
475
559
|
files: ["**/*.{json, json5, jsonc}"],
|
|
476
560
|
languageOptions: {
|
|
477
|
-
parser:
|
|
561
|
+
parser: default14
|
|
478
562
|
},
|
|
563
|
+
name: "lqbach/json",
|
|
479
564
|
rules: {
|
|
480
|
-
...
|
|
481
|
-
...
|
|
482
|
-
...
|
|
483
|
-
...
|
|
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,
|
|
484
569
|
"jsonc/no-comments": "off"
|
|
485
570
|
}
|
|
486
571
|
}
|
|
487
572
|
] : [];
|
|
488
573
|
const perfectionistConfig = params.perfectionist ?? true ? {
|
|
574
|
+
name: "lqbach/perfectionist",
|
|
489
575
|
plugins: {
|
|
490
|
-
perfectionist:
|
|
576
|
+
perfectionist: default8
|
|
491
577
|
},
|
|
492
578
|
rules: {
|
|
493
|
-
...
|
|
579
|
+
...default8.configs["recommended-natural"].rules
|
|
494
580
|
}
|
|
495
581
|
} : {};
|
|
496
|
-
const prettierConfig =
|
|
582
|
+
const prettierConfig = default6;
|
|
497
583
|
let config2 = [];
|
|
498
584
|
config2.push(ignoresConfig);
|
|
499
585
|
config2.push(...javascriptConfig);
|
|
500
586
|
config2.push(typescriptConfig);
|
|
501
587
|
config2.push(reactConfig);
|
|
588
|
+
config2.push(reactHooksConfig);
|
|
502
589
|
config2.push(vueConfig);
|
|
590
|
+
config2.push(nextConfig);
|
|
503
591
|
config2.push(yamlConfig);
|
|
504
592
|
config2.push(...jsoncConfig);
|
|
505
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,18 +18,19 @@
|
|
|
18
18
|
"main": "./dist/index.js",
|
|
19
19
|
"types": "./dist/index.d.ts",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@
|
|
22
|
-
"@typescript-eslint/
|
|
21
|
+
"@next/eslint-plugin-next": "^15.1.2",
|
|
22
|
+
"@typescript-eslint/eslint-plugin": "^8.18.0",
|
|
23
|
+
"@typescript-eslint/parser": "^8.18.0",
|
|
23
24
|
"eslint-config-prettier": "^9.1.0",
|
|
24
25
|
"eslint-plugin-jsonc": "^2.16.0",
|
|
25
26
|
"eslint-plugin-perfectionist": "^3.8.0",
|
|
26
27
|
"eslint-plugin-react": "^7.37.1",
|
|
28
|
+
"eslint-plugin-react-hooks": "^5.1.0",
|
|
27
29
|
"eslint-plugin-unused-imports": "^4.1.4",
|
|
28
30
|
"eslint-plugin-vue": "^9.28.0",
|
|
29
31
|
"eslint-plugin-yml": "^1.14.0",
|
|
30
32
|
"globals": "^15.0.0",
|
|
31
33
|
"jsonc-eslint-parser": "^2.4.0",
|
|
32
|
-
"remove": "^0.1.5",
|
|
33
34
|
"vue-eslint-parser": "^9.3.2",
|
|
34
35
|
"yaml-eslint-parser": "^1.2.2"
|
|
35
36
|
},
|
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
|
|
@@ -66,6 +71,7 @@ export default function config(params: ConfigParams = {}): Array<ConfigObject> {
|
|
|
66
71
|
sourceType: "module",
|
|
67
72
|
},
|
|
68
73
|
},
|
|
74
|
+
name: "lqbach/javascript",
|
|
69
75
|
plugins: {
|
|
70
76
|
"unused-imports": pluginUnusedImports,
|
|
71
77
|
},
|
|
@@ -86,7 +92,7 @@ export default function config(params: ConfigParams = {}): Array<ConfigObject> {
|
|
|
86
92
|
|
|
87
93
|
// TypeScript Config
|
|
88
94
|
const typescriptConfig: ConfigObject =
|
|
89
|
-
params.typescript ?? true
|
|
95
|
+
(params.typescript ?? true)
|
|
90
96
|
? {
|
|
91
97
|
files: ["**/*.{ts,tsx}"],
|
|
92
98
|
languageOptions: {
|
|
@@ -95,6 +101,7 @@ export default function config(params: ConfigParams = {}): Array<ConfigObject> {
|
|
|
95
101
|
sourceType: "module",
|
|
96
102
|
},
|
|
97
103
|
},
|
|
104
|
+
name: "lqbach/typescript",
|
|
98
105
|
plugins: {
|
|
99
106
|
"@typescript-eslint": pluginTypeScript,
|
|
100
107
|
},
|
|
@@ -106,7 +113,7 @@ export default function config(params: ConfigParams = {}): Array<ConfigObject> {
|
|
|
106
113
|
|
|
107
114
|
// React Config: turned off by default
|
|
108
115
|
const reactConfig: ConfigObject =
|
|
109
|
-
params.react ?? false
|
|
116
|
+
((params.next || params.react) ?? false)
|
|
110
117
|
? {
|
|
111
118
|
files: ["**/*.{js,jsx,mjs,cjs,ts,tsx}"],
|
|
112
119
|
languageOptions: {
|
|
@@ -120,20 +127,37 @@ export default function config(params: ConfigParams = {}): Array<ConfigObject> {
|
|
|
120
127
|
},
|
|
121
128
|
},
|
|
122
129
|
},
|
|
130
|
+
name: "lqbach/react",
|
|
123
131
|
plugins: {
|
|
124
132
|
react: pluginReact,
|
|
125
133
|
},
|
|
126
134
|
rules: {
|
|
127
|
-
...pluginReact.configs.flat
|
|
135
|
+
...pluginReact.configs.flat?.recommended.rules,
|
|
128
136
|
// ignore `css` for emotion usage
|
|
129
137
|
"react/no-unknown-property": ["error", { ignore: ["css"] }],
|
|
130
138
|
},
|
|
131
139
|
}
|
|
132
140
|
: {}
|
|
133
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
|
+
|
|
134
158
|
// Vue Config: turned off by default
|
|
135
159
|
const vueConfig: ConfigObject =
|
|
136
|
-
params.vue ?? false
|
|
160
|
+
(params.vue ?? false)
|
|
137
161
|
? {
|
|
138
162
|
files: ["**/*.vue"],
|
|
139
163
|
languageOptions: {
|
|
@@ -143,6 +167,7 @@ export default function config(params: ConfigParams = {}): Array<ConfigObject> {
|
|
|
143
167
|
sourceType: "module",
|
|
144
168
|
},
|
|
145
169
|
},
|
|
170
|
+
name: "lqbach/vue",
|
|
146
171
|
plugins: {
|
|
147
172
|
vue: pluginVue,
|
|
148
173
|
},
|
|
@@ -155,14 +180,39 @@ export default function config(params: ConfigParams = {}): Array<ConfigObject> {
|
|
|
155
180
|
}
|
|
156
181
|
: {}
|
|
157
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
|
+
|
|
158
207
|
// YAML Config
|
|
159
208
|
const yamlConfig: ConfigObject =
|
|
160
|
-
params.yaml ?? true
|
|
209
|
+
(params.yaml ?? true)
|
|
161
210
|
? {
|
|
162
211
|
files: ["**/*.{yaml, yml}"],
|
|
163
212
|
languageOptions: {
|
|
164
213
|
parser: parserYaml,
|
|
165
214
|
},
|
|
215
|
+
name: "lqbach/yaml",
|
|
166
216
|
plugins: {
|
|
167
217
|
yml: pluginYaml,
|
|
168
218
|
},
|
|
@@ -175,9 +225,10 @@ export default function config(params: ConfigParams = {}): Array<ConfigObject> {
|
|
|
175
225
|
|
|
176
226
|
// JSONC Config
|
|
177
227
|
const jsoncConfig: Array<ConfigObject> =
|
|
178
|
-
params.json ?? true
|
|
228
|
+
(params.json ?? true)
|
|
179
229
|
? [
|
|
180
230
|
{
|
|
231
|
+
name: "lqbach/jsonc-plugin",
|
|
181
232
|
plugins: {
|
|
182
233
|
jsonc: pluginJsonc,
|
|
183
234
|
},
|
|
@@ -187,6 +238,7 @@ export default function config(params: ConfigParams = {}): Array<ConfigObject> {
|
|
|
187
238
|
languageOptions: {
|
|
188
239
|
parser: parserJsonc,
|
|
189
240
|
},
|
|
241
|
+
name: "lqbach/json",
|
|
190
242
|
rules: {
|
|
191
243
|
...pluginJsonc.configs["recommended-with-json"].rules,
|
|
192
244
|
...pluginJsonc.configs["recommended-with-jsonc"].rules,
|
|
@@ -200,8 +252,9 @@ export default function config(params: ConfigParams = {}): Array<ConfigObject> {
|
|
|
200
252
|
|
|
201
253
|
// Perfectionist Config
|
|
202
254
|
const perfectionistConfig: ConfigObject =
|
|
203
|
-
params.perfectionist ?? true
|
|
255
|
+
(params.perfectionist ?? true)
|
|
204
256
|
? {
|
|
257
|
+
name: "lqbach/perfectionist",
|
|
205
258
|
plugins: {
|
|
206
259
|
perfectionist: pluginPerfectionist,
|
|
207
260
|
},
|
|
@@ -218,7 +271,9 @@ export default function config(params: ConfigParams = {}): Array<ConfigObject> {
|
|
|
218
271
|
config.push(...javascriptConfig)
|
|
219
272
|
config.push(typescriptConfig)
|
|
220
273
|
config.push(reactConfig)
|
|
274
|
+
config.push(reactHooksConfig)
|
|
221
275
|
config.push(vueConfig)
|
|
276
|
+
config.push(nextConfig)
|
|
222
277
|
config.push(yamlConfig)
|
|
223
278
|
config.push(...jsoncConfig)
|
|
224
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
|
+
}
|