eslint-plugin-react-features 2.0.3 β†’ 2.0.4

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/AGENTS.md CHANGED
@@ -109,6 +109,10 @@ Enable these by name (`'react-features/<rule>': 'error'`):
109
109
  - `sort-comp`: Enforce component method ordering.
110
110
  - `state-in-constructor`: Enforce state initialization in constructor.
111
111
  - `static-property-placement`: Enforce static property placement.
112
+ - `jsx-no-comment-textnodes`: Disallow comments from being inserted as text nodes.
113
+ - `jsx-no-undef`: Disallow undeclared variables in JSX.
114
+ - `jsx-uses-react`: Disallow React to be incorrectly marked as unused.
115
+ - `jsx-uses-vars`: Disallow variables used in JSX to be incorrectly marked as unused.
112
116
  - `no-find-dom-node`: Prevent using findDOMNode.
113
117
  - `no-unsafe`: Prevent usage of unsafe lifecycle methods.
114
118
  - `void-dom-elements-no-children`: Prevent void DOM elements from having children.
package/README.md CHANGED
@@ -117,10 +117,14 @@ See the [ESLint Version Support Policy](../../docs/ESLINT_VERSION_SUPPORT.md)
117
117
  | [jsx-key](https://eslint.interlace.tools/docs/quality/plugin-react-features/rules/jsx-key?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features) | | | | jsx-key rule | 🟒 | πŸ’Ό | | | πŸ’‘ | |
118
118
  | [jsx-max-depth](https://eslint.interlace.tools/docs/quality/plugin-react-features/rules/jsx-max-depth?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features) | | | | jsx-max-depth rule | 🟒 | | | | πŸ’‘ | |
119
119
  | [jsx-no-bind](https://eslint.interlace.tools/docs/quality/plugin-react-features/rules/jsx-no-bind?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features) | | | | jsx-no-bind rule | 🟒 | | | | πŸ’‘ | |
120
+ | [jsx-no-comment-textnodes](https://eslint.interlace.tools/docs/quality/plugin-react-features/rules/jsx-no-comment-textnodes?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features) | | | | Disallow comments from being inserted as text nodes | 🟒 | | | | | |
120
121
  | [jsx-no-duplicate-props](https://eslint.interlace.tools/docs/quality/plugin-react-features/rules/jsx-no-duplicate-props?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features) | | | | Prevent duplicate props in JSX elements. This rule is part of eslint-plugin-react-features and provides LLM… | 🟒 | πŸ’Ό | | | πŸ’‘ | |
121
122
  | [jsx-no-literals](https://eslint.interlace.tools/docs/quality/plugin-react-features/rules/jsx-no-literals?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features) | | | | jsx-no-literals rule | 🟒 | | | | πŸ’‘ | |
122
123
  | [jsx-no-script-url](https://eslint.interlace.tools/docs/quality/plugin-react-features/rules/jsx-no-script-url?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features) | | | | Prevent javascript: URLs in JSX. This rule is part of eslint-plugin-react-features and provides LLM-optimiz… | 🟒 | πŸ’Ό | | | πŸ’‘ | |
123
124
  | [jsx-no-target-blank](https://eslint.interlace.tools/docs/quality/plugin-react-features/rules/jsx-no-target-blank?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features) | | | | Require rel='noopener noreferrer' with target='_blank'. This rule is part of eslint-plugin-react-features a… | 🟒 | πŸ’Ό | | | πŸ’‘ | |
125
+ | [jsx-no-undef](https://eslint.interlace.tools/docs/quality/plugin-react-features/rules/jsx-no-undef?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features) | | | | Disallow undeclared variables in JSX | 🟒 | | | | | |
126
+ | [jsx-uses-react](https://eslint.interlace.tools/docs/quality/plugin-react-features/rules/jsx-uses-react?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features) | | | | Disallow React to be incorrectly marked as unused | 🟒 | | | | | |
127
+ | [jsx-uses-vars](https://eslint.interlace.tools/docs/quality/plugin-react-features/rules/jsx-uses-vars?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features) | | | | Disallow variables used in JSX to be incorrectly marked as unused | 🟒 | | | | | |
124
128
  | [no-access-state-in-setstate](https://eslint.interlace.tools/docs/quality/plugin-react-features/rules/no-access-state-in-setstate?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features) | | | | no-access-state-in-setstate rule | 🟒 | | | | πŸ’‘ | |
125
129
  | [no-adjacent-inline-elements](https://eslint.interlace.tools/docs/quality/plugin-react-features/rules/no-adjacent-inline-elements?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features) | | | | no-adjacent-inline-elements rule | 🟒 | | | | πŸ’‘ | |
126
130
  | [no-arbitrary-token-class](https://eslint.interlace.tools/docs/quality/plugin-react-features/rules/no-arbitrary-token-class?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features) | | | | | 🟒 | | | | | |
@@ -151,7 +155,7 @@ See the [ESLint Version Support Policy](../../docs/ESLINT_VERSION_SUPPORT.md)
151
155
  | [no-typos](https://eslint.interlace.tools/docs/quality/plugin-react-features/rules/no-typos?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features) | | | | no-typos rule | 🟒 | | | | πŸ’‘ | |
152
156
  | [no-unescaped-entities](https://eslint.interlace.tools/docs/quality/plugin-react-features/rules/no-unescaped-entities?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features) | | | | no-unescaped-entities rule | 🟒 | | | | πŸ’‘ | |
153
157
  | [no-unknown-property](https://eslint.interlace.tools/docs/quality/plugin-react-features/rules/no-unknown-property?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features) | | | | no-unknown-property rule | 🟒 | πŸ’Ό | | | πŸ’‘ | |
154
- | [no-unnecessary-rerenders](https://eslint.interlace.tools/docs/quality/plugin-react-features/rules/no-unnecessary-rerenders?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features) | | | | no-unnecessary-rerenders rule | 🟒 | | | | πŸ’‘ | |
158
+ | [no-unnecessary-rerenders](https://eslint.interlace.tools/docs/quality/plugin-react-features/rules/no-unnecessary-rerenders?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features) | | | | Report an object, array or function created during render and passed to a component that compares props by… | 🟒 | | | | πŸ’‘ | |
155
159
  | [no-unsafe](https://eslint.interlace.tools/docs/quality/plugin-react-features/rules/no-unsafe?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features) | | | | Warn about UNSAFE_ lifecycle methods. This rule is part of eslint-plugin-react-features and provides LLM-op… | 🟒 | | | | πŸ’‘ | |
156
160
  | [no-wrapper-sub-component](https://eslint.interlace.tools/docs/quality/plugin-react-features/rules/no-wrapper-sub-component?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features) | | | | | 🟒 | | | | | |
157
161
  | [prefer-es6-class](https://eslint.interlace.tools/docs/quality/plugin-react-features/rules/prefer-es6-class?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features) | | | | prefer-es6-class rule | 🟒 | | | | πŸ’‘ | |
@@ -160,7 +164,7 @@ See the [ESLint Version Support Policy](../../docs/ESLINT_VERSION_SUPPORT.md)
160
164
  | [react-class-to-hooks](https://eslint.interlace.tools/docs/quality/plugin-react-features/rules/react-class-to-hooks?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features) | | | | react-class-to-hooks rule | 🟒 | | | | πŸ’‘ | |
161
165
  | [react-in-jsx-scope](https://eslint.interlace.tools/docs/quality/plugin-react-features/rules/react-in-jsx-scope?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features) | | | | react-in-jsx-scope rule | 🟒 | | | | πŸ’‘ | |
162
166
  | [react-no-inline-functions](https://eslint.interlace.tools/docs/quality/plugin-react-features/rules/react-no-inline-functions?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features) | | | | react-no-inline-functions rule | 🟒 | | | | πŸ’‘ | |
163
- | [react-render-optimization](https://eslint.interlace.tools/docs/quality/plugin-react-features/rules/react-render-optimization?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features) | | | | react-render-optimization rule | 🟒 | | | | πŸ’‘ | |
167
+ | [react-render-optimization](https://eslint.interlace.tools/docs/quality/plugin-react-features/rules/react-render-optimization?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features) | | | | Report inline object, array and function props passed to a component that compares props by identity, and p… | 🟒 | | | | πŸ’‘ | |
164
168
  | [require-data-slot](https://eslint.interlace.tools/docs/quality/plugin-react-features/rules/require-data-slot?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features) | | | | | 🟒 | | | | | |
165
169
  | [require-default-props](https://eslint.interlace.tools/docs/quality/plugin-react-features/rules/require-default-props?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features) | | | | require-default-props rule | 🟒 | | | | πŸ’‘ | |
166
170
  | [require-optimization](https://eslint.interlace.tools/docs/quality/plugin-react-features/rules/require-optimization?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features) | | | | require-optimization rule | 🟒 | | | | πŸ’‘ | |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-features",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "ESLint React hooks and JSX rules β€” prop-types, JSX correctness, render performance, and class-to-hooks migration for modern React codebases.",
5
5
  "type": "commonjs",
6
6
  "sideEffects": false,
package/src/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.configs=exports.plugin=exports.rules=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.rules={get"required-attributes"(){return require("./rules/react/required-attributes").requiredAttributes},get"jsx-key"(){return require("./rules/react/jsx-key").jsxKey},get"no-direct-mutation-state"(){return require("./rules/react/no-direct-mutation-state").noDirectMutationState},get"require-optimization"(){return require("./rules/react/require-optimization").requireOptimization},get"no-set-state"(){return require("./rules/react/no-set-state").noSetState},get"no-this-in-sfc"(){return require("./rules/react/no-this-in-sfc").noThisInSfc},get"no-access-state-in-setstate"(){return require("./rules/react/no-access-state-in-setstate").noAccessStateInSetState},get"no-children-prop"(){return require("./rules/react/no-children-prop").noChildrenProp},get"no-danger"(){return require("./rules/react/no-danger").noDanger},get"no-string-refs"(){return require("./rules/react/no-string-refs").noStringRefs},get"no-unknown-property"(){return require("./rules/react/no-unknown-property").noUnknownProperty},get"checked-requires-onchange-or-readonly"(){return require("./rules/react/checked-requires-onchange-or-readonly").checkedRequiresOnchangeOrReadonly},get"default-props-match-prop-types"(){return require("./rules/react/default-props-match-prop-types").defaultPropsMatchPropTypes},get"display-name"(){return require("./rules/react/display-name").displayName},get"jsx-handler-names"(){return require("./rules/react/jsx-handler-names").jsxHandlerNames},get"jsx-max-depth"(){return require("./rules/react/jsx-max-depth").jsxMaxDepth},get"jsx-no-bind"(){return require("./rules/react/jsx-no-bind").jsxNoBind},get"jsx-no-literals"(){return require("./rules/react/jsx-no-literals").jsxNoLiterals},get"no-adjacent-inline-elements"(){return require("./rules/react/no-adjacent-inline-elements").noAdjacentInlineElements},get"no-arrow-function-lifecycle"(){return require("./rules/react/no-arrow-function-lifecycle").noArrowFunctionLifecycle},get"no-did-mount-set-state"(){return require("./rules/react/no-did-mount-set-state").noDidMountSetState},get"no-did-update-set-state"(){return require("./rules/react/no-did-update-set-state").noDidUpdateSetState},get"no-invalid-html-attribute"(){return require("./rules/react/no-invalid-html-attribute").noInvalidHtmlAttribute},get"no-is-mounted"(){return require("./rules/react/no-is-mounted").noIsMounted},get"no-multi-comp"(){return require("./rules/react/no-multi-comp").noMultiComp},get"no-namespace"(){return require("./rules/react/no-namespace").noNamespace},get"no-object-type-as-default-prop"(){return require("./rules/react/no-object-type-as-default-prop").noObjectTypeAsDefaultProp},get"no-redundant-should-component-update"(){return require("./rules/react/no-redundant-should-component-update").noRedundantShouldComponentUpdate},get"no-render-return-value"(){return require("./rules/react/no-render-return-value").noRenderReturnValue},get"no-typos"(){return require("./rules/react/no-typos").noTypos},get"no-unescaped-entities"(){return require("./rules/react/no-unescaped-entities").noUnescapedEntities},get"prefer-es6-class"(){return require("./rules/react/prefer-es6-class").preferEs6Class},get"prefer-stateless-function"(){return require("./rules/react/prefer-stateless-function").preferStatelessFunction},get"prop-types"(){return require("./rules/react/prop-types").propTypes},get"react-in-jsx-scope"(){return require("./rules/react/react-in-jsx-scope").reactInJsxScope},get"require-default-props"(){return require("./rules/react/require-default-props").requireDefaultProps},get"require-render-return"(){return require("./rules/react/require-render-return").requireRenderReturn},get"sort-comp"(){return require("./rules/react/sort-comp").sortComp},get"state-in-constructor"(){return require("./rules/react/state-in-constructor").stateInConstructor},get"static-property-placement"(){return require("./rules/react/static-property-placement").staticPropertyPlacement},get"hooks-exhaustive-deps"(){return require("./rules/react/hooks-exhaustive-deps").hooksExhaustiveDeps},get"jsx-no-target-blank"(){return require("./rules/react/jsx-no-target-blank").jsxNoTargetBlank},get"jsx-no-script-url"(){return require("./rules/react/jsx-no-script-url").jsxNoScriptUrl},get"jsx-no-duplicate-props"(){return require("./rules/react/jsx-no-duplicate-props").jsxNoDuplicateProps},get"no-danger-with-children"(){return require("./rules/react/no-danger-with-children").noDangerWithChildren},get"no-deprecated"(){return require("./rules/react/no-deprecated").noDeprecated},get"no-find-dom-node"(){return require("./rules/react/no-find-dom-node").noFindDomNode},get"no-unsafe"(){return require("./rules/react/no-unsafe").noUnsafe},get"void-dom-elements-no-children"(){return require("./rules/react/void-dom-elements-no-children").voidDomElementsNoChildren},get"react-class-to-hooks"(){return require("./rules/migration/react-class-to-hooks").reactClassToHooks},get"no-unnecessary-rerenders"(){return require("./rules/performance/no-unnecessary-rerenders").noUnnecessaryRerenders},get"react-render-optimization"(){return require("./rules/performance/react-render-optimization").reactRenderOptimization},get"react-no-inline-functions"(){return require("./rules/performance/react-no-inline-functions").reactNoInlineFunctions},get"no-default-test-id"(){return require("./rules/component-api/no-default-test-id").noDefaultTestId},get"require-data-slot"(){return require("./rules/component-api/require-data-slot").requireDataSlot},get"no-is-prefix-prop"(){return require("./rules/component-api/no-is-prefix-prop").noIsPrefixProp},get"no-inline-style"(){return require("./rules/component-api/no-inline-style").noInlineStyle},get"no-raw-color-literal"(){return require("./rules/component-api/no-raw-color-literal").noRawColorLiteral},get"no-arbitrary-token-class"(){return require("./rules/component-api/no-arbitrary-token-class").noArbitraryTokenClass},get"no-kind-prop-discriminator"(){return require("./rules/component-api/no-kind-prop-discriminator").noKindPropDiscriminator},get"no-wrapper-sub-component"(){return require("./rules/component-api/no-wrapper-sub-component").noWrapperSubComponent},get"react/required-attributes"(){return require("./rules/react/required-attributes").requiredAttributes},get"react/jsx-key"(){return require("./rules/react/jsx-key").jsxKey},get"react/no-direct-mutation-state"(){return require("./rules/react/no-direct-mutation-state").noDirectMutationState},get"react/require-optimization"(){return require("./rules/react/require-optimization").requireOptimization},get"react/no-set-state"(){return require("./rules/react/no-set-state").noSetState},get"react/no-this-in-sfc"(){return require("./rules/react/no-this-in-sfc").noThisInSfc},get"react/no-access-state-in-setstate"(){return require("./rules/react/no-access-state-in-setstate").noAccessStateInSetState},get"react/no-children-prop"(){return require("./rules/react/no-children-prop").noChildrenProp},get"react/no-danger"(){return require("./rules/react/no-danger").noDanger},get"react/no-string-refs"(){return require("./rules/react/no-string-refs").noStringRefs},get"react/no-unknown-property"(){return require("./rules/react/no-unknown-property").noUnknownProperty},get"react/checked-requires-onchange-or-readonly"(){return require("./rules/react/checked-requires-onchange-or-readonly").checkedRequiresOnchangeOrReadonly},get"react/default-props-match-prop-types"(){return require("./rules/react/default-props-match-prop-types").defaultPropsMatchPropTypes},get"react/display-name"(){return require("./rules/react/display-name").displayName},get"react/jsx-handler-names"(){return require("./rules/react/jsx-handler-names").jsxHandlerNames},get"react/jsx-max-depth"(){return require("./rules/react/jsx-max-depth").jsxMaxDepth},get"react/jsx-no-bind"(){return require("./rules/react/jsx-no-bind").jsxNoBind},get"react/jsx-no-literals"(){return require("./rules/react/jsx-no-literals").jsxNoLiterals},get"react/no-adjacent-inline-elements"(){return require("./rules/react/no-adjacent-inline-elements").noAdjacentInlineElements},get"react/no-arrow-function-lifecycle"(){return require("./rules/react/no-arrow-function-lifecycle").noArrowFunctionLifecycle},get"react/no-did-mount-set-state"(){return require("./rules/react/no-did-mount-set-state").noDidMountSetState},get"react/no-did-update-set-state"(){return require("./rules/react/no-did-update-set-state").noDidUpdateSetState},get"react/no-invalid-html-attribute"(){return require("./rules/react/no-invalid-html-attribute").noInvalidHtmlAttribute},get"react/no-is-mounted"(){return require("./rules/react/no-is-mounted").noIsMounted},get"react/no-multi-comp"(){return require("./rules/react/no-multi-comp").noMultiComp},get"react/no-namespace"(){return require("./rules/react/no-namespace").noNamespace},get"react/no-object-type-as-default-prop"(){return require("./rules/react/no-object-type-as-default-prop").noObjectTypeAsDefaultProp},get"react/no-redundant-should-component-update"(){return require("./rules/react/no-redundant-should-component-update").noRedundantShouldComponentUpdate},get"react/no-render-return-value"(){return require("./rules/react/no-render-return-value").noRenderReturnValue},get"react/no-typos"(){return require("./rules/react/no-typos").noTypos},get"react/no-unescaped-entities"(){return require("./rules/react/no-unescaped-entities").noUnescapedEntities},get"react/prefer-es6-class"(){return require("./rules/react/prefer-es6-class").preferEs6Class},get"react/prefer-stateless-function"(){return require("./rules/react/prefer-stateless-function").preferStatelessFunction},get"react/prop-types"(){return require("./rules/react/prop-types").propTypes},get"react/react-in-jsx-scope"(){return require("./rules/react/react-in-jsx-scope").reactInJsxScope},get"react/require-default-props"(){return require("./rules/react/require-default-props").requireDefaultProps},get"react/require-render-return"(){return require("./rules/react/require-render-return").requireRenderReturn},get"react/sort-comp"(){return require("./rules/react/sort-comp").sortComp},get"react/state-in-constructor"(){return require("./rules/react/state-in-constructor").stateInConstructor},get"react/static-property-placement"(){return require("./rules/react/static-property-placement").staticPropertyPlacement},get"react/hooks-exhaustive-deps"(){return require("./rules/react/hooks-exhaustive-deps").hooksExhaustiveDeps},get"react/jsx-no-target-blank"(){return require("./rules/react/jsx-no-target-blank").jsxNoTargetBlank},get"react/jsx-no-script-url"(){return require("./rules/react/jsx-no-script-url").jsxNoScriptUrl},get"react/jsx-no-duplicate-props"(){return require("./rules/react/jsx-no-duplicate-props").jsxNoDuplicateProps},get"react/no-danger-with-children"(){return require("./rules/react/no-danger-with-children").noDangerWithChildren},get"react/no-deprecated"(){return require("./rules/react/no-deprecated").noDeprecated},get"react/no-find-dom-node"(){return require("./rules/react/no-find-dom-node").noFindDomNode},get"react/no-unsafe"(){return require("./rules/react/no-unsafe").noUnsafe},get"react/void-dom-elements-no-children"(){return require("./rules/react/void-dom-elements-no-children").voidDomElementsNoChildren},get"migration/react-class-to-hooks"(){return require("./rules/migration/react-class-to-hooks").reactClassToHooks},get"performance/no-unnecessary-rerenders"(){return require("./rules/performance/no-unnecessary-rerenders").noUnnecessaryRerenders},get"performance/react-render-optimization"(){return require("./rules/performance/react-render-optimization").reactRenderOptimization},get"performance/react-no-inline-functions"(){return require("./rules/performance/react-no-inline-functions").reactNoInlineFunctions},get"component-api/no-default-test-id"(){return require("./rules/component-api/no-default-test-id").noDefaultTestId},get"component-api/require-data-slot"(){return require("./rules/component-api/require-data-slot").requireDataSlot},get"component-api/no-is-prefix-prop"(){return require("./rules/component-api/no-is-prefix-prop").noIsPrefixProp},get"component-api/no-inline-style"(){return require("./rules/component-api/no-inline-style").noInlineStyle},get"component-api/no-raw-color-literal"(){return require("./rules/component-api/no-raw-color-literal").noRawColorLiteral},get"component-api/no-arbitrary-token-class"(){return require("./rules/component-api/no-arbitrary-token-class").noArbitraryTokenClass},get"component-api/no-kind-prop-discriminator"(){return require("./rules/component-api/no-kind-prop-discriminator").noKindPropDiscriminator},get"component-api/no-wrapper-sub-component"(){return require("./rules/component-api/no-wrapper-sub-component").noWrapperSubComponent}};(0,eslint_devkit_1.withCanonicalDocsUrls)("plugin-react-features",exports.rules);exports.plugin={meta:{name:"eslint-plugin-react-features",version:"2.0.3"},rules:exports.rules};exports.configs={flagship:{plugins:{"react-features":exports.plugin},rules:{"react-features/hooks-exhaustive-deps":"error"}},recommended:{plugins:{"react-features":exports.plugin},rules:{"react-features/jsx-key":"error","react-features/no-children-prop":"warn","react-features/no-danger":"warn","react-features/no-string-refs":"error","react-features/no-unknown-property":"error","react-features/hooks-exhaustive-deps":"warn","react-features/jsx-no-target-blank":"error","react-features/jsx-no-script-url":"error","react-features/jsx-no-duplicate-props":"error","react-features/no-danger-with-children":"error","react-features/no-deprecated":"warn"}},componentApi:{plugins:{"react-features":exports.plugin},rules:{"react-features/component-api/no-default-test-id":"error","react-features/component-api/require-data-slot":"warn","react-features/component-api/no-is-prefix-prop":"warn","react-features/component-api/no-inline-style":"warn","react-features/component-api/no-raw-color-literal":"warn","react-features/component-api/no-arbitrary-token-class":"warn","react-features/component-api/no-kind-prop-discriminator":"warn","react-features/component-api/no-wrapper-sub-component":"warn"}}};exports.default=exports.plugin;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.configs=exports.plugin=exports.rules=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.rules={get"required-attributes"(){return require("./rules/react/required-attributes").requiredAttributes},get"jsx-key"(){return require("./rules/react/jsx-key").jsxKey},get"no-direct-mutation-state"(){return require("./rules/react/no-direct-mutation-state").noDirectMutationState},get"require-optimization"(){return require("./rules/react/require-optimization").requireOptimization},get"no-set-state"(){return require("./rules/react/no-set-state").noSetState},get"no-this-in-sfc"(){return require("./rules/react/no-this-in-sfc").noThisInSfc},get"no-access-state-in-setstate"(){return require("./rules/react/no-access-state-in-setstate").noAccessStateInSetState},get"no-children-prop"(){return require("./rules/react/no-children-prop").noChildrenProp},get"no-danger"(){return require("./rules/react/no-danger").noDanger},get"no-string-refs"(){return require("./rules/react/no-string-refs").noStringRefs},get"no-unknown-property"(){return require("./rules/react/no-unknown-property").noUnknownProperty},get"checked-requires-onchange-or-readonly"(){return require("./rules/react/checked-requires-onchange-or-readonly").checkedRequiresOnchangeOrReadonly},get"default-props-match-prop-types"(){return require("./rules/react/default-props-match-prop-types").defaultPropsMatchPropTypes},get"display-name"(){return require("./rules/react/display-name").displayName},get"jsx-handler-names"(){return require("./rules/react/jsx-handler-names").jsxHandlerNames},get"jsx-max-depth"(){return require("./rules/react/jsx-max-depth").jsxMaxDepth},get"jsx-no-bind"(){return require("./rules/react/jsx-no-bind").jsxNoBind},get"jsx-no-literals"(){return require("./rules/react/jsx-no-literals").jsxNoLiterals},get"no-adjacent-inline-elements"(){return require("./rules/react/no-adjacent-inline-elements").noAdjacentInlineElements},get"no-arrow-function-lifecycle"(){return require("./rules/react/no-arrow-function-lifecycle").noArrowFunctionLifecycle},get"no-did-mount-set-state"(){return require("./rules/react/no-did-mount-set-state").noDidMountSetState},get"no-did-update-set-state"(){return require("./rules/react/no-did-update-set-state").noDidUpdateSetState},get"no-invalid-html-attribute"(){return require("./rules/react/no-invalid-html-attribute").noInvalidHtmlAttribute},get"no-is-mounted"(){return require("./rules/react/no-is-mounted").noIsMounted},get"no-multi-comp"(){return require("./rules/react/no-multi-comp").noMultiComp},get"no-namespace"(){return require("./rules/react/no-namespace").noNamespace},get"no-object-type-as-default-prop"(){return require("./rules/react/no-object-type-as-default-prop").noObjectTypeAsDefaultProp},get"no-redundant-should-component-update"(){return require("./rules/react/no-redundant-should-component-update").noRedundantShouldComponentUpdate},get"no-render-return-value"(){return require("./rules/react/no-render-return-value").noRenderReturnValue},get"no-typos"(){return require("./rules/react/no-typos").noTypos},get"no-unescaped-entities"(){return require("./rules/react/no-unescaped-entities").noUnescapedEntities},get"prefer-es6-class"(){return require("./rules/react/prefer-es6-class").preferEs6Class},get"prefer-stateless-function"(){return require("./rules/react/prefer-stateless-function").preferStatelessFunction},get"prop-types"(){return require("./rules/react/prop-types").propTypes},get"react-in-jsx-scope"(){return require("./rules/react/react-in-jsx-scope").reactInJsxScope},get"require-default-props"(){return require("./rules/react/require-default-props").requireDefaultProps},get"require-render-return"(){return require("./rules/react/require-render-return").requireRenderReturn},get"sort-comp"(){return require("./rules/react/sort-comp").sortComp},get"state-in-constructor"(){return require("./rules/react/state-in-constructor").stateInConstructor},get"static-property-placement"(){return require("./rules/react/static-property-placement").staticPropertyPlacement},get"hooks-exhaustive-deps"(){return require("./rules/react/hooks-exhaustive-deps").hooksExhaustiveDeps},get"jsx-no-target-blank"(){return require("./rules/react/jsx-no-target-blank").jsxNoTargetBlank},get"jsx-no-script-url"(){return require("./rules/react/jsx-no-script-url").jsxNoScriptUrl},get"jsx-no-duplicate-props"(){return require("./rules/react/jsx-no-duplicate-props").jsxNoDuplicateProps},get"no-danger-with-children"(){return require("./rules/react/no-danger-with-children").noDangerWithChildren},get"no-deprecated"(){return require("./rules/react/no-deprecated").noDeprecated},get"jsx-no-comment-textnodes"(){return require("./rules/react/jsx-no-comment-textnodes").jsxNoCommentTextnodes},get"jsx-no-undef"(){return require("./rules/react/jsx-no-undef").jsxNoUndef},get"jsx-uses-react"(){return require("./rules/react/jsx-uses-react").jsxUsesReact},get"jsx-uses-vars"(){return require("./rules/react/jsx-uses-vars").jsxUsesVars},get"no-find-dom-node"(){return require("./rules/react/no-find-dom-node").noFindDomNode},get"no-unsafe"(){return require("./rules/react/no-unsafe").noUnsafe},get"void-dom-elements-no-children"(){return require("./rules/react/void-dom-elements-no-children").voidDomElementsNoChildren},get"react-class-to-hooks"(){return require("./rules/migration/react-class-to-hooks").reactClassToHooks},get"no-unnecessary-rerenders"(){return require("./rules/performance/no-unnecessary-rerenders").noUnnecessaryRerenders},get"react-render-optimization"(){return require("./rules/performance/react-render-optimization").reactRenderOptimization},get"react-no-inline-functions"(){return require("./rules/performance/react-no-inline-functions").reactNoInlineFunctions},get"no-default-test-id"(){return require("./rules/component-api/no-default-test-id").noDefaultTestId},get"require-data-slot"(){return require("./rules/component-api/require-data-slot").requireDataSlot},get"no-is-prefix-prop"(){return require("./rules/component-api/no-is-prefix-prop").noIsPrefixProp},get"no-inline-style"(){return require("./rules/component-api/no-inline-style").noInlineStyle},get"no-raw-color-literal"(){return require("./rules/component-api/no-raw-color-literal").noRawColorLiteral},get"no-arbitrary-token-class"(){return require("./rules/component-api/no-arbitrary-token-class").noArbitraryTokenClass},get"no-kind-prop-discriminator"(){return require("./rules/component-api/no-kind-prop-discriminator").noKindPropDiscriminator},get"no-wrapper-sub-component"(){return require("./rules/component-api/no-wrapper-sub-component").noWrapperSubComponent},get"react/required-attributes"(){return require("./rules/react/required-attributes").requiredAttributes},get"react/jsx-key"(){return require("./rules/react/jsx-key").jsxKey},get"react/no-direct-mutation-state"(){return require("./rules/react/no-direct-mutation-state").noDirectMutationState},get"react/require-optimization"(){return require("./rules/react/require-optimization").requireOptimization},get"react/no-set-state"(){return require("./rules/react/no-set-state").noSetState},get"react/no-this-in-sfc"(){return require("./rules/react/no-this-in-sfc").noThisInSfc},get"react/no-access-state-in-setstate"(){return require("./rules/react/no-access-state-in-setstate").noAccessStateInSetState},get"react/no-children-prop"(){return require("./rules/react/no-children-prop").noChildrenProp},get"react/no-danger"(){return require("./rules/react/no-danger").noDanger},get"react/no-string-refs"(){return require("./rules/react/no-string-refs").noStringRefs},get"react/no-unknown-property"(){return require("./rules/react/no-unknown-property").noUnknownProperty},get"react/checked-requires-onchange-or-readonly"(){return require("./rules/react/checked-requires-onchange-or-readonly").checkedRequiresOnchangeOrReadonly},get"react/default-props-match-prop-types"(){return require("./rules/react/default-props-match-prop-types").defaultPropsMatchPropTypes},get"react/display-name"(){return require("./rules/react/display-name").displayName},get"react/jsx-handler-names"(){return require("./rules/react/jsx-handler-names").jsxHandlerNames},get"react/jsx-max-depth"(){return require("./rules/react/jsx-max-depth").jsxMaxDepth},get"react/jsx-no-bind"(){return require("./rules/react/jsx-no-bind").jsxNoBind},get"react/jsx-no-literals"(){return require("./rules/react/jsx-no-literals").jsxNoLiterals},get"react/no-adjacent-inline-elements"(){return require("./rules/react/no-adjacent-inline-elements").noAdjacentInlineElements},get"react/no-arrow-function-lifecycle"(){return require("./rules/react/no-arrow-function-lifecycle").noArrowFunctionLifecycle},get"react/no-did-mount-set-state"(){return require("./rules/react/no-did-mount-set-state").noDidMountSetState},get"react/no-did-update-set-state"(){return require("./rules/react/no-did-update-set-state").noDidUpdateSetState},get"react/no-invalid-html-attribute"(){return require("./rules/react/no-invalid-html-attribute").noInvalidHtmlAttribute},get"react/no-is-mounted"(){return require("./rules/react/no-is-mounted").noIsMounted},get"react/no-multi-comp"(){return require("./rules/react/no-multi-comp").noMultiComp},get"react/no-namespace"(){return require("./rules/react/no-namespace").noNamespace},get"react/no-object-type-as-default-prop"(){return require("./rules/react/no-object-type-as-default-prop").noObjectTypeAsDefaultProp},get"react/no-redundant-should-component-update"(){return require("./rules/react/no-redundant-should-component-update").noRedundantShouldComponentUpdate},get"react/no-render-return-value"(){return require("./rules/react/no-render-return-value").noRenderReturnValue},get"react/no-typos"(){return require("./rules/react/no-typos").noTypos},get"react/no-unescaped-entities"(){return require("./rules/react/no-unescaped-entities").noUnescapedEntities},get"react/prefer-es6-class"(){return require("./rules/react/prefer-es6-class").preferEs6Class},get"react/prefer-stateless-function"(){return require("./rules/react/prefer-stateless-function").preferStatelessFunction},get"react/prop-types"(){return require("./rules/react/prop-types").propTypes},get"react/react-in-jsx-scope"(){return require("./rules/react/react-in-jsx-scope").reactInJsxScope},get"react/require-default-props"(){return require("./rules/react/require-default-props").requireDefaultProps},get"react/require-render-return"(){return require("./rules/react/require-render-return").requireRenderReturn},get"react/sort-comp"(){return require("./rules/react/sort-comp").sortComp},get"react/state-in-constructor"(){return require("./rules/react/state-in-constructor").stateInConstructor},get"react/static-property-placement"(){return require("./rules/react/static-property-placement").staticPropertyPlacement},get"react/hooks-exhaustive-deps"(){return require("./rules/react/hooks-exhaustive-deps").hooksExhaustiveDeps},get"react/jsx-no-target-blank"(){return require("./rules/react/jsx-no-target-blank").jsxNoTargetBlank},get"react/jsx-no-script-url"(){return require("./rules/react/jsx-no-script-url").jsxNoScriptUrl},get"react/jsx-no-duplicate-props"(){return require("./rules/react/jsx-no-duplicate-props").jsxNoDuplicateProps},get"react/no-danger-with-children"(){return require("./rules/react/no-danger-with-children").noDangerWithChildren},get"react/no-deprecated"(){return require("./rules/react/no-deprecated").noDeprecated},get"react/jsx-no-comment-textnodes"(){return require("./rules/react/jsx-no-comment-textnodes").jsxNoCommentTextnodes},get"react/jsx-no-undef"(){return require("./rules/react/jsx-no-undef").jsxNoUndef},get"react/jsx-uses-react"(){return require("./rules/react/jsx-uses-react").jsxUsesReact},get"react/jsx-uses-vars"(){return require("./rules/react/jsx-uses-vars").jsxUsesVars},get"react/no-find-dom-node"(){return require("./rules/react/no-find-dom-node").noFindDomNode},get"react/no-unsafe"(){return require("./rules/react/no-unsafe").noUnsafe},get"react/void-dom-elements-no-children"(){return require("./rules/react/void-dom-elements-no-children").voidDomElementsNoChildren},get"migration/react-class-to-hooks"(){return require("./rules/migration/react-class-to-hooks").reactClassToHooks},get"performance/no-unnecessary-rerenders"(){return require("./rules/performance/no-unnecessary-rerenders").noUnnecessaryRerenders},get"performance/react-render-optimization"(){return require("./rules/performance/react-render-optimization").reactRenderOptimization},get"performance/react-no-inline-functions"(){return require("./rules/performance/react-no-inline-functions").reactNoInlineFunctions},get"component-api/no-default-test-id"(){return require("./rules/component-api/no-default-test-id").noDefaultTestId},get"component-api/require-data-slot"(){return require("./rules/component-api/require-data-slot").requireDataSlot},get"component-api/no-is-prefix-prop"(){return require("./rules/component-api/no-is-prefix-prop").noIsPrefixProp},get"component-api/no-inline-style"(){return require("./rules/component-api/no-inline-style").noInlineStyle},get"component-api/no-raw-color-literal"(){return require("./rules/component-api/no-raw-color-literal").noRawColorLiteral},get"component-api/no-arbitrary-token-class"(){return require("./rules/component-api/no-arbitrary-token-class").noArbitraryTokenClass},get"component-api/no-kind-prop-discriminator"(){return require("./rules/component-api/no-kind-prop-discriminator").noKindPropDiscriminator},get"component-api/no-wrapper-sub-component"(){return require("./rules/component-api/no-wrapper-sub-component").noWrapperSubComponent}};(0,eslint_devkit_1.withCanonicalDocsUrls)("plugin-react-features",exports.rules);exports.plugin={meta:{name:"eslint-plugin-react-features",version:"2.0.4"},rules:exports.rules};exports.configs={flagship:{plugins:{"react-features":exports.plugin},rules:{"react-features/hooks-exhaustive-deps":"error"}},recommended:{plugins:{"react-features":exports.plugin},rules:{"react-features/jsx-key":"error","react-features/no-children-prop":"warn","react-features/no-danger":"warn","react-features/no-string-refs":"error","react-features/no-unknown-property":"error","react-features/hooks-exhaustive-deps":"warn","react-features/jsx-no-target-blank":"error","react-features/jsx-no-script-url":"error","react-features/jsx-no-duplicate-props":"error","react-features/no-danger-with-children":"error","react-features/no-deprecated":"warn"}},componentApi:{plugins:{"react-features":exports.plugin},rules:{"react-features/component-api/no-default-test-id":"error","react-features/component-api/require-data-slot":"warn","react-features/component-api/no-is-prefix-prop":"warn","react-features/component-api/no-inline-style":"warn","react-features/component-api/no-raw-color-literal":"warn","react-features/component-api/no-arbitrary-token-class":"warn","react-features/component-api/no-kind-prop-discriminator":"warn","react-features/component-api/no-wrapper-sub-component":"warn"}}};exports.default=exports.plugin;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.displayName=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const react_api_1=require("../../utils/react-api");const eslint_devkit_2=require("@interlace/eslint-devkit");exports.displayName=(0,eslint_devkit_1.createRule)({name:"display-name",meta:{interop:{runtimes:["eslint","oxlint"],nativeEquivalent:"react/display-name"},type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/display-name.md",description:"Enforce component display names"},schema:[],messages:{displayName:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Anonymous Component",description:'Component has no name React can infer, so it renders as "Anonymous" in DevTools and stack traces',severity:"LOW",fix:"Assign it to a named variable, name the function, or set a displayName",documentationLink:"https://react.dev/learn/components-and-props#displaying-a-custom-component"})}},defaultOptions:[],createOnce(context){const report=node=>{context.report({node,messageId:"displayName"})};const scopeOf=node=>context.sourceCode.getScope(node);const renders=node=>containsRender(node,scopeOf);return{ExportDefaultDeclaration(node){const declaration=node.declaration;if(!isFunctionNode(declaration)||declaration.id)return;if(renders(declaration.body))report(declaration)},CallExpression(node){if(!isReactWrapperCall(node,scopeOf)||hasInferableName(node,scopeOf))return;const inner=node.arguments[0];if(inner&&isFunctionNode(inner)&&!inner.id&&renders(inner.body)){report(inner)}},"ClassDeclaration, ClassExpression"(node){if(node.id||!(0,react_api_1.extendsReactComponent)(node,scopeOf(node)))return;if(hasDisplayNameProperty(node)||hasInferableName(node,scopeOf))return;report(node)}}}});function hasInferableName(node,scopeOf){let current=node.parent;while(current&&isReactWrapperCall(current,scopeOf)){current=current.parent}switch(current?.type){case eslint_devkit_1.AST_NODE_TYPES.VariableDeclarator:return current.id.type===eslint_devkit_1.AST_NODE_TYPES.Identifier;case eslint_devkit_1.AST_NODE_TYPES.AssignmentExpression:case eslint_devkit_1.AST_NODE_TYPES.Property:case eslint_devkit_1.AST_NODE_TYPES.PropertyDefinition:return true;default:return false}}function isReactWrapperCall(node,scopeOf){if(node.type!==eslint_devkit_1.AST_NODE_TYPES.CallExpression)return false;const scope=scopeOf(node);return(0,react_api_1.isReactApi)(node.callee,scope,"memo")||(0,react_api_1.isReactApi)(node.callee,scope,"forwardRef")}function isFunctionNode(node){return node.type===eslint_devkit_1.AST_NODE_TYPES.FunctionDeclaration||node.type===eslint_devkit_1.AST_NODE_TYPES.FunctionExpression||node.type===eslint_devkit_1.AST_NODE_TYPES.ArrowFunctionExpression}function hasDisplayNameProperty(node){for(const member of node.body.body){if(member.type===eslint_devkit_1.AST_NODE_TYPES.PropertyDefinition&&member.key.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&member.key.name==="displayName"&&member.static){return true}}return false}function containsRender(node,scopeOf){if(node.type===eslint_devkit_1.AST_NODE_TYPES.JSXElement||node.type===eslint_devkit_1.AST_NODE_TYPES.JSXFragment||node.type===eslint_devkit_1.AST_NODE_TYPES.CallExpression&&(0,react_api_1.isReactApi)(node.callee,scopeOf(node),"createElement")){return true}for(const key in node){if(key==="parent")continue;const child=node[key];if(!child||typeof child!=="object")continue;if(Array.isArray(child)){for(const item of child){if(item&&typeof item==="object"&&"type"in item){if(containsRender(item,scopeOf))return true}}}else if("type"in child){if(containsRender(child,scopeOf))return true}}return false}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.displayName=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const function_component_1=require("../../utils/function-component");const react_api_1=require("../../utils/react-api");const react_settings_1=require("../../utils/react-settings");const eslint_devkit_2=require("@interlace/eslint-devkit");exports.displayName=(0,eslint_devkit_1.createRule)({name:"display-name",meta:{interop:{runtimes:["eslint","oxlint"],nativeEquivalent:"react/display-name"},type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/display-name.md",description:"Enforce component display names"},schema:[{type:"object",properties:{ignoreTranspilerName:{type:"boolean",default:false},checkContextObjects:{type:"boolean",default:false}},additionalProperties:false}],messages:{contextDisplayName:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Unnamed Context",description:'Context object has no displayName, so DevTools shows it as "Context.Provider"',severity:"LOW",fix:'Set `MyContext.displayName = "MyContext"` after creating it',documentationLink:"https://react.dev/reference/react/createContext#context-displayname"}),displayName:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Anonymous Component",description:'Component has no name React can infer, so it renders as "Anonymous" in DevTools and stack traces',severity:"LOW",fix:"Assign it to a named variable, name the function, or set a displayName",documentationLink:"https://react.dev/learn/components-and-props#displaying-a-custom-component"})}},defaultOptions:[{}],createOnce(context,options){let ignoreTranspilerName=false;let checkContextObjects=false;let pragma="React";let createClass="createReactClass";let assigned;let unnamed;let contexts;let reported;const report=node=>{reported.add(node);context.report({node,messageId:"displayName"})};const scopeOf=node=>context.sourceCode.getScope(node);const renders=node=>containsRender(node,scopeOf);const isCreateClassCall=node=>{const callee=node.callee;return callee.type===eslint_devkit_1.AST_NODE_TYPES.Identifier?callee.name===createClass:callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&callee.object.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&callee.object.name===pragma&&(0,eslint_devkit_1.propertyName)(callee)===createClass};const isCreateContext=node=>node.type===eslint_devkit_1.AST_NODE_TYPES.CallExpression&&(0,react_api_1.isReactApi)(node.callee,scopeOf(node),"createContext");const needsExplicitName=node=>{unnamed.push({node,ref:referenceText(node,scopeOf)})};return{before(){const[config]=options();ignoreTranspilerName=config?.ignoreTranspilerName??false;checkContextObjects=(config?.checkContextObjects??false)&&(0,react_settings_1.reactVersionAtLeast)(context,"16.3.0");pragma=(0,react_settings_1.getPragma)(context);createClass=(0,react_settings_1.getCreateClassPragma)(context);assigned=new Set;unnamed=[];contexts=[];reported=new WeakSet},AssignmentExpression(node){if(node.left.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&(0,eslint_devkit_1.propertyName)(node.left)==="displayName"){assigned.add(context.sourceCode.getText(node.left.object))}else if(checkContextObjects&&node.left.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&isCreateContext(node.right)){contexts.push({node:node.right,name:node.left.name})}},VariableDeclarator(node){if(checkContextObjects&&node.id.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.init&&isCreateContext(node.init)){contexts.push({node:node.init,name:node.id.name})}},"Program:exit"(){for(const{node,ref}of unnamed){if(reported.has(node)||ref!==null&&assigned.has(ref))continue;report(node)}for(const{node,name}of contexts){if(!assigned.has(name)){context.report({node,messageId:"contextDisplayName"})}}},ExportDefaultDeclaration(node){const declaration=node.declaration;if(!isFunctionNode(declaration)||declaration.id)return;if(renders(declaration.body))report(declaration)},CallExpression(node){if(ignoreTranspilerName&&isCreateClassCall(node)){const spec=node.arguments[0];const named=spec?.type===eslint_devkit_1.AST_NODE_TYPES.ObjectExpression&&spec.properties.some(p=>p.type===eslint_devkit_1.AST_NODE_TYPES.Property&&(0,eslint_devkit_1.objectKeyName)(p)==="displayName");if(!named)needsExplicitName(node);return}if(!isReactWrapperCall(node,scopeOf)||hasInferableName(node,scopeOf))return;const inner=node.arguments[0];if(inner&&isFunctionNode(inner)&&!inner.id&&renders(inner.body)){report(inner)}},"ClassDeclaration, ClassExpression"(node){if(!(0,react_api_1.extendsReactComponent)(node,scopeOf(node)))return;if(hasDisplayNameProperty(node))return;if(node.id){if(ignoreTranspilerName)needsExplicitName(node);return}if(hasInferableName(node,scopeOf)){if(ignoreTranspilerName)needsExplicitName(node);return}report(node)},"FunctionDeclaration, FunctionExpression, ArrowFunctionExpression"(node){if(!ignoreTranspilerName)return;const parent=node.parent;const method=parent.type===eslint_devkit_1.AST_NODE_TYPES.Property&&parent.value===node&&/^[A-Z]/.test((0,eslint_devkit_1.objectKeyName)(parent)??"")&&(0,function_component_1.returnsJsx)(node);if(method||(0,function_component_1.isFunctionComponent)(node,context.sourceCode)){needsExplicitName(node)}}}}});function referenceText(node,scopeOf){if((node.type===eslint_devkit_1.AST_NODE_TYPES.FunctionDeclaration||node.type===eslint_devkit_1.AST_NODE_TYPES.ClassDeclaration)&&node.id){return node.id.name}const path=[];let current=node;for(;;){const parent=current.parent;if(isReactWrapperCall(parent,scopeOf)){current=parent}else if(parent.type===eslint_devkit_1.AST_NODE_TYPES.VariableDeclarator&&parent.id.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){return[parent.id.name,...path].join(".")}else if(parent.type===eslint_devkit_1.AST_NODE_TYPES.Property&&parent.value===current&&parent.parent.type===eslint_devkit_1.AST_NODE_TYPES.ObjectExpression){const key=(0,eslint_devkit_1.objectKeyName)(parent);if(key===null)return null;path.unshift(key);current=parent.parent}else{return null}}}function hasInferableName(node,scopeOf){let current=node.parent;while(current&&isReactWrapperCall(current,scopeOf)){current=current.parent}switch(current?.type){case eslint_devkit_1.AST_NODE_TYPES.VariableDeclarator:return current.id.type===eslint_devkit_1.AST_NODE_TYPES.Identifier;case eslint_devkit_1.AST_NODE_TYPES.AssignmentExpression:case eslint_devkit_1.AST_NODE_TYPES.Property:case eslint_devkit_1.AST_NODE_TYPES.PropertyDefinition:return true;default:return false}}function isReactWrapperCall(node,scopeOf){if(node.type!==eslint_devkit_1.AST_NODE_TYPES.CallExpression)return false;const scope=scopeOf(node);return(0,react_api_1.isReactApi)(node.callee,scope,"memo")||(0,react_api_1.isReactApi)(node.callee,scope,"forwardRef")}function isFunctionNode(node){return node.type===eslint_devkit_1.AST_NODE_TYPES.FunctionDeclaration||node.type===eslint_devkit_1.AST_NODE_TYPES.FunctionExpression||node.type===eslint_devkit_1.AST_NODE_TYPES.ArrowFunctionExpression}function hasDisplayNameProperty(node){return node.body.body.some(member=>(member.type===eslint_devkit_1.AST_NODE_TYPES.PropertyDefinition||member.type===eslint_devkit_1.AST_NODE_TYPES.MethodDefinition)&&member.static&&(0,eslint_devkit_1.objectKeyName)(member)==="displayName")}function containsRender(node,scopeOf){if(node.type===eslint_devkit_1.AST_NODE_TYPES.JSXElement||node.type===eslint_devkit_1.AST_NODE_TYPES.JSXFragment||node.type===eslint_devkit_1.AST_NODE_TYPES.CallExpression&&(0,react_api_1.isReactApi)(node.callee,scopeOf(node),"createElement")){return true}for(const key in node){if(key==="parent")continue;const child=node[key];if(!child||typeof child!=="object")continue;if(Array.isArray(child)){for(const item of child){if(item&&typeof item==="object"&&"type"in item){if(containsRender(item,scopeOf))return true}}}else if("type"in child){if(containsRender(child,scopeOf))return true}}return false}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.hooksExhaustiveDeps=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const react_api_1=require("../../utils/react-api");const eslint_devkit_2=require("@interlace/eslint-devkit");const SKIP_KEYS=new Set(["parent","loc","range","tokens","comments","type"]);const CHILD_KEYS_CACHE=new Map;function getChildKeys(node){const cached=CHILD_KEYS_CACHE.get(node.type);if(cached)return cached;const keys=[];for(const key of Object.keys(node)){if(SKIP_KEYS.has(key))continue;const v=node[key];if(v&&typeof v==="object"){keys.push(key)}}CHILD_KEYS_CACHE.set(node.type,keys);return keys}const HOOKS_WITH_DEPS=new Set(["useEffect","useLayoutEffect","useCallback","useMemo","useImperativeHandle"]);exports.hooksExhaustiveDeps=(0,eslint_devkit_1.createRule)({name:"hooks-exhaustive-deps",meta:{interop:{runtimes:["eslint","oxlint"]},type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/hooks-exhaustive-deps.md",description:"Enforce exhaustive dependencies in React hooks to prevent stale closures",confidence:"high"},hasSuggestions:true,messages:{missingDep:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Missing Hook Dependency",description:"React Hook {{hookName}} has missing dependencies: {{deps}}",severity:"HIGH",fix:"Add missing dependencies to the dependency array or memoize values with useMemo/useCallback",documentationLink:"https://react.dev/reference/react/useEffect#specifying-reactive-dependencies"}),extraDep:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Unnecessary Hook Dependency",description:"React Hook {{hookName}} has unnecessary dependency: {{dep}}",severity:"MEDIUM",fix:"Remove the unnecessary dependency from the array - it never changes or is not used in the effect",documentationLink:"https://react.dev/reference/react/useEffect#removing-unnecessary-dependencies"}),unnecessaryDep:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.INFO,issueName:"Unnecessary Dependency",description:"The dependency {{dep}} is stable and never changes",severity:"LOW",fix:"Consider removing stable dependencies like setState functions or refs",documentationLink:"https://react.dev/reference/react/useEffect#removing-unnecessary-dependencies"}),suggestAddDep:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.INFO,issueName:"Add Missing Dependency",description:"Add {{dep}} to dependency array",severity:"LOW",fix:"Add the missing dependency to prevent stale closures",documentationLink:"https://react.dev/reference/react/useEffect#specifying-reactive-dependencies"}),suggestRemoveDep:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.INFO,issueName:"Remove Unnecessary Dependency",description:"Remove {{dep}} from dependency array",severity:"LOW",fix:"Remove the unnecessary dependency",documentationLink:"https://react.dev/reference/react/useEffect#removing-unnecessary-dependencies"}),depsNotArrayLiteral:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Non-literal Dependency Array",description:"React Hook {{hookName}} was passed a dependency list that is not an array literal. This means we cannot statically verify whether you have passed the correct dependencies.",severity:"HIGH",fix:"Replace the variable with an inline array literal: [dep1, dep2]. If you need dynamic deps, refactor to compute them inside the hook callback instead.",documentationLink:"https://react.dev/reference/react/useEffect#specifying-reactive-dependencies"})},schema:[{type:"object",properties:{additionalHooks:{type:"string",description:'Regex pattern for additional hooks to check (e.g., "useMyCustomHook")'},enableDangerousAutofixThisMayCauseInfiniteLoops:{type:"boolean",default:false,description:"Enable autofix (warning: may cause infinite loops)"}},additionalProperties:false}]},defaultOptions:[{}],createOnce(context){let additionalHooksPattern;function checkedHookName(node){const callee=node.callee;const found=(0,react_api_1.reactExport)(callee,context.sourceCode.getScope(node));if(found&&HOOKS_WITH_DEPS.has(found.name))return found.name;if(callee.type==="Identifier"&&additionalHooksPattern?.test(callee.name)){return callee.name}return null}function extractLocallyDeclaredIdentifiers(node){const declared=new Set;const visited=new WeakSet;function visit(n){if(visited.has(n))return;visited.add(n);if(n.type==="VariableDeclaration"){for(const declarator of n.declarations){if(declarator.id.type==="Identifier"){declared.add(declarator.id.name)}else if(declarator.id.type==="ObjectPattern"){for(const prop of declarator.id.properties){if(prop.type==="Property"&&prop.value.type==="Identifier"){declared.add(prop.value.name)}}}else if(declarator.id.type==="ArrayPattern"){for(const element of declarator.id.elements){if(element&&element.type==="Identifier"){declared.add(element.name)}}}}}if(n.type==="FunctionDeclaration"&&n.id){declared.add(n.id.name)}if(n.type==="ArrowFunctionExpression"||n.type==="FunctionExpression"||n.type==="FunctionDeclaration"){const collectFromPattern=param=>{if(param.type==="Identifier"){declared.add(param.name)}else if(param.type==="ObjectPattern"){for(const prop of param.properties){if(prop.type==="Property"&&prop.value.type==="Identifier"){declared.add(prop.value.name)}else if(prop.type==="RestElement"&&prop.argument.type==="Identifier"){declared.add(prop.argument.name)}}}else if(param.type==="ArrayPattern"){for(const el of param.elements){if(el&&el.type==="Identifier")declared.add(el.name)}}else if(param.type==="RestElement"&&param.argument.type==="Identifier"){declared.add(param.argument.name)}else if(param.type==="AssignmentPattern"&&param.left.type==="Identifier"){declared.add(param.left.name)}};for(const param of n.params??[])collectFromPattern(param)}const keys=getChildKeys(n);for(let i=0;i<keys.length;i++){const child=n[keys[i]];if(Array.isArray(child)){for(let j=0;j<child.length;j++){const c=child[j];if(c&&typeof c==="object"&&"type"in c){visit(c)}}}else if(child&&typeof child==="object"&&"type"in child){visit(child)}}}visit(node);return declared}function extractUsedIdentifiers(node){const used=new Set;const visited=new WeakSet;function visit(n,isPropertyKey=false){if(visited.has(n)){return}visited.add(n);if(n.type==="MemberExpression"){visit(n.object,false);if(n.computed&&n.property){visit(n.property,false)}return}if(n.type==="CallExpression"){if(n.callee){visit(n.callee,false)}if(n.arguments){n.arguments.forEach(arg=>visit(arg,false))}return}if(n.type==="TSTypeAnnotation"||n.type==="TSTypeParameterInstantiation"||n.type==="TSTypeReference"){return}if(n.type==="Identifier"&&!isPropertyKey){used.add(n.name)}const keys=getChildKeys(n);for(let i=0;i<keys.length;i++){const child=n[keys[i]];if(Array.isArray(child)){for(let j=0;j<child.length;j++){const c=child[j];if(c&&typeof c==="object"&&"type"in c){visit(c,false)}}}else if(child&&typeof child==="object"&&"type"in child){visit(child,false)}}}visit(node);return used}function extractDependencies(depsArray){const deps=new Set;for(const element of depsArray.elements){if(element?.type==="Identifier"){deps.add(element.name)}else if(element?.type==="MemberExpression"&&element.object.type==="Identifier"){const sourceCode=context.sourceCode;deps.add(sourceCode.getText(element))}}return deps}function isStableReference(name,scope){for(let current=scope;current;current=current.upper){const variable=current.variables.find(v=>v.name===name);if(!variable)continue;const owner=variable.scope.type;if(owner==="module"||owner==="global")return true;return variable.defs.some(def=>isStableDefinition(def,name))}return true}function isStableDefinition(def,name){if(def.type!=="Variable")return false;const declarator=def.node;const init=declarator.init;if(!init||init.type!=="CallExpression")return false;const hookName=(0,react_api_1.reactExport)(init.callee,context.sourceCode.getScope(declarator))?.name??"";if(hookName==="useRef")return declarator.id.type==="Identifier";if(hookName==="useState"||hookName==="useReducer"){if(declarator.id.type!=="ArrayPattern")return false;const second=declarator.id.elements[1];return second?.type==="Identifier"&&second.name===name}return false}function filterReactiveDeps(used,scope){const reactive=new Set;const nonReactive=new Set(["undefined","null","true","false","console","window","document","Math","JSON","Object","Array","String","Number","Boolean","Date","Promise","Error","Map","Set","WeakMap","WeakSet","Symbol","Reflect","Proxy","Intl","navigator","localStorage","sessionStorage","fetch","setTimeout","setInterval","clearTimeout","clearInterval","requestAnimationFrame","cancelAnimationFrame"]);for(const name of used){if(!nonReactive.has(name)&&!isStableReference(name,scope)){reactive.add(name)}}return reactive}return{before(){const options=context.options[0]||{};additionalHooksPattern=options.additionalHooks?new RegExp(options.additionalHooks):null},CallExpression(node){const hookName=checkedHookName(node);if(hookName===null){return}const offset=hookName==="useImperativeHandle"?1:0;const args=node.arguments.slice(offset);if(args.length===0){return}const callback=args[0];if(callback.type!=="ArrowFunctionExpression"&&callback.type!=="FunctionExpression"){return}const depsArg=args[1];if(!depsArg){return}const isTSAsArrayExpression=depsArg.type==="TSAsExpression"&&depsArg.expression?.type==="ArrayExpression";const isArrayExpression=depsArg.type==="ArrayExpression";if(!isArrayExpression&&!isTSAsArrayExpression){context.report({node:depsArg,messageId:"depsNotArrayLiteral",data:{hookName}});return}const depsArrayNode=isTSAsArrayExpression?depsArg.expression:depsArg;const usedInCallback=extractUsedIdentifiers(callback.body);const locallyDeclared=extractLocallyDeclaredIdentifiers(callback);const externalUsed=new Set;for(const id of usedInCallback){if(!locallyDeclared.has(id)){externalUsed.add(id)}}const callbackScope=context.sourceCode.getScope(callback);const reactiveDeps=filterReactiveDeps(externalUsed,callbackScope);const declaredDeps=extractDependencies(depsArrayNode);const missingDeps=[];for(const dep of reactiveDeps){const listed=declaredDeps.has(dep)||[...declaredDeps].some(d=>d.startsWith(`${dep}.`));if(!listed){missingDeps.push(dep)}}const isEffect=hookName!=="useCallback"&&hookName!=="useMemo";const extraDeps=[];for(const dep of declaredDeps){if(!usedInCallback.has(dep)&&!dep.includes(".")&&(!isEffect||isStableReference(dep,callbackScope))){extraDeps.push(dep)}}if(missingDeps.length>0){context.report({node:depsArg,messageId:"missingDep",data:{hookName,deps:missingDeps.join(", ")},suggest:missingDeps.map(dep=>({messageId:"suggestAddDep",data:{dep},fix(fixer){const lastElement=depsArrayNode.elements[depsArrayNode.elements.length-1];if(lastElement){return fixer.insertTextAfter(lastElement,`, ${dep}`)}else{return fixer.insertTextAfterRange([depsArrayNode.range[0]+1,depsArrayNode.range[0]+1],dep)}}}))})}for(const dep of extraDeps){context.report({node:depsArg,messageId:"extraDep",data:{hookName,dep},suggest:[{messageId:"suggestRemoveDep",data:{dep},fix(fixer){const element=depsArrayNode.elements.find(el=>el?.type==="Identifier"&&el.name===dep);if(element){const index=depsArrayNode.elements.indexOf(element);const isLast=index===depsArrayNode.elements.length-1;const isFirst=index===0;if(isFirst&&depsArrayNode.elements.length>1){const nextElement=depsArrayNode.elements[1];if(nextElement){return fixer.removeRange([element.range[0],nextElement.range[0]])}}else if(isLast&&index>0){const prevElement=depsArrayNode.elements[index-1];if(prevElement){return fixer.removeRange([prevElement.range[1],element.range[1]])}}return fixer.remove(element)}return null}}]})}}}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.hooksExhaustiveDeps=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const react_api_1=require("../../utils/react-api");const eslint_devkit_2=require("@interlace/eslint-devkit");const SKIP_KEYS=new Set(["parent","loc","range","tokens","comments","type"]);function getChildKeys(node,visitorKeys){const known=visitorKeys[node.type];if(known)return known;return Object.keys(node).filter(key=>!SKIP_KEYS.has(key))}const HOOKS_WITH_DEPS=new Set(["useEffect","useLayoutEffect","useCallback","useMemo","useImperativeHandle"]);exports.hooksExhaustiveDeps=(0,eslint_devkit_1.createRule)({name:"hooks-exhaustive-deps",meta:{interop:{runtimes:["eslint","oxlint"]},type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/hooks-exhaustive-deps.md",description:"Enforce exhaustive dependencies in React hooks to prevent stale closures",confidence:"high"},hasSuggestions:true,messages:{missingDep:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Missing Hook Dependency",description:"React Hook {{hookName}} has missing dependencies: {{deps}}",severity:"HIGH",fix:"Add missing dependencies to the dependency array or memoize values with useMemo/useCallback",documentationLink:"https://react.dev/reference/react/useEffect#specifying-reactive-dependencies"}),extraDep:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Unnecessary Hook Dependency",description:"React Hook {{hookName}} has unnecessary dependency: {{dep}}",severity:"MEDIUM",fix:"Remove the unnecessary dependency from the array - it never changes or is not used in the effect",documentationLink:"https://react.dev/reference/react/useEffect#removing-unnecessary-dependencies"}),unnecessaryDep:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.INFO,issueName:"Unnecessary Dependency",description:"The dependency {{dep}} is stable and never changes",severity:"LOW",fix:"Consider removing stable dependencies like setState functions or refs",documentationLink:"https://react.dev/reference/react/useEffect#removing-unnecessary-dependencies"}),suggestAddDep:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.INFO,issueName:"Add Missing Dependency",description:"Add {{dep}} to dependency array",severity:"LOW",fix:"Add the missing dependency to prevent stale closures",documentationLink:"https://react.dev/reference/react/useEffect#specifying-reactive-dependencies"}),suggestRemoveDep:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.INFO,issueName:"Remove Unnecessary Dependency",description:"Remove {{dep}} from dependency array",severity:"LOW",fix:"Remove the unnecessary dependency",documentationLink:"https://react.dev/reference/react/useEffect#removing-unnecessary-dependencies"}),depsNotArrayLiteral:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Non-literal Dependency Array",description:"React Hook {{hookName}} was passed a dependency list that is not an array literal. This means we cannot statically verify whether you have passed the correct dependencies.",severity:"HIGH",fix:"Replace the variable with an inline array literal: [dep1, dep2]. If you need dynamic deps, refactor to compute them inside the hook callback instead.",documentationLink:"https://react.dev/reference/react/useEffect#specifying-reactive-dependencies"})},schema:[{type:"object",properties:{additionalHooks:{type:"string",description:'Regex pattern for additional hooks to check (e.g., "useMyCustomHook")'},enableDangerousAutofixThisMayCauseInfiniteLoops:{type:"boolean",default:false,description:"Enable autofix (warning: may cause infinite loops)"}},additionalProperties:false}]},defaultOptions:[{}],createOnce(context){let additionalHooksPattern;function checkedHookName(node){const callee=node.callee;const found=(0,react_api_1.reactExport)(callee,context.sourceCode.getScope(node));if(found&&HOOKS_WITH_DEPS.has(found.name))return found.name;if(callee.type==="Identifier"&&additionalHooksPattern?.test(callee.name)){return callee.name}return null}function extractLocallyDeclaredIdentifiers(node){const declared=new Set;const visited=new WeakSet;function visit(n){if(visited.has(n))return;visited.add(n);if(n.type==="VariableDeclaration"){for(const declarator of n.declarations){if(declarator.id.type==="Identifier"){declared.add(declarator.id.name)}else if(declarator.id.type==="ObjectPattern"){for(const prop of declarator.id.properties){if(prop.type==="Property"&&prop.value.type==="Identifier"){declared.add(prop.value.name)}}}else if(declarator.id.type==="ArrayPattern"){for(const element of declarator.id.elements){if(element&&element.type==="Identifier"){declared.add(element.name)}}}}}if(n.type==="FunctionDeclaration"&&n.id){declared.add(n.id.name)}if(n.type==="ArrowFunctionExpression"||n.type==="FunctionExpression"||n.type==="FunctionDeclaration"){const collectFromPattern=param=>{if(param.type==="Identifier"){declared.add(param.name)}else if(param.type==="ObjectPattern"){for(const prop of param.properties){if(prop.type==="Property"&&prop.value.type==="Identifier"){declared.add(prop.value.name)}else if(prop.type==="RestElement"&&prop.argument.type==="Identifier"){declared.add(prop.argument.name)}}}else if(param.type==="ArrayPattern"){for(const el of param.elements){if(el&&el.type==="Identifier")declared.add(el.name)}}else if(param.type==="RestElement"&&param.argument.type==="Identifier"){declared.add(param.argument.name)}else if(param.type==="AssignmentPattern"&&param.left.type==="Identifier"){declared.add(param.left.name)}};for(const param of n.params??[])collectFromPattern(param)}const keys=getChildKeys(n,context.sourceCode.visitorKeys??{});for(let i=0;i<keys.length;i++){const child=n[keys[i]];if(Array.isArray(child)){for(let j=0;j<child.length;j++){const c=child[j];if(c&&typeof c==="object"&&"type"in c){visit(c)}}}else if(child&&typeof child==="object"&&"type"in child){visit(child)}}}visit(node);return declared}function extractUsedIdentifiers(node){const used=new Set;const visited=new WeakSet;function visit(n,isPropertyKey=false){if(visited.has(n)){return}visited.add(n);if(n.type==="MemberExpression"){visit(n.object,false);if(n.computed&&n.property){visit(n.property,false)}return}if(n.type==="CallExpression"){if(n.callee){visit(n.callee,false)}if(n.arguments){n.arguments.forEach(arg=>visit(arg,false))}return}if(n.type==="TSTypeAnnotation"||n.type==="TSTypeParameterInstantiation"||n.type==="TSTypeReference"){return}if(n.type==="Identifier"&&!isPropertyKey){used.add(n.name)}const keys=getChildKeys(n,context.sourceCode.visitorKeys??{});for(let i=0;i<keys.length;i++){const child=n[keys[i]];if(Array.isArray(child)){for(let j=0;j<child.length;j++){const c=child[j];if(c&&typeof c==="object"&&"type"in c){visit(c,false)}}}else if(child&&typeof child==="object"&&"type"in child){visit(child,false)}}}visit(node);return used}function extractDependencies(depsArray){const deps=new Set;for(const element of depsArray.elements){if(element?.type==="Identifier"){deps.add(element.name)}else if(element?.type==="MemberExpression"&&element.object.type==="Identifier"){const sourceCode=context.sourceCode;deps.add(sourceCode.getText(element))}}return deps}function isStableReference(name,scope){for(let current=scope;current;current=current.upper){const variable=current.variables.find(v=>v.name===name);if(!variable)continue;const owner=variable.scope.type;if(owner==="module"||owner==="global")return true;return variable.defs.some(def=>isStableDefinition(def,name))}return true}function isStableDefinition(def,name){if(def.type!=="Variable")return false;const declarator=def.node;const init=declarator.init;if(!init||init.type!=="CallExpression")return false;const hookName=(0,react_api_1.reactExport)(init.callee,context.sourceCode.getScope(declarator))?.name??"";if(hookName==="useRef")return declarator.id.type==="Identifier";if(hookName==="useState"||hookName==="useReducer"){if(declarator.id.type!=="ArrayPattern")return false;const second=declarator.id.elements[1];return second?.type==="Identifier"&&second.name===name}return false}function filterReactiveDeps(used,scope){const reactive=new Set;const nonReactive=new Set(["undefined","null","true","false","console","window","document","Math","JSON","Object","Array","String","Number","Boolean","Date","Promise","Error","Map","Set","WeakMap","WeakSet","Symbol","Reflect","Proxy","Intl","navigator","localStorage","sessionStorage","fetch","setTimeout","setInterval","clearTimeout","clearInterval","requestAnimationFrame","cancelAnimationFrame"]);for(const name of used){if(!nonReactive.has(name)&&!isStableReference(name,scope)){reactive.add(name)}}return reactive}return{before(){const options=context.options[0]||{};additionalHooksPattern=options.additionalHooks?new RegExp(options.additionalHooks):null},CallExpression(node){const hookName=checkedHookName(node);if(hookName===null){return}const offset=hookName==="useImperativeHandle"?1:0;const args=node.arguments.slice(offset);if(args.length===0){return}const callback=args[0];if(callback.type!=="ArrowFunctionExpression"&&callback.type!=="FunctionExpression"){return}const depsArg=args[1];if(!depsArg){return}const isTSAsArrayExpression=depsArg.type==="TSAsExpression"&&depsArg.expression?.type==="ArrayExpression";const isArrayExpression=depsArg.type==="ArrayExpression";if(!isArrayExpression&&!isTSAsArrayExpression){context.report({node:depsArg,messageId:"depsNotArrayLiteral",data:{hookName}});return}const depsArrayNode=isTSAsArrayExpression?depsArg.expression:depsArg;const usedInCallback=extractUsedIdentifiers(callback.body);const locallyDeclared=extractLocallyDeclaredIdentifiers(callback);const externalUsed=new Set;for(const id of usedInCallback){if(!locallyDeclared.has(id)){externalUsed.add(id)}}const callbackScope=context.sourceCode.getScope(callback);const reactiveDeps=filterReactiveDeps(externalUsed,callbackScope);const declaredDeps=extractDependencies(depsArrayNode);const missingDeps=[];for(const dep of reactiveDeps){const listed=declaredDeps.has(dep)||[...declaredDeps].some(d=>d.startsWith(`${dep}.`));if(!listed){missingDeps.push(dep)}}const isEffect=hookName!=="useCallback"&&hookName!=="useMemo";const extraDeps=[];for(const dep of declaredDeps){if(!usedInCallback.has(dep)&&!dep.includes(".")&&(!isEffect||isStableReference(dep,callbackScope))){extraDeps.push(dep)}}if(missingDeps.length>0){context.report({node:depsArg,messageId:"missingDep",data:{hookName,deps:missingDeps.join(", ")},suggest:missingDeps.map(dep=>({messageId:"suggestAddDep",data:{dep},fix(fixer){const lastElement=depsArrayNode.elements[depsArrayNode.elements.length-1];if(lastElement){return fixer.insertTextAfter(lastElement,`, ${dep}`)}else{return fixer.insertTextAfterRange([depsArrayNode.range[0]+1,depsArrayNode.range[0]+1],dep)}}}))})}for(const dep of extraDeps){context.report({node:depsArg,messageId:"extraDep",data:{hookName,dep},suggest:[{messageId:"suggestRemoveDep",data:{dep},fix(fixer){const element=depsArrayNode.elements.find(el=>el?.type==="Identifier"&&el.name===dep);if(element){const index=depsArrayNode.elements.indexOf(element);const isLast=index===depsArrayNode.elements.length-1;const isFirst=index===0;if(isFirst&&depsArrayNode.elements.length>1){const nextElement=depsArrayNode.elements[1];if(nextElement){return fixer.removeRange([element.range[0],nextElement.range[0]])}}else if(isLast&&index>0){const prevElement=depsArrayNode.elements[index-1];if(prevElement){return fixer.removeRange([prevElement.range[1],element.range[1]])}}return fixer.remove(element)}return null}}]})}}}}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.jsxKey=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const react_api_1=require("../../utils/react-api");const keyExpressionForParam=param=>{if(param.type===eslint_devkit_1.AST_NODE_TYPES.AssignmentPattern){return keyExpressionForParam(param.left)}if(param.type===eslint_devkit_1.AST_NODE_TYPES.Identifier)return`${param.name}.id`;if(param.type===eslint_devkit_1.AST_NODE_TYPES.ObjectPattern){for(const prop of param.properties){if(prop.type!==eslint_devkit_1.AST_NODE_TYPES.Property)continue;if((0,eslint_devkit_1.objectKeyName)(prop)!=="id")continue;const bound=prop.value.type===eslint_devkit_1.AST_NODE_TYPES.AssignmentPattern?prop.value.left:prop.value;if(bound.type===eslint_devkit_1.AST_NODE_TYPES.Identifier)return bound.name}}return null};const keyExpressionForCallback=fn=>fn.params.length>0?keyExpressionForParam(fn.params[0]):null;exports.jsxKey=(0,eslint_devkit_1.createRule)({name:"jsx-key",meta:{interop:{runtimes:["eslint","oxlint"],nativeEquivalent:"react/jsx-key"},type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/jsx-key.md",description:"Detect missing or problematic React keys that could break reconciliation"},hasSuggestions:true,messages:{missingKey:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Missing React Key",description:"Missing key prop for element in iterator",severity:"HIGH",fix:"Add unique, stable key prop based on item data",documentationLink:"https://react.dev/learn/render-and-commit#lists-and-keys"}),invalidKey:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Invalid React Key",description:"Key prop should be unique and stable",severity:"MEDIUM",fix:"Use item.id, item.key, or index as last resort",documentationLink:"https://react.dev/learn/render-and-commit#lists-and-keys"}),duplicateKey:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Duplicate React Key",description:"Duplicate key values can break reconciliation",severity:"HIGH",fix:"Ensure all keys in the array are unique",documentationLink:"https://react.dev/learn/render-and-commit#lists-and-keys"}),unstableKey:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Unstable React Key",description:"Using index as key can cause reconciliation issues",severity:"MEDIUM",fix:"Use stable identifier from data instead of array index",documentationLink:"https://react.dev/learn/render-and-commit#lists-and-keys"}),suggestKey:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.INFO,issueName:"Add Key Prop",description:"Add unique key prop to element",severity:"LOW",fix:"key={item.id}",documentationLink:"https://react.dev/learn/render-and-commit#lists-and-keys"})},schema:[{type:"object",properties:{warnUnstableKeys:{type:"boolean",default:true}},additionalProperties:false}]},defaultOptions:[{warnUnstableKeys:true}],createOnce(context){let warnUnstableKeys;let keyTracker;let ITERATOR_METHODS;function resetKeyTracker(){keyTracker.clear()}function isIteratorCall(node){if(node.type!=="CallExpression"){return false}const{callee}=node;if(callee.type==="MemberExpression"&&(0,eslint_devkit_1.namesOneOf)((0,eslint_devkit_1.propertyName)(callee),ITERATOR_METHODS)){return(0,react_api_1.reactExport)(callee.object,context.sourceCode.getScope(node))?.name!=="Children"}if(callee.type==="MemberExpression"&&callee.object.type==="Identifier"&&callee.object.name==="Array"&&(0,eslint_devkit_1.propertyName)(callee)==="from"&&node.arguments.length>=2){const mapFn=node.arguments[1];if(mapFn.type==="ArrowFunctionExpression"||mapFn.type==="FunctionExpression"){return true}}return false}function isInsideArrayFromMapFn(node){let current=node;while(current?.parent){const parent=current.parent;if(parent.type==="ArrowFunctionExpression"||parent.type==="FunctionExpression"){const grandParent=parent.parent;if(grandParent?.type==="CallExpression"&&grandParent.callee.type==="MemberExpression"&&grandParent.callee.object.type==="Identifier"&&grandParent.callee.object.name==="Array"&&(0,eslint_devkit_1.propertyName)(grandParent.callee)==="from"&&grandParent.arguments[1]===parent){return true}}current=parent}return false}function isDirectIteratorReturn(node){if(isInsideArrayFromMapFn(node)){return isDirectReturnFromFunction(node)}let current=node;while(current.parent){const parent=current.parent;if(parent.type==="JSXElement"||parent.type==="JSXFragment"){return false}if(parent.type==="ArrowFunctionExpression"&&parent.body===current){if(parent.parent&&isIteratorCall(parent.parent)){return true}}if(parent.type==="ReturnStatement"&&parent.argument===current){let funcParent=parent.parent;while(funcParent){if(funcParent.type==="ArrowFunctionExpression"||funcParent.type==="FunctionExpression"){if(funcParent.parent&&isIteratorCall(funcParent.parent)){return true}break}if(funcParent.type==="BlockStatement"){funcParent=funcParent.parent;continue}break}}if(parent.type==="JSXExpressionContainer"){if(current.type==="JSXElement"&&parent.parent?.type==="JSXElement"){return false}}if(parent.type==="ConditionalExpression"||parent.type==="LogicalExpression"||parent.type==="SequenceExpression"){current=parent;continue}if(parent.type==="CallExpression"){break}current=parent}return false}function isDirectReturnFromFunction(node){let current=node;while(current.parent){const parent=current.parent;if(parent.type==="JSXElement"||parent.type==="JSXFragment"){return false}if(parent.type==="ArrowFunctionExpression"&&parent.body===current){return true}if(parent.type==="ReturnStatement"&&parent.argument===current){return true}if(parent.type==="ConditionalExpression"||parent.type==="LogicalExpression"){current=parent;continue}current=parent}return false}function getIteratorKeyExpression(node){let current=node.parent;while(!((current.type===eslint_devkit_1.AST_NODE_TYPES.ArrowFunctionExpression||current.type===eslint_devkit_1.AST_NODE_TYPES.FunctionExpression)&&isIteratorCall(current.parent))){current=current.parent}return keyExpressionForCallback(current)}function isIndexParam(id){const scope=context.sourceCode.getScope(id);const variable=scope.references.find(ref=>ref.identifier===id)?.resolved;const def=variable?.defs[0];if(def?.type!=="Parameter")return false;const fn=def.node;return(fn.type===eslint_devkit_1.AST_NODE_TYPES.ArrowFunctionExpression||fn.type===eslint_devkit_1.AST_NODE_TYPES.FunctionExpression)&&fn.params[1]===def.name&&isIteratorCall(fn.parent)}function checkFragmentInIteration(node){if(isDirectIteratorReturn(node)){context.report({node:node.openingFragment,messageId:"missingKey"})}}function checkCreateElementInIteration(node){if(!(0,react_api_1.isReactApi)(node.callee,context.sourceCode.getScope(node),"createElement")||!isDirectIteratorReturn(node)){return}const props=node.arguments[1];const missing=props===void 0||props.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&props.value===null||props.type===eslint_devkit_1.AST_NODE_TYPES.ObjectExpression&&props.properties.every(p=>p.type===eslint_devkit_1.AST_NODE_TYPES.Property&&(0,eslint_devkit_1.objectKeyName)(p)!=="key");if(missing){context.report({node,messageId:"missingKey"})}}function checkJSXElementInIteration(node){const isDirectReturn=isDirectIteratorReturn(node);if(!isDirectReturn){return}const keyProp=node.openingElement.attributes.find(attr=>attr.type==="JSXAttribute"&&attr.name.type==="JSXIdentifier"&&attr.name.name==="key");if(!keyProp){const keyExpression=getIteratorKeyExpression(node);context.report({node:node.openingElement,messageId:"missingKey",...keyExpression===null?{}:{suggest:[{messageId:"suggestKey",fix(fixer){return fixer.insertTextAfter(node.openingElement.name,` key={${keyExpression}}`)}}]}});return}if(keyProp.type==="JSXAttribute"&&keyProp.value){const keyValue=keyProp.value;if(warnUnstableKeys&&keyValue.type==="JSXExpressionContainer"&&keyValue.expression.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&isIndexParam(keyValue.expression)){context.report({node:keyProp,messageId:"unstableKey"})}}}return{before(){const[options]=context.options;({warnUnstableKeys=true}=options||{});keyTracker=new Map;ITERATOR_METHODS=new Set(["map","forEach","flatMap"])},JSXElement(node){checkJSXElementInIteration(node)},JSXFragment(node){checkFragmentInIteration(node)},CallExpression(node){checkCreateElementInIteration(node);if(isIteratorCall(node)){resetKeyTracker()}}}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.jsxKey=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const react_api_1=require("../../utils/react-api");const jsxAttributeName=attribute=>attribute.name.type===eslint_devkit_1.AST_NODE_TYPES.JSXIdentifier?attribute.name.name:null;const keyExpressionForParam=param=>{if(param.type===eslint_devkit_1.AST_NODE_TYPES.AssignmentPattern){return keyExpressionForParam(param.left)}if(param.type===eslint_devkit_1.AST_NODE_TYPES.Identifier)return`${param.name}.id`;if(param.type===eslint_devkit_1.AST_NODE_TYPES.ObjectPattern){for(const prop of param.properties){if(prop.type!==eslint_devkit_1.AST_NODE_TYPES.Property)continue;if((0,eslint_devkit_1.objectKeyName)(prop)!=="id")continue;const bound=prop.value.type===eslint_devkit_1.AST_NODE_TYPES.AssignmentPattern?prop.value.left:prop.value;if(bound.type===eslint_devkit_1.AST_NODE_TYPES.Identifier)return bound.name}}return null};const keyExpressionForCallback=fn=>fn.params.length>0?keyExpressionForParam(fn.params[0]):null;exports.jsxKey=(0,eslint_devkit_1.createRule)({name:"jsx-key",meta:{interop:{runtimes:["eslint","oxlint"],nativeEquivalent:"react/jsx-key"},type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/jsx-key.md",description:"Detect missing or problematic React keys that could break reconciliation"},hasSuggestions:true,messages:{missingKey:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Missing React Key",description:"Missing key prop for element in iterator",severity:"HIGH",fix:"Add unique, stable key prop based on item data",documentationLink:"https://react.dev/learn/render-and-commit#lists-and-keys"}),missingArrayKey:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Missing React Key",description:"Missing key prop for element in array",severity:"HIGH",fix:"Add a unique key prop; a shorthand fragment cannot take one, use <React.Fragment key={...}>",documentationLink:"https://react.dev/learn/rendering-lists#keeping-list-items-in-order-with-key"}),keyBeforeSpread:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Key After Spread",description:"key prop must be placed before any {...spread}, to avoid conflicting with the new JSX transform",severity:"MEDIUM",fix:"Move the key prop before the spread attribute",documentationLink:"https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html"}),nonUniqueKeys:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Non-unique React Key",description:"key prop must be unique among siblings",severity:"HIGH",fix:"Give every sibling its own key",documentationLink:"https://react.dev/learn/rendering-lists#keeping-list-items-in-order-with-key"}),invalidKey:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Invalid React Key",description:"Key prop should be unique and stable",severity:"MEDIUM",fix:"Use item.id, item.key, or index as last resort",documentationLink:"https://react.dev/learn/render-and-commit#lists-and-keys"}),duplicateKey:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Duplicate React Key",description:"Duplicate key values can break reconciliation",severity:"HIGH",fix:"Ensure all keys in the array are unique",documentationLink:"https://react.dev/learn/render-and-commit#lists-and-keys"}),unstableKey:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Unstable React Key",description:"Using index as key can cause reconciliation issues",severity:"MEDIUM",fix:"Use stable identifier from data instead of array index",documentationLink:"https://react.dev/learn/render-and-commit#lists-and-keys"}),suggestKey:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.INFO,issueName:"Add Key Prop",description:"Add unique key prop to element",severity:"LOW",fix:"key={item.id}",documentationLink:"https://react.dev/learn/render-and-commit#lists-and-keys"})},schema:[{type:"object",properties:{warnUnstableKeys:{type:"boolean",default:true},checkFragmentShorthand:{type:"boolean",default:false},checkKeyMustBeforeSpread:{type:"boolean",default:false},warnOnDuplicates:{type:"boolean",default:false}},additionalProperties:false}]},defaultOptions:[{warnUnstableKeys:true}],createOnce(context){let warnUnstableKeys;let checkFragmentShorthand;let checkKeyMustBeforeSpread;let warnOnDuplicates;let withinChildrenToArray=0;let reportedDuplicates;let keyTracker;let ITERATOR_METHODS;function resetKeyTracker(){keyTracker.clear()}function isChildrenToArray(node){const{callee}=node;return callee.type==="MemberExpression"&&(0,eslint_devkit_1.propertyName)(callee)==="toArray"&&(0,react_api_1.reactExport)(callee.object,context.sourceCode.getScope(node))?.name==="Children"}function isIteratorCall(node){if(node.type!=="CallExpression"){return false}const{callee}=node;if(callee.type==="MemberExpression"&&(0,eslint_devkit_1.namesOneOf)((0,eslint_devkit_1.propertyName)(callee),ITERATOR_METHODS)){return(0,react_api_1.reactExport)(callee.object,context.sourceCode.getScope(node))?.name!=="Children"}if(callee.type==="MemberExpression"&&callee.object.type==="Identifier"&&callee.object.name==="Array"&&(0,eslint_devkit_1.propertyName)(callee)==="from"&&node.arguments.length>=2){const mapFn=node.arguments[1];if(mapFn.type==="ArrowFunctionExpression"||mapFn.type==="FunctionExpression"){return true}}return false}function isInsideArrayFromMapFn(node){let current=node;while(current?.parent){const parent=current.parent;if(parent.type==="ArrowFunctionExpression"||parent.type==="FunctionExpression"){const grandParent=parent.parent;if(grandParent?.type==="CallExpression"&&grandParent.callee.type==="MemberExpression"&&grandParent.callee.object.type==="Identifier"&&grandParent.callee.object.name==="Array"&&(0,eslint_devkit_1.propertyName)(grandParent.callee)==="from"&&grandParent.arguments[1]===parent){return true}}current=parent}return false}function isDirectIteratorReturn(node){if(isInsideArrayFromMapFn(node)){return isDirectReturnFromFunction(node)}let current=node;while(current.parent){const parent=current.parent;if(parent.type==="JSXElement"||parent.type==="JSXFragment"){return false}if(parent.type==="ArrowFunctionExpression"&&parent.body===current){if(parent.parent&&isIteratorCall(parent.parent)){return true}}if(parent.type==="ReturnStatement"&&parent.argument===current){let funcParent=parent.parent;while(funcParent){if(funcParent.type==="ArrowFunctionExpression"||funcParent.type==="FunctionExpression"){if(funcParent.parent&&isIteratorCall(funcParent.parent)){return true}break}if(funcParent.type==="BlockStatement"){funcParent=funcParent.parent;continue}break}}if(parent.type==="JSXExpressionContainer"){if(current.type==="JSXElement"&&parent.parent?.type==="JSXElement"){return false}}if(parent.type==="ConditionalExpression"||parent.type==="LogicalExpression"||parent.type==="SequenceExpression"){current=parent;continue}if(parent.type==="CallExpression"){break}current=parent}return false}function isDirectReturnFromFunction(node){let current=node;while(current.parent){const parent=current.parent;if(parent.type==="JSXElement"||parent.type==="JSXFragment"){return false}if(parent.type==="ArrowFunctionExpression"&&parent.body===current){return true}if(parent.type==="ReturnStatement"&&parent.argument===current){return true}if(parent.type==="ConditionalExpression"||parent.type==="LogicalExpression"){current=parent;continue}current=parent}return false}function getIteratorKeyExpression(node){let current=node.parent;while(!((current.type===eslint_devkit_1.AST_NODE_TYPES.ArrowFunctionExpression||current.type===eslint_devkit_1.AST_NODE_TYPES.FunctionExpression)&&isIteratorCall(current.parent))){current=current.parent}return keyExpressionForCallback(current)}function isIndexParam(id){const scope=context.sourceCode.getScope(id);const variable=scope.references.find(ref=>ref.identifier===id)?.resolved;const def=variable?.defs[0];if(def?.type!=="Parameter")return false;const fn=def.node;return(fn.type===eslint_devkit_1.AST_NODE_TYPES.ArrowFunctionExpression||fn.type===eslint_devkit_1.AST_NODE_TYPES.FunctionExpression)&&fn.params[1]===def.name&&isIteratorCall(fn.parent)}function checkFragmentInIteration(node){if(withinChildrenToArray===0&&isDirectIteratorReturn(node)){context.report({node:node.openingFragment,messageId:"missingKey"})}}function checkCreateElementInIteration(node){if(!(0,react_api_1.isReactApi)(node.callee,context.sourceCode.getScope(node),"createElement")||!isDirectIteratorReturn(node)){return}if(withinChildrenToArray>0)return;const props=node.arguments[1];const missing=props===void 0||props.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&props.value===null||props.type===eslint_devkit_1.AST_NODE_TYPES.ObjectExpression&&props.properties.every(p=>p.type===eslint_devkit_1.AST_NODE_TYPES.Property&&(0,eslint_devkit_1.objectKeyName)(p)!=="key");if(missing){context.report({node,messageId:"missingKey"})}}function isKeyAfterSpread(attributes){let spreadSeen=false;return attributes.some(attribute=>{if(attribute.type==="JSXSpreadAttribute"){spreadSeen=true;return false}return spreadSeen&&jsxAttributeName(attribute)==="key"})}function checkSiblings(container,siblings){const elements=siblings.filter(n=>n?.type==="JSXElement");const byKeyText=new Map;for(const element of elements){const attributes=element.openingElement.attributes;const keys=attributes.filter(a=>a.type==="JSXAttribute"&&jsxAttributeName(a)==="key");if(keys.length===0){if(container.type==="ArrayExpression"){context.report({node:element,messageId:"missingArrayKey"})}continue}for(const key of keys){const text=key.value?context.sourceCode.getText(key.value):"";byKeyText.set(text,[...byKeyText.get(text)??[],key]);if(checkKeyMustBeforeSpread&&isKeyAfterSpread(attributes)){context.report({node:container.type==="ArrayExpression"?container:container.parent,messageId:"keyBeforeSpread"})}}}if(!warnOnDuplicates)return;for(const sameKey of byKeyText.values()){if(sameKey.length<2)continue;for(const key of sameKey){if(reportedDuplicates.has(key))continue;reportedDuplicates.add(key);context.report({node:key,messageId:"nonUniqueKeys"})}}}function checkJSXElementInIteration(node){const isDirectReturn=withinChildrenToArray===0&&isDirectIteratorReturn(node);if(!isDirectReturn){return}const keyProp=node.openingElement.attributes.find(attr=>attr.type==="JSXAttribute"&&attr.name.type==="JSXIdentifier"&&attr.name.name==="key");if(!keyProp){const keyExpression=getIteratorKeyExpression(node);context.report({node:node.openingElement,messageId:"missingKey",...keyExpression===null?{}:{suggest:[{messageId:"suggestKey",fix(fixer){return fixer.insertTextAfter(node.openingElement.name,` key={${keyExpression}}`)}}]}});return}if(checkKeyMustBeforeSpread&&isKeyAfterSpread(node.openingElement.attributes)){context.report({node,messageId:"keyBeforeSpread"})}if(keyProp.type==="JSXAttribute"&&keyProp.value){const keyValue=keyProp.value;if(warnUnstableKeys&&keyValue.type==="JSXExpressionContainer"&&keyValue.expression.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&isIndexParam(keyValue.expression)){context.report({node:keyProp,messageId:"unstableKey"})}}}return{before(){const[options]=context.options;({warnUnstableKeys=true,checkFragmentShorthand=false,checkKeyMustBeforeSpread=false,warnOnDuplicates=false}=options||{});withinChildrenToArray=0;reportedDuplicates=new WeakSet;keyTracker=new Map;ITERATOR_METHODS=new Set(["map","forEach","flatMap"])},JSXElement(node){checkJSXElementInIteration(node);if(withinChildrenToArray===0&&node.parent.type==="JSXElement"){checkSiblings(node.parent,node.parent.children)}},JSXFragment(node){checkFragmentInIteration(node);if(checkFragmentShorthand&&withinChildrenToArray===0&&node.parent.type==="ArrayExpression"){context.report({node:node.openingFragment,messageId:"missingArrayKey"})}},ArrayExpression(node){if(withinChildrenToArray===0)checkSiblings(node,node.elements)},CallExpression(node){if(isChildrenToArray(node))withinChildrenToArray++;checkCreateElementInIteration(node);if(isIteratorCall(node)){resetKeyTracker()}},"CallExpression:exit"(node){if(isChildrenToArray(node))withinChildrenToArray--}}}});
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.jsxNoCommentTextnodes=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const COMMENT_LIKE=/^\s*\/(\/|\*)/m;exports.jsxNoCommentTextnodes=(0,eslint_devkit_1.createRule)({name:"jsx-no-comment-textnodes",meta:{interop:{runtimes:["eslint","oxlint"]},type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/jsx-no-comment-textnodes.md",description:"Disallow comments from being inserted as text nodes"},schema:[],messages:{putCommentInBraces:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Comment Rendered as Text",description:"Comments inside children section of tag should be placed inside braces",severity:"MEDIUM",fix:"Wrap the comment in braces: {/* comment */}",documentationLink:"https://react.dev/learn/writing-markup-with-jsx#jsx-curly-braces"})}},defaultOptions:[],createOnce(context){function check(node){if(!COMMENT_LIKE.test(context.sourceCode.getText(node)))return;const parent=node.parent;if(parent.type!=="JSXAttribute"&&parent.type!=="JSXExpressionContainer"&&parent.type.includes("JSX")){context.report({node,messageId:"putCommentInBraces"})}}return{Literal:check,JSXText:check}}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.jsxNoTargetBlank=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");function attributeText(value){if(!value)return null;return(0,eslint_devkit_1.staticString)(value.type==="JSXExpressionContainer"?value.expression:value)}exports.jsxNoTargetBlank=(0,eslint_devkit_2.createRule)({name:"jsx-no-target-blank",meta:{interop:{runtimes:["eslint","oxlint"],nativeEquivalent:"react/jsx-no-target-blank"},type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/jsx-no-target-blank.md",description:'Forbid target="_blank" without rel="noopener noreferrer"',cwe:"CWE-1022",cvss:7.5},fixable:"code",messages:{noTargetBlank:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:'Unsafe target="_blank"',cwe:"CWE-1022",description:'Using target="_blank" without rel="noopener noreferrer" is a security risk',severity:"HIGH",fix:'Add rel="noopener noreferrer" to prevent reverse tabnabbing',documentationLink:"https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md"}),noRelWithoutNoopener:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Missing noopener",cwe:"CWE-1022",description:'rel attribute is missing "noopener" value',severity:"MEDIUM",fix:'Add "noopener" to the rel attribute',documentationLink:"https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md"})},schema:[{type:"object",properties:{allowReferrer:{type:"boolean",default:false},enforceDynamicLinks:{type:"string",enum:["always","never"],default:"always"},warnOnSpreadAttributes:{type:"boolean",default:false},links:{type:"boolean",default:true},forms:{type:"boolean",default:false}},additionalProperties:false}]},defaultOptions:[{}],createOnce(context,currentOptions){let allowReferrer;let enforceDynamicLinks;let warnOnSpreadAttributes;let links;let forms;let elementsToCheck;function hasTargetBlank(node){const targetAttr=node.attributes.find(attr=>attr.type==="JSXAttribute"&&attr.name.type==="JSXIdentifier"&&attr.name.name==="target");if(!targetAttr||!targetAttr.value)return false;const staticTarget=attributeText(targetAttr.value);if(staticTarget!==null){return staticTarget.toLowerCase()==="_blank"}if(enforceDynamicLinks==="always"){return true}return false}function hasExternalHref(node){const hrefAttr=node.attributes.find(attr=>attr.type==="JSXAttribute"&&attr.name.type==="JSXIdentifier"&&attr.name.name==="href");if(!hrefAttr||!hrefAttr.value)return false;const href=attributeText(hrefAttr.value);if(href!==null){return/^(https?:)?\/\//i.test(href)}return enforceDynamicLinks==="always"}function getRelAttribute(node){return node.attributes.find(attr=>attr.type==="JSXAttribute"&&attr.name.type==="JSXIdentifier"&&attr.name.name==="rel")}function hasNoopener(relAttr){const staticText2=attributeText(relAttr.value);if(staticText2!==null){const relValues=staticText2.toLowerCase().split(/\s+/);return relValues.includes("noopener")}return false}function hasNoreferrer(relAttr){const staticText3=attributeText(relAttr.value);if(staticText3!==null){const relValues=staticText3.toLowerCase().split(/\s+/);return relValues.includes("noreferrer")}return false}function hasSpreadAttribute(node){return node.attributes.some(attr=>attr.type==="JSXSpreadAttribute")}return{before(){const[options={}]=currentOptions();({allowReferrer=false,enforceDynamicLinks="always",warnOnSpreadAttributes=false,links=true,forms=false}=options??{});elementsToCheck=[];if(links)elementsToCheck.push("a");if(forms)elementsToCheck.push("form")},JSXOpeningElement(node){if(node.name.type!=="JSXIdentifier"||!elementsToCheck.includes(node.name.name)){return}if(hasSpreadAttribute(node)&&!warnOnSpreadAttributes){return}if(!hasTargetBlank(node)){return}if(node.name.name==="a"&&!hasExternalHref(node)){return}const relAttr=getRelAttribute(node);const hasNoopenerValue=relAttr?hasNoopener(relAttr):false;const hasNoreferrerValue=relAttr?hasNoreferrer(relAttr):false;if(hasNoopenerValue||hasNoreferrerValue){if(!allowReferrer&&!hasNoreferrerValue){return}return}context.report({node,messageId:relAttr?"noRelWithoutNoopener":"noTargetBlank",fix:fixer=>{if(relAttr&&relAttr.value&&relAttr.value.type==="Literal"){const currentRel=String((0,eslint_devkit_1.staticString)(relAttr.value));const newRel=allowReferrer?`${currentRel} noopener`.trim():`${currentRel} noopener noreferrer`.trim();return fixer.replaceText(relAttr.value,`"${newRel}"`)}else if(!relAttr){const lastAttr=node.attributes[node.attributes.length-1];const relValue=allowReferrer?"noopener":"noopener noreferrer";if(lastAttr){return fixer.insertTextAfter(lastAttr,` rel="${relValue}"`)}return fixer.insertTextAfter(node.name,` rel="${relValue}"`)}return null}})}}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.jsxNoTargetBlank=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");function attributeText(value){if(!value)return null;return(0,eslint_devkit_1.staticString)(value.type==="JSXExpressionContainer"?value.expression:value)}function componentAttributes(settings,key,attributeKey,builtIn,builtInAttribute){const found=new Map([[builtIn,[builtInAttribute]]]);const configured=settings?.[key];const entries=Array.isArray(configured)?configured:configured===void 0?[]:[configured];for(const entry of entries){if(typeof entry==="string"){found.set(entry,[builtInAttribute])}else if(entry&&typeof entry==="object"){const{name,[attributeKey]:attribute}=entry;if(typeof name==="string"){found.set(name,[attribute].flat().filter(a=>typeof a==="string"))}}}return found}exports.jsxNoTargetBlank=(0,eslint_devkit_2.createRule)({name:"jsx-no-target-blank",meta:{interop:{runtimes:["eslint","oxlint"],nativeEquivalent:"react/jsx-no-target-blank"},type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/jsx-no-target-blank.md",description:'Forbid target="_blank" without rel="noopener noreferrer"',cwe:"CWE-1022",cvss:7.5},fixable:"code",messages:{noTargetBlank:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:'Unsafe target="_blank"',cwe:"CWE-1022",description:'Using target="_blank" without rel="noopener noreferrer" is a security risk',severity:"HIGH",fix:'Add rel="noopener noreferrer" to prevent reverse tabnabbing',documentationLink:"https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md"}),noRelWithoutNoopener:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Missing noopener",cwe:"CWE-1022",description:'rel attribute is missing "noopener" value',severity:"MEDIUM",fix:'Add "noopener" to the rel attribute',documentationLink:"https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md"})},schema:[{type:"object",properties:{allowReferrer:{type:"boolean",default:false},enforceDynamicLinks:{type:"string",enum:["always","never"],default:"always"},warnOnSpreadAttributes:{type:"boolean",default:false},links:{type:"boolean",default:true},forms:{type:"boolean",default:false}},additionalProperties:false}]},defaultOptions:[{}],createOnce(context,currentOptions){let allowReferrer;let enforceDynamicLinks;let warnOnSpreadAttributes;let links;let forms;let linkAttributes;let elementsToCheck;function hasTargetBlank(node){const targetAttr=node.attributes.find(attr=>attr.type==="JSXAttribute"&&attr.name.type==="JSXIdentifier"&&attr.name.name==="target");if(!targetAttr||!targetAttr.value)return false;const staticTarget=attributeText(targetAttr.value);if(staticTarget!==null){return staticTarget.toLowerCase()==="_blank"}if(enforceDynamicLinks==="always"){return true}return false}function hasExternalHref(node,attributeNames){return attributeNames.some(attributeName=>{const hrefAttr=node.attributes.find(attr=>attr.type==="JSXAttribute"&&attr.name.type==="JSXIdentifier"&&attr.name.name===attributeName);if(!hrefAttr||!hrefAttr.value)return false;const href=attributeText(hrefAttr.value);if(href!==null){return/^(https?:)?\/\//i.test(href)}return enforceDynamicLinks==="always"})}function getRelAttribute(node){return node.attributes.find(attr=>attr.type==="JSXAttribute"&&attr.name.type==="JSXIdentifier"&&attr.name.name==="rel")}function hasNoopener(relAttr){const staticText2=attributeText(relAttr.value);if(staticText2!==null){const relValues=staticText2.toLowerCase().split(/\s+/);return relValues.includes("noopener")}return false}function hasNoreferrer(relAttr){const staticText3=attributeText(relAttr.value);if(staticText3!==null){const relValues=staticText3.toLowerCase().split(/\s+/);return relValues.includes("noreferrer")}return false}function hasSpreadAttribute(node){return node.attributes.some(attr=>attr.type==="JSXSpreadAttribute")}return{before(){const[options={}]=currentOptions();({allowReferrer=false,enforceDynamicLinks="always",warnOnSpreadAttributes=false,links=true,forms=false}=options??{});linkAttributes=componentAttributes(context.settings,"linkComponents","linkAttribute","a","href");elementsToCheck=[];if(links)elementsToCheck.push(...linkAttributes.keys());if(forms){elementsToCheck.push(...componentAttributes(context.settings,"formComponents","formAttribute","form","action").keys())}},JSXOpeningElement(node){const elementName=node.name.type==="JSXIdentifier"?node.name.name:context.sourceCode.getText(node.name);if(!elementsToCheck.includes(elementName)){return}if(hasSpreadAttribute(node)&&!warnOnSpreadAttributes){return}if(!hasTargetBlank(node)){return}const urlAttributes=links?linkAttributes.get(elementName):void 0;if(urlAttributes&&!hasExternalHref(node,urlAttributes)){return}const relAttr=getRelAttribute(node);const hasNoopenerValue=relAttr?hasNoopener(relAttr):false;const hasNoreferrerValue=relAttr?hasNoreferrer(relAttr):false;if(hasNoopenerValue||hasNoreferrerValue){if(!allowReferrer&&!hasNoreferrerValue){return}return}context.report({node,messageId:relAttr?"noRelWithoutNoopener":"noTargetBlank",fix:fixer=>{if(relAttr&&relAttr.value&&relAttr.value.type==="Literal"){const currentRel=String((0,eslint_devkit_1.staticString)(relAttr.value));const newRel=allowReferrer?`${currentRel} noopener`.trim():`${currentRel} noopener noreferrer`.trim();return fixer.replaceText(relAttr.value,`"${newRel}"`)}else if(!relAttr){const lastAttr=node.attributes[node.attributes.length-1];const relValue=allowReferrer?"noopener":"noopener noreferrer";if(lastAttr){return fixer.insertTextAfter(lastAttr,` rel="${relValue}"`)}return fixer.insertTextAfter(node.name,` rel="${relValue}"`)}return null}})}}}});
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.jsxNoUndef=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");exports.jsxNoUndef=(0,eslint_devkit_1.createRule)({name:"jsx-no-undef",meta:{interop:{runtimes:["eslint","oxlint"]},type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/jsx-no-undef.md",description:"Disallow undeclared variables in JSX"},schema:[{type:"object",properties:{allowGlobals:{type:"boolean"}},additionalProperties:false}],messages:{undefined:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Undefined JSX Component",description:"'{{identifier}}' is not defined.",severity:"HIGH",fix:"Import or declare the component before using it as a JSX tag",documentationLink:"https://react.dev/learn/your-first-component#importing-and-exporting-components"})}},defaultOptions:[{}],createOnce(context,options){let allowGlobals=false;function checkIdentifier(node){if(node.name==="this")return;const sourceType=context.sourceCode.ast.sourceType;const upperBound=!allowGlobals&&sourceType==="module"?"module":"global";let scope=context.sourceCode.getScope(node);let variables=[...scope.variables];while(scope.type!==upperBound&&scope.type!=="global"){scope=scope.upper;variables=[...scope.variables,...variables]}if(scope.type==="global"&&sourceType==="module"){variables=[...scope.childScopes.filter(child=>child.type==="module").flatMap(child=>child.variables),...variables]}if(variables.some(variable=>variable.name===node.name))return;context.report({node,messageId:"undefined",data:{identifier:node.name}})}return{before(){allowGlobals=options()[0]?.allowGlobals??false},JSXOpeningElement(node){let name=node.name;while(name.type==="JSXMemberExpression")name=name.object;if(name.type==="JSXNamespacedName")return;if(node.name.type==="JSXIdentifier"&&/^[a-z]/.test(name.name)){return}checkIdentifier(name)}}}});
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.jsxUsesReact=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const react_settings_1=require("../../utils/react-settings");exports.jsxUsesReact=(0,eslint_devkit_1.createRule)({name:"jsx-uses-react",meta:{interop:{runtimes:["eslint"]},type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/jsx-uses-react.md",description:"Disallow React to be incorrectly marked as unused"},schema:[],messages:{}},defaultOptions:[],createOnce(context){let pragma="React";let fragment="Fragment";const markPragma=node=>{context.sourceCode.markVariableAsUsed(pragma,node)};return{before(){pragma=(0,react_settings_1.getPragma)(context);fragment=(0,react_settings_1.getFragmentPragma)(context)},JSXOpeningElement:markPragma,JSXOpeningFragment:markPragma,JSXFragment(node){context.sourceCode.markVariableAsUsed(fragment,node)}}}});
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.jsxUsesVars=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const INTRINSIC=/^[a-z]/;exports.jsxUsesVars=(0,eslint_devkit_1.createRule)({name:"jsx-uses-vars",meta:{interop:{runtimes:["eslint"]},type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/jsx-uses-vars.md",description:"Disallow variables used in JSX to be incorrectly marked as unused"},schema:[],messages:{}},defaultOptions:[],createOnce(context){return{JSXOpeningElement(node){const tag=node.name;if(tag.type==="JSXIdentifier"){if(INTRINSIC.test(tag.name))return;context.sourceCode.markVariableAsUsed(tag.name,node)}else if(tag.type==="JSXMemberExpression"){let object=tag.object;while(object.type==="JSXMemberExpression")object=object.object;context.sourceCode.markVariableAsUsed(object.name,node)}}}}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noChildrenProp=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const react_api_1=require("../../utils/react-api");const eslint_devkit_2=require("@interlace/eslint-devkit");exports.noChildrenProp=(0,eslint_devkit_1.createRule)({name:"no-children-prop",meta:{interop:{runtimes:["eslint","oxlint"],nativeEquivalent:"react/no-children-prop"},type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-children-prop.md",description:"Disallow passing children as props"},schema:[],messages:{noChildrenProp:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Children as Prop",description:"Passing children as a prop",severity:"HIGH",fix:"Use JSX children syntax: <Component>children</Component>",documentationLink:"https://react.dev/learn/passing-props-to-a-component#passing-jsx-as-children"})}},defaultOptions:[],createOnce(context){const reportChildrenKey=props=>{for(const prop of props.properties){if(prop.type==="Property"&&(0,eslint_devkit_1.objectKeyName)(prop)==="children"){context.report({node:prop.key,messageId:"noChildrenProp"})}}};return{JSXAttribute(node){if(node.name.type==="JSXIdentifier"&&node.name.name==="children"){context.report({node:node.name,messageId:"noChildrenProp"})}},JSXSpreadAttribute(node){if(node.argument.type==="ObjectExpression"){reportChildrenKey(node.argument)}},CallExpression(node){const props=node.arguments[1];if(props?.type==="ObjectExpression"&&(0,react_api_1.isReactApi)(node.callee,context.sourceCode.getScope(node),"createElement")){reportChildrenKey(props)}}}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noChildrenProp=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const react_api_1=require("../../utils/react-api");const eslint_devkit_2=require("@interlace/eslint-devkit");exports.noChildrenProp=(0,eslint_devkit_1.createRule)({name:"no-children-prop",meta:{interop:{runtimes:["eslint","oxlint"],nativeEquivalent:"react/no-children-prop"},type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-children-prop.md",description:"Disallow passing children as props"},schema:[{type:"object",properties:{allowFunctions:{type:"boolean",default:false}},additionalProperties:false}],messages:{noChildrenProp:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Children as Prop",description:"Passing children as a prop",severity:"HIGH",fix:"Use JSX children syntax: <Component>children</Component>",documentationLink:"https://react.dev/learn/passing-props-to-a-component#passing-jsx-as-children"}),nestFunction:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Function as Nested Children",description:"Do not nest a function between the opening and closing tags",severity:"MEDIUM",fix:"Pass the function as a `children` prop instead",documentationLink:"https://react.dev/learn/passing-props-to-a-component#passing-jsx-as-children"}),passFunctionAsArgs:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Function as createElement Argument",description:"Do not pass a function as an additional argument to React.createElement",severity:"MEDIUM",fix:"Pass the function as a `children` prop instead",documentationLink:"https://react.dev/reference/react/createElement#parameters"})}},defaultOptions:[{}],createOnce(context,options){let allowFunctions=false;const isFunction=node=>allowFunctions&&(node.type==="ArrowFunctionExpression"||node.type==="FunctionExpression");const reportChildrenKey=props=>{for(const prop of props.properties){if(prop.type==="Property"&&(0,eslint_devkit_1.objectKeyName)(prop)==="children"&&!isFunction(prop.value)){context.report({node:prop.key,messageId:"noChildrenProp"})}}};return{before(){allowFunctions=options()[0]?.allowFunctions??false},JSXAttribute(node){if(node.name.type==="JSXIdentifier"&&node.name.name==="children"&&!(node.value?.type==="JSXExpressionContainer"&&isFunction(node.value.expression))){context.report({node:node.name,messageId:"noChildrenProp"})}},JSXSpreadAttribute(node){if(node.argument.type==="ObjectExpression"){reportChildrenKey(node.argument)}},CallExpression(node){const props=node.arguments[1];if(props?.type==="ObjectExpression"&&(0,react_api_1.isReactApi)(node.callee,context.sourceCode.getScope(node),"createElement")){reportChildrenKey(props);const extra=node.arguments[2];if(node.arguments.length===3&&extra&&isFunction(extra)&&!props.properties.some(prop=>prop.type==="Property"&&(0,eslint_devkit_1.objectKeyName)(prop)==="children")){context.report({node,messageId:"passFunctionAsArgs"})}}},JSXElement(node){const only=node.children[0];if(node.children.length===1&&only?.type==="JSXExpressionContainer"&&isFunction(only.expression)){context.report({node,messageId:"nestFunction"})}}}}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noDeprecated=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const react_api_1=require("../../utils/react-api");const DEPRECATED_APIS={"React.createClass":{replacement:"class extends React.Component",since:"React 16"},"React.PropTypes":{replacement:'import PropTypes from "prop-types"',since:"React 15.5"},"React.findDOMNode":{replacement:"refs",since:"React 16.3"},"ReactDOM.render":{replacement:"createRoot().render()",since:"React 18"},"ReactDOM.hydrate":{replacement:"hydrateRoot()",since:"React 18"},"ReactDOM.unmountComponentAtNode":{replacement:"root.unmount()",since:"React 18"},"ReactDOM.findDOMNode":{replacement:"refs",since:"React 16.3"},componentWillMount:{replacement:"componentDidMount or constructor",since:"React 16.3"},componentWillReceiveProps:{replacement:"static getDerivedStateFromProps",since:"React 16.3"},componentWillUpdate:{replacement:"getSnapshotBeforeUpdate",since:"React 16.3"},UNSAFE_componentWillMount:{replacement:"componentDidMount or constructor",since:"React 17"},UNSAFE_componentWillReceiveProps:{replacement:"static getDerivedStateFromProps",since:"React 17"},UNSAFE_componentWillUpdate:{replacement:"getSnapshotBeforeUpdate",since:"React 17"}};const LIFECYCLES=new Set(["componentWillMount","componentWillReceiveProps","componentWillUpdate","UNSAFE_componentWillMount","UNSAFE_componentWillReceiveProps","UNSAFE_componentWillUpdate"]);exports.noDeprecated=(0,eslint_devkit_2.createRule)({name:"no-deprecated",meta:{interop:{runtimes:["eslint","oxlint"]},type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-deprecated.md",description:"Prevent using deprecated React methods"},messages:{deprecated:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.DEPRECATION,issueName:"Deprecated React API",description:'"{{name}}" is deprecated since {{since}}',severity:"MEDIUM",fix:"Use {{replacement}} instead",documentationLink:"https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-deprecated.md"})},schema:[]},defaultOptions:[],createOnce(context){let classes;function report(node,name){const deprecation=DEPRECATED_APIS[name];context.report({node,messageId:"deprecated",data:{name,replacement:deprecation.replacement,since:deprecation.since}})}function check(node){const api=(0,react_api_1.reactExport)(node,context.sourceCode.getScope(node));if(api?.module!=="react"&&api?.module!=="react-dom")return;const name=`${api.module==="react"?"React":"ReactDOM"}.${api.name}`;if(Object.hasOwn(DEPRECATED_APIS,name))report(node,name)}function enterClass(node){classes.push((0,react_api_1.extendsReactComponent)(node,context.sourceCode.getScope(node)))}function checkLifecycleMethod(node){if(!classes.at(-1)||node.static)return;const methodName=(0,eslint_devkit_1.objectKeyName)(node);if(methodName!==null&&LIFECYCLES.has(methodName)){report(node,methodName)}}return{before(){classes=[]},ClassDeclaration:enterClass,ClassExpression:enterClass,"ClassDeclaration:exit"(){classes.pop()},"ClassExpression:exit"(){classes.pop()},MemberExpression:check,Identifier(node){const scope=context.sourceCode.getScope(node);if(scope.references.some(ref=>ref.identifier===node))check(node)},MethodDefinition:checkLifecycleMethod,PropertyDefinition:checkLifecycleMethod}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noDeprecated=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const react_api_1=require("../../utils/react-api");const react_settings_1=require("../../utils/react-settings");const DEPRECATED_APIS={"React.createClass":{replacement:"class extends React.Component",since:"React 16",from:"15.5.0"},"React.PropTypes":{replacement:'import PropTypes from "prop-types"',since:"React 15.5",from:"15.5.0"},"React.findDOMNode":{replacement:"refs",since:"React 16.3",from:"0.14.0"},"ReactDOM.render":{replacement:"createRoot().render()",since:"React 18",from:"18.0.0"},"ReactDOM.hydrate":{replacement:"hydrateRoot()",since:"React 18",from:"18.0.0"},"ReactDOM.unmountComponentAtNode":{replacement:"root.unmount()",since:"React 18",from:"18.0.0"},"ReactDOM.findDOMNode":{replacement:"refs",since:"React 16.3",from:"16.6.0"},componentWillMount:{replacement:"componentDidMount or constructor",since:"React 16.3",from:"16.9.0"},componentWillReceiveProps:{replacement:"static getDerivedStateFromProps",since:"React 16.3",from:"16.9.0"},componentWillUpdate:{replacement:"getSnapshotBeforeUpdate",since:"React 16.3",from:"16.9.0"},UNSAFE_componentWillMount:{replacement:"componentDidMount or constructor",since:"React 17",from:"17.0.0"},UNSAFE_componentWillReceiveProps:{replacement:"static getDerivedStateFromProps",since:"React 17",from:"17.0.0"},UNSAFE_componentWillUpdate:{replacement:"getSnapshotBeforeUpdate",since:"React 17",from:"17.0.0"}};function pragmaExport(node,pragma,scope){if(pragma==="React"||node.type!=="MemberExpression"||node.object.type!=="Identifier"||node.object.name!==pragma||(0,eslint_devkit_1.propertyName)(node)===null)return null;for(let s=scope;s;s=s.upper){if((s.set.get(pragma)?.defs.length??0)>0)return null}return{module:"react",name:(0,eslint_devkit_1.propertyName)(node)}}const LIFECYCLES=new Set(["componentWillMount","componentWillReceiveProps","componentWillUpdate","UNSAFE_componentWillMount","UNSAFE_componentWillReceiveProps","UNSAFE_componentWillUpdate"]);exports.noDeprecated=(0,eslint_devkit_2.createRule)({name:"no-deprecated",meta:{interop:{runtimes:["eslint","oxlint"]},type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-deprecated.md",description:"Prevent using deprecated React methods"},messages:{deprecated:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.DEPRECATION,issueName:"Deprecated React API",description:'"{{name}}" is deprecated since {{since}}',severity:"MEDIUM",fix:"Use {{replacement}} instead",documentationLink:"https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-deprecated.md"})},schema:[]},defaultOptions:[],createOnce(context){let classes;let pragma;function report(node,name){const deprecation=DEPRECATED_APIS[name];if(!(0,react_settings_1.reactVersionAtLeast)(context,deprecation.from))return;context.report({node,messageId:"deprecated",data:{name,replacement:deprecation.replacement,since:deprecation.since}})}function check(node){const scope=context.sourceCode.getScope(node);const api=(0,react_api_1.reactExport)(node,scope)??pragmaExport(node,pragma,scope);if(api?.module!=="react"&&api?.module!=="react-dom")return;const name=`${api.module==="react"?"React":"ReactDOM"}.${api.name}`;if(Object.hasOwn(DEPRECATED_APIS,name))report(node,name)}function enterClass(node){classes.push((0,react_api_1.extendsReactComponent)(node,context.sourceCode.getScope(node)))}function checkLifecycleMethod(node){if(!classes.at(-1)||node.static)return;const methodName=(0,eslint_devkit_1.objectKeyName)(node);if(methodName!==null&&LIFECYCLES.has(methodName)){report(node,methodName)}}return{before(){classes=[];pragma=(0,react_settings_1.getPragma)(context)},ClassDeclaration:enterClass,ClassExpression:enterClass,"ClassDeclaration:exit"(){classes.pop()},"ClassExpression:exit"(){classes.pop()},MemberExpression:check,Identifier(node){const scope=context.sourceCode.getScope(node);if(scope.references.some(ref=>ref.identifier===node))check(node)},MethodDefinition:checkLifecycleMethod,PropertyDefinition:checkLifecycleMethod}}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noRenderReturnValue=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const react_api_1=require("../../utils/react-api");const eslint_devkit_2=require("@interlace/eslint-devkit");exports.noRenderReturnValue=(0,eslint_devkit_1.createRule)({name:"no-render-return-value",meta:{interop:{runtimes:["eslint","oxlint"],nativeEquivalent:"react/no-render-return-value"},type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-render-return-value.md",description:"Prevent using render return value"},messages:{noRenderReturnValue:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Render Return Value Usage",description:"Using return value of ReactDOM.render()",severity:"HIGH",fix:"ReactDOM.render() return value is deprecated, use refs instead",documentationLink:"https://react.dev/reference/react-dom/render"})},schema:[]},defaultOptions:[],createOnce(context){return{CallExpression(node){const api=(0,react_api_1.reactExport)(node.callee,context.sourceCode.getScope(node));if(api?.module!=="react-dom"||api.name!=="render")return;const target=usedAs(node);if(target){context.report({node:target,messageId:"noRenderReturnValue"})}}}}});function usedAs(call){const parent=call.parent;switch(parent.type){case"VariableDeclarator":return parent.id;case"AssignmentExpression":return parent.left;case"ReturnStatement":return call;case"CallExpression":case"NewExpression":return parent.arguments.includes(call)?call:null;default:return null}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noRenderReturnValue=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const react_api_1=require("../../utils/react-api");const eslint_devkit_2=require("@interlace/eslint-devkit");const react_settings_1=require("../../utils/react-settings");exports.noRenderReturnValue=(0,eslint_devkit_1.createRule)({name:"no-render-return-value",meta:{interop:{runtimes:["eslint","oxlint"],nativeEquivalent:"react/no-render-return-value"},type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-render-return-value.md",description:"Prevent using render return value"},messages:{noRenderReturnValue:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Render Return Value Usage",description:"Using return value of ReactDOM.render()",severity:"HIGH",fix:"ReactDOM.render() return value is deprecated, use refs instead",documentationLink:"https://react.dev/reference/react-dom/render"})},schema:[]},defaultOptions:[],createOnce(context){let renderModules;return{before(){renderModules=(0,react_settings_1.reactVersionAtLeast)(context,"0.14.0")&&!(0,react_settings_1.reactVersionAtLeast)(context,"0.15.0")?["react","react-dom"]:(0,react_settings_1.reactVersionAtLeast)(context,"0.13.0")&&!(0,react_settings_1.reactVersionAtLeast)(context,"0.14.0")?["react"]:["react-dom"]},CallExpression(node){const api=(0,react_api_1.reactExport)(node.callee,context.sourceCode.getScope(node));if(!api||api.name!=="render"||!renderModules.includes(api.module))return;const target=usedAs(node);if(target){context.report({node:target,messageId:"noRenderReturnValue"})}}}}});function usedAs(call){const parent=call.parent;switch(parent.type){case"VariableDeclarator":return parent.id;case"AssignmentExpression":return parent.left;case"ReturnStatement":return call;case"CallExpression":case"NewExpression":return parent.arguments.includes(call)?call:null;default:return null}}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noStringRefs=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const component_set_state_1=require("../../utils/component-set-state");const eslint_devkit_2=require("@interlace/eslint-devkit");exports.noStringRefs=(0,eslint_devkit_1.createRule)({name:"no-string-refs",meta:{interop:{runtimes:["eslint","oxlint"],nativeEquivalent:"react/no-string-refs"},type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-string-refs.md",description:"Disallow string refs"},messages:{noStringRefs:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.MIGRATION,issueName:"String Refs",description:"Usage of string refs detected",severity:"HIGH",fix:"Use callback refs: ref={(el) => this.myRef = el} or createRef: this.myRef = React.createRef()",documentationLink:"https://react.dev/reference/react/forwardRef"})},schema:[]},defaultOptions:[],createOnce(context){function isString(node){if(node.type==="Literal")return typeof node.value==="string";if(node.type==="TemplateLiteral")return true;if(node.type==="ConditionalExpression")return isString(node.consequent)&&isString(node.alternate);return false}return{JSXAttribute(node){if(node.name.type!=="JSXIdentifier"||node.name.name!=="ref")return;const value=node.value?.type==="JSXExpressionContainer"?node.value.expression:node.value;if(value&&isString(value)){context.report({node:node.name,messageId:"noStringRefs"})}},MemberExpression(node){if(node.object.type!=="ThisExpression"||(0,eslint_devkit_1.propertyName)(node)!=="refs"||!(0,component_set_state_1.componentThis)(node.object,context.sourceCode))return;context.report({node,messageId:"noStringRefs"})}}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noStringRefs=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const component_set_state_1=require("../../utils/component-set-state");const eslint_devkit_2=require("@interlace/eslint-devkit");const react_settings_1=require("../../utils/react-settings");exports.noStringRefs=(0,eslint_devkit_1.createRule)({name:"no-string-refs",meta:{interop:{runtimes:["eslint","oxlint"],nativeEquivalent:"react/no-string-refs"},type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-string-refs.md",description:"Disallow string refs"},messages:{noStringRefs:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.MIGRATION,issueName:"String Refs",description:"Usage of string refs detected",severity:"HIGH",fix:"Use callback refs: ref={(el) => this.myRef = el} or createRef: this.myRef = React.createRef()",documentationLink:"https://react.dev/reference/react/forwardRef"})},schema:[{type:"object",properties:{noTemplateLiterals:{type:"boolean",default:false}},additionalProperties:false}]},defaultOptions:[{}],createOnce(context,options){let noTemplateLiterals=false;let checkRefsUsage=false;function isString(node){if(node.type==="Literal")return typeof node.value==="string";if(node.type==="TemplateLiteral")return noTemplateLiterals;if(node.type==="ConditionalExpression")return isString(node.consequent)&&isString(node.alternate);return false}return{before(){noTemplateLiterals=options()[0]?.noTemplateLiterals??false;checkRefsUsage=(0,react_settings_1.reactVersionBelow)(context,"18.3.0")},JSXAttribute(node){if(node.name.type!=="JSXIdentifier"||node.name.name!=="ref")return;const value=node.value?.type==="JSXExpressionContainer"?node.value.expression:node.value;if(value&&isString(value)){context.report({node:node.name,messageId:"noStringRefs"})}},MemberExpression(node){if(!checkRefsUsage||node.object.type!=="ThisExpression"||(0,eslint_devkit_1.propertyName)(node)!=="refs"||!(0,component_set_state_1.componentThis)(node.object,context.sourceCode))return;context.report({node,messageId:"noStringRefs"})}}}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noUnescapedEntities=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const UNESCAPED_ENTITIES=/[<>"]/;exports.noUnescapedEntities=(0,eslint_devkit_1.createRule)({name:"no-unescaped-entities",meta:{interop:{runtimes:["eslint","oxlint"],nativeEquivalent:"react/no-unescaped-entities"},type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-unescaped-entities.md",description:"Prevent unescaped entities"},messages:{noUnescapedEntities:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Unescaped Entity",description:"Unescaped HTML entity in JSX text",severity:"MEDIUM",fix:"Use HTML entities (&lt;, &gt;, &quot;) or wrap in curly braces",documentationLink:"https://react.dev/learn/javascript-in-jsx-with-curly-braces"})},schema:[]},defaultOptions:[],createOnce(context){return{JSXText(node){const text=node.raw;if(!text.trim()){return}if(UNESCAPED_ENTITIES.test(text)){context.report({node,messageId:"noUnescapedEntities"})}}}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noUnescapedEntities=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const UNESCAPED_ENTITIES=/[<>"]/;exports.noUnescapedEntities=(0,eslint_devkit_1.createRule)({name:"no-unescaped-entities",meta:{interop:{runtimes:["eslint","oxlint"],nativeEquivalent:"react/no-unescaped-entities"},type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-unescaped-entities.md",description:"Prevent unescaped entities"},hasSuggestions:true,messages:{replaceWithAlt:"Replace with `{{alt}}`.",noUnescapedEntities:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Unescaped Entity",description:"Unescaped HTML entity in JSX text",severity:"MEDIUM",fix:"Use HTML entities (&lt;, &gt;, &quot;) or wrap in curly braces",documentationLink:"https://react.dev/learn/javascript-in-jsx-with-curly-braces"})},schema:[{type:"object",properties:{forbid:{type:"array",items:{anyOf:[{type:"string"},{type:"object",properties:{char:{type:"string"},alternatives:{type:"array",uniqueItems:true,items:{type:"string"}}}}]}}},additionalProperties:false}]},defaultOptions:[{}],createOnce(context,options){let forbid;function reportForbidden(node,list){const start=node.range[0];for(const entity of list){const char=typeof entity==="string"?entity:entity.char;if(!char)continue;const alternatives=typeof entity==="string"?[]:entity.alternatives??[];for(let index=0;index<node.raw.length;index++){if(node.raw[index]!==char)continue;const at=start+index;context.report({node,loc:{start:context.sourceCode.getLocFromIndex(at),end:context.sourceCode.getLocFromIndex(at+1)},messageId:"noUnescapedEntities",suggest:alternatives.map(alt=>({messageId:"replaceWithAlt",data:{alt},fix:fixer=>fixer.replaceTextRange([at,at+1],alt)}))})}}}return{before(){forbid=options()[0]?.forbid},JSXText(node){if(forbid){reportForbidden(node,forbid);return}const text=node.raw;if(!text.trim()){return}if(UNESCAPED_ENTITIES.test(text)){context.report({node,messageId:"noUnescapedEntities"})}}}}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noUnknownProperty=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const XML_ATTRIBUTES=["xmlns","xmlnsXlink","xmlLang","xmlBase","xmlSpace"];const VALID_DOM_PROPERTIES=new Set([...XML_ATTRIBUTES,"accept","acceptCharset","accessKey","action","allowFullScreen","allowTransparency","alt","async","autoComplete","autoFocus","autoPlay","capture","cellPadding","cellSpacing","challenge","charSet","checked","cite","classID","className","colSpan","cols","content","contentEditable","contextMenu","controls","coords","crossOrigin","data","dateTime","decoding","default","defer","dir","disabled","download","draggable","encType","fetchPriority","form","formAction","formEncType","formMethod","formNoValidate","formTarget","frameBorder","headers","height","hidden","high","href","hrefLang","htmlFor","httpEquiv","icon","id","inputMode","integrity","is","keyParams","keyType","kind","label","lang","list","loading","loop","low","manifest","marginHeight","marginWidth","max","maxLength","media","mediaGroup","method","min","minLength","multiple","muted","name","noValidate","nonce","open","optimum","pattern","placeholder","poster","preload","profile","radioGroup","readOnly","rel","required","reversed","role","rowSpan","rows","sandbox","scope","scoped","scrolling","seamless","selected","shape","size","sizes","span","spellCheck","src","srcDoc","srcLang","srcSet","start","step","style","summary","tabIndex","target","title","type","useMap","value","width","wmode","wrap","children","dangerouslySetInnerHTML","key","ref","suppressContentEditableWarning","suppressHydrationWarning","accentHeight","accumulate","additive","alignmentBaseline","allowReorder","alphabetic","amplitude","arabicForm","ascent","attributeName","attributeType","autoReverse","azimuth","baseFrequency","baselineShift","baseProfile","bbox","begin","bias","by","calcMode","capHeight","clip","clipPath","clipPathUnits","clipRule","colorInterpolation","colorInterpolationFilters","colorProfile","colorRendering","contentScriptType","contentStyleType","cursor","cx","cy","d","decelerate","descent","diffuseConstant","direction","display","divisor","dominantBaseline","dur","dx","dy","edgeMode","elevation","enableBackground","end","exponent","externalResourcesRequired","fill","fillOpacity","fillRule","filter","filterRes","filterUnits","floodColor","floodOpacity","focusable","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontVariant","fontWeight","format","from","fx","fy","g1","g2","glyphName","glyphOrientationHorizontal","glyphOrientationVertical","glyphRef","gradientTransform","gradientUnits","hanging","horizAdvX","horizOriginX","ideographic","imageRendering","in","in2","intercept","k","k1","k2","k3","k4","kernelMatrix","kernelUnitLength","kerning","keyPoints","keySplines","keyTimes","lengthAdjust","letterSpacing","lightingColor","limitingConeAngle","local","markerEnd","markerHeight","markerMid","markerStart","markerUnits","markerWidth","mask","maskContentUnits","maskUnits","mathematical","mode","numOctaves","offset","opacity","operator","order","orient","orientation","origin","overflow","overlinePosition","overlineThickness","paintOrder","panose1","pathLength","patternContentUnits","patternTransform","patternUnits","pointerEvents","points","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","r","radius","refX","refY","renderingIntent","repeatCount","repeatDur","requiredExtensions","requiredFeatures","restart","result","rotate","rx","ry","scale","seed","shapeRendering","slope","spacing","specularConstant","specularExponent","speed","spreadMethod","startOffset","stdDeviation","stemh","stemv","stitchTiles","stopColor","stopOpacity","strikethroughPosition","strikethroughThickness","string","stroke","strokeDasharray","strokeDashoffset","strokeLinecap","strokeLinejoin","strokeMiterlimit","strokeOpacity","strokeWidth","surfaceScale","systemLanguage","tableValues","targetX","targetY","textAnchor","textDecoration","textLength","textRendering","to","transform","u1","u2","underlinePosition","underlineThickness","unicode","unicodeBidi","unicodeRange","unitsPerEm","vAlphabetic","values","vectorEffect","version","vertAdvY","vertOriginX","vertOriginY","vHanging","vIdeographic","viewBox","viewTarget","visibility","vMathematical","widths","wordSpacing","writingMode","x","x1","x2","xChannelSelector","xHeight","xlinkActuate","xlinkArcrole","xlinkHref","xlinkRole","xlinkShow","xlinkTitle","xlinkType","xmlBase","xmlLang","xmlSpace","y","y1","y2","yChannelSelector","z","zoomAndPan","onAbort","onAnimationEnd","onAnimationIteration","onAnimationStart","onAuxClick","onBeforeInput","onBlur","onCanPlay","onCanPlayThrough","onChange","onClick","onCompositionEnd","onCompositionStart","onCompositionUpdate","onContextMenu","onCopy","onCut","onDoubleClick","onDrag","onDragEnd","onDragEnter","onDragExit","onDragLeave","onDragOver","onDragStart","onDrop","onDurationChange","onEmptied","onEncrypted","onEnded","onError","onFocus","onFocusIn","onFocusOut","onFormData","onGotPointerCapture","onInput","onInvalid","onKeyDown","onKeyPress","onKeyUp","onLoad","onLoadStart","onLoadedData","onLoadedMetadata","onLostPointerCapture","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp","onPaste","onPause","onPlay","onPlaying","onPointerCancel","onPointerDown","onPointerEnter","onPointerLeave","onPointerMove","onPointerOut","onPointerOver","onPointerUp","onProgress","onRateChange","onReset","onResize","onScroll","onSeeked","onSeeking","onSelect","onStalled","onSubmit","onSuspend","onTimeUpdate","onToggle","onTouchCancel","onTouchEnd","onTouchMove","onTouchStart","onTransitionEnd","onVolumeChange","onWaiting","onWheel"]);const REACT_PROPS=new Set(["defaultChecked","defaultValue","suppressContentEditableWarning","suppressHydrationWarning"]);exports.noUnknownProperty=(0,eslint_devkit_1.createRule)({name:"no-unknown-property",meta:{interop:{runtimes:["eslint","oxlint"],nativeEquivalent:"react/no-unknown-property"},type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-unknown-property.md",description:"Disallow unknown DOM properties"},schema:[],messages:{noUnknownProperty:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Unknown DOM Property",description:"`{{propName}}` is not a DOM property of `<{{elementName}}>`",severity:"MEDIUM",fix:"Use standard DOM properties or data attributes (data-*)",documentationLink:"https://react.dev/learn/writing-markup-with-jsx#html-attributes"})}},defaultOptions:[],createOnce(context){return{JSXAttribute(node){const elementName=node.parent.name;if(elementName.type!=="JSXIdentifier"||!/^[a-z]/.test(elementName.name)){return}if(elementName.name.includes("-")){return}if(node.name.type==="JSXIdentifier"){const propName=node.name.name;if(REACT_PROPS.has(propName)||propName.startsWith("data-")||propName.startsWith("aria-")){return}if(!VALID_DOM_PROPERTIES.has(propName)){context.report({node:node.name,messageId:"noUnknownProperty",data:{propName,elementName:elementName.name}})}}}}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noUnknownProperty=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const XML_ATTRIBUTES=["xmlns","xmlnsXlink","xmlLang","xmlBase","xmlSpace"];const VALID_DOM_PROPERTIES=new Set([...XML_ATTRIBUTES,"accept","acceptCharset","accessKey","action","allowFullScreen","allowTransparency","alt","async","autoComplete","autoFocus","autoPlay","capture","cellPadding","cellSpacing","challenge","charSet","checked","cite","classID","className","colSpan","cols","content","contentEditable","contextMenu","controls","coords","crossOrigin","data","dateTime","decoding","default","defer","dir","disabled","download","draggable","encType","fetchPriority","form","formAction","formEncType","formMethod","formNoValidate","formTarget","frameBorder","headers","height","hidden","high","href","hrefLang","htmlFor","httpEquiv","icon","id","inputMode","integrity","is","keyParams","keyType","kind","label","lang","list","loading","loop","low","manifest","marginHeight","marginWidth","max","maxLength","media","mediaGroup","method","min","minLength","multiple","muted","name","noValidate","nonce","open","optimum","pattern","placeholder","poster","preload","profile","radioGroup","readOnly","rel","required","reversed","role","rowSpan","rows","sandbox","scope","scoped","scrolling","seamless","selected","shape","size","sizes","span","spellCheck","src","srcDoc","srcLang","srcSet","start","step","style","summary","tabIndex","target","title","type","useMap","value","width","wmode","wrap","children","dangerouslySetInnerHTML","key","ref","suppressContentEditableWarning","suppressHydrationWarning","accentHeight","accumulate","additive","alignmentBaseline","allowReorder","alphabetic","amplitude","arabicForm","ascent","attributeName","attributeType","autoReverse","azimuth","baseFrequency","baselineShift","baseProfile","bbox","begin","bias","by","calcMode","capHeight","clip","clipPath","clipPathUnits","clipRule","colorInterpolation","colorInterpolationFilters","colorProfile","colorRendering","contentScriptType","contentStyleType","cursor","cx","cy","d","decelerate","descent","diffuseConstant","direction","display","divisor","dominantBaseline","dur","dx","dy","edgeMode","elevation","enableBackground","end","exponent","externalResourcesRequired","fill","fillOpacity","fillRule","filter","filterRes","filterUnits","floodColor","floodOpacity","focusable","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontVariant","fontWeight","format","from","fx","fy","g1","g2","glyphName","glyphOrientationHorizontal","glyphOrientationVertical","glyphRef","gradientTransform","gradientUnits","hanging","horizAdvX","horizOriginX","ideographic","imageRendering","in","in2","intercept","k","k1","k2","k3","k4","kernelMatrix","kernelUnitLength","kerning","keyPoints","keySplines","keyTimes","lengthAdjust","letterSpacing","lightingColor","limitingConeAngle","local","markerEnd","markerHeight","markerMid","markerStart","markerUnits","markerWidth","mask","maskContentUnits","maskUnits","mathematical","mode","numOctaves","offset","opacity","operator","order","orient","orientation","origin","overflow","overlinePosition","overlineThickness","paintOrder","panose1","pathLength","patternContentUnits","patternTransform","patternUnits","pointerEvents","points","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","r","radius","refX","refY","renderingIntent","repeatCount","repeatDur","requiredExtensions","requiredFeatures","restart","result","rotate","rx","ry","scale","seed","shapeRendering","slope","spacing","specularConstant","specularExponent","speed","spreadMethod","startOffset","stdDeviation","stemh","stemv","stitchTiles","stopColor","stopOpacity","strikethroughPosition","strikethroughThickness","string","stroke","strokeDasharray","strokeDashoffset","strokeLinecap","strokeLinejoin","strokeMiterlimit","strokeOpacity","strokeWidth","surfaceScale","systemLanguage","tableValues","targetX","targetY","textAnchor","textDecoration","textLength","textRendering","to","transform","u1","u2","underlinePosition","underlineThickness","unicode","unicodeBidi","unicodeRange","unitsPerEm","vAlphabetic","values","vectorEffect","version","vertAdvY","vertOriginX","vertOriginY","vHanging","vIdeographic","viewBox","viewTarget","visibility","vMathematical","widths","wordSpacing","writingMode","x","x1","x2","xChannelSelector","xHeight","xlinkActuate","xlinkArcrole","xlinkHref","xlinkRole","xlinkShow","xlinkTitle","xlinkType","xmlBase","xmlLang","xmlSpace","y","y1","y2","yChannelSelector","z","zoomAndPan","onAbort","onAnimationEnd","onAnimationIteration","onAnimationStart","onAuxClick","onBeforeInput","onBlur","onCanPlay","onCanPlayThrough","onChange","onClick","onCompositionEnd","onCompositionStart","onCompositionUpdate","onContextMenu","onCopy","onCut","onDoubleClick","onDrag","onDragEnd","onDragEnter","onDragExit","onDragLeave","onDragOver","onDragStart","onDrop","onDurationChange","onEmptied","onEncrypted","onEnded","onError","onFocus","onFocusIn","onFocusOut","onFormData","onGotPointerCapture","onInput","onInvalid","onKeyDown","onKeyPress","onKeyUp","onLoad","onLoadStart","onLoadedData","onLoadedMetadata","onLostPointerCapture","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp","onPaste","onPause","onPlay","onPlaying","onPointerCancel","onPointerDown","onPointerEnter","onPointerLeave","onPointerMove","onPointerOut","onPointerOver","onPointerUp","onProgress","onRateChange","onReset","onResize","onScroll","onSeeked","onSeeking","onSelect","onStalled","onSubmit","onSuspend","onTimeUpdate","onToggle","onTouchCancel","onTouchEnd","onTouchMove","onTouchStart","onTransitionEnd","onVolumeChange","onWaiting","onWheel"]);const REACT_PROPS=new Set(["defaultChecked","defaultValue","suppressContentEditableWarning","suppressHydrationWarning"]);const isValidDataAttribute=name=>!/^data-xml/i.test(name)&&/^data-[^:]*$/.test(name);exports.noUnknownProperty=(0,eslint_devkit_1.createRule)({name:"no-unknown-property",meta:{interop:{runtimes:["eslint","oxlint"],nativeEquivalent:"react/no-unknown-property"},type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-unknown-property.md",description:"Disallow unknown DOM properties"},schema:[{type:"object",properties:{ignore:{type:"array",items:{type:"string"}},requireDataLowercase:{type:"boolean",default:false}},additionalProperties:false}],messages:{dataLowercaseRequired:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Uppercase data-* Attribute",description:"React does not recognize data-* props with uppercase characters on a DOM element. Found '{{name}}', use '{{lowerCaseName}}' instead",severity:"MEDIUM",fix:"Write the data-* attribute name in lowercase",documentationLink:"https://react.dev/learn/writing-markup-with-jsx#html-attributes"}),noUnknownProperty:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Unknown DOM Property",description:"`{{propName}}` is not a DOM property of `<{{elementName}}>`",severity:"MEDIUM",fix:"Use standard DOM properties or data attributes (data-*)",documentationLink:"https://react.dev/learn/writing-markup-with-jsx#html-attributes"})}},defaultOptions:[{}],createOnce(context,options){let ignore;let requireDataLowercase=false;return{before(){const[config]=options();ignore=new Set(config?.ignore);requireDataLowercase=config?.requireDataLowercase??false},JSXAttribute(node){if(ignore.has(context.sourceCode.getText(node.name)))return;if(node.parent.name.type==="JSXMemberExpression")return;if(requireDataLowercase&&node.name.type==="JSXIdentifier"&&isValidDataAttribute(node.name.name)&&node.name.name!==node.name.name.toLowerCase()){context.report({node,messageId:"dataLowercaseRequired",data:{name:node.name.name,lowerCaseName:node.name.name.toLowerCase()}});return}const elementName=node.parent.name;if(elementName.type!=="JSXIdentifier"||!/^[a-z]/.test(elementName.name)){return}if(elementName.name.includes("-")){return}if(node.name.type==="JSXIdentifier"){const propName=node.name.name;if(REACT_PROPS.has(propName)||propName.startsWith("data-")||propName.startsWith("aria-")){return}const isKnownCaptureVariant=propName.endsWith("Capture")&&VALID_DOM_PROPERTIES.has(propName.slice(0,-"Capture".length));if(!VALID_DOM_PROPERTIES.has(propName)&&!isKnownCaptureVariant){context.report({node:node.name,messageId:"noUnknownProperty",data:{propName,elementName:elementName.name}})}}}}}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noUnsafe=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const react_api_1=require("../../utils/react-api");const UNSAFE_METHODS={UNSAFE_componentWillMount:{replacement:"componentDidMount or useEffect"},UNSAFE_componentWillReceiveProps:{replacement:"static getDerivedStateFromProps or useEffect"},UNSAFE_componentWillUpdate:{replacement:"getSnapshotBeforeUpdate or useEffect"}};const LEGACY_METHODS={componentWillMount:{replacement:"componentDidMount or useEffect"},componentWillReceiveProps:{replacement:"static getDerivedStateFromProps or useEffect"},componentWillUpdate:{replacement:"getSnapshotBeforeUpdate or useEffect"}};exports.noUnsafe=(0,eslint_devkit_2.createRule)({name:"no-unsafe",meta:{interop:{runtimes:["eslint","oxlint"],nativeEquivalent:"react/no-unsafe"},type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-unsafe.md",description:"Prevent usage of unsafe lifecycle methods"},messages:{noUnsafe:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.WARNING,issueName:"Unsafe Lifecycle Method",description:'"{{method}}" is unsafe and may cause bugs in concurrent mode',severity:"HIGH",fix:"Use {{replacement}} instead",documentationLink:"https://react.dev/blog/2018/03/27/update-on-async-rendering"})},schema:[{type:"object",properties:{checkAliases:{type:"boolean",default:false}},additionalProperties:false}]},defaultOptions:[{}],createOnce(context,currentOptions){let checkAliases;function checkMethod(node){if(node.static)return;const owner=node.parent.parent;if(owner.type!=="ClassDeclaration"&&owner.type!=="ClassExpression"||!(0,react_api_1.extendsReactComponent)(owner,context.sourceCode.getScope(owner)))return;const methodName=(0,eslint_devkit_1.objectKeyName)(node);if(methodName===null)return;const info=Object.hasOwn(UNSAFE_METHODS,methodName)&&UNSAFE_METHODS[methodName]||checkAliases&&Object.hasOwn(LEGACY_METHODS,methodName)&&LEGACY_METHODS[methodName];if(info){context.report({node,messageId:"noUnsafe",data:{method:methodName,replacement:info.replacement}})}}return{before(){const[options={}]=currentOptions();({checkAliases=false}=options??{})},MethodDefinition:checkMethod,PropertyDefinition:checkMethod}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noUnsafe=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const react_api_1=require("../../utils/react-api");const react_settings_1=require("../../utils/react-settings");const UNSAFE_METHODS={UNSAFE_componentWillMount:{replacement:"componentDidMount or useEffect"},UNSAFE_componentWillReceiveProps:{replacement:"static getDerivedStateFromProps or useEffect"},UNSAFE_componentWillUpdate:{replacement:"getSnapshotBeforeUpdate or useEffect"}};const LEGACY_METHODS={componentWillMount:{replacement:"componentDidMount or useEffect"},componentWillReceiveProps:{replacement:"static getDerivedStateFromProps or useEffect"},componentWillUpdate:{replacement:"getSnapshotBeforeUpdate or useEffect"}};exports.noUnsafe=(0,eslint_devkit_2.createRule)({name:"no-unsafe",meta:{interop:{runtimes:["eslint","oxlint"],nativeEquivalent:"react/no-unsafe"},type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-unsafe.md",description:"Prevent usage of unsafe lifecycle methods"},messages:{noUnsafe:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.WARNING,issueName:"Unsafe Lifecycle Method",description:'"{{method}}" is unsafe and may cause bugs in concurrent mode',severity:"HIGH",fix:"Use {{replacement}} instead",documentationLink:"https://react.dev/blog/2018/03/27/update-on-async-rendering"})},schema:[{type:"object",properties:{checkAliases:{type:"boolean",default:false}},additionalProperties:false}]},defaultOptions:[{}],createOnce(context,currentOptions){let checkAliases;let applicable;function checkMethod(node){if(!applicable||node.static)return;const owner=node.parent.parent;if(owner.type!=="ClassDeclaration"&&owner.type!=="ClassExpression"||!(0,react_api_1.extendsReactComponent)(owner,context.sourceCode.getScope(owner)))return;const methodName=(0,eslint_devkit_1.objectKeyName)(node);if(methodName===null)return;const info=Object.hasOwn(UNSAFE_METHODS,methodName)&&UNSAFE_METHODS[methodName]||checkAliases&&Object.hasOwn(LEGACY_METHODS,methodName)&&LEGACY_METHODS[methodName];if(info){context.report({node,messageId:"noUnsafe",data:{method:methodName,replacement:info.replacement}})}}return{before(){const[options={}]=currentOptions();({checkAliases=false}=options??{});applicable=(0,react_settings_1.reactVersionAtLeast)(context,"16.3.0")},MethodDefinition:checkMethod,PropertyDefinition:checkMethod}}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.reactInJsxScope=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");exports.reactInJsxScope=(0,eslint_devkit_1.createRule)({name:"react-in-jsx-scope",meta:{interop:{runtimes:["eslint","oxlint"],nativeEquivalent:"react/react-in-jsx-scope"},type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/react-in-jsx-scope.md",description:"Ensure React is in scope"},schema:[],messages:{reactInJsxScope:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"React Not in Scope",description:"React must be in scope when using JSX",severity:"CRITICAL",fix:'Add import React from "react" at the top of the file',documentationLink:"https://react.dev/learn/add-react-to-a-website#optional-using-jsx-without-a-build-step"})}},defaultOptions:[],createOnce(context){let automatic;function declaresValue(def){if(def.type==="Type")return false;if(def.type!=="ImportBinding")return true;const declaration=def.parent;const specifier=def.node;return declaration.importKind!=="type"&&specifier.importKind!=="type"}function reactInScope(scope){for(let s=scope;s!==null;s=s.upper){const variable=s.set.get("React");if(variable?.defs.some(declaresValue))return true}return false}function check(node){if(automatic||reactInScope(context.sourceCode.getScope(node)))return;context.report({node:node.type==="JSXOpeningElement"?node.name:node,messageId:"reactInJsxScope"})}return{Program(){automatic=context.sourceCode.getAllComments().some(c=>/@jsxRuntime\s+automatic\b/.test(c.value))},JSXOpeningElement:check,JSXOpeningFragment:check}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.reactInJsxScope=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const react_settings_1=require("../../utils/react-settings");exports.reactInJsxScope=(0,eslint_devkit_1.createRule)({name:"react-in-jsx-scope",meta:{interop:{runtimes:["eslint","oxlint"],nativeEquivalent:"react/react-in-jsx-scope"},type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/react-in-jsx-scope.md",description:"Ensure React is in scope"},schema:[],messages:{reactInJsxScope:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"React Not in Scope",description:"React must be in scope when using JSX",severity:"CRITICAL",fix:'Add import React from "react" at the top of the file',documentationLink:"https://react.dev/learn/add-react-to-a-website#optional-using-jsx-without-a-build-step"})}},defaultOptions:[],createOnce(context){let automatic;let pragma;function declaresValue(def){if(def.type==="Type")return false;if(def.type!=="ImportBinding")return true;const declaration=def.parent;const specifier=def.node;return declaration.importKind!=="type"&&specifier.importKind!=="type"}function reactInScope(scope){for(let s=scope;s!==null;s=s.upper){const variable=s.set.get(pragma);if(variable?.defs.some(declaresValue))return true}return false}function check(node){if(automatic||reactInScope(context.sourceCode.getScope(node)))return;context.report({node:node.type==="JSXOpeningElement"?node.name:node,messageId:"reactInJsxScope"})}return{Program(){pragma=(0,react_settings_1.getPragma)(context);automatic=context.sourceCode.getAllComments().some(c=>/@jsxRuntime\s+automatic\b/.test(c.value))},JSXOpeningElement:check,JSXOpeningFragment:check}}});
@@ -0,0 +1 @@
1
+ "use strict";var __importDefault=this&&this.__importDefault||function(mod){return mod&&mod.__esModule?mod:{"default":mod}};Object.defineProperty(exports,"__esModule",{value:true});exports.getPragma=getPragma;exports.getFragmentPragma=getFragmentPragma;exports.getCreateClassPragma=getCreateClassPragma;exports.parseVersion=parseVersion;exports.getReactVersion=getReactVersion;exports.reactVersionAtLeast=reactVersionAtLeast;exports.reactVersionBelow=reactVersionBelow;const node_fs_1=__importDefault(require("node:fs"));const node_module_1=require("node:module");const node_path_1=__importDefault(require("node:path"));const LATEST=[999,999,999];const JSX_ANNOTATION=/@jsx\s+([^\s]+)/;const JS_IDENTIFIER=/^[_$a-zA-Z][_$a-zA-Z0-9]*$/;function reactSettings(context){const react=context.settings?.react;return react&&typeof react==="object"?react:{}}function getPragma(context){let pragma="React";const annotated=context.sourceCode.getAllComments().find(comment=>JSX_ANNOTATION.test(comment.value));if(annotated){pragma=JSX_ANNOTATION.exec(annotated.value)[1].split(".")[0]}else{const configured=reactSettings(context).pragma;if(typeof configured==="string"&&configured)pragma=configured}return JS_IDENTIFIER.test(pragma)?pragma:"React"}function getFragmentPragma(context){const configured=reactSettings(context).fragment;return typeof configured==="string"&&JS_IDENTIFIER.test(configured)?configured:"Fragment"}function getCreateClassPragma(context){const configured=reactSettings(context).createClass;return typeof configured==="string"&&JS_IDENTIFIER.test(configured)?configured:"createReactClass"}function parseVersion(text){const m=/(\d+)(?:\.(\d+))?(?:\.(\d+))?/.exec(text);return m?[Number(m[1]),Number(m[2]??0),Number(m[3]??0)]:null}function compare(a,b){return a[0]-b[0]||a[1]-b[1]||a[2]-b[2]}const detected=new Map;function isDirectory(candidate){try{return node_fs_1.default.statSync(candidate).isDirectory()}catch{return false}}function baseDirectory(context){const filename=context.filename;if(filename&&node_path_1.default.isAbsolute(filename)){let dir=node_path_1.default.dirname(filename);while(!isDirectory(dir))dir=node_path_1.default.dirname(dir);return dir}return context.cwd||process.cwd()}function detectInstalled(context){const base=baseDirectory(context);if(detected.has(base))return detected.get(base)??null;let version=null;try{const manifest=(0,node_module_1.createRequire)(node_path_1.default.join(base,"noop.js")).resolve("react/package.json");const raw=JSON.parse(node_fs_1.default.readFileSync(manifest,"utf8"));version=typeof raw.version==="string"?parseVersion(raw.version):null}catch{version=null}detected.set(base,version);return version}function getReactVersion(context){const settings=reactSettings(context);const fallback=typeof settings.defaultVersion==="string"?parseVersion(settings.defaultVersion)??LATEST:LATEST;const configured=settings.version;if(configured==="detect")return detectInstalled(context)??fallback;if(typeof configured==="string"){return parseVersion(configured)??fallback}return fallback}function reactVersionAtLeast(context,minimum){const min=parseVersion(minimum);return min!==null&&compare(getReactVersion(context),min)>=0}function reactVersionBelow(context,limit){const max=parseVersion(limit);return max!==null&&compare(getReactVersion(context),max)<0}