@lunit/eslint-config 2.0.1 → 3.0.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/README.md CHANGED
@@ -14,7 +14,75 @@ npm install --save-dev @lunit/eslint-config
14
14
 
15
15
  ### Getting Started
16
16
 
17
- `@lunit/eslint-config v2.x` is configured using the ESLint Flat Config approach.
17
+ `@lunit/eslint-config v3.x` is configured using the ESLint Flat Config approach.
18
+
19
+ #### Compatibility
20
+
21
+ - ESLint 9.27.0 through ESLint 10.x
22
+ - Prettier 3 or newer
23
+ - TypeScript 5.x, or TypeScript 6.0.x with the override below
24
+
25
+ ESLint 8.x is not supported. It reached end of life on October 5, 2024:
26
+ https://eslint.org/blog/2024/09/eslint-v8-eol-version-support/
27
+
28
+ For projects with React installed in the current working directory, the default config supplies the
29
+ installed React version to `eslint-plugin-react`. This avoids its incompatible version-detection
30
+ path on ESLint 10. If React cannot be resolved, the config retains the previous `'detect'` behavior.
31
+
32
+ In a monorepo, the process working directory may differ from the package that owns React. Use the
33
+ config factory to provide either the React version or the package directory explicitly:
34
+
35
+ ```js
36
+ import { createLunitEslintConfig } from '@lunit/eslint-config';
37
+
38
+ export default defineConfig([
39
+ createLunitEslintConfig({ reactResolveFrom: import.meta.dirname }),
40
+ // Alternatively: createLunitEslintConfig({ reactVersion: '19.2.0' }),
41
+ ]);
42
+ ```
43
+
44
+ ```js
45
+ const { createLunitEslintConfig } = require('@lunit/eslint-config');
46
+
47
+ module.exports = defineConfig([
48
+ createLunitEslintConfig({ reactResolveFrom: __dirname }),
49
+ ]);
50
+ ```
51
+
52
+ ESLint 10 runtime compatibility is covered by this package's integration tests. However, the latest
53
+ `@rushstack/eslint-config` and some of its plugins do not yet include ESLint 10 in their peer ranges,
54
+ so package managers may report peer dependency warnings until upstream support is published.
55
+
56
+ `@rushstack/eslint-config@4.6.5` pins an older TypeScript-ESLint release. TypeScript 6 consumers
57
+ must align that transitive toolchain in the application root because dependency-level overrides
58
+ are not inherited by package consumers.
59
+
60
+ ##### pnpm
61
+
62
+ ```yaml
63
+ # pnpm-workspace.yaml
64
+ overrides:
65
+ '@typescript-eslint/eslint-plugin': 8.68.0
66
+ '@typescript-eslint/parser': 8.68.0
67
+ '@typescript-eslint/typescript-estree': 8.68.0
68
+ '@typescript-eslint/utils': 8.68.0
69
+ ```
70
+
71
+ ##### npm
72
+
73
+ ```json
74
+ {
75
+ "overrides": {
76
+ "@typescript-eslint/eslint-plugin": "8.68.0",
77
+ "@typescript-eslint/parser": "8.68.0",
78
+ "@typescript-eslint/typescript-estree": "8.68.0",
79
+ "@typescript-eslint/utils": "8.68.0"
80
+ }
81
+ }
82
+ ```
83
+
84
+ This supports TypeScript 6.0.x; TypeScript 6.1 and newer remain outside the parser's supported
85
+ range.
18
86
 
19
87
  For information regarding ESLint Flat Config, please refer to the relevant ESLint Blog post.
20
88
  - https://eslint.org/blog/2022/08/new-config-system-part-2/
@@ -34,7 +102,7 @@ import globals from "globals";
34
102
  import reactHooks from "eslint-plugin-react-hooks";
35
103
  import reactRefresh from "eslint-plugin-react-refresh";
36
104
  import { defineConfig, globalIgnores } from "eslint/config";
37
- import eslintConfig from '@lunit/eslint-config';
105
+ import lunitEslintConfig from '@lunit/eslint-config';
38
106
 
39
107
  export default defineConfig([
40
108
  globalIgnores(["dist"]),
@@ -101,7 +169,7 @@ import globals from "globals";
101
169
  import reactHooks from "eslint-plugin-react-hooks";
102
170
  import reactRefresh from "eslint-plugin-react-refresh";
103
171
  import { defineConfig, globalIgnores } from "eslint/config";
104
- import eslintConfig from '@lunit/eslint-config';
172
+ import lunitEslintConfig from '@lunit/eslint-config';
105
173
 
106
174
  export default defineConfig([
107
175
  globalIgnores(["dist"]),
@@ -118,7 +186,7 @@ export default defineConfig([
118
186
  },
119
187
  },
120
188
  {
121
- ...eslintConfig,
189
+ ...lunitEslintConfig,
122
190
  // You must integrate the tsconfig.app.json file applied to the actual ts and tsx files as shown below.
123
191
  languageOptions: {
124
192
  parserOptions: {
@@ -182,7 +250,7 @@ import globals from "globals";
182
250
  import reactHooks from "eslint-plugin-react-hooks";
183
251
  import reactRefresh from "eslint-plugin-react-refresh";
184
252
  import { defineConfig, globalIgnores } from "eslint/config";
185
- import eslintConfig from '@lunit/eslint-config';
253
+ import lunitEslintConfig from '@lunit/eslint-config';
186
254
 
187
255
  export default defineConfig([
188
256
  globalIgnores(["dist"]),
package/dist/index.js CHANGED
@@ -1,110 +1,95 @@
1
- "use strict";
2
- const react = require("@rushstack/eslint-config/flat/mixins/react.js");
3
- const webApp = require("@rushstack/eslint-config/flat/profile/web-app.js");
4
- function _interopNamespaceDefault(e) {
5
- const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
6
- if (e) {
7
- for (const k in e) {
8
- if (k !== "default") {
9
- const d = Object.getOwnPropertyDescriptor(e, k);
10
- Object.defineProperty(n, k, d.get ? d : {
11
- enumerable: true,
12
- get: () => e[k]
13
- });
14
- }
15
- }
16
- }
17
- n.default = e;
18
- return Object.freeze(n);
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
5
+ //#region \0rolldown/runtime.js
6
+ var __create = Object.create;
7
+ var __defProp = Object.defineProperty;
8
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __getProtoOf = Object.getPrototypeOf;
11
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
14
+ key = keys[i];
15
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: ((k) => from[k]).bind(null, key),
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+ //#endregion
27
+ let node_module = require("node:module");
28
+ let node_path = require("node:path");
29
+ let _rushstack_eslint_config_flat_mixins_react_js = require("@rushstack/eslint-config/flat/mixins/react.js");
30
+ _rushstack_eslint_config_flat_mixins_react_js = __toESM(_rushstack_eslint_config_flat_mixins_react_js, 1);
31
+ let _rushstack_eslint_config_flat_profile_web_app_js = require("@rushstack/eslint-config/flat/profile/web-app.js");
32
+ _rushstack_eslint_config_flat_profile_web_app_js = __toESM(_rushstack_eslint_config_flat_profile_web_app_js, 1);
33
+ //#region index.mjs
34
+ function cleanConfig(config) {
35
+ if (Array.isArray(config)) return config.map(cleanConfig);
36
+ if (config && typeof config === "object" && config.default) return cleanConfig(config.default);
37
+ return config;
19
38
  }
20
- const react__namespace = /* @__PURE__ */ _interopNamespaceDefault(react);
21
- const webApp__namespace = /* @__PURE__ */ _interopNamespaceDefault(webApp);
22
- function getDefaultExportFromCjs(x) {
23
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
39
+ function resolveReactVersion(resolveFrom) {
40
+ try {
41
+ return (0, node_module.createRequire)((0, node_path.resolve)(resolveFrom, "package.json"))("react/package.json").version;
42
+ } catch {
43
+ return "detect";
44
+ }
24
45
  }
25
- function getAugmentedNamespace(n) {
26
- if (Object.prototype.hasOwnProperty.call(n, "__esModule")) return n;
27
- var f = n.default;
28
- if (typeof f == "function") {
29
- var a = function a2() {
30
- var isInstance = false;
31
- try {
32
- isInstance = this instanceof a2;
33
- } catch {
34
- }
35
- if (isInstance) {
36
- return Reflect.construct(f, arguments, this.constructor);
37
- }
38
- return f.apply(this, arguments);
39
- };
40
- a.prototype = f.prototype;
41
- } else a = {};
42
- Object.defineProperty(a, "__esModule", { value: true });
43
- Object.keys(n).forEach(function(k) {
44
- var d = Object.getOwnPropertyDescriptor(n, k);
45
- Object.defineProperty(a, k, d.get ? d : {
46
- enumerable: true,
47
- get: function() {
48
- return n[k];
49
- }
50
- });
51
- });
52
- return a;
46
+ /**
47
+ * When using this library in ESM mode, an error occurs unless the default key is removed as shown below.
48
+ * To resolve this issue, apply a function that removes the default key.
49
+ * - ConfigError: Config "UserConfig[0][2] > ExtendedConfig[0]": Unexpected key "default" found.
50
+ *
51
+ * TODO: This method cannot control the elements used inside rushstack, so it is processed this way.
52
+ * We recommend finding a way to solve this problem and modifying it in the future.
53
+ */
54
+ var cleanedExtends = [_rushstack_eslint_config_flat_profile_web_app_js.default, _rushstack_eslint_config_flat_mixins_react_js.default].map(cleanConfig);
55
+ function createLunitEslintConfig({ reactResolveFrom = process.cwd(), reactVersion } = {}) {
56
+ return {
57
+ files: ["**/*.ts", "**/*.tsx"],
58
+ extends: cleanedExtends,
59
+ rules: {
60
+ /**
61
+ * RATIONALE : The null type is universally used, so it is excluded.
62
+ * docs: https://www.npmjs.com/package/@rushstack/eslint-plugin
63
+ */
64
+ "@rushstack/no-new-null": "off",
65
+ /**
66
+ * RATIONALE : Rushstack's policy enforces explicit types for top-level variables for readability,
67
+ * but our project prefers to leverage TypeScript's type inference.
68
+ * docs: https://github.com/microsoft/rushstack/tree/main/eslint/eslint-plugin#rushstacktypedef-var
69
+ */
70
+ "@rushstack/typedef-var": "off",
71
+ /**
72
+ * RATIONALE : According to the documentation, it can be used in projects that use many classes,
73
+ * but it is unnecessary because the development pattern is functional.
74
+ * docs: https://typescript-eslint.io/rules/explicit-member-accessibility/
75
+ */
76
+ "@typescript-eslint/explicit-member-accessibility": "off",
77
+ /**
78
+ * RATIONALE : Depending on the situation, it may be better to leave the return type to type inference.
79
+ * docs: https://typescript-eslint.io/rules/explicit-function-return-type/
80
+ */
81
+ "@typescript-eslint/explicit-function-return-type": "off"
82
+ },
83
+ settings: { react: { version: reactVersion ?? resolveReactVersion(reactResolveFrom) } }
84
+ };
53
85
  }
54
- const require$$0 = /* @__PURE__ */ getAugmentedNamespace(react__namespace);
55
- const require$$1 = /* @__PURE__ */ getAugmentedNamespace(webApp__namespace);
56
- var eslintConfig;
57
- var hasRequiredEslintConfig;
58
- function requireEslintConfig() {
59
- if (hasRequiredEslintConfig) return eslintConfig;
60
- hasRequiredEslintConfig = 1;
61
- const rushStackReactConfig = require$$0;
62
- const rushStackWebAppConfig = require$$1;
63
- function cleanConfig(config) {
64
- if (Array.isArray(config)) {
65
- return config.map(cleanConfig);
66
- }
67
- if (config && typeof config === "object" && config.default) {
68
- return cleanConfig(config.default);
69
- }
70
- return config;
71
- }
72
- const cleanedExtends = [rushStackWebAppConfig, rushStackReactConfig].map(cleanConfig);
73
- eslintConfig = {
74
- files: ["**/*.ts", "**/*.tsx"],
75
- extends: cleanedExtends,
76
- rules: {
77
- /**
78
- * RATIONALE : The null type is universally used, so it is excluded.
79
- * docs: https://www.npmjs.com/package/@rushstack/eslint-plugin
80
- */
81
- "@rushstack/no-new-null": "off",
82
- /**
83
- * RATIONALE : Rushstack's policy enforces explicit types for top-level variables for readability,
84
- * but our project prefers to leverage TypeScript's type inference.
85
- * docs: https://github.com/microsoft/rushstack/tree/main/eslint/eslint-plugin#rushstacktypedef-var
86
- */
87
- "@rushstack/typedef-var": "off",
88
- /**
89
- * RATIONALE : According to the documentation, it can be used in projects that use many classes,
90
- * but it is unnecessary because the development pattern is functional.
91
- * docs: https://typescript-eslint.io/rules/explicit-member-accessibility/
92
- */
93
- "@typescript-eslint/explicit-member-accessibility": "off",
94
- /**
95
- * RATIONALE : Depending on the situation, it may be better to leave the return type to type inference.
96
- * docs: https://typescript-eslint.io/rules/explicit-function-return-type/
97
- */
98
- "@typescript-eslint/explicit-function-return-type": "off"
99
- },
100
- settings: {
101
- react: {
102
- version: "detect"
103
- }
104
- }
105
- };
106
- return eslintConfig;
107
- }
108
- var eslintConfigExports = requireEslintConfig();
109
- const index = /* @__PURE__ */ getDefaultExportFromCjs(eslintConfigExports);
110
- module.exports = index;
86
+ var eslint_config_default = createLunitEslintConfig();
87
+ //#endregion
88
+ exports.createLunitEslintConfig = createLunitEslintConfig;
89
+ exports.default = eslint_config_default;
90
+
91
+ const defaultConfig = module.exports.default;
92
+ Object.defineProperty(defaultConfig, 'createLunitEslintConfig', {
93
+ value: module.exports.createLunitEslintConfig,
94
+ });
95
+ module.exports = defaultConfig;
package/dist/index.mjs CHANGED
@@ -1,91 +1,60 @@
1
- import * as react from "@rushstack/eslint-config/flat/mixins/react.js";
2
- import * as webApp from "@rushstack/eslint-config/flat/profile/web-app.js";
3
- function getDefaultExportFromCjs(x) {
4
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
1
+ import { createRequire } from "node:module";
2
+ import { resolve } from "node:path";
3
+ import rushStackReactConfig from "@rushstack/eslint-config/flat/mixins/react.js";
4
+ import rushStackWebAppConfig from "@rushstack/eslint-config/flat/profile/web-app.js";
5
+ //#region index.mjs
6
+ function cleanConfig(config) {
7
+ if (Array.isArray(config)) return config.map(cleanConfig);
8
+ if (config && typeof config === "object" && config.default) return cleanConfig(config.default);
9
+ return config;
5
10
  }
6
- function getAugmentedNamespace(n) {
7
- if (Object.prototype.hasOwnProperty.call(n, "__esModule")) return n;
8
- var f = n.default;
9
- if (typeof f == "function") {
10
- var a = function a2() {
11
- var isInstance = false;
12
- try {
13
- isInstance = this instanceof a2;
14
- } catch {
15
- }
16
- if (isInstance) {
17
- return Reflect.construct(f, arguments, this.constructor);
18
- }
19
- return f.apply(this, arguments);
20
- };
21
- a.prototype = f.prototype;
22
- } else a = {};
23
- Object.defineProperty(a, "__esModule", { value: true });
24
- Object.keys(n).forEach(function(k) {
25
- var d = Object.getOwnPropertyDescriptor(n, k);
26
- Object.defineProperty(a, k, d.get ? d : {
27
- enumerable: true,
28
- get: function() {
29
- return n[k];
30
- }
31
- });
32
- });
33
- return a;
11
+ function resolveReactVersion(resolveFrom) {
12
+ try {
13
+ return createRequire(resolve(resolveFrom, "package.json"))("react/package.json").version;
14
+ } catch {
15
+ return "detect";
16
+ }
34
17
  }
35
- const require$$0 = /* @__PURE__ */ getAugmentedNamespace(react);
36
- const require$$1 = /* @__PURE__ */ getAugmentedNamespace(webApp);
37
- var eslintConfig;
38
- var hasRequiredEslintConfig;
39
- function requireEslintConfig() {
40
- if (hasRequiredEslintConfig) return eslintConfig;
41
- hasRequiredEslintConfig = 1;
42
- const rushStackReactConfig = require$$0;
43
- const rushStackWebAppConfig = require$$1;
44
- function cleanConfig(config) {
45
- if (Array.isArray(config)) {
46
- return config.map(cleanConfig);
47
- }
48
- if (config && typeof config === "object" && config.default) {
49
- return cleanConfig(config.default);
50
- }
51
- return config;
52
- }
53
- const cleanedExtends = [rushStackWebAppConfig, rushStackReactConfig].map(cleanConfig);
54
- eslintConfig = {
55
- files: ["**/*.ts", "**/*.tsx"],
56
- extends: cleanedExtends,
57
- rules: {
58
- /**
59
- * RATIONALE : The null type is universally used, so it is excluded.
60
- * docs: https://www.npmjs.com/package/@rushstack/eslint-plugin
61
- */
62
- "@rushstack/no-new-null": "off",
63
- /**
64
- * RATIONALE : Rushstack's policy enforces explicit types for top-level variables for readability,
65
- * but our project prefers to leverage TypeScript's type inference.
66
- * docs: https://github.com/microsoft/rushstack/tree/main/eslint/eslint-plugin#rushstacktypedef-var
67
- */
68
- "@rushstack/typedef-var": "off",
69
- /**
70
- * RATIONALE : According to the documentation, it can be used in projects that use many classes,
71
- * but it is unnecessary because the development pattern is functional.
72
- * docs: https://typescript-eslint.io/rules/explicit-member-accessibility/
73
- */
74
- "@typescript-eslint/explicit-member-accessibility": "off",
75
- /**
76
- * RATIONALE : Depending on the situation, it may be better to leave the return type to type inference.
77
- * docs: https://typescript-eslint.io/rules/explicit-function-return-type/
78
- */
79
- "@typescript-eslint/explicit-function-return-type": "off"
80
- },
81
- settings: {
82
- react: {
83
- version: "detect"
84
- }
85
- }
86
- };
87
- return eslintConfig;
18
+ /**
19
+ * When using this library in ESM mode, an error occurs unless the default key is removed as shown below.
20
+ * To resolve this issue, apply a function that removes the default key.
21
+ * - ConfigError: Config "UserConfig[0][2] > ExtendedConfig[0]": Unexpected key "default" found.
22
+ *
23
+ * TODO: This method cannot control the elements used inside rushstack, so it is processed this way.
24
+ * We recommend finding a way to solve this problem and modifying it in the future.
25
+ */
26
+ var cleanedExtends = [rushStackWebAppConfig, rushStackReactConfig].map(cleanConfig);
27
+ function createLunitEslintConfig({ reactResolveFrom = process.cwd(), reactVersion } = {}) {
28
+ return {
29
+ files: ["**/*.ts", "**/*.tsx"],
30
+ extends: cleanedExtends,
31
+ rules: {
32
+ /**
33
+ * RATIONALE : The null type is universally used, so it is excluded.
34
+ * docs: https://www.npmjs.com/package/@rushstack/eslint-plugin
35
+ */
36
+ "@rushstack/no-new-null": "off",
37
+ /**
38
+ * RATIONALE : Rushstack's policy enforces explicit types for top-level variables for readability,
39
+ * but our project prefers to leverage TypeScript's type inference.
40
+ * docs: https://github.com/microsoft/rushstack/tree/main/eslint/eslint-plugin#rushstacktypedef-var
41
+ */
42
+ "@rushstack/typedef-var": "off",
43
+ /**
44
+ * RATIONALE : According to the documentation, it can be used in projects that use many classes,
45
+ * but it is unnecessary because the development pattern is functional.
46
+ * docs: https://typescript-eslint.io/rules/explicit-member-accessibility/
47
+ */
48
+ "@typescript-eslint/explicit-member-accessibility": "off",
49
+ /**
50
+ * RATIONALE : Depending on the situation, it may be better to leave the return type to type inference.
51
+ * docs: https://typescript-eslint.io/rules/explicit-function-return-type/
52
+ */
53
+ "@typescript-eslint/explicit-function-return-type": "off"
54
+ },
55
+ settings: { react: { version: reactVersion ?? resolveReactVersion(reactResolveFrom) } }
56
+ };
88
57
  }
89
- var eslintConfigExports = requireEslintConfig();
90
- const index = /* @__PURE__ */ getDefaultExportFromCjs(eslintConfigExports);
91
- export default index;
58
+ var eslint_config_default = createLunitEslintConfig();
59
+ //#endregion
60
+ export { createLunitEslintConfig, eslint_config_default as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunit/eslint-config",
3
- "version": "2.0.1",
3
+ "version": "3.0.0",
4
4
  "description": "Lunit ESLint Config",
5
5
  "type": "commonjs",
6
6
  "main": "dist/index.js",
@@ -22,21 +22,30 @@
22
22
  "access": "public"
23
23
  },
24
24
  "scripts": {
25
- "build": "vite build"
25
+ "build": "vite build",
26
+ "prepack": "npm test",
27
+ "test": "npm run build && node --test"
26
28
  },
27
29
  "license": "MIT",
28
30
  "peerDependencies": {
29
- "eslint": ">= 8",
31
+ "eslint": ">= 9.27.0 < 11",
30
32
  "prettier": ">= 3",
31
- "typescript": ">= 5"
33
+ "typescript": ">= 5 < 6.1"
32
34
  },
33
35
  "dependencies": {
34
- "@rushstack/eslint-config": "^4.6.4"
36
+ "@rushstack/eslint-config": "^4.6.5"
35
37
  },
36
38
  "devDependencies": {
37
- "@rollup/plugin-commonjs": "^28.0.6",
38
- "eslint": "^9.36.0",
39
- "typescript": "^5.8.3",
40
- "vite": "^7.1.11"
39
+ "eslint": "^9.39.5",
40
+ "eslint9min": "npm:eslint@9.27.0",
41
+ "eslint10": "npm:eslint@^10.9.1",
42
+ "typescript": "6.0.3",
43
+ "vite": "^8.2.2"
44
+ },
45
+ "overrides": {
46
+ "@typescript-eslint/eslint-plugin": "8.68.0",
47
+ "@typescript-eslint/parser": "8.68.0",
48
+ "@typescript-eslint/typescript-estree": "8.68.0",
49
+ "@typescript-eslint/utils": "8.68.0"
41
50
  }
42
51
  }