@bfra.me/eslint-config 0.50.2 → 0.51.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/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import "./chunk-EGRHWZRV.js";
2
2
 
3
3
  // src/define-config.ts
4
- import { isPackageExists as isPackageExists4 } from "local-pkg";
4
+ import { isPackageExists as isPackageExists3 } from "local-pkg";
5
5
 
6
6
  // ../es/src/env/ci.ts
7
7
  import isCI from "is-in-ci";
@@ -147,7 +147,7 @@ var GLOB_EXCLUDE = [
147
147
  import { fileURLToPath } from "url";
148
148
 
149
149
  // package.json
150
- var version = "0.50.2";
150
+ var version = "0.51.0";
151
151
 
152
152
  // src/parsers/any-parser.ts
153
153
  var lineBreakPattern = /\r\n|[\n\r\u2028\u2029]/u;
@@ -1287,7 +1287,6 @@ async function pnpm() {
1287
1287
 
1288
1288
  // src/configs/prettier.ts
1289
1289
  import process4 from "process";
1290
- import { isPackageExists as isPackageExists2 } from "local-pkg";
1291
1290
  function getConfigRules(configs) {
1292
1291
  if (Array.isArray(configs)) {
1293
1292
  const configWithRules = [...configs].reverse().find(
@@ -1309,8 +1308,8 @@ async function prettier(options = {}) {
1309
1308
  const [configPrettier, pluginPrettier, pluginJsonc, pluginYaml] = await Promise.all([
1310
1309
  interopDefault(import("eslint-config-prettier")),
1311
1310
  interopDefault(import("eslint-plugin-prettier")),
1312
- isPackageExists2("eslint-plugin-jsonc") ? interopDefault(import("eslint-plugin-jsonc")) : Promise.resolve(void 0),
1313
- isPackageExists2("eslint-plugin-yml") ? interopDefault(import("eslint-plugin-yml")) : Promise.resolve(void 0)
1311
+ interopDefault(import("eslint-plugin-jsonc")).catch(() => void 0),
1312
+ interopDefault(import("eslint-plugin-yml")).catch(() => void 0)
1314
1313
  ]);
1315
1314
  const jsoncPrettierRules = getConfigRules(pluginJsonc?.configs.prettier);
1316
1315
  const yamlPrettierRules = getConfigRules(pluginYaml?.configs.prettier);
@@ -1371,7 +1370,7 @@ async function prettier(options = {}) {
1371
1370
  }
1372
1371
 
1373
1372
  // src/configs/react.ts
1374
- import { isPackageExists as isPackageExists3 } from "local-pkg";
1373
+ import { isPackageExists as isPackageExists2 } from "local-pkg";
1375
1374
  var ReactRefreshAllowConstantExportPackages = ["vite"];
1376
1375
  var RemixPackages = ["@remix-run/node", "@remix-run/react", "@remix-run/serve", "@remix-run/dev"];
1377
1376
  var ReactRouterPackages = [
@@ -1382,8 +1381,8 @@ var ReactRouterPackages = [
1382
1381
  ];
1383
1382
  var NextJsPackages = ["next"];
1384
1383
  var ReactTypeAwareRules = {
1385
- "react/no-implicit-key": "warn",
1386
- "react/no-leaked-conditional-rendering": "warn"
1384
+ "@eslint-react/no-implicit-key": "warn",
1385
+ "@eslint-react/no-leaked-conditional-rendering": "warn"
1387
1386
  };
1388
1387
  async function react(options = {}) {
1389
1388
  const {
@@ -1397,31 +1396,25 @@ async function react(options = {}) {
1397
1396
  } = options;
1398
1397
  const isTypeAware = typeof tsconfigPath === "string" && tsconfigPath.trim().length > 0;
1399
1398
  return requireOf(
1400
- ["@eslint-react/eslint-plugin", "eslint-plugin-react-hooks", "eslint-plugin-react-refresh"],
1399
+ ["@eslint-react/eslint-plugin", "eslint-plugin-react-refresh"],
1401
1400
  async () => {
1402
- const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all([
1401
+ const [pluginReact, pluginReactRefresh] = await Promise.all([
1403
1402
  interopDefault(import("@eslint-react/eslint-plugin")),
1404
- interopDefault(import("eslint-plugin-react-hooks")),
1405
1403
  import("eslint-plugin-react-refresh").then((m) => m.reactRefresh)
1406
1404
  ]);
1407
1405
  const plugins = pluginReact.configs.all.plugins;
1408
1406
  const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
1409
- (i) => isPackageExists3(i)
1407
+ (i) => isPackageExists2(i)
1410
1408
  );
1411
- const isUsingRemix = RemixPackages.some((i) => isPackageExists3(i));
1412
- const isUsingReactRouter = ReactRouterPackages.some((i) => isPackageExists3(i));
1413
- const isUsingNext = NextJsPackages.some((i) => isPackageExists3(i));
1409
+ const isUsingRemix = RemixPackages.some((i) => isPackageExists2(i));
1410
+ const isUsingReactRouter = ReactRouterPackages.some((i) => isPackageExists2(i));
1411
+ const isUsingNext = NextJsPackages.some((i) => isPackageExists2(i));
1414
1412
  return [
1415
1413
  {
1416
1414
  name: "@bfra.me/react/setup",
1417
1415
  plugins: {
1418
- react: plugins["@eslint-react"],
1419
- "react-dom": plugins["@eslint-react/dom"],
1420
- "react-hooks": pluginReactHooks,
1421
- "react-hooks-extra": plugins["@eslint-react/hooks-extra"],
1422
- "react-naming-convention": plugins["@eslint-react/naming-convention"],
1423
- "react-refresh": pluginReactRefresh.plugin,
1424
- "react-web-api": plugins["@eslint-react/web-api"]
1416
+ ...plugins,
1417
+ "react-refresh": pluginReactRefresh.plugin
1425
1418
  }
1426
1419
  },
1427
1420
  {
@@ -1436,26 +1429,7 @@ async function react(options = {}) {
1436
1429
  sourceType: "module"
1437
1430
  },
1438
1431
  rules: {
1439
- // recommended rules from eslint-plugin-react-dom https://eslint-react.xyz/docs/rules/overview#dom-rules
1440
- "react-dom/no-namespace": "error",
1441
- "react-dom/no-dangerously-set-innerhtml": "warn",
1442
- "react-dom/no-dangerously-set-innerhtml-with-children": "error",
1443
- "react-dom/no-find-dom-node": "error",
1444
- "react-dom/no-flush-sync": "error",
1445
- "react-dom/no-hydrate": "error",
1446
- "react-dom/no-missing-button-type": "warn",
1447
- "react-dom/no-missing-iframe-sandbox": "warn",
1448
- "react-dom/no-render": "error",
1449
- "react-dom/no-render-return-value": "error",
1450
- "react-dom/no-script-url": "warn",
1451
- "react-dom/no-unsafe-iframe-sandbox": "warn",
1452
- "react-dom/no-unsafe-target-blank": "warn",
1453
- "react-dom/no-use-form-state": "error",
1454
- "react-dom/no-void-elements-with-children": "error",
1455
- // recommended rules from eslint-plugin-react-hooks-extra https://eslint-react.xyz/docs/rules/overview#hooks-extra-rules
1456
- "react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
1457
- // recommended rules eslint-plugin-react-hooks https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks/src/rules
1458
- ...pluginReactHooks.configs.recommended.rules,
1432
+ ...pluginReact.configs.recommended.rules,
1459
1433
  // preconfigured rules from eslint-plugin-react-refresh https://github.com/ArnaudBarre/eslint-plugin-react-refresh/tree/main/src
1460
1434
  "react-refresh/only-export-components": [
1461
1435
  "warn",
@@ -1491,51 +1465,6 @@ async function react(options = {}) {
1491
1465
  ]
1492
1466
  }
1493
1467
  ],
1494
- // recommended rules from eslint-plugin-react-web-api https://eslint-react.xyz/docs/rules/overview#web-api-rules
1495
- "react-web-api/no-leaked-event-listener": "warn",
1496
- "react-web-api/no-leaked-interval": "warn",
1497
- "react-web-api/no-leaked-resize-observer": "warn",
1498
- "react-web-api/no-leaked-timeout": "warn",
1499
- // recommended rules from eslint-plugin-react-x https://eslint-react.xyz/docs/rules/overview#core-rules
1500
- "react/jsx-no-comment-textnodes": "warn",
1501
- "react/jsx-no-duplicate-props": "warn",
1502
- "react/jsx-uses-vars": "warn",
1503
- "react/no-access-state-in-setstate": "error",
1504
- "react/no-array-index-key": "warn",
1505
- "react/no-children-count": "warn",
1506
- "react/no-children-for-each": "warn",
1507
- "react/no-children-map": "warn",
1508
- "react/no-children-only": "warn",
1509
- "react/no-children-to-array": "warn",
1510
- "react/no-clone-element": "warn",
1511
- "react/no-component-will-mount": "error",
1512
- "react/no-component-will-receive-props": "error",
1513
- "react/no-component-will-update": "error",
1514
- "react/no-context-provider": "warn",
1515
- "react/no-create-ref": "error",
1516
- "react/no-default-props": "error",
1517
- "react/no-direct-mutation-state": "error",
1518
- "react/no-duplicate-key": "warn",
1519
- "react/no-forward-ref": "warn",
1520
- "react/no-missing-key": "error",
1521
- "react/no-nested-component-definitions": "error",
1522
- "react/no-prop-types": "error",
1523
- "react/no-redundant-should-component-update": "error",
1524
- "react/no-set-state-in-component-did-mount": "warn",
1525
- "react/no-set-state-in-component-did-update": "warn",
1526
- "react/no-set-state-in-component-will-update": "warn",
1527
- "react/no-string-refs": "error",
1528
- "react/no-unnecessary-use-prefix": "warn",
1529
- "react/no-unsafe-component-will-mount": "warn",
1530
- "react/no-unsafe-component-will-receive-props": "warn",
1531
- "react/no-unsafe-component-will-update": "warn",
1532
- "react/no-unstable-context-value": "warn",
1533
- "react/no-unstable-default-props": "warn",
1534
- "react/no-unused-class-component-members": "warn",
1535
- "react/no-unused-state": "warn",
1536
- "react/no-use-context": "warn",
1537
- "react/no-useless-forward-ref": "warn",
1538
- "react/prefer-use-state-lazy-initialization": "warn",
1539
1468
  ...overrides
1540
1469
  }
1541
1470
  },
@@ -2306,10 +2235,10 @@ async function defineConfig(options = {}, ...userConfigs) {
2306
2235
  packageJson: enablePackageJson = false,
2307
2236
  perfectionist: enablePerfectionist = true,
2308
2237
  pnpm: enableCatalogs = false,
2309
- prettier: enablePrettier = isPackageExists4("prettier"),
2238
+ prettier: enablePrettier = isPackageExists3("prettier"),
2310
2239
  react: enableReact = false,
2311
2240
  regexp: enableRegexp = true,
2312
- typescript: enableTypeScript = isPackageExists4("typescript"),
2241
+ typescript: enableTypeScript = isPackageExists3("typescript"),
2313
2242
  unicorn: enableUnicorn = true
2314
2243
  } = options;
2315
2244
  let isInEditor = options.isInEditor;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bfra.me/eslint-config",
3
- "version": "0.50.2",
3
+ "version": "0.51.0",
4
4
  "description": "Shared ESLint configuration for bfra.me",
5
5
  "keywords": [
6
6
  "bfra.me",
@@ -38,7 +38,7 @@
38
38
  ],
39
39
  "dependencies": {
40
40
  "@eslint-community/eslint-plugin-eslint-comments": "4.7.1",
41
- "@eslint/markdown": "7.5.1",
41
+ "@eslint/markdown": "8.0.1",
42
42
  "@stylistic/eslint-plugin": "5.10.0",
43
43
  "eslint-config-flat-gitignore": "2.3.0",
44
44
  "eslint-flat-config-utils": "3.1.0",
@@ -52,30 +52,30 @@
52
52
  "eslint-plugin-perfectionist": "5.8.0",
53
53
  "eslint-plugin-regexp": "3.1.0",
54
54
  "eslint-plugin-toml": "1.3.1",
55
- "eslint-plugin-unicorn": "63.0.0",
55
+ "eslint-plugin-unicorn": "64.0.0",
56
56
  "eslint-plugin-unused-imports": "4.4.1",
57
57
  "eslint-plugin-yml": "3.3.1",
58
- "globals": "17.4.0",
58
+ "globals": "17.5.0",
59
59
  "is-in-ci": "2.0.0",
60
60
  "local-pkg": "1.1.2",
61
61
  "package-manager-detector": "1.6.0",
62
62
  "sort-package-json": "3.6.1",
63
- "typescript-eslint": "8.58.0",
63
+ "typescript-eslint": "8.58.1",
64
64
  "@bfra.me/es": "0.1.0"
65
65
  },
66
66
  "devDependencies": {
67
- "@eslint-react/eslint-plugin": "2.13.0",
67
+ "@eslint-react/eslint-plugin": "4.2.3",
68
68
  "@eslint/config-inspector": "1.5.0",
69
- "@eslint/core": "1.1.1",
70
- "@next/eslint-plugin-next": "16.2.2",
69
+ "@eslint/core": "1.2.1",
70
+ "@next/eslint-plugin-next": "16.2.3",
71
71
  "@types/eslint-config-prettier": "6.11.3",
72
72
  "@types/eslint-plugin-jsx-a11y": "6.10.1",
73
- "@typescript-eslint/types": "8.58.0",
74
- "@vitest/eslint-plugin": "1.6.14",
73
+ "@typescript-eslint/types": "8.58.1",
74
+ "@vitest/eslint-plugin": "1.6.15",
75
75
  "astro-eslint-parser": "1.4.0",
76
- "eslint": "10.1.0",
76
+ "eslint": "10.2.0",
77
77
  "eslint-config-prettier": "10.1.8",
78
- "eslint-plugin-astro": "1.6.0",
78
+ "eslint-plugin-astro": "1.7.0",
79
79
  "eslint-plugin-erasable-syntax-only": "0.4.0",
80
80
  "eslint-plugin-jsx-a11y": "6.10.2",
81
81
  "eslint-plugin-node-dependencies": "2.2.0",
@@ -84,12 +84,12 @@
84
84
  "eslint-plugin-react-hooks": "7.0.1",
85
85
  "eslint-plugin-react-refresh": "0.5.2",
86
86
  "eslint-typegen": "2.3.1",
87
- "@bfra.me/prettier-config": "0.16.7",
88
- "@bfra.me/tsconfig": "0.12.2",
87
+ "@bfra.me/tsconfig": "0.13.0",
88
+ "@bfra.me/prettier-config": "0.16.8",
89
89
  "@bfra.me/works": "0.0.0-development"
90
90
  },
91
91
  "peerDependencies": {
92
- "@eslint-react/eslint-plugin": "^2.2.3",
92
+ "@eslint-react/eslint-plugin": "^4.2.3",
93
93
  "@next/eslint-plugin-next": ">=15.5.3",
94
94
  "@vitest/eslint-plugin": "^1.1.21",
95
95
  "astro-eslint-parser": "^1.2.2",
@@ -1,7 +1,6 @@
1
1
  import type {Config} from '../config'
2
2
  import type {Flatten, OptionsIsInEditor, OptionsOverrides} from '../options'
3
3
  import process from 'node:process'
4
- import {isPackageExists} from 'local-pkg'
5
4
  import {GLOB_EXT_IN_MARKDOWN_FILES, GLOB_MARKDOWN_FILES, GLOB_TOML_FILES} from '../globs'
6
5
  import {requireOf} from '../require-of'
7
6
  import {interopDefault} from '../utils'
@@ -46,12 +45,8 @@ export async function prettier(options: PrettierOptions = {}): Promise<Config[]>
46
45
  const [configPrettier, pluginPrettier, pluginJsonc, pluginYaml] = await Promise.all([
47
46
  interopDefault(import('eslint-config-prettier')),
48
47
  interopDefault(import('eslint-plugin-prettier')),
49
- isPackageExists('eslint-plugin-jsonc')
50
- ? interopDefault(import('eslint-plugin-jsonc'))
51
- : Promise.resolve(undefined),
52
- isPackageExists('eslint-plugin-yml')
53
- ? interopDefault(import('eslint-plugin-yml'))
54
- : Promise.resolve(undefined),
48
+ interopDefault(import('eslint-plugin-jsonc')).catch(() => undefined),
49
+ interopDefault(import('eslint-plugin-yml')).catch(() => undefined),
55
50
  ])
56
51
  const jsoncPrettierRules = getConfigRules(pluginJsonc?.configs.prettier)
57
52
  const yamlPrettierRules = getConfigRules(pluginYaml?.configs.prettier)
@@ -1,4 +1,3 @@
1
- import type {Plugin} from '@eslint/core'
2
1
  import type {Config} from '../config'
3
2
  import type {
4
3
  Flatten,
@@ -25,8 +24,8 @@ const ReactRouterPackages = [
25
24
  const NextJsPackages = ['next']
26
25
 
27
26
  const ReactTypeAwareRules: Config['rules'] = {
28
- 'react/no-implicit-key': 'warn',
29
- 'react/no-leaked-conditional-rendering': 'warn',
27
+ '@eslint-react/no-implicit-key': 'warn',
28
+ '@eslint-react/no-leaked-conditional-rendering': 'warn',
30
29
  }
31
30
 
32
31
  /**
@@ -77,15 +76,14 @@ export async function react(options: ReactOptions = {}): Promise<Config[]> {
77
76
  const isTypeAware = typeof tsconfigPath === 'string' && tsconfigPath.trim().length > 0
78
77
 
79
78
  return requireOf(
80
- ['@eslint-react/eslint-plugin', 'eslint-plugin-react-hooks', 'eslint-plugin-react-refresh'],
79
+ ['@eslint-react/eslint-plugin', 'eslint-plugin-react-refresh'],
81
80
  async () => {
82
- const [pluginReact, pluginReactHooks, pluginReactRefresh] = await Promise.all([
81
+ const [pluginReact, pluginReactRefresh] = await Promise.all([
83
82
  interopDefault(import('@eslint-react/eslint-plugin')),
84
- interopDefault(import('eslint-plugin-react-hooks')),
85
83
  import('eslint-plugin-react-refresh').then(m => m.reactRefresh),
86
84
  ] as const)
87
85
 
88
- const plugins = (pluginReact.configs.all as {plugins: Record<string, Plugin>}).plugins
86
+ const plugins = pluginReact.configs.all.plugins as NonNullable<Config['plugins']>
89
87
  const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(i =>
90
88
  isPackageExists(i),
91
89
  )
@@ -97,13 +95,8 @@ export async function react(options: ReactOptions = {}): Promise<Config[]> {
97
95
  {
98
96
  name: '@bfra.me/react/setup',
99
97
  plugins: {
100
- react: plugins['@eslint-react'],
101
- 'react-dom': plugins['@eslint-react/dom'],
102
- 'react-hooks': pluginReactHooks,
103
- 'react-hooks-extra': plugins['@eslint-react/hooks-extra'],
104
- 'react-naming-convention': plugins['@eslint-react/naming-convention'],
98
+ ...plugins,
105
99
  'react-refresh': pluginReactRefresh.plugin,
106
- 'react-web-api': plugins['@eslint-react/web-api'],
107
100
  } as Config['plugins'],
108
101
  },
109
102
  {
@@ -118,28 +111,7 @@ export async function react(options: ReactOptions = {}): Promise<Config[]> {
118
111
  sourceType: 'module',
119
112
  },
120
113
  rules: {
121
- // recommended rules from eslint-plugin-react-dom https://eslint-react.xyz/docs/rules/overview#dom-rules
122
- 'react-dom/no-namespace': 'error',
123
- 'react-dom/no-dangerously-set-innerhtml': 'warn',
124
- 'react-dom/no-dangerously-set-innerhtml-with-children': 'error',
125
- 'react-dom/no-find-dom-node': 'error',
126
- 'react-dom/no-flush-sync': 'error',
127
- 'react-dom/no-hydrate': 'error',
128
- 'react-dom/no-missing-button-type': 'warn',
129
- 'react-dom/no-missing-iframe-sandbox': 'warn',
130
- 'react-dom/no-render': 'error',
131
- 'react-dom/no-render-return-value': 'error',
132
- 'react-dom/no-script-url': 'warn',
133
- 'react-dom/no-unsafe-iframe-sandbox': 'warn',
134
- 'react-dom/no-unsafe-target-blank': 'warn',
135
- 'react-dom/no-use-form-state': 'error',
136
- 'react-dom/no-void-elements-with-children': 'error',
137
-
138
- // recommended rules from eslint-plugin-react-hooks-extra https://eslint-react.xyz/docs/rules/overview#hooks-extra-rules
139
- 'react-hooks-extra/no-direct-set-state-in-use-effect': 'warn',
140
-
141
- // recommended rules eslint-plugin-react-hooks https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks/src/rules
142
- ...pluginReactHooks.configs.recommended.rules,
114
+ ...pluginReact.configs.recommended.rules,
143
115
 
144
116
  // preconfigured rules from eslint-plugin-react-refresh https://github.com/ArnaudBarre/eslint-plugin-react-refresh/tree/main/src
145
117
  'react-refresh/only-export-components': [
@@ -181,53 +153,6 @@ export async function react(options: ReactOptions = {}): Promise<Config[]> {
181
153
  },
182
154
  ],
183
155
 
184
- // recommended rules from eslint-plugin-react-web-api https://eslint-react.xyz/docs/rules/overview#web-api-rules
185
- 'react-web-api/no-leaked-event-listener': 'warn',
186
- 'react-web-api/no-leaked-interval': 'warn',
187
- 'react-web-api/no-leaked-resize-observer': 'warn',
188
- 'react-web-api/no-leaked-timeout': 'warn',
189
-
190
- // recommended rules from eslint-plugin-react-x https://eslint-react.xyz/docs/rules/overview#core-rules
191
- 'react/jsx-no-comment-textnodes': 'warn',
192
- 'react/jsx-no-duplicate-props': 'warn',
193
- 'react/jsx-uses-vars': 'warn',
194
- 'react/no-access-state-in-setstate': 'error',
195
- 'react/no-array-index-key': 'warn',
196
- 'react/no-children-count': 'warn',
197
- 'react/no-children-for-each': 'warn',
198
- 'react/no-children-map': 'warn',
199
- 'react/no-children-only': 'warn',
200
- 'react/no-children-to-array': 'warn',
201
- 'react/no-clone-element': 'warn',
202
- 'react/no-component-will-mount': 'error',
203
- 'react/no-component-will-receive-props': 'error',
204
- 'react/no-component-will-update': 'error',
205
- 'react/no-context-provider': 'warn',
206
- 'react/no-create-ref': 'error',
207
- 'react/no-default-props': 'error',
208
- 'react/no-direct-mutation-state': 'error',
209
- 'react/no-duplicate-key': 'warn',
210
- 'react/no-forward-ref': 'warn',
211
- 'react/no-missing-key': 'error',
212
- 'react/no-nested-component-definitions': 'error',
213
- 'react/no-prop-types': 'error',
214
- 'react/no-redundant-should-component-update': 'error',
215
- 'react/no-set-state-in-component-did-mount': 'warn',
216
- 'react/no-set-state-in-component-did-update': 'warn',
217
- 'react/no-set-state-in-component-will-update': 'warn',
218
- 'react/no-string-refs': 'error',
219
- 'react/no-unnecessary-use-prefix': 'warn',
220
- 'react/no-unsafe-component-will-mount': 'warn',
221
- 'react/no-unsafe-component-will-receive-props': 'warn',
222
- 'react/no-unsafe-component-will-update': 'warn',
223
- 'react/no-unstable-context-value': 'warn',
224
- 'react/no-unstable-default-props': 'warn',
225
- 'react/no-unused-class-component-members': 'warn',
226
- 'react/no-unused-state': 'warn',
227
- 'react/no-use-context': 'warn',
228
- 'react/no-useless-forward-ref': 'warn',
229
- 'react/prefer-use-state-lazy-initialization': 'warn',
230
-
231
156
  ...overrides,
232
157
  },
233
158
  },