|
1 | | -import { name, version } from "../package.json"; |
2 | | -import noDangerouslySetInnerHTML from "./rules/no-dangerously-set-innerhtml"; |
3 | | -import noDangerouslySetInnerHTMLWithChildren from "./rules/no-dangerously-set-innerhtml-with-children"; |
4 | | -import noFindDomNode from "./rules/no-find-dom-node"; |
5 | | -import noMissingButtonType from "./rules/no-missing-button-type"; |
6 | | -import noMissingIframeSandbox from "./rules/no-missing-iframe-sandbox"; |
7 | | -import noNamespace from "./rules/no-namespace"; |
8 | | -import noRenderReturnValue from "./rules/no-render-return-value"; |
9 | | -import noScriptUrl from "./rules/no-script-url"; |
10 | | -import noUnknownProperty from "./rules/no-unknown-property"; |
11 | | -import noUnsafeIframeSandbox from "./rules/no-unsafe-iframe-sandbox"; |
12 | | -import noUnsafeTargetBlank from "./rules/no-unsafe-target-blank"; |
13 | | -import noVoidElementsWithChildren from "./rules/no-void-elements-with-children"; |
| 1 | +import type { Linter } from "eslint"; |
14 | 2 |
|
15 | | -export default { |
16 | | - meta: { |
17 | | - name, |
18 | | - version, |
19 | | - }, |
20 | | - rules: { |
21 | | - "no-dangerously-set-innerhtml": noDangerouslySetInnerHTML, |
22 | | - "no-dangerously-set-innerhtml-with-children": noDangerouslySetInnerHTMLWithChildren, |
23 | | - "no-find-dom-node": noFindDomNode, |
24 | | - "no-missing-button-type": noMissingButtonType, |
25 | | - "no-missing-iframe-sandbox": noMissingIframeSandbox, |
26 | | - "no-namespace": noNamespace, |
27 | | - "no-render-return-value": noRenderReturnValue, |
28 | | - "no-script-url": noScriptUrl, |
29 | | - "no-unknown-property": noUnknownProperty, |
30 | | - "no-unsafe-iframe-sandbox": noUnsafeIframeSandbox, |
31 | | - "no-unsafe-target-blank": noUnsafeTargetBlank, |
32 | | - "no-void-elements-with-children": noVoidElementsWithChildren, |
| 3 | +import * as recommendedConfig from "./configs/recommended"; |
| 4 | +import { plugin } from "./plugin"; |
| 5 | + |
| 6 | +function makeConfig(config: Linter.Config): Linter.Config { |
| 7 | + return { |
| 8 | + ...config, |
| 9 | + plugins: { |
| 10 | + ...config.plugins, |
| 11 | + "react-dom": plugin, |
| 12 | + }, |
| 13 | + }; |
| 14 | +} |
33 | 15 |
|
34 | | - // Part: deprecated rules |
35 | | - /** @deprecated Use `no-void-elements-with-children` instead */ |
36 | | - "no-children-in-void-dom-elements": noVoidElementsWithChildren, |
| 16 | +function toLegacyConfig({ rules }: Linter.Config): Linter.LegacyConfig { |
| 17 | + return { |
| 18 | + plugins: ["react-dom"], |
| 19 | + rules, |
| 20 | + }; |
| 21 | +} |
| 22 | + |
| 23 | +export default { |
| 24 | + ...plugin, |
| 25 | + configs: { |
| 26 | + ["recommended"]: makeConfig(recommendedConfig), |
| 27 | + ["recommended-legacy"]: toLegacyConfig(recommendedConfig), |
37 | 28 | }, |
38 | | -} as const; |
| 29 | +}; |
0 commit comments