eslint-plugin-react-features 1.7.1 → 1.7.3
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/README.md +2 -2
- package/package.json +10 -2
- package/src/index.js +1 -1
- package/src/rules/migration/react-class-to-hooks.js +1 -1
- package/src/rules/react/default-props-match-prop-types.js +1 -1
- package/src/rules/react/no-direct-mutation-state.js +1 -1
- package/src/rules/react/no-typos.js +1 -1
- package/src/rules/react/require-default-props.js +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<a href="https://eslint.interlace.tools
|
|
2
|
+
<a href="https://eslint.interlace.tools/docs/quality/plugin-react-features?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features" target="blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://eslint.interlace.tools/logos/interlace-dark.svg"><img src="https://eslint.interlace.tools/logos/interlace-light.svg" alt="Interlace" height="90" /></picture></a>
|
|
3
3
|
|
|
4
4
|
<a href="https://react.dev" target="_blank"><img src="https://eslint.interlace.tools/logos/react.svg" alt="React" height="90" /></a>
|
|
5
5
|
|
|
@@ -210,5 +210,5 @@ MIT © [Ofri Peretz](https://github.com/ofri-peretz)
|
|
|
210
210
|
</p>
|
|
211
211
|
|
|
212
212
|
<p align="center">
|
|
213
|
-
<a href="https://eslint.interlace.tools
|
|
213
|
+
<a href="https://eslint.interlace.tools/docs/quality/plugin-react-features?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features" target="blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://eslint.interlace.tools/logos/interlace-dark.svg"><img src="https://eslint.interlace.tools/logos/interlace-light.svg" alt="Interlace" height="70" /></picture></a>
|
|
214
214
|
</p>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-features",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.3",
|
|
4
4
|
"description": "ESLint plugin for React — hooks, prop-types, JSX correctness, render performance, and class-to-hooks migration rules for modern React codebases.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
}
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@interlace/eslint-devkit": "^1.19.
|
|
72
|
+
"@interlace/eslint-devkit": "^1.19.2"
|
|
73
73
|
},
|
|
74
74
|
"repository": {
|
|
75
75
|
"type": "git",
|
|
@@ -83,5 +83,13 @@
|
|
|
83
83
|
"funding": {
|
|
84
84
|
"type": "github",
|
|
85
85
|
"url": "git+https://github.com/ofri-peretz/eslint.git"
|
|
86
|
+
},
|
|
87
|
+
"interlace": {
|
|
88
|
+
"surface": {
|
|
89
|
+
"kind": "npm",
|
|
90
|
+
"modules": [
|
|
91
|
+
"react"
|
|
92
|
+
]
|
|
93
|
+
}
|
|
86
94
|
}
|
|
87
95
|
}
|
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:"1.7.1"},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"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:"1.7.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 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.reactClassToHooks=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");exports.reactClassToHooks=(0,eslint_devkit_2.createRule)({name:"react-class-to-hooks",meta:{type:"suggestion",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/react-class-to-hooks.md",description:"Suggest migrating React class components to hooks with detailed migration path",cwe:"CWE-1078",cvss:5},fixable:"code",hasSuggestions:true,messages:{migrateToHooks:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.MIGRATION,issueName:"React class component",cwe:"CWE-1078",description:"React class component detected",severity:"MEDIUM",fix:"Use functional component with useEffect/useState (Complexity: {{complexity}})",documentationLink:"https://react.dev/reference/react/hooks"}),convertToFunction:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Convert to Functional",description:"Convert to functional component with hooks",severity:"LOW",fix:"function Component() { const [state, setState] = useState() }",documentationLink:"https://react.dev/reference/react/hooks"}),viewMigrationGuide:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Migration Guide",description:"View detailed migration guide",severity:"LOW",fix:"Follow React hooks migration guide",documentationLink:"https://react.dev/reference/react/hooks"})},schema:[{type:"object",properties:{ignorePureRenderComponents:{type:"boolean",default:false},allowComplexLifecycle:{type:"boolean",default:false}},additionalProperties:false}]},defaultOptions:[{ignorePureRenderComponents:false,allowComplexLifecycle:false}],create(context){const options=context.options[0]||{};const{allowComplexLifecycle=false}=options;const sourceCode=context.sourceCode;const isReactComponent=node=>{if(!node.superClass)return false;if(node.superClass.type===
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.reactClassToHooks=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");exports.reactClassToHooks=(0,eslint_devkit_2.createRule)({name:"react-class-to-hooks",meta:{type:"suggestion",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/react-class-to-hooks.md",description:"Suggest migrating React class components to hooks with detailed migration path",cwe:"CWE-1078",cvss:5},fixable:"code",hasSuggestions:true,messages:{migrateToHooks:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.MIGRATION,issueName:"React class component",cwe:"CWE-1078",description:"React class component detected",severity:"MEDIUM",fix:"Use functional component with useEffect/useState (Complexity: {{complexity}})",documentationLink:"https://react.dev/reference/react/hooks"}),convertToFunction:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Convert to Functional",description:"Convert to functional component with hooks",severity:"LOW",fix:"function Component() { const [state, setState] = useState() }",documentationLink:"https://react.dev/reference/react/hooks"}),viewMigrationGuide:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Migration Guide",description:"View detailed migration guide",severity:"LOW",fix:"Follow React hooks migration guide",documentationLink:"https://react.dev/reference/react/hooks"})},schema:[{type:"object",properties:{ignorePureRenderComponents:{type:"boolean",default:false},allowComplexLifecycle:{type:"boolean",default:false}},additionalProperties:false}]},defaultOptions:[{ignorePureRenderComponents:false,allowComplexLifecycle:false}],create(context){const options=context.options[0]||{};const{allowComplexLifecycle=false}=options;const sourceCode=context.sourceCode;const isReactComponent=node=>{if(!node.superClass)return false;if(node.superClass.type===eslint_devkit_2.AST_NODE_TYPES.Identifier){return node.superClass.name==="Component"||node.superClass.name==="PureComponent"}if(node.superClass.type===eslint_devkit_2.AST_NODE_TYPES.MemberExpression){if(node.superClass.object.type===eslint_devkit_2.AST_NODE_TYPES.Identifier&&node.superClass.object.name==="React"){const base=(0,eslint_devkit_2.propertyName)(node.superClass);return base==="Component"||base==="PureComponent"}}return false};const analyzeLifecycleMethods=node=>{const lifecycleMethods=[];const classBody=node.body.body;const lifecycleMap={componentDidMount:"useEffect",componentDidUpdate:"useEffect",componentWillUnmount:"useEffect cleanup",shouldComponentUpdate:"React.memo",getDerivedStateFromProps:"useState + useEffect",getSnapshotBeforeUpdate:"useEffect"};for(const member of classBody){if(member.type===eslint_devkit_2.AST_NODE_TYPES.MethodDefinition&&member.key.type===eslint_devkit_2.AST_NODE_TYPES.Identifier&&lifecycleMap[member.key.name]){lifecycleMethods.push(member.key.name)}}const suggestedHooks=[...new Set(lifecycleMethods.map(m=>lifecycleMap[m]))];let complexity="simple";if(lifecycleMethods.length>2)complexity="medium";if(lifecycleMethods.includes("getDerivedStateFromProps")||lifecycleMethods.includes("getSnapshotBeforeUpdate")){complexity="complex"}return{methods:lifecycleMethods,suggestedHooks,complexity}};return{ClassDeclaration(node){if(!isReactComponent(node))return;if(!node.id)return;const componentName=node.id.name;const{complexity,methods:lifecycleMethods}=analyzeLifecycleMethods(node);const hasRenderMethod=node.body.body.some(member=>member.type===eslint_devkit_2.AST_NODE_TYPES.MethodDefinition&&(0,eslint_devkit_2.objectKeyName)(member)==="render");if(complexity==="complex"&&allowComplexLifecycle){return}context.report({node,messageId:"migrateToHooks",data:{componentName,complexity},...complexity==="simple"&&lifecycleMethods.length===0&&!hasRenderMethod?{suggest:[{messageId:"convertToFunction",fix:fixer=>{const classText=sourceCode.getText(node);const funcText=classText.replace(/class\s+(\w+)\s+extends\s+\w+(?:\s*\.\s*\w+|\s*\[\s*(['"])[^'"]+\2\s*\])?/,"function $1(props)").replace(/this\.props\./g,"props.").replace(/this\.state\.(\w+)/g,(_,name)=>name);return fixer.replaceText(node,funcText)}}]}:{}})}}}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.defaultPropsMatchPropTypes=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");exports.defaultPropsMatchPropTypes=(0,eslint_devkit_1.createRule)({name:"default-props-match-prop-types",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/default-props-match-prop-types.md",description:"Validate default props match prop types"},schema:[],messages:{defaultPropsMatchPropTypes:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Default Props Mismatch",description:"Default prop does not match prop type",severity:"MEDIUM",fix:"Update default prop to match propTypes or update propTypes",documentationLink:"https://react.dev/learn/components-and-props#default-props"})}},defaultOptions:[],create(context){const propTypes=new Map;const defaultProps=new Map;return{'PropertyDefinition[key.name="propTypes"]'(node){if(node.value&&node.value.type==="ObjectExpression"){for(const prop of node.value.properties){if(prop.type==="Property"&&prop.key.type==="Identifier"){propTypes.set(prop.key.name,prop)}}}},'PropertyDefinition[key.name="defaultProps"]'(node){if(node.value&&node.value.type==="ObjectExpression"){for(const prop of node.value.properties){if(prop.type==="Property"&&prop.key.type==="Identifier"){defaultProps.set(prop.key.name,prop)}}}},"ClassDeclaration:exit"(){for(const[propName,defaultProp]of defaultProps){const propType=propTypes.get(propName);if(propType&&defaultProp.value&&propType.value&&defaultProp.value.type!=="TSEmptyBodyFunctionExpression"&&propType.value.type!=="TSEmptyBodyFunctionExpression"&&!isPattern(defaultProp.value)&&!isPattern(propType.value)&&!isCompatibleDefaultValue(defaultProp.value,propType.value)){context.report({node:defaultProp.key,messageId:"defaultPropsMatchPropTypes"})}}propTypes.clear();defaultProps.clear()}}}});function isCompatibleDefaultValue(defaultValue,propType){if(defaultValue.type==="Literal"&&propType.type==="MemberExpression"){const propTypeName=getPropTypeName(propType);const defaultType=typeof defaultValue.value;switch(propTypeName){case"string":return defaultType==="string";case"number":return defaultType==="number";case"bool":return defaultType==="boolean";default:return true}}return true}function getPropTypeName(node){if(node.object.type==="Identifier"&&node.object.name==="PropTypes"
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.defaultPropsMatchPropTypes=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");exports.defaultPropsMatchPropTypes=(0,eslint_devkit_1.createRule)({name:"default-props-match-prop-types",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/default-props-match-prop-types.md",description:"Validate default props match prop types"},schema:[],messages:{defaultPropsMatchPropTypes:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Default Props Mismatch",description:"Default prop does not match prop type",severity:"MEDIUM",fix:"Update default prop to match propTypes or update propTypes",documentationLink:"https://react.dev/learn/components-and-props#default-props"})}},defaultOptions:[],create(context){const propTypes=new Map;const defaultProps=new Map;return{'PropertyDefinition[key.name="propTypes"]'(node){if(node.value&&node.value.type==="ObjectExpression"){for(const prop of node.value.properties){if(prop.type==="Property"&&prop.key.type==="Identifier"){propTypes.set(prop.key.name,prop)}}}},'PropertyDefinition[key.name="defaultProps"]'(node){if(node.value&&node.value.type==="ObjectExpression"){for(const prop of node.value.properties){if(prop.type==="Property"&&prop.key.type==="Identifier"){defaultProps.set(prop.key.name,prop)}}}},"ClassDeclaration:exit"(){for(const[propName,defaultProp]of defaultProps){const propType=propTypes.get(propName);if(propType&&defaultProp.value&&propType.value&&defaultProp.value.type!=="TSEmptyBodyFunctionExpression"&&propType.value.type!=="TSEmptyBodyFunctionExpression"&&!isPattern(defaultProp.value)&&!isPattern(propType.value)&&!isCompatibleDefaultValue(defaultProp.value,propType.value)){context.report({node:defaultProp.key,messageId:"defaultPropsMatchPropTypes"})}}propTypes.clear();defaultProps.clear()}}}});function isCompatibleDefaultValue(defaultValue,propType){if(defaultValue.type==="Literal"&&propType.type==="MemberExpression"){const propTypeName=getPropTypeName(propType);const defaultType=typeof defaultValue.value;switch(propTypeName){case"string":return defaultType==="string";case"number":return defaultType==="number";case"bool":return defaultType==="boolean";default:return true}}return true}function getPropTypeName(node){if(node.object.type==="Identifier"&&node.object.name==="PropTypes"){return(0,eslint_devkit_1.propertyName)(node)??""}return""}function isPattern(node){return node.type==="AssignmentPattern"||node.type==="ArrayPattern"||node.type==="ObjectPattern"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noDirectMutationState=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");exports.noDirectMutationState=(0,eslint_devkit_1.createRule)({name:"no-direct-mutation-state",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-direct-mutation-state.md",description:"Prevent direct mutation of this.state that breaks React reconciliation"},hasSuggestions:true,messages:{noDirectMutationState:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Direct State Mutation",description:"Never mutate this.state directly",severity:"HIGH",fix:"Use setState() or functional updates for immutable state changes",documentationLink:"https://react.dev/learn/state-and-lifecycle#state-updates-may-be-asynchronous"}),suggestSetState:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"State Update",description:"Use setState with object for state updates",severity:"MEDIUM",fix:"Use this.setState({ count: this.state.count + 1 })",documentationLink:"https://react.dev/reference/react/Component#setstate"}),suggestFunctionalUpdate:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Functional State Update",description:"Use functional setState for immutable updates",severity:"MEDIUM",fix:"Use this.setState(prevState => ({ count: prevState.count + 1 }))",documentationLink:"https://react.dev/reference/react/Component#setstate"})},schema:[{type:"object",properties:{allowInLifecycleMethods:{type:"boolean",default:false}},additionalProperties:false}]},defaultOptions:[{allowInLifecycleMethods:false}],create(context){const[options]=context.options;const{allowInLifecycleMethods=false}=options||{};let inClassComponent=false;let inLifecycleMethod=false;const classStack=[];function isLifecycleMethod(methodName){const lifecycleMethods=["componentDidMount","componentDidUpdate","componentWillUnmount","componentWillMount","componentWillReceiveProps","componentWillUpdate","shouldComponentUpdate","getSnapshotBeforeUpdate","getDerivedStateFromProps","getDerivedStateFromError","componentDidCatch"];return lifecycleMethods.includes(methodName)}function isInReactClassComponent(){return inClassComponent}function reportStateMutation(node,mutationType){if(!isInReactClassComponent()){return}if(allowInLifecycleMethods&&inLifecycleMethod){return}context.report({node,messageId:"noDirectMutationState",data:{mutationType,context:inLifecycleMethod?"lifecycle method":"regular method"},suggest:[{messageId:"suggestSetState",fix(fixer){const sourceCode=context.sourceCode;const start=node.range[0];const lineStart=sourceCode.getIndexFromLoc({line:sourceCode.getLocFromIndex(start).line,column:0});const lineText=sourceCode.getText().slice(lineStart,start);const indent=lineText.slice(0,lineText.length-lineText.trimStart().length);return fixer.insertTextBefore(node,`// TODO: Use setState instead of direct mutation
|
|
2
2
|
${indent}`)}},{messageId:"suggestFunctionalUpdate",fix(fixer){const sourceCode=context.sourceCode;const start=node.range[0];const lineStart=sourceCode.getIndexFromLoc({line:sourceCode.getLocFromIndex(start).line,column:0});const lineText=sourceCode.getText().slice(lineStart,start);const indent=lineText.slice(0,lineText.length-lineText.trimStart().length);return fixer.insertTextBefore(node,`// TODO: Use functional setState for immutable updates
|
|
3
|
-
${indent}`)}}]})}function isStatePropertyAccess(target){if(target.type==="MemberExpression"&&target.object.type==="MemberExpression"&&target.object.object.type==="ThisExpression"&&(0,eslint_devkit_1.propertyName)(target.object)==="state"){return true}if(target.type==="MemberExpression"){return isStatePropertyAccess(target.object)}if(target.type==="LogicalExpression"){return isStatePropertyAccess(target.left)}return false}return{ClassDeclaration(node){if(node.superClass){if(node.superClass.type==="Identifier"&&["Component","PureComponent"].includes(node.superClass.name)){inClassComponent=true;classStack.push(true)}else if(node.superClass.type==="MemberExpression"&&node.superClass.object.type==="Identifier"&&node.superClass.object.name==="React"&&
|
|
3
|
+
${indent}`)}}]})}function isStatePropertyAccess(target){if(target.type==="MemberExpression"&&target.object.type==="MemberExpression"&&target.object.object.type==="ThisExpression"&&(0,eslint_devkit_1.propertyName)(target.object)==="state"){return true}if(target.type==="MemberExpression"){return isStatePropertyAccess(target.object)}if(target.type==="LogicalExpression"){return isStatePropertyAccess(target.left)}return false}return{ClassDeclaration(node){if(node.superClass){if(node.superClass.type==="Identifier"&&["Component","PureComponent"].includes(node.superClass.name)){inClassComponent=true;classStack.push(true)}else if(node.superClass.type==="MemberExpression"&&node.superClass.object.type==="Identifier"&&node.superClass.object.name==="React"&&["Component","PureComponent"].includes((0,eslint_devkit_1.propertyName)(node.superClass)??"")){inClassComponent=true;classStack.push(true)}}},"ClassDeclaration:exit"(){classStack.pop();inClassComponent=classStack.length>0&&classStack[classStack.length-1]},MethodDefinition(node){if(node.key.type==="Identifier"){inLifecycleMethod=isLifecycleMethod(node.key.name)}},"MethodDefinition:exit"(){inLifecycleMethod=false},AssignmentExpression(node){if(node.left.type==="MemberExpression"){if(isStatePropertyAccess(node.left)){reportStateMutation(node,"assignment")}}},UpdateExpression(node){if(node.argument.type==="MemberExpression"){if(isStatePropertyAccess(node.argument)){reportStateMutation(node,"update")}}},UnaryExpression(node){if(node.operator==="delete"&&node.argument.type==="MemberExpression"){if(isStatePropertyAccess(node.argument)){reportStateMutation(node,"delete operator")}}},CallExpression(node){const methodName=(0,eslint_devkit_1.memberPropertyName)(node.callee);if(node.callee.type==="MemberExpression"&&methodName!==null){if(isStatePropertyAccess(node.callee.object)){const mutatingMethods=["push","pop","shift","unshift","splice","sort","reverse","copyWithin","fill","defineProperty","deleteProperty","setPrototypeOf"];if(mutatingMethods.includes(methodName)){reportStateMutation(node,`mutating method (${methodName})`)}}}}}}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noTypos=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const COMMON_TYPOS=new Map([["defaulProps","defaultProps"],["defaulProps","defaultProps"],["defalutProps","defaultProps"],["defualtProps","defaultProps"],["DefaulProps","DefaultProps"],["DefalutProps","DefaultProps"],["DefualtProps","DefaultProps"],["propTypes","propTypes"],["PropTypes","PropTypes"],["componenDidMount","componentDidMount"],["componenDidUpdate","componentDidUpdate"],["componenWillUnmount","componentWillUnmount"],["componenWillMount","componentWillMount"],["componenWillReceiveProps","componentWillReceiveProps"],["componenWillUpdate","componentWillUpdate"],["shoudComponentUpdate","shouldComponentUpdate"],["getDerivedStateFromProps","getDerivedStateFromProps"],["getSnapshoBeforeUpdate","getSnapshotBeforeUpdate"],["UNSAFE_componenWillMount","UNSAFE_componentWillMount"],["UNSAFE_componenWillReceiveProps","UNSAFE_componentWillReceiveProps"],["UNSAFE_componenWillUpdate","UNSAFE_componentWillUpdate"]]);exports.noTypos=(0,eslint_devkit_1.createRule)({name:"no-typos",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-typos.md",description:"Catch common typos"},schema:[],messages:{noTypos:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Typo Detected",description:"Common typo in React method/property name",severity:"LOW",fix:"Correct the spelling to match React API",documentationLink:"https://react.dev/reference/react/Component"})}},defaultOptions:[],create(context){return{PropertyDefinition(node){
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noTypos=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const COMMON_TYPOS=new Map([["defaulProps","defaultProps"],["defaulProps","defaultProps"],["defalutProps","defaultProps"],["defualtProps","defaultProps"],["DefaulProps","DefaultProps"],["DefalutProps","DefaultProps"],["DefualtProps","DefaultProps"],["propTypes","propTypes"],["PropTypes","PropTypes"],["componenDidMount","componentDidMount"],["componenDidUpdate","componentDidUpdate"],["componenWillUnmount","componentWillUnmount"],["componenWillMount","componentWillMount"],["componenWillReceiveProps","componentWillReceiveProps"],["componenWillUpdate","componentWillUpdate"],["shoudComponentUpdate","shouldComponentUpdate"],["getDerivedStateFromProps","getDerivedStateFromProps"],["getSnapshoBeforeUpdate","getSnapshotBeforeUpdate"],["UNSAFE_componenWillMount","UNSAFE_componentWillMount"],["UNSAFE_componenWillReceiveProps","UNSAFE_componentWillReceiveProps"],["UNSAFE_componenWillUpdate","UNSAFE_componentWillUpdate"]]);exports.noTypos=(0,eslint_devkit_1.createRule)({name:"no-typos",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-typos.md",description:"Catch common typos"},schema:[],messages:{noTypos:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Typo Detected",description:"Common typo in React method/property name",severity:"LOW",fix:"Correct the spelling to match React API",documentationLink:"https://react.dev/reference/react/Component"})}},defaultOptions:[],create(context){return{PropertyDefinition(node){const name=(0,eslint_devkit_1.objectKeyName)(node);if(name!==null){const correction=COMMON_TYPOS.get(name);if(correction){context.report({node:node.key,messageId:"noTypos"})}}},MethodDefinition(node){const name=(0,eslint_devkit_1.objectKeyName)(node);if(name!==null){const correction=COMMON_TYPOS.get(name);if(correction){context.report({node:node.key,messageId:"noTypos"})}}},MemberExpression(node){const name=(0,eslint_devkit_1.propertyName)(node);if(name!==null){const correction=COMMON_TYPOS.get(name);if(correction){context.report({node:node.property,messageId:"noTypos"})}}}}}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.requireDefaultProps=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");exports.requireDefaultProps=(0,eslint_devkit_1.createRule)({name:"require-default-props",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/require-default-props.md",description:"Require default props"},messages:{requireDefaultProps:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Missing Default Props",description:"Prop is not required but has no default value",severity:"MEDIUM",fix:"Add defaultProps or make prop required in propTypes",documentationLink:"https://react.dev/learn/components-and-props#specifying-a-default-prop"})},schema:[{type:"object",properties:{forbidDefaultForRequired:{type:"boolean"}},additionalProperties:false}]},defaultOptions:[{}],create(context){const[options]=context.options;const forbidDefaultForRequired=options?.forbidDefaultForRequired??false;const propTypes=new Map;const defaultProps=new Map;const reactComponents=new Set;return{ClassDeclaration(node){if(isReactComponent(node)
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.requireDefaultProps=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");exports.requireDefaultProps=(0,eslint_devkit_1.createRule)({name:"require-default-props",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/require-default-props.md",description:"Require default props"},messages:{requireDefaultProps:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Missing Default Props",description:"Prop is not required but has no default value",severity:"MEDIUM",fix:"Add defaultProps or make prop required in propTypes",documentationLink:"https://react.dev/learn/components-and-props#specifying-a-default-prop"})},schema:[{type:"object",properties:{forbidDefaultForRequired:{type:"boolean"}},additionalProperties:false}]},defaultOptions:[{}],create(context){const[options]=context.options;const forbidDefaultForRequired=options?.forbidDefaultForRequired??false;const propTypes=new Map;const defaultProps=new Map;const reactComponents=new Set;return{ClassDeclaration(node){if(isReactComponent(node))reactComponents.add(componentKey(node))},ClassExpression(node){if(isReactComponent(node))reactComponents.add(componentKey(node))},'PropertyDefinition[key.name="propTypes"]'(node){if(node.value&&node.value.type==="ObjectExpression"){const componentName=getComponentName(node);{const propsMap=new Map;for(const prop of node.value.properties){if(prop.type==="Property"&&prop.key.type==="Identifier"){propsMap.set(prop.key.name,prop)}}propTypes.set(componentName,propsMap)}}},'PropertyDefinition[key.name="defaultProps"]'(node){if(node.value&&node.value.type==="ObjectExpression"){const componentName=getComponentName(node);{const propsMap=new Map;for(const prop of node.value.properties){if(prop.type==="Property"&&prop.key.type==="Identifier"){propsMap.set(prop.key.name,prop)}}defaultProps.set(componentName,propsMap)}}},"Program:exit"(){for(const[componentName,propTypesMap]of propTypes){if(!reactComponents.has(componentName)){continue}const defaultsMap=defaultProps.get(componentName);for(const[propName,propType]of propTypesMap){const hasDefault=defaultsMap?.has(propName);const isRequired=isRequiredProp(propType);if(!isRequired&&!hasDefault){context.report({node:propType.key,messageId:"requireDefaultProps"})}if(forbidDefaultForRequired&&isRequired&&defaultsMap){const defaultProp=defaultsMap.get(propName);if(defaultProp){context.report({node:defaultProp.key,messageId:"requireDefaultProps"})}}}}}};function getComponentName(node){const cls=node.parent.parent;return componentKey(cls)}function componentKey(node){return node.id?.name??`anonymous@${node.range[0]}`}function isReactComponent(node){if(!node.superClass)return false;if(node.superClass.type==="Identifier"){return node.superClass.name==="Component"||node.superClass.name==="PureComponent"}if(node.superClass.type==="MemberExpression"){return node.superClass.object.type==="Identifier"&&node.superClass.object.name==="React"&&((0,eslint_devkit_1.propertyName)(node.superClass)==="Component"||(0,eslint_devkit_1.propertyName)(node.superClass)==="PureComponent")}return false}function isRequiredProp(propType){if(propType.value.type==="MemberExpression"&&(0,eslint_devkit_1.propertyName)(propType.value)==="isRequired"){return true}return false}}});
|