@biscuittin/eslint-config 0.0.4 → 0.0.6

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/dist/index.js CHANGED
@@ -12,8 +12,7 @@ import pluginJsonc from 'eslint-plugin-jsonc';
12
12
  import pluginNode from 'eslint-plugin-n';
13
13
  import pluginPerfectionist from 'eslint-plugin-perfectionist';
14
14
  import * as pluginReactCompiler from 'eslint-plugin-react-compiler';
15
- import pluginReactHooks from 'eslint-plugin-react-hooks';
16
- import pluginReactPreferFunctionComponent from 'eslint-plugin-react-prefer-function-component';
15
+ import * as pluginReactHooks from 'eslint-plugin-react-hooks';
17
16
  import pluginReactRefresh from 'eslint-plugin-react-refresh';
18
17
  import * as pluginRegexp from 'eslint-plugin-regexp';
19
18
  import pluginTailwindCSS from 'eslint-plugin-tailwindcss';
@@ -25,12 +24,13 @@ import path from 'node:path';
25
24
  import process from 'node:process';
26
25
  import { findUp } from 'find-up';
27
26
  import fsp from 'node:fs/promises';
28
- import parserJsonc from 'jsonc-eslint-parser';
27
+ import * as parserJsonc from 'jsonc-eslint-parser';
29
28
  import gitignore from 'eslint-config-flat-gitignore';
30
29
  import js from '@eslint/js';
30
+ import { createNodeResolver } from 'eslint-plugin-import-x/node-resolver.js';
31
31
  import globals from 'globals';
32
32
  export { default as globals } from 'globals';
33
- import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript';
33
+ import { defaultExtensions, createTypeScriptImportResolver } from 'eslint-import-resolver-typescript';
34
34
  import { FlatConfigComposer } from 'eslint-flat-config-utils';
35
35
  import { isPackageExists } from 'local-pkg';
36
36
 
@@ -149,12 +149,12 @@ async function loadLocalFile(name, cwd = process.cwd()) {
149
149
  function memo(function_, key) {
150
150
  var _a;
151
151
  let _key = key;
152
- if (_key === undefined || !_key) {
152
+ if (_key === void 0 || !_key) {
153
153
  if (typeof function_.toString !== "function") throw new TypeError("memo() requires a key!");
154
154
  _key = function_.toString();
155
155
  }
156
156
  globalThis.__ESLINT_PLUGIN_MEMO__ ?? (globalThis.__ESLINT_PLUGIN_MEMO__ = {});
157
- (_a = globalThis.__ESLINT_PLUGIN_MEMO__)[_key] || (_a[_key] = function_);
157
+ (_a = globalThis.__ESLINT_PLUGIN_MEMO__)[_key] ?? (_a[_key] = function_);
158
158
  return globalThis.__ESLINT_PLUGIN_MEMO__[_key];
159
159
  }
160
160
 
@@ -199,10 +199,6 @@ const plugins = {
199
199
  reactPlugins["@eslint-react/naming-convention"],
200
200
  "eslint-plugin-react-naming-convention"
201
201
  ),
202
- pluginReactPreferFunctionComponent: memo(
203
- pluginReactPreferFunctionComponent,
204
- "eslint-plugin-react-prefer-function-component"
205
- ),
206
202
  pluginReactRefresh: memo(pluginReactRefresh, "eslint-plugin-react-refresh"),
207
203
  pluginReactWebApi: memo(
208
204
  reactPlugins["@eslint-react/web-api"],
@@ -560,10 +556,6 @@ function imports(options = {}) {
560
556
  "unused-imports": plugins["pluginUnusedImports"],
561
557
  antfu: plugins["pluginAntfu"],
562
558
  perfectionist: plugins["pluginPerfectionist"]
563
- },
564
- languageOptions: {
565
- sourceType: "module",
566
- ecmaVersion: "latest"
567
559
  }
568
560
  },
569
561
  {
@@ -625,9 +617,10 @@ function imports(options = {}) {
625
617
  }
626
618
 
627
619
  const name$9 = getFlatConfigName("javascript");
628
- const files$5 = [GLOB_SRC];
620
+ const files$5 = [GLOB_JS, GLOB_JSX];
629
621
  const commonjsGlobalsOffList = Object.keys(globals.commonjs).map((key) => ({ [key]: "off" }));
630
622
  const commonjsGlobalsOff = Object.assign({}, ...commonjsGlobalsOffList);
623
+ const extensions = [".js", ".jsx", ".cjs", ".mjs"];
631
624
  function javascript(options = {}) {
632
625
  const { env = { browser: true }, module = true } = options;
633
626
  const sourceType = module ? "module" : "commonjs";
@@ -663,7 +656,10 @@ function javascript(options = {}) {
663
656
  }
664
657
  },
665
658
  settings: {
666
- "import-x/extensions": [".js", ".jsx", ".cjs", ".mjs"]
659
+ "import-x/extensions": extensions,
660
+ "import-x/resolver-next": [
661
+ createNodeResolver({ extensions })
662
+ ]
667
663
  }
668
664
  },
669
665
  {
@@ -1082,9 +1078,25 @@ function nextJs() {
1082
1078
 
1083
1079
  const name$5 = getFlatConfigName("node-js");
1084
1080
  const isModule = getPackageJson()?.type === "module";
1081
+ const globalsCommonJs = {
1082
+ ...globals.es2025,
1083
+ ...globals.node,
1084
+ ...globals.commonjs,
1085
+ __dirname: "readonly",
1086
+ __filename: "readonly"
1087
+ };
1088
+ const globalsModule = {
1089
+ ...globals.es2025,
1090
+ ...globals.node,
1091
+ __dirname: "off",
1092
+ __filename: "off",
1093
+ exports: "off",
1094
+ module: "off",
1095
+ require: "off"
1096
+ };
1085
1097
  function nodeJs(options = {}) {
1086
1098
  const { module = isModule, extraFiles = [] } = options;
1087
- const files = [GLOB_JS, ...extraFiles];
1099
+ const files = [GLOB_JS, GLOB_TS, ...extraFiles];
1088
1100
  return [
1089
1101
  {
1090
1102
  name: name$5.setup,
@@ -1093,27 +1105,11 @@ function nodeJs(options = {}) {
1093
1105
  node: plugins["pluginNode"]
1094
1106
  },
1095
1107
  languageOptions: {
1096
- sourceType: module ? "module" : "commonjs",
1097
1108
  ecmaVersion: "latest",
1098
1109
  parserOptions: {
1099
1110
  ecmaFeatures: {
1100
1111
  impliedStrict: true
1101
1112
  }
1102
- },
1103
- globals: {
1104
- ...globals.es2025,
1105
- ...globals.node,
1106
- ...module ? {
1107
- __dirname: "off",
1108
- __filename: "off",
1109
- exports: "off",
1110
- module: "off",
1111
- require: "off"
1112
- } : {
1113
- ...globals.commonjs,
1114
- __dirname: "readonly",
1115
- __filename: "readonly"
1116
- }
1117
1113
  }
1118
1114
  }
1119
1115
  },
@@ -1125,11 +1121,7 @@ function nodeJs(options = {}) {
1125
1121
  // pluginNode.configs.commons
1126
1122
  // Ref: https://github.com/eslint-community/eslint-plugin-n/blob/ccf5f9e482c32f2fd2d5f78649d7f837a5db8870/lib/configs/_commons.js#L6
1127
1123
  "node/no-deprecated-api": "error",
1128
- "node/no-extraneous-import": "error",
1129
- "node/no-extraneous-require": "error",
1130
1124
  "node/no-exports-assign": "error",
1131
- "node/no-missing-import": "error",
1132
- "node/no-missing-require": "error",
1133
1125
  "node/no-process-exit": "error",
1134
1126
  "node/no-unpublished-bin": "error",
1135
1127
  "node/no-unpublished-import": "error",
@@ -1139,6 +1131,11 @@ function nodeJs(options = {}) {
1139
1131
  "node/no-unsupported-features/node-builtins": "error",
1140
1132
  "node/process-exit-as-throw": "error",
1141
1133
  "node/hashbang": "error",
1134
+ // Will handled by `eslint-plugin-import-x`
1135
+ "node/no-extraneous-import": "off",
1136
+ "node/no-extraneous-require": "off",
1137
+ "node/no-missing-import": "off",
1138
+ "node/no-missing-require": "off",
1142
1139
  // Require error handling in callbacks
1143
1140
  "node/handle-callback-err": ["error", "^error$"],
1144
1141
  // Disallow `new` operators with calls to `require`
@@ -1159,21 +1156,54 @@ function nodeJs(options = {}) {
1159
1156
  }
1160
1157
  }
1161
1158
  },
1159
+ {
1160
+ name: name$5.script,
1161
+ files: ["**/*.[jt]s"],
1162
+ languageOptions: {
1163
+ sourceType: module ? "module" : "commonjs",
1164
+ parserOptions: {
1165
+ ecmaFeatures: {
1166
+ globalReturn: !module
1167
+ }
1168
+ },
1169
+ globals: {
1170
+ ...module ? globalsModule : globalsCommonJs
1171
+ }
1172
+ }
1173
+ },
1162
1174
  {
1163
1175
  name: name$5.commonjs,
1164
- files: ["*.c[jt]s", ".*.c[jt]s"],
1176
+ files: ["**/*.c[jt]s"],
1165
1177
  languageOptions: {
1166
1178
  sourceType: "commonjs",
1179
+ parserOptions: {
1180
+ ecmaFeatures: {
1181
+ globalReturn: true
1182
+ }
1183
+ },
1167
1184
  globals: {
1168
- ...globals.commonjs,
1169
- __dirname: "readonly",
1170
- __filename: "readonly"
1185
+ ...globalsCommonJs
1171
1186
  }
1172
1187
  },
1173
1188
  rules: {
1174
1189
  strict: ["error", "global"],
1175
1190
  "node/no-unsupported-features/es-syntax": ["error", { ignores: [] }]
1176
1191
  }
1192
+ },
1193
+ {
1194
+ name: name$5.module,
1195
+ files: ["**/*.m[jt]s"],
1196
+ languageOptions: {
1197
+ sourceType: "module",
1198
+ parserOptions: {
1199
+ ecmaFeatures: {
1200
+ globalReturn: false
1201
+ }
1202
+ },
1203
+ globals: {
1204
+ ...globalsModule
1205
+ }
1206
+ }
1177
1207
  }
1178
1208
  ];
1179
1209
  }
@@ -1190,7 +1220,6 @@ function react(options = {}) {
1190
1220
  "react-hooks": plugins["pluginReactHooks"],
1191
1221
  "react-compiler": plugins["pluginReactCompiler"],
1192
1222
  "react-refresh": plugins["pluginReactRefresh"],
1193
- "react-prefer-function-component": plugins["pluginReactPreferFunctionComponent"],
1194
1223
  "jsx-a11y": plugins["pluginJsxA11y"],
1195
1224
  "@stylistic/jsx": plugins["pluginStylisticJsx"],
1196
1225
  "@eslint-react": plugins["pluginReact"],
@@ -1202,12 +1231,17 @@ function react(options = {}) {
1202
1231
  },
1203
1232
  settings: {
1204
1233
  "react-x": {
1205
- additionalHooks: {
1206
- useLayoutEffect: ["useIsomorphicLayoutEffect"]
1207
- },
1234
+ importSource: "react",
1235
+ jsxPragma: "createElement",
1236
+ jsxPragmaFrag: "Fragment",
1208
1237
  polymorphicPropName: "as",
1238
+ strict: true,
1209
1239
  strictImportCheck: true,
1210
- version: "detect"
1240
+ version: "detect",
1241
+ additionalHooks: {
1242
+ useEffect: ["useIsomorphicLayoutEffect"],
1243
+ useLayoutEffect: ["useIsomorphicLayoutEffect"]
1244
+ }
1211
1245
  }
1212
1246
  }
1213
1247
  },
@@ -1225,9 +1259,6 @@ function react(options = {}) {
1225
1259
  // eslint-plugin-react-refresh
1226
1260
  // https://github.com/ArnaudBarre/eslint-plugin-react-refresh
1227
1261
  "react-refresh/only-export-components": "warn",
1228
- // eslint-plugin-react-prefer-function-component
1229
- // https://github.com/tatethurston/eslint-plugin-react-prefer-function-component
1230
- "react-prefer-function-component/react-prefer-function-component": "error",
1231
1262
  // @eslint-sukka/eslint-plugin-react-jsx-a11y
1232
1263
  // https://github.com/SukkaW/eslint-config-sukka/tree/master/packages/eslint-plugin-react-jsx-a11y
1233
1264
  // Copied from SukkaW/eslint-config-sukka
@@ -1247,6 +1278,7 @@ function react(options = {}) {
1247
1278
  ...pluginReact.configs.recommended.rules,
1248
1279
  "@eslint-react/ensure-forward-ref-using-ref": "error",
1249
1280
  "@eslint-react/no-duplicate-jsx-props": "error",
1281
+ "@eslint-react/no-duplicate-key": "error",
1250
1282
  "@eslint-react/no-children-count": "error",
1251
1283
  "@eslint-react/no-children-for-each": "error",
1252
1284
  "@eslint-react/no-children-only": "error",
@@ -1414,6 +1446,7 @@ const typescriptStylisticTypeCheckedRules = Object.assign(
1414
1446
  {},
1415
1447
  ...typescriptStylisticTypeCheckedRuleList
1416
1448
  );
1449
+ const externalModuleFolders = ["node_modules", "node_modules/@types"];
1417
1450
  function typescript(options = {}) {
1418
1451
  const {
1419
1452
  isInEditor = false,
@@ -1428,6 +1461,10 @@ function typescript(options = {}) {
1428
1461
  GLOB_TSX,
1429
1462
  ...extraFileExtensions.map((extension) => `**/*${extension}`)
1430
1463
  ];
1464
+ const extensions = [".cjs", ".mjs", ".cts", ".mts", ...defaultExtensions, ...extraFileExtensions];
1465
+ if (process.versions["pnp"]) {
1466
+ externalModuleFolders.push(".yarn");
1467
+ }
1431
1468
  const tsProjectOptions = tsconfigPath === true ? {
1432
1469
  projectService: {
1433
1470
  allowDefaultProject,
@@ -1460,18 +1497,8 @@ function typescript(options = {}) {
1460
1497
  }
1461
1498
  },
1462
1499
  settings: {
1463
- "import-x/extensions": [
1464
- ".js",
1465
- ".jsx",
1466
- ".cjs",
1467
- ".mjs",
1468
- ".ts",
1469
- ".tsx",
1470
- ".cts",
1471
- ".mts",
1472
- ...extraFileExtensions
1473
- ],
1474
- "import-x/external-module-folders": ["node_modules", "node_modules/@types"],
1500
+ "import-x/extensions": extensions,
1501
+ "import-x/external-module-folders": externalModuleFolders,
1475
1502
  "import-x/parsers": {
1476
1503
  "@typescript-eslint/parser": [".ts", ".tsx", ".cts", ".mts", ...extraFileExtensions]
1477
1504
  },
@@ -1480,17 +1507,8 @@ function typescript(options = {}) {
1480
1507
  // https://github.com/import-js/eslint-import-resolver-typescript
1481
1508
  createTypeScriptImportResolver({
1482
1509
  alwaysTryTypes: true,
1483
- project: tsconfigPath === true ? undefined : tsconfigPath,
1484
- extensions: [
1485
- ".ts",
1486
- ".tsx",
1487
- ".d.ts",
1488
- ".js",
1489
- ".jsx",
1490
- ".json",
1491
- ".node",
1492
- ...extraFileExtensions
1493
- ]
1510
+ project: tsconfigPath === true ? void 0 : tsconfigPath,
1511
+ extensions
1494
1512
  })
1495
1513
  ]
1496
1514
  }
@@ -1638,19 +1656,16 @@ function unicorn() {
1638
1656
 
1639
1657
  function enabled(options, defaults = false) {
1640
1658
  if (typeof options === "boolean") return options;
1641
- if (options === undefined) return defaults;
1659
+ if (options === void 0) return defaults;
1642
1660
  if (options.enable) return true;
1643
1661
  return defaults;
1644
1662
  }
1645
1663
  function configOptions(options, defaultOptions) {
1646
1664
  const isInEditor = isInEditorEnv();
1647
- if (options === undefined) return { isInEditor };
1665
+ if (options === void 0) return { isInEditor };
1648
1666
  if (typeof options === "boolean") return { isInEditor };
1649
1667
  return { ...defaultOptions, ...options, isInEditor };
1650
1668
  }
1651
- const pluginRenaming = {
1652
- "import-x": "import"
1653
- };
1654
1669
  async function config(options, ...userConfigs) {
1655
1670
  const configs = [];
1656
1671
  const enableTypeScript = enabled(options?.typescript, isPackageExists("typescript"));
@@ -1685,7 +1700,7 @@ async function config(options, ...userConfigs) {
1685
1700
  if (enabled(options?.node, isPackageExists("@types/node"))) {
1686
1701
  configs.push(nodeJs(configOptions(options?.node)));
1687
1702
  }
1688
- if (enabled(undefined, isPackageExists("tailwindcss"))) {
1703
+ if (enabled(void 0, isPackageExists("tailwindcss"))) {
1689
1704
  configs.push(tailwindcss());
1690
1705
  }
1691
1706
  configs.push(regexp(), unicorn(), disables());
@@ -1701,7 +1716,7 @@ async function config(options, ...userConfigs) {
1701
1716
  }
1702
1717
  let composer = new FlatConfigComposer(...configs);
1703
1718
  const _userConfigs = userConfigs;
1704
- composer = composer.append(..._userConfigs).renamePlugins(pluginRenaming);
1719
+ composer = composer.append(..._userConfigs);
1705
1720
  return composer;
1706
1721
  }
1707
1722
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@biscuittin/eslint-config",
3
3
  "type": "module",
4
- "version": "0.0.4",
4
+ "version": "0.0.6",
5
5
  "description": "A collection of ESLint configurations for Biscuit Tin projects.",
6
6
  "author": "Biscuit Tin <opensource@biscuitt.in>",
7
7
  "license": "MIT",
@@ -28,7 +28,10 @@
28
28
  "peerDependencies": {
29
29
  "@typescript-eslint/parser": ">=8.17.0",
30
30
  "dprint": ">=0.47.0",
31
- "eslint": ">=9.15.0"
31
+ "eslint": ">=9.15.0",
32
+ "tailwindcss": ">=3.4.0 <4",
33
+ "ts-api-utils": "^2.0.1",
34
+ "typescript": "^5.7.3"
32
35
  },
33
36
  "peerDependenciesMeta": {
34
37
  "@typescript-eslint/parser": {
@@ -39,40 +42,48 @@
39
42
  },
40
43
  "eslint": {
41
44
  "optional": true
45
+ },
46
+ "tailwindcss": {
47
+ "optional": true
48
+ },
49
+ "ts-api-utils": {
50
+ "optional": true
51
+ },
52
+ "typescript": {
53
+ "optional": true
42
54
  }
43
55
  },
44
56
  "dependencies": {
45
57
  "@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
46
- "@eslint-react/eslint-plugin": "^1.24.1",
47
- "@eslint-sukka/eslint-plugin-react-jsx-a11y": "^6.13.1",
48
- "@eslint/js": "^9.17.0",
49
- "@eslint/json": "^0.10.0",
50
- "@next/eslint-plugin-next": "^15.1.6",
58
+ "@eslint-react/eslint-plugin": "^1.37.3",
59
+ "@eslint-sukka/eslint-plugin-react-jsx-a11y": "^6.17.1",
60
+ "@eslint/js": "^9.23.0",
61
+ "@eslint/json": "^0.11.0",
62
+ "@next/eslint-plugin-next": "^15.2.3",
51
63
  "@package-json/types": "^0.0.11",
52
- "@stylistic/eslint-plugin-jsx": "^3.0.0",
53
- "eslint-config-flat-gitignore": "^1.0.0",
54
- "eslint-flat-config-utils": "^2.0.0",
55
- "eslint-import-resolver-typescript": "^3.7.0",
56
- "eslint-plugin-antfu": "^3.0.0",
64
+ "@stylistic/eslint-plugin-jsx": "^4.2.0",
65
+ "eslint-config-flat-gitignore": "^2.1.0",
66
+ "eslint-flat-config-utils": "^2.0.1",
67
+ "eslint-import-resolver-typescript": "^4.2.2",
68
+ "eslint-plugin-antfu": "^3.1.1",
57
69
  "eslint-plugin-autofix": "^2.2.0",
58
70
  "eslint-plugin-format": "^1.0.1",
59
- "eslint-plugin-import-x": "^4.5.1",
71
+ "eslint-plugin-import-x": "^4.9.1",
60
72
  "eslint-plugin-jsonc": "^2.19.1",
61
- "eslint-plugin-n": "^17.15.0",
62
- "eslint-plugin-perfectionist": "^4.7.0",
63
- "eslint-plugin-react-compiler": "19.0.0-beta-decd7b8-20250118",
64
- "eslint-plugin-react-hooks": "^5.1.0",
65
- "eslint-plugin-react-prefer-function-component": "^3.4.0",
66
- "eslint-plugin-react-refresh": "^0.4.16",
73
+ "eslint-plugin-n": "^17.16.2",
74
+ "eslint-plugin-perfectionist": "^4.10.1",
75
+ "eslint-plugin-react-compiler": "19.0.0-beta-aeaed83-20250323",
76
+ "eslint-plugin-react-hooks": "^5.2.0",
77
+ "eslint-plugin-react-refresh": "^0.4.19",
67
78
  "eslint-plugin-regexp": "^2.7.0",
68
79
  "eslint-plugin-tailwindcss": "^3.18.0",
69
- "eslint-plugin-unicorn": "^56.0.1",
80
+ "eslint-plugin-unicorn": "^57.0.0",
70
81
  "eslint-plugin-unused-imports": "^4.1.4",
71
82
  "find-up": "^7.0.0",
72
- "globals": "^15.14.0",
83
+ "globals": "^16.0.0",
73
84
  "jsonc-eslint-parser": "^2.4.0",
74
- "local-pkg": "^1.0.0",
75
- "typescript-eslint": "^8.21.0"
85
+ "local-pkg": "^1.1.1",
86
+ "typescript-eslint": "^8.27.0"
76
87
  },
77
88
  "scripts": {
78
89
  "build:inspector": "eslint-config-inspector build --config eslint-inspector.config.ts",