@lincy/eslint-config 4.4.0 → 4.5.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/dist/index.js CHANGED
@@ -906,152 +906,116 @@ async function react(options = {}) {
906
906
  typescript: typescript2 = true,
907
907
  version = "detect"
908
908
  } = options;
909
+ const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
910
+ const isTypeAware = !!tsconfigPath || !typescript2;
909
911
  await ensurePackages([
910
- "eslint-plugin-react",
912
+ "@eslint-react/eslint-plugin",
911
913
  "eslint-plugin-react-hooks",
912
914
  "eslint-plugin-react-refresh"
913
915
  ]);
914
916
  const [
915
917
  pluginReact,
916
918
  pluginReactHooks,
917
- pluginReactRefresh
919
+ pluginReactRefresh,
920
+ parserTs
918
921
  ] = await Promise.all([
919
- // @ts-expect-error missing types
920
- interopDefault(import("eslint-plugin-react")),
922
+ interopDefault(import("@eslint-react/eslint-plugin")),
921
923
  // @ts-expect-error missing types
922
924
  interopDefault(import("eslint-plugin-react-hooks")),
923
925
  // @ts-expect-error missing types
924
- interopDefault(import("eslint-plugin-react-refresh"))
926
+ interopDefault(import("eslint-plugin-react-refresh")),
927
+ interopDefault(import("@typescript-eslint/parser"))
925
928
  ]);
926
929
  const _isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
927
930
  (i) => isPackageExists2(i)
928
931
  );
932
+ const plugins = pluginReact.configs.all.plugins;
929
933
  return [
930
934
  {
931
935
  name: "eslint:react:setup",
932
936
  plugins: {
933
- "react": pluginReact,
937
+ "react": plugins["@eslint-react"],
938
+ "react-dom": plugins["@eslint-react/dom"],
934
939
  "react-hooks": pluginReactHooks,
940
+ "react-hooks-extra": plugins["@eslint-react/hooks-extra"],
941
+ "react-naming-convention": plugins["@eslint-react/naming-convention"],
935
942
  "react-refresh": pluginReactRefresh
936
943
  }
937
944
  },
938
945
  {
939
946
  files,
940
947
  languageOptions: {
948
+ parser: parserTs,
941
949
  parserOptions: {
942
950
  ecmaFeatures: {
943
951
  jsx
944
- }
952
+ },
953
+ ...isTypeAware ? { project: tsconfigPath } : {}
945
954
  }
946
955
  },
947
956
  name: "eslint:react:rules",
948
957
  rules: {
949
- // react-hooks
958
+ // recommended rules from @eslint-react/dom
959
+ "react-dom/no-children-in-void-dom-elements": "warn",
960
+ "react-dom/no-dangerously-set-innerhtml": "warn",
961
+ "react-dom/no-dangerously-set-innerhtml-with-children": "error",
962
+ "react-dom/no-find-dom-node": "error",
963
+ "react-dom/no-missing-button-type": "warn",
964
+ "react-dom/no-missing-iframe-sandbox": "warn",
965
+ "react-dom/no-namespace": "error",
966
+ "react-dom/no-render-return-value": "error",
967
+ "react-dom/no-script-url": "warn",
968
+ "react-dom/no-unsafe-iframe-sandbox": "warn",
969
+ "react-dom/no-unsafe-target-blank": "warn",
970
+ // recommended rules react-hooks
950
971
  "react-hooks/exhaustive-deps": "warn",
951
972
  "react-hooks/rules-of-hooks": "error",
952
- // react-refresh
973
+ // react refresh
953
974
  // 'react-refresh/only-export-components': [
954
975
  // 'warn',
955
- // { allowConstantExport: _isAllowConstantExport },
976
+ // { allowConstantExport: isAllowConstantExport },
956
977
  // ],
957
- "react-refresh/only-export-components": "off",
958
- // react
959
- "react/boolean-prop-naming": "error",
960
- "react/button-has-type": "error",
961
- "react/default-props-match-prop-types": "error",
962
- "react/destructuring-assignment": "error",
963
- "react/display-name": "error",
964
- "react/forbid-component-props": "off",
965
- // 禁止组件上使用某些 props
966
- "react/forbid-dom-props": "error",
967
- "react/forbid-elements": "error",
968
- "react/forbid-foreign-prop-types": "error",
969
- "react/forbid-prop-types": "error",
970
- "react/function-component-definition": "error",
971
- "react/hook-use-state": "off",
972
- // useState 钩子值和 setter 变量的解构和对称命名
973
- "react/iframe-missing-sandbox": "error",
974
- "react/jsx-boolean-value": "error",
975
- "react/jsx-filename-extension": "off",
976
- // 禁止可能包含 JSX 文件扩展名
977
- "react/jsx-fragments": "error",
978
- "react/jsx-handler-names": "error",
979
- "react/jsx-key": "error",
980
- "react/jsx-max-depth": "off",
981
- // 强制 JSX 最大深度
982
- "react/jsx-no-bind": "off",
983
- // .bind()JSX 属性中禁止使用箭头函数
984
- "react/jsx-no-comment-textnodes": "error",
985
- "react/jsx-no-constructed-context-values": "error",
986
- "react/jsx-no-duplicate-props": "error",
987
- "react/jsx-no-leaked-render": "error",
988
- "react/jsx-no-literals": "off",
989
- // 禁止在 JSX 中使用字符串文字
990
- "react/jsx-no-script-url": "error",
991
- "react/jsx-no-target-blank": "error",
992
- "react/jsx-no-undef": "error",
993
- "react/jsx-no-useless-fragment": "error",
994
- "react/jsx-props-no-spreading": "off",
995
- // 强制任何 JSX 属性都不会传播
996
- "react/jsx-uses-react": "error",
997
- "react/jsx-uses-vars": "error",
978
+ // recommended rules from @eslint-react
979
+ "react/ensure-forward-ref-using-ref": "warn",
998
980
  "react/no-access-state-in-setstate": "error",
999
- "react/no-adjacent-inline-elements": "error",
1000
- "react/no-array-index-key": "error",
1001
- "react/no-arrow-function-lifecycle": "error",
1002
- "react/no-children-prop": "error",
1003
- "react/no-danger": "off",
1004
- // 禁止使用 dangerouslySetInnerHTML
1005
- "react/no-danger-with-children": "error",
1006
- "react/no-deprecated": "error",
1007
- "react/no-did-mount-set-state": "error",
1008
- "react/no-did-update-set-state": "error",
981
+ "react/no-array-index-key": "warn",
982
+ "react/no-children-count": "warn",
983
+ "react/no-children-for-each": "warn",
984
+ "react/no-children-map": "warn",
985
+ "react/no-children-only": "warn",
986
+ "react/no-children-prop": "warn",
987
+ "react/no-children-to-array": "warn",
988
+ "react/no-clone-element": "warn",
989
+ "react/no-comment-textnodes": "warn",
990
+ "react/no-component-will-mount": "error",
991
+ "react/no-component-will-receive-props": "error",
992
+ "react/no-component-will-update": "error",
993
+ "react/no-create-ref": "error",
1009
994
  "react/no-direct-mutation-state": "error",
1010
- "react/no-find-dom-node": "error",
1011
- "react/no-invalid-html-attribute": "error",
1012
- "react/no-is-mounted": "error",
1013
- "react/no-multi-comp": "error",
1014
- "react/no-namespace": "error",
1015
- "react/no-object-type-as-default-prop": "error",
995
+ "react/no-duplicate-key": "error",
996
+ "react/no-implicit-key": "error",
997
+ "react/no-missing-key": "error",
998
+ "react/no-nested-components": "warn",
1016
999
  "react/no-redundant-should-component-update": "error",
1017
- "react/no-render-return-value": "error",
1018
- "react/no-set-state": "error",
1000
+ "react/no-set-state-in-component-did-mount": "warn",
1001
+ "react/no-set-state-in-component-did-update": "warn",
1002
+ "react/no-set-state-in-component-will-update": "warn",
1019
1003
  "react/no-string-refs": "error",
1020
- "react/no-this-in-sfc": "error",
1021
- "react/no-typos": "error",
1022
- "react/no-unescaped-entities": "error",
1023
- "react/no-unknown-property": "error",
1024
- "react/no-unsafe": "off",
1025
- // 禁止使用不安全的生命周期方法
1026
- "react/no-unstable-nested-components": "error",
1027
- "react/no-unused-class-component-methods": "error",
1028
- "react/no-unused-prop-types": "error",
1029
- "react/no-unused-state": "error",
1030
- "react/no-will-update-set-state": "error",
1031
- "react/prefer-es6-class": "error",
1032
- "react/prefer-exact-props": "error",
1033
- "react/prefer-read-only-props": "error",
1034
- "react/prefer-stateless-function": "error",
1035
- "react/prop-types": "error",
1036
- "react/react-in-jsx-scope": "off",
1037
- // 使用 JSX 时需要引入 React
1038
- "react/require-default-props": "off",
1039
- // 为每个非必需 prop 强制执行 defaultProps 定义
1040
- "react/require-optimization": "error",
1041
- "react/require-render-return": "error",
1042
- "react/self-closing-comp": "error",
1043
- "react/sort-comp": "error",
1044
- "react/sort-default-props": "error",
1045
- "react/sort-prop-types": "error",
1046
- "react/state-in-constructor": "error",
1047
- "react/static-property-placement": "error",
1048
- "react/style-prop-object": "error",
1049
- "react/void-dom-elements-no-children": "error",
1050
- "style/jsx-pascal-case": "error",
1051
- ...typescript2 ? {
1052
- "react/jsx-no-undef": "off",
1053
- "react/prop-type": "off"
1004
+ "react/no-unsafe-component-will-mount": "warn",
1005
+ "react/no-unsafe-component-will-receive-props": "warn",
1006
+ "react/no-unsafe-component-will-update": "warn",
1007
+ "react/no-unstable-context-value": "error",
1008
+ "react/no-unstable-default-props": "error",
1009
+ "react/no-unused-class-component-members": "warn",
1010
+ "react/no-unused-state": "warn",
1011
+ "react/no-useless-fragment": "warn",
1012
+ "react/prefer-destructuring-assignment": "warn",
1013
+ "react/prefer-shorthand-boolean": "warn",
1014
+ "react/prefer-shorthand-fragment": "warn",
1015
+ ...isTypeAware ? {
1016
+ "react/no-leaked-conditional-rendering": "warn"
1054
1017
  } : {},
1018
+ // overrides
1055
1019
  ...overrides
1056
1020
  },
1057
1021
  settings: {
@@ -1881,6 +1845,10 @@ var VuePackages = [
1881
1845
  "@slidev/cli"
1882
1846
  ];
1883
1847
  var defaultPluginRenaming = {
1848
+ "@eslint-react": "react",
1849
+ "@eslint-react/dom": "react-dom",
1850
+ "@eslint-react/hooks-extra": "react-hooks-extra",
1851
+ "@eslint-react/naming-convention": "react-naming-convention",
1884
1852
  "@stylistic": "style",
1885
1853
  "@typescript-eslint": "ts",
1886
1854
  "import-x": "import",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lincy/eslint-config",
3
3
  "type": "module",
4
- "version": "4.4.0",
4
+ "version": "4.5.0",
5
5
  "packageManager": "pnpm@8.7.6",
6
6
  "description": "LinCenYing's ESLint config",
7
7
  "author": "LinCenYing <lincenying@gmail.com> (https://github.com/lincenying/)",
@@ -37,21 +37,21 @@
37
37
  "prepare": "npx simple-git-hooks"
38
38
  },
39
39
  "peerDependencies": {
40
+ "@eslint-react/eslint-plugin": "^7.33.2",
40
41
  "@unocss/eslint-plugin": ">=0.50.0",
41
42
  "eslint": ">=8.40.0",
42
43
  "eslint-plugin-format": ">=0.1.0",
43
- "eslint-plugin-react": "^7.33.2",
44
44
  "eslint-plugin-react-hooks": "^4.6.0",
45
45
  "eslint-plugin-react-refresh": "^0.4.4"
46
46
  },
47
47
  "peerDependenciesMeta": {
48
- "@unocss/eslint-plugin": {
48
+ "@eslint-react/eslint-plugin": {
49
49
  "optional": true
50
50
  },
51
- "eslint-plugin-format": {
51
+ "@unocss/eslint-plugin": {
52
52
  "optional": true
53
53
  },
54
- "eslint-plugin-react": {
54
+ "eslint-plugin-format": {
55
55
  "optional": true
56
56
  },
57
57
  "eslint-plugin-react-hooks": {
@@ -64,9 +64,9 @@
64
64
  "dependencies": {
65
65
  "@antfu/eslint-define-config": "1.23.0-2",
66
66
  "@antfu/install-pkg": "^0.3.2",
67
- "@stylistic/eslint-plugin": "1.7.0",
68
- "@typescript-eslint/eslint-plugin": "^7.6.0",
69
- "@typescript-eslint/parser": "^7.6.0",
67
+ "@stylistic/eslint-plugin": "1.7.2",
68
+ "@typescript-eslint/eslint-plugin": "^7.7.1",
69
+ "@typescript-eslint/parser": "^7.7.1",
70
70
  "eslint-config-flat-gitignore": "^0.1.5",
71
71
  "eslint-flat-config-utils": "^0.2.3",
72
72
  "eslint-merge-processors": "^0.1.0",
@@ -86,7 +86,7 @@
86
86
  "eslint-plugin-vitest": "^0.5.3",
87
87
  "eslint-plugin-vue": "^9.25.0",
88
88
  "eslint-plugin-yml": "^1.14.0",
89
- "eslint-processor-vue-blocks": "^0.1.1",
89
+ "eslint-processor-vue-blocks": "^0.1.2",
90
90
  "globals": "^15.0.0",
91
91
  "jsonc-eslint-parser": "^2.4.0",
92
92
  "local-pkg": "^0.5.0",
@@ -97,26 +97,27 @@
97
97
  },
98
98
  "devDependencies": {
99
99
  "@antfu/ni": "^0.21.12",
100
+ "@eslint-react/eslint-plugin": "^1.5.9",
100
101
  "@eslint-types/jsdoc": "48.2.2",
101
102
  "@eslint-types/typescript-eslint": "^7.5.0",
102
103
  "@eslint-types/unicorn": "^52.0.0",
103
- "@eslint/config-inspector": "^0.4.6",
104
+ "@eslint/config-inspector": "^0.4.7",
104
105
  "@lincy/eslint-config": "workspace:*",
105
- "@stylistic/eslint-plugin-migrate": "^1.7.0",
106
- "@types/eslint": "^8.56.9",
106
+ "@stylistic/eslint-plugin-migrate": "^1.7.2",
107
+ "@types/eslint": "^8.56.10",
107
108
  "@types/node": "^20.12.7",
108
109
  "@types/prompts": "^2.4.9",
109
- "@unocss/eslint-plugin": "^0.59.2",
110
+ "@unocss/eslint-plugin": "^0.59.4",
110
111
  "bumpp": "^9.4.0",
111
- "eslint": "^8.57.0",
112
- "eslint-plugin-format": "^0.1.0",
113
- "eslint-plugin-react": "^7.34.1",
112
+ "eslint": "^9.1.1",
113
+ "eslint-plugin-format": "^0.1.1",
114
114
  "eslint-plugin-react-hooks": "^4.6.0",
115
115
  "eslint-plugin-react-refresh": "^0.4.6",
116
- "eslint-typegen": "^0.2.2",
116
+ "eslint-typegen": "^0.2.4",
117
117
  "esno": "^4.7.0",
118
118
  "lint-staged": "^15.2.2",
119
119
  "prettier": "^3.2.5",
120
+ "react": "^18.2.0",
120
121
  "rimraf": "^5.0.5",
121
122
  "simple-git-hooks": "^2.11.1",
122
123
  "simple-open-url": "^3.0.1",
@@ -125,7 +126,7 @@
125
126
  "typescript": "^5.4.5",
126
127
  "unbuild": "^2.0.0",
127
128
  "vitest": "^1.5.0",
128
- "vue": "^3.4.21"
129
+ "vue": "^3.4.24"
129
130
  },
130
131
  "pnpm": {
131
132
  "peerDependencyRules": {