@fast-china/eslint-config 2.0.4 → 2.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/CHANGELOG.md +15 -0
- package/CONTRIBUTING.md +62 -0
- package/README.md +19 -6
- package/README.zh.md +19 -6
- package/SECURITY.md +133 -0
- package/dist/configs/angular.d.mts +7 -2
- package/dist/configs/angular.d.mts.map +1 -1
- package/dist/configs/angular.mjs +4 -0
- package/dist/configs/angular.mjs.map +1 -1
- package/dist/configs/common.d.mts +4 -0
- package/dist/configs/common.d.mts.map +1 -1
- package/dist/configs/common.mjs +4 -0
- package/dist/configs/common.mjs.map +1 -1
- package/dist/configs/environment.d.mts +16 -4
- package/dist/configs/environment.d.mts.map +1 -1
- package/dist/configs/environment.mjs +4 -0
- package/dist/configs/environment.mjs.map +1 -1
- package/dist/configs/ignores.d.mts +16 -2
- package/dist/configs/ignores.d.mts.map +1 -1
- package/dist/configs/ignores.mjs +16 -2
- package/dist/configs/ignores.mjs.map +1 -1
- package/dist/configs/import.d.mts +4 -0
- package/dist/configs/import.d.mts.map +1 -1
- package/dist/configs/import.mjs +4 -0
- package/dist/configs/import.mjs.map +1 -1
- package/dist/configs/javascript.d.mts +5 -0
- package/dist/configs/javascript.d.mts.map +1 -1
- package/dist/configs/javascript.mjs +5 -0
- package/dist/configs/javascript.mjs.map +1 -1
- package/dist/configs/json.d.mts +4 -0
- package/dist/configs/json.d.mts.map +1 -1
- package/dist/configs/json.mjs +4 -0
- package/dist/configs/json.mjs.map +1 -1
- package/dist/configs/lodash.d.mts +11 -1
- package/dist/configs/lodash.d.mts.map +1 -1
- package/dist/configs/lodash.mjs +6 -0
- package/dist/configs/lodash.mjs.map +1 -1
- package/dist/configs/markdown.d.mts +3 -0
- package/dist/configs/markdown.d.mts.map +1 -1
- package/dist/configs/markdown.mjs +3 -0
- package/dist/configs/markdown.mjs.map +1 -1
- package/dist/configs/prettier.d.mts +3 -0
- package/dist/configs/prettier.d.mts.map +1 -1
- package/dist/configs/prettier.mjs +3 -0
- package/dist/configs/prettier.mjs.map +1 -1
- package/dist/configs/react.d.mts +13 -6
- package/dist/configs/react.d.mts.map +1 -1
- package/dist/configs/react.mjs +5 -0
- package/dist/configs/react.mjs.map +1 -1
- package/dist/configs/regexp.d.mts +4 -0
- package/dist/configs/regexp.d.mts.map +1 -1
- package/dist/configs/regexp.mjs +4 -0
- package/dist/configs/regexp.mjs.map +1 -1
- package/dist/configs/sort-package.d.mts +3 -0
- package/dist/configs/sort-package.d.mts.map +1 -1
- package/dist/configs/sort-package.mjs +3 -0
- package/dist/configs/sort-package.mjs.map +1 -1
- package/dist/configs/sort-tsconfig.d.mts +3 -0
- package/dist/configs/sort-tsconfig.d.mts.map +1 -1
- package/dist/configs/sort-tsconfig.mjs +3 -0
- package/dist/configs/sort-tsconfig.mjs.map +1 -1
- package/dist/configs/typescript.d.mts +19 -3
- package/dist/configs/typescript.d.mts.map +1 -1
- package/dist/configs/typescript.mjs +16 -1
- package/dist/configs/typescript.mjs.map +1 -1
- package/dist/configs/vue.d.mts +7 -2
- package/dist/configs/vue.d.mts.map +1 -1
- package/dist/configs/vue.mjs +4 -0
- package/dist/configs/vue.mjs.map +1 -1
- package/dist/constants/index.d.mts +12 -2
- package/dist/constants/index.d.mts.map +1 -1
- package/dist/constants/index.mjs +12 -2
- package/dist/constants/index.mjs.map +1 -1
- package/dist/index.d.mts +48 -19
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +31 -1
- package/dist/index.mjs.map +1 -1
- package/dist/rules/angular.d.mts +15 -2
- package/dist/rules/angular.d.mts.map +1 -1
- package/dist/rules/angular.mjs +15 -2
- package/dist/rules/angular.mjs.map +1 -1
- package/dist/rules/common.d.mts +1 -0
- package/dist/rules/common.d.mts.map +1 -1
- package/dist/rules/common.mjs +1 -0
- package/dist/rules/common.mjs.map +1 -1
- package/dist/rules/import.d.mts +7 -1
- package/dist/rules/import.d.mts.map +1 -1
- package/dist/rules/import.mjs +7 -1
- package/dist/rules/import.mjs.map +1 -1
- package/dist/rules/javascript.d.mts +2 -0
- package/dist/rules/javascript.d.mts.map +1 -1
- package/dist/rules/javascript.mjs +2 -0
- package/dist/rules/javascript.mjs.map +1 -1
- package/dist/rules/lodash.d.mts +2 -0
- package/dist/rules/lodash.d.mts.map +1 -1
- package/dist/rules/lodash.mjs +2 -0
- package/dist/rules/lodash.mjs.map +1 -1
- package/dist/rules/react.d.mts +1 -0
- package/dist/rules/react.d.mts.map +1 -1
- package/dist/rules/react.mjs +1 -0
- package/dist/rules/react.mjs.map +1 -1
- package/dist/rules/sort-package.d.mts +1 -0
- package/dist/rules/sort-package.d.mts.map +1 -1
- package/dist/rules/sort-package.mjs +1 -0
- package/dist/rules/sort-package.mjs.map +1 -1
- package/dist/rules/sort-tsconfig.d.mts +1 -0
- package/dist/rules/sort-tsconfig.d.mts.map +1 -1
- package/dist/rules/sort-tsconfig.mjs +1 -0
- package/dist/rules/sort-tsconfig.mjs.map +1 -1
- package/dist/rules/typescript.d.mts +2 -0
- package/dist/rules/typescript.d.mts.map +1 -1
- package/dist/rules/typescript.mjs +2 -0
- package/dist/rules/typescript.mjs.map +1 -1
- package/dist/rules/vue.d.mts +2 -0
- package/dist/rules/vue.d.mts.map +1 -1
- package/dist/rules/vue.mjs +2 -0
- package/dist/rules/vue.mjs.map +1 -1
- package/docs/engineering-audit.zh.md +4 -2
- package/package.json +7 -3
|
@@ -2,8 +2,12 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* 创建模块导入规则配置。
|
|
4
4
|
*
|
|
5
|
+
* @remarks
|
|
5
6
|
* 共享库不猜测项目的路径别名或解析器,因此只继承 import-x 的推荐能力,
|
|
6
7
|
* 与 resolver 强耦合且容易误报的规则会在本地规则记录中显式关闭。
|
|
8
|
+
*
|
|
9
|
+
* @param files - 应用 import-x 推荐规则与本地覆盖规则的 ESLint glob 列表。
|
|
10
|
+
* @returns 包含 import-x 插件预置和本地规则的 Flat Config 数组。
|
|
7
11
|
*/
|
|
8
12
|
declare const createImportConfigs: (files?: readonly string[]) => import("eslint/config").ConfigObject[];
|
|
9
13
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import.d.mts","names":[],"sources":["../../src/configs/import.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"import.d.mts","names":[],"sources":["../../src/configs/import.ts"],"mappings":";;;;;;;;;;;cAgBa,sBAAuB,sDAAqC"}
|
package/dist/configs/import.mjs
CHANGED
|
@@ -6,8 +6,12 @@ import eslintPluginImportX from "eslint-plugin-import-x";
|
|
|
6
6
|
/**
|
|
7
7
|
* 创建模块导入规则配置。
|
|
8
8
|
*
|
|
9
|
+
* @remarks
|
|
9
10
|
* 共享库不猜测项目的路径别名或解析器,因此只继承 import-x 的推荐能力,
|
|
10
11
|
* 与 resolver 强耦合且容易误报的规则会在本地规则记录中显式关闭。
|
|
12
|
+
*
|
|
13
|
+
* @param files - 应用 import-x 推荐规则与本地覆盖规则的 ESLint glob 列表。
|
|
14
|
+
* @returns 包含 import-x 插件预置和本地规则的 Flat Config 数组。
|
|
11
15
|
*/
|
|
12
16
|
const createImportConfigs = (files = GLOBS_CODE) => defineConfig([{
|
|
13
17
|
name: "@fast-china/import",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import.mjs","names":[],"sources":["../../src/configs/import.ts"],"sourcesContent":["import { defineConfig } from \"eslint/config\";\nimport eslintPluginImportX from \"eslint-plugin-import-x\";\n\nimport { GLOBS_CODE } from \"../constants\";\nimport { importRules } from \"../rules\";\n\n/**\n * 创建模块导入规则配置。\n *\n * 共享库不猜测项目的路径别名或解析器,因此只继承 import-x 的推荐能力,\n * 与 resolver 强耦合且容易误报的规则会在本地规则记录中显式关闭。\n */\nexport const createImportConfigs = (files: readonly string[] = GLOBS_CODE) =>\n\tdefineConfig([\n\t\t{\n\t\t\tname: \"@fast-china/import\",\n\t\t\tfiles: [...files],\n\t\t\textends: [eslintPluginImportX.flatConfigs.recommended],\n\t\t\trules: importRules,\n\t\t},\n\t]);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"import.mjs","names":[],"sources":["../../src/configs/import.ts"],"sourcesContent":["import { defineConfig } from \"eslint/config\";\nimport eslintPluginImportX from \"eslint-plugin-import-x\";\n\nimport { GLOBS_CODE } from \"../constants\";\nimport { importRules } from \"../rules\";\n\n/**\n * 创建模块导入规则配置。\n *\n * @remarks\n * 共享库不猜测项目的路径别名或解析器,因此只继承 import-x 的推荐能力,\n * 与 resolver 强耦合且容易误报的规则会在本地规则记录中显式关闭。\n *\n * @param files - 应用 import-x 推荐规则与本地覆盖规则的 ESLint glob 列表。\n * @returns 包含 import-x 插件预置和本地规则的 Flat Config 数组。\n */\nexport const createImportConfigs = (files: readonly string[] = GLOBS_CODE) =>\n\tdefineConfig([\n\t\t{\n\t\t\tname: \"@fast-china/import\",\n\t\t\tfiles: [...files],\n\t\t\textends: [eslintPluginImportX.flatConfigs.recommended],\n\t\t\trules: importRules,\n\t\t},\n\t]);\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,MAAa,uBAAuB,QAA2B,eAC9D,aAAa,CACZ;CACC,MAAM;CACN,OAAO,CAAC,GAAG,KAAK;CAChB,SAAS,CAAC,oBAAoB,YAAY,WAAW;CACrD,OAAO;AACR,CACD,CAAC"}
|
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* 创建 JavaScript/JSX 配置。
|
|
4
4
|
*
|
|
5
|
+
* @remarks
|
|
5
6
|
* `@eslint/js` 提供基础正确性规则,本仓库只在其后补充有明确维护理由的规则。
|
|
7
|
+
* 普通 `.jsx` 文件会显式启用 JSX 语法解析,但不会因此自动启用 React 规则。
|
|
8
|
+
*
|
|
9
|
+
* @param files - 应用 JavaScript 基础规则的 ESLint glob 列表。
|
|
10
|
+
* @returns 包含 JavaScript 推荐预置、本地规则与 JSX 解析设置的 Flat Config 数组。
|
|
6
11
|
*/
|
|
7
12
|
declare const createJavaScriptConfigs: (files?: readonly string[]) => import("eslint/config").ConfigObject[];
|
|
8
13
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"javascript.d.mts","names":[],"sources":["../../src/configs/javascript.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"javascript.d.mts","names":[],"sources":["../../src/configs/javascript.ts"],"mappings":";;;;;;;;;;;cAgBa,0BAA2B,sDAA2C"}
|
|
@@ -6,7 +6,12 @@ import eslint from "@eslint/js";
|
|
|
6
6
|
/**
|
|
7
7
|
* 创建 JavaScript/JSX 配置。
|
|
8
8
|
*
|
|
9
|
+
* @remarks
|
|
9
10
|
* `@eslint/js` 提供基础正确性规则,本仓库只在其后补充有明确维护理由的规则。
|
|
11
|
+
* 普通 `.jsx` 文件会显式启用 JSX 语法解析,但不会因此自动启用 React 规则。
|
|
12
|
+
*
|
|
13
|
+
* @param files - 应用 JavaScript 基础规则的 ESLint glob 列表。
|
|
14
|
+
* @returns 包含 JavaScript 推荐预置、本地规则与 JSX 解析设置的 Flat Config 数组。
|
|
10
15
|
*/
|
|
11
16
|
const createJavaScriptConfigs = (files = GLOBS_JAVASCRIPT) => defineConfig([{
|
|
12
17
|
name: "@fast-china/javascript",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"javascript.mjs","names":[],"sources":["../../src/configs/javascript.ts"],"sourcesContent":["import eslint from \"@eslint/js\";\nimport { defineConfig } from \"eslint/config\";\n\nimport { GLOBS_JAVASCRIPT } from \"../constants\";\nimport { javascriptRules } from \"../rules\";\n\n/**\n * 创建 JavaScript/JSX 配置。\n *\n * `@eslint/js` 提供基础正确性规则,本仓库只在其后补充有明确维护理由的规则。\n */\nexport const createJavaScriptConfigs = (files: readonly string[] = GLOBS_JAVASCRIPT) =>\n\tdefineConfig([\n\t\t{\n\t\t\tname: \"@fast-china/javascript\",\n\t\t\tfiles: [...files],\n\t\t\textends: [eslint.configs.recommended],\n\t\t\tlanguageOptions: {\n\t\t\t\tecmaVersion: \"latest\",\n\t\t\t\tparserOptions: {\n\t\t\t\t\tecmaFeatures: {\n\t\t\t\t\t\t// 普通 `.jsx` 文件需要显式开启 JSX 语法解析。\n\t\t\t\t\t\tjsx: true,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\trules: javascriptRules,\n\t\t},\n\t]);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"javascript.mjs","names":[],"sources":["../../src/configs/javascript.ts"],"sourcesContent":["import eslint from \"@eslint/js\";\nimport { defineConfig } from \"eslint/config\";\n\nimport { GLOBS_JAVASCRIPT } from \"../constants\";\nimport { javascriptRules } from \"../rules\";\n\n/**\n * 创建 JavaScript/JSX 配置。\n *\n * @remarks\n * `@eslint/js` 提供基础正确性规则,本仓库只在其后补充有明确维护理由的规则。\n * 普通 `.jsx` 文件会显式启用 JSX 语法解析,但不会因此自动启用 React 规则。\n *\n * @param files - 应用 JavaScript 基础规则的 ESLint glob 列表。\n * @returns 包含 JavaScript 推荐预置、本地规则与 JSX 解析设置的 Flat Config 数组。\n */\nexport const createJavaScriptConfigs = (files: readonly string[] = GLOBS_JAVASCRIPT) =>\n\tdefineConfig([\n\t\t{\n\t\t\tname: \"@fast-china/javascript\",\n\t\t\tfiles: [...files],\n\t\t\textends: [eslint.configs.recommended],\n\t\t\tlanguageOptions: {\n\t\t\t\tecmaVersion: \"latest\",\n\t\t\t\tparserOptions: {\n\t\t\t\t\tecmaFeatures: {\n\t\t\t\t\t\t// 普通 `.jsx` 文件需要显式开启 JSX 语法解析。\n\t\t\t\t\t\tjsx: true,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\trules: javascriptRules,\n\t\t},\n\t]);\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,MAAa,2BAA2B,QAA2B,qBAClE,aAAa,CACZ;CACC,MAAM;CACN,OAAO,CAAC,GAAG,KAAK;CAChB,SAAS,CAAC,OAAO,QAAQ,WAAW;CACpC,iBAAiB;EAChB,aAAa;EACb,eAAe,EACd,cAAc,EAEb,KAAK,KACN,EACD;CACD;CACA,OAAO;AACR,CACD,CAAC"}
|
package/dist/configs/json.d.mts
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* 创建 JSON、JSONC 与 JSON5 配置。
|
|
4
4
|
*
|
|
5
|
+
* @remarks
|
|
5
6
|
* 三种方言使用各自的官方推荐预置,避免严格 JSON 规则错误覆盖允许注释或尾随逗号的文件。
|
|
7
|
+
* VS Code 的 `.vscode/settings.json` 仍以 `.json` 结尾,因此额外允许其中出现注释。
|
|
8
|
+
*
|
|
9
|
+
* @returns 按 JSON、JSONC、JSON5 与 VS Code 设置覆盖顺序排列的 Flat Config 数组。
|
|
6
10
|
*/
|
|
7
11
|
declare const createJsonConfigs: () => import("eslint/config").ConfigObject[];
|
|
8
12
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.mts","names":[],"sources":["../../src/configs/json.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"json.d.mts","names":[],"sources":["../../src/configs/json.ts"],"mappings":";;;;;;;;;;cAca,iDAAiB"}
|
package/dist/configs/json.mjs
CHANGED
|
@@ -5,7 +5,11 @@ import eslintPluginJsonc from "eslint-plugin-jsonc";
|
|
|
5
5
|
/**
|
|
6
6
|
* 创建 JSON、JSONC 与 JSON5 配置。
|
|
7
7
|
*
|
|
8
|
+
* @remarks
|
|
8
9
|
* 三种方言使用各自的官方推荐预置,避免严格 JSON 规则错误覆盖允许注释或尾随逗号的文件。
|
|
10
|
+
* VS Code 的 `.vscode/settings.json` 仍以 `.json` 结尾,因此额外允许其中出现注释。
|
|
11
|
+
*
|
|
12
|
+
* @returns 按 JSON、JSONC、JSON5 与 VS Code 设置覆盖顺序排列的 Flat Config 数组。
|
|
9
13
|
*/
|
|
10
14
|
const createJsonConfigs = () => defineConfig([
|
|
11
15
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.mjs","names":[],"sources":["../../src/configs/json.ts"],"sourcesContent":["import { defineConfig } from \"eslint/config\";\nimport eslintPluginJsonc from \"eslint-plugin-jsonc\";\n\nimport { GLOB_JSON, GLOB_JSON5, GLOB_JSONC } from \"../constants\";\n\n/**\n * 创建 JSON、JSONC 与 JSON5 配置。\n *\n * 三种方言使用各自的官方推荐预置,避免严格 JSON 规则错误覆盖允许注释或尾随逗号的文件。\n */\nexport const createJsonConfigs = () =>\n\tdefineConfig([\n\t\t{\n\t\t\tname: \"@fast-china/json/json\",\n\t\t\tfiles: [GLOB_JSON],\n\t\t\textends: [eslintPluginJsonc.configs[\"flat/recommended-with-json\"]],\n\t\t},\n\t\t{\n\t\t\tname: \"@fast-china/json/jsonc\",\n\t\t\tfiles: [GLOB_JSONC],\n\t\t\textends: [eslintPluginJsonc.configs[\"flat/recommended-with-jsonc\"]],\n\t\t},\n\t\t{\n\t\t\tname: \"@fast-china/json/json5\",\n\t\t\tfiles: [GLOB_JSON5],\n\t\t\textends: [eslintPluginJsonc.configs[\"flat/recommended-with-json5\"]],\n\t\t},\n\t\t{\n\t\t\tname: \"@fast-china/json/vscode-settings\",\n\t\t\tfiles: [\"**/.vscode/settings.json\"],\n\t\t\trules: {\n\t\t\t\t// VS Code 的 settings.json 使用带注释的 JSONC 方言。\n\t\t\t\t\"jsonc/no-comments\": \"off\",\n\t\t\t},\n\t\t},\n\t]);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"json.mjs","names":[],"sources":["../../src/configs/json.ts"],"sourcesContent":["import { defineConfig } from \"eslint/config\";\nimport eslintPluginJsonc from \"eslint-plugin-jsonc\";\n\nimport { GLOB_JSON, GLOB_JSON5, GLOB_JSONC } from \"../constants\";\n\n/**\n * 创建 JSON、JSONC 与 JSON5 配置。\n *\n * @remarks\n * 三种方言使用各自的官方推荐预置,避免严格 JSON 规则错误覆盖允许注释或尾随逗号的文件。\n * VS Code 的 `.vscode/settings.json` 仍以 `.json` 结尾,因此额外允许其中出现注释。\n *\n * @returns 按 JSON、JSONC、JSON5 与 VS Code 设置覆盖顺序排列的 Flat Config 数组。\n */\nexport const createJsonConfigs = () =>\n\tdefineConfig([\n\t\t{\n\t\t\tname: \"@fast-china/json/json\",\n\t\t\tfiles: [GLOB_JSON],\n\t\t\textends: [eslintPluginJsonc.configs[\"flat/recommended-with-json\"]],\n\t\t},\n\t\t{\n\t\t\tname: \"@fast-china/json/jsonc\",\n\t\t\tfiles: [GLOB_JSONC],\n\t\t\textends: [eslintPluginJsonc.configs[\"flat/recommended-with-jsonc\"]],\n\t\t},\n\t\t{\n\t\t\tname: \"@fast-china/json/json5\",\n\t\t\tfiles: [GLOB_JSON5],\n\t\t\textends: [eslintPluginJsonc.configs[\"flat/recommended-with-json5\"]],\n\t\t},\n\t\t{\n\t\t\tname: \"@fast-china/json/vscode-settings\",\n\t\t\tfiles: [\"**/.vscode/settings.json\"],\n\t\t\trules: {\n\t\t\t\t// VS Code 的 settings.json 使用带注释的 JSONC 方言。\n\t\t\t\t\"jsonc/no-comments\": \"off\",\n\t\t\t},\n\t\t},\n\t]);\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAa,0BACZ,aAAa;CACZ;EACC,MAAM;EACN,OAAO,CAAC,SAAS;EACjB,SAAS,CAAC,kBAAkB,QAAQ,6BAA6B;CAClE;CACA;EACC,MAAM;EACN,OAAO,CAAC,UAAU;EAClB,SAAS,CAAC,kBAAkB,QAAQ,8BAA8B;CACnE;CACA;EACC,MAAM;EACN,OAAO,CAAC,UAAU;EAClB,SAAS,CAAC,kBAAkB,QAAQ,8BAA8B;CACnE;CACA;EACC,MAAM;EACN,OAAO,CAAC,0BAA0B;EAClC,OAAO,EAEN,qBAAqB,MACtB;CACD;AACD,CAAC"}
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
//#region src/configs/lodash.d.ts
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* 项目允许使用的 Lodash 静态导入来源。
|
|
4
|
+
*
|
|
5
|
+
* `"lodash"` 允许根入口及 `lodash/*` 子路径;`"lodash-unified"` 只允许统一入口。
|
|
6
|
+
*/
|
|
3
7
|
type LodashPreference = "lodash" | "lodash-unified";
|
|
4
8
|
/**
|
|
5
9
|
* 创建 Lodash 静态导入约束。
|
|
6
10
|
*
|
|
11
|
+
* @remarks
|
|
7
12
|
* 该配置使用 ESLint 核心规则,因此不依赖 import-x 开关或额外插件。
|
|
13
|
+
* 它只检查静态 `import` 与 `export ... from`,不会安装依赖或检查动态导入。
|
|
14
|
+
*
|
|
15
|
+
* @param preference - 项目唯一允许使用的 Lodash 包入口。
|
|
16
|
+
* @param files - 应用导入约束的 ESLint glob 列表。
|
|
17
|
+
* @returns 包含对应 Lodash 导入限制规则的 Flat Config 数组。
|
|
8
18
|
*/
|
|
9
19
|
declare const createLodashConfigs: (preference: LodashPreference, files?: readonly string[]) => import("eslint/config").ConfigObject[];
|
|
10
20
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lodash.d.mts","names":[],"sources":["../../src/configs/lodash.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"lodash.d.mts","names":[],"sources":["../../src/configs/lodash.ts"],"mappings":";;;;;;KAUY;;;;;;;;;;;;cAaC,sBAAuB,YAAY,kBAAkB,sDAAqC"}
|
package/dist/configs/lodash.mjs
CHANGED
|
@@ -5,7 +5,13 @@ import { defineConfig } from "eslint/config";
|
|
|
5
5
|
/**
|
|
6
6
|
* 创建 Lodash 静态导入约束。
|
|
7
7
|
*
|
|
8
|
+
* @remarks
|
|
8
9
|
* 该配置使用 ESLint 核心规则,因此不依赖 import-x 开关或额外插件。
|
|
10
|
+
* 它只检查静态 `import` 与 `export ... from`,不会安装依赖或检查动态导入。
|
|
11
|
+
*
|
|
12
|
+
* @param preference - 项目唯一允许使用的 Lodash 包入口。
|
|
13
|
+
* @param files - 应用导入约束的 ESLint glob 列表。
|
|
14
|
+
* @returns 包含对应 Lodash 导入限制规则的 Flat Config 数组。
|
|
9
15
|
*/
|
|
10
16
|
const createLodashConfigs = (preference, files = GLOBS_CODE) => defineConfig([{
|
|
11
17
|
name: `@fast-china/lodash/${preference}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lodash.mjs","names":[],"sources":["../../src/configs/lodash.ts"],"sourcesContent":["import { defineConfig } from \"eslint/config\";\n\nimport { GLOBS_CODE } from \"../constants\";\nimport { preferLodashRules, preferLodashUnifiedRules } from \"../rules\";\n\n
|
|
1
|
+
{"version":3,"file":"lodash.mjs","names":[],"sources":["../../src/configs/lodash.ts"],"sourcesContent":["import { defineConfig } from \"eslint/config\";\n\nimport { GLOBS_CODE } from \"../constants\";\nimport { preferLodashRules, preferLodashUnifiedRules } from \"../rules\";\n\n/**\n * 项目允许使用的 Lodash 静态导入来源。\n *\n * `\"lodash\"` 允许根入口及 `lodash/*` 子路径;`\"lodash-unified\"` 只允许统一入口。\n */\nexport type LodashPreference = \"lodash\" | \"lodash-unified\";\n\n/**\n * 创建 Lodash 静态导入约束。\n *\n * @remarks\n * 该配置使用 ESLint 核心规则,因此不依赖 import-x 开关或额外插件。\n * 它只检查静态 `import` 与 `export ... from`,不会安装依赖或检查动态导入。\n *\n * @param preference - 项目唯一允许使用的 Lodash 包入口。\n * @param files - 应用导入约束的 ESLint glob 列表。\n * @returns 包含对应 Lodash 导入限制规则的 Flat Config 数组。\n */\nexport const createLodashConfigs = (preference: LodashPreference, files: readonly string[] = GLOBS_CODE) =>\n\tdefineConfig([\n\t\t{\n\t\t\tname: `@fast-china/lodash/${preference}`,\n\t\t\tfiles: [...files],\n\t\t\trules: preference === \"lodash\" ? preferLodashRules : preferLodashUnifiedRules,\n\t\t},\n\t]);\n"],"mappings":";;;;;;;;;;;;;;;AAuBA,MAAa,uBAAuB,YAA8B,QAA2B,eAC5F,aAAa,CACZ;CACC,MAAM,sBAAsB;CAC5B,OAAO,CAAC,GAAG,KAAK;CAChB,OAAO,eAAe,WAAW,oBAAoB;AACtD,CACD,CAAC"}
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* 创建 Markdown 结构与语法检查配置。
|
|
4
4
|
*
|
|
5
|
+
* @remarks
|
|
5
6
|
* 该配置检查 Markdown 文档本身;代码块是否接受额外语言规则由项目覆盖配置决定。
|
|
7
|
+
*
|
|
8
|
+
* @returns 包含 `@eslint/markdown` 推荐预置的 Flat Config 数组。
|
|
6
9
|
*/
|
|
7
10
|
declare const createMarkdownConfigs: () => import("eslint/config").ConfigObject[];
|
|
8
11
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.mts","names":[],"sources":["../../src/configs/markdown.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"markdown.d.mts","names":[],"sources":["../../src/configs/markdown.ts"],"mappings":";;;;;;;;;cAaa,qDAAqB"}
|
|
@@ -5,7 +5,10 @@ import eslintMarkdown from "@eslint/markdown";
|
|
|
5
5
|
/**
|
|
6
6
|
* 创建 Markdown 结构与语法检查配置。
|
|
7
7
|
*
|
|
8
|
+
* @remarks
|
|
8
9
|
* 该配置检查 Markdown 文档本身;代码块是否接受额外语言规则由项目覆盖配置决定。
|
|
10
|
+
*
|
|
11
|
+
* @returns 包含 `@eslint/markdown` 推荐预置的 Flat Config 数组。
|
|
9
12
|
*/
|
|
10
13
|
const createMarkdownConfigs = () => defineConfig([{
|
|
11
14
|
name: "@fast-china/markdown",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.mjs","names":[],"sources":["../../src/configs/markdown.ts"],"sourcesContent":["import eslintMarkdown from \"@eslint/markdown\";\nimport { defineConfig } from \"eslint/config\";\n\nimport { GLOB_MARKDOWN } from \"../constants\";\n\n/**\n * 创建 Markdown 结构与语法检查配置。\n *\n * 该配置检查 Markdown 文档本身;代码块是否接受额外语言规则由项目覆盖配置决定。\n */\nexport const createMarkdownConfigs = () =>\n\tdefineConfig([\n\t\t{\n\t\t\tname: \"@fast-china/markdown\",\n\t\t\tfiles: [GLOB_MARKDOWN],\n\t\t\textends: [eslintMarkdown.configs.recommended],\n\t\t},\n\t]);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"markdown.mjs","names":[],"sources":["../../src/configs/markdown.ts"],"sourcesContent":["import eslintMarkdown from \"@eslint/markdown\";\nimport { defineConfig } from \"eslint/config\";\n\nimport { GLOB_MARKDOWN } from \"../constants\";\n\n/**\n * 创建 Markdown 结构与语法检查配置。\n *\n * @remarks\n * 该配置检查 Markdown 文档本身;代码块是否接受额外语言规则由项目覆盖配置决定。\n *\n * @returns 包含 `@eslint/markdown` 推荐预置的 Flat Config 数组。\n */\nexport const createMarkdownConfigs = () =>\n\tdefineConfig([\n\t\t{\n\t\t\tname: \"@fast-china/markdown\",\n\t\t\tfiles: [GLOB_MARKDOWN],\n\t\t\textends: [eslintMarkdown.configs.recommended],\n\t\t},\n\t]);\n"],"mappings":";;;;;;;;;;;;AAaA,MAAa,8BACZ,aAAa,CACZ;CACC,MAAM;CACN,OAAO,CAAC,aAAa;CACrB,SAAS,CAAC,eAAe,QAAQ,WAAW;AAC7C,CACD,CAAC"}
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* 创建 Prettier 兼容层。
|
|
4
4
|
*
|
|
5
|
+
* @remarks
|
|
5
6
|
* 它只关闭与 Prettier 冲突的 ESLint 格式规则,不会在 ESLint 进程中执行 Prettier。
|
|
6
7
|
* 工厂始终把它放在内置配置之后,使上游预置的格式规则能够被正确覆盖。
|
|
8
|
+
*
|
|
9
|
+
* @returns 包含命名后的 `eslint-config-prettier` Flat Config 数组。
|
|
7
10
|
*/
|
|
8
11
|
declare const createPrettierConfigs: () => import("eslint/config").ConfigObject[];
|
|
9
12
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prettier.d.mts","names":[],"sources":["../../src/configs/prettier.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"prettier.d.mts","names":[],"sources":["../../src/configs/prettier.ts"],"mappings":";;;;;;;;;;cAYa,qDAAqB"}
|
|
@@ -4,8 +4,11 @@ import eslintConfigPrettierFlat from "eslint-config-prettier/flat";
|
|
|
4
4
|
/**
|
|
5
5
|
* 创建 Prettier 兼容层。
|
|
6
6
|
*
|
|
7
|
+
* @remarks
|
|
7
8
|
* 它只关闭与 Prettier 冲突的 ESLint 格式规则,不会在 ESLint 进程中执行 Prettier。
|
|
8
9
|
* 工厂始终把它放在内置配置之后,使上游预置的格式规则能够被正确覆盖。
|
|
10
|
+
*
|
|
11
|
+
* @returns 包含命名后的 `eslint-config-prettier` Flat Config 数组。
|
|
9
12
|
*/
|
|
10
13
|
const createPrettierConfigs = () => defineConfig([{
|
|
11
14
|
...eslintConfigPrettierFlat,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prettier.mjs","names":[],"sources":["../../src/configs/prettier.ts"],"sourcesContent":["import { defineConfig } from \"eslint/config\";\nimport eslintConfigPrettierFlat from \"eslint-config-prettier/flat\";\n\n/**\n * 创建 Prettier 兼容层。\n *\n * 它只关闭与 Prettier 冲突的 ESLint 格式规则,不会在 ESLint 进程中执行 Prettier。\n * 工厂始终把它放在内置配置之后,使上游预置的格式规则能够被正确覆盖。\n */\nexport const createPrettierConfigs = () =>\n\tdefineConfig([\n\t\t{\n\t\t\t...eslintConfigPrettierFlat,\n\t\t\tname: \"@fast-china/prettier\",\n\t\t},\n\t]);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"prettier.mjs","names":[],"sources":["../../src/configs/prettier.ts"],"sourcesContent":["import { defineConfig } from \"eslint/config\";\nimport eslintConfigPrettierFlat from \"eslint-config-prettier/flat\";\n\n/**\n * 创建 Prettier 兼容层。\n *\n * @remarks\n * 它只关闭与 Prettier 冲突的 ESLint 格式规则,不会在 ESLint 进程中执行 Prettier。\n * 工厂始终把它放在内置配置之后,使上游预置的格式规则能够被正确覆盖。\n *\n * @returns 包含命名后的 `eslint-config-prettier` Flat Config 数组。\n */\nexport const createPrettierConfigs = () =>\n\tdefineConfig([\n\t\t{\n\t\t\t...eslintConfigPrettierFlat,\n\t\t\tname: \"@fast-china/prettier\",\n\t\t},\n\t]);\n"],"mappings":";;;;;;;;;;;;AAYA,MAAa,8BACZ,aAAa,CACZ;CACC,GAAG;CACH,MAAM;AACP,CACD,CAAC"}
|
package/dist/configs/react.d.mts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* React 与兼容 JSX 运行时的检测设置。
|
|
4
4
|
*
|
|
5
|
+
* @remarks
|
|
5
6
|
* 该对象通过 `fastConfig({ react: { ... } })` 传入。传入对象会启用 React 支持,并在
|
|
6
7
|
* JavaScript/JSX 和 TypeScript/TSX 文件上加载对应的 `@eslint-react` 推荐预置、React
|
|
7
8
|
* 官方 Hooks Flat Config 以及本库规则。实际文件范围仍受顶层 `javascript`、
|
|
@@ -17,7 +18,7 @@ interface ReactConfigOptions {
|
|
|
17
18
|
* 标准 React 项目保持 `"react"`;Preact 等兼容运行时可填写自身包名,使
|
|
18
19
|
* `@eslint-react` 按正确的导入来源识别组件和 API。该设置不会修改 TypeScript
|
|
19
20
|
* `jsxImportSource`、Babel、Vite 或其他构建工具配置,两侧需要由项目自行保持一致。
|
|
20
|
-
* @
|
|
21
|
+
* @defaultValue `"react"`
|
|
21
22
|
*/
|
|
22
23
|
importSource?: string;
|
|
23
24
|
/**
|
|
@@ -25,7 +26,7 @@ interface ReactConfigOptions {
|
|
|
25
26
|
*
|
|
26
27
|
* 例如 `<Button as="a" />` 中的 `as`。插件会据此理解多态组件最终渲染元素的语义,
|
|
27
28
|
* 从而提高 DOM 与可访问性相关规则的判断准确度;未采用多态组件时通常无需修改。
|
|
28
|
-
* @
|
|
29
|
+
* @defaultValue `"as"`
|
|
29
30
|
*/
|
|
30
31
|
polymorphicPropName?: string;
|
|
31
32
|
/**
|
|
@@ -34,13 +35,14 @@ interface ReactConfigOptions {
|
|
|
34
35
|
* `"detect"` 会尝试从当前项目依赖解析已安装的 React 版本。monorepo、PnP、兼容运行时
|
|
35
36
|
* 或依赖不可见的执行环境若无法可靠检测,可传入明确版本号,例如 `"19.1.0"`。
|
|
36
37
|
* 该值只影响 lint 规则判断,不会限制或安装 React 依赖版本。
|
|
37
|
-
* @
|
|
38
|
+
* @defaultValue `"detect"`
|
|
38
39
|
*/
|
|
39
40
|
version?: string;
|
|
40
41
|
}
|
|
41
42
|
/**
|
|
42
43
|
* React 配置生成器使用的语言状态。
|
|
43
44
|
*
|
|
45
|
+
* @remarks
|
|
44
46
|
* `fastConfig()` 会自动推导这些值;直接组合配置片段时由调用方显式传入。
|
|
45
47
|
*
|
|
46
48
|
* 用户不直接配置该接口。`fastConfig()` 会把顶层 JavaScript、TypeScript 开关以及
|
|
@@ -53,7 +55,7 @@ interface ReactLanguageOptions {
|
|
|
53
55
|
*
|
|
54
56
|
* 该值来自顶层 `FastConfigOptions.javascript`;为 `false` 时即使 React 已启用,
|
|
55
57
|
* React 配置也不会声明这些文件范围。
|
|
56
|
-
* @
|
|
58
|
+
* @defaultValue `true`
|
|
57
59
|
*/
|
|
58
60
|
javascript?: boolean;
|
|
59
61
|
/**
|
|
@@ -61,7 +63,7 @@ interface ReactLanguageOptions {
|
|
|
61
63
|
*
|
|
62
64
|
* 该值来自 `FastConfigOptions.typescript.typeChecked`,只影响 TypeScript React 配置;
|
|
63
65
|
* JavaScript 配置始终使用普通推荐预置。
|
|
64
|
-
* @
|
|
66
|
+
* @defaultValue `false`
|
|
65
67
|
*/
|
|
66
68
|
typeChecked?: boolean;
|
|
67
69
|
/**
|
|
@@ -69,16 +71,21 @@ interface ReactLanguageOptions {
|
|
|
69
71
|
*
|
|
70
72
|
* 该值来自顶层 `FastConfigOptions.typescript`;为 `false` 时不会生成 TypeScript React
|
|
71
73
|
* 片段,也不会仅因为 React 已启用而重新接管 TypeScript 文件。
|
|
72
|
-
* @
|
|
74
|
+
* @defaultValue `true`
|
|
73
75
|
*/
|
|
74
76
|
typescript?: boolean;
|
|
75
77
|
}
|
|
76
78
|
/**
|
|
77
79
|
* 创建 React、JSX/TSX 与 Hooks 配置。
|
|
78
80
|
*
|
|
81
|
+
* @remarks
|
|
79
82
|
* JavaScript 和 TypeScript 分别继承对应的 @eslint-react 推荐预置;Hooks 使用
|
|
80
83
|
* React 官方 Flat Config。组件、Hooks 即使不返回 JSX 也能在普通 `.js`/`.ts` 中
|
|
81
84
|
* 定义,因此规则覆盖全部已启用脚本扩展名,而不仅是 `.jsx`/`.tsx`。
|
|
85
|
+
*
|
|
86
|
+
* @param options - React 版本、运行时导入来源与多态组件属性设置。
|
|
87
|
+
* @param languages - 由调用方启用的脚本语言以及 TypeScript 类型感知状态。
|
|
88
|
+
* @returns 仅包含已启用语言的 React 与 Hooks Flat Config 数组。
|
|
82
89
|
*/
|
|
83
90
|
declare const createReactConfigs: ({ importSource, polymorphicPropName, version }?: ReactConfigOptions, { javascript, typeChecked, typescript }?: ReactLanguageOptions) => import("eslint/config").ConfigObject[];
|
|
84
91
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.mts","names":[],"sources":["../../src/configs/react.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"react.d.mts","names":[],"sources":["../../src/configs/react.ts"],"mappings":";;;;;;;;;;;;;UAqBiB;;;;;;;;;EAShB;;;;;;;;EAQA;;;;;;;;;EASA;;;;;;;;;;;;UAaS;;;;;;;;EAQT;;;;;;;;EAQA;;;;;;;;EAQA;;;;;;;;;;;;;;cAeY,uBACZ,cAAA,qBAAA,YAA4E,sBAC5E,YAAA,aAAA,eAA+D,iDAAyB"}
|
package/dist/configs/react.mjs
CHANGED
|
@@ -7,9 +7,14 @@ import eslintPluginReactHooks from "eslint-plugin-react-hooks";
|
|
|
7
7
|
/**
|
|
8
8
|
* 创建 React、JSX/TSX 与 Hooks 配置。
|
|
9
9
|
*
|
|
10
|
+
* @remarks
|
|
10
11
|
* JavaScript 和 TypeScript 分别继承对应的 @eslint-react 推荐预置;Hooks 使用
|
|
11
12
|
* React 官方 Flat Config。组件、Hooks 即使不返回 JSX 也能在普通 `.js`/`.ts` 中
|
|
12
13
|
* 定义,因此规则覆盖全部已启用脚本扩展名,而不仅是 `.jsx`/`.tsx`。
|
|
14
|
+
*
|
|
15
|
+
* @param options - React 版本、运行时导入来源与多态组件属性设置。
|
|
16
|
+
* @param languages - 由调用方启用的脚本语言以及 TypeScript 类型感知状态。
|
|
17
|
+
* @returns 仅包含已启用语言的 React 与 Hooks Flat Config 数组。
|
|
13
18
|
*/
|
|
14
19
|
const createReactConfigs = ({ importSource = "react", polymorphicPropName = "as", version = "detect" } = {}, { javascript = true, typeChecked = false, typescript = true } = {}) => {
|
|
15
20
|
const createConfig = (name, files, preset) => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.mjs","names":[],"sources":["../../src/configs/react.ts"],"sourcesContent":["import eslintReact from \"@eslint-react/eslint-plugin\";\nimport { defineConfig } from \"eslint/config\";\nimport eslintPluginReactHooks from \"eslint-plugin-react-hooks\";\n\nimport { GLOBS_JAVASCRIPT, GLOBS_TYPESCRIPT } from \"../constants\";\nimport { reactRules } from \"../rules\";\n\nimport type { Linter } from \"eslint\";\n\n/**\n * React 与兼容 JSX 运行时的检测设置。\n *\n * 该对象通过 `fastConfig({ react: { ... } })` 传入。传入对象会启用 React 支持,并在\n * JavaScript/JSX 和 TypeScript/TSX 文件上加载对应的 `@eslint-react` 推荐预置、React\n * 官方 Hooks Flat Config 以及本库规则。实际文件范围仍受顶层 `javascript`、\n * `typescript` 开关控制。\n *\n * 这些字段只传给 ESLint 插件用于理解项目的 React 语义,不会改变 JSX 编译方式、自动\n * 导入 React、设置打包器别名或安装兼容运行时。\n */\nexport interface ReactConfigOptions {\n\t/**\n\t * 提供 React API 与 JSX 运行时的包入口名称。\n\t *\n\t * 标准 React 项目保持 `\"react\"`;Preact 等兼容运行时可填写自身包名,使\n\t * `@eslint-react` 按正确的导入来源识别组件和 API。该设置不会修改 TypeScript\n\t * `jsxImportSource`、Babel、Vite 或其他构建工具配置,两侧需要由项目自行保持一致。\n\t * @
|
|
1
|
+
{"version":3,"file":"react.mjs","names":[],"sources":["../../src/configs/react.ts"],"sourcesContent":["import eslintReact from \"@eslint-react/eslint-plugin\";\nimport { defineConfig } from \"eslint/config\";\nimport eslintPluginReactHooks from \"eslint-plugin-react-hooks\";\n\nimport { GLOBS_JAVASCRIPT, GLOBS_TYPESCRIPT } from \"../constants\";\nimport { reactRules } from \"../rules\";\n\nimport type { Linter } from \"eslint\";\n\n/**\n * React 与兼容 JSX 运行时的检测设置。\n *\n * @remarks\n * 该对象通过 `fastConfig({ react: { ... } })` 传入。传入对象会启用 React 支持,并在\n * JavaScript/JSX 和 TypeScript/TSX 文件上加载对应的 `@eslint-react` 推荐预置、React\n * 官方 Hooks Flat Config 以及本库规则。实际文件范围仍受顶层 `javascript`、\n * `typescript` 开关控制。\n *\n * 这些字段只传给 ESLint 插件用于理解项目的 React 语义,不会改变 JSX 编译方式、自动\n * 导入 React、设置打包器别名或安装兼容运行时。\n */\nexport interface ReactConfigOptions {\n\t/**\n\t * 提供 React API 与 JSX 运行时的包入口名称。\n\t *\n\t * 标准 React 项目保持 `\"react\"`;Preact 等兼容运行时可填写自身包名,使\n\t * `@eslint-react` 按正确的导入来源识别组件和 API。该设置不会修改 TypeScript\n\t * `jsxImportSource`、Babel、Vite 或其他构建工具配置,两侧需要由项目自行保持一致。\n\t * @defaultValue `\"react\"`\n\t */\n\timportSource?: string;\n\t/**\n\t * 项目约定用于切换多态组件底层元素或组件类型的属性名。\n\t *\n\t * 例如 `<Button as=\"a\" />` 中的 `as`。插件会据此理解多态组件最终渲染元素的语义,\n\t * 从而提高 DOM 与可访问性相关规则的判断准确度;未采用多态组件时通常无需修改。\n\t * @defaultValue `\"as\"`\n\t */\n\tpolymorphicPropName?: string;\n\t/**\n\t * 供插件选择版本相关行为的 React 版本号或自动检测标记。\n\t *\n\t * `\"detect\"` 会尝试从当前项目依赖解析已安装的 React 版本。monorepo、PnP、兼容运行时\n\t * 或依赖不可见的执行环境若无法可靠检测,可传入明确版本号,例如 `\"19.1.0\"`。\n\t * 该值只影响 lint 规则判断,不会限制或安装 React 依赖版本。\n\t * @defaultValue `\"detect\"`\n\t */\n\tversion?: string;\n}\n\n/**\n * React 配置生成器使用的语言状态。\n *\n * @remarks\n * `fastConfig()` 会自动推导这些值;直接组合配置片段时由调用方显式传入。\n *\n * 用户不直接配置该接口。`fastConfig()` 会把顶层 JavaScript、TypeScript 开关以及\n * TypeScript 类型感知状态转换为这里的三个布尔值,确保 React 不会重新接管已经关闭的\n * 文件类型,并为 TypeScript 选择正确的 `@eslint-react` 推荐预置。\n */\ninterface ReactLanguageOptions {\n\t/**\n\t * 是否为 `.js`、`.cjs`、`.mjs` 与 `.jsx` 文件创建 React 配置。\n\t *\n\t * 该值来自顶层 `FastConfigOptions.javascript`;为 `false` 时即使 React 已启用,\n\t * React 配置也不会声明这些文件范围。\n\t * @defaultValue `true`\n\t */\n\tjavascript?: boolean;\n\t/**\n\t * 是否为 TypeScript/TSX 选择需要类型信息的 React 推荐预置。\n\t *\n\t * 该值来自 `FastConfigOptions.typescript.typeChecked`,只影响 TypeScript React 配置;\n\t * JavaScript 配置始终使用普通推荐预置。\n\t * @defaultValue `false`\n\t */\n\ttypeChecked?: boolean;\n\t/**\n\t * 是否为 `.ts`、`.cts`、`.mts` 与 `.tsx` 文件创建 React 配置。\n\t *\n\t * 该值来自顶层 `FastConfigOptions.typescript`;为 `false` 时不会生成 TypeScript React\n\t * 片段,也不会仅因为 React 已启用而重新接管 TypeScript 文件。\n\t * @defaultValue `true`\n\t */\n\ttypescript?: boolean;\n}\n\n/**\n * 创建 React、JSX/TSX 与 Hooks 配置。\n *\n * @remarks\n * JavaScript 和 TypeScript 分别继承对应的 @eslint-react 推荐预置;Hooks 使用\n * React 官方 Flat Config。组件、Hooks 即使不返回 JSX 也能在普通 `.js`/`.ts` 中\n * 定义,因此规则覆盖全部已启用脚本扩展名,而不仅是 `.jsx`/`.tsx`。\n *\n * @param options - React 版本、运行时导入来源与多态组件属性设置。\n * @param languages - 由调用方启用的脚本语言以及 TypeScript 类型感知状态。\n * @returns 仅包含已启用语言的 React 与 Hooks Flat Config 数组。\n */\nexport const createReactConfigs = (\n\t{ importSource = \"react\", polymorphicPropName = \"as\", version = \"detect\" }: ReactConfigOptions = {},\n\t{ javascript = true, typeChecked = false, typescript = true }: ReactLanguageOptions = {}\n) => {\n\tconst createConfig = (name: string, files: readonly string[], preset: Linter.Config) => ({\n\t\tname,\n\t\tfiles: [...files],\n\t\textends: [preset, eslintPluginReactHooks.configs.flat.recommended],\n\t\tsettings: {\n\t\t\t\"react-x\": {\n\t\t\t\timportSource,\n\t\t\t\tpolymorphicPropName,\n\t\t\t\tversion,\n\t\t\t},\n\t\t},\n\t\trules: reactRules,\n\t});\n\n\treturn defineConfig([\n\t\t...(javascript ? [createConfig(\"@fast-china/react/javascript\", GLOBS_JAVASCRIPT, eslintReact.configs.recommended)] : []),\n\t\t...(typescript\n\t\t\t? [\n\t\t\t\t\tcreateConfig(\n\t\t\t\t\t\ttypeChecked ? \"@fast-china/react/typescript-type-checked\" : \"@fast-china/react/typescript\",\n\t\t\t\t\t\tGLOBS_TYPESCRIPT,\n\t\t\t\t\t\ttypeChecked ? eslintReact.configs[\"recommended-type-checked\"] : eslintReact.configs[\"recommended-typescript\"]\n\t\t\t\t\t),\n\t\t\t\t]\n\t\t\t: []),\n\t]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmGA,MAAa,sBACZ,EAAE,eAAe,SAAS,sBAAsB,MAAM,UAAU,aAAiC,CAAC,GAClG,EAAE,aAAa,MAAM,cAAc,OAAO,aAAa,SAA+B,CAAC,MACnF;CACJ,MAAM,gBAAgB,MAAc,OAA0B,YAA2B;EACxF;EACA,OAAO,CAAC,GAAG,KAAK;EAChB,SAAS,CAAC,QAAQ,uBAAuB,QAAQ,KAAK,WAAW;EACjE,UAAU,EACT,WAAW;GACV;GACA;GACA;EACD,EACD;EACA,OAAO;CACR;CAEA,OAAO,aAAa,CACnB,GAAI,aAAa,CAAC,aAAa,gCAAgC,kBAAkB,YAAY,QAAQ,WAAW,CAAC,IAAI,CAAC,GACtH,GAAI,aACD,CACA,aACC,cAAc,8CAA8C,gCAC5D,kBACA,cAAc,YAAY,QAAQ,8BAA8B,YAAY,QAAQ,yBACrF,CACD,IACC,CAAC,CACL,CAAC;AACF"}
|
|
@@ -2,8 +2,12 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* 创建正则表达式正确性配置。
|
|
4
4
|
*
|
|
5
|
+
* @remarks
|
|
5
6
|
* 插件推荐规则会检查无效、冗余或容易产生回溯问题的正则结构;部分规则可修复,
|
|
6
7
|
* 批量修复后仍需运行覆盖真实输入的项目测试。
|
|
8
|
+
*
|
|
9
|
+
* @param files - 应用正则表达式规则的 ESLint glob 列表。
|
|
10
|
+
* @returns 包含 `eslint-plugin-regexp` 推荐预置的 Flat Config 数组。
|
|
7
11
|
*/
|
|
8
12
|
declare const createRegexpConfigs: (files?: readonly string[]) => import("eslint/config").ConfigObject[];
|
|
9
13
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"regexp.d.mts","names":[],"sources":["../../src/configs/regexp.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"regexp.d.mts","names":[],"sources":["../../src/configs/regexp.ts"],"mappings":";;;;;;;;;;;cAea,sBAAuB,sDAAqC"}
|
package/dist/configs/regexp.mjs
CHANGED
|
@@ -5,8 +5,12 @@ import eslintPluginRegexp from "eslint-plugin-regexp";
|
|
|
5
5
|
/**
|
|
6
6
|
* 创建正则表达式正确性配置。
|
|
7
7
|
*
|
|
8
|
+
* @remarks
|
|
8
9
|
* 插件推荐规则会检查无效、冗余或容易产生回溯问题的正则结构;部分规则可修复,
|
|
9
10
|
* 批量修复后仍需运行覆盖真实输入的项目测试。
|
|
11
|
+
*
|
|
12
|
+
* @param files - 应用正则表达式规则的 ESLint glob 列表。
|
|
13
|
+
* @returns 包含 `eslint-plugin-regexp` 推荐预置的 Flat Config 数组。
|
|
10
14
|
*/
|
|
11
15
|
const createRegexpConfigs = (files = GLOBS_CODE) => defineConfig([{
|
|
12
16
|
name: "@fast-china/regexp",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"regexp.mjs","names":[],"sources":["../../src/configs/regexp.ts"],"sourcesContent":["import { defineConfig } from \"eslint/config\";\nimport eslintPluginRegexp from \"eslint-plugin-regexp\";\n\nimport { GLOBS_CODE } from \"../constants\";\n\n/**\n * 创建正则表达式正确性配置。\n *\n * 插件推荐规则会检查无效、冗余或容易产生回溯问题的正则结构;部分规则可修复,\n * 批量修复后仍需运行覆盖真实输入的项目测试。\n */\nexport const createRegexpConfigs = (files: readonly string[] = GLOBS_CODE) =>\n\tdefineConfig([\n\t\t{\n\t\t\tname: \"@fast-china/regexp\",\n\t\t\tfiles: [...files],\n\t\t\textends: [eslintPluginRegexp.configs[\"flat/recommended\"]],\n\t\t},\n\t]);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"regexp.mjs","names":[],"sources":["../../src/configs/regexp.ts"],"sourcesContent":["import { defineConfig } from \"eslint/config\";\nimport eslintPluginRegexp from \"eslint-plugin-regexp\";\n\nimport { GLOBS_CODE } from \"../constants\";\n\n/**\n * 创建正则表达式正确性配置。\n *\n * @remarks\n * 插件推荐规则会检查无效、冗余或容易产生回溯问题的正则结构;部分规则可修复,\n * 批量修复后仍需运行覆盖真实输入的项目测试。\n *\n * @param files - 应用正则表达式规则的 ESLint glob 列表。\n * @returns 包含 `eslint-plugin-regexp` 推荐预置的 Flat Config 数组。\n */\nexport const createRegexpConfigs = (files: readonly string[] = GLOBS_CODE) =>\n\tdefineConfig([\n\t\t{\n\t\t\tname: \"@fast-china/regexp\",\n\t\t\tfiles: [...files],\n\t\t\textends: [eslintPluginRegexp.configs[\"flat/recommended\"]],\n\t\t},\n\t]);\n"],"mappings":";;;;;;;;;;;;;;AAeA,MAAa,uBAAuB,QAA2B,eAC9D,aAAa,CACZ;CACC,MAAM;CACN,OAAO,CAAC,GAAG,KAAK;CAChB,SAAS,CAAC,mBAAmB,QAAQ,mBAAmB;AACzD,CACD,CAAC"}
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* 创建 package.json 排序配置。
|
|
4
4
|
*
|
|
5
|
+
* @remarks
|
|
5
6
|
* 该能力会产生较大的可修复 diff,因此必须显式启用;规则不会进入顺序具有
|
|
6
7
|
* 条件导出语义的 `exports` 对象内部。
|
|
8
|
+
*
|
|
9
|
+
* @returns 仅匹配 `package.json` 的字段排序 Flat Config 数组。
|
|
7
10
|
*/
|
|
8
11
|
declare const createPackageJsonSortConfigs: () => import("eslint/config").ConfigObject[];
|
|
9
12
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort-package.d.mts","names":[],"sources":["../../src/configs/sort-package.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"sort-package.d.mts","names":[],"sources":["../../src/configs/sort-package.ts"],"mappings":";;;;;;;;;;cAaa,4DAA4B"}
|
|
@@ -4,8 +4,11 @@ import { defineConfig } from "eslint/config";
|
|
|
4
4
|
/**
|
|
5
5
|
* 创建 package.json 排序配置。
|
|
6
6
|
*
|
|
7
|
+
* @remarks
|
|
7
8
|
* 该能力会产生较大的可修复 diff,因此必须显式启用;规则不会进入顺序具有
|
|
8
9
|
* 条件导出语义的 `exports` 对象内部。
|
|
10
|
+
*
|
|
11
|
+
* @returns 仅匹配 `package.json` 的字段排序 Flat Config 数组。
|
|
9
12
|
*/
|
|
10
13
|
const createPackageJsonSortConfigs = () => defineConfig([{
|
|
11
14
|
name: "@fast-china/sort/package-json",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort-package.mjs","names":[],"sources":["../../src/configs/sort-package.ts"],"sourcesContent":["import { defineConfig } from \"eslint/config\";\n\nimport { packageJsonSortRules } from \"../rules\";\n\n/**\n * 创建 package.json 排序配置。\n *\n * 该能力会产生较大的可修复 diff,因此必须显式启用;规则不会进入顺序具有\n * 条件导出语义的 `exports` 对象内部。\n */\nexport const createPackageJsonSortConfigs = () =>\n\tdefineConfig([\n\t\t{\n\t\t\tname: \"@fast-china/sort/package-json\",\n\t\t\tfiles: [\"**/package.json\"],\n\t\t\trules: packageJsonSortRules,\n\t\t},\n\t]);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"sort-package.mjs","names":[],"sources":["../../src/configs/sort-package.ts"],"sourcesContent":["import { defineConfig } from \"eslint/config\";\n\nimport { packageJsonSortRules } from \"../rules\";\n\n/**\n * 创建 package.json 排序配置。\n *\n * @remarks\n * 该能力会产生较大的可修复 diff,因此必须显式启用;规则不会进入顺序具有\n * 条件导出语义的 `exports` 对象内部。\n *\n * @returns 仅匹配 `package.json` 的字段排序 Flat Config 数组。\n */\nexport const createPackageJsonSortConfigs = () =>\n\tdefineConfig([\n\t\t{\n\t\t\tname: \"@fast-china/sort/package-json\",\n\t\t\tfiles: [\"**/package.json\"],\n\t\t\trules: packageJsonSortRules,\n\t\t},\n\t]);\n"],"mappings":";;;;;;;;;;;;AAaA,MAAa,qCACZ,aAAa,CACZ;CACC,MAAM;CACN,OAAO,CAAC,iBAAiB;CACzB,OAAO;AACR,CACD,CAAC"}
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* 创建 tsconfig.json 排序配置。
|
|
4
4
|
*
|
|
5
|
+
* @remarks
|
|
5
6
|
* 排序只改变字段阅读顺序,不改变编译选项值;由于首次修复 diff 较大,默认关闭。
|
|
7
|
+
*
|
|
8
|
+
* @returns 匹配 `tsconfig.json` 与 `tsconfig.*.json` 的字段排序 Flat Config 数组。
|
|
6
9
|
*/
|
|
7
10
|
declare const createTsconfigSortConfigs: () => import("eslint/config").ConfigObject[];
|
|
8
11
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort-tsconfig.d.mts","names":[],"sources":["../../src/configs/sort-tsconfig.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"sort-tsconfig.d.mts","names":[],"sources":["../../src/configs/sort-tsconfig.ts"],"mappings":";;;;;;;;;cAaa,yDAAyB"}
|
|
@@ -5,7 +5,10 @@ import { defineConfig } from "eslint/config";
|
|
|
5
5
|
/**
|
|
6
6
|
* 创建 tsconfig.json 排序配置。
|
|
7
7
|
*
|
|
8
|
+
* @remarks
|
|
8
9
|
* 排序只改变字段阅读顺序,不改变编译选项值;由于首次修复 diff 较大,默认关闭。
|
|
10
|
+
*
|
|
11
|
+
* @returns 匹配 `tsconfig.json` 与 `tsconfig.*.json` 的字段排序 Flat Config 数组。
|
|
9
12
|
*/
|
|
10
13
|
const createTsconfigSortConfigs = () => defineConfig([{
|
|
11
14
|
name: "@fast-china/sort/tsconfig",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort-tsconfig.mjs","names":[],"sources":["../../src/configs/sort-tsconfig.ts"],"sourcesContent":["import { defineConfig } from \"eslint/config\";\n\nimport { GLOBS_TSCONFIG } from \"../constants\";\nimport { tsconfigJsonSortRules } from \"../rules\";\n\n/**\n * 创建 tsconfig.json 排序配置。\n *\n * 排序只改变字段阅读顺序,不改变编译选项值;由于首次修复 diff 较大,默认关闭。\n */\nexport const createTsconfigSortConfigs = () =>\n\tdefineConfig([\n\t\t{\n\t\t\tname: \"@fast-china/sort/tsconfig\",\n\t\t\tfiles: [...GLOBS_TSCONFIG],\n\t\t\trules: tsconfigJsonSortRules,\n\t\t},\n\t]);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"sort-tsconfig.mjs","names":[],"sources":["../../src/configs/sort-tsconfig.ts"],"sourcesContent":["import { defineConfig } from \"eslint/config\";\n\nimport { GLOBS_TSCONFIG } from \"../constants\";\nimport { tsconfigJsonSortRules } from \"../rules\";\n\n/**\n * 创建 tsconfig.json 排序配置。\n *\n * @remarks\n * 排序只改变字段阅读顺序,不改变编译选项值;由于首次修复 diff 较大,默认关闭。\n *\n * @returns 匹配 `tsconfig.json` 与 `tsconfig.*.json` 的字段排序 Flat Config 数组。\n */\nexport const createTsconfigSortConfigs = () =>\n\tdefineConfig([\n\t\t{\n\t\t\tname: \"@fast-china/sort/tsconfig\",\n\t\t\tfiles: [...GLOBS_TSCONFIG],\n\t\t\trules: tsconfigJsonSortRules,\n\t\t},\n\t]);\n"],"mappings":";;;;;;;;;;;;AAaA,MAAa,kCACZ,aAAa,CACZ;CACC,MAAM;CACN,OAAO,CAAC,GAAG,cAAc;CACzB,OAAO;AACR,CACD,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { Linter } from "eslint";
|
|
|
3
3
|
/**
|
|
4
4
|
* TypeScript 解析器、推荐预置与类型感知检查选项。
|
|
5
5
|
*
|
|
6
|
+
* @remarks
|
|
6
7
|
* 该对象通过 `fastConfig({ typescript: { ... } })` 传入。传入对象会启用 TypeScript
|
|
7
8
|
* 支持,并检查 `.ts`、`.cts`、`.mts` 与 `.tsx`。相同的类型感知状态还会传递给已启用的
|
|
8
9
|
* Vue 和 React 配置,使普通 TypeScript 文件、Vue SFC 与 TSX 使用一致的检查级别。
|
|
@@ -22,7 +23,7 @@ interface TypeScriptConfigOptions {
|
|
|
22
23
|
*
|
|
23
24
|
* 开启后 Vue 与 React 的 TypeScript 规则也会选择类型感知版本。大型 monorepo 建议评估
|
|
24
25
|
* lint 启动耗时和内存占用,并确保各工作区 tsconfig 边界明确。
|
|
25
|
-
* @
|
|
26
|
+
* @defaultValue `false`
|
|
26
27
|
*/
|
|
27
28
|
typeChecked?: boolean;
|
|
28
29
|
/**
|
|
@@ -32,18 +33,28 @@ interface TypeScriptConfigOptions {
|
|
|
32
33
|
* `eslint.config.*` 调用栈推断;复杂 monorepo、共享配置包装层或从其他目录启动 ESLint
|
|
33
34
|
* 时,建议传入配置文件所在目录的绝对路径,例如 `import.meta.dirname`,避免发现错误的
|
|
34
35
|
* tsconfig 或跨越预期的项目边界。
|
|
35
|
-
* @
|
|
36
|
+
* @defaultValue `undefined`
|
|
36
37
|
*/
|
|
37
38
|
tsconfigRootDir?: string;
|
|
38
39
|
}
|
|
39
40
|
/**
|
|
40
41
|
* 返回 typescript-eslint 推荐预置。
|
|
41
42
|
*
|
|
43
|
+
* @remarks
|
|
42
44
|
* Vue SFC 需要移除上游仅匹配 `.ts` 的文件范围,否则这些关闭核心规则的配置会与
|
|
43
45
|
* `.vue` 外层范围形成不可能命中的 AND 条件。
|
|
46
|
+
*
|
|
47
|
+
* @param typeChecked - 是否选择依赖完整类型信息的推荐与风格预置。
|
|
48
|
+
* @param removeFileScopes - 是否从每个上游预置中移除 `files` 范围。
|
|
49
|
+
* @returns 新的预置数组;移除范围时会复制各配置对象,不修改 typescript-eslint 的导出。
|
|
44
50
|
*/
|
|
45
51
|
declare const getTypeScriptPresetConfigs: (typeChecked: boolean, removeFileScopes?: boolean) => Linter.Config[];
|
|
46
|
-
/**
|
|
52
|
+
/**
|
|
53
|
+
* 创建 TypeScript 解析器的 Project Service 选项。
|
|
54
|
+
*
|
|
55
|
+
* @param options - 类型感知开关及可选的 tsconfig 查找根目录。
|
|
56
|
+
* @returns 未启用类型感知时返回空对象;启用时返回 `projectService` 及可选的 `tsconfigRootDir`。
|
|
57
|
+
*/
|
|
47
58
|
declare const createTypeScriptParserOptions: ({ typeChecked, tsconfigRootDir }?: TypeScriptConfigOptions) => {
|
|
48
59
|
tsconfigRootDir?: string | undefined;
|
|
49
60
|
projectService?: boolean | undefined;
|
|
@@ -51,8 +62,13 @@ declare const createTypeScriptParserOptions: ({ typeChecked, tsconfigRootDir }?:
|
|
|
51
62
|
/**
|
|
52
63
|
* 创建 TypeScript 配置。
|
|
53
64
|
*
|
|
65
|
+
* @remarks
|
|
54
66
|
* 默认采用无需类型信息的 recommended + stylistic 预置;`typeChecked: true` 会切换为
|
|
55
67
|
* 对应的类型感知预置并启动 Project Service。
|
|
68
|
+
*
|
|
69
|
+
* @param options - TypeScript 类型感知与 tsconfig 根目录选项。
|
|
70
|
+
* @param files - 应用 TypeScript 配置的 ESLint glob 列表。
|
|
71
|
+
* @returns 包含 TypeScript 预置、解析器选项与本地规则的 Flat Config 数组。
|
|
56
72
|
*/
|
|
57
73
|
declare const createTypeScriptConfigs: (options?: TypeScriptConfigOptions, files?: readonly string[]) => import("eslint/config").ConfigObject[];
|
|
58
74
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.d.mts","names":[],"sources":["../../src/configs/typescript.ts"],"mappings":";;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"typescript.d.mts","names":[],"sources":["../../src/configs/typescript.ts"],"mappings":";;;;;;;;;;;;;;UAoBiB;;;;;;;;;;;;;EAahB;;;;;;;;;;EAUA;;;;;;;;;;;;;cAcY,6BAA8B,sBAAsB,+BAA2B,OAAO;;;;;;;cAoBtF,kCAAiC,aAAA,oBAA0C;;;;;;;;;;;;;;;cAgB3E,0BAA2B,UAAS,yBAA8B,sDAA2C"}
|