@fullstacksjs/eslint-config 14.5.0 → 14.7.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.
Files changed (58) hide show
  1. package/README.md +95 -60
  2. package/cjs/index.js +12 -2
  3. package/cjs/modules/base.js +6 -2
  4. package/cjs/modules/cypress.js +10 -3
  5. package/cjs/modules/ignore.js +1 -1
  6. package/cjs/modules/imports.js +6 -3
  7. package/cjs/modules/jest.js +6 -2
  8. package/cjs/modules/next.js +10 -3
  9. package/cjs/modules/node.js +7 -3
  10. package/cjs/modules/perfectionist.js +8 -3
  11. package/cjs/modules/playwright.js +10 -3
  12. package/cjs/modules/prettier.js +10 -9
  13. package/cjs/modules/promise.js +9 -2
  14. package/cjs/modules/react.js +51 -29
  15. package/cjs/modules/regex.js +11 -3
  16. package/cjs/modules/storybook.js +10 -3
  17. package/cjs/modules/stylistic.js +7 -3
  18. package/cjs/modules/tailwind.js +13 -4
  19. package/cjs/modules/tests.js +6 -2
  20. package/cjs/modules/typescript.js +7 -13
  21. package/cjs/modules/vitest.js +7 -3
  22. package/cjs/{index.d.ts → types/index.d.ts} +50 -52
  23. package/cjs/types/modules/import.d.ts +7 -0
  24. package/cjs/types/modules/react.d.ts +10 -0
  25. package/cjs/types/modules/regex.d.ts +5 -0
  26. package/cjs/types/modules/tailwind.d.ts +13 -0
  27. package/cjs/types/modules/typescript.d.ts +38 -0
  28. package/cjs/utils/nextAllowExportNames.js +7 -0
  29. package/cjs/utils/objectOrEmpty.js +14 -0
  30. package/package.json +15 -14
  31. package/src/index.mjs +12 -2
  32. package/src/modules/base.mjs +8 -2
  33. package/src/modules/cypress.mjs +12 -3
  34. package/src/modules/ignore.mjs +1 -1
  35. package/src/modules/imports.mjs +6 -3
  36. package/src/modules/jest.mjs +7 -2
  37. package/src/modules/next.mjs +13 -3
  38. package/src/modules/node.mjs +9 -3
  39. package/src/modules/perfectionist.mjs +11 -3
  40. package/src/modules/playwright.mjs +12 -3
  41. package/src/modules/prettier.mjs +13 -9
  42. package/src/modules/promise.mjs +11 -2
  43. package/src/modules/react.mjs +55 -28
  44. package/src/modules/regex.mjs +14 -3
  45. package/src/modules/storybook.mjs +12 -3
  46. package/src/modules/stylistic.mjs +9 -3
  47. package/src/modules/tailwind.mjs +17 -5
  48. package/src/modules/tests.mjs +8 -2
  49. package/src/modules/typescript.mjs +7 -9
  50. package/src/modules/vitest.mjs +9 -3
  51. package/src/{index.d.ts → types/index.d.ts} +50 -52
  52. package/src/types/modules/import.d.ts +7 -0
  53. package/src/types/modules/react.d.ts +10 -0
  54. package/src/types/modules/regex.d.ts +5 -0
  55. package/src/types/modules/tailwind.d.ts +13 -0
  56. package/src/types/modules/typescript.d.ts +38 -0
  57. package/src/utils/nextAllowExportNames.mjs +17 -0
  58. package/src/utils/objectOrEmpty.mjs +8 -0
@@ -0,0 +1,38 @@
1
+ import type { ConfigWithOverrides } from '..';
2
+
3
+ /**
4
+ * Granular options to configure the project service.
5
+ */
6
+ interface ProjectServiceOptions {
7
+ /**
8
+ * Globs of files to allow running with the default project compiler options
9
+ * despite not being matched by the project service.
10
+ */
11
+ allowDefaultProject?: string[];
12
+
13
+ /**
14
+ * Path to a TSConfig to use instead of TypeScript's default project configuration.
15
+ * @default 'tsconfig.json'
16
+ */
17
+ defaultProject?: string;
18
+
19
+ /**
20
+ * Whether to allow TypeScript plugins as configured in the TSConfig.
21
+ */
22
+ loadTypeScriptPlugins?: boolean;
23
+
24
+ /**
25
+ * The maximum number of files {@link allowDefaultProject} may match.
26
+ * Each file match slows down linting, so if you do need to use this, please
27
+ * file an informative issue on typescript-eslint explaining why - so we can
28
+ * help you avoid using it!
29
+ * @default 8
30
+ */
31
+ maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING?: number;
32
+ }
33
+
34
+ interface TypeScriptOptions extends ConfigWithOverrides {
35
+ projectService?: boolean | ProjectServiceOptions;
36
+ tsconfigRootDir?: string;
37
+ cacheLifetime?: number;
38
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.nextAllowExportNames = void 0;
7
+ const nextAllowExportNames = exports.nextAllowExportNames = ['experimental_ppr', 'dynamic', 'dynamicParams', 'revalidate', 'fetchCache', 'runtime', 'preferredRegion', 'maxDuration', 'metadata', 'generateMetadata', 'viewport', 'generateViewport', 'generateImageMetadata', 'generateSitemaps', 'generateStaticParams'];
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.objectOrEmpty = objectOrEmpty;
7
+ /**
8
+ * @template T
9
+ * @param {T | null | undefined} value
10
+ * @returns {T | {}}
11
+ */
12
+ function objectOrEmpty(value) {
13
+ return typeof value === 'object' && value !== null ? value : {};
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fullstacksjs/eslint-config",
3
- "version": "14.5.0",
3
+ "version": "14.7.0",
4
4
  "license": "MIT",
5
5
  "author": "fullstacks <fullstacksjs@gmail.com>",
6
6
  "description": "fullstacks eslint config",
@@ -16,7 +16,7 @@
16
16
  "src",
17
17
  "cjs"
18
18
  ],
19
- "packageManager": "npm@11.13.0",
19
+ "packageManager": "npm@11.16.0",
20
20
  "scripts": {
21
21
  "lint": "eslint .",
22
22
  "spell": "cspell ./* --no-progress",
@@ -34,16 +34,17 @@
34
34
  ".": {
35
35
  "import": "./src/index.mjs",
36
36
  "require": "./cjs/index.js",
37
- "types": "./src/index.d.ts"
37
+ "types": "./src/types/index.d.ts"
38
38
  }
39
39
  },
40
40
  "dependencies": {
41
- "@eslint-react/eslint-plugin": "5.8.3",
41
+ "@eslint-react/eslint-plugin": "5.8.16",
42
42
  "@eslint/compat": "2.1.0",
43
- "@next/eslint-plugin-next": "16.2.6",
43
+ "@next/eslint-plugin-next": "16.2.7",
44
44
  "@stylistic/eslint-plugin": "5.10.0",
45
- "@vitest/eslint-plugin": "1.6.17",
45
+ "@vitest/eslint-plugin": "1.6.19",
46
46
  "deepmerge": "4.3.1",
47
+ "eslint-flat-config-utils": "3.2.0",
47
48
  "eslint-plugin-better-tailwindcss": "4.5.0",
48
49
  "eslint-plugin-cypress": "6.4.1",
49
50
  "eslint-plugin-import-x": "4.16.2",
@@ -52,14 +53,14 @@
52
53
  "eslint-plugin-n": "18.0.1",
53
54
  "eslint-plugin-perfectionist": "5.9.0",
54
55
  "eslint-plugin-playwright": "2.10.4",
55
- "eslint-plugin-prettier": "5.5.5",
56
+ "eslint-plugin-prettier": "5.5.6",
56
57
  "eslint-plugin-promise": "7.3.0",
57
- "eslint-plugin-react-hooks": "7.1.1",
58
+ "eslint-plugin-react-refresh": "0.5.2",
58
59
  "eslint-plugin-regexp": "3.1.0",
59
- "eslint-plugin-storybook": "10.4.0",
60
+ "eslint-plugin-storybook": "10.4.2",
60
61
  "globals": "17.6.0",
61
62
  "local-pkg": "1.2.1",
62
- "typescript-eslint": "8.59.4"
63
+ "typescript-eslint": "8.61.0"
63
64
  },
64
65
  "devDependencies": {
65
66
  "@eslint/eslintrc": "3.3.5",
@@ -68,15 +69,15 @@
68
69
  "@semantic-release/npm": "13.1.5",
69
70
  "@semantic-release/release-notes-generator": "14.1.1",
70
71
  "@types/eslint": "9.6.1",
71
- "cspell": "10.0.0",
72
- "eslint": "10.4.0",
72
+ "cspell": "10.0.1",
73
+ "eslint": "10.4.1",
73
74
  "husky": "9.1.7",
74
75
  "jest": "30.4.2",
75
- "lint-staged": "17.0.5",
76
+ "lint-staged": "17.0.7",
76
77
  "pinst": "3.0.0",
77
78
  "prettier": "3.8.3",
78
79
  "semantic-release": "25.0.3",
79
- "storybook": "10.4.0",
80
+ "storybook": "10.4.2",
80
81
  "typescript": "6.0.3",
81
82
  "unbuild": "3.6.1"
82
83
  },
package/src/index.mjs CHANGED
@@ -12,6 +12,7 @@ import node from './modules/node.mjs';
12
12
  import perfectionist from './modules/perfectionist.mjs';
13
13
  import playwright from './modules/playwright.mjs';
14
14
  import prettier from './modules/prettier.mjs';
15
+ import promise from './modules/promise.mjs';
15
16
  import react from './modules/react.mjs';
16
17
  import regex from './modules/regex.mjs';
17
18
  import storybook from './modules/storybook.mjs';
@@ -25,11 +26,14 @@ const testPackages = ['jest', 'vitest', 'cypress', '@playwright/test'];
25
26
 
26
27
  /**
27
28
  * @typedef {import('eslint').Linter.Config} Config
28
- * @typedef {import('.').Options} Options
29
+ * @typedef {import('./types').Options} Options
29
30
  * /
30
31
 
31
32
  /** @type {Options} */
32
33
  const defaultOptions = {
34
+ base: true,
35
+ promise: true,
36
+ stylistic: true,
33
37
  cypress: isPackageExists('cypress'),
34
38
  disableExpensiveRules: false,
35
39
  esm: false,
@@ -74,6 +78,9 @@ export function defineConfig(initOptions = {}, ...extend) {
74
78
  }
75
79
 
76
80
  const {
81
+ base: enableBase,
82
+ promise: enablePromise,
83
+ stylistic: enableStylistic,
77
84
  sort: enableSort,
78
85
  cypress: enableCypress,
79
86
  disableExpensiveRules,
@@ -97,8 +104,11 @@ export function defineConfig(initOptions = {}, ...extend) {
97
104
  ...eslintOptions
98
105
  } = options;
99
106
 
100
- const rules = [ignores(options), base(options), stylistic(options)];
107
+ const rules = [ignores(options)];
101
108
 
109
+ if (enableBase) rules.push(base(options));
110
+ if (enablePromise) rules.push(promise(options));
111
+ if (enableStylistic) rules.push(stylistic(options));
102
112
  if (enableSort) rules.push(perfectionist(options));
103
113
  if (enableImport) rules.push(imports(options));
104
114
  if (enableTailwind) rules.push(tailwind(options));
@@ -1,13 +1,17 @@
1
+ import { mergeConfigs } from 'eslint-flat-config-utils';
1
2
  import globals from 'globals';
2
3
 
3
4
  import { strict } from '../utils/conditions.mjs';
5
+ import { objectOrEmpty } from '../utils/objectOrEmpty.mjs';
4
6
 
5
7
  /**
6
- * @param { import('..').Options } options
8
+ * @param { import('../types').Options } options
7
9
  * @return { import('eslint').Linter.Config }
8
10
  */
9
11
  function base(options = {}) {
10
- return {
12
+ const overrides = objectOrEmpty(options.base.overrides);
13
+
14
+ const baseConfig = {
11
15
  name: 'base',
12
16
  languageOptions: {
13
17
  ecmaVersion: 'latest',
@@ -195,6 +199,8 @@ function base(options = {}) {
195
199
  'no-console': strict(options, 'warn'),
196
200
  },
197
201
  };
202
+
203
+ return mergeConfigs(baseConfig, overrides);
198
204
  }
199
205
 
200
206
  export default base;
@@ -1,10 +1,17 @@
1
+ import { mergeConfigs } from 'eslint-flat-config-utils';
1
2
  import plugin from 'eslint-plugin-cypress';
2
3
 
3
4
  import { globs } from '../utils/globs.mjs';
5
+ import { objectOrEmpty } from '../utils/objectOrEmpty.mjs';
4
6
 
5
- /** @return { import('eslint').Linter.Config } */
6
- function cypress() {
7
- return {
7
+ /**
8
+ * @param { import('../types').Options } options
9
+ * @return { import('eslint').Linter.Config }
10
+ */
11
+ function cypress(options = {}) {
12
+ const overrides = objectOrEmpty(options.cypress.overrides);
13
+
14
+ const cypressConfig = {
8
15
  name: 'cypress',
9
16
  files: globs.e2e,
10
17
  plugins: { cypress: plugin },
@@ -21,6 +28,8 @@ function cypress() {
21
28
  '@typescript-eslint/no-namespace': 'off',
22
29
  },
23
30
  };
31
+
32
+ return mergeConfigs(cypressConfig, overrides);
24
33
  }
25
34
 
26
35
  export default cypress;
@@ -4,7 +4,7 @@ import { getGitignorePatterns } from '../utils/getGitignorePatterns.mjs';
4
4
  import { ignoreGlobs } from '../utils/globs.mjs';
5
5
 
6
6
  /**
7
- * @param { import('..').Options } options
7
+ * @param { import('../types').Options } options
8
8
  * @return { import('eslint').Linter.Config }
9
9
  */
10
10
  function ignores(options = {}) {
@@ -1,19 +1,22 @@
1
+ import { mergeConfigs } from 'eslint-flat-config-utils';
1
2
  import plugin from 'eslint-plugin-import-x';
2
3
 
3
4
  import { predicate } from '../utils/conditions.mjs';
5
+ import { objectOrEmpty } from '../utils/objectOrEmpty.mjs';
4
6
 
5
7
  const tsExtensions = ['.ts', '.tsx', '.cts', '.mts', '.ctsx', '.mtsx'];
6
8
  const jsExtensions = ['.mjs', '.js', '.jsx', '.cjs'];
7
9
  const allExtensions = [...jsExtensions, ...tsExtensions];
8
10
 
9
11
  /**
10
- * @param { import('..').Options } options
12
+ * @param { import('../types').Options } options
11
13
  * @return { import('eslint').Linter.Config }
12
14
  */
13
15
  function imports(options = {}) {
14
16
  const isObject = typeof options.import === 'object';
17
+ const overrides = objectOrEmpty(options.import.overrides);
15
18
 
16
- const config = {
19
+ const importsConfig = {
17
20
  name: 'imports',
18
21
  plugins: { import: plugin },
19
22
  settings: {
@@ -105,7 +108,7 @@ function imports(options = {}) {
105
108
  },
106
109
  };
107
110
 
108
- return config;
111
+ return mergeConfigs(importsConfig, overrides);
109
112
  }
110
113
 
111
114
  export default imports;
@@ -1,16 +1,19 @@
1
+ import { mergeConfigs } from 'eslint-flat-config-utils';
1
2
  import plugin from 'eslint-plugin-jest';
2
3
  import globals from 'globals';
3
4
 
4
5
  import { predicate } from '../utils/conditions.mjs';
5
6
  import { globs } from '../utils/globs.mjs';
7
+ import { objectOrEmpty } from '../utils/objectOrEmpty.mjs';
6
8
 
7
9
  /**
8
- * @param { import('..').Options } options
10
+ * @param { import('../types').Options } options
9
11
  * @return { import('eslint').Linter.Config } */
10
12
  function jest(options = {}) {
11
13
  const projectService = options.typescript && options.typescript.tsconfigRootDir && options.typescript.projectService;
14
+ const overrides = objectOrEmpty(options.jest.overrides);
12
15
 
13
- return {
16
+ const jestConfig = {
14
17
  name: 'jest',
15
18
  files: globs.test,
16
19
  plugins: { jest: plugin },
@@ -84,6 +87,8 @@ function jest(options = {}) {
84
87
  // }),
85
88
  },
86
89
  };
90
+
91
+ return mergeConfigs(jestConfig, overrides);
87
92
  }
88
93
 
89
94
  export default jest;
@@ -1,8 +1,16 @@
1
1
  import plugin from '@next/eslint-plugin-next';
2
+ import { mergeConfigs } from 'eslint-flat-config-utils';
2
3
 
3
- /** @type { import('eslint').Linter.Config } */
4
- function next() {
5
- return {
4
+ import { objectOrEmpty } from '../utils/objectOrEmpty.mjs';
5
+
6
+ /**
7
+ * @param { import('../types').Options } options
8
+ * @return { import('eslint').Linter.Config }
9
+ */
10
+ function next(options = {}) {
11
+ const overrides = objectOrEmpty(options.next.overrides);
12
+
13
+ const nextConfig = {
6
14
  name: 'next',
7
15
  plugins: { next: plugin },
8
16
  rules: {
@@ -29,6 +37,8 @@ function next() {
29
37
  'next/no-unwanted-polyfillio': 'warn',
30
38
  },
31
39
  };
40
+
41
+ return mergeConfigs(nextConfig, overrides);
32
42
  }
33
43
 
34
44
  export default next;
@@ -1,13 +1,17 @@
1
+ import { mergeConfigs } from 'eslint-flat-config-utils';
1
2
  import plugin from 'eslint-plugin-n';
2
3
 
3
4
  import { strict } from '../utils/conditions.mjs';
5
+ import { objectOrEmpty } from '../utils/objectOrEmpty.mjs';
4
6
 
5
7
  /**
6
- * @param { import('..').Options } options
8
+ * @param { import('../types').Options } options
7
9
  * @return { import('eslint').Linter.Config }
8
10
  */
9
11
  function node(options = {}) {
10
- return {
12
+ const overrides = objectOrEmpty(options.node.overrides);
13
+
14
+ const nodeConfig = {
11
15
  name: 'node',
12
16
  plugins: { n: plugin },
13
17
  rules: {
@@ -29,7 +33,7 @@ function node(options = {}) {
29
33
  'n/no-sync': strict(options, 'warn'),
30
34
  'n/no-top-level-await': 'off',
31
35
  'n/no-unpublished-bin': 'warn',
32
- 'n/no-unpublished-import': 'warn',
36
+ 'n/no-unpublished-import': 'off',
33
37
  'n/no-unpublished-require': 'warn',
34
38
  'n/no-unsupported-features/es-builtins': 'off', // Nice but not a general rule
35
39
  'n/no-unsupported-features/es-syntax': 'off', // Nice but not a general rule
@@ -56,6 +60,8 @@ function node(options = {}) {
56
60
  'n/no-missing-require': 'off',
57
61
  },
58
62
  };
63
+
64
+ return mergeConfigs(nodeConfig, overrides);
59
65
  }
60
66
 
61
67
  export default node;
@@ -1,10 +1,16 @@
1
+ import { mergeConfigs } from 'eslint-flat-config-utils';
1
2
  import plugin from 'eslint-plugin-perfectionist';
2
3
 
4
+ import { objectOrEmpty } from '../utils/objectOrEmpty.mjs';
5
+
3
6
  /**
4
- * @return { import('eslint').Linter.Config }
7
+ * @param { import('../types').Options } options
8
+ * @return { Promise<import('eslint').Linter.Config> }
5
9
  */
6
- function perfectionist() {
7
- return {
10
+ function perfectionist(options = {}) {
11
+ const overrides = objectOrEmpty(options.sort.overrides);
12
+
13
+ const perfectionistConfig = {
8
14
  name: 'perfectionist',
9
15
  plugins: { perfectionist: plugin },
10
16
  rules: {
@@ -69,6 +75,8 @@ function perfectionist() {
69
75
  'perfectionist/sort-variable-declarations': 'warn',
70
76
  },
71
77
  };
78
+
79
+ return mergeConfigs(perfectionistConfig, overrides);
72
80
  }
73
81
 
74
82
  export default perfectionist;
@@ -1,10 +1,17 @@
1
+ import { mergeConfigs } from 'eslint-flat-config-utils';
1
2
  import plugin from 'eslint-plugin-playwright';
2
3
 
3
4
  import { globs } from '../utils/globs.mjs';
5
+ import { objectOrEmpty } from '../utils/objectOrEmpty.mjs';
4
6
 
5
- /** @return { import('eslint').Linter.Config } */
6
- function playwright() {
7
- return {
7
+ /**
8
+ * @param { import('../types').Options } options
9
+ * @return { Promise<import('eslint').Linter.Config> }
10
+ */
11
+ function playwright(options = {}) {
12
+ const overrides = objectOrEmpty(options.playwright.overrides);
13
+
14
+ const playwrightConfig = {
8
15
  name: 'playwright',
9
16
  plugins: { playwright: plugin },
10
17
  files: globs.e2e,
@@ -69,6 +76,8 @@ function playwright() {
69
76
  'playwright/valid-title': 'warn',
70
77
  },
71
78
  };
79
+
80
+ return mergeConfigs(playwrightConfig, overrides);
72
81
  }
73
82
 
74
83
  export default playwright;
@@ -1,32 +1,36 @@
1
+ import { mergeConfigs } from 'eslint-flat-config-utils';
1
2
  import plugin from 'eslint-plugin-prettier';
2
3
 
3
- /** @return { import('eslint').Linter.Config } */
4
- function prettier() {
5
- return {
4
+ import { objectOrEmpty } from '../utils/objectOrEmpty.mjs';
5
+
6
+ /**
7
+ * @param { import('../types').Options } options
8
+ * @return { Promise<import('eslint').Linter.Config> }
9
+ */
10
+ function prettier(options = {}) {
11
+ const overrides = objectOrEmpty(options.prettier.overrides);
12
+
13
+ const prettierConfig = {
6
14
  name: 'prettier',
7
15
  plugins: { prettier: plugin },
8
16
  rules: {
9
17
  'prettier/prettier': 'error',
10
18
 
11
19
  'curly': 'off',
12
- 'brace-style': 'off',
13
20
  'no-unexpected-multiline': 'off',
14
21
 
15
22
  '@typescript-eslint/lines-around-comment': 'off',
16
23
  '@typescript-eslint/quotes': 'off',
17
24
  '@typescript-eslint/block-spacing': 'off',
18
- '@typescript-eslint/brace-style': 'off',
19
25
  '@typescript-eslint/comma-dangle': 'off',
20
26
  '@typescript-eslint/comma-spacing': 'off',
21
27
  '@typescript-eslint/func-call-spacing': 'off',
22
28
  '@typescript-eslint/indent': 'off',
23
- '@typescript-eslint/key-spacing': 'off',
24
29
  '@typescript-eslint/keyword-spacing': 'off',
25
30
  '@typescript-eslint/member-delimiter-style': 'off',
26
31
  '@typescript-eslint/no-extra-parens': 'off',
27
32
  '@typescript-eslint/no-extra-semi': 'off',
28
33
  '@typescript-eslint/semi': 'off',
29
- '@typescript-eslint/space-before-blocks': 'off',
30
34
  '@typescript-eslint/space-before-function-paren': 'off',
31
35
  '@typescript-eslint/space-infix-ops': 'off',
32
36
  '@typescript-eslint/type-annotation-spacing': 'off',
@@ -38,12 +42,10 @@ function prettier() {
38
42
  '@stylistic/jsx-curly-spacing': 'off',
39
43
  '@stylistic/jsx-equals-spacing': 'off',
40
44
  '@stylistic/jsx-first-prop-new-line': 'off',
41
- '@stylistic/jsx-indent': 'off',
42
45
  '@stylistic/jsx-indent-props': 'off',
43
46
  '@stylistic/jsx-max-props-per-line': 'off',
44
47
  '@stylistic/jsx-newline': 'off',
45
48
  '@stylistic/jsx-one-expression-per-line': 'off',
46
- '@stylistic/jsx-props-no-multi-spaces': 'off',
47
49
  '@stylistic/jsx-tag-spacing': 'off',
48
50
  '@stylistic/jsx-wrap-multilines': 'off',
49
51
 
@@ -88,6 +90,8 @@ function prettier() {
88
90
  'vue/template-curly-spacing': 'off',
89
91
  },
90
92
  };
93
+
94
+ return mergeConfigs(prettierConfig, overrides);
91
95
  }
92
96
 
93
97
  export default prettier;
@@ -1,10 +1,17 @@
1
+ import { mergeConfigs } from 'eslint-flat-config-utils';
1
2
  import plugin from 'eslint-plugin-promise';
2
3
 
3
4
  import { strict } from '../utils/conditions.mjs';
5
+ import { objectOrEmpty } from '../utils/objectOrEmpty.mjs';
4
6
 
5
- /** @return { import('eslint').Linter.Config } */
7
+ /**
8
+ * @param { import('../types').Options } options
9
+ * @return { Promise<import('eslint').Linter.Config> }
10
+ */
6
11
  function promise(options = {}) {
7
- return {
12
+ const overrides = objectOrEmpty(options.promise.overrides);
13
+
14
+ const promiseConfig = {
8
15
  name: 'promise',
9
16
  plugins: { promise: plugin },
10
17
  rules: {
@@ -27,6 +34,8 @@ function promise(options = {}) {
27
34
  'promise/spec-only': 'warn',
28
35
  },
29
36
  };
37
+
38
+ return mergeConfigs(promiseConfig, overrides);
30
39
  }
31
40
 
32
41
  export default promise;
@@ -1,22 +1,31 @@
1
1
  import reactPlugin from '@eslint-react/eslint-plugin';
2
+ import { mergeConfigs } from 'eslint-flat-config-utils';
2
3
  import a11yPlugin from 'eslint-plugin-jsx-a11y';
3
- import hooksPlugin from 'eslint-plugin-react-hooks';
4
+ import { reactRefresh } from 'eslint-plugin-react-refresh';
5
+ import { isPackageExists } from 'local-pkg';
4
6
  import { parser } from 'typescript-eslint';
5
7
 
6
8
  import { predicate, strict } from '../utils/conditions.mjs';
7
9
  import { globs } from '../utils/globs.mjs';
10
+ import { nextAllowExportNames } from '../utils/nextAllowExportNames.mjs';
11
+ import { objectOrEmpty } from '../utils/objectOrEmpty.mjs';
8
12
 
9
- /** @return { import('eslint').Linter.Config } */
13
+ /**
14
+ * @param { import('../types').Options } options
15
+ * @return { Promise<import('eslint').Linter.Config> }
16
+ */
10
17
  function react(options = {}) {
11
18
  const projectService = options.typescript && options.typescript.tsconfigRootDir && options.typescript.projectService;
19
+ const isObject = typeof options.react === 'object';
20
+ const overrides = objectOrEmpty(options.react.overrides);
12
21
 
13
- return {
22
+ const reactConfig = {
14
23
  name: 'react',
15
24
  files: [globs.js, globs.jsx, globs.ts, globs.tsx],
16
25
  plugins: {
17
26
  ...reactPlugin.configs.all.plugins,
18
- 'react-hooks': hooksPlugin,
19
27
  'jsx-a11y': a11yPlugin,
28
+ 'react-refresh': reactRefresh.plugin,
20
29
  },
21
30
  ...predicate(projectService, {
22
31
  languageOptions: {
@@ -25,12 +34,25 @@ function react(options = {}) {
25
34
  },
26
35
  }),
27
36
  settings: {
28
- 'react': {
29
- pragma: 'React',
30
- version: 'detect',
31
- },
32
- 'react-hooks': {
33
- additionalEffectHooks: options.react.additionalEffectHooks,
37
+ 'react-x': {
38
+ ...predicate(isObject && 'version' in options.react, {
39
+ version: options.react.version,
40
+ }),
41
+ ...predicate(isObject && 'importSource' in options.react, {
42
+ importSource: options.react.importSource,
43
+ }),
44
+ ...predicate(isObject && 'compilationMode' in options.react, {
45
+ compilationMode: options.react.compilationMode,
46
+ }),
47
+ ...predicate(isObject && 'polymorphicPropName' in options.react, {
48
+ polymorphicPropName: options.react.polymorphicPropName,
49
+ }),
50
+ ...predicate(isObject && 'additionalStateHooks' in options.react, {
51
+ additionalStateHooks: options.react.additionalStateHooks,
52
+ }),
53
+ ...predicate(isObject && 'additionalEffectHooks' in options.react, {
54
+ additionalEffectHooks: options.react.additionalEffectHooks,
55
+ }),
34
56
  },
35
57
  },
36
58
  rules: {
@@ -114,24 +136,18 @@ function react(options = {}) {
114
136
 
115
137
  '@eslint-react/rsc-function-definition': 'error',
116
138
 
117
- 'react-hooks/rules-of-hooks': 'error',
118
- 'react-hooks/exhaustive-deps': 'warn',
119
-
120
- 'react-hooks/config': 'error',
121
- 'react-hooks/error-boundaries': 'error',
122
- 'react-hooks/component-hook-factories': 'error',
123
- 'react-hooks/gating': 'error',
124
- 'react-hooks/globals': 'error',
125
- 'react-hooks/immutability': 'error',
126
- 'react-hooks/preserve-manual-memoization': 'error',
127
- 'react-hooks/purity': 'error',
128
- 'react-hooks/refs': 'error',
129
- 'react-hooks/set-state-in-effect': strict('error'),
130
- 'react-hooks/set-state-in-render': 'error',
131
- 'react-hooks/static-components': strict('error'),
132
- 'react-hooks/unsupported-syntax': 'warn',
133
- 'react-hooks/use-memo': 'error',
134
- 'react-hooks/incompatible-library': 'warn',
139
+ '@eslint-react/rules-of-hooks': 'error',
140
+ '@eslint-react/exhaustive-deps': 'error',
141
+ '@eslint-react/error-boundaries': 'error',
142
+ '@eslint-react/globals': 'error',
143
+ '@eslint-react/immutability': 'error',
144
+ '@eslint-react/purity': 'error',
145
+ '@eslint-react/refs': 'error',
146
+ '@eslint-react/set-state-in-effect': strict('error'),
147
+ '@eslint-react/set-state-in-render': 'error',
148
+ '@eslint-react/static-components': strict('error'),
149
+ '@eslint-react/unsupported-syntax': 'error',
150
+ '@eslint-react/use-memo': 'error',
135
151
 
136
152
  'jsx-a11y/alt-text': 'warn',
137
153
  'jsx-a11y/anchor-has-content': 'error',
@@ -169,8 +185,19 @@ function react(options = {}) {
169
185
  'jsx-a11y/tabindex-no-positive': 'warn',
170
186
  'jsx-a11y/anchor-ambiguous-text': 'off',
171
187
  'jsx-a11y/prefer-tag-over-role': 'off',
188
+
189
+ 'react-refresh/only-export-components': [
190
+ 'error',
191
+ {
192
+ allowExportNames: isPackageExists('next') ? nextAllowExportNames : [],
193
+
194
+ allowConstantExport: isPackageExists('vite'),
195
+ },
196
+ ],
172
197
  },
173
198
  };
199
+
200
+ return mergeConfigs(reactConfig, overrides);
174
201
  }
175
202
 
176
203
  export default react;