Skip to content

Commit 40f566e

Browse files
committed
feat: add 'RuleFeature' type to rules
1 parent b4503c6 commit 40f566e

File tree

82 files changed

+414
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+414
-5
lines changed

packages/plugins/eslint-plugin-react-debug/src/rules/class-component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import { useComponentCollectorLegacy } from "@eslint-react/core";
22
import { F, O } from "@eslint-react/tools";
3+
import type { RuleFeature } from "@eslint-react/types";
34
import type { CamelCase } from "string-ts";
45

56
import { createRule } from "../utils";
67

78
export const RULE_NAME = "class-component";
89

10+
export const RULE_FEATURES = [
11+
"DBG",
12+
] as const satisfies RuleFeature[];
13+
914
export type MessageID = CamelCase<typeof RULE_NAME>;
1015

1116
export default createRule<[], MessageID>({

packages/plugins/eslint-plugin-react-debug/src/rules/function-component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import { ERFunctionComponentFlag, useComponentCollector } from "@eslint-react/core";
22
import { F, O } from "@eslint-react/tools";
3+
import type { RuleFeature } from "@eslint-react/types";
34
import type { CamelCase } from "string-ts";
45

56
import { createRule } from "../utils";
67

78
export const RULE_NAME = "function-component";
89

10+
export const RULE_FEATURES = [
11+
"DBG",
12+
] as const satisfies RuleFeature[];
13+
914
export type MessageID = CamelCase<typeof RULE_NAME>;
1015

1116
export default createRule<[], MessageID>({

packages/plugins/eslint-plugin-react-debug/src/rules/hook.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import { useHookCollector } from "@eslint-react/core";
2+
import type { RuleFeature } from "@eslint-react/types";
23
import type { CamelCase } from "string-ts";
34

45
import { createRule } from "../utils";
56

67
export const RULE_NAME = "hook";
78

9+
export const RULE_FEATURES = [
10+
"DBG",
11+
] as const satisfies RuleFeature[];
12+
813
export type MessageID = CamelCase<typeof RULE_NAME>;
914

1015
export default createRule<[], MessageID>({

packages/plugins/eslint-plugin-react-debug/src/rules/is-from-react.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { isInitializedFromReact } from "@eslint-react/core";
22
import { decodeSettings } from "@eslint-react/shared";
33
import { F, O } from "@eslint-react/tools";
4+
import type { RuleFeature } from "@eslint-react/types";
45
import type { Scope } from "@typescript-eslint/scope-manager";
56
import type { TSESTree } from "@typescript-eslint/utils";
67
import { AST_NODE_TYPES } from "@typescript-eslint/utils";
@@ -11,6 +12,10 @@ import { createRule } from "../utils";
1112

1213
export const RULE_NAME = "is-from-react";
1314

15+
export const RULE_FEATURES = [
16+
"DBG",
17+
] as const satisfies RuleFeature[];
18+
1419
export type MessageID = CamelCase<typeof RULE_NAME>;
1520

1621
export default createRule<[], MessageID>({

packages/plugins/eslint-plugin-react-dom/src/rules/no-children-in-void-dom-elements.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import * as JSX from "@eslint-react/jsx";
22
import { O } from "@eslint-react/tools";
3+
import type { RuleFeature } from "@eslint-react/types";
34
import type { CamelCase } from "string-ts";
45

56
import { createRule } from "../utils";
67

78
export const RULE_NAME = "no-children-in-void-dom-elements";
89

10+
export const RULE_FEATURES = [
11+
"LNT",
12+
] as const satisfies RuleFeature[];
13+
914
export type MessageID = CamelCase<typeof RULE_NAME>;
1015

1116
const voidElements = [

packages/plugins/eslint-plugin-react-dom/src/rules/no-dangerously-set-innerhtml-with-children.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
import * as JSX from "@eslint-react/jsx";
22
import { isNullable } from "@eslint-react/tools";
3+
import type { RuleFeature } from "@eslint-react/types";
34
import type { TSESTree } from "@typescript-eslint/types";
45
import type { CamelCase } from "string-ts";
56

67
import { createRule } from "../utils";
78

89
export const RULE_NAME = "no-dangerously-set-innerhtml-with-children";
910

11+
export const RULE_FEATURES = [
12+
"LNT",
13+
] as const satisfies RuleFeature[];
14+
1015
export type MessageID = CamelCase<typeof RULE_NAME>;
1116

1217
function firstChildIsText(node: TSESTree.JSXElement) {

packages/plugins/eslint-plugin-react-dom/src/rules/no-dangerously-set-innerhtml.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import * as JSX from "@eslint-react/jsx";
22
import { O } from "@eslint-react/tools";
3+
import type { RuleFeature } from "@eslint-react/types";
34
import type { CamelCase } from "string-ts";
45

56
import { createRule } from "../utils";
67

78
export const RULE_NAME = "no-dangerously-set-innerhtml";
89

10+
export const RULE_FEATURES = [
11+
"LNT",
12+
] as const satisfies RuleFeature[];
13+
914
export type MessageID = CamelCase<typeof RULE_NAME>;
1015

1116
// TODO: Use the information in `settings["react-x"].additionalComponents` to add support for user-defined components that use different properties to receive HTML and set them internally.

packages/plugins/eslint-plugin-react-dom/src/rules/no-find-dom-node.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
import type { RuleFeature } from "@eslint-react/types";
12
import { AST_NODE_TYPES } from "@typescript-eslint/types";
23
import type { CamelCase } from "string-ts";
34

45
import { createRule } from "../utils";
56

67
export const RULE_NAME = "no-find-dom-node";
78

9+
export const RULE_FEATURES = [
10+
"LNT",
11+
] as const satisfies RuleFeature[];
12+
813
export type MessageID = CamelCase<typeof RULE_NAME>;
914

1015
export default createRule<[], MessageID>({

packages/plugins/eslint-plugin-react-dom/src/rules/no-missing-button-type.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
import { getElementRepresentName } from "@eslint-react/core";
22
import * as JSX from "@eslint-react/jsx";
33
import { O } from "@eslint-react/tools";
4+
import type { RuleFeature } from "@eslint-react/types";
45
import type { CamelCase } from "string-ts";
56

67
import { createRule } from "../utils";
78

89
export const RULE_NAME = "no-missing-button-type";
910

11+
export const RULE_FEATURES = [
12+
"LNT",
13+
] as const satisfies RuleFeature[];
14+
1015
export type MessageID = CamelCase<typeof RULE_NAME>;
1116

1217
// TODO: Use the information in `settings["react-x"].additionalComponents` to add support for user-defined components

packages/plugins/eslint-plugin-react-dom/src/rules/no-missing-iframe-sandbox.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
import { getElementRepresentName } from "@eslint-react/core";
22
import * as JSX from "@eslint-react/jsx";
33
import { F, isString, O } from "@eslint-react/tools";
4+
import type { RuleFeature } from "@eslint-react/types";
45
import type { CamelCase } from "string-ts";
56

67
import { createRule } from "../utils";
78

89
export const RULE_NAME = "no-missing-iframe-sandbox";
910

11+
export const RULE_FEATURES = [
12+
"LNT",
13+
] as const satisfies RuleFeature[];
14+
1015
export type MessageID = CamelCase<typeof RULE_NAME>;
1116

1217
const validTypes = [

0 commit comments

Comments
 (0)