@w5s/eslint-config 3.7.3 → 3.8.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@w5s/eslint-config",
3
- "version": "3.7.3",
3
+ "version": "3.8.0",
4
4
  "description": "ESLint configuration presets",
5
5
  "keywords": [
6
6
  "eslint",
@@ -13,20 +13,16 @@
13
13
  },
14
14
  "repository": {
15
15
  "type": "git",
16
- "url": "git+ssh@github.com:w5s/project-config.git",
16
+ "url": "git+https://github.com/w5s/project-config.git",
17
17
  "directory": "packages/eslint-config"
18
18
  },
19
19
  "license": "MIT",
20
20
  "author": "Julien Polo <julien.polo@gmail.com>",
21
21
  "type": "module",
22
22
  "exports": {
23
- ".": {
24
- "import": {
25
- "types": "./dist/index.d.ts",
26
- "default": "./dist/index.js"
27
- }
28
- },
29
- "./dist/*": "./dist/*"
23
+ "./package.json": "./package.json",
24
+ ".": "./dist/index.js",
25
+ "./internal/*": null
30
26
  },
31
27
  "files": [
32
28
  "dist/",
@@ -42,6 +38,7 @@
42
38
  },
43
39
  "dependencies": {
44
40
  "@e18e/eslint-plugin": "^0.5.0",
41
+ "@eslint-react/eslint-plugin": "5.9.1",
45
42
  "@eslint/js": "^10.0.0",
46
43
  "@eslint/markdown": "^8.0.0",
47
44
  "@next/eslint-plugin-next": "^16.0.0",
@@ -49,15 +46,15 @@
49
46
  "@typescript-eslint/eslint-plugin": "^8.0.0",
50
47
  "@typescript-eslint/parser": "^8.0.0",
51
48
  "@vitest/eslint-plugin": "^1.0.0",
52
- "@w5s/dev": "^3.4.3",
53
- "@w5s/eslint-config-ignore": "^1.2.3",
54
- "@w5s/prettier-config": "^3.1.11",
49
+ "@w5s/dev": "^3.4.4",
50
+ "@w5s/eslint-config-ignore": "^1.2.4",
51
+ "@w5s/prettier-config": "^3.1.12",
55
52
  "eslint-merge-processors": "^2.0.0",
56
53
  "eslint-plugin-import": "~2.32.0",
57
54
  "eslint-plugin-jsdoc": "~63.0.0",
58
55
  "eslint-plugin-jsonc": "~3.2.0",
59
56
  "eslint-plugin-n": "~18.1.0",
60
- "eslint-plugin-unicorn": "~64.0.0",
57
+ "eslint-plugin-unicorn": "~65.0.0",
61
58
  "eslint-plugin-yml": "~3.4.0",
62
59
  "globals": "^17.0.0",
63
60
  "jsonc-eslint-parser": "^3.0.0",
@@ -83,5 +80,5 @@
83
80
  "access": "public"
84
81
  },
85
82
  "sideEffect": false,
86
- "gitHead": "7a039902bfbde2e273c2bebf555061091f8a88c1"
83
+ "gitHead": "0fc09427b8a0c77dcc4adb9530e1d74a7fbf1d15"
87
84
  }
@@ -0,0 +1,43 @@
1
+ import { interopDefault } from '@w5s/dev';
2
+ import { type Config, type PluginOptionsBase } from '../type.js';
3
+ import type { RuleOptions } from '../typegen/react.js';
4
+ import { sourceGlob } from '../glob.js';
5
+
6
+ const defaultFiles = [sourceGlob];
7
+
8
+ export async function react(options: react.Options = {}) {
9
+ const [reactPlugin] = await Promise.all([
10
+ interopDefault(import('@eslint-react/eslint-plugin')),
11
+ ] as const);
12
+ const { files = defaultFiles, recommended, rules = {} } = options;
13
+ return [
14
+ {
15
+ name: 'w5s/react/setup',
16
+ plugins: {
17
+ react: reactPlugin,
18
+ },
19
+ },
20
+ {
21
+ name: 'w5s/react/rules',
22
+ files,
23
+ languageOptions: {
24
+ parserOptions: {
25
+ ecmaFeatures: {
26
+ jsx: true,
27
+ },
28
+ },
29
+ sourceType: 'module',
30
+ },
31
+ rules: {
32
+ ...(recommended ? reactPlugin.configs['recommended'].rules : {}),
33
+ ...rules,
34
+ },
35
+ },
36
+ ] as [Config, Config] satisfies Array<Config>;
37
+ }
38
+
39
+ export namespace react {
40
+ export type Rules = RuleOptions;
41
+
42
+ export interface Options extends Omit<PluginOptionsBase<Rules>, 'stylistic'> {}
43
+ }
package/src/config.ts CHANGED
@@ -7,6 +7,7 @@ export * from './config/imports.js';
7
7
  export * from './config/markdown.js';
8
8
  export * from './config/next.js';
9
9
  export * from './config/node.js';
10
+ export * from './config/react.js';
10
11
  export * from './config/stylistic.js';
11
12
  export * from './config/test.js';
12
13
  export * from './config/ts.js';
@@ -1,5 +1,21 @@
1
1
  import { ESLintConfig } from '@w5s/dev';
2
- import { jsdoc, jsonc, ignores, imports, markdown, next, node, ts, yml, unicorn, stylistic, es, e18e, test } from './config.js';
2
+ import {
3
+ e18e,
4
+ es,
5
+ ignores,
6
+ imports,
7
+ jsdoc,
8
+ jsonc,
9
+ markdown,
10
+ next,
11
+ node,
12
+ react,
13
+ stylistic,
14
+ test,
15
+ ts,
16
+ unicorn,
17
+ yml,
18
+ } from './config.js';
3
19
  import type { Config } from './type.js';
4
20
 
5
21
  export interface DefineConfigOptions extends ignores.Options {
@@ -11,6 +27,7 @@ export interface DefineConfigOptions extends ignores.Options {
11
27
  jsonc?: boolean | jsonc.Options;
12
28
  next?: boolean | next.Options;
13
29
  node?: boolean | node.Options;
30
+ react?: boolean | react.Options;
14
31
  stylistic?: boolean | stylistic.Options;
15
32
  test?: boolean | test.Options;
16
33
  ts?: boolean | ts.Options;
@@ -38,6 +55,7 @@ export async function defineConfig(options: DefineConfigOptions = {}) {
38
55
  ...includeEnabled(ignores, toOption(options)),
39
56
  ...includeEnabled(jsonc, toOption(options.jsonc)),
40
57
  ...includeEnabled(jsdoc, toOption(options.jsdoc)),
58
+ ...includeEnabled(react, toOption(options.react)),
41
59
  ...includeEnabled(stylistic, toOption(options.stylistic)),
42
60
  ...includeEnabled(imports, toOption(options.import)),
43
61
  ...includeEnabled(markdown, toOption(options.markdown)),
@@ -61,6 +61,14 @@ export interface RuleOptions {
61
61
  * Prefer the exponentiation operator ** over Math.pow()
62
62
  */
63
63
  'e18e/prefer-exponentiation-operator'?: Linter.RuleEntry<[]>
64
+ /**
65
+ * Prefer Array.prototype.flatMap() over .map(fn).flat() to avoid the intermediate array
66
+ */
67
+ 'e18e/prefer-flatmap-over-map-flat'?: Linter.RuleEntry<[]>
68
+ /**
69
+ * Prefer `Map.prototype.getOrInsert()` over reading an entry with a default and writing it back
70
+ */
71
+ 'e18e/prefer-get-or-insert'?: Linter.RuleEntry<[]>
64
72
  /**
65
73
  * Prefer .includes() over indexOf() comparisons for arrays and strings
66
74
  */