eslint-plugin-react-features 1.2.5 → 1.2.7

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 (129) hide show
  1. package/package.json +7 -18
  2. package/src/index.d.ts +15 -2074
  3. package/src/index.js +1 -36
  4. package/src/oxlint.d.ts +17 -20
  5. package/src/oxlint.js +0 -18
  6. package/src/rules/component-api/no-arbitrary-token-class.js +0 -11
  7. package/src/rules/component-api/no-default-test-id.js +0 -7
  8. package/src/rules/component-api/no-inline-style.js +0 -6
  9. package/src/rules/component-api/no-is-prefix-prop.js +0 -7
  10. package/src/rules/component-api/no-kind-prop-discriminator.js +0 -5
  11. package/src/rules/component-api/no-raw-color-literal.js +0 -8
  12. package/src/rules/component-api/no-wrapper-sub-component.js +0 -8
  13. package/src/rules/component-api/require-data-slot.js +0 -5
  14. package/src/rules/migration/react-class-to-hooks.js +1 -26
  15. package/src/rules/performance/no-unnecessary-rerenders.js +1 -32
  16. package/src/rules/performance/react-no-inline-functions.js +2 -29
  17. package/src/rules/performance/react-render-optimization.js +1 -40
  18. package/src/rules/react/checked-requires-onchange-or-readonly.js +0 -7
  19. package/src/rules/react/default-props-match-prop-types.js +2 -23
  20. package/src/rules/react/display-name.js +1 -33
  21. package/src/rules/react/hooks-exhaustive-deps.js +1 -90
  22. package/src/rules/react/jsx-handler-names.js +0 -8
  23. package/src/rules/react/jsx-key.js +0 -84
  24. package/src/rules/react/jsx-max-depth.js +0 -10
  25. package/src/rules/react/jsx-no-bind.js +0 -10
  26. package/src/rules/react/jsx-no-duplicate-props.js +0 -5
  27. package/src/rules/react/jsx-no-literals.js +0 -5
  28. package/src/rules/react/jsx-no-script-url.js +0 -16
  29. package/src/rules/react/jsx-no-target-blank.js +1 -20
  30. package/src/rules/react/no-access-state-in-setstate.js +0 -13
  31. package/src/rules/react/no-adjacent-inline-elements.js +0 -10
  32. package/src/rules/react/no-arrow-function-lifecycle.js +0 -7
  33. package/src/rules/react/no-children-prop.js +0 -7
  34. package/src/rules/react/no-danger-with-children.js +0 -13
  35. package/src/rules/react/no-danger.js +0 -5
  36. package/src/rules/react/no-deprecated.js +0 -11
  37. package/src/rules/react/no-did-mount-set-state.js +0 -6
  38. package/src/rules/react/no-did-update-set-state.js +0 -10
  39. package/src/rules/react/no-direct-mutation-state.js +3 -29
  40. package/src/rules/react/no-find-dom-node.js +0 -7
  41. package/src/rules/react/no-invalid-html-attribute.js +36 -41
  42. package/src/rules/react/no-is-mounted.js +0 -7
  43. package/src/rules/react/no-multi-comp.js +0 -14
  44. package/src/rules/react/no-namespace.js +0 -5
  45. package/src/rules/react/no-object-type-as-default-prop.js +0 -9
  46. package/src/rules/react/no-redundant-should-component-update.js +0 -6
  47. package/src/rules/react/no-render-return-value.js +1 -9
  48. package/src/rules/react/no-set-state.js +0 -6
  49. package/src/rules/react/no-string-refs.js +0 -8
  50. package/src/rules/react/no-this-in-sfc.js +0 -11
  51. package/src/rules/react/no-typos.js +1 -9
  52. package/src/rules/react/no-unescaped-entities.js +0 -7
  53. package/src/rules/react/no-unknown-property.js +0 -13
  54. package/src/rules/react/no-unsafe.js +0 -7
  55. package/src/rules/react/prefer-es6-class.js +0 -7
  56. package/src/rules/react/prefer-stateless-function.js +0 -13
  57. package/src/rules/react/prop-types.js +0 -12
  58. package/src/rules/react/react-in-jsx-scope.js +0 -9
  59. package/src/rules/react/require-default-props.js +0 -19
  60. package/src/rules/react/require-optimization.js +6 -44
  61. package/src/rules/react/require-render-return.js +0 -9
  62. package/src/rules/react/required-attributes.js +0 -34
  63. package/src/rules/react/sort-comp.js +1 -19
  64. package/src/rules/react/state-in-constructor.js +0 -11
  65. package/src/rules/react/static-property-placement.js +1 -21
  66. package/src/rules/react/void-dom-elements-no-children.js +0 -7
  67. package/src/types/index.js +0 -5
  68. package/CHANGELOG.md +0 -255
  69. package/src/rules/component-api/no-arbitrary-token-class.d.ts +0 -17
  70. package/src/rules/component-api/no-default-test-id.d.ts +0 -15
  71. package/src/rules/component-api/no-inline-style.d.ts +0 -15
  72. package/src/rules/component-api/no-is-prefix-prop.d.ts +0 -17
  73. package/src/rules/component-api/no-kind-prop-discriminator.d.ts +0 -25
  74. package/src/rules/component-api/no-raw-color-literal.d.ts +0 -16
  75. package/src/rules/component-api/no-wrapper-sub-component.d.ts +0 -23
  76. package/src/rules/component-api/require-data-slot.d.ts +0 -15
  77. package/src/rules/migration/react-class-to-hooks.d.ts +0 -22
  78. package/src/rules/performance/no-unnecessary-rerenders.d.ts +0 -26
  79. package/src/rules/performance/react-no-inline-functions.d.ts +0 -24
  80. package/src/rules/performance/react-render-optimization.d.ts +0 -31
  81. package/src/rules/react/checked-requires-onchange-or-readonly.d.ts +0 -16
  82. package/src/rules/react/default-props-match-prop-types.d.ts +0 -13
  83. package/src/rules/react/display-name.d.ts +0 -13
  84. package/src/rules/react/hooks-exhaustive-deps.d.ts +0 -25
  85. package/src/rules/react/jsx-handler-names.d.ts +0 -13
  86. package/src/rules/react/jsx-key.d.ts +0 -20
  87. package/src/rules/react/jsx-max-depth.d.ts +0 -19
  88. package/src/rules/react/jsx-no-bind.d.ts +0 -13
  89. package/src/rules/react/jsx-no-duplicate-props.d.ts +0 -21
  90. package/src/rules/react/jsx-no-literals.d.ts +0 -20
  91. package/src/rules/react/jsx-no-script-url.d.ts +0 -25
  92. package/src/rules/react/jsx-no-target-blank.d.ts +0 -26
  93. package/src/rules/react/no-access-state-in-setstate.d.ts +0 -13
  94. package/src/rules/react/no-adjacent-inline-elements.d.ts +0 -13
  95. package/src/rules/react/no-arrow-function-lifecycle.d.ts +0 -13
  96. package/src/rules/react/no-children-prop.d.ts +0 -13
  97. package/src/rules/react/no-danger-with-children.d.ts +0 -16
  98. package/src/rules/react/no-danger.d.ts +0 -13
  99. package/src/rules/react/no-deprecated.d.ts +0 -16
  100. package/src/rules/react/no-did-mount-set-state.d.ts +0 -13
  101. package/src/rules/react/no-did-update-set-state.d.ts +0 -19
  102. package/src/rules/react/no-direct-mutation-state.d.ts +0 -20
  103. package/src/rules/react/no-find-dom-node.d.ts +0 -15
  104. package/src/rules/react/no-invalid-html-attribute.d.ts +0 -13
  105. package/src/rules/react/no-is-mounted.d.ts +0 -13
  106. package/src/rules/react/no-multi-comp.d.ts +0 -18
  107. package/src/rules/react/no-namespace.d.ts +0 -13
  108. package/src/rules/react/no-object-type-as-default-prop.d.ts +0 -13
  109. package/src/rules/react/no-redundant-should-component-update.d.ts +0 -13
  110. package/src/rules/react/no-render-return-value.d.ts +0 -13
  111. package/src/rules/react/no-set-state.d.ts +0 -13
  112. package/src/rules/react/no-string-refs.d.ts +0 -13
  113. package/src/rules/react/no-this-in-sfc.d.ts +0 -13
  114. package/src/rules/react/no-typos.d.ts +0 -13
  115. package/src/rules/react/no-unescaped-entities.d.ts +0 -13
  116. package/src/rules/react/no-unknown-property.d.ts +0 -13
  117. package/src/rules/react/no-unsafe.d.ts +0 -20
  118. package/src/rules/react/prefer-es6-class.d.ts +0 -13
  119. package/src/rules/react/prefer-stateless-function.d.ts +0 -16
  120. package/src/rules/react/prop-types.d.ts +0 -18
  121. package/src/rules/react/react-in-jsx-scope.d.ts +0 -13
  122. package/src/rules/react/require-default-props.d.ts +0 -16
  123. package/src/rules/react/require-optimization.d.ts +0 -26
  124. package/src/rules/react/require-render-return.d.ts +0 -13
  125. package/src/rules/react/required-attributes.d.ts +0 -28
  126. package/src/rules/react/sort-comp.d.ts +0 -17
  127. package/src/rules/react/state-in-constructor.d.ts +0 -13
  128. package/src/rules/react/static-property-placement.d.ts +0 -20
  129. package/src/rules/react/void-dom-elements-no-children.d.ts +0 -15
@@ -1,50 +1,45 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.noInvalidHtmlAttribute = void 0;
9
4
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
10
5
  const eslint_devkit_2 = require("@interlace/eslint-devkit");
11
6
  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
7
+ 'accept-charset',
8
+ 'accesskey',
9
+ 'allowfullscreen',
10
+ 'allowtransparency',
11
+ 'bgcolor',
12
+ 'cellpadding',
13
+ 'cellspacing',
14
+ 'charset',
15
+ 'class',
16
+ 'colspan',
17
+ 'contenteditable',
18
+ 'contextmenu',
19
+ 'crossorigin',
20
+ 'datetime',
21
+ 'enctype',
22
+ 'for',
23
+ 'formaction',
24
+ 'formenctype',
25
+ 'formmethod',
26
+ 'formnovalidate',
27
+ 'formtarget',
28
+ 'frameborder',
29
+ 'hreflang',
30
+ 'http-equiv',
31
+ 'inputmode',
32
+ 'maxlength',
33
+ 'minlength',
34
+ 'novalidate',
35
+ 'readonly',
36
+ 'rowspan',
37
+ 'spellcheck',
38
+ 'srcdoc',
39
+ 'srclang',
40
+ 'srcset',
41
+ 'tabindex',
42
+ 'usemap',
48
43
  ]);
49
44
  exports.noInvalidHtmlAttribute = (0, eslint_devkit_1.createRule)({
50
45
  name: 'no-invalid-html-attribute',
@@ -1,9 +1,4 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.noIsMounted = void 0;
9
4
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
@@ -31,7 +26,6 @@ exports.noIsMounted = (0, eslint_devkit_1.createRule)({
31
26
  defaultOptions: [],
32
27
  create(context) {
33
28
  return {
34
- // Check for isMounted property access (covers both property access and method calls)
35
29
  MemberExpression(node) {
36
30
  if (node.property.type === 'Identifier' &&
37
31
  node.property.name === 'isMounted') {
@@ -41,7 +35,6 @@ exports.noIsMounted = (0, eslint_devkit_1.createRule)({
41
35
  });
42
36
  }
43
37
  },
44
- // Check for isMounted variable declarations
45
38
  'VariableDeclarator[id.name="isMounted"]'(node) {
46
39
  context.report({
47
40
  node: node.id,
@@ -1,9 +1,4 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.noMultiComp = void 0;
9
4
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
@@ -42,13 +37,11 @@ exports.noMultiComp = (0, eslint_devkit_1.createRule)({
42
37
  create(context) {
43
38
  const components = [];
44
39
  return {
45
- // Class components
46
40
  ClassDeclaration(node) {
47
41
  if (isReactComponent(node)) {
48
42
  components.push(node);
49
43
  }
50
44
  },
51
- // Function components
52
45
  'VariableDeclarator, FunctionDeclaration'(node) {
53
46
  if (isReactComponentFunction(getComponentFromDeclaration(node))) {
54
47
  components.push(node);
@@ -59,11 +52,9 @@ exports.noMultiComp = (0, eslint_devkit_1.createRule)({
59
52
  const ignoreStateless = firstOption?.ignoreStateless ?? false;
60
53
  let componentCount = components.length;
61
54
  if (ignoreStateless) {
62
- // Count only stateful components
63
55
  componentCount = components.filter(comp => !isStatelessComponent(comp)).length;
64
56
  }
65
57
  if (componentCount > 1) {
66
- // Report on all components except the first
67
58
  for (let i = 1; i < components.length; i++) {
68
59
  const comp = components[i];
69
60
  if (!ignoreStateless || !isStatelessComponent(comp)) {
@@ -76,7 +67,6 @@ exports.noMultiComp = (0, eslint_devkit_1.createRule)({
76
67
  }
77
68
  },
78
69
  };
79
- // oxlint-disable-next-line consistent-function-scoping
80
70
  function getComponentFromDeclaration(node) {
81
71
  if (node.type === 'FunctionDeclaration') {
82
72
  return node;
@@ -103,7 +93,6 @@ exports.noMultiComp = (0, eslint_devkit_1.createRule)({
103
93
  if (node.type === 'JSXElement' || node.type === 'JSXFragment') {
104
94
  return true;
105
95
  }
106
- // Skip non-child keys to avoid circular references
107
96
  const skipKeys = new Set(['parent', 'range', 'loc', 'start', 'end', 'tokens', 'comments']);
108
97
  for (const key in node) {
109
98
  if (skipKeys.has(key))
@@ -128,7 +117,6 @@ exports.noMultiComp = (0, eslint_devkit_1.createRule)({
128
117
  }
129
118
  return false;
130
119
  }
131
- // oxlint-disable-next-line consistent-function-scoping
132
120
  function isReactComponent(node) {
133
121
  if (!node.superClass)
134
122
  return false;
@@ -144,10 +132,8 @@ exports.noMultiComp = (0, eslint_devkit_1.createRule)({
144
132
  return false;
145
133
  }
146
134
  function isStatelessComponent(node) {
147
- // Simple heuristic: check if it's a function component without useState
148
135
  return !isReactComponent(node);
149
136
  }
150
- // oxlint-disable-next-line consistent-function-scoping
151
137
  function getComponentNameNode(node) {
152
138
  if (node.type === 'ClassDeclaration') {
153
139
  return node.id || node;
@@ -1,9 +1,4 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.noNamespace = void 0;
9
4
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
@@ -1,9 +1,4 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.noObjectTypeAsDefaultProp = void 0;
9
4
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
@@ -31,7 +26,6 @@ exports.noObjectTypeAsDefaultProp = (0, eslint_devkit_1.createRule)({
31
26
  defaultOptions: [],
32
27
  create(context) {
33
28
  return {
34
- // Check defaultProps assignments (PropertyDefinition is used by TypeScript parser)
35
29
  'PropertyDefinition[key.name="defaultProps"]'(node) {
36
30
  if (node.value && node.value.type === 'ObjectExpression') {
37
31
  for (const prop of node.value.properties) {
@@ -44,12 +38,9 @@ exports.noObjectTypeAsDefaultProp = (0, eslint_devkit_1.createRule)({
44
38
  }
45
39
  }
46
40
  },
47
- // Check default parameter assignments in function components
48
41
  AssignmentPattern(node) {
49
42
  if (node.right.type === 'ObjectExpression') {
50
- // Check if this is a destructured parameter in a function component
51
43
  if (node.parent.type === 'Property' || node.parent.type === 'RestElement') {
52
- // This is likely a function parameter with default value
53
44
  context.report({
54
45
  node: node.left,
55
46
  messageId: 'noObjectTypeAsDefaultProp',
@@ -1,9 +1,4 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.noRedundantShouldComponentUpdate = void 0;
9
4
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
@@ -35,7 +30,6 @@ exports.noRedundantShouldComponentUpdate = (0, eslint_devkit_1.createRule)({
35
30
  if (node.key.type === 'Identifier' &&
36
31
  node.key.name === 'shouldComponentUpdate' &&
37
32
  node.value.type === 'FunctionExpression') {
38
- // Check if the method just returns true
39
33
  const body = node.value.body;
40
34
  if (body.type === 'BlockStatement' && body.body.length === 1) {
41
35
  const statement = body.body[0];
@@ -1,9 +1,4 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.noRenderReturnValue = void 0;
9
4
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
@@ -53,9 +48,6 @@ exports.noRenderReturnValue = (0, eslint_devkit_1.createRule)({
53
48
  };
54
49
  },
55
50
  });
56
- /**
57
- * Check if call expression is ReactDOM.render()
58
- */
59
51
  function isReactDOMRenderCall(node) {
60
52
  if (node.callee.type === 'MemberExpression' &&
61
53
  node.callee.object.type === 'MemberExpression' &&
@@ -65,7 +57,7 @@ function isReactDOMRenderCall(node) {
65
57
  node.callee.object.property.name === 'render' &&
66
58
  node.callee.property.type === 'Identifier' &&
67
59
  node.callee.property.name === 'render') {
68
- return false; // This would be ReactDOM.render.render which is invalid
60
+ return false;
69
61
  }
70
62
  return (node.callee.type === 'MemberExpression' &&
71
63
  node.callee.object.type === 'Identifier' &&
@@ -1,9 +1,4 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.noSetState = void 0;
9
4
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
@@ -32,7 +27,6 @@ exports.noSetState = (0, eslint_devkit_1.createRule)({
32
27
  create(context) {
33
28
  return {
34
29
  CallExpression(node) {
35
- // Check if this is a setState call
36
30
  if (node.callee.type === 'MemberExpression' &&
37
31
  node.callee.property.type === 'Identifier' &&
38
32
  node.callee.property.name === 'setState') {
@@ -1,9 +1,4 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.noStringRefs = void 0;
9
4
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
@@ -34,7 +29,6 @@ exports.noStringRefs = (0, eslint_devkit_1.createRule)({
34
29
  JSXAttribute(node) {
35
30
  if (node.name.type === 'JSXIdentifier' &&
36
31
  node.name.name === 'ref') {
37
- // Check for direct string literals
38
32
  if (node.value &&
39
33
  node.value.type === 'Literal' &&
40
34
  typeof node.value.value === 'string') {
@@ -43,7 +37,6 @@ exports.noStringRefs = (0, eslint_devkit_1.createRule)({
43
37
  messageId: 'noStringRefs',
44
38
  });
45
39
  }
46
- // Check for string literals inside JSX expressions
47
40
  else if (node.value &&
48
41
  node.value.type === 'JSXExpressionContainer' &&
49
42
  node.value.expression.type === 'Literal' &&
@@ -53,7 +46,6 @@ exports.noStringRefs = (0, eslint_devkit_1.createRule)({
53
46
  messageId: 'noStringRefs',
54
47
  });
55
48
  }
56
- // Check for template literals
57
49
  else if (node.value &&
58
50
  node.value.type === 'JSXExpressionContainer' &&
59
51
  node.value.expression.type === 'TemplateLiteral') {
@@ -1,9 +1,4 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.noThisInSfc = void 0;
9
4
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
@@ -32,7 +27,6 @@ exports.noThisInSfc = (0, eslint_devkit_1.createRule)({
32
27
  create(context) {
33
28
  let inClassContext = false;
34
29
  return {
35
- // Track class context
36
30
  ClassDeclaration() {
37
31
  inClassContext = true;
38
32
  },
@@ -45,17 +39,12 @@ exports.noThisInSfc = (0, eslint_devkit_1.createRule)({
45
39
  'ClassExpression:exit'() {
46
40
  inClassContext = false;
47
41
  },
48
- // Track method context within classes
49
42
  MethodDefinition() {
50
- // Already in class context, this is allowed
51
43
  },
52
44
  ThisExpression(node) {
53
- // Allow 'this' in class contexts
54
45
  if (inClassContext) {
55
46
  return;
56
47
  }
57
- // Flag 'this' usage outside of class contexts
58
- // In React, this typically indicates the code should be in a class component
59
48
  context.report({
60
49
  node,
61
50
  messageId: 'noThisInSfc',
@@ -1,9 +1,4 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.noTypos = void 0;
9
4
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
@@ -16,7 +11,7 @@ const COMMON_TYPOS = new Map([
16
11
  ['DefaulProps', 'DefaultProps'],
17
12
  ['DefalutProps', 'DefaultProps'],
18
13
  ['DefualtProps', 'DefaultProps'],
19
- ['propTypes', 'propTypes'], // This would catch variations
14
+ ['propTypes', 'propTypes'],
20
15
  ['PropTypes', 'PropTypes'],
21
16
  ['componenDidMount', 'componentDidMount'],
22
17
  ['componenDidUpdate', 'componentDidUpdate'],
@@ -54,7 +49,6 @@ exports.noTypos = (0, eslint_devkit_1.createRule)({
54
49
  defaultOptions: [],
55
50
  create(context) {
56
51
  return {
57
- // Check class property names (PropertyDefinition is used by TypeScript parser)
58
52
  PropertyDefinition(node) {
59
53
  if (node.key.type === 'Identifier') {
60
54
  const name = node.key.name;
@@ -67,7 +61,6 @@ exports.noTypos = (0, eslint_devkit_1.createRule)({
67
61
  }
68
62
  }
69
63
  },
70
- // Check method names
71
64
  MethodDefinition(node) {
72
65
  if (node.key.type === 'Identifier') {
73
66
  const name = node.key.name;
@@ -80,7 +73,6 @@ exports.noTypos = (0, eslint_devkit_1.createRule)({
80
73
  }
81
74
  }
82
75
  },
83
- // Check property access
84
76
  MemberExpression(node) {
85
77
  if (node.property.type === 'Identifier') {
86
78
  const name = node.property.name;
@@ -1,9 +1,4 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.noUnescapedEntities = void 0;
9
4
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
@@ -34,11 +29,9 @@ exports.noUnescapedEntities = (0, eslint_devkit_1.createRule)({
34
29
  return {
35
30
  JSXText(node) {
36
31
  const text = node.value;
37
- // Skip whitespace-only text
38
32
  if (!text.trim()) {
39
33
  return;
40
34
  }
41
- // Check for unescaped entities
42
35
  if (UNESCAPED_ENTITIES.test(text)) {
43
36
  context.report({
44
37
  node,
@@ -1,15 +1,9 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.noUnknownProperty = void 0;
9
4
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
10
5
  const eslint_devkit_2 = require("@interlace/eslint-devkit");
11
6
  const VALID_DOM_PROPERTIES = new Set([
12
- // HTML attributes
13
7
  'accept', 'acceptCharset', 'accessKey', 'action', 'allowFullScreen', 'allowTransparency',
14
8
  'alt', 'async', 'autoComplete', 'autoFocus', 'autoPlay', 'capture', 'cellPadding',
15
9
  'cellSpacing', 'challenge', 'charSet', 'checked', 'cite', 'classID', 'className',
@@ -26,10 +20,8 @@ const VALID_DOM_PROPERTIES = new Set([
26
20
  'scrolling', 'seamless', 'selected', 'shape', 'size', 'sizes', 'span', 'spellCheck',
27
21
  'src', 'srcDoc', 'srcLang', 'srcSet', 'start', 'step', 'style', 'summary', 'tabIndex',
28
22
  'target', 'title', 'type', 'useMap', 'value', 'width', 'wmode', 'wrap',
29
- // React-specific attributes
30
23
  'children', 'dangerouslySetInnerHTML', 'key', 'ref', 'suppressContentEditableWarning',
31
24
  'suppressHydrationWarning',
32
- // SVG attributes
33
25
  'accentHeight', 'accumulate', 'additive', 'alignmentBaseline', 'allowReorder',
34
26
  'alphabetic', 'amplitude', 'arabicForm', 'ascent', 'attributeName', 'attributeType',
35
27
  'autoReverse', 'azimuth', 'baseFrequency', 'baselineShift', 'baseProfile', 'bbox',
@@ -67,7 +59,6 @@ const VALID_DOM_PROPERTIES = new Set([
67
59
  'xlinkActuate', 'xlinkArcrole', 'xlinkHref', 'xlinkRole', 'xlinkShow', 'xlinkTitle',
68
60
  'xlinkType', 'xmlBase', 'xmlLang', 'xmlSpace', 'y', 'y1', 'y2', 'yChannelSelector',
69
61
  'z', 'zoomAndPan',
70
- // Event handlers
71
62
  'onAbort', 'onAnimationEnd', 'onAnimationIteration', 'onAnimationStart', 'onAuxClick',
72
63
  'onBeforeInput', 'onBlur', 'onCanPlay', 'onCanPlayThrough', 'onChange', 'onClick',
73
64
  'onCompositionEnd', 'onCompositionStart', 'onCompositionUpdate', 'onContextMenu',
@@ -111,19 +102,15 @@ exports.noUnknownProperty = (0, eslint_devkit_1.createRule)({
111
102
  create(context) {
112
103
  return {
113
104
  JSXAttribute(node) {
114
- // Only host (DOM) elements have a fixed property set. Custom
115
- // components (<Box />, <Motion.div />) accept arbitrary props.
116
105
  const elementName = node.parent.name;
117
106
  if (elementName.type !== 'JSXIdentifier' || !/^[a-z]/.test(elementName.name)) {
118
107
  return;
119
108
  }
120
109
  if (node.name.type === 'JSXIdentifier') {
121
110
  const propName = node.name.name;
122
- // Skip React-specific props and data attributes
123
111
  if (REACT_PROPS.has(propName) || propName.startsWith('data-') || propName.startsWith('aria-')) {
124
112
  return;
125
113
  }
126
- // Check if it's a valid DOM property
127
114
  if (!VALID_DOM_PROPERTIES.has(propName)) {
128
115
  context.report({
129
116
  node: node.name,
@@ -1,9 +1,4 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.noUnsafe = void 0;
9
4
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
@@ -56,7 +51,6 @@ exports.noUnsafe = (0, eslint_devkit_2.createRule)({
56
51
  if (node.key.type !== 'Identifier')
57
52
  return;
58
53
  const methodName = node.key.name;
59
- // Check UNSAFE_ prefixed methods
60
54
  const unsafeInfo = UNSAFE_METHODS[methodName];
61
55
  if (unsafeInfo) {
62
56
  context.report({
@@ -69,7 +63,6 @@ exports.noUnsafe = (0, eslint_devkit_2.createRule)({
69
63
  });
70
64
  return;
71
65
  }
72
- // Check legacy methods if checkAliases is enabled
73
66
  if (checkAliases) {
74
67
  const legacyInfo = LEGACY_METHODS[methodName];
75
68
  if (legacyInfo) {
@@ -1,9 +1,4 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.preferEs6Class = void 0;
9
4
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
@@ -32,7 +27,6 @@ exports.preferEs6Class = (0, eslint_devkit_1.createRule)({
32
27
  create(context) {
33
28
  return {
34
29
  CallExpression(node) {
35
- // Check for React.createClass()
36
30
  if (node.callee.type === 'MemberExpression' &&
37
31
  node.callee.object.type === 'Identifier' &&
38
32
  node.callee.object.name === 'React' &&
@@ -43,7 +37,6 @@ exports.preferEs6Class = (0, eslint_devkit_1.createRule)({
43
37
  messageId: 'preferEs6Class',
44
38
  });
45
39
  }
46
- // Check for createClass() (imported)
47
40
  if (node.callee.type === 'Identifier' &&
48
41
  node.callee.name === 'createClass') {
49
42
  context.report({
@@ -1,9 +1,4 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.preferStatelessFunction = void 0;
9
4
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
@@ -46,10 +41,8 @@ exports.preferStatelessFunction = (0, eslint_devkit_1.createRule)({
46
41
  ClassDeclaration(node) {
47
42
  if (!isReactComponent(node))
48
43
  return;
49
- // Skip if it's a PureComponent and we're ignoring them
50
44
  if (ignorePureComponents && isPureComponent(node))
51
45
  return;
52
- // Check if class has state or lifecycle methods
53
46
  if (!hasState(node) && !hasLifecycleMethods(node)) {
54
47
  context.report({
55
48
  node: node.id || node,
@@ -58,7 +51,6 @@ exports.preferStatelessFunction = (0, eslint_devkit_1.createRule)({
58
51
  }
59
52
  },
60
53
  };
61
- // oxlint-disable-next-line consistent-function-scoping
62
54
  function isReactComponent(node) {
63
55
  if (!node.superClass)
64
56
  return false;
@@ -73,7 +65,6 @@ exports.preferStatelessFunction = (0, eslint_devkit_1.createRule)({
73
65
  }
74
66
  return false;
75
67
  }
76
- // oxlint-disable-next-line consistent-function-scoping
77
68
  function isPureComponent(node) {
78
69
  if (!node.superClass)
79
70
  return false;
@@ -88,10 +79,8 @@ exports.preferStatelessFunction = (0, eslint_devkit_1.createRule)({
88
79
  }
89
80
  return false;
90
81
  }
91
- // oxlint-disable-next-line consistent-function-scoping
92
82
  function hasState(node) {
93
83
  for (const member of node.body.body) {
94
- // PropertyDefinition is used by TypeScript parser for class properties
95
84
  if (member.type === 'PropertyDefinition' &&
96
85
  member.key.type === 'Identifier' &&
97
86
  member.key.name === 'state') {
@@ -100,7 +89,6 @@ exports.preferStatelessFunction = (0, eslint_devkit_1.createRule)({
100
89
  if (member.type === 'MethodDefinition' &&
101
90
  member.key.type === 'Identifier' &&
102
91
  member.key.name === 'constructor') {
103
- // Check if constructor sets this.state
104
92
  const body = member.value.body;
105
93
  if (!body)
106
94
  continue;
@@ -118,7 +106,6 @@ exports.preferStatelessFunction = (0, eslint_devkit_1.createRule)({
118
106
  }
119
107
  return false;
120
108
  }
121
- // oxlint-disable-next-line consistent-function-scoping
122
109
  function hasLifecycleMethods(node) {
123
110
  const lifecycleMethods = new Set([
124
111
  'componentDidMount', 'componentDidUpdate', 'componentWillUnmount',
@@ -1,9 +1,4 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.propTypes = void 0;
9
4
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
@@ -54,13 +49,11 @@ exports.propTypes = (0, eslint_devkit_1.createRule)({
54
49
  const components = [];
55
50
  const propTypesMap = new Map();
56
51
  return {
57
- // Collect class components
58
52
  ClassDeclaration(node) {
59
53
  if (isReactComponent(node) && !ignore.includes(node.id?.name || '')) {
60
54
  components.push(node);
61
55
  }
62
56
  },
63
- // Collect propTypes (PropertyDefinition in TypeScript ESLint)
64
57
  'PropertyDefinition[key.name="propTypes"]'(node) {
65
58
  if (node.parent.type === 'ClassBody') {
66
59
  const classNode = node.parent.parent;
@@ -69,14 +62,12 @@ exports.propTypes = (0, eslint_devkit_1.createRule)({
69
62
  }
70
63
  }
71
64
  },
72
- // Check components at the end
73
65
  'Program:exit'() {
74
66
  for (const component of components) {
75
67
  const componentName = component.id?.name;
76
68
  if (!componentName)
77
69
  continue;
78
70
  const propTypesProp = propTypesMap.get(componentName);
79
- // Skip if component has propTypes or if skipUndeclared is true and no props are used
80
71
  if (propTypesProp || (skipUndeclared && !hasPropsUsage(component))) {
81
72
  continue;
82
73
  }
@@ -87,7 +78,6 @@ exports.propTypes = (0, eslint_devkit_1.createRule)({
87
78
  }
88
79
  },
89
80
  };
90
- // oxlint-disable-next-line consistent-function-scoping
91
81
  function isReactComponent(node) {
92
82
  if (!node.superClass)
93
83
  return false;
@@ -103,7 +93,6 @@ exports.propTypes = (0, eslint_devkit_1.createRule)({
103
93
  return false;
104
94
  }
105
95
  function hasPropsUsage(node) {
106
- // Simple check: look for this.props usage
107
96
  for (const member of node.body.body) {
108
97
  if (member.type === 'MethodDefinition') {
109
98
  const body = member.value.body;
@@ -126,7 +115,6 @@ exports.propTypes = (0, eslint_devkit_1.createRule)({
126
115
  node.property.name === 'props') {
127
116
  return true;
128
117
  }
129
- // Skip non-child keys to avoid circular references
130
118
  const skipKeys = new Set(['parent', 'range', 'loc', 'start', 'end', 'tokens', 'comments']);
131
119
  for (const key in node) {
132
120
  if (skipKeys.has(key))