eslint-plugin-react-features 1.2.11 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -0
- package/package.json +7 -3
- package/src/index.js +1 -1
- package/src/rules/react/display-name.js +1 -1
package/README.md
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
<a href="https://opensource.org/licenses/MIT" target="_blank"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="Package License" /></a>
|
|
19
19
|
<a href="https://app.codecov.io/gh/ofri-peretz/eslint/components?components%5B0%5D=eslint-plugin-react-features" target="_blank"><img src="https://codecov.io/gh/ofri-peretz/eslint/graph/badge.svg?component=eslint-plugin-react-features" alt="Codecov" /></a>
|
|
20
20
|
<a href="https://github.com/ofri-peretz/eslint" target="_blank"><img src="https://img.shields.io/badge/Since-Dec_2025-blue?logo=rocket&logoColor=white" alt="Since Dec 2025" /></a>
|
|
21
|
+
<a href="https://scorecard.dev/viewer/?uri=github.com/ofri-peretz/eslint" target="_blank"><img src="https://api.securityscorecards.dev/projects/github.com/ofri-peretz/eslint/badge" alt="OpenSSF Scorecard" /></a>
|
|
21
22
|
</p>
|
|
22
23
|
|
|
23
24
|
> ⭐ If this plugin caught a real bug for you, [**star the repo**](https://github.com/ofri-peretz/eslint) — it's the signal that keeps these rules maintained.
|
|
@@ -30,6 +31,45 @@ This plugin provides Advanced React patterns, hook usage, and best practices enf
|
|
|
30
31
|
|
|
31
32
|
**Interlace** fosters **strength through integration**. Instead of stacking isolated rules, we **interlace** security directly into your workflow to create a resilient fabric of code. We believe tools should **guide rather than gatekeep**, providing educational feedback that strengthens the developer with every interaction.
|
|
32
33
|
|
|
34
|
+
<!-- AUTO-GENERATED:DOCTRINE:START - Do not edit manually -->
|
|
35
|
+
|
|
36
|
+
## Why these rules are quiet
|
|
37
|
+
|
|
38
|
+
**Noise creates apathy, and apathy is not a security posture.** A linter that reports
|
|
39
|
+
a thousand things a week gets switched off in a month, and the real finding goes with
|
|
40
|
+
it. So every rule here is built to be worth reading: we would rather miss a finding
|
|
41
|
+
than spend your attention on one that was never real.
|
|
42
|
+
|
|
43
|
+
That is a trade, and it is made deliberately. It costs recall, and we measure what it
|
|
44
|
+
costs rather than assuming it is free.
|
|
45
|
+
|
|
46
|
+
## How the rules decide
|
|
47
|
+
|
|
48
|
+
**Evidence, not names.** A rule fires on what the code *does*, resolved through the
|
|
49
|
+
AST and ESLint's own scope analysis — not on an identifier that happens to contain
|
|
50
|
+
`query`, a method called `setItem`, or a file whose path contains `key`. Every one of
|
|
51
|
+
those was a real false positive in this ecosystem, found by reading our own output on
|
|
52
|
+
open-source projects and fixed with a test that fails on the unfixed rule.
|
|
53
|
+
|
|
54
|
+
Where a rule has known false-positive shapes, its page carries a **Not a finding**
|
|
55
|
+
section: what it deliberately stays quiet on, and what to check first when it fires
|
|
56
|
+
and you disagree.
|
|
57
|
+
|
|
58
|
+
## What you get
|
|
59
|
+
|
|
60
|
+
The rules below. Security rules carry a CWE mapping and, where one is assigned, a
|
|
61
|
+
CVSS score; every rule carries a fix on its message — in prose for a human and as
|
|
62
|
+
structured JSON for an agent. Install it, enable
|
|
63
|
+
`recommended`, and read the findings. If one of them is wrong,
|
|
64
|
+
[open an issue](https://github.com/ofri-peretz/eslint/issues) — a false positive is a
|
|
65
|
+
bug here, not a tuning exercise for you.
|
|
66
|
+
|
|
67
|
+
How that is measured, on which projects, and where it falls short:
|
|
68
|
+
[benchmark methodology](https://github.com/ofri-peretz/eslint/blob/main/BENCHMARK-METHODOLOGY.md)
|
|
69
|
+
and [results](https://github.com/ofri-peretz/eslint/blob/main/BENCHMARK-RESULTS.md).
|
|
70
|
+
|
|
71
|
+
<!-- AUTO-GENERATED:DOCTRINE:END -->
|
|
72
|
+
|
|
33
73
|
## Getting Started
|
|
34
74
|
|
|
35
75
|
- To check out the [guide](https://eslint.interlace.tools/docs/quality/plugin-react-features?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features), visit [eslint.interlace.tools](https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-react-features). 📚
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-features",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
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",
|
|
@@ -57,15 +57,19 @@
|
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"eslint": "^8.40.0 || ^9.0.0 || ^10.0.0",
|
|
60
|
-
"typescript": "
|
|
60
|
+
"typescript": "^4.8.4 || ^5.0.0 || ^6.0.0",
|
|
61
|
+
"react": "^17.0.0 || ^18.0.0 || ^19.0.0"
|
|
61
62
|
},
|
|
62
63
|
"peerDependenciesMeta": {
|
|
63
64
|
"typescript": {
|
|
64
65
|
"optional": true
|
|
66
|
+
},
|
|
67
|
+
"react": {
|
|
68
|
+
"optional": true
|
|
65
69
|
}
|
|
66
70
|
},
|
|
67
71
|
"dependencies": {
|
|
68
|
-
"@interlace/eslint-devkit": "^1.
|
|
72
|
+
"@interlace/eslint-devkit": "^1.16.0"
|
|
69
73
|
},
|
|
70
74
|
"repository": {
|
|
71
75
|
"type": "git",
|
package/src/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.configs=exports.plugin=exports.rules=void 0;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}};exports.plugin={meta:{name:"eslint-plugin-react-features",version:"1.2.11"},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;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}};exports.plugin={meta:{name:"eslint-plugin-react-features",version:"1.3.0"},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 eslint_devkit_2=require("@interlace/eslint-devkit");exports.displayName=(0,eslint_devkit_1.createRule)({name:"display-name",meta:{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:"
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.displayName=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const REACT_WRAPPERS=new Set(["memo","forwardRef"]);exports.displayName=(0,eslint_devkit_1.createRule)({name:"display-name",meta:{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:[],create(context){const report=node=>{context.report({node,messageId:"displayName"})};return{ExportDefaultDeclaration(node){const declaration=node.declaration;if(!isFunctionNode(declaration)||declaration.id)return;if(containsJSX(declaration.body))report(declaration)},CallExpression(node){if(!isReactWrapperCall(node)||hasInferableName(node))return;const inner=node.arguments[0];if(inner&&isFunctionNode(inner)&&!inner.id&&containsJSX(inner.body)){report(inner)}},"ClassDeclaration, ClassExpression"(node){if(node.id||!isReactComponent(node))return;if(hasDisplayNameProperty(node)||hasInferableName(node))return;report(node)}}}});function hasInferableName(node){let current=node.parent;while(current&&isReactWrapperCall(current)){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){if(node.type!==eslint_devkit_1.AST_NODE_TYPES.CallExpression)return false;const callee=node.callee;if(callee.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){return REACT_WRAPPERS.has(callee.name)}return callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&callee.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&REACT_WRAPPERS.has(callee.property.name)}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 isReactComponent(node){if(!node.superClass)return false;if(node.superClass.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){return node.superClass.name==="Component"||node.superClass.name==="PureComponent"}if(node.superClass.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression){return node.superClass.object.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&node.superClass.object.name==="React"&&node.superClass.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&(node.superClass.property.name==="Component"||node.superClass.property.name==="PureComponent")}return false}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 containsJSX(node){if(node.type===eslint_devkit_1.AST_NODE_TYPES.JSXElement||node.type===eslint_devkit_1.AST_NODE_TYPES.JSXFragment){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(containsJSX(item))return true}}}else if("type"in child){if(containsJSX(child))return true}}return false}
|