|
| 1 | +/* eslint-disable perfectionist/sort-objects */ |
1 | 2 | import type { OptionsFiles, OptionsOverrides, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, TypedFlatConfigItem } from '../types'
|
2 | 3 |
|
3 | 4 | import { isPackageExists } from 'local-pkg'
|
@@ -93,23 +94,78 @@ export async function react(
|
93 | 94 | },
|
94 | 95 | name: 'antfu/react/rules',
|
95 | 96 | rules: {
|
96 |
| - // recommended rules from @eslint-react/dom |
97 |
| - 'react-dom/no-children-in-void-dom-elements': 'warn', |
| 97 | + // recommended rules from eslint-plugin-react-x https://eslint-react.xyz/docs/rules/overview#core-rules |
| 98 | + 'react/no-access-state-in-setstate': 'error', |
| 99 | + 'react/no-array-index-key': 'warn', |
| 100 | + 'react/no-children-count': 'warn', |
| 101 | + 'react/no-children-for-each': 'warn', |
| 102 | + 'react/no-children-map': 'warn', |
| 103 | + 'react/no-children-only': 'warn', |
| 104 | + 'react/no-children-to-array': 'warn', |
| 105 | + 'react/no-clone-element': 'warn', |
| 106 | + 'react/no-comment-textnodes': 'warn', |
| 107 | + 'react/no-component-will-mount': 'error', |
| 108 | + 'react/no-component-will-receive-props': 'error', |
| 109 | + 'react/no-component-will-update': 'error', |
| 110 | + 'react/no-context-provider': 'warn', |
| 111 | + 'react/no-create-ref': 'error', |
| 112 | + 'react/no-default-props': 'error', |
| 113 | + 'react/no-direct-mutation-state': 'error', |
| 114 | + 'react/no-duplicate-jsx-props': 'warn', |
| 115 | + 'react/no-duplicate-key': 'warn', |
| 116 | + 'react/no-forward-ref': 'warn', |
| 117 | + 'react/no-implicit-key': 'warn', |
| 118 | + 'react/no-missing-key': 'error', |
| 119 | + 'react/no-nested-component-definitions': 'error', |
| 120 | + 'react/no-prop-types': 'error', |
| 121 | + 'react/no-redundant-should-component-update': 'error', |
| 122 | + 'react/no-set-state-in-component-did-mount': 'warn', |
| 123 | + 'react/no-set-state-in-component-did-update': 'warn', |
| 124 | + 'react/no-set-state-in-component-will-update': 'warn', |
| 125 | + 'react/no-string-refs': 'error', |
| 126 | + 'react/no-unsafe-component-will-mount': 'warn', |
| 127 | + 'react/no-unsafe-component-will-receive-props': 'warn', |
| 128 | + 'react/no-unsafe-component-will-update': 'warn', |
| 129 | + 'react/no-unstable-context-value': 'warn', |
| 130 | + 'react/no-unstable-default-props': 'warn', |
| 131 | + 'react/no-unused-class-component-members': 'warn', |
| 132 | + 'react/no-unused-state': 'warn', |
| 133 | + 'react/no-use-context': 'warn', |
| 134 | + 'react/no-useless-forward-ref': 'warn', |
| 135 | + 'react/use-jsx-vars': 'warn', |
| 136 | + |
| 137 | + // recommended rules from eslint-plugin-react-dom https://eslint-react.xyz/docs/rules/overview#dom-rules |
98 | 138 | 'react-dom/no-dangerously-set-innerhtml': 'warn',
|
99 | 139 | 'react-dom/no-dangerously-set-innerhtml-with-children': 'error',
|
100 | 140 | 'react-dom/no-find-dom-node': 'error',
|
| 141 | + 'react-dom/no-flush-sync': 'error', |
| 142 | + 'react-dom/no-hydrate': 'error', |
101 | 143 | 'react-dom/no-missing-button-type': 'warn',
|
102 | 144 | 'react-dom/no-missing-iframe-sandbox': 'warn',
|
103 | 145 | 'react-dom/no-namespace': 'error',
|
| 146 | + 'react-dom/no-render': 'error', |
104 | 147 | 'react-dom/no-render-return-value': 'error',
|
105 | 148 | 'react-dom/no-script-url': 'warn',
|
106 | 149 | 'react-dom/no-unsafe-iframe-sandbox': 'warn',
|
107 | 150 | 'react-dom/no-unsafe-target-blank': 'warn',
|
| 151 | + 'react-dom/no-use-form-state': 'error', |
| 152 | + 'react-dom/no-void-elements-with-children': 'error', |
108 | 153 |
|
109 |
| - // recommended rules react-hooks |
| 154 | + // recommended rules eslint-plugin-react-hooks https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks/src/rules |
110 | 155 | 'react-hooks/exhaustive-deps': 'warn',
|
111 | 156 | 'react-hooks/rules-of-hooks': 'error',
|
112 |
| - // react refresh |
| 157 | + |
| 158 | + // recommended rules from eslint-plugin-react-hooks-extra https://eslint-react.xyz/docs/rules/overview#hooks-extra-rules |
| 159 | + 'react-hooks-extra/no-direct-set-state-in-use-effect': 'warn', |
| 160 | + 'react-hooks-extra/no-unnecessary-use-prefix': 'warn', |
| 161 | + |
| 162 | + // recommended rules from eslint-plugin-react-web-api https://eslint-react.xyz/docs/rules/overview#web-api-rules |
| 163 | + 'react-web-api/no-leaked-event-listener': 'warn', |
| 164 | + 'react-web-api/no-leaked-interval': 'warn', |
| 165 | + 'react-web-api/no-leaked-resize-observer': 'warn', |
| 166 | + 'react-web-api/no-leaked-timeout': 'warn', |
| 167 | + |
| 168 | + // preconfigured rules from eslint-plugin-react-refresh https://github.com/ArnaudBarre/eslint-plugin-react-refresh/tree/main/src |
113 | 169 | 'react-refresh/only-export-components': [
|
114 | 170 | 'warn',
|
115 | 171 | {
|
@@ -144,55 +200,6 @@ export async function react(
|
144 | 200 | ],
|
145 | 201 | },
|
146 | 202 | ],
|
147 |
| - // recommended rules from @eslint-react/web-api |
148 |
| - 'react-web-api/no-leaked-event-listener': 'warn', |
149 |
| - |
150 |
| - 'react-web-api/no-leaked-interval': 'warn', |
151 |
| - 'react-web-api/no-leaked-resize-observer': 'warn', |
152 |
| - |
153 |
| - 'react-web-api/no-leaked-timeout': 'warn', |
154 |
| - |
155 |
| - // recommended rules from @eslint-react |
156 |
| - 'react/ensure-forward-ref-using-ref': 'warn', |
157 |
| - 'react/jsx-no-duplicate-props': 'warn', |
158 |
| - 'react/jsx-uses-vars': 'warn', |
159 |
| - 'react/no-access-state-in-setstate': 'error', |
160 |
| - 'react/no-array-index-key': 'warn', |
161 |
| - 'react/no-children-count': 'warn', |
162 |
| - 'react/no-children-for-each': 'warn', |
163 |
| - 'react/no-children-map': 'warn', |
164 |
| - 'react/no-children-only': 'warn', |
165 |
| - 'react/no-children-to-array': 'warn', |
166 |
| - 'react/no-clone-element': 'warn', |
167 |
| - 'react/no-comment-textnodes': 'warn', |
168 |
| - 'react/no-component-will-mount': 'error', |
169 |
| - 'react/no-component-will-receive-props': 'error', |
170 |
| - 'react/no-component-will-update': 'error', |
171 |
| - 'react/no-context-provider': 'warn', |
172 |
| - 'react/no-create-ref': 'error', |
173 |
| - 'react/no-default-props': 'error', |
174 |
| - 'react/no-direct-mutation-state': 'error', |
175 |
| - 'react/no-duplicate-key': 'error', |
176 |
| - 'react/no-forward-ref': 'warn', |
177 |
| - 'react/no-implicit-key': 'warn', |
178 |
| - 'react/no-missing-key': 'error', |
179 |
| - 'react/no-nested-components': 'error', |
180 |
| - 'react/no-prop-types': 'error', |
181 |
| - 'react/no-redundant-should-component-update': 'error', |
182 |
| - 'react/no-set-state-in-component-did-mount': 'warn', |
183 |
| - 'react/no-set-state-in-component-did-update': 'warn', |
184 |
| - 'react/no-set-state-in-component-will-update': 'warn', |
185 |
| - 'react/no-string-refs': 'error', |
186 |
| - 'react/no-unsafe-component-will-mount': 'warn', |
187 |
| - 'react/no-unsafe-component-will-receive-props': 'warn', |
188 |
| - 'react/no-unsafe-component-will-update': 'warn', |
189 |
| - 'react/no-unstable-context-value': 'warn', |
190 |
| - 'react/no-unstable-default-props': 'warn', |
191 |
| - 'react/no-unused-class-component-members': 'warn', |
192 |
| - 'react/no-unused-state': 'warn', |
193 |
| - 'react/prefer-destructuring-assignment': 'warn', |
194 |
| - 'react/prefer-shorthand-boolean': 'warn', |
195 |
| - 'react/prefer-shorthand-fragment': 'warn', |
196 | 203 |
|
197 | 204 | // overrides
|
198 | 205 | ...overrides,
|
|
0 commit comments