eslint-plugin-react-features 1.1.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.
Files changed (114) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/LICENSE +23 -0
  3. package/README.md +155 -0
  4. package/package.json +65 -0
  5. package/src/index.d.ts +1093 -0
  6. package/src/index.js +212 -0
  7. package/src/rules/migration/react-class-to-hooks.d.ts +22 -0
  8. package/src/rules/migration/react-class-to-hooks.js +178 -0
  9. package/src/rules/performance/no-unnecessary-rerenders.d.ts +26 -0
  10. package/src/rules/performance/no-unnecessary-rerenders.js +212 -0
  11. package/src/rules/performance/react-no-inline-functions.d.ts +24 -0
  12. package/src/rules/performance/react-no-inline-functions.js +211 -0
  13. package/src/rules/performance/react-render-optimization.d.ts +31 -0
  14. package/src/rules/performance/react-render-optimization.js +294 -0
  15. package/src/rules/react/checked-requires-onchange-or-readonly.d.ts +16 -0
  16. package/src/rules/react/checked-requires-onchange-or-readonly.js +74 -0
  17. package/src/rules/react/default-props-match-prop-types.d.ts +13 -0
  18. package/src/rules/react/default-props-match-prop-types.js +119 -0
  19. package/src/rules/react/display-name.d.ts +13 -0
  20. package/src/rules/react/display-name.js +164 -0
  21. package/src/rules/react/hooks-exhaustive-deps.d.ts +25 -0
  22. package/src/rules/react/hooks-exhaustive-deps.js +466 -0
  23. package/src/rules/react/jsx-handler-names.d.ts +13 -0
  24. package/src/rules/react/jsx-handler-names.js +57 -0
  25. package/src/rules/react/jsx-key.d.ts +20 -0
  26. package/src/rules/react/jsx-key.js +421 -0
  27. package/src/rules/react/jsx-max-depth.d.ts +19 -0
  28. package/src/rules/react/jsx-max-depth.js +80 -0
  29. package/src/rules/react/jsx-no-bind.d.ts +13 -0
  30. package/src/rules/react/jsx-no-bind.js +64 -0
  31. package/src/rules/react/jsx-no-duplicate-props.d.ts +21 -0
  32. package/src/rules/react/jsx-no-duplicate-props.js +70 -0
  33. package/src/rules/react/jsx-no-literals.d.ts +20 -0
  34. package/src/rules/react/jsx-no-literals.js +83 -0
  35. package/src/rules/react/jsx-no-script-url.d.ts +25 -0
  36. package/src/rules/react/jsx-no-script-url.js +131 -0
  37. package/src/rules/react/jsx-no-target-blank.d.ts +26 -0
  38. package/src/rules/react/jsx-no-target-blank.js +176 -0
  39. package/src/rules/react/no-access-state-in-setstate.d.ts +13 -0
  40. package/src/rules/react/no-access-state-in-setstate.js +92 -0
  41. package/src/rules/react/no-adjacent-inline-elements.d.ts +13 -0
  42. package/src/rules/react/no-adjacent-inline-elements.js +81 -0
  43. package/src/rules/react/no-arrow-function-lifecycle.d.ts +13 -0
  44. package/src/rules/react/no-arrow-function-lifecycle.js +63 -0
  45. package/src/rules/react/no-children-prop.d.ts +13 -0
  46. package/src/rules/react/no-children-prop.js +60 -0
  47. package/src/rules/react/no-danger-with-children.d.ts +16 -0
  48. package/src/rules/react/no-danger-with-children.js +110 -0
  49. package/src/rules/react/no-danger.d.ts +13 -0
  50. package/src/rules/react/no-danger.js +45 -0
  51. package/src/rules/react/no-deprecated.d.ts +16 -0
  52. package/src/rules/react/no-deprecated.js +140 -0
  53. package/src/rules/react/no-did-mount-set-state.d.ts +13 -0
  54. package/src/rules/react/no-did-mount-set-state.js +55 -0
  55. package/src/rules/react/no-did-update-set-state.d.ts +19 -0
  56. package/src/rules/react/no-did-update-set-state.js +80 -0
  57. package/src/rules/react/no-direct-mutation-state.d.ts +20 -0
  58. package/src/rules/react/no-direct-mutation-state.js +277 -0
  59. package/src/rules/react/no-find-dom-node.d.ts +15 -0
  60. package/src/rules/react/no-find-dom-node.js +56 -0
  61. package/src/rules/react/no-invalid-html-attribute.d.ts +13 -0
  62. package/src/rules/react/no-invalid-html-attribute.js +84 -0
  63. package/src/rules/react/no-is-mounted.d.ts +13 -0
  64. package/src/rules/react/no-is-mounted.js +52 -0
  65. package/src/rules/react/no-multi-comp.d.ts +18 -0
  66. package/src/rules/react/no-multi-comp.js +160 -0
  67. package/src/rules/react/no-namespace.d.ts +13 -0
  68. package/src/rules/react/no-namespace.js +41 -0
  69. package/src/rules/react/no-object-type-as-default-prop.d.ts +13 -0
  70. package/src/rules/react/no-object-type-as-default-prop.js +61 -0
  71. package/src/rules/react/no-redundant-should-component-update.d.ts +13 -0
  72. package/src/rules/react/no-redundant-should-component-update.js +55 -0
  73. package/src/rules/react/no-render-return-value.d.ts +13 -0
  74. package/src/rules/react/no-render-return-value.js +74 -0
  75. package/src/rules/react/no-set-state.d.ts +13 -0
  76. package/src/rules/react/no-set-state.js +50 -0
  77. package/src/rules/react/no-string-refs.d.ts +13 -0
  78. package/src/rules/react/no-string-refs.js +68 -0
  79. package/src/rules/react/no-this-in-sfc.d.ts +13 -0
  80. package/src/rules/react/no-this-in-sfc.js +65 -0
  81. package/src/rules/react/no-typos.d.ts +13 -0
  82. package/src/rules/react/no-typos.js +97 -0
  83. package/src/rules/react/no-unescaped-entities.d.ts +13 -0
  84. package/src/rules/react/no-unescaped-entities.js +50 -0
  85. package/src/rules/react/no-unknown-property.d.ts +13 -0
  86. package/src/rules/react/no-unknown-property.js +130 -0
  87. package/src/rules/react/no-unsafe.d.ts +20 -0
  88. package/src/rules/react/no-unsafe.js +112 -0
  89. package/src/rules/react/prefer-es6-class.d.ts +13 -0
  90. package/src/rules/react/prefer-es6-class.js +56 -0
  91. package/src/rules/react/prefer-stateless-function.d.ts +16 -0
  92. package/src/rules/react/prefer-stateless-function.js +134 -0
  93. package/src/rules/react/prop-types.d.ts +18 -0
  94. package/src/rules/react/prop-types.js +153 -0
  95. package/src/rules/react/react-in-jsx-scope.d.ts +13 -0
  96. package/src/rules/react/react-in-jsx-scope.js +94 -0
  97. package/src/rules/react/require-default-props.d.ts +16 -0
  98. package/src/rules/react/require-default-props.js +146 -0
  99. package/src/rules/react/require-optimization.d.ts +26 -0
  100. package/src/rules/react/require-optimization.js +436 -0
  101. package/src/rules/react/require-render-return.d.ts +13 -0
  102. package/src/rules/react/require-render-return.js +87 -0
  103. package/src/rules/react/required-attributes.d.ts +28 -0
  104. package/src/rules/react/required-attributes.js +212 -0
  105. package/src/rules/react/sort-comp.d.ts +17 -0
  106. package/src/rules/react/sort-comp.js +160 -0
  107. package/src/rules/react/state-in-constructor.d.ts +13 -0
  108. package/src/rules/react/state-in-constructor.js +103 -0
  109. package/src/rules/react/static-property-placement.d.ts +20 -0
  110. package/src/rules/react/static-property-placement.js +166 -0
  111. package/src/rules/react/void-dom-elements-no-children.d.ts +15 -0
  112. package/src/rules/react/void-dom-elements-no-children.js +94 -0
  113. package/src/types/index.d.ts +54 -0
  114. package/src/types/index.js +7 -0
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2025 Ofri Peretz
4
+ * Licensed under the MIT License. Use of this source code is governed by the
5
+ * MIT license that can be found in the LICENSE file.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.noDidUpdateSetState = void 0;
9
+ const eslint_devkit_1 = require("@interlace/eslint-devkit");
10
+ const eslint_devkit_2 = require("@interlace/eslint-devkit");
11
+ exports.noDidUpdateSetState = (0, eslint_devkit_1.createRule)({
12
+ name: 'no-did-update-set-state',
13
+ meta: {
14
+ type: 'problem',
15
+ docs: {
16
+ description: 'Prevent setState in componentDidUpdate',
17
+ },
18
+ messages: {
19
+ noDidUpdateSetState: (0, eslint_devkit_2.formatLLMMessage)({
20
+ icon: eslint_devkit_2.MessageIcons.WARNING,
21
+ issueName: 'setState in componentDidUpdate',
22
+ description: 'setState called in componentDidUpdate without condition',
23
+ severity: 'HIGH',
24
+ fix: 'Add condition to prevent infinite re-render loop',
25
+ documentationLink: 'https://react.dev/reference/react/Component#componentdidupdate',
26
+ }),
27
+ },
28
+ schema: [
29
+ {
30
+ type: 'object',
31
+ properties: {
32
+ allowInCallback: {
33
+ type: 'boolean',
34
+ default: false,
35
+ },
36
+ },
37
+ additionalProperties: false,
38
+ },
39
+ ],
40
+ },
41
+ defaultOptions: [{ allowInCallback: false }],
42
+ create(context) {
43
+ const [options] = context.options;
44
+ let inComponentDidUpdate = false;
45
+ let hasConditionalCheck = false;
46
+ return {
47
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
48
+ 'MethodDefinition[key.name="componentDidUpdate"]'(node) {
49
+ inComponentDidUpdate = true;
50
+ hasConditionalCheck = false;
51
+ },
52
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
53
+ 'MethodDefinition[key.name="componentDidUpdate"]:exit'(node) {
54
+ inComponentDidUpdate = false;
55
+ },
56
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
57
+ IfStatement(node) {
58
+ if (inComponentDidUpdate) {
59
+ hasConditionalCheck = true;
60
+ }
61
+ },
62
+ CallExpression(node) {
63
+ if (!inComponentDidUpdate)
64
+ return;
65
+ // Check if this is a setState call
66
+ if (node.callee.type === 'MemberExpression' &&
67
+ node.callee.property.type === 'Identifier' &&
68
+ node.callee.property.name === 'setState') {
69
+ // Allow if there's a conditional check or callback is allowed
70
+ if (!hasConditionalCheck && !options?.allowInCallback) {
71
+ context.report({
72
+ node: node.callee.property,
73
+ messageId: 'noDidUpdateSetState',
74
+ });
75
+ }
76
+ }
77
+ },
78
+ };
79
+ },
80
+ });
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) 2025 Ofri Peretz
3
+ * Licensed under the MIT License. Use of this source code is governed by the
4
+ * MIT license that can be found in the LICENSE file.
5
+ */
6
+ /**
7
+ * ESLint Rule: no-direct-mutation-state
8
+ * Prevent direct mutation of this.state (requires deep React state understanding)
9
+ */
10
+ import type { TSESLint } from '@interlace/eslint-devkit';
11
+ type MessageIds = 'noDirectMutationState' | 'suggestSetState' | 'suggestFunctionalUpdate';
12
+ export interface Options {
13
+ /** Allow mutations in lifecycle methods */
14
+ allowInLifecycleMethods?: boolean;
15
+ }
16
+ type RuleOptions = [Options?];
17
+ export declare const noDirectMutationState: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
18
+ name: string;
19
+ };
20
+ export {};
@@ -0,0 +1,277 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2025 Ofri Peretz
4
+ * Licensed under the MIT License. Use of this source code is governed by the
5
+ * MIT license that can be found in the LICENSE file.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.noDirectMutationState = void 0;
9
+ const eslint_devkit_1 = require("@interlace/eslint-devkit");
10
+ const eslint_devkit_2 = require("@interlace/eslint-devkit");
11
+ exports.noDirectMutationState = (0, eslint_devkit_1.createRule)({
12
+ name: 'no-direct-mutation-state',
13
+ meta: {
14
+ type: 'problem',
15
+ docs: {
16
+ description: 'Prevent direct mutation of this.state that breaks React reconciliation',
17
+ },
18
+ hasSuggestions: true,
19
+ messages: {
20
+ noDirectMutationState: (0, eslint_devkit_2.formatLLMMessage)({
21
+ icon: eslint_devkit_2.MessageIcons.WARNING,
22
+ issueName: 'Direct State Mutation',
23
+ description: 'Never mutate this.state directly',
24
+ severity: 'HIGH',
25
+ fix: 'Use setState() or functional updates for immutable state changes',
26
+ documentationLink: 'https://react.dev/learn/state-and-lifecycle#state-updates-may-be-asynchronous',
27
+ }),
28
+ suggestSetState: (0, eslint_devkit_2.formatLLMMessage)({
29
+ icon: eslint_devkit_2.MessageIcons.WARNING,
30
+ issueName: 'State Update',
31
+ description: 'Use setState with object for state updates',
32
+ severity: 'MEDIUM',
33
+ fix: 'Use this.setState({ count: this.state.count + 1 })',
34
+ documentationLink: 'https://react.dev/reference/react/Component#setstate',
35
+ }),
36
+ suggestFunctionalUpdate: (0, eslint_devkit_2.formatLLMMessage)({
37
+ icon: eslint_devkit_2.MessageIcons.WARNING,
38
+ issueName: 'Functional State Update',
39
+ description: 'Use functional setState for immutable updates',
40
+ severity: 'MEDIUM',
41
+ fix: 'Use this.setState(prevState => ({ count: prevState.count + 1 }))',
42
+ documentationLink: 'https://react.dev/reference/react/Component#setstate',
43
+ }),
44
+ },
45
+ schema: [
46
+ {
47
+ type: 'object',
48
+ properties: {
49
+ allowInLifecycleMethods: {
50
+ type: 'boolean',
51
+ default: false,
52
+ },
53
+ },
54
+ additionalProperties: false,
55
+ },
56
+ ],
57
+ },
58
+ defaultOptions: [{ allowInLifecycleMethods: false }],
59
+ create(context) {
60
+ const [options] = context.options;
61
+ const { allowInLifecycleMethods = false } = options || {};
62
+ // Track if we're in a class component
63
+ let inClassComponent = false;
64
+ let inLifecycleMethod = false;
65
+ const classStack = [];
66
+ function isLifecycleMethod(methodName) {
67
+ const lifecycleMethods = [
68
+ 'componentDidMount',
69
+ 'componentDidUpdate',
70
+ 'componentWillUnmount',
71
+ 'componentWillMount',
72
+ 'componentWillReceiveProps',
73
+ 'componentWillUpdate',
74
+ 'shouldComponentUpdate',
75
+ 'getSnapshotBeforeUpdate',
76
+ 'getDerivedStateFromProps',
77
+ 'getDerivedStateFromError',
78
+ 'componentDidCatch',
79
+ ];
80
+ return lifecycleMethods.includes(methodName);
81
+ }
82
+ function isInReactClassComponent() {
83
+ // Simple heuristic: check if we're in a class that extends Component
84
+ // In a real implementation, this would be more sophisticated
85
+ return inClassComponent;
86
+ }
87
+ function reportStateMutation(node, mutationType) {
88
+ if (!isInReactClassComponent()) {
89
+ return; // Only applies to class components
90
+ }
91
+ if (allowInLifecycleMethods && inLifecycleMethod) {
92
+ return; // Allowed in lifecycle methods if configured
93
+ }
94
+ context.report({
95
+ node,
96
+ messageId: 'noDirectMutationState',
97
+ data: {
98
+ mutationType,
99
+ context: inLifecycleMethod ? 'lifecycle method' : 'regular method',
100
+ },
101
+ suggest: [
102
+ {
103
+ messageId: 'suggestSetState',
104
+ fix(fixer) {
105
+ // Get the source code to determine indentation
106
+ const sourceCode = context.getSourceCode();
107
+ const start = node.range[0];
108
+ const lineStart = sourceCode.getIndexFromLoc({
109
+ line: sourceCode.getLocFromIndex(start).line,
110
+ column: 0
111
+ });
112
+ const lineText = sourceCode.getText().slice(lineStart, start);
113
+ const indentMatch = lineText.match(/^(\s*)/);
114
+ const indent = indentMatch ? indentMatch[1] : '';
115
+ return fixer.insertTextBefore(node, `// TODO: Use setState instead of direct mutation\n${indent}`);
116
+ },
117
+ },
118
+ {
119
+ messageId: 'suggestFunctionalUpdate',
120
+ fix(fixer) {
121
+ // Get the source code to determine indentation
122
+ const sourceCode = context.getSourceCode();
123
+ const start = node.range[0];
124
+ const lineStart = sourceCode.getIndexFromLoc({
125
+ line: sourceCode.getLocFromIndex(start).line,
126
+ column: 0
127
+ });
128
+ const lineText = sourceCode.getText().slice(lineStart, start);
129
+ const indentMatch = lineText.match(/^(\s*)/);
130
+ const indent = indentMatch ? indentMatch[1] : '';
131
+ return fixer.insertTextBefore(node, `// TODO: Use functional setState for immutable updates\n${indent}`);
132
+ },
133
+ },
134
+ ],
135
+ });
136
+ }
137
+ return {
138
+ ClassDeclaration(node) {
139
+ // Check if this is a React component class
140
+ if (node.superClass) {
141
+ if (node.superClass.type === 'Identifier' &&
142
+ ['Component', 'PureComponent'].includes(node.superClass.name)) {
143
+ inClassComponent = true;
144
+ classStack.push(true);
145
+ }
146
+ else if (node.superClass.type === 'MemberExpression' &&
147
+ node.superClass.object.type === 'Identifier' &&
148
+ node.superClass.object.name === 'React' &&
149
+ node.superClass.property.type === 'Identifier' &&
150
+ ['Component', 'PureComponent'].includes(node.superClass.property.name)) {
151
+ inClassComponent = true;
152
+ classStack.push(true);
153
+ }
154
+ }
155
+ },
156
+ 'ClassDeclaration:exit'() {
157
+ classStack.pop();
158
+ inClassComponent = classStack.length > 0 && classStack[classStack.length - 1];
159
+ },
160
+ MethodDefinition(node) {
161
+ if (node.key.type === 'Identifier') {
162
+ inLifecycleMethod = isLifecycleMethod(node.key.name);
163
+ }
164
+ },
165
+ 'MethodDefinition:exit'() {
166
+ inLifecycleMethod = false;
167
+ },
168
+ // Assignment to this.state properties
169
+ AssignmentExpression(node) {
170
+ if (node.left.type === 'MemberExpression') {
171
+ // Check if this is assignment to this.state.xxx (but not this.state itself)
172
+ function isStatePropertyAccess(node) {
173
+ if (node.type === 'MemberExpression' &&
174
+ node.object.type === 'MemberExpression' &&
175
+ node.object.object.type === 'ThisExpression' &&
176
+ node.object.property.type === 'Identifier' &&
177
+ node.object.property.name === 'state') {
178
+ return true; // this.state.xxx
179
+ }
180
+ // Handle deeper nesting
181
+ if (node.type === 'MemberExpression') {
182
+ return isStatePropertyAccess(node.object);
183
+ }
184
+ return false;
185
+ }
186
+ if (isStatePropertyAccess(node.left)) {
187
+ reportStateMutation(node, 'assignment');
188
+ }
189
+ }
190
+ },
191
+ // Update expressions on this.state properties (++state.count, state.count--)
192
+ UpdateExpression(node) {
193
+ if (node.argument.type === 'MemberExpression') {
194
+ // Check if this is update on this.state.xxx
195
+ function isStatePropertyAccess(node) {
196
+ if (node.type === 'MemberExpression' &&
197
+ node.object.type === 'MemberExpression' &&
198
+ node.object.object.type === 'ThisExpression' &&
199
+ node.object.property.type === 'Identifier' &&
200
+ node.object.property.name === 'state') {
201
+ return true; // this.state.xxx
202
+ }
203
+ // Handle deeper nesting
204
+ if (node.type === 'MemberExpression') {
205
+ return isStatePropertyAccess(node.object);
206
+ }
207
+ return false;
208
+ }
209
+ if (isStatePropertyAccess(node.argument)) {
210
+ reportStateMutation(node, 'update');
211
+ }
212
+ }
213
+ },
214
+ // Delete operator on this.state properties
215
+ UnaryExpression(node) {
216
+ if (node.operator === 'delete' && node.argument.type === 'MemberExpression') {
217
+ // Check if this is delete on this.state.xxx
218
+ function isStatePropertyAccess(node) {
219
+ if (node.type === 'MemberExpression' &&
220
+ node.object.type === 'MemberExpression' &&
221
+ node.object.object.type === 'ThisExpression' &&
222
+ node.object.property.type === 'Identifier' &&
223
+ node.object.property.name === 'state') {
224
+ return true; // this.state.xxx
225
+ }
226
+ // Handle deeper nesting
227
+ if (node.type === 'MemberExpression') {
228
+ return isStatePropertyAccess(node.object);
229
+ }
230
+ return false;
231
+ }
232
+ if (isStatePropertyAccess(node.argument)) {
233
+ reportStateMutation(node, 'delete operator');
234
+ }
235
+ }
236
+ },
237
+ // Array/object methods that mutate this.state
238
+ CallExpression(node) {
239
+ if (node.callee.type === 'MemberExpression' &&
240
+ node.callee.property.type === 'Identifier') {
241
+ const methodName = node.callee.property.name;
242
+ // Check if this is a call on this.state.xxx
243
+ function isStatePropertyAccess(node) {
244
+ if (node.type === 'MemberExpression' &&
245
+ node.object.type === 'MemberExpression' &&
246
+ node.object.object.type === 'ThisExpression' &&
247
+ node.object.property.type === 'Identifier' &&
248
+ node.object.property.name === 'state') {
249
+ return true; // this.state.xxx
250
+ }
251
+ // Handle deeper nesting
252
+ if (node.type === 'MemberExpression') {
253
+ return isStatePropertyAccess(node.object);
254
+ }
255
+ // Handle logical expressions like (this.state.items || [])
256
+ if (node.type === 'LogicalExpression') {
257
+ return isStatePropertyAccess(node.left);
258
+ }
259
+ return false;
260
+ }
261
+ if (isStatePropertyAccess(node.callee.object)) {
262
+ // Methods that mutate arrays/objects
263
+ const mutatingMethods = [
264
+ 'push', 'pop', 'shift', 'unshift', 'splice', 'sort', 'reverse',
265
+ 'copyWithin', 'fill',
266
+ // Object methods
267
+ 'defineProperty', 'deleteProperty', 'setPrototypeOf',
268
+ ];
269
+ if (mutatingMethods.includes(methodName)) {
270
+ reportStateMutation(node, `mutating method (${methodName})`);
271
+ }
272
+ }
273
+ }
274
+ },
275
+ };
276
+ },
277
+ });
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Copyright (c) 2025 Ofri Peretz
3
+ * Licensed under the MIT License. Use of this source code is governed by the
4
+ * MIT license that can be found in the LICENSE file.
5
+ */
6
+ /**
7
+ * ESLint Rule: no-find-dom-node
8
+ * Prevent using findDOMNode (deprecated since React 16.3)
9
+ *
10
+ * @see https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-find-dom-node.md
11
+ */
12
+ import type { TSESLint } from '@interlace/eslint-devkit';
13
+ export declare const noFindDomNode: TSESLint.RuleModule<"noFindDOMNode", [], unknown, TSESLint.RuleListener> & {
14
+ name: string;
15
+ };
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2025 Ofri Peretz
4
+ * Licensed under the MIT License. Use of this source code is governed by the
5
+ * MIT license that can be found in the LICENSE file.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.noFindDomNode = void 0;
9
+ const eslint_devkit_1 = require("@interlace/eslint-devkit");
10
+ const eslint_devkit_2 = require("@interlace/eslint-devkit");
11
+ exports.noFindDomNode = (0, eslint_devkit_2.createRule)({
12
+ name: 'no-find-dom-node',
13
+ meta: {
14
+ type: 'problem',
15
+ docs: {
16
+ description: 'Prevent using findDOMNode',
17
+ },
18
+ messages: {
19
+ noFindDOMNode: (0, eslint_devkit_1.formatLLMMessage)({
20
+ icon: eslint_devkit_1.MessageIcons.DEPRECATION,
21
+ issueName: 'Deprecated findDOMNode',
22
+ description: 'findDOMNode is deprecated since React 16.3 and removed in React 19',
23
+ severity: 'HIGH',
24
+ fix: 'Use refs instead: const ref = useRef(); return <div ref={ref} />',
25
+ documentationLink: 'https://react.dev/reference/react-dom/findDOMNode',
26
+ }),
27
+ },
28
+ schema: [],
29
+ },
30
+ defaultOptions: [],
31
+ create(context) {
32
+ return {
33
+ CallExpression(node) {
34
+ // Check for ReactDOM.findDOMNode()
35
+ if (node.callee.type === 'MemberExpression' &&
36
+ node.callee.object.type === 'Identifier' &&
37
+ node.callee.object.name === 'ReactDOM' &&
38
+ node.callee.property.type === 'Identifier' &&
39
+ node.callee.property.name === 'findDOMNode') {
40
+ context.report({
41
+ node,
42
+ messageId: 'noFindDOMNode',
43
+ });
44
+ }
45
+ // Check for findDOMNode() imported directly
46
+ if (node.callee.type === 'Identifier' &&
47
+ node.callee.name === 'findDOMNode') {
48
+ context.report({
49
+ node,
50
+ messageId: 'noFindDOMNode',
51
+ });
52
+ }
53
+ },
54
+ };
55
+ },
56
+ });
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Copyright (c) 2025 Ofri Peretz
3
+ * Licensed under the MIT License. Use of this source code is governed by the
4
+ * MIT license that can be found in the LICENSE file.
5
+ */
6
+ /**
7
+ * ESLint Rule: no-invalid-html-attribute
8
+ * Prevent invalid HTML attributes
9
+ */
10
+ import type { TSESLint } from '@interlace/eslint-devkit';
11
+ export declare const noInvalidHtmlAttribute: TSESLint.RuleModule<"noInvalidHtmlAttribute", [], unknown, TSESLint.RuleListener> & {
12
+ name: string;
13
+ };
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2025 Ofri Peretz
4
+ * Licensed under the MIT License. Use of this source code is governed by the
5
+ * MIT license that can be found in the LICENSE file.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.noInvalidHtmlAttribute = void 0;
9
+ const eslint_devkit_1 = require("@interlace/eslint-devkit");
10
+ const eslint_devkit_2 = require("@interlace/eslint-devkit");
11
+ const INVALID_HTML_ATTRIBUTES = new Set([
12
+ 'accept-charset', // Should be acceptCharset
13
+ 'accesskey', // Should be accessKey
14
+ 'allowfullscreen', // Should be allowFullScreen
15
+ 'allowtransparency', // Should be allowTransparency (deprecated)
16
+ 'bgcolor', // Should be backgroundColor
17
+ 'cellpadding', // Should be cellPadding
18
+ 'cellspacing', // Should be cellSpacing
19
+ 'charset', // Should be charSet
20
+ 'class', // Should be className
21
+ 'colspan', // Should be colSpan
22
+ 'contenteditable', // Should be contentEditable
23
+ 'contextmenu', // Should be contextMenu
24
+ 'crossorigin', // Should be crossOrigin
25
+ 'datetime', // Should be dateTime
26
+ 'enctype', // Should be encType
27
+ 'for', // Should be htmlFor
28
+ 'formaction', // Should be formAction
29
+ 'formenctype', // Should be formEncType
30
+ 'formmethod', // Should be formMethod
31
+ 'formnovalidate', // Should be formNoValidate
32
+ 'formtarget', // Should be formTarget
33
+ 'frameborder', // Should be frameBorder
34
+ 'hreflang', // Should be hrefLang
35
+ 'http-equiv', // Should be httpEquiv
36
+ 'inputmode', // Should be inputMode
37
+ 'maxlength', // Should be maxLength
38
+ 'minlength', // Should be minLength
39
+ 'novalidate', // Should be noValidate
40
+ 'readonly', // Should be readOnly
41
+ 'rowspan', // Should be rowSpan
42
+ 'spellcheck', // Should be spellCheck
43
+ 'srcdoc', // Should be srcDoc
44
+ 'srclang', // Should be srcLang
45
+ 'srcset', // Should be srcSet
46
+ 'tabindex', // Should be tabIndex
47
+ 'usemap', // Should be useMap
48
+ ]);
49
+ exports.noInvalidHtmlAttribute = (0, eslint_devkit_1.createRule)({
50
+ name: 'no-invalid-html-attribute',
51
+ meta: {
52
+ type: 'problem',
53
+ docs: {
54
+ description: 'Prevent invalid HTML attributes',
55
+ },
56
+ messages: {
57
+ noInvalidHtmlAttribute: (0, eslint_devkit_2.formatLLMMessage)({
58
+ icon: eslint_devkit_2.MessageIcons.WARNING,
59
+ issueName: 'Invalid HTML Attribute',
60
+ description: 'Invalid HTML attribute detected',
61
+ severity: 'MEDIUM',
62
+ fix: 'Use camelCase React attribute instead',
63
+ documentationLink: 'https://react.dev/reference/react-dom/components/common#html-attributes',
64
+ }),
65
+ },
66
+ schema: [],
67
+ },
68
+ defaultOptions: [],
69
+ create(context) {
70
+ return {
71
+ JSXAttribute(node) {
72
+ if (node.name.type === 'JSXIdentifier') {
73
+ const attrName = node.name.name;
74
+ if (INVALID_HTML_ATTRIBUTES.has(attrName)) {
75
+ context.report({
76
+ node: node.name,
77
+ messageId: 'noInvalidHtmlAttribute',
78
+ });
79
+ }
80
+ }
81
+ },
82
+ };
83
+ },
84
+ });
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Copyright (c) 2025 Ofri Peretz
3
+ * Licensed under the MIT License. Use of this source code is governed by the
4
+ * MIT license that can be found in the LICENSE file.
5
+ */
6
+ /**
7
+ * ESLint Rule: no-is-mounted
8
+ * Prevent isMounted anti-pattern
9
+ */
10
+ import type { TSESLint } from '@interlace/eslint-devkit';
11
+ export declare const noIsMounted: TSESLint.RuleModule<"noIsMounted", [], unknown, TSESLint.RuleListener> & {
12
+ name: string;
13
+ };
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2025 Ofri Peretz
4
+ * Licensed under the MIT License. Use of this source code is governed by the
5
+ * MIT license that can be found in the LICENSE file.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.noIsMounted = void 0;
9
+ const eslint_devkit_1 = require("@interlace/eslint-devkit");
10
+ const eslint_devkit_2 = require("@interlace/eslint-devkit");
11
+ exports.noIsMounted = (0, eslint_devkit_1.createRule)({
12
+ name: 'no-is-mounted',
13
+ meta: {
14
+ type: 'problem',
15
+ docs: {
16
+ description: 'Prevent isMounted anti-pattern',
17
+ },
18
+ schema: [],
19
+ messages: {
20
+ noIsMounted: (0, eslint_devkit_2.formatLLMMessage)({
21
+ icon: eslint_devkit_2.MessageIcons.WARNING,
22
+ issueName: 'isMounted Usage',
23
+ description: 'isMounted anti-pattern detected',
24
+ severity: 'HIGH',
25
+ fix: 'Use proper lifecycle management or cancellation tokens',
26
+ documentationLink: 'https://react.dev/blog/2015/12/16/ismounted-antipattern.html',
27
+ }),
28
+ },
29
+ },
30
+ defaultOptions: [],
31
+ create(context) {
32
+ return {
33
+ // Check for isMounted property access (covers both property access and method calls)
34
+ MemberExpression(node) {
35
+ if (node.property.type === 'Identifier' &&
36
+ node.property.name === 'isMounted') {
37
+ context.report({
38
+ node: node.property,
39
+ messageId: 'noIsMounted',
40
+ });
41
+ }
42
+ },
43
+ // Check for isMounted variable declarations
44
+ 'VariableDeclarator[id.name="isMounted"]'(node) {
45
+ context.report({
46
+ node: node.id,
47
+ messageId: 'noIsMounted',
48
+ });
49
+ },
50
+ };
51
+ },
52
+ });
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) 2025 Ofri Peretz
3
+ * Licensed under the MIT License. Use of this source code is governed by the
4
+ * MIT license that can be found in the LICENSE file.
5
+ */
6
+ /**
7
+ * ESLint Rule: no-multi-comp
8
+ * Prevent multiple components per file
9
+ */
10
+ import type { TSESLint } from '@interlace/eslint-devkit';
11
+ export interface Options {
12
+ ignoreStateless?: boolean;
13
+ }
14
+ type RuleOptions = [Options?];
15
+ export declare const noMultiComp: TSESLint.RuleModule<"noMultiComp", RuleOptions, unknown, TSESLint.RuleListener> & {
16
+ name: string;
17
+ };
18
+ export {};