@html-eslint/eslint-plugin-react 0.56.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/LICENSE +21 -0
- package/README.md +11 -0
- package/lib/configs/index.js +14 -0
- package/lib/constants/node-types.js +176 -0
- package/lib/index.js +37 -0
- package/lib/rules/index.js +15 -0
- package/lib/rules/no-ineffective-attrs.js +67 -0
- package/lib/rules/no-invalid-attr-value.js +96 -0
- package/lib/rules/no-obsolete-attrs.js +55 -0
- package/lib/rules/no-obsolete-tags.js +54 -0
- package/lib/rules/use-baseline.js +92 -0
- package/lib/rules/utils/adapter.js +180 -0
- package/lib/types.js +1 -0
- package/lib/types.ts +401 -0
- package/package.json +55 -0
- package/types/configs/index.d.ts +2 -0
- package/types/configs/index.d.ts.map +1 -0
- package/types/constants/node-types.d.ts +171 -0
- package/types/constants/node-types.d.ts.map +1 -0
- package/types/index.d.ts +6 -0
- package/types/index.d.ts.map +1 -0
- package/types/rules/index.d.ts +22 -0
- package/types/rules/index.d.ts.map +1 -0
- package/types/rules/no-ineffective-attrs.d.ts +4 -0
- package/types/rules/no-ineffective-attrs.d.ts.map +1 -0
- package/types/rules/no-invalid-attr-value.d.ts +10 -0
- package/types/rules/no-invalid-attr-value.d.ts.map +1 -0
- package/types/rules/no-obsolete-attrs.d.ts +4 -0
- package/types/rules/no-obsolete-attrs.d.ts.map +1 -0
- package/types/rules/no-obsolete-tags.d.ts +10 -0
- package/types/rules/no-obsolete-tags.d.ts.map +1 -0
- package/types/rules/use-baseline.d.ts +10 -0
- package/types/rules/use-baseline.d.ts.map +1 -0
- package/types/rules/utils/adapter.d.ts +14 -0
- package/types/rules/utils/adapter.d.ts.map +1 -0
- package/types/types.d.ts +255 -0
- package/types/types.d.ts.map +1 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {
|
|
3
|
+
* AttributeAdapter,
|
|
4
|
+
* ElementNodeAdapter
|
|
5
|
+
* } from "@html-eslint/core"
|
|
6
|
+
* @import {
|
|
7
|
+
* JSXAttribute,
|
|
8
|
+
* JSXOpeningElement,
|
|
9
|
+
* JSXSpreadAttribute,
|
|
10
|
+
* Node,
|
|
11
|
+
* NullLiteral
|
|
12
|
+
* } from "../../types"
|
|
13
|
+
*/
|
|
14
|
+
const { AST_NODE_TYPES } = require("../../constants/node-types");
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @type {AttributeAdapter<
|
|
18
|
+
* JSXSpreadAttribute | JSXAttribute["name"] | null,
|
|
19
|
+
* JSXAttribute["value"]
|
|
20
|
+
* >}
|
|
21
|
+
*/
|
|
22
|
+
const nullAdapter = {
|
|
23
|
+
key: {
|
|
24
|
+
node: () => null,
|
|
25
|
+
isExpression() {
|
|
26
|
+
return true;
|
|
27
|
+
},
|
|
28
|
+
value: () => null,
|
|
29
|
+
raw: () => null,
|
|
30
|
+
},
|
|
31
|
+
value: {
|
|
32
|
+
node: () => null,
|
|
33
|
+
isExpression() {
|
|
34
|
+
return true;
|
|
35
|
+
},
|
|
36
|
+
value: () => null,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @param {Node} node
|
|
42
|
+
* @returns {node is NullLiteral}
|
|
43
|
+
*/
|
|
44
|
+
function isNullLiteral(node) {
|
|
45
|
+
return node.type === AST_NODE_TYPES.Literal && node.value == null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @param {Node} node
|
|
50
|
+
* @returns {string | null}
|
|
51
|
+
*/
|
|
52
|
+
function getAttributeValue(node) {
|
|
53
|
+
switch (node.type) {
|
|
54
|
+
case AST_NODE_TYPES.Literal:
|
|
55
|
+
if (node.value === null) {
|
|
56
|
+
if (isNullLiteral(node)) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
if ("regex" in node) {
|
|
60
|
+
// @ts-ignore
|
|
61
|
+
return `/${node.regex.pattern}/${node.regex.flags}`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if ("bigint" in node) {
|
|
65
|
+
// @ts-ignore
|
|
66
|
+
return node.bigint;
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
if (node.value === true) {
|
|
70
|
+
return "";
|
|
71
|
+
}
|
|
72
|
+
if (node.value === false || node.value === undefined) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
return String(node.value);
|
|
76
|
+
}
|
|
77
|
+
break;
|
|
78
|
+
|
|
79
|
+
case AST_NODE_TYPES.TemplateLiteral:
|
|
80
|
+
if (node.expressions.length === 0 && node.quasis.length === 1) {
|
|
81
|
+
return node.quasis[0].value.cooked;
|
|
82
|
+
}
|
|
83
|
+
break;
|
|
84
|
+
case AST_NODE_TYPES.JSXExpressionContainer: {
|
|
85
|
+
// @ts-ignore
|
|
86
|
+
return getAttributeValue(node.expression);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @param {JSXAttribute | JSXSpreadAttribute} node
|
|
94
|
+
* @returns {AttributeAdapter<
|
|
95
|
+
* JSXSpreadAttribute | JSXAttribute["name"] | null,
|
|
96
|
+
* JSXAttribute["value"]
|
|
97
|
+
* >}
|
|
98
|
+
*/
|
|
99
|
+
function attributeNodeAdapter(node) {
|
|
100
|
+
if (node.type === AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
101
|
+
return nullAdapter;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
key: {
|
|
106
|
+
node: () => node.name,
|
|
107
|
+
isExpression() {
|
|
108
|
+
return false;
|
|
109
|
+
},
|
|
110
|
+
value: () => {
|
|
111
|
+
if (node.name.type === AST_NODE_TYPES.JSXIdentifier) {
|
|
112
|
+
return node.name.name.toLowerCase();
|
|
113
|
+
}
|
|
114
|
+
return `${node.name.namespace}:${node.name.name}`;
|
|
115
|
+
},
|
|
116
|
+
raw: () => {
|
|
117
|
+
if (node.name.type === AST_NODE_TYPES.JSXIdentifier) {
|
|
118
|
+
return node.name.name;
|
|
119
|
+
}
|
|
120
|
+
return `${node.name.namespace}:${node.name.name}`;
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
value: {
|
|
124
|
+
node: () => node.value,
|
|
125
|
+
isExpression() {
|
|
126
|
+
if (!node.value) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (node.value.type === AST_NODE_TYPES.Literal) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (
|
|
135
|
+
node.value.type === AST_NODE_TYPES.JSXExpressionContainer &&
|
|
136
|
+
(node.value.expression.type === AST_NODE_TYPES.Literal ||
|
|
137
|
+
(node.value.expression.type === AST_NODE_TYPES.TemplateLiteral &&
|
|
138
|
+
node.value.expression.expressions.length === 0 &&
|
|
139
|
+
node.value.expression.quasis.length === 1))
|
|
140
|
+
) {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return true;
|
|
145
|
+
},
|
|
146
|
+
value: () => {
|
|
147
|
+
if (!node.value) {
|
|
148
|
+
return "";
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return getAttributeValue(node.value);
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @param {JSXOpeningElement} node
|
|
159
|
+
* @returns {ElementNodeAdapter<
|
|
160
|
+
* JSXOpeningElement,
|
|
161
|
+
* JSXSpreadAttribute | JSXAttribute["name"] | null,
|
|
162
|
+
* JSXAttribute["value"]
|
|
163
|
+
* >}
|
|
164
|
+
*/
|
|
165
|
+
function elementNodeAdapter(node) {
|
|
166
|
+
return {
|
|
167
|
+
node: () => node,
|
|
168
|
+
getTagName() {
|
|
169
|
+
if (node.name.type === AST_NODE_TYPES.JSXIdentifier) {
|
|
170
|
+
return node.name.name;
|
|
171
|
+
}
|
|
172
|
+
return "";
|
|
173
|
+
},
|
|
174
|
+
getAttributes() {
|
|
175
|
+
return node.attributes.map(attributeNodeAdapter);
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
module.exports = { elementNodeAdapter };
|
package/lib/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = {};
|
package/lib/types.ts
ADDED
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
/** https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/utils/src/ts-eslint/Rule.ts */
|
|
2
|
+
import type { TSESTree } from "@typescript-eslint/types";
|
|
3
|
+
import eslint from "eslint";
|
|
4
|
+
|
|
5
|
+
/** Utility type to convert node type enum to string literal */
|
|
6
|
+
type NodeWithStringType<T extends TSESTree.Node> = Omit<T, "type"> & {
|
|
7
|
+
type: `${T["type"]}`;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type NullLiteral = NodeWithStringType<TSESTree.NullLiteral>;
|
|
11
|
+
|
|
12
|
+
// Node type aliases with string literal types
|
|
13
|
+
export type AccessorProperty = NodeWithStringType<TSESTree.AccessorProperty>;
|
|
14
|
+
export type ArrayExpression = NodeWithStringType<TSESTree.ArrayExpression>;
|
|
15
|
+
export type ArrayPattern = NodeWithStringType<TSESTree.ArrayPattern>;
|
|
16
|
+
export type ArrowFunctionExpression =
|
|
17
|
+
NodeWithStringType<TSESTree.ArrowFunctionExpression>;
|
|
18
|
+
export type AssignmentExpression =
|
|
19
|
+
NodeWithStringType<TSESTree.AssignmentExpression>;
|
|
20
|
+
export type AssignmentPattern = NodeWithStringType<TSESTree.AssignmentPattern>;
|
|
21
|
+
export type AwaitExpression = NodeWithStringType<TSESTree.AwaitExpression>;
|
|
22
|
+
export type BinaryExpression = NodeWithStringType<TSESTree.BinaryExpression>;
|
|
23
|
+
export type BlockStatement = NodeWithStringType<TSESTree.BlockStatement>;
|
|
24
|
+
export type BreakStatement = NodeWithStringType<TSESTree.BreakStatement>;
|
|
25
|
+
export type CallExpression = NodeWithStringType<TSESTree.CallExpression>;
|
|
26
|
+
export type CatchClause = NodeWithStringType<TSESTree.CatchClause>;
|
|
27
|
+
export type ChainExpression = NodeWithStringType<TSESTree.ChainExpression>;
|
|
28
|
+
export type ClassBody = NodeWithStringType<TSESTree.ClassBody>;
|
|
29
|
+
export type ClassDeclaration = NodeWithStringType<TSESTree.ClassDeclaration>;
|
|
30
|
+
export type ClassExpression = NodeWithStringType<TSESTree.ClassExpression>;
|
|
31
|
+
export type ConditionalExpression =
|
|
32
|
+
NodeWithStringType<TSESTree.ConditionalExpression>;
|
|
33
|
+
export type ContinueStatement = NodeWithStringType<TSESTree.ContinueStatement>;
|
|
34
|
+
export type DebuggerStatement = NodeWithStringType<TSESTree.DebuggerStatement>;
|
|
35
|
+
export type Decorator = NodeWithStringType<TSESTree.Decorator>;
|
|
36
|
+
export type DoWhileStatement = NodeWithStringType<TSESTree.DoWhileStatement>;
|
|
37
|
+
export type EmptyStatement = NodeWithStringType<TSESTree.EmptyStatement>;
|
|
38
|
+
export type ExportAllDeclaration =
|
|
39
|
+
NodeWithStringType<TSESTree.ExportAllDeclaration>;
|
|
40
|
+
export type ExportDefaultDeclaration =
|
|
41
|
+
NodeWithStringType<TSESTree.ExportDefaultDeclaration>;
|
|
42
|
+
export type ExportNamedDeclaration =
|
|
43
|
+
NodeWithStringType<TSESTree.ExportNamedDeclaration>;
|
|
44
|
+
export type ExportSpecifier = NodeWithStringType<TSESTree.ExportSpecifier>;
|
|
45
|
+
export type ExpressionStatement =
|
|
46
|
+
NodeWithStringType<TSESTree.ExpressionStatement>;
|
|
47
|
+
export type ForInStatement = NodeWithStringType<TSESTree.ForInStatement>;
|
|
48
|
+
export type ForOfStatement = NodeWithStringType<TSESTree.ForOfStatement>;
|
|
49
|
+
export type ForStatement = NodeWithStringType<TSESTree.ForStatement>;
|
|
50
|
+
export type FunctionDeclaration =
|
|
51
|
+
NodeWithStringType<TSESTree.FunctionDeclaration>;
|
|
52
|
+
export type FunctionExpression =
|
|
53
|
+
NodeWithStringType<TSESTree.FunctionExpression>;
|
|
54
|
+
export type Identifier = NodeWithStringType<TSESTree.Identifier>;
|
|
55
|
+
export type IfStatement = NodeWithStringType<TSESTree.IfStatement>;
|
|
56
|
+
export type ImportAttribute = NodeWithStringType<TSESTree.ImportAttribute>;
|
|
57
|
+
export type ImportDeclaration = NodeWithStringType<TSESTree.ImportDeclaration>;
|
|
58
|
+
export type ImportDefaultSpecifier =
|
|
59
|
+
NodeWithStringType<TSESTree.ImportDefaultSpecifier>;
|
|
60
|
+
export type ImportExpression = NodeWithStringType<TSESTree.ImportExpression>;
|
|
61
|
+
export type ImportNamespaceSpecifier =
|
|
62
|
+
NodeWithStringType<TSESTree.ImportNamespaceSpecifier>;
|
|
63
|
+
export type ImportSpecifier = NodeWithStringType<TSESTree.ImportSpecifier>;
|
|
64
|
+
export type JSXAttribute = NodeWithStringType<TSESTree.JSXAttribute>;
|
|
65
|
+
export type JSXClosingElement = NodeWithStringType<TSESTree.JSXClosingElement>;
|
|
66
|
+
export type JSXClosingFragment =
|
|
67
|
+
NodeWithStringType<TSESTree.JSXClosingFragment>;
|
|
68
|
+
export type JSXElement = NodeWithStringType<TSESTree.JSXElement>;
|
|
69
|
+
export type JSXEmptyExpression =
|
|
70
|
+
NodeWithStringType<TSESTree.JSXEmptyExpression>;
|
|
71
|
+
export type JSXExpressionContainer =
|
|
72
|
+
NodeWithStringType<TSESTree.JSXExpressionContainer>;
|
|
73
|
+
export type JSXFragment = NodeWithStringType<TSESTree.JSXFragment>;
|
|
74
|
+
export type JSXIdentifier = NodeWithStringType<TSESTree.JSXIdentifier>;
|
|
75
|
+
export type JSXMemberExpression =
|
|
76
|
+
NodeWithStringType<TSESTree.JSXMemberExpression>;
|
|
77
|
+
export type JSXNamespacedName = NodeWithStringType<TSESTree.JSXNamespacedName>;
|
|
78
|
+
export type JSXOpeningElement = NodeWithStringType<TSESTree.JSXOpeningElement>;
|
|
79
|
+
export type JSXOpeningFragment =
|
|
80
|
+
NodeWithStringType<TSESTree.JSXOpeningFragment>;
|
|
81
|
+
export type JSXSpreadAttribute =
|
|
82
|
+
NodeWithStringType<TSESTree.JSXSpreadAttribute>;
|
|
83
|
+
export type JSXSpreadChild = NodeWithStringType<TSESTree.JSXSpreadChild>;
|
|
84
|
+
export type JSXText = NodeWithStringType<TSESTree.JSXText>;
|
|
85
|
+
export type LabeledStatement = NodeWithStringType<TSESTree.LabeledStatement>;
|
|
86
|
+
export type Literal = NodeWithStringType<TSESTree.Literal>;
|
|
87
|
+
export type LogicalExpression = NodeWithStringType<TSESTree.LogicalExpression>;
|
|
88
|
+
export type MemberExpression = NodeWithStringType<TSESTree.MemberExpression>;
|
|
89
|
+
export type MetaProperty = NodeWithStringType<TSESTree.MetaProperty>;
|
|
90
|
+
export type MethodDefinition = NodeWithStringType<TSESTree.MethodDefinition>;
|
|
91
|
+
export type NewExpression = NodeWithStringType<TSESTree.NewExpression>;
|
|
92
|
+
export type ObjectExpression = NodeWithStringType<TSESTree.ObjectExpression>;
|
|
93
|
+
export type ObjectPattern = NodeWithStringType<TSESTree.ObjectPattern>;
|
|
94
|
+
export type PrivateIdentifier = NodeWithStringType<TSESTree.PrivateIdentifier>;
|
|
95
|
+
export type Program = NodeWithStringType<TSESTree.Program>;
|
|
96
|
+
export type Property = NodeWithStringType<TSESTree.Property>;
|
|
97
|
+
export type PropertyDefinition =
|
|
98
|
+
NodeWithStringType<TSESTree.PropertyDefinition>;
|
|
99
|
+
export type RestElement = NodeWithStringType<TSESTree.RestElement>;
|
|
100
|
+
export type ReturnStatement = NodeWithStringType<TSESTree.ReturnStatement>;
|
|
101
|
+
export type SequenceExpression =
|
|
102
|
+
NodeWithStringType<TSESTree.SequenceExpression>;
|
|
103
|
+
export type SpreadElement = NodeWithStringType<TSESTree.SpreadElement>;
|
|
104
|
+
export type StaticBlock = NodeWithStringType<TSESTree.StaticBlock>;
|
|
105
|
+
export type Super = NodeWithStringType<TSESTree.Super>;
|
|
106
|
+
export type SwitchCase = NodeWithStringType<TSESTree.SwitchCase>;
|
|
107
|
+
export type SwitchStatement = NodeWithStringType<TSESTree.SwitchStatement>;
|
|
108
|
+
export type TaggedTemplateExpression =
|
|
109
|
+
NodeWithStringType<TSESTree.TaggedTemplateExpression>;
|
|
110
|
+
export type TemplateElement = NodeWithStringType<TSESTree.TemplateElement>;
|
|
111
|
+
export type TemplateLiteral = NodeWithStringType<TSESTree.TemplateLiteral>;
|
|
112
|
+
export type ThisExpression = NodeWithStringType<TSESTree.ThisExpression>;
|
|
113
|
+
export type ThrowStatement = NodeWithStringType<TSESTree.ThrowStatement>;
|
|
114
|
+
export type TryStatement = NodeWithStringType<TSESTree.TryStatement>;
|
|
115
|
+
export type UnaryExpression = NodeWithStringType<TSESTree.UnaryExpression>;
|
|
116
|
+
export type UpdateExpression = NodeWithStringType<TSESTree.UpdateExpression>;
|
|
117
|
+
export type VariableDeclaration =
|
|
118
|
+
NodeWithStringType<TSESTree.VariableDeclaration>;
|
|
119
|
+
export type VariableDeclarator =
|
|
120
|
+
NodeWithStringType<TSESTree.VariableDeclarator>;
|
|
121
|
+
export type WhileStatement = NodeWithStringType<TSESTree.WhileStatement>;
|
|
122
|
+
export type WithStatement = NodeWithStringType<TSESTree.WithStatement>;
|
|
123
|
+
export type YieldExpression = NodeWithStringType<TSESTree.YieldExpression>;
|
|
124
|
+
|
|
125
|
+
// TypeScript-specific node types
|
|
126
|
+
export type TSAsExpression = NodeWithStringType<TSESTree.TSAsExpression>;
|
|
127
|
+
export type TSTypeAnnotation = NodeWithStringType<TSESTree.TSTypeAnnotation>;
|
|
128
|
+
export type TSTypeReference = NodeWithStringType<TSESTree.TSTypeReference>;
|
|
129
|
+
export type TSQualifiedName = NodeWithStringType<TSESTree.TSQualifiedName>;
|
|
130
|
+
export type TSInterfaceDeclaration =
|
|
131
|
+
NodeWithStringType<TSESTree.TSInterfaceDeclaration>;
|
|
132
|
+
export type TSTypeAliasDeclaration =
|
|
133
|
+
NodeWithStringType<TSESTree.TSTypeAliasDeclaration>;
|
|
134
|
+
export type TSEnumDeclaration = NodeWithStringType<TSESTree.TSEnumDeclaration>;
|
|
135
|
+
export type TSModuleDeclaration =
|
|
136
|
+
NodeWithStringType<TSESTree.TSModuleDeclaration>;
|
|
137
|
+
export type TSImportEqualsDeclaration =
|
|
138
|
+
NodeWithStringType<TSESTree.TSImportEqualsDeclaration>;
|
|
139
|
+
export type TSExportAssignment =
|
|
140
|
+
NodeWithStringType<TSESTree.TSExportAssignment>;
|
|
141
|
+
export type TSNamespaceExportDeclaration =
|
|
142
|
+
NodeWithStringType<TSESTree.TSNamespaceExportDeclaration>;
|
|
143
|
+
|
|
144
|
+
// Union type of all node types
|
|
145
|
+
export type Node =
|
|
146
|
+
| AccessorProperty
|
|
147
|
+
| ArrayExpression
|
|
148
|
+
| ArrayPattern
|
|
149
|
+
| ArrowFunctionExpression
|
|
150
|
+
| AssignmentExpression
|
|
151
|
+
| AssignmentPattern
|
|
152
|
+
| AwaitExpression
|
|
153
|
+
| BinaryExpression
|
|
154
|
+
| BlockStatement
|
|
155
|
+
| BreakStatement
|
|
156
|
+
| CallExpression
|
|
157
|
+
| CatchClause
|
|
158
|
+
| ChainExpression
|
|
159
|
+
| ClassBody
|
|
160
|
+
| ClassDeclaration
|
|
161
|
+
| ClassExpression
|
|
162
|
+
| ConditionalExpression
|
|
163
|
+
| ContinueStatement
|
|
164
|
+
| DebuggerStatement
|
|
165
|
+
| Decorator
|
|
166
|
+
| DoWhileStatement
|
|
167
|
+
| EmptyStatement
|
|
168
|
+
| ExportAllDeclaration
|
|
169
|
+
| ExportDefaultDeclaration
|
|
170
|
+
| ExportNamedDeclaration
|
|
171
|
+
| ExportSpecifier
|
|
172
|
+
| ExpressionStatement
|
|
173
|
+
| ForInStatement
|
|
174
|
+
| ForOfStatement
|
|
175
|
+
| ForStatement
|
|
176
|
+
| FunctionDeclaration
|
|
177
|
+
| FunctionExpression
|
|
178
|
+
| Identifier
|
|
179
|
+
| IfStatement
|
|
180
|
+
| ImportAttribute
|
|
181
|
+
| ImportDeclaration
|
|
182
|
+
| ImportDefaultSpecifier
|
|
183
|
+
| ImportExpression
|
|
184
|
+
| ImportNamespaceSpecifier
|
|
185
|
+
| ImportSpecifier
|
|
186
|
+
| JSXAttribute
|
|
187
|
+
| JSXClosingElement
|
|
188
|
+
| JSXClosingFragment
|
|
189
|
+
| JSXElement
|
|
190
|
+
| JSXEmptyExpression
|
|
191
|
+
| JSXExpressionContainer
|
|
192
|
+
| JSXFragment
|
|
193
|
+
| JSXIdentifier
|
|
194
|
+
| JSXMemberExpression
|
|
195
|
+
| JSXNamespacedName
|
|
196
|
+
| JSXOpeningElement
|
|
197
|
+
| JSXOpeningFragment
|
|
198
|
+
| JSXSpreadAttribute
|
|
199
|
+
| JSXSpreadChild
|
|
200
|
+
| JSXText
|
|
201
|
+
| LabeledStatement
|
|
202
|
+
| Literal
|
|
203
|
+
| LogicalExpression
|
|
204
|
+
| MemberExpression
|
|
205
|
+
| MetaProperty
|
|
206
|
+
| MethodDefinition
|
|
207
|
+
| NewExpression
|
|
208
|
+
| ObjectExpression
|
|
209
|
+
| ObjectPattern
|
|
210
|
+
| PrivateIdentifier
|
|
211
|
+
| Program
|
|
212
|
+
| Property
|
|
213
|
+
| PropertyDefinition
|
|
214
|
+
| RestElement
|
|
215
|
+
| ReturnStatement
|
|
216
|
+
| SequenceExpression
|
|
217
|
+
| SpreadElement
|
|
218
|
+
| StaticBlock
|
|
219
|
+
| Super
|
|
220
|
+
| SwitchCase
|
|
221
|
+
| SwitchStatement
|
|
222
|
+
| TaggedTemplateExpression
|
|
223
|
+
| TemplateElement
|
|
224
|
+
| TemplateLiteral
|
|
225
|
+
| ThisExpression
|
|
226
|
+
| ThrowStatement
|
|
227
|
+
| TryStatement
|
|
228
|
+
| UnaryExpression
|
|
229
|
+
| UpdateExpression
|
|
230
|
+
| VariableDeclaration
|
|
231
|
+
| VariableDeclarator
|
|
232
|
+
| WhileStatement
|
|
233
|
+
| WithStatement
|
|
234
|
+
| YieldExpression;
|
|
235
|
+
|
|
236
|
+
export type RuleFunction<T extends TSESTree.NodeOrTokenData = never> = (
|
|
237
|
+
node: T
|
|
238
|
+
) => void;
|
|
239
|
+
|
|
240
|
+
type RuleListenerExitSelectors = {
|
|
241
|
+
[K in keyof RuleListenerBaseSelectors as `${K}:exit`]: RuleListenerBaseSelectors[K];
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
interface RuleListenerBaseSelectors {
|
|
245
|
+
AccessorProperty?: RuleFunction<AccessorProperty>;
|
|
246
|
+
ArrayExpression?: RuleFunction<ArrayExpression>;
|
|
247
|
+
ArrayPattern?: RuleFunction<ArrayPattern>;
|
|
248
|
+
ArrowFunctionExpression?: RuleFunction<ArrowFunctionExpression>;
|
|
249
|
+
AssignmentExpression?: RuleFunction<AssignmentExpression>;
|
|
250
|
+
AssignmentPattern?: RuleFunction<AssignmentPattern>;
|
|
251
|
+
AwaitExpression?: RuleFunction<AwaitExpression>;
|
|
252
|
+
BinaryExpression?: RuleFunction<BinaryExpression>;
|
|
253
|
+
BlockStatement?: RuleFunction<BlockStatement>;
|
|
254
|
+
BreakStatement?: RuleFunction<BreakStatement>;
|
|
255
|
+
CallExpression?: RuleFunction<CallExpression>;
|
|
256
|
+
CatchClause?: RuleFunction<CatchClause>;
|
|
257
|
+
ChainExpression?: RuleFunction<ChainExpression>;
|
|
258
|
+
ClassBody?: RuleFunction<ClassBody>;
|
|
259
|
+
ClassDeclaration?: RuleFunction<ClassDeclaration>;
|
|
260
|
+
ClassExpression?: RuleFunction<ClassExpression>;
|
|
261
|
+
ConditionalExpression?: RuleFunction<ConditionalExpression>;
|
|
262
|
+
ContinueStatement?: RuleFunction<ContinueStatement>;
|
|
263
|
+
DebuggerStatement?: RuleFunction<DebuggerStatement>;
|
|
264
|
+
Decorator?: RuleFunction<Decorator>;
|
|
265
|
+
DoWhileStatement?: RuleFunction<DoWhileStatement>;
|
|
266
|
+
EmptyStatement?: RuleFunction<EmptyStatement>;
|
|
267
|
+
ExportAllDeclaration?: RuleFunction<ExportAllDeclaration>;
|
|
268
|
+
ExportDefaultDeclaration?: RuleFunction<ExportDefaultDeclaration>;
|
|
269
|
+
ExportNamedDeclaration?: RuleFunction<ExportNamedDeclaration>;
|
|
270
|
+
ExportSpecifier?: RuleFunction<ExportSpecifier>;
|
|
271
|
+
ExpressionStatement?: RuleFunction<ExpressionStatement>;
|
|
272
|
+
ForInStatement?: RuleFunction<ForInStatement>;
|
|
273
|
+
ForOfStatement?: RuleFunction<ForOfStatement>;
|
|
274
|
+
ForStatement?: RuleFunction<ForStatement>;
|
|
275
|
+
FunctionDeclaration?: RuleFunction<FunctionDeclaration>;
|
|
276
|
+
FunctionExpression?: RuleFunction<FunctionExpression>;
|
|
277
|
+
Identifier?: RuleFunction<Identifier>;
|
|
278
|
+
IfStatement?: RuleFunction<IfStatement>;
|
|
279
|
+
ImportAttribute?: RuleFunction<ImportAttribute>;
|
|
280
|
+
ImportDeclaration?: RuleFunction<ImportDeclaration>;
|
|
281
|
+
ImportDefaultSpecifier?: RuleFunction<ImportDefaultSpecifier>;
|
|
282
|
+
ImportExpression?: RuleFunction<ImportExpression>;
|
|
283
|
+
ImportNamespaceSpecifier?: RuleFunction<ImportNamespaceSpecifier>;
|
|
284
|
+
ImportSpecifier?: RuleFunction<ImportSpecifier>;
|
|
285
|
+
JSXAttribute?: RuleFunction<JSXAttribute>;
|
|
286
|
+
JSXClosingElement?: RuleFunction<JSXClosingElement>;
|
|
287
|
+
JSXClosingFragment?: RuleFunction<JSXClosingFragment>;
|
|
288
|
+
JSXElement?: RuleFunction<JSXElement>;
|
|
289
|
+
JSXEmptyExpression?: RuleFunction<JSXEmptyExpression>;
|
|
290
|
+
JSXExpressionContainer?: RuleFunction<JSXExpressionContainer>;
|
|
291
|
+
JSXFragment?: RuleFunction<JSXFragment>;
|
|
292
|
+
JSXIdentifier?: RuleFunction<JSXIdentifier>;
|
|
293
|
+
JSXMemberExpression?: RuleFunction<JSXMemberExpression>;
|
|
294
|
+
JSXNamespacedName?: RuleFunction<JSXNamespacedName>;
|
|
295
|
+
JSXOpeningElement?: RuleFunction<JSXOpeningElement>;
|
|
296
|
+
JSXOpeningFragment?: RuleFunction<JSXOpeningFragment>;
|
|
297
|
+
JSXSpreadAttribute?: RuleFunction<JSXSpreadAttribute>;
|
|
298
|
+
JSXSpreadChild?: RuleFunction<JSXSpreadChild>;
|
|
299
|
+
JSXText?: RuleFunction<JSXText>;
|
|
300
|
+
LabeledStatement?: RuleFunction<LabeledStatement>;
|
|
301
|
+
Literal?: RuleFunction<Literal>;
|
|
302
|
+
LogicalExpression?: RuleFunction<LogicalExpression>;
|
|
303
|
+
MemberExpression?: RuleFunction<MemberExpression>;
|
|
304
|
+
MetaProperty?: RuleFunction<MetaProperty>;
|
|
305
|
+
MethodDefinition?: RuleFunction<MethodDefinition>;
|
|
306
|
+
NewExpression?: RuleFunction<NewExpression>;
|
|
307
|
+
ObjectExpression?: RuleFunction<ObjectExpression>;
|
|
308
|
+
ObjectPattern?: RuleFunction<ObjectPattern>;
|
|
309
|
+
PrivateIdentifier?: RuleFunction<PrivateIdentifier>;
|
|
310
|
+
Program?: RuleFunction<Program>;
|
|
311
|
+
Property?: RuleFunction<Property>;
|
|
312
|
+
PropertyDefinition?: RuleFunction<PropertyDefinition>;
|
|
313
|
+
RestElement?: RuleFunction<RestElement>;
|
|
314
|
+
ReturnStatement?: RuleFunction<ReturnStatement>;
|
|
315
|
+
SequenceExpression?: RuleFunction<SequenceExpression>;
|
|
316
|
+
SpreadElement?: RuleFunction<SpreadElement>;
|
|
317
|
+
StaticBlock?: RuleFunction<StaticBlock>;
|
|
318
|
+
Super?: RuleFunction<Super>;
|
|
319
|
+
SwitchCase?: RuleFunction<SwitchCase>;
|
|
320
|
+
SwitchStatement?: RuleFunction<SwitchStatement>;
|
|
321
|
+
TaggedTemplateExpression?: RuleFunction<TaggedTemplateExpression>;
|
|
322
|
+
TemplateElement?: RuleFunction<TemplateElement>;
|
|
323
|
+
TemplateLiteral?: RuleFunction<TemplateLiteral>;
|
|
324
|
+
ThisExpression?: RuleFunction<ThisExpression>;
|
|
325
|
+
ThrowStatement?: RuleFunction<ThrowStatement>;
|
|
326
|
+
TryStatement?: RuleFunction<TryStatement>;
|
|
327
|
+
UnaryExpression?: RuleFunction<UnaryExpression>;
|
|
328
|
+
UpdateExpression?: RuleFunction<UpdateExpression>;
|
|
329
|
+
VariableDeclaration?: RuleFunction<VariableDeclaration>;
|
|
330
|
+
VariableDeclarator?: RuleFunction<VariableDeclarator>;
|
|
331
|
+
WhileStatement?: RuleFunction<WhileStatement>;
|
|
332
|
+
WithStatement?: RuleFunction<WithStatement>;
|
|
333
|
+
YieldExpression?: RuleFunction<YieldExpression>;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export type RuleListener = RuleListenerBaseSelectors &
|
|
337
|
+
RuleListenerExitSelectors;
|
|
338
|
+
|
|
339
|
+
interface RuleFix {
|
|
340
|
+
range: eslint.AST.Range;
|
|
341
|
+
text: string;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export interface RuleFixer {
|
|
345
|
+
insertTextAfter(nodeOrToken: TSESTree.BaseNode, text: string): RuleFix;
|
|
346
|
+
|
|
347
|
+
insertTextAfterRange(range: eslint.AST.Range, text: string): RuleFix;
|
|
348
|
+
|
|
349
|
+
insertTextBefore(nodeOrToken: TSESTree.BaseNode, text: string): RuleFix;
|
|
350
|
+
|
|
351
|
+
insertTextBeforeRange(range: eslint.AST.Range, text: string): RuleFix;
|
|
352
|
+
|
|
353
|
+
remove(nodeOrToken: TSESTree.BaseNode): RuleFix;
|
|
354
|
+
|
|
355
|
+
removeRange(range: eslint.AST.Range): RuleFix;
|
|
356
|
+
|
|
357
|
+
replaceText(nodeOrToken: TSESTree.BaseNode, text: string): RuleFix;
|
|
358
|
+
|
|
359
|
+
replaceTextRange(range: eslint.AST.Range, text: string): RuleFix;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
export type ReportFixFunction = (
|
|
363
|
+
fixer: RuleFixer
|
|
364
|
+
) => IterableIterator<RuleFix> | readonly RuleFix[] | RuleFix | null;
|
|
365
|
+
|
|
366
|
+
interface ReportDescriptorOptionsBase {
|
|
367
|
+
data?: { [key: string]: string };
|
|
368
|
+
fix?: null | ReportFixFunction;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
type SuggestionDescriptorMessage = { messageId: string };
|
|
372
|
+
export type SuggestionReportDescriptor = SuggestionDescriptorMessage &
|
|
373
|
+
ReportDescriptorOptionsBase;
|
|
374
|
+
|
|
375
|
+
interface ReportDescriptorOptions extends ReportDescriptorOptionsBase {
|
|
376
|
+
suggest?: SuggestionReportDescriptor[] | null;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
type ReportDescriptor = ReportDescriptorMessage &
|
|
380
|
+
ReportDescriptorLocation &
|
|
381
|
+
ReportDescriptorOptions;
|
|
382
|
+
type ReportDescriptorMessage = { message: string } | { messageId: string };
|
|
383
|
+
type ReportDescriptorLocation = {
|
|
384
|
+
node?: Node;
|
|
385
|
+
loc?: eslint.AST.SourceLocation;
|
|
386
|
+
line?: number;
|
|
387
|
+
column?: number;
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
export interface Context<Options extends unknown[]> extends Omit<
|
|
391
|
+
eslint.Rule.RuleContext,
|
|
392
|
+
"report"
|
|
393
|
+
> {
|
|
394
|
+
report(descriptor: ReportDescriptor): void;
|
|
395
|
+
options: Options;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
export interface RuleModule<Options extends unknown[]> {
|
|
399
|
+
create(context: Context<Options>): RuleListener;
|
|
400
|
+
meta: eslint.Rule.RuleMetaData;
|
|
401
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@html-eslint/eslint-plugin-react",
|
|
3
|
+
"version": "0.56.0",
|
|
4
|
+
"type": "commonjs",
|
|
5
|
+
"description": "ESLint plugin for HTML with React support",
|
|
6
|
+
"author": "yeonjuan",
|
|
7
|
+
"homepage": "https://github.com/yeonjuan/html-eslint#readme",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"main": "lib/index.js",
|
|
10
|
+
"types": "types/index.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"lib",
|
|
13
|
+
"types"
|
|
14
|
+
],
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/yeonjuan/html-eslint.git"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"test": "jest --coverage",
|
|
24
|
+
"ts": "tsc --noEmit",
|
|
25
|
+
"lint": "eslint .",
|
|
26
|
+
"build": "rimraf types && tsc --project tsconfig.build.json"
|
|
27
|
+
},
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/yeonjuan/html-eslint/issues"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"eslint",
|
|
33
|
+
"eslintplugin",
|
|
34
|
+
"eslint-plugin",
|
|
35
|
+
"html",
|
|
36
|
+
"react",
|
|
37
|
+
"lint"
|
|
38
|
+
],
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@html-eslint/core": "^0.56.0",
|
|
41
|
+
"@html-eslint/eslint-plugin": "^0.56.0",
|
|
42
|
+
"@html-eslint/types": "^0.56.0",
|
|
43
|
+
"@typescript-eslint/types": "^8.56.0"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"eslint": ">=8.0.0 || ^10.0.0-0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"typescript": "^5.9.3"
|
|
50
|
+
},
|
|
51
|
+
"engines": {
|
|
52
|
+
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
|
53
|
+
},
|
|
54
|
+
"gitHead": "cece9315a6d09aff6e1af21091309df7152cb964"
|
|
55
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/configs/index.js"],"names":[],"mappings":"AAGA,wDAMyD"}
|