@pob/eslint-config 67.9.0 → 67.11.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/lib/_base.js CHANGED
@@ -35,6 +35,7 @@ export default [
35
35
  "**/coverage/",
36
36
  "**/.next/",
37
37
  "**/.tamagui/",
38
+ "**/.expo/",
38
39
  "**/*.d.ts",
39
40
  ],
40
41
  },
package/lib/index.js CHANGED
@@ -142,6 +142,21 @@ export const createOxlintConfigs = (additionalOxlintConfigs = []) => {
142
142
  ];
143
143
  };
144
144
 
145
+ // Without the TypeScript program, a type-aware rule crashes eslint. Computed
146
+ // from the installed typescript-eslint, not from oxlint/typescript.json: a rule
147
+ // added by a newer version is off until moved to oxlint, instead of crashing.
148
+ const typeAwareRuleNames = new Set(
149
+ oxlintTypescript
150
+ ? Object.entries(
151
+ /** @type {{ rules?: Record<string, { meta?: { docs?: { requiresTypeChecking?: boolean } } }> }} */ (
152
+ tseslint.plugin
153
+ ).rules ?? {},
154
+ )
155
+ .filter(([, rule]) => rule.meta?.docs?.requiresTypeChecking)
156
+ .map(([ruleName]) => `@typescript-eslint/${ruleName}`)
157
+ : [],
158
+ );
159
+
145
160
  const oxlintConfigs = [
146
161
  ...createOxlintConfigs(),
147
162
  // oxlint runs every type-aware rule: eslint no longer needs to build the
@@ -154,11 +169,26 @@ const oxlintConfigs = [
154
169
  languageOptions: {
155
170
  parserOptions: { project: false, projectService: false },
156
171
  },
172
+ rules: Object.fromEntries(
173
+ [...typeAwareRuleNames].map((ruleName) => [ruleName, "off"]),
174
+ ),
157
175
  },
158
176
  ]
159
177
  : []),
160
178
  ];
161
179
 
180
+ // n/process-exit-as-throw only feeds eslint's code path analysis, used by rules
181
+ // checked by oxlint (no-unreachable, array-callback-return, ...)
182
+ const oxlintNodeConfigs = oxlintrc
183
+ ? [
184
+ {
185
+ name: "@pob/eslint-config/oxlint-node",
186
+ files: ["**/*.{js,cjs,mjs,ts,cts,mts,tsx}"],
187
+ rules: { "n/process-exit-as-throw": "off" },
188
+ },
189
+ ]
190
+ : [];
191
+
162
192
  /**
163
193
  * Removes the rules checked by oxlint from configs applied after
164
194
  * `oxlintConfigs`, like the overrides a project selects. Their oxlint
@@ -176,7 +206,9 @@ const withoutOxlintRules = (configs) =>
176
206
  ...config,
177
207
  rules: Object.fromEntries(
178
208
  Object.entries(config.rules).filter(
179
- ([ruleName]) => !oxlintEslintRuleNames.has(ruleName),
209
+ ([ruleName]) =>
210
+ !oxlintEslintRuleNames.has(ruleName) &&
211
+ !typeAwareRuleNames.has(ruleName),
180
212
  ),
181
213
  ),
182
214
  }
@@ -320,10 +352,10 @@ export default {
320
352
  ...oxlintConfigs,
321
353
  ],
322
354
  /** @deprecated */
323
- nodeModule: [...nodeModule, ...oxlintConfigs],
355
+ nodeModule: [...nodeModule, ...oxlintNodeConfigs, ...oxlintConfigs],
324
356
  /** @deprecated */
325
- nodeCommonjs: [...nodeCommonjs, ...oxlintConfigs],
326
- node: [...nodeModule, ...oxlintConfigs],
357
+ nodeCommonjs: [...nodeCommonjs, ...oxlintNodeConfigs, ...oxlintConfigs],
358
+ node: [...nodeModule, ...oxlintNodeConfigs, ...oxlintConfigs],
327
359
 
328
360
  allowImplicitReturnType: applyTs({
329
361
  configs: withoutOxlintRules([allowImplicitReturnTypeConfig]),
@@ -19,7 +19,7 @@ export default [
19
19
  // lint JSONC files
20
20
  {
21
21
  // name: "@pob/eslint-config/base/languages/json/jsonc",
22
- files: ["**/*.jsonc", "**/tsconfig.json", ".vscode/*.json"],
22
+ files: ["**/*.jsonc", "**/tsconfig*.json", ".vscode/*.json"],
23
23
  language: "json/jsonc",
24
24
  languageOptions: {
25
25
  allowTrailingCommas: true,
@@ -0,0 +1,23 @@
1
+ // JS plugin of oxlint/*.json, see ./regexp.js. eslint core rules without
2
+ // oxlint equivalent, or whose oxlint version differs. Named "eslint-js":
3
+ // "eslint" is reserved for oxlint's native rules.
4
+ import { builtinRules } from "eslint/use-at-your-own-risk";
5
+
6
+ const ruleNames = [
7
+ "camelcase",
8
+ "dot-notation",
9
+ "no-lone-blocks",
10
+ "no-restricted-syntax",
11
+ "no-undef-init",
12
+ ];
13
+
14
+ export default {
15
+ meta: { name: "eslint-js" },
16
+ rules: Object.fromEntries(
17
+ ruleNames.map((ruleName) => {
18
+ const rule = builtinRules.get(ruleName);
19
+ if (!rule) throw new Error(`Unknown eslint rule "${ruleName}"`);
20
+ return [ruleName, rule];
21
+ }),
22
+ ),
23
+ };
@@ -0,0 +1,3 @@
1
+ // JS plugin of oxlint/*.json, see ./regexp.js. Named "node-js": "node" is
2
+ // reserved for oxlint's native plugin.
3
+ export { default } from "eslint-plugin-n";
@@ -0,0 +1,2 @@
1
+ // JS plugin of oxlint/*.json, see ./regexp.js
2
+ export { default } from "@pob/eslint-plugin";
@@ -0,0 +1,5 @@
1
+ // JS plugin of oxlint/*.json. oxlint resolves a package name from the
2
+ // directory of the config file, not from its real path: when this package is
3
+ // symlinked (pnpm or yarn isolated node_modules), its dependencies are not
4
+ // found. Node resolves the imports of this file from its real path.
5
+ export { default } from "eslint-plugin-regexp";
@@ -0,0 +1,3 @@
1
+ // JS plugin of oxlint/*.json, see ./regexp.js. Named "unicorn-js": "unicorn"
2
+ // is reserved for oxlint's native plugin.
3
+ export { default } from "eslint-plugin-unicorn";
@@ -12,6 +12,8 @@ import {
12
12
  * - enabled: in oxlint/*.json
13
13
  * - migrate: enabled in eslint, to move to oxlint (docs/oxlint-migration.md)
14
14
  * - eslint: kept in eslint
15
+ * - js-plugin: checked by the eslint rule run as an oxlint JS plugin, as the
16
+ * oxlint rule differs (docs/oxlint-migration.md)
15
17
  * - evaluate: not used today, to evaluate (Phase 4 of the migration)
16
18
  * - rejected: not wanted
17
19
  */
@@ -31,6 +33,7 @@ const decisions = new Set([
31
33
  "enabled",
32
34
  "migrate",
33
35
  "eslint",
36
+ "js-plugin",
34
37
  "evaluate",
35
38
  "rejected",
36
39
  ]);
@@ -76,6 +79,12 @@ describe("oxlint rules inventory", () => {
76
79
  Object.keys(inventory)
77
80
  .filter((name) => inventory[name] === "enabled")
78
81
  .toSorted(),
79
- ).toEqual(getEnabledOxlintConfigRules());
82
+ ).toEqual(
83
+ // rules of JS plugins (regexp, @pob) are listed in
84
+ // inventory/eslint-rules.json
85
+ getEnabledOxlintConfigRules().filter((name) =>
86
+ plugins.has(name.slice(0, name.indexOf("/"))),
87
+ ),
88
+ );
80
89
  });
81
90
  });
@@ -15,6 +15,9 @@ export default [
15
15
  "unicorn/filename-case": "off",
16
16
 
17
17
  // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-abusive-eslint-disable.md
18
+ // kept in eslint: oxlint's version reports rule names with more than one
19
+ // slash, like n/no-unsupported-features/node-builtins, as not specifying
20
+ // any rule (1.85, https://github.com/oxc-project/oxc/issues/27364)
18
21
  "unicorn/no-abusive-eslint-disable": "error",
19
22
 
20
23
  // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-process-exit.md
@@ -136,8 +136,9 @@ export default {
136
136
  "no-global-assign": "error",
137
137
 
138
138
  // https://eslint.org/docs/rules/no-implicit-globals
139
- // TODO to enable
140
- "no-implicit-globals": "warn",
139
+ // only reports in scripts: ES modules have their own scope, and node wraps
140
+ // CommonJS files in a function
141
+ "no-implicit-globals": "off",
141
142
 
142
143
  // https://eslint.org/docs/rules/no-implied-eval
143
144
  "no-implied-eval": "error",
@@ -9,6 +9,14 @@ const eslintRulePrefixes = new Map([
9
9
  ["node", "n/"],
10
10
  ["react", "react/"],
11
11
  ["jsx_a11y", "jsx-a11y/"],
12
+ // JS plugins: the eslint plugins themselves, loaded by oxlint
13
+ ["regexp", "regexp/"],
14
+ ["@pob", "@pob/"],
15
+ // named "<plugin>-js" when the name is reserved for a native plugin
16
+ ["eslint-js", ""],
17
+ ["unicorn-js", "unicorn/"],
18
+ ["node-js", "n/"],
19
+ ["react-js", "react/"],
12
20
  ]);
13
21
 
14
22
  /** oxlint plugins without eslint equivalent in @pob/eslint-config */
@@ -1,11 +1,14 @@
1
1
  import { describe, expect, it } from "vitest";
2
+ import pobPlugin from "@pob/eslint-plugin";
2
3
  import { Linter } from "eslint";
3
4
  import { builtinRules } from "eslint/use-at-your-own-risk";
4
5
  import importPlugin from "eslint-plugin-import-x";
5
6
  import nodePlugin from "eslint-plugin-n";
7
+ import regexpPlugin from "eslint-plugin-regexp";
6
8
  import eslintPluginUnicorn from "eslint-plugin-unicorn";
7
9
  import tseslint from "typescript-eslint";
8
10
  import oxlintBaseConfig from "../../oxlint/base.json" with { type: "json" };
11
+ import oxlintNodeConfig from "../../oxlint/node.json" with { type: "json" };
9
12
  import oxlintTypescriptConfig from "../../oxlint/typescript.json" with { type: "json" };
10
13
  import {
11
14
  createOxlintDisableDirectivesProcessor,
@@ -102,6 +105,11 @@ describe("oxlintToEslintRuleNames", () => {
102
105
  ["react/jsx-key", ["react/jsx-key"]],
103
106
  ["react/rules-of-hooks", ["react-hooks/rules-of-hooks"]],
104
107
  ["react/exhaustive-deps", ["react-hooks/exhaustive-deps"]],
108
+ ["react-js/jsx-no-leaked-render", ["react/jsx-no-leaked-render"]],
109
+ ["eslint-js/camelcase", ["camelcase"]],
110
+ ["eslint-js/dot-notation", ["dot-notation"]],
111
+ ["unicorn-js/prefer-switch", ["unicorn/prefer-switch"]],
112
+ ["node-js/no-deprecated-api", ["n/no-deprecated-api"]],
105
113
  ["oxc/no-map-spread", []],
106
114
  ["promise/valid-params", []],
107
115
  ["vitest/no-focused-tests", []],
@@ -163,6 +171,8 @@ describe("oxlint/*.json", () => {
163
171
  ["unicorn/", eslintPluginUnicorn],
164
172
  ["import-x/", importPlugin],
165
173
  ["n/", nodePlugin],
174
+ ["regexp/", regexpPlugin],
175
+ ["@pob/", pobPlugin],
166
176
  ];
167
177
  const eslintRuleNames = new Set([
168
178
  ...builtinRules.keys(),
@@ -175,8 +185,8 @@ describe("oxlint/*.json", () => {
175
185
 
176
186
  it.each([
177
187
  ...new Set(
178
- [oxlintBaseConfig, oxlintTypescriptConfig].flatMap((config) =>
179
- getOxlintConfigRuleNames(config),
188
+ [oxlintBaseConfig, oxlintNodeConfig, oxlintTypescriptConfig].flatMap(
189
+ (config) => getOxlintConfigRuleNames(config),
180
190
  ),
181
191
  ),
182
192
  ])("%s turns off existing eslint rules", (oxlintRuleName) => {
package/oxlint/base.json CHANGED
@@ -3,6 +3,12 @@
3
3
  "correctness": "off"
4
4
  },
5
5
  "plugins": ["import"],
6
+ "jsPlugins": [
7
+ { "name": "@pob", "specifier": "../lib/oxlint-plugins/pob.js" },
8
+ { "name": "regexp", "specifier": "../lib/oxlint-plugins/regexp.js" },
9
+ { "name": "eslint-js", "specifier": "../lib/oxlint-plugins/eslint.js" },
10
+ { "name": "unicorn-js", "specifier": "../lib/oxlint-plugins/unicorn.js" }
11
+ ],
6
12
  "rules": {
7
13
  "array-callback-return": [
8
14
  "error",
@@ -728,7 +734,6 @@
728
734
  }
729
735
  ],
730
736
  "unicorn/new-for-builtins": "error",
731
- "unicorn/no-abusive-eslint-disable": "error",
732
737
  "unicorn/no-accessor-recursion": "error",
733
738
  "unicorn/no-array-method-this-argument": "error",
734
739
  "unicorn/no-array-reduce": [
@@ -876,6 +881,126 @@
876
881
  }
877
882
  ],
878
883
  "unicorn/throw-new-error": "error",
884
+ "@pob/forbid-non-native-fetch-import": "error",
885
+ "eslint-js/camelcase": [
886
+ "error",
887
+ {
888
+ "allow": [],
889
+ "ignoreDestructuring": false,
890
+ "ignoreGlobals": false,
891
+ "ignoreImports": false,
892
+ "properties": "always"
893
+ }
894
+ ],
895
+ "eslint-js/dot-notation": [
896
+ "error",
897
+ {
898
+ "allowKeywords": true,
899
+ "allowPattern": ""
900
+ }
901
+ ],
902
+ "eslint-js/no-lone-blocks": "error",
903
+ "eslint-js/no-restricted-syntax": [
904
+ "error",
905
+ {
906
+ "selector": "ForInStatement",
907
+ "message": "for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array."
908
+ },
909
+ {
910
+ "selector": "LabeledStatement",
911
+ "message": "Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand."
912
+ },
913
+ {
914
+ "selector": "WithStatement",
915
+ "message": "`with` is disallowed in strict mode because it makes code impossible to predict and optimize."
916
+ }
917
+ ],
918
+ "eslint-js/no-undef-init": "error",
919
+ "regexp/confusing-quantifier": "warn",
920
+ "regexp/control-character-escape": "error",
921
+ "regexp/match-any": "error",
922
+ "regexp/negation": "error",
923
+ "regexp/no-contradiction-with-assertion": "error",
924
+ "regexp/no-dupe-characters-character-class": "error",
925
+ "regexp/no-dupe-disjunctions": "error",
926
+ "regexp/no-empty-alternative": "warn",
927
+ "regexp/no-empty-capturing-group": "error",
928
+ "regexp/no-empty-character-class": "error",
929
+ "regexp/no-empty-group": "error",
930
+ "regexp/no-empty-lookarounds-assertion": "error",
931
+ "regexp/no-empty-string-literal": "error",
932
+ "regexp/no-escape-backspace": "error",
933
+ "regexp/no-extra-lookaround-assertions": "error",
934
+ "regexp/no-invalid-regexp": "error",
935
+ "regexp/no-invisible-character": "error",
936
+ "regexp/no-lazy-ends": "warn",
937
+ "regexp/no-legacy-features": "error",
938
+ "regexp/no-misleading-capturing-group": "error",
939
+ "regexp/no-misleading-unicode-character": "error",
940
+ "regexp/no-missing-g-flag": "error",
941
+ "regexp/no-non-standard-flag": "error",
942
+ "regexp/no-obscure-range": "error",
943
+ "regexp/no-optional-assertion": "error",
944
+ "regexp/no-potentially-useless-backreference": "warn",
945
+ "regexp/no-super-linear-backtracking": "error",
946
+ "regexp/no-trivially-nested-assertion": "error",
947
+ "regexp/no-trivially-nested-quantifier": "error",
948
+ "regexp/no-unused-capturing-group": "error",
949
+ "regexp/no-useless-assertions": "error",
950
+ "regexp/no-useless-backreference": "error",
951
+ "regexp/no-useless-character-class": "error",
952
+ "regexp/no-useless-dollar-replacements": "error",
953
+ "regexp/no-useless-escape": "error",
954
+ "regexp/no-useless-flag": "warn",
955
+ "regexp/no-useless-lazy": "error",
956
+ "regexp/no-useless-non-capturing-group": "error",
957
+ "regexp/no-useless-quantifier": "error",
958
+ "regexp/no-useless-range": "error",
959
+ "regexp/no-useless-set-operand": "error",
960
+ "regexp/no-useless-string-literal": "error",
961
+ "regexp/no-useless-two-nums-quantifier": "error",
962
+ "regexp/no-zero-quantifier": "error",
963
+ "regexp/optimal-lookaround-quantifier": "warn",
964
+ "regexp/optimal-quantifier-concatenation": "error",
965
+ "regexp/prefer-character-class": "error",
966
+ "regexp/prefer-d": "error",
967
+ "regexp/prefer-plus-quantifier": "error",
968
+ "regexp/prefer-predefined-assertion": "error",
969
+ "regexp/prefer-question-quantifier": "error",
970
+ "regexp/prefer-range": "error",
971
+ "regexp/prefer-set-operation": "error",
972
+ "regexp/prefer-star-quantifier": "error",
973
+ "regexp/prefer-unicode-codepoint-escapes": "error",
974
+ "regexp/prefer-w": "error",
975
+ "regexp/simplify-set-operations": "error",
976
+ "regexp/sort-flags": "error",
977
+ "regexp/strict": "error",
978
+ "regexp/use-ignore-case": "error",
979
+ "unicorn-js/expiring-todo-comments": [
980
+ "error",
981
+ {
982
+ "terms": ["todo", "fixme", "xxx"],
983
+ "ignore": [],
984
+ "ignoreDates": false,
985
+ "ignoreDatesOnPullRequests": true,
986
+ "allowWarningComments": true
987
+ }
988
+ ],
989
+ "unicorn-js/no-unnecessary-polyfills": "error",
990
+ "unicorn-js/prefer-add-event-listener": [
991
+ "error",
992
+ {
993
+ "excludedPackages": ["koa", "sax"]
994
+ }
995
+ ],
996
+ "unicorn-js/prefer-json-parse-buffer": "error",
997
+ "unicorn-js/prefer-switch": [
998
+ "error",
999
+ {
1000
+ "minimumCases": 3,
1001
+ "emptyDefaultCase": "no-default-comment"
1002
+ }
1003
+ ],
879
1004
  "use-isnan": [
880
1005
  "error",
881
1006
  {
@@ -939,6 +1064,7 @@
939
1064
  "no-with": "off",
940
1065
  "prefer-promise-reject-errors": "off",
941
1066
  "require-await": "off",
1067
+ "eslint-js/dot-notation": "off",
942
1068
  "import/named": "off",
943
1069
  "import/no-anonymous-default-export": [
944
1070
  "error",
package/oxlint/node.json CHANGED
@@ -1,7 +1,23 @@
1
1
  {
2
2
  "plugins": ["node"],
3
+ "jsPlugins": [
4
+ { "name": "@pob", "specifier": "../lib/oxlint-plugins/pob.js" },
5
+ { "name": "node-js", "specifier": "../lib/oxlint-plugins/n.js" }
6
+ ],
3
7
  "rules": {
4
- "node/no-exports-assign": "error"
8
+ "@pob/forbid-non-native-node-imports": "error",
9
+ "node/no-exports-assign": "error",
10
+ "node-js/no-deprecated-api": "error",
11
+ "node-js/no-unpublished-bin": "error",
12
+ "node-js/no-unsupported-features/es-builtins": "error",
13
+ "node-js/no-unsupported-features/es-syntax": [
14
+ "error",
15
+ { "ignores": ["modules"] }
16
+ ],
17
+ "node-js/no-unsupported-features/node-builtins": [
18
+ "error",
19
+ { "ignores": ["localStorage", "sessionStorage", "Storage"] }
20
+ ]
5
21
  },
6
22
  "overrides": [
7
23
  {
@@ -14,7 +30,11 @@
14
30
  "files": ["**/*.{cjs,cts}"],
15
31
  "rules": {
16
32
  "node/no-new-require": "error",
17
- "node/no-path-concat": "error"
33
+ "node/no-path-concat": "error",
34
+ "node-js/no-unsupported-features/es-syntax": [
35
+ "error",
36
+ { "ignores": [] }
37
+ ]
18
38
  }
19
39
  },
20
40
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pob/eslint-config",
3
- "version": "67.9.0",
3
+ "version": "67.11.0",
4
4
  "description": "eslint config files",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/christophehurpeau/pob",
@@ -52,6 +52,7 @@
52
52
  "dependencies": {
53
53
  "@eslint/js": "^10.0.1",
54
54
  "@eslint/json": "^1.2.0",
55
+ "@pob/eslint-plugin": "66.5.0",
55
56
  "@typescript-eslint/eslint-plugin": "8.63.0",
56
57
  "@typescript-eslint/parser": "8.63.0",
57
58
  "check-package-dependencies": "^13.2.0",
@@ -60,11 +61,10 @@
60
61
  "eslint-plugin-n": "^17.24.0",
61
62
  "eslint-plugin-regexp": "^3.1.0",
62
63
  "eslint-plugin-unicorn": "^64.0.0",
63
- "typescript-eslint": "^8.63.0",
64
- "@pob/eslint-plugin": "66.4.0"
64
+ "typescript-eslint": "^8.63.0"
65
65
  },
66
66
  "devDependencies": {
67
- "@types/node": "24.13.3",
67
+ "@types/node": "24.19.1",
68
68
  "eslint": "10.8.1",
69
69
  "eslint-plugin-import-x": "4.17.1",
70
70
  "eslint-plugin-n": "17.24.0",