@lincy/eslint-config 4.4.0 → 4.5.1
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 +3 -3
- package/dist/index.cjs +71 -103
- package/dist/index.d.cts +231 -873
- package/dist/index.d.ts +231 -873
- package/dist/index.js +71 -103
- package/package.json +19 -18
package/README.md
CHANGED
|
@@ -508,7 +508,7 @@ pnpm add eslint-plugin-format -D
|
|
|
508
508
|
运行“npx eslint”会提示您安装所需的依赖项,当然,也可以手动安装它们:
|
|
509
509
|
|
|
510
510
|
```bash
|
|
511
|
-
pnpm i -D eslint-plugin
|
|
511
|
+
pnpm i -D @eslint-react/eslint-plugin eslint-plugin-react-hooks eslint-plugin-react-refresh
|
|
512
512
|
```
|
|
513
513
|
|
|
514
514
|
#### UnoCSS
|
|
@@ -540,14 +540,14 @@ pnpm i -D @unocss/eslint-plugin
|
|
|
540
540
|
|
|
541
541
|
建议使用[configuration comments]单独选择每个文件。(https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1).
|
|
542
542
|
|
|
543
|
-
```
|
|
543
|
+
```ts
|
|
544
544
|
/* eslint perfectionist/sort-objects: "error" */
|
|
545
545
|
const objectWantedToSort = {
|
|
546
546
|
a: 2,
|
|
547
547
|
b: 1,
|
|
548
548
|
c: 3,
|
|
549
549
|
}
|
|
550
|
-
/*
|
|
550
|
+
/* e slint perfectionist/sort-objects: "off" */
|
|
551
551
|
```
|
|
552
552
|
|
|
553
553
|
### 类型感知规则
|
package/dist/index.cjs
CHANGED
|
@@ -997,152 +997,116 @@ async function react(options = {}) {
|
|
|
997
997
|
typescript: typescript2 = true,
|
|
998
998
|
version = "detect"
|
|
999
999
|
} = options;
|
|
1000
|
+
const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
|
|
1001
|
+
const isTypeAware = !!tsconfigPath || !typescript2;
|
|
1000
1002
|
await ensurePackages([
|
|
1001
|
-
"eslint-plugin
|
|
1003
|
+
"@eslint-react/eslint-plugin",
|
|
1002
1004
|
"eslint-plugin-react-hooks",
|
|
1003
1005
|
"eslint-plugin-react-refresh"
|
|
1004
1006
|
]);
|
|
1005
1007
|
const [
|
|
1006
1008
|
pluginReact,
|
|
1007
1009
|
pluginReactHooks,
|
|
1008
|
-
pluginReactRefresh
|
|
1010
|
+
pluginReactRefresh,
|
|
1011
|
+
parserTs
|
|
1009
1012
|
] = await Promise.all([
|
|
1010
|
-
|
|
1011
|
-
interopDefault(import("eslint-plugin-react")),
|
|
1013
|
+
interopDefault(import("@eslint-react/eslint-plugin")),
|
|
1012
1014
|
// @ts-expect-error missing types
|
|
1013
1015
|
interopDefault(import("eslint-plugin-react-hooks")),
|
|
1014
1016
|
// @ts-expect-error missing types
|
|
1015
|
-
interopDefault(import("eslint-plugin-react-refresh"))
|
|
1017
|
+
interopDefault(import("eslint-plugin-react-refresh")),
|
|
1018
|
+
interopDefault(import("@typescript-eslint/parser"))
|
|
1016
1019
|
]);
|
|
1017
1020
|
const _isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
|
|
1018
1021
|
(i) => (0, import_local_pkg2.isPackageExists)(i)
|
|
1019
1022
|
);
|
|
1023
|
+
const plugins = pluginReact.configs.all.plugins;
|
|
1020
1024
|
return [
|
|
1021
1025
|
{
|
|
1022
1026
|
name: "eslint:react:setup",
|
|
1023
1027
|
plugins: {
|
|
1024
|
-
"react":
|
|
1028
|
+
"react": plugins["@eslint-react"],
|
|
1029
|
+
"react-dom": plugins["@eslint-react/dom"],
|
|
1025
1030
|
"react-hooks": pluginReactHooks,
|
|
1031
|
+
"react-hooks-extra": plugins["@eslint-react/hooks-extra"],
|
|
1032
|
+
"react-naming-convention": plugins["@eslint-react/naming-convention"],
|
|
1026
1033
|
"react-refresh": pluginReactRefresh
|
|
1027
1034
|
}
|
|
1028
1035
|
},
|
|
1029
1036
|
{
|
|
1030
1037
|
files,
|
|
1031
1038
|
languageOptions: {
|
|
1039
|
+
parser: parserTs,
|
|
1032
1040
|
parserOptions: {
|
|
1033
1041
|
ecmaFeatures: {
|
|
1034
1042
|
jsx
|
|
1035
|
-
}
|
|
1043
|
+
},
|
|
1044
|
+
...isTypeAware ? { project: tsconfigPath } : {}
|
|
1036
1045
|
}
|
|
1037
1046
|
},
|
|
1038
1047
|
name: "eslint:react:rules",
|
|
1039
1048
|
rules: {
|
|
1040
|
-
// react
|
|
1049
|
+
// recommended rules from @eslint-react/dom
|
|
1050
|
+
"react-dom/no-children-in-void-dom-elements": "warn",
|
|
1051
|
+
"react-dom/no-dangerously-set-innerhtml": "off",
|
|
1052
|
+
"react-dom/no-dangerously-set-innerhtml-with-children": "error",
|
|
1053
|
+
"react-dom/no-find-dom-node": "error",
|
|
1054
|
+
"react-dom/no-missing-button-type": "warn",
|
|
1055
|
+
"react-dom/no-missing-iframe-sandbox": "warn",
|
|
1056
|
+
"react-dom/no-namespace": "error",
|
|
1057
|
+
"react-dom/no-render-return-value": "error",
|
|
1058
|
+
"react-dom/no-script-url": "warn",
|
|
1059
|
+
"react-dom/no-unsafe-iframe-sandbox": "warn",
|
|
1060
|
+
"react-dom/no-unsafe-target-blank": "warn",
|
|
1061
|
+
// recommended rules react-hooks
|
|
1041
1062
|
"react-hooks/exhaustive-deps": "warn",
|
|
1042
1063
|
"react-hooks/rules-of-hooks": "error",
|
|
1043
|
-
// react
|
|
1064
|
+
// react refresh
|
|
1044
1065
|
// 'react-refresh/only-export-components': [
|
|
1045
1066
|
// 'warn',
|
|
1046
|
-
// { allowConstantExport:
|
|
1067
|
+
// { allowConstantExport: isAllowConstantExport },
|
|
1047
1068
|
// ],
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
"react/boolean-prop-naming": "error",
|
|
1051
|
-
"react/button-has-type": "error",
|
|
1052
|
-
"react/default-props-match-prop-types": "error",
|
|
1053
|
-
"react/destructuring-assignment": "error",
|
|
1054
|
-
"react/display-name": "error",
|
|
1055
|
-
"react/forbid-component-props": "off",
|
|
1056
|
-
// 禁止组件上使用某些 props
|
|
1057
|
-
"react/forbid-dom-props": "error",
|
|
1058
|
-
"react/forbid-elements": "error",
|
|
1059
|
-
"react/forbid-foreign-prop-types": "error",
|
|
1060
|
-
"react/forbid-prop-types": "error",
|
|
1061
|
-
"react/function-component-definition": "error",
|
|
1062
|
-
"react/hook-use-state": "off",
|
|
1063
|
-
// useState 钩子值和 setter 变量的解构和对称命名
|
|
1064
|
-
"react/iframe-missing-sandbox": "error",
|
|
1065
|
-
"react/jsx-boolean-value": "error",
|
|
1066
|
-
"react/jsx-filename-extension": "off",
|
|
1067
|
-
// 禁止可能包含 JSX 文件扩展名
|
|
1068
|
-
"react/jsx-fragments": "error",
|
|
1069
|
-
"react/jsx-handler-names": "error",
|
|
1070
|
-
"react/jsx-key": "error",
|
|
1071
|
-
"react/jsx-max-depth": "off",
|
|
1072
|
-
// 强制 JSX 最大深度
|
|
1073
|
-
"react/jsx-no-bind": "off",
|
|
1074
|
-
// .bind()JSX 属性中禁止使用箭头函数
|
|
1075
|
-
"react/jsx-no-comment-textnodes": "error",
|
|
1076
|
-
"react/jsx-no-constructed-context-values": "error",
|
|
1077
|
-
"react/jsx-no-duplicate-props": "error",
|
|
1078
|
-
"react/jsx-no-leaked-render": "error",
|
|
1079
|
-
"react/jsx-no-literals": "off",
|
|
1080
|
-
// 禁止在 JSX 中使用字符串文字
|
|
1081
|
-
"react/jsx-no-script-url": "error",
|
|
1082
|
-
"react/jsx-no-target-blank": "error",
|
|
1083
|
-
"react/jsx-no-undef": "error",
|
|
1084
|
-
"react/jsx-no-useless-fragment": "error",
|
|
1085
|
-
"react/jsx-props-no-spreading": "off",
|
|
1086
|
-
// 强制任何 JSX 属性都不会传播
|
|
1087
|
-
"react/jsx-uses-react": "error",
|
|
1088
|
-
"react/jsx-uses-vars": "error",
|
|
1069
|
+
// recommended rules from @eslint-react
|
|
1070
|
+
"react/ensure-forward-ref-using-ref": "warn",
|
|
1089
1071
|
"react/no-access-state-in-setstate": "error",
|
|
1090
|
-
"react/no-
|
|
1091
|
-
"react/no-
|
|
1092
|
-
"react/no-
|
|
1093
|
-
"react/no-children-
|
|
1094
|
-
"react/no-
|
|
1095
|
-
|
|
1096
|
-
"react/no-
|
|
1097
|
-
"react/no-
|
|
1098
|
-
"react/no-
|
|
1099
|
-
"react/no-
|
|
1072
|
+
"react/no-array-index-key": "warn",
|
|
1073
|
+
"react/no-children-count": "warn",
|
|
1074
|
+
"react/no-children-for-each": "warn",
|
|
1075
|
+
"react/no-children-map": "warn",
|
|
1076
|
+
"react/no-children-only": "warn",
|
|
1077
|
+
"react/no-children-prop": "warn",
|
|
1078
|
+
"react/no-children-to-array": "warn",
|
|
1079
|
+
"react/no-clone-element": "warn",
|
|
1080
|
+
"react/no-comment-textnodes": "warn",
|
|
1081
|
+
"react/no-component-will-mount": "error",
|
|
1082
|
+
"react/no-component-will-receive-props": "error",
|
|
1083
|
+
"react/no-component-will-update": "error",
|
|
1084
|
+
"react/no-create-ref": "error",
|
|
1100
1085
|
"react/no-direct-mutation-state": "error",
|
|
1101
|
-
"react/no-
|
|
1102
|
-
"react/no-
|
|
1103
|
-
"react/no-
|
|
1104
|
-
"react/no-
|
|
1105
|
-
"react/no-namespace": "error",
|
|
1106
|
-
"react/no-object-type-as-default-prop": "error",
|
|
1086
|
+
"react/no-duplicate-key": "error",
|
|
1087
|
+
"react/no-implicit-key": "error",
|
|
1088
|
+
"react/no-missing-key": "error",
|
|
1089
|
+
"react/no-nested-components": "warn",
|
|
1107
1090
|
"react/no-redundant-should-component-update": "error",
|
|
1108
|
-
"react/no-
|
|
1109
|
-
"react/no-set-state": "
|
|
1091
|
+
"react/no-set-state-in-component-did-mount": "warn",
|
|
1092
|
+
"react/no-set-state-in-component-did-update": "warn",
|
|
1093
|
+
"react/no-set-state-in-component-will-update": "warn",
|
|
1110
1094
|
"react/no-string-refs": "error",
|
|
1111
|
-
"react/no-
|
|
1112
|
-
"react/no-
|
|
1113
|
-
"react/no-
|
|
1114
|
-
"react/no-
|
|
1115
|
-
"react/no-
|
|
1116
|
-
|
|
1117
|
-
"react/no-
|
|
1118
|
-
"react/no-
|
|
1119
|
-
"react/
|
|
1120
|
-
"react/
|
|
1121
|
-
"react/
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
"react/prefer-read-only-props": "error",
|
|
1125
|
-
"react/prefer-stateless-function": "error",
|
|
1126
|
-
"react/prop-types": "error",
|
|
1127
|
-
"react/react-in-jsx-scope": "off",
|
|
1128
|
-
// 使用 JSX 时需要引入 React
|
|
1129
|
-
"react/require-default-props": "off",
|
|
1130
|
-
// 为每个非必需 prop 强制执行 defaultProps 定义
|
|
1131
|
-
"react/require-optimization": "error",
|
|
1132
|
-
"react/require-render-return": "error",
|
|
1133
|
-
"react/self-closing-comp": "error",
|
|
1134
|
-
"react/sort-comp": "error",
|
|
1135
|
-
"react/sort-default-props": "error",
|
|
1136
|
-
"react/sort-prop-types": "error",
|
|
1137
|
-
"react/state-in-constructor": "error",
|
|
1138
|
-
"react/static-property-placement": "error",
|
|
1139
|
-
"react/style-prop-object": "error",
|
|
1140
|
-
"react/void-dom-elements-no-children": "error",
|
|
1141
|
-
"style/jsx-pascal-case": "error",
|
|
1142
|
-
...typescript2 ? {
|
|
1143
|
-
"react/jsx-no-undef": "off",
|
|
1144
|
-
"react/prop-type": "off"
|
|
1095
|
+
"react/no-unsafe-component-will-mount": "warn",
|
|
1096
|
+
"react/no-unsafe-component-will-receive-props": "warn",
|
|
1097
|
+
"react/no-unsafe-component-will-update": "warn",
|
|
1098
|
+
"react/no-unstable-context-value": "error",
|
|
1099
|
+
"react/no-unstable-default-props": "error",
|
|
1100
|
+
"react/no-unused-class-component-members": "warn",
|
|
1101
|
+
"react/no-unused-state": "warn",
|
|
1102
|
+
"react/no-useless-fragment": "warn",
|
|
1103
|
+
"react/prefer-destructuring-assignment": "warn",
|
|
1104
|
+
"react/prefer-shorthand-boolean": "warn",
|
|
1105
|
+
"react/prefer-shorthand-fragment": "warn",
|
|
1106
|
+
...isTypeAware ? {
|
|
1107
|
+
"react/no-leaked-conditional-rendering": "warn"
|
|
1145
1108
|
} : {},
|
|
1109
|
+
// overrides
|
|
1146
1110
|
...overrides
|
|
1147
1111
|
},
|
|
1148
1112
|
settings: {
|
|
@@ -1972,6 +1936,10 @@ var VuePackages = [
|
|
|
1972
1936
|
"@slidev/cli"
|
|
1973
1937
|
];
|
|
1974
1938
|
var defaultPluginRenaming = {
|
|
1939
|
+
"@eslint-react": "react",
|
|
1940
|
+
"@eslint-react/dom": "react-dom",
|
|
1941
|
+
"@eslint-react/hooks-extra": "react-hooks-extra",
|
|
1942
|
+
"@eslint-react/naming-convention": "react-naming-convention",
|
|
1975
1943
|
"@stylistic": "style",
|
|
1976
1944
|
"@typescript-eslint": "ts",
|
|
1977
1945
|
"import-x": "import",
|