@jsse/eslint-config 0.2.15 → 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 CHANGED
@@ -4,15 +4,15 @@
4
4
 
5
5
  Eslint config
6
6
 
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)
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
- // options
35
- // typescript: {
36
- // tsconfigPath: "tsconfig.json", // or ["tsconfig.json", "tsconfig.eslint.json", ...]
37
- // },
38
- // react: true
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
- // options
48
- // typescript: {
49
- // tsconfigPath: "tsconfig.json", // or ["tsconfig.json", "tsconfig.eslint.json", ...]
50
- // },
51
- // react: true
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
- "scripts": {
64
- "lint": "eslint .",
65
- "lint:fix": "eslint . --fix"
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
- typescript: {
81
- tsconfigPath: "tsconfig.json", // or ["tsconfig.json", "tsconfig.eslint.json", ...]
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
- - [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
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
@@ -612,7 +612,7 @@ var CAC = class extends import_events.EventEmitter {
612
612
  var cac = (name = "") => new CAC(name);
613
613
 
614
614
  // package.json
615
- var version = "0.2.15";
615
+ var version = "0.2.17";
616
616
 
617
617
  // src/cli.ts
618
618
  var cli = cac("jsselint");
package/dist/cli.js CHANGED
@@ -588,7 +588,7 @@ var CAC = class extends EventEmitter {
588
588
  var cac = (name = "") => new CAC(name);
589
589
 
590
590
  // package.json
591
- var version = "0.2.15";
591
+ var version = "0.2.17";
592
592
 
593
593
  // src/cli.ts
594
594
  var cli = cac("jsselint");
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
  };
@@ -10432,16 +10444,21 @@ var javascript = async (options) => {
10432
10444
  "prefer-rest-params": "error",
10433
10445
  "prefer-spread": "error",
10434
10446
  "prefer-template": "error",
10435
- "sort-imports": [
10436
- "error",
10437
- {
10438
- allowSeparatedGroups: false,
10439
- ignoreCase: false,
10440
- ignoreDeclarationSort: true,
10441
- ignoreMemberSort: false,
10442
- memberSyntaxSortOrder: ["none", "all", "multiple", "single"]
10443
- }
10444
- ],
10447
+ "sort-imports": "off",
10448
+ // use `perfectionist/sort-imports` instead
10449
+ /**
10450
+ * previously used this before switching to `perfectionist/sort-imports`
10451
+ * "sort-imports": [
10452
+ * "error",
10453
+ * {
10454
+ * allowSeparatedGroups: false,
10455
+ * ignoreCase: false,
10456
+ * ignoreDeclarationSort: true,
10457
+ * ignoreMemberSort: false,
10458
+ * memberSyntaxSortOrder: ["none", "all", "multiple", "single"],
10459
+ * },
10460
+ * ],
10461
+ */
10445
10462
  "symbol-description": "error",
10446
10463
  "unicode-bom": ["error", "never"],
10447
10464
  "unused-imports/no-unused-imports": isInEditor2 ? "off" : "error",
@@ -11335,6 +11352,9 @@ var prettier = async () => {
11335
11352
  ];
11336
11353
  };
11337
11354
 
11355
+ // src/configs/react.ts
11356
+ var import_compat = require("@eslint/compat");
11357
+
11338
11358
  // src/configs/ts/typescript-language-options.ts
11339
11359
  var import_node_process4 = __toESM(require("process"), 1);
11340
11360
  function typescriptLanguageOptions(options) {
@@ -11530,24 +11550,6 @@ function reactRules() {
11530
11550
  "react/void-dom-elements-no-children": "error"
11531
11551
  };
11532
11552
  }
11533
- function reactRefreshFlatConfigRules() {
11534
- return [
11535
- {
11536
- files: [GLOB_SRC],
11537
- name: "jsse/react/refresh",
11538
- rules: {
11539
- "react-refresh/only-export-components": "error"
11540
- }
11541
- },
11542
- {
11543
- files: ["**/*.stories.tsx"],
11544
- name: "jsse/react:refresh/stories",
11545
- rules: {
11546
- "react-refresh/only-export-components": "off"
11547
- }
11548
- }
11549
- ];
11550
- }
11551
11553
  function reactRecomendedRules() {
11552
11554
  return {
11553
11555
  "react/display-name": 2,
@@ -11599,13 +11601,14 @@ var react = async (options) => {
11599
11601
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
11600
11602
  react: pluginReact,
11601
11603
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
11602
- "react-hooks": pluginReactHooks,
11604
+ "react-hooks": (0, import_compat.fixupPluginRules)(pluginReactHooks),
11603
11605
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
11604
11606
  "react-refresh": pluginReactRefresh
11605
11607
  }
11606
11608
  },
11607
11609
  {
11608
11610
  files: [GLOB_SRC],
11611
+ name: "jsse/react/rules",
11609
11612
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
11610
11613
  rules: {
11611
11614
  ...reactRecomendedRules(),
@@ -11618,10 +11621,39 @@ var react = async (options) => {
11618
11621
  version: "detect"
11619
11622
  }
11620
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
+ }
11621
11638
  }
11622
11639
  ];
11623
11640
  if (reactRefresh) {
11624
- config.push(...reactRefreshFlatConfigRules());
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
+ );
11625
11657
  }
11626
11658
  return config;
11627
11659
  };
@@ -11939,6 +11971,7 @@ function typescriptParser(options) {
11939
11971
  componentExts = [],
11940
11972
  filesTypeAware: files = [GLOB_TS, GLOB_TSX],
11941
11973
  ignoresTypeAware: ignores2 = [GLOB_MARKDOWN],
11974
+ name,
11942
11975
  parserOptions: parserOptionsOverride = {},
11943
11976
  react: react2,
11944
11977
  tsconfig,
@@ -11966,7 +11999,7 @@ function typescriptParser(options) {
11966
11999
  ...parserOptionsOverride
11967
12000
  }
11968
12001
  },
11969
- name: `jsse/typescript/${typeAware ? "type-aware-parser" : "parser"}`
12002
+ name: name ?? `jsse/typescript/${typeAware ? "type-aware-parser" : "parser"}`
11970
12003
  };
11971
12004
  }
11972
12005
  return {
@@ -11986,7 +12019,7 @@ function typescriptParser(options) {
11986
12019
  ...parserOptionsOverride
11987
12020
  }
11988
12021
  },
11989
- name: `jsse/typescript/${typeAware ? "type-aware-parser" : "parser"}`
12022
+ name: name ?? `jsse/typescript/${typeAware ? "type-aware-parser" : "parser"}`
11990
12023
  };
11991
12024
  }
11992
12025
 
@@ -12291,7 +12324,7 @@ var yml = async (options) => {
12291
12324
  languageOptions: {
12292
12325
  parser: parserYaml
12293
12326
  },
12294
- name: "antfu:yaml/rules",
12327
+ name: "jsse/yaml/rules",
12295
12328
  rules: {
12296
12329
  "style/spaced-comment": "off",
12297
12330
  "yaml/block-mapping": "error",
@@ -12400,15 +12433,6 @@ var Lager = class {
12400
12433
  };
12401
12434
  var log = new Lager();
12402
12435
 
12403
- // src/slow.ts
12404
- var slowRules = [
12405
- "@typescript-eslint/no-misused-promises",
12406
- "@typescript-eslint/no-unsafe-assignment",
12407
- "@typescript-eslint/no-unsafe-call",
12408
- "@typescript-eslint/no-unsafe-member-access",
12409
- "@typescript-eslint/no-unsafe-return"
12410
- ];
12411
-
12412
12436
  // src/factory.ts
12413
12437
  var flatConfigProps = [
12414
12438
  "files",
@@ -12446,7 +12470,7 @@ function normalizeOptions(options = {}) {
12446
12470
  const off = [
12447
12471
  .../* @__PURE__ */ new Set([
12448
12472
  ...options.off ?? [],
12449
- ...options.fast ? [...slowRules] : []
12473
+ ...options.fast ? [...SLOW_RULES] : []
12450
12474
  ])
12451
12475
  ].sort(
12452
12476
  (a, b) => a.localeCompare(b, void 0, { numeric: true, sensitivity: "base" })
@@ -12642,21 +12666,6 @@ async function jsse(options = {}, ...userConfigs) {
12642
12666
  }
12643
12667
  }
12644
12668
  }
12645
- if (normalizedOptions.preReturn) {
12646
- log.debug("Running preReturn");
12647
- const preReturned = normalizedOptions.preReturn(combinedConfigs);
12648
- if (preReturned instanceof Promise) {
12649
- const res = await preReturned;
12650
- log.debug("preReturn finished");
12651
- log.debug("final config", res);
12652
- return res;
12653
- } else {
12654
- const res = preReturned;
12655
- log.debug("preReturn finished");
12656
- log.debug("final config", res);
12657
- return res;
12658
- }
12659
- }
12660
12669
  for (const config of combinedConfigs) {
12661
12670
  if (config.plugins) {
12662
12671
  for (const [key, value] of Object.entries(config.plugins)) {
@@ -12675,6 +12684,21 @@ async function jsse(options = {}, ...userConfigs) {
12675
12684
  }
12676
12685
  }
12677
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
+ }
12678
12702
  return combinedConfigs;
12679
12703
  }
12680
12704
 
@@ -12720,6 +12744,7 @@ function jsseReact() {
12720
12744
  GLOB_TSCONFIG,
12721
12745
  GLOB_TSX,
12722
12746
  GLOB_YAML,
12747
+ SLOW_RULES,
12723
12748
  combine,
12724
12749
  combineAsync,
12725
12750
  importJsoncLibs,