@jsse/eslint-config 0.2.16 → 0.2.18
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/README.md +30 -30
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.cjs +78 -78
- package/dist/index.d.cts +208 -106
- package/dist/index.d.ts +208 -106
- package/dist/index.js +77 -78
- package/package.json +14 -13
package/README.md
CHANGED
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
Eslint config
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
- eslint flat config
|
|
8
|
+
- double quotes + semi
|
|
9
|
+
- react, react-hooks & react-refresh, OH MY!
|
|
10
|
+
- no vue (I don't use vue (as of 2023-10-12) don't want/need the vue plugins/parsers/etc)
|
|
11
|
+
- assumes you're using prettier
|
|
12
|
+
- Based on:
|
|
13
|
+
- My old, very long, and very messy (non-flat) eslint config (`.eslintrc.js`)
|
|
14
|
+
- antfu eslint-config [eslint-config](https://github.com/antfu/eslint-config)
|
|
15
|
+
- sxzz eslint-config [eslint-config](https://github.com/sxzz/eslint-config)
|
|
16
16
|
|
|
17
17
|
## Usage
|
|
18
18
|
|
|
@@ -31,11 +31,11 @@ With [`"type": "module"`](https://nodejs.org/api/packages.html#type) in `package
|
|
|
31
31
|
import jsse from "@jsse/eslint-config";
|
|
32
32
|
|
|
33
33
|
export default jsse({
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
// options
|
|
35
|
+
// typescript: {
|
|
36
|
+
// tsconfigPath: "tsconfig.json", // or ["tsconfig.json", "tsconfig.eslint.json", ...]
|
|
37
|
+
// },
|
|
38
|
+
// react: true
|
|
39
39
|
});
|
|
40
40
|
```
|
|
41
41
|
|
|
@@ -44,11 +44,11 @@ With CJS:
|
|
|
44
44
|
```js
|
|
45
45
|
// eslint.config.js
|
|
46
46
|
module.exports = require("@jsse/eslint-config").jsse({
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
// options
|
|
48
|
+
// typescript: {
|
|
49
|
+
// tsconfigPath: "tsconfig.json", // or ["tsconfig.json", "tsconfig.eslint.json", ...]
|
|
50
|
+
// },
|
|
51
|
+
// react: true
|
|
52
52
|
});
|
|
53
53
|
```
|
|
54
54
|
|
|
@@ -60,10 +60,10 @@ For example:
|
|
|
60
60
|
|
|
61
61
|
```json
|
|
62
62
|
{
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
"scripts": {
|
|
64
|
+
"lint": "eslint .",
|
|
65
|
+
"lint:fix": "eslint . --fix"
|
|
66
|
+
}
|
|
67
67
|
}
|
|
68
68
|
```
|
|
69
69
|
|
|
@@ -77,18 +77,18 @@ options object to the `typescript` config:
|
|
|
77
77
|
import jsse from "@jsse/eslint-config";
|
|
78
78
|
|
|
79
79
|
export default jsse({
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
typescript: {
|
|
81
|
+
tsconfigPath: "tsconfig.json", // or ["tsconfig.json", "tsconfig.eslint.json", ...]
|
|
82
|
+
},
|
|
83
83
|
});
|
|
84
84
|
```
|
|
85
85
|
|
|
86
86
|
## Thanks
|
|
87
87
|
|
|
88
|
-
-
|
|
89
|
-
|
|
90
|
-
-
|
|
91
|
-
-
|
|
88
|
+
- [antfu](https://github.com/antfu) and [sxzz](https://github.com/sxzz) for their eslint-configs which
|
|
89
|
+
this is based on
|
|
90
|
+
- Younger me for being more willing to spend time configuring eslint
|
|
91
|
+
- My fans for being my fans
|
|
92
92
|
|
|
93
93
|
## FAQ
|
|
94
94
|
|
package/dist/cli.cjs
CHANGED
package/dist/cli.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -3004,6 +3004,7 @@ __export(src_exports, {
|
|
|
3004
3004
|
GLOB_TSCONFIG: () => GLOB_TSCONFIG,
|
|
3005
3005
|
GLOB_TSX: () => GLOB_TSX,
|
|
3006
3006
|
GLOB_YAML: () => GLOB_YAML,
|
|
3007
|
+
SLOW_RULES: () => SLOW_RULES,
|
|
3007
3008
|
combine: () => combine,
|
|
3008
3009
|
combineAsync: () => combineAsync,
|
|
3009
3010
|
default: () => jsse,
|
|
@@ -3040,6 +3041,16 @@ __export(src_exports, {
|
|
|
3040
3041
|
});
|
|
3041
3042
|
module.exports = __toCommonJS(src_exports);
|
|
3042
3043
|
|
|
3044
|
+
// src/const.ts
|
|
3045
|
+
var SLOW_RULES = [
|
|
3046
|
+
"@typescript-eslint/no-misused-promises",
|
|
3047
|
+
"@typescript-eslint/no-unsafe-assignment",
|
|
3048
|
+
"@typescript-eslint/no-unsafe-call",
|
|
3049
|
+
"@typescript-eslint/no-unsafe-member-access",
|
|
3050
|
+
"@typescript-eslint/no-unsafe-return",
|
|
3051
|
+
"unicorn/no-unnecessary-polyfills"
|
|
3052
|
+
];
|
|
3053
|
+
|
|
3043
3054
|
// src/factory.ts
|
|
3044
3055
|
var import_node_fs3 = __toESM(require("fs"), 1);
|
|
3045
3056
|
var import_node_process6 = __toESM(require("process"), 1);
|
|
@@ -10180,7 +10191,8 @@ var comments = async () => [
|
|
|
10180
10191
|
var ignores = async () => {
|
|
10181
10192
|
return [
|
|
10182
10193
|
{
|
|
10183
|
-
ignores: GLOB_EXCLUDE
|
|
10194
|
+
ignores: GLOB_EXCLUDE,
|
|
10195
|
+
name: "jsse/ignores"
|
|
10184
10196
|
}
|
|
10185
10197
|
];
|
|
10186
10198
|
};
|
|
@@ -10714,32 +10726,7 @@ function typescriptRulesTypeOblivious() {
|
|
|
10714
10726
|
"no-console": [
|
|
10715
10727
|
"warn",
|
|
10716
10728
|
{
|
|
10717
|
-
allow: [
|
|
10718
|
-
"log",
|
|
10719
|
-
"warn",
|
|
10720
|
-
"dir",
|
|
10721
|
-
"time",
|
|
10722
|
-
"timeEnd",
|
|
10723
|
-
"timeLog",
|
|
10724
|
-
"trace",
|
|
10725
|
-
"assert",
|
|
10726
|
-
"clear",
|
|
10727
|
-
"count",
|
|
10728
|
-
"countReset",
|
|
10729
|
-
"group",
|
|
10730
|
-
"groupEnd",
|
|
10731
|
-
"table",
|
|
10732
|
-
"debug",
|
|
10733
|
-
"info",
|
|
10734
|
-
"dirxml",
|
|
10735
|
-
"error",
|
|
10736
|
-
"groupCollapsed",
|
|
10737
|
-
"Console",
|
|
10738
|
-
"profile",
|
|
10739
|
-
"profileEnd",
|
|
10740
|
-
"timeStamp",
|
|
10741
|
-
"context"
|
|
10742
|
-
]
|
|
10729
|
+
allow: ["warn", "error"]
|
|
10743
10730
|
}
|
|
10744
10731
|
],
|
|
10745
10732
|
"object-curly-spacing": "off",
|
|
@@ -11340,6 +11327,9 @@ var prettier = async () => {
|
|
|
11340
11327
|
];
|
|
11341
11328
|
};
|
|
11342
11329
|
|
|
11330
|
+
// src/configs/react.ts
|
|
11331
|
+
var import_compat = require("@eslint/compat");
|
|
11332
|
+
|
|
11343
11333
|
// src/configs/ts/typescript-language-options.ts
|
|
11344
11334
|
var import_node_process4 = __toESM(require("process"), 1);
|
|
11345
11335
|
function typescriptLanguageOptions(options) {
|
|
@@ -11535,24 +11525,6 @@ function reactRules() {
|
|
|
11535
11525
|
"react/void-dom-elements-no-children": "error"
|
|
11536
11526
|
};
|
|
11537
11527
|
}
|
|
11538
|
-
function reactRefreshFlatConfigRules() {
|
|
11539
|
-
return [
|
|
11540
|
-
{
|
|
11541
|
-
files: [GLOB_SRC],
|
|
11542
|
-
name: "jsse/react/refresh",
|
|
11543
|
-
rules: {
|
|
11544
|
-
"react-refresh/only-export-components": "error"
|
|
11545
|
-
}
|
|
11546
|
-
},
|
|
11547
|
-
{
|
|
11548
|
-
files: ["**/*.stories.tsx"],
|
|
11549
|
-
name: "jsse/react:refresh/stories",
|
|
11550
|
-
rules: {
|
|
11551
|
-
"react-refresh/only-export-components": "off"
|
|
11552
|
-
}
|
|
11553
|
-
}
|
|
11554
|
-
];
|
|
11555
|
-
}
|
|
11556
11528
|
function reactRecomendedRules() {
|
|
11557
11529
|
return {
|
|
11558
11530
|
"react/display-name": 2,
|
|
@@ -11604,13 +11576,14 @@ var react = async (options) => {
|
|
|
11604
11576
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
11605
11577
|
react: pluginReact,
|
|
11606
11578
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
11607
|
-
"react-hooks": pluginReactHooks,
|
|
11579
|
+
"react-hooks": (0, import_compat.fixupPluginRules)(pluginReactHooks),
|
|
11608
11580
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
11609
11581
|
"react-refresh": pluginReactRefresh
|
|
11610
11582
|
}
|
|
11611
11583
|
},
|
|
11612
11584
|
{
|
|
11613
11585
|
files: [GLOB_SRC],
|
|
11586
|
+
name: "jsse/react/rules",
|
|
11614
11587
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
11615
11588
|
rules: {
|
|
11616
11589
|
...reactRecomendedRules(),
|
|
@@ -11623,10 +11596,39 @@ var react = async (options) => {
|
|
|
11623
11596
|
version: "detect"
|
|
11624
11597
|
}
|
|
11625
11598
|
}
|
|
11599
|
+
},
|
|
11600
|
+
{
|
|
11601
|
+
files: [GLOB_SRC],
|
|
11602
|
+
name: "jsse/react-hooks/rules",
|
|
11603
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
11604
|
+
rules: {
|
|
11605
|
+
"react-hooks/exhaustive-deps": "error",
|
|
11606
|
+
"react-hooks/rules-of-hooks": "error"
|
|
11607
|
+
},
|
|
11608
|
+
settings: {
|
|
11609
|
+
react: {
|
|
11610
|
+
version: "detect"
|
|
11611
|
+
}
|
|
11612
|
+
}
|
|
11626
11613
|
}
|
|
11627
11614
|
];
|
|
11628
11615
|
if (reactRefresh) {
|
|
11629
|
-
config.push(
|
|
11616
|
+
config.push(
|
|
11617
|
+
{
|
|
11618
|
+
files: [GLOB_SRC],
|
|
11619
|
+
name: "jsse/react/refresh",
|
|
11620
|
+
rules: {
|
|
11621
|
+
"react-refresh/only-export-components": "error"
|
|
11622
|
+
}
|
|
11623
|
+
},
|
|
11624
|
+
{
|
|
11625
|
+
files: ["**/*.stories.tsx"],
|
|
11626
|
+
name: "jsse/react-refresh/stories",
|
|
11627
|
+
rules: {
|
|
11628
|
+
"react-refresh/only-export-components": "off"
|
|
11629
|
+
}
|
|
11630
|
+
}
|
|
11631
|
+
);
|
|
11630
11632
|
}
|
|
11631
11633
|
return config;
|
|
11632
11634
|
};
|
|
@@ -11944,6 +11946,7 @@ function typescriptParser(options) {
|
|
|
11944
11946
|
componentExts = [],
|
|
11945
11947
|
filesTypeAware: files = [GLOB_TS, GLOB_TSX],
|
|
11946
11948
|
ignoresTypeAware: ignores2 = [GLOB_MARKDOWN],
|
|
11949
|
+
name,
|
|
11947
11950
|
parserOptions: parserOptionsOverride = {},
|
|
11948
11951
|
react: react2,
|
|
11949
11952
|
tsconfig,
|
|
@@ -11971,7 +11974,7 @@ function typescriptParser(options) {
|
|
|
11971
11974
|
...parserOptionsOverride
|
|
11972
11975
|
}
|
|
11973
11976
|
},
|
|
11974
|
-
name: `jsse/typescript/${typeAware ? "type-aware-parser" : "parser"}`
|
|
11977
|
+
name: name ?? `jsse/typescript/${typeAware ? "type-aware-parser" : "parser"}`
|
|
11975
11978
|
};
|
|
11976
11979
|
}
|
|
11977
11980
|
return {
|
|
@@ -11991,7 +11994,7 @@ function typescriptParser(options) {
|
|
|
11991
11994
|
...parserOptionsOverride
|
|
11992
11995
|
}
|
|
11993
11996
|
},
|
|
11994
|
-
name: `jsse/typescript/${typeAware ? "type-aware-parser" : "parser"}`
|
|
11997
|
+
name: name ?? `jsse/typescript/${typeAware ? "type-aware-parser" : "parser"}`
|
|
11995
11998
|
};
|
|
11996
11999
|
}
|
|
11997
12000
|
|
|
@@ -12163,6 +12166,7 @@ var unicorn = async () => {
|
|
|
12163
12166
|
...unicornRecommended(),
|
|
12164
12167
|
...unicornOff(),
|
|
12165
12168
|
"unicorn/better-regex": "error",
|
|
12169
|
+
"unicorn/consistent-empty-array-spread": "error",
|
|
12166
12170
|
"unicorn/custom-error-definition": "error",
|
|
12167
12171
|
// Pass error message when throwing errors
|
|
12168
12172
|
"unicorn/error-message": "error",
|
|
@@ -12296,7 +12300,7 @@ var yml = async (options) => {
|
|
|
12296
12300
|
languageOptions: {
|
|
12297
12301
|
parser: parserYaml
|
|
12298
12302
|
},
|
|
12299
|
-
name: "
|
|
12303
|
+
name: "jsse/yaml/rules",
|
|
12300
12304
|
rules: {
|
|
12301
12305
|
"style/spaced-comment": "off",
|
|
12302
12306
|
"yaml/block-mapping": "error",
|
|
@@ -12405,15 +12409,6 @@ var Lager = class {
|
|
|
12405
12409
|
};
|
|
12406
12410
|
var log = new Lager();
|
|
12407
12411
|
|
|
12408
|
-
// src/slow.ts
|
|
12409
|
-
var slowRules = [
|
|
12410
|
-
"@typescript-eslint/no-misused-promises",
|
|
12411
|
-
"@typescript-eslint/no-unsafe-assignment",
|
|
12412
|
-
"@typescript-eslint/no-unsafe-call",
|
|
12413
|
-
"@typescript-eslint/no-unsafe-member-access",
|
|
12414
|
-
"@typescript-eslint/no-unsafe-return"
|
|
12415
|
-
];
|
|
12416
|
-
|
|
12417
12412
|
// src/factory.ts
|
|
12418
12413
|
var flatConfigProps = [
|
|
12419
12414
|
"files",
|
|
@@ -12451,7 +12446,7 @@ function normalizeOptions(options = {}) {
|
|
|
12451
12446
|
const off = [
|
|
12452
12447
|
.../* @__PURE__ */ new Set([
|
|
12453
12448
|
...options.off ?? [],
|
|
12454
|
-
...options.fast ? [...
|
|
12449
|
+
...options.fast ? [...SLOW_RULES] : []
|
|
12455
12450
|
])
|
|
12456
12451
|
].sort(
|
|
12457
12452
|
(a, b) => a.localeCompare(b, void 0, { numeric: true, sensitivity: "base" })
|
|
@@ -12630,9 +12625,13 @@ async function jsse(options = {}, ...userConfigs) {
|
|
|
12630
12625
|
}
|
|
12631
12626
|
}
|
|
12632
12627
|
for (const config of combinedConfigs) {
|
|
12633
|
-
for (const
|
|
12634
|
-
if (
|
|
12635
|
-
|
|
12628
|
+
for (const cfgRules of [config.rules, config.plugins]) {
|
|
12629
|
+
if (cfgRules) {
|
|
12630
|
+
for (const rule of off) {
|
|
12631
|
+
if (cfgRules[rule] !== void 0 && cfgRules[rule] !== "off" && cfgRules[rule] !== 0) {
|
|
12632
|
+
cfgRules[rule] = "off";
|
|
12633
|
+
}
|
|
12634
|
+
}
|
|
12636
12635
|
}
|
|
12637
12636
|
}
|
|
12638
12637
|
}
|
|
@@ -12647,21 +12646,6 @@ async function jsse(options = {}, ...userConfigs) {
|
|
|
12647
12646
|
}
|
|
12648
12647
|
}
|
|
12649
12648
|
}
|
|
12650
|
-
if (normalizedOptions.preReturn) {
|
|
12651
|
-
log.debug("Running preReturn");
|
|
12652
|
-
const preReturned = normalizedOptions.preReturn(combinedConfigs);
|
|
12653
|
-
if (preReturned instanceof Promise) {
|
|
12654
|
-
const res = await preReturned;
|
|
12655
|
-
log.debug("preReturn finished");
|
|
12656
|
-
log.debug("final config", res);
|
|
12657
|
-
return res;
|
|
12658
|
-
} else {
|
|
12659
|
-
const res = preReturned;
|
|
12660
|
-
log.debug("preReturn finished");
|
|
12661
|
-
log.debug("final config", res);
|
|
12662
|
-
return res;
|
|
12663
|
-
}
|
|
12664
|
-
}
|
|
12665
12649
|
for (const config of combinedConfigs) {
|
|
12666
12650
|
if (config.plugins) {
|
|
12667
12651
|
for (const [key, value] of Object.entries(config.plugins)) {
|
|
@@ -12680,6 +12664,21 @@ async function jsse(options = {}, ...userConfigs) {
|
|
|
12680
12664
|
}
|
|
12681
12665
|
}
|
|
12682
12666
|
}
|
|
12667
|
+
if (normalizedOptions.preReturn) {
|
|
12668
|
+
log.debug("Running preReturn");
|
|
12669
|
+
const preReturned = normalizedOptions.preReturn(combinedConfigs);
|
|
12670
|
+
if (preReturned instanceof Promise) {
|
|
12671
|
+
const res = await preReturned;
|
|
12672
|
+
log.debug("preReturn finished");
|
|
12673
|
+
log.debug("final config", res);
|
|
12674
|
+
return res;
|
|
12675
|
+
} else {
|
|
12676
|
+
const res = preReturned;
|
|
12677
|
+
log.debug("preReturn finished");
|
|
12678
|
+
log.debug("final config", res);
|
|
12679
|
+
return res;
|
|
12680
|
+
}
|
|
12681
|
+
}
|
|
12683
12682
|
return combinedConfigs;
|
|
12684
12683
|
}
|
|
12685
12684
|
|
|
@@ -12725,6 +12724,7 @@ function jsseReact() {
|
|
|
12725
12724
|
GLOB_TSCONFIG,
|
|
12726
12725
|
GLOB_TSX,
|
|
12727
12726
|
GLOB_YAML,
|
|
12727
|
+
SLOW_RULES,
|
|
12728
12728
|
combine,
|
|
12729
12729
|
combineAsync,
|
|
12730
12730
|
importJsoncLibs,
|