@jsse/eslint-config 0.2.16 → 0.2.17
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 +69 -49
- package/dist/index.d.cts +104 -94
- package/dist/index.d.ts +104 -94
- package/dist/index.js +68 -49
- package/package.json +4 -3
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
|
};
|
|
@@ -11340,6 +11352,9 @@ var prettier = async () => {
|
|
|
11340
11352
|
];
|
|
11341
11353
|
};
|
|
11342
11354
|
|
|
11355
|
+
// src/configs/react.ts
|
|
11356
|
+
var import_compat = require("@eslint/compat");
|
|
11357
|
+
|
|
11343
11358
|
// src/configs/ts/typescript-language-options.ts
|
|
11344
11359
|
var import_node_process4 = __toESM(require("process"), 1);
|
|
11345
11360
|
function typescriptLanguageOptions(options) {
|
|
@@ -11535,24 +11550,6 @@ function reactRules() {
|
|
|
11535
11550
|
"react/void-dom-elements-no-children": "error"
|
|
11536
11551
|
};
|
|
11537
11552
|
}
|
|
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
11553
|
function reactRecomendedRules() {
|
|
11557
11554
|
return {
|
|
11558
11555
|
"react/display-name": 2,
|
|
@@ -11604,13 +11601,14 @@ var react = async (options) => {
|
|
|
11604
11601
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
11605
11602
|
react: pluginReact,
|
|
11606
11603
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
11607
|
-
"react-hooks": pluginReactHooks,
|
|
11604
|
+
"react-hooks": (0, import_compat.fixupPluginRules)(pluginReactHooks),
|
|
11608
11605
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
11609
11606
|
"react-refresh": pluginReactRefresh
|
|
11610
11607
|
}
|
|
11611
11608
|
},
|
|
11612
11609
|
{
|
|
11613
11610
|
files: [GLOB_SRC],
|
|
11611
|
+
name: "jsse/react/rules",
|
|
11614
11612
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
11615
11613
|
rules: {
|
|
11616
11614
|
...reactRecomendedRules(),
|
|
@@ -11623,10 +11621,39 @@ var react = async (options) => {
|
|
|
11623
11621
|
version: "detect"
|
|
11624
11622
|
}
|
|
11625
11623
|
}
|
|
11624
|
+
},
|
|
11625
|
+
{
|
|
11626
|
+
files: [GLOB_SRC],
|
|
11627
|
+
name: "jsse/react-hooks/rules",
|
|
11628
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
11629
|
+
rules: {
|
|
11630
|
+
"react-hooks/exhaustive-deps": "error",
|
|
11631
|
+
"react-hooks/rules-of-hooks": "error"
|
|
11632
|
+
},
|
|
11633
|
+
settings: {
|
|
11634
|
+
react: {
|
|
11635
|
+
version: "detect"
|
|
11636
|
+
}
|
|
11637
|
+
}
|
|
11626
11638
|
}
|
|
11627
11639
|
];
|
|
11628
11640
|
if (reactRefresh) {
|
|
11629
|
-
config.push(
|
|
11641
|
+
config.push(
|
|
11642
|
+
{
|
|
11643
|
+
files: [GLOB_SRC],
|
|
11644
|
+
name: "jsse/react/refresh",
|
|
11645
|
+
rules: {
|
|
11646
|
+
"react-refresh/only-export-components": "error"
|
|
11647
|
+
}
|
|
11648
|
+
},
|
|
11649
|
+
{
|
|
11650
|
+
files: ["**/*.stories.tsx"],
|
|
11651
|
+
name: "jsse/react-refresh/stories",
|
|
11652
|
+
rules: {
|
|
11653
|
+
"react-refresh/only-export-components": "off"
|
|
11654
|
+
}
|
|
11655
|
+
}
|
|
11656
|
+
);
|
|
11630
11657
|
}
|
|
11631
11658
|
return config;
|
|
11632
11659
|
};
|
|
@@ -11944,6 +11971,7 @@ function typescriptParser(options) {
|
|
|
11944
11971
|
componentExts = [],
|
|
11945
11972
|
filesTypeAware: files = [GLOB_TS, GLOB_TSX],
|
|
11946
11973
|
ignoresTypeAware: ignores2 = [GLOB_MARKDOWN],
|
|
11974
|
+
name,
|
|
11947
11975
|
parserOptions: parserOptionsOverride = {},
|
|
11948
11976
|
react: react2,
|
|
11949
11977
|
tsconfig,
|
|
@@ -11971,7 +11999,7 @@ function typescriptParser(options) {
|
|
|
11971
11999
|
...parserOptionsOverride
|
|
11972
12000
|
}
|
|
11973
12001
|
},
|
|
11974
|
-
name: `jsse/typescript/${typeAware ? "type-aware-parser" : "parser"}`
|
|
12002
|
+
name: name ?? `jsse/typescript/${typeAware ? "type-aware-parser" : "parser"}`
|
|
11975
12003
|
};
|
|
11976
12004
|
}
|
|
11977
12005
|
return {
|
|
@@ -11991,7 +12019,7 @@ function typescriptParser(options) {
|
|
|
11991
12019
|
...parserOptionsOverride
|
|
11992
12020
|
}
|
|
11993
12021
|
},
|
|
11994
|
-
name: `jsse/typescript/${typeAware ? "type-aware-parser" : "parser"}`
|
|
12022
|
+
name: name ?? `jsse/typescript/${typeAware ? "type-aware-parser" : "parser"}`
|
|
11995
12023
|
};
|
|
11996
12024
|
}
|
|
11997
12025
|
|
|
@@ -12296,7 +12324,7 @@ var yml = async (options) => {
|
|
|
12296
12324
|
languageOptions: {
|
|
12297
12325
|
parser: parserYaml
|
|
12298
12326
|
},
|
|
12299
|
-
name: "
|
|
12327
|
+
name: "jsse/yaml/rules",
|
|
12300
12328
|
rules: {
|
|
12301
12329
|
"style/spaced-comment": "off",
|
|
12302
12330
|
"yaml/block-mapping": "error",
|
|
@@ -12405,15 +12433,6 @@ var Lager = class {
|
|
|
12405
12433
|
};
|
|
12406
12434
|
var log = new Lager();
|
|
12407
12435
|
|
|
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
12436
|
// src/factory.ts
|
|
12418
12437
|
var flatConfigProps = [
|
|
12419
12438
|
"files",
|
|
@@ -12451,7 +12470,7 @@ function normalizeOptions(options = {}) {
|
|
|
12451
12470
|
const off = [
|
|
12452
12471
|
.../* @__PURE__ */ new Set([
|
|
12453
12472
|
...options.off ?? [],
|
|
12454
|
-
...options.fast ? [...
|
|
12473
|
+
...options.fast ? [...SLOW_RULES] : []
|
|
12455
12474
|
])
|
|
12456
12475
|
].sort(
|
|
12457
12476
|
(a, b) => a.localeCompare(b, void 0, { numeric: true, sensitivity: "base" })
|
|
@@ -12647,21 +12666,6 @@ async function jsse(options = {}, ...userConfigs) {
|
|
|
12647
12666
|
}
|
|
12648
12667
|
}
|
|
12649
12668
|
}
|
|
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
12669
|
for (const config of combinedConfigs) {
|
|
12666
12670
|
if (config.plugins) {
|
|
12667
12671
|
for (const [key, value] of Object.entries(config.plugins)) {
|
|
@@ -12680,6 +12684,21 @@ async function jsse(options = {}, ...userConfigs) {
|
|
|
12680
12684
|
}
|
|
12681
12685
|
}
|
|
12682
12686
|
}
|
|
12687
|
+
if (normalizedOptions.preReturn) {
|
|
12688
|
+
log.debug("Running preReturn");
|
|
12689
|
+
const preReturned = normalizedOptions.preReturn(combinedConfigs);
|
|
12690
|
+
if (preReturned instanceof Promise) {
|
|
12691
|
+
const res = await preReturned;
|
|
12692
|
+
log.debug("preReturn finished");
|
|
12693
|
+
log.debug("final config", res);
|
|
12694
|
+
return res;
|
|
12695
|
+
} else {
|
|
12696
|
+
const res = preReturned;
|
|
12697
|
+
log.debug("preReturn finished");
|
|
12698
|
+
log.debug("final config", res);
|
|
12699
|
+
return res;
|
|
12700
|
+
}
|
|
12701
|
+
}
|
|
12683
12702
|
return combinedConfigs;
|
|
12684
12703
|
}
|
|
12685
12704
|
|
|
@@ -12725,6 +12744,7 @@ function jsseReact() {
|
|
|
12725
12744
|
GLOB_TSCONFIG,
|
|
12726
12745
|
GLOB_TSX,
|
|
12727
12746
|
GLOB_YAML,
|
|
12747
|
+
SLOW_RULES,
|
|
12728
12748
|
combine,
|
|
12729
12749
|
combineAsync,
|
|
12730
12750
|
importJsoncLibs,
|