eslint-plugin-react-features 1.1.2 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/README.md +71 -10
- package/package.json +15 -3
- package/src/index.d.ts +375 -6
- package/src/index.js +15 -1
- package/src/oxlint.d.ts +20 -0
- package/src/oxlint.js +21 -0
- package/src/rules/migration/react-class-to-hooks.js +6 -1
- package/src/rules/performance/no-unnecessary-rerenders.js +7 -3
- package/src/rules/performance/react-no-inline-functions.js +3 -0
- package/src/rules/performance/react-render-optimization.js +2 -1
- package/src/rules/react/checked-requires-onchange-or-readonly.js +1 -0
- package/src/rules/react/default-props-match-prop-types.js +1 -0
- package/src/rules/react/display-name.js +1 -0
- package/src/rules/react/hooks-exhaustive-deps.d.ts +1 -1
- package/src/rules/react/hooks-exhaustive-deps.js +136 -47
- package/src/rules/react/jsx-handler-names.js +1 -0
- package/src/rules/react/jsx-key.js +3 -2
- package/src/rules/react/jsx-max-depth.js +1 -0
- package/src/rules/react/jsx-no-bind.js +1 -0
- package/src/rules/react/jsx-no-duplicate-props.js +1 -0
- package/src/rules/react/jsx-no-literals.js +1 -0
- package/src/rules/react/jsx-no-script-url.js +6 -2
- package/src/rules/react/jsx-no-target-blank.js +7 -1
- package/src/rules/react/no-access-state-in-setstate.js +1 -0
- package/src/rules/react/no-adjacent-inline-elements.js +1 -0
- package/src/rules/react/no-arrow-function-lifecycle.js +1 -0
- package/src/rules/react/no-children-prop.js +1 -0
- package/src/rules/react/no-danger-with-children.js +2 -0
- package/src/rules/react/no-danger.js +3 -0
- package/src/rules/react/no-deprecated.js +1 -0
- package/src/rules/react/no-did-mount-set-state.js +1 -0
- package/src/rules/react/no-did-update-set-state.js +1 -0
- package/src/rules/react/no-direct-mutation-state.js +24 -66
- package/src/rules/react/no-find-dom-node.js +1 -0
- package/src/rules/react/no-invalid-html-attribute.js +1 -0
- package/src/rules/react/no-is-mounted.js +1 -0
- package/src/rules/react/no-multi-comp.js +4 -0
- package/src/rules/react/no-namespace.js +1 -0
- package/src/rules/react/no-object-type-as-default-prop.js +1 -0
- package/src/rules/react/no-redundant-should-component-update.js +1 -0
- package/src/rules/react/no-render-return-value.js +1 -0
- package/src/rules/react/no-set-state.js +1 -0
- package/src/rules/react/no-string-refs.js +1 -0
- package/src/rules/react/no-this-in-sfc.js +1 -0
- package/src/rules/react/no-typos.js +1 -0
- package/src/rules/react/no-unescaped-entities.js +1 -0
- package/src/rules/react/no-unknown-property.js +1 -0
- package/src/rules/react/no-unsafe.js +1 -0
- package/src/rules/react/prefer-es6-class.js +1 -0
- package/src/rules/react/prefer-stateless-function.js +8 -3
- package/src/rules/react/prop-types.js +2 -0
- package/src/rules/react/react-in-jsx-scope.js +1 -0
- package/src/rules/react/require-default-props.js +4 -0
- package/src/rules/react/require-optimization.js +1 -0
- package/src/rules/react/require-render-return.js +1 -0
- package/src/rules/react/required-attributes.js +6 -0
- package/src/rules/react/sort-comp.js +17 -13
- package/src/rules/react/state-in-constructor.js +3 -0
- package/src/rules/react/static-property-placement.js +7 -0
- package/src/rules/react/void-dom-elements-no-children.js +2 -0
package/src/index.d.ts
CHANGED
|
@@ -128,7 +128,7 @@ export declare const rules: {
|
|
|
128
128
|
'static-property-placement': TSESLint.RuleModule<"staticPropertyPlacement", [import("./rules/react/static-property-placement").Options], unknown, TSESLint.RuleListener> & {
|
|
129
129
|
name: string;
|
|
130
130
|
};
|
|
131
|
-
'hooks-exhaustive-deps': TSESLint.RuleModule<"missingDep" | "extraDep" | "unnecessaryDep" | "suggestAddDep" | "suggestRemoveDep", [(import("./rules/react/hooks-exhaustive-deps").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
131
|
+
'hooks-exhaustive-deps': TSESLint.RuleModule<"missingDep" | "extraDep" | "unnecessaryDep" | "suggestAddDep" | "suggestRemoveDep" | "depsNotArrayLiteral", [(import("./rules/react/hooks-exhaustive-deps").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
132
132
|
name: string;
|
|
133
133
|
};
|
|
134
134
|
'jsx-no-target-blank': TSESLint.RuleModule<"noTargetBlank" | "noRelWithoutNoopener", [({
|
|
@@ -302,7 +302,7 @@ export declare const rules: {
|
|
|
302
302
|
'react/static-property-placement': TSESLint.RuleModule<"staticPropertyPlacement", [import("./rules/react/static-property-placement").Options], unknown, TSESLint.RuleListener> & {
|
|
303
303
|
name: string;
|
|
304
304
|
};
|
|
305
|
-
'react/hooks-exhaustive-deps': TSESLint.RuleModule<"missingDep" | "extraDep" | "unnecessaryDep" | "suggestAddDep" | "suggestRemoveDep", [(import("./rules/react/hooks-exhaustive-deps").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
305
|
+
'react/hooks-exhaustive-deps': TSESLint.RuleModule<"missingDep" | "extraDep" | "unnecessaryDep" | "suggestAddDep" | "suggestRemoveDep" | "depsNotArrayLiteral", [(import("./rules/react/hooks-exhaustive-deps").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
306
306
|
name: string;
|
|
307
307
|
};
|
|
308
308
|
'react/jsx-no-target-blank': TSESLint.RuleModule<"noTargetBlank" | "noRelWithoutNoopener", [({
|
|
@@ -483,7 +483,7 @@ export declare const plugin: {
|
|
|
483
483
|
'static-property-placement': TSESLint.RuleModule<"staticPropertyPlacement", [import("./rules/react/static-property-placement").Options], unknown, TSESLint.RuleListener> & {
|
|
484
484
|
name: string;
|
|
485
485
|
};
|
|
486
|
-
'hooks-exhaustive-deps': TSESLint.RuleModule<"missingDep" | "extraDep" | "unnecessaryDep" | "suggestAddDep" | "suggestRemoveDep", [(import("./rules/react/hooks-exhaustive-deps").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
486
|
+
'hooks-exhaustive-deps': TSESLint.RuleModule<"missingDep" | "extraDep" | "unnecessaryDep" | "suggestAddDep" | "suggestRemoveDep" | "depsNotArrayLiteral", [(import("./rules/react/hooks-exhaustive-deps").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
487
487
|
name: string;
|
|
488
488
|
};
|
|
489
489
|
'jsx-no-target-blank': TSESLint.RuleModule<"noTargetBlank" | "noRelWithoutNoopener", [({
|
|
@@ -657,7 +657,7 @@ export declare const plugin: {
|
|
|
657
657
|
'react/static-property-placement': TSESLint.RuleModule<"staticPropertyPlacement", [import("./rules/react/static-property-placement").Options], unknown, TSESLint.RuleListener> & {
|
|
658
658
|
name: string;
|
|
659
659
|
};
|
|
660
|
-
'react/hooks-exhaustive-deps': TSESLint.RuleModule<"missingDep" | "extraDep" | "unnecessaryDep" | "suggestAddDep" | "suggestRemoveDep", [(import("./rules/react/hooks-exhaustive-deps").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
660
|
+
'react/hooks-exhaustive-deps': TSESLint.RuleModule<"missingDep" | "extraDep" | "unnecessaryDep" | "suggestAddDep" | "suggestRemoveDep" | "depsNotArrayLiteral", [(import("./rules/react/hooks-exhaustive-deps").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
661
661
|
name: string;
|
|
662
662
|
};
|
|
663
663
|
'react/jsx-no-target-blank': TSESLint.RuleModule<"noTargetBlank" | "noRelWithoutNoopener", [({
|
|
@@ -714,6 +714,375 @@ export declare const plugin: {
|
|
|
714
714
|
};
|
|
715
715
|
};
|
|
716
716
|
export declare const configs: {
|
|
717
|
+
/**
|
|
718
|
+
* Flagship preset — the rule from this plugin in the ecosystem-wide
|
|
719
|
+
* flagship list (`.agent/flagship-rules.md`). Head-to-head with
|
|
720
|
+
* `react-hooks/exhaustive-deps` — same scope, more permissive context
|
|
721
|
+
* detection (catches non-array deps, TS `as const` cast deps).
|
|
722
|
+
*/
|
|
723
|
+
flagship: {
|
|
724
|
+
plugins: {
|
|
725
|
+
'@eslint/react-features': {
|
|
726
|
+
meta: {
|
|
727
|
+
name: string;
|
|
728
|
+
version: string;
|
|
729
|
+
};
|
|
730
|
+
rules: {
|
|
731
|
+
'required-attributes': TSESLint.RuleModule<"missingAttribute" | "addAttribute", [(import("./rules/react/required-attributes").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
732
|
+
name: string;
|
|
733
|
+
};
|
|
734
|
+
'jsx-key': TSESLint.RuleModule<"missingKey" | "invalidKey" | "duplicateKey" | "unstableKey" | "suggestKey", [(import("./rules/react/jsx-key").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
735
|
+
name: string;
|
|
736
|
+
};
|
|
737
|
+
'no-direct-mutation-state': TSESLint.RuleModule<"noDirectMutationState" | "suggestSetState" | "suggestFunctionalUpdate", [(import("./rules/react/no-direct-mutation-state").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
738
|
+
name: string;
|
|
739
|
+
};
|
|
740
|
+
'require-optimization': TSESLint.RuleModule<"considerMemo" | "considerUseMemo" | "considerUseCallback" | "considerLazy" | "considerPureComponent" | "performanceOptimization", [(import("./rules/react/require-optimization").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
741
|
+
name: string;
|
|
742
|
+
};
|
|
743
|
+
'no-set-state': TSESLint.RuleModule<"noSetState", [], unknown, TSESLint.RuleListener> & {
|
|
744
|
+
name: string;
|
|
745
|
+
};
|
|
746
|
+
'no-this-in-sfc': TSESLint.RuleModule<"noThisInSfc", [], unknown, TSESLint.RuleListener> & {
|
|
747
|
+
name: string;
|
|
748
|
+
};
|
|
749
|
+
'no-access-state-in-setstate': TSESLint.RuleModule<"noAccessStateInSetState", [], unknown, TSESLint.RuleListener> & {
|
|
750
|
+
name: string;
|
|
751
|
+
};
|
|
752
|
+
'no-children-prop': TSESLint.RuleModule<"noChildrenProp", [], unknown, TSESLint.RuleListener> & {
|
|
753
|
+
name: string;
|
|
754
|
+
};
|
|
755
|
+
'no-danger': TSESLint.RuleModule<"noDanger", [], unknown, TSESLint.RuleListener> & {
|
|
756
|
+
name: string;
|
|
757
|
+
};
|
|
758
|
+
'no-string-refs': TSESLint.RuleModule<"noStringRefs", [], unknown, TSESLint.RuleListener> & {
|
|
759
|
+
name: string;
|
|
760
|
+
};
|
|
761
|
+
'no-unknown-property': TSESLint.RuleModule<"noUnknownProperty", [], unknown, TSESLint.RuleListener> & {
|
|
762
|
+
name: string;
|
|
763
|
+
};
|
|
764
|
+
'checked-requires-onchange-or-readonly': TSESLint.RuleModule<"checkedRequiresOnChangeOrReadOnly", import("./rules/react/checked-requires-onchange-or-readonly").RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
765
|
+
name: string;
|
|
766
|
+
};
|
|
767
|
+
'default-props-match-prop-types': TSESLint.RuleModule<"defaultPropsMatchPropTypes", [], unknown, TSESLint.RuleListener> & {
|
|
768
|
+
name: string;
|
|
769
|
+
};
|
|
770
|
+
'display-name': TSESLint.RuleModule<"displayName", [], unknown, TSESLint.RuleListener> & {
|
|
771
|
+
name: string;
|
|
772
|
+
};
|
|
773
|
+
'jsx-handler-names': TSESLint.RuleModule<"jsxHandlerNames", [], unknown, TSESLint.RuleListener> & {
|
|
774
|
+
name: string;
|
|
775
|
+
};
|
|
776
|
+
'jsx-max-depth': TSESLint.RuleModule<"jsxMaxDepth", [(import("./rules/react/jsx-max-depth").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
777
|
+
name: string;
|
|
778
|
+
};
|
|
779
|
+
'jsx-no-bind': TSESLint.RuleModule<"jsxNoBind", [], unknown, TSESLint.RuleListener> & {
|
|
780
|
+
name: string;
|
|
781
|
+
};
|
|
782
|
+
'jsx-no-literals': TSESLint.RuleModule<"jsxNoLiterals", [(import("./rules/react/jsx-no-literals").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
783
|
+
name: string;
|
|
784
|
+
};
|
|
785
|
+
'no-adjacent-inline-elements': TSESLint.RuleModule<"noAdjacentInlineElements", [], unknown, TSESLint.RuleListener> & {
|
|
786
|
+
name: string;
|
|
787
|
+
};
|
|
788
|
+
'no-arrow-function-lifecycle': TSESLint.RuleModule<"noArrowFunctionLifecycle", [], unknown, TSESLint.RuleListener> & {
|
|
789
|
+
name: string;
|
|
790
|
+
};
|
|
791
|
+
'no-did-mount-set-state': TSESLint.RuleModule<"noDidMountSetState", [], unknown, TSESLint.RuleListener> & {
|
|
792
|
+
name: string;
|
|
793
|
+
};
|
|
794
|
+
'no-did-update-set-state': TSESLint.RuleModule<"noDidUpdateSetState", [(import("./rules/react/no-did-update-set-state").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
795
|
+
name: string;
|
|
796
|
+
};
|
|
797
|
+
'no-invalid-html-attribute': TSESLint.RuleModule<"noInvalidHtmlAttribute", [], unknown, TSESLint.RuleListener> & {
|
|
798
|
+
name: string;
|
|
799
|
+
};
|
|
800
|
+
'no-is-mounted': TSESLint.RuleModule<"noIsMounted", [], unknown, TSESLint.RuleListener> & {
|
|
801
|
+
name: string;
|
|
802
|
+
};
|
|
803
|
+
'no-multi-comp': TSESLint.RuleModule<"noMultiComp", [(import("./rules/react/no-multi-comp").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
804
|
+
name: string;
|
|
805
|
+
};
|
|
806
|
+
'no-namespace': TSESLint.RuleModule<"noNamespace", [], unknown, TSESLint.RuleListener> & {
|
|
807
|
+
name: string;
|
|
808
|
+
};
|
|
809
|
+
'no-object-type-as-default-prop': TSESLint.RuleModule<"noObjectTypeAsDefaultProp", [], unknown, TSESLint.RuleListener> & {
|
|
810
|
+
name: string;
|
|
811
|
+
};
|
|
812
|
+
'no-redundant-should-component-update': TSESLint.RuleModule<"noRedundantShouldComponentUpdate", [], unknown, TSESLint.RuleListener> & {
|
|
813
|
+
name: string;
|
|
814
|
+
};
|
|
815
|
+
'no-render-return-value': TSESLint.RuleModule<"noRenderReturnValue", [], unknown, TSESLint.RuleListener> & {
|
|
816
|
+
name: string;
|
|
817
|
+
};
|
|
818
|
+
'no-typos': TSESLint.RuleModule<"noTypos", [], unknown, TSESLint.RuleListener> & {
|
|
819
|
+
name: string;
|
|
820
|
+
};
|
|
821
|
+
'no-unescaped-entities': TSESLint.RuleModule<"noUnescapedEntities", [], unknown, TSESLint.RuleListener> & {
|
|
822
|
+
name: string;
|
|
823
|
+
};
|
|
824
|
+
'prefer-es6-class': TSESLint.RuleModule<"preferEs6Class", [], unknown, TSESLint.RuleListener> & {
|
|
825
|
+
name: string;
|
|
826
|
+
};
|
|
827
|
+
'prefer-stateless-function': TSESLint.RuleModule<"preferStatelessFunction", [import("./rules/react/prefer-stateless-function").Options], unknown, TSESLint.RuleListener> & {
|
|
828
|
+
name: string;
|
|
829
|
+
};
|
|
830
|
+
'prop-types': TSESLint.RuleModule<"propTypes", [import("./rules/react/prop-types").Options], unknown, TSESLint.RuleListener> & {
|
|
831
|
+
name: string;
|
|
832
|
+
};
|
|
833
|
+
'react-in-jsx-scope': TSESLint.RuleModule<"reactInJsxScope", [], unknown, TSESLint.RuleListener> & {
|
|
834
|
+
name: string;
|
|
835
|
+
};
|
|
836
|
+
'require-default-props': TSESLint.RuleModule<"requireDefaultProps", [import("./rules/react/require-default-props").Options], unknown, TSESLint.RuleListener> & {
|
|
837
|
+
name: string;
|
|
838
|
+
};
|
|
839
|
+
'require-render-return': TSESLint.RuleModule<"requireRenderReturn", [], unknown, TSESLint.RuleListener> & {
|
|
840
|
+
name: string;
|
|
841
|
+
};
|
|
842
|
+
'sort-comp': TSESLint.RuleModule<"sortComp", [import("./rules/react/sort-comp").Options], unknown, TSESLint.RuleListener> & {
|
|
843
|
+
name: string;
|
|
844
|
+
};
|
|
845
|
+
'state-in-constructor': TSESLint.RuleModule<"stateInConstructor", [], unknown, TSESLint.RuleListener> & {
|
|
846
|
+
name: string;
|
|
847
|
+
};
|
|
848
|
+
'static-property-placement': TSESLint.RuleModule<"staticPropertyPlacement", [import("./rules/react/static-property-placement").Options], unknown, TSESLint.RuleListener> & {
|
|
849
|
+
name: string;
|
|
850
|
+
};
|
|
851
|
+
'hooks-exhaustive-deps': TSESLint.RuleModule<"missingDep" | "extraDep" | "unnecessaryDep" | "suggestAddDep" | "suggestRemoveDep" | "depsNotArrayLiteral", [(import("./rules/react/hooks-exhaustive-deps").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
852
|
+
name: string;
|
|
853
|
+
};
|
|
854
|
+
'jsx-no-target-blank': TSESLint.RuleModule<"noTargetBlank" | "noRelWithoutNoopener", [({
|
|
855
|
+
allowReferrer?: boolean;
|
|
856
|
+
enforceDynamicLinks?: "always" | "never";
|
|
857
|
+
warnOnSpreadAttributes?: boolean;
|
|
858
|
+
links?: boolean;
|
|
859
|
+
forms?: boolean;
|
|
860
|
+
} | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
861
|
+
name: string;
|
|
862
|
+
};
|
|
863
|
+
'jsx-no-script-url': TSESLint.RuleModule<"noScriptUrl", [({
|
|
864
|
+
name: string;
|
|
865
|
+
props: string[];
|
|
866
|
+
}[] | undefined)?, ({
|
|
867
|
+
includeFromSettings?: boolean;
|
|
868
|
+
} | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
869
|
+
name: string;
|
|
870
|
+
};
|
|
871
|
+
'jsx-no-duplicate-props': TSESLint.RuleModule<"duplicateProp", [({
|
|
872
|
+
ignoreCase?: boolean;
|
|
873
|
+
} | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
874
|
+
name: string;
|
|
875
|
+
};
|
|
876
|
+
'no-danger-with-children': TSESLint.RuleModule<"dangerWithChildren", [], unknown, TSESLint.RuleListener> & {
|
|
877
|
+
name: string;
|
|
878
|
+
};
|
|
879
|
+
'no-deprecated': TSESLint.RuleModule<"deprecated", [], unknown, TSESLint.RuleListener> & {
|
|
880
|
+
name: string;
|
|
881
|
+
};
|
|
882
|
+
'no-find-dom-node': TSESLint.RuleModule<"noFindDOMNode", [], unknown, TSESLint.RuleListener> & {
|
|
883
|
+
name: string;
|
|
884
|
+
};
|
|
885
|
+
'no-unsafe': TSESLint.RuleModule<"noUnsafe", [({
|
|
886
|
+
checkAliases?: boolean;
|
|
887
|
+
} | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
888
|
+
name: string;
|
|
889
|
+
};
|
|
890
|
+
'void-dom-elements-no-children': TSESLint.RuleModule<"voidNoChildren", [], unknown, TSESLint.RuleListener> & {
|
|
891
|
+
name: string;
|
|
892
|
+
};
|
|
893
|
+
'react-class-to-hooks': TSESLint.RuleModule<"migrateToHooks" | "convertToFunction" | "viewMigrationGuide", [(import("./rules/migration/react-class-to-hooks").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
894
|
+
name: string;
|
|
895
|
+
};
|
|
896
|
+
'no-unnecessary-rerenders': TSESLint.RuleModule<"useCallback" | "useMemo" | "unnecessaryRerender" | "extractToVariable", [(import("./rules/performance/no-unnecessary-rerenders").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
897
|
+
name: string;
|
|
898
|
+
};
|
|
899
|
+
'react-render-optimization': TSESLint.RuleModule<"useCallback" | "useMemo" | "unnecessaryRerender" | "missingMemoization" | "expensiveComputation" | "useReactMemo", [(import("./rules/performance/react-render-optimization").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
900
|
+
name: string;
|
|
901
|
+
};
|
|
902
|
+
'react-no-inline-functions': TSESLint.RuleModule<"useCallback" | "inlineFunction" | "extractFunction" | "strategyUseCallback" | "strategyUseMemo" | "strategyExtract", [(import("./rules/performance/react-no-inline-functions").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
903
|
+
name: string;
|
|
904
|
+
};
|
|
905
|
+
'react/required-attributes': TSESLint.RuleModule<"missingAttribute" | "addAttribute", [(import("./rules/react/required-attributes").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
906
|
+
name: string;
|
|
907
|
+
};
|
|
908
|
+
'react/jsx-key': TSESLint.RuleModule<"missingKey" | "invalidKey" | "duplicateKey" | "unstableKey" | "suggestKey", [(import("./rules/react/jsx-key").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
909
|
+
name: string;
|
|
910
|
+
};
|
|
911
|
+
'react/no-direct-mutation-state': TSESLint.RuleModule<"noDirectMutationState" | "suggestSetState" | "suggestFunctionalUpdate", [(import("./rules/react/no-direct-mutation-state").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
912
|
+
name: string;
|
|
913
|
+
};
|
|
914
|
+
'react/require-optimization': TSESLint.RuleModule<"considerMemo" | "considerUseMemo" | "considerUseCallback" | "considerLazy" | "considerPureComponent" | "performanceOptimization", [(import("./rules/react/require-optimization").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
915
|
+
name: string;
|
|
916
|
+
};
|
|
917
|
+
'react/no-set-state': TSESLint.RuleModule<"noSetState", [], unknown, TSESLint.RuleListener> & {
|
|
918
|
+
name: string;
|
|
919
|
+
};
|
|
920
|
+
'react/no-this-in-sfc': TSESLint.RuleModule<"noThisInSfc", [], unknown, TSESLint.RuleListener> & {
|
|
921
|
+
name: string;
|
|
922
|
+
};
|
|
923
|
+
'react/no-access-state-in-setstate': TSESLint.RuleModule<"noAccessStateInSetState", [], unknown, TSESLint.RuleListener> & {
|
|
924
|
+
name: string;
|
|
925
|
+
};
|
|
926
|
+
'react/no-children-prop': TSESLint.RuleModule<"noChildrenProp", [], unknown, TSESLint.RuleListener> & {
|
|
927
|
+
name: string;
|
|
928
|
+
};
|
|
929
|
+
'react/no-danger': TSESLint.RuleModule<"noDanger", [], unknown, TSESLint.RuleListener> & {
|
|
930
|
+
name: string;
|
|
931
|
+
};
|
|
932
|
+
'react/no-string-refs': TSESLint.RuleModule<"noStringRefs", [], unknown, TSESLint.RuleListener> & {
|
|
933
|
+
name: string;
|
|
934
|
+
};
|
|
935
|
+
'react/no-unknown-property': TSESLint.RuleModule<"noUnknownProperty", [], unknown, TSESLint.RuleListener> & {
|
|
936
|
+
name: string;
|
|
937
|
+
};
|
|
938
|
+
'react/checked-requires-onchange-or-readonly': TSESLint.RuleModule<"checkedRequiresOnChangeOrReadOnly", import("./rules/react/checked-requires-onchange-or-readonly").RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
939
|
+
name: string;
|
|
940
|
+
};
|
|
941
|
+
'react/default-props-match-prop-types': TSESLint.RuleModule<"defaultPropsMatchPropTypes", [], unknown, TSESLint.RuleListener> & {
|
|
942
|
+
name: string;
|
|
943
|
+
};
|
|
944
|
+
'react/display-name': TSESLint.RuleModule<"displayName", [], unknown, TSESLint.RuleListener> & {
|
|
945
|
+
name: string;
|
|
946
|
+
};
|
|
947
|
+
'react/jsx-handler-names': TSESLint.RuleModule<"jsxHandlerNames", [], unknown, TSESLint.RuleListener> & {
|
|
948
|
+
name: string;
|
|
949
|
+
};
|
|
950
|
+
'react/jsx-max-depth': TSESLint.RuleModule<"jsxMaxDepth", [(import("./rules/react/jsx-max-depth").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
951
|
+
name: string;
|
|
952
|
+
};
|
|
953
|
+
'react/jsx-no-bind': TSESLint.RuleModule<"jsxNoBind", [], unknown, TSESLint.RuleListener> & {
|
|
954
|
+
name: string;
|
|
955
|
+
};
|
|
956
|
+
'react/jsx-no-literals': TSESLint.RuleModule<"jsxNoLiterals", [(import("./rules/react/jsx-no-literals").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
957
|
+
name: string;
|
|
958
|
+
};
|
|
959
|
+
'react/no-adjacent-inline-elements': TSESLint.RuleModule<"noAdjacentInlineElements", [], unknown, TSESLint.RuleListener> & {
|
|
960
|
+
name: string;
|
|
961
|
+
};
|
|
962
|
+
'react/no-arrow-function-lifecycle': TSESLint.RuleModule<"noArrowFunctionLifecycle", [], unknown, TSESLint.RuleListener> & {
|
|
963
|
+
name: string;
|
|
964
|
+
};
|
|
965
|
+
'react/no-did-mount-set-state': TSESLint.RuleModule<"noDidMountSetState", [], unknown, TSESLint.RuleListener> & {
|
|
966
|
+
name: string;
|
|
967
|
+
};
|
|
968
|
+
'react/no-did-update-set-state': TSESLint.RuleModule<"noDidUpdateSetState", [(import("./rules/react/no-did-update-set-state").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
969
|
+
name: string;
|
|
970
|
+
};
|
|
971
|
+
'react/no-invalid-html-attribute': TSESLint.RuleModule<"noInvalidHtmlAttribute", [], unknown, TSESLint.RuleListener> & {
|
|
972
|
+
name: string;
|
|
973
|
+
};
|
|
974
|
+
'react/no-is-mounted': TSESLint.RuleModule<"noIsMounted", [], unknown, TSESLint.RuleListener> & {
|
|
975
|
+
name: string;
|
|
976
|
+
};
|
|
977
|
+
'react/no-multi-comp': TSESLint.RuleModule<"noMultiComp", [(import("./rules/react/no-multi-comp").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
978
|
+
name: string;
|
|
979
|
+
};
|
|
980
|
+
'react/no-namespace': TSESLint.RuleModule<"noNamespace", [], unknown, TSESLint.RuleListener> & {
|
|
981
|
+
name: string;
|
|
982
|
+
};
|
|
983
|
+
'react/no-object-type-as-default-prop': TSESLint.RuleModule<"noObjectTypeAsDefaultProp", [], unknown, TSESLint.RuleListener> & {
|
|
984
|
+
name: string;
|
|
985
|
+
};
|
|
986
|
+
'react/no-redundant-should-component-update': TSESLint.RuleModule<"noRedundantShouldComponentUpdate", [], unknown, TSESLint.RuleListener> & {
|
|
987
|
+
name: string;
|
|
988
|
+
};
|
|
989
|
+
'react/no-render-return-value': TSESLint.RuleModule<"noRenderReturnValue", [], unknown, TSESLint.RuleListener> & {
|
|
990
|
+
name: string;
|
|
991
|
+
};
|
|
992
|
+
'react/no-typos': TSESLint.RuleModule<"noTypos", [], unknown, TSESLint.RuleListener> & {
|
|
993
|
+
name: string;
|
|
994
|
+
};
|
|
995
|
+
'react/no-unescaped-entities': TSESLint.RuleModule<"noUnescapedEntities", [], unknown, TSESLint.RuleListener> & {
|
|
996
|
+
name: string;
|
|
997
|
+
};
|
|
998
|
+
'react/prefer-es6-class': TSESLint.RuleModule<"preferEs6Class", [], unknown, TSESLint.RuleListener> & {
|
|
999
|
+
name: string;
|
|
1000
|
+
};
|
|
1001
|
+
'react/prefer-stateless-function': TSESLint.RuleModule<"preferStatelessFunction", [import("./rules/react/prefer-stateless-function").Options], unknown, TSESLint.RuleListener> & {
|
|
1002
|
+
name: string;
|
|
1003
|
+
};
|
|
1004
|
+
'react/prop-types': TSESLint.RuleModule<"propTypes", [import("./rules/react/prop-types").Options], unknown, TSESLint.RuleListener> & {
|
|
1005
|
+
name: string;
|
|
1006
|
+
};
|
|
1007
|
+
'react/react-in-jsx-scope': TSESLint.RuleModule<"reactInJsxScope", [], unknown, TSESLint.RuleListener> & {
|
|
1008
|
+
name: string;
|
|
1009
|
+
};
|
|
1010
|
+
'react/require-default-props': TSESLint.RuleModule<"requireDefaultProps", [import("./rules/react/require-default-props").Options], unknown, TSESLint.RuleListener> & {
|
|
1011
|
+
name: string;
|
|
1012
|
+
};
|
|
1013
|
+
'react/require-render-return': TSESLint.RuleModule<"requireRenderReturn", [], unknown, TSESLint.RuleListener> & {
|
|
1014
|
+
name: string;
|
|
1015
|
+
};
|
|
1016
|
+
'react/sort-comp': TSESLint.RuleModule<"sortComp", [import("./rules/react/sort-comp").Options], unknown, TSESLint.RuleListener> & {
|
|
1017
|
+
name: string;
|
|
1018
|
+
};
|
|
1019
|
+
'react/state-in-constructor': TSESLint.RuleModule<"stateInConstructor", [], unknown, TSESLint.RuleListener> & {
|
|
1020
|
+
name: string;
|
|
1021
|
+
};
|
|
1022
|
+
'react/static-property-placement': TSESLint.RuleModule<"staticPropertyPlacement", [import("./rules/react/static-property-placement").Options], unknown, TSESLint.RuleListener> & {
|
|
1023
|
+
name: string;
|
|
1024
|
+
};
|
|
1025
|
+
'react/hooks-exhaustive-deps': TSESLint.RuleModule<"missingDep" | "extraDep" | "unnecessaryDep" | "suggestAddDep" | "suggestRemoveDep" | "depsNotArrayLiteral", [(import("./rules/react/hooks-exhaustive-deps").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
1026
|
+
name: string;
|
|
1027
|
+
};
|
|
1028
|
+
'react/jsx-no-target-blank': TSESLint.RuleModule<"noTargetBlank" | "noRelWithoutNoopener", [({
|
|
1029
|
+
allowReferrer?: boolean;
|
|
1030
|
+
enforceDynamicLinks?: "always" | "never";
|
|
1031
|
+
warnOnSpreadAttributes?: boolean;
|
|
1032
|
+
links?: boolean;
|
|
1033
|
+
forms?: boolean;
|
|
1034
|
+
} | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
1035
|
+
name: string;
|
|
1036
|
+
};
|
|
1037
|
+
'react/jsx-no-script-url': TSESLint.RuleModule<"noScriptUrl", [({
|
|
1038
|
+
name: string;
|
|
1039
|
+
props: string[];
|
|
1040
|
+
}[] | undefined)?, ({
|
|
1041
|
+
includeFromSettings?: boolean;
|
|
1042
|
+
} | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
1043
|
+
name: string;
|
|
1044
|
+
};
|
|
1045
|
+
'react/jsx-no-duplicate-props': TSESLint.RuleModule<"duplicateProp", [({
|
|
1046
|
+
ignoreCase?: boolean;
|
|
1047
|
+
} | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
1048
|
+
name: string;
|
|
1049
|
+
};
|
|
1050
|
+
'react/no-danger-with-children': TSESLint.RuleModule<"dangerWithChildren", [], unknown, TSESLint.RuleListener> & {
|
|
1051
|
+
name: string;
|
|
1052
|
+
};
|
|
1053
|
+
'react/no-deprecated': TSESLint.RuleModule<"deprecated", [], unknown, TSESLint.RuleListener> & {
|
|
1054
|
+
name: string;
|
|
1055
|
+
};
|
|
1056
|
+
'react/no-find-dom-node': TSESLint.RuleModule<"noFindDOMNode", [], unknown, TSESLint.RuleListener> & {
|
|
1057
|
+
name: string;
|
|
1058
|
+
};
|
|
1059
|
+
'react/no-unsafe': TSESLint.RuleModule<"noUnsafe", [({
|
|
1060
|
+
checkAliases?: boolean;
|
|
1061
|
+
} | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
1062
|
+
name: string;
|
|
1063
|
+
};
|
|
1064
|
+
'react/void-dom-elements-no-children': TSESLint.RuleModule<"voidNoChildren", [], unknown, TSESLint.RuleListener> & {
|
|
1065
|
+
name: string;
|
|
1066
|
+
};
|
|
1067
|
+
'migration/react-class-to-hooks': TSESLint.RuleModule<"migrateToHooks" | "convertToFunction" | "viewMigrationGuide", [(import("./rules/migration/react-class-to-hooks").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
1068
|
+
name: string;
|
|
1069
|
+
};
|
|
1070
|
+
'performance/no-unnecessary-rerenders': TSESLint.RuleModule<"useCallback" | "useMemo" | "unnecessaryRerender" | "extractToVariable", [(import("./rules/performance/no-unnecessary-rerenders").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
1071
|
+
name: string;
|
|
1072
|
+
};
|
|
1073
|
+
'performance/react-render-optimization': TSESLint.RuleModule<"useCallback" | "useMemo" | "unnecessaryRerender" | "missingMemoization" | "expensiveComputation" | "useReactMemo", [(import("./rules/performance/react-render-optimization").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
1074
|
+
name: string;
|
|
1075
|
+
};
|
|
1076
|
+
'performance/react-no-inline-functions': TSESLint.RuleModule<"useCallback" | "inlineFunction" | "extractFunction" | "strategyUseCallback" | "strategyUseMemo" | "strategyExtract", [(import("./rules/performance/react-no-inline-functions").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
1077
|
+
name: string;
|
|
1078
|
+
};
|
|
1079
|
+
};
|
|
1080
|
+
};
|
|
1081
|
+
};
|
|
1082
|
+
rules: {
|
|
1083
|
+
'@eslint/react-features/react/hooks-exhaustive-deps': "error";
|
|
1084
|
+
};
|
|
1085
|
+
};
|
|
717
1086
|
recommended: {
|
|
718
1087
|
plugins: {
|
|
719
1088
|
'@eslint/react-features': {
|
|
@@ -842,7 +1211,7 @@ export declare const configs: {
|
|
|
842
1211
|
'static-property-placement': TSESLint.RuleModule<"staticPropertyPlacement", [import("./rules/react/static-property-placement").Options], unknown, TSESLint.RuleListener> & {
|
|
843
1212
|
name: string;
|
|
844
1213
|
};
|
|
845
|
-
'hooks-exhaustive-deps': TSESLint.RuleModule<"missingDep" | "extraDep" | "unnecessaryDep" | "suggestAddDep" | "suggestRemoveDep", [(import("./rules/react/hooks-exhaustive-deps").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
1214
|
+
'hooks-exhaustive-deps': TSESLint.RuleModule<"missingDep" | "extraDep" | "unnecessaryDep" | "suggestAddDep" | "suggestRemoveDep" | "depsNotArrayLiteral", [(import("./rules/react/hooks-exhaustive-deps").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
846
1215
|
name: string;
|
|
847
1216
|
};
|
|
848
1217
|
'jsx-no-target-blank': TSESLint.RuleModule<"noTargetBlank" | "noRelWithoutNoopener", [({
|
|
@@ -1016,7 +1385,7 @@ export declare const configs: {
|
|
|
1016
1385
|
'react/static-property-placement': TSESLint.RuleModule<"staticPropertyPlacement", [import("./rules/react/static-property-placement").Options], unknown, TSESLint.RuleListener> & {
|
|
1017
1386
|
name: string;
|
|
1018
1387
|
};
|
|
1019
|
-
'react/hooks-exhaustive-deps': TSESLint.RuleModule<"missingDep" | "extraDep" | "unnecessaryDep" | "suggestAddDep" | "suggestRemoveDep", [(import("./rules/react/hooks-exhaustive-deps").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
1388
|
+
'react/hooks-exhaustive-deps': TSESLint.RuleModule<"missingDep" | "extraDep" | "unnecessaryDep" | "suggestAddDep" | "suggestRemoveDep" | "depsNotArrayLiteral", [(import("./rules/react/hooks-exhaustive-deps").Options | undefined)?], unknown, TSESLint.RuleListener> & {
|
|
1020
1389
|
name: string;
|
|
1021
1390
|
};
|
|
1022
1391
|
'react/jsx-no-target-blank': TSESLint.RuleModule<"noTargetBlank" | "noRelWithoutNoopener", [({
|
package/src/index.js
CHANGED
|
@@ -181,11 +181,25 @@ exports.rules = {
|
|
|
181
181
|
exports.plugin = {
|
|
182
182
|
meta: {
|
|
183
183
|
name: 'eslint-plugin-react-features',
|
|
184
|
-
version: '1.
|
|
184
|
+
version: '1.1.4',
|
|
185
185
|
},
|
|
186
186
|
rules: exports.rules,
|
|
187
187
|
};
|
|
188
188
|
exports.configs = {
|
|
189
|
+
/**
|
|
190
|
+
* Flagship preset — the rule from this plugin in the ecosystem-wide
|
|
191
|
+
* flagship list (`.agent/flagship-rules.md`). Head-to-head with
|
|
192
|
+
* `react-hooks/exhaustive-deps` — same scope, more permissive context
|
|
193
|
+
* detection (catches non-array deps, TS `as const` cast deps).
|
|
194
|
+
*/
|
|
195
|
+
flagship: {
|
|
196
|
+
plugins: {
|
|
197
|
+
'@eslint/react-features': exports.plugin,
|
|
198
|
+
},
|
|
199
|
+
rules: {
|
|
200
|
+
'@eslint/react-features/react/hooks-exhaustive-deps': 'error',
|
|
201
|
+
},
|
|
202
|
+
},
|
|
189
203
|
recommended: {
|
|
190
204
|
plugins: {
|
|
191
205
|
'@eslint/react-features': exports.plugin,
|
package/src/oxlint.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
+
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
+
* MIT license that can be found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* oxlint sub-export.
|
|
8
|
+
*
|
|
9
|
+
* Consumers wire oxlint to this entry via:
|
|
10
|
+
* { "jsPlugins": ["eslint-plugin-react-features/oxlint"] }
|
|
11
|
+
*
|
|
12
|
+
* oxlint's JS plugin loader does `require('eslint-plugin-react-features/oxlint')` and reads
|
|
13
|
+
* `.rules` off the result. The compiled output of `export = plugin` is
|
|
14
|
+
* `module.exports = plugin`, which gives oxlint the plugin object directly
|
|
15
|
+
* (`{ meta, rules }`) — no wrapper, no `.default` indirection.
|
|
16
|
+
*
|
|
17
|
+
* Generated by scripts/generate-oxlint-shims.mjs. Do not edit by hand.
|
|
18
|
+
*/
|
|
19
|
+
import { plugin } from './index';
|
|
20
|
+
export = plugin;
|
package/src/oxlint.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2025 Ofri Peretz
|
|
4
|
+
* Licensed under the MIT License. Use of this source code is governed by the
|
|
5
|
+
* MIT license that can be found in the LICENSE file.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* oxlint sub-export.
|
|
9
|
+
*
|
|
10
|
+
* Consumers wire oxlint to this entry via:
|
|
11
|
+
* { "jsPlugins": ["eslint-plugin-react-features/oxlint"] }
|
|
12
|
+
*
|
|
13
|
+
* oxlint's JS plugin loader does `require('eslint-plugin-react-features/oxlint')` and reads
|
|
14
|
+
* `.rules` off the result. The compiled output of `export = plugin` is
|
|
15
|
+
* `module.exports = plugin`, which gives oxlint the plugin object directly
|
|
16
|
+
* (`{ meta, rules }`) — no wrapper, no `.default` indirection.
|
|
17
|
+
*
|
|
18
|
+
* Generated by scripts/generate-oxlint-shims.mjs. Do not edit by hand.
|
|
19
|
+
*/
|
|
20
|
+
const index_1 = require("./index");
|
|
21
|
+
module.exports = index_1.plugin;
|
|
@@ -13,7 +13,10 @@ exports.reactClassToHooks = (0, eslint_devkit_2.createRule)({
|
|
|
13
13
|
meta: {
|
|
14
14
|
type: 'suggestion',
|
|
15
15
|
docs: {
|
|
16
|
+
url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/react-class-to-hooks.md',
|
|
16
17
|
description: 'Suggest migrating React class components to hooks with detailed migration path',
|
|
18
|
+
cwe: 'CWE-1078',
|
|
19
|
+
cvss: 5,
|
|
17
20
|
},
|
|
18
21
|
fixable: 'code',
|
|
19
22
|
hasSuggestions: true,
|
|
@@ -71,10 +74,11 @@ exports.reactClassToHooks = (0, eslint_devkit_2.createRule)({
|
|
|
71
74
|
create(context) {
|
|
72
75
|
const options = context.options[0] || {};
|
|
73
76
|
const { allowComplexLifecycle = false } = options || {};
|
|
74
|
-
const sourceCode = context.sourceCode
|
|
77
|
+
const sourceCode = context.sourceCode;
|
|
75
78
|
/**
|
|
76
79
|
* Check if class extends React.Component
|
|
77
80
|
*/
|
|
81
|
+
// oxlint-disable-next-line consistent-function-scoping
|
|
78
82
|
const isReactComponent = (node) => {
|
|
79
83
|
if (!node.superClass)
|
|
80
84
|
return false;
|
|
@@ -97,6 +101,7 @@ exports.reactClassToHooks = (0, eslint_devkit_2.createRule)({
|
|
|
97
101
|
/**
|
|
98
102
|
* Analyze lifecycle methods used
|
|
99
103
|
*/
|
|
104
|
+
// oxlint-disable-next-line consistent-function-scoping
|
|
100
105
|
const analyzeLifecycleMethods = (node) => {
|
|
101
106
|
const lifecycleMethods = [];
|
|
102
107
|
const classBody = node.body.body;
|
|
@@ -12,10 +12,13 @@ const eslint_devkit_2 = require("@interlace/eslint-devkit");
|
|
|
12
12
|
* Check if a node is in a React component render context
|
|
13
13
|
*/
|
|
14
14
|
function isInReactRenderContext(node) {
|
|
15
|
+
// `current` is `node` on entry and only ever reassigned from `parent` after
|
|
16
|
+
// an explicit `if (!parent) break;`, so it's never null at the loop check
|
|
17
|
+
// (CodeQL: `js/useless-conditional` on the `current &&` test).
|
|
15
18
|
let current = node;
|
|
16
19
|
let depth = 0;
|
|
17
20
|
const maxDepth = 15;
|
|
18
|
-
while (
|
|
21
|
+
while (depth < maxDepth) {
|
|
19
22
|
const parent = current.parent;
|
|
20
23
|
if (!parent)
|
|
21
24
|
break;
|
|
@@ -80,6 +83,7 @@ exports.noUnnecessaryRerenders = (0, eslint_devkit_2.createRule)({
|
|
|
80
83
|
meta: {
|
|
81
84
|
type: 'suggestion',
|
|
82
85
|
docs: {
|
|
86
|
+
url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/no-unnecessary-rerenders.md',
|
|
83
87
|
description: 'Detects prevented re-renders in React',
|
|
84
88
|
},
|
|
85
89
|
hasSuggestions: true,
|
|
@@ -143,14 +147,14 @@ exports.noUnnecessaryRerenders = (0, eslint_devkit_2.createRule)({
|
|
|
143
147
|
],
|
|
144
148
|
create(context, [options = {}]) {
|
|
145
149
|
const { ignoreInTests = true, minSize = 5 } = options || {};
|
|
146
|
-
const filename = context.
|
|
150
|
+
const filename = context.filename;
|
|
147
151
|
// Only skip if ignoreInTests is true AND filename matches test pattern
|
|
148
152
|
// If ignoreInTests is explicitly false, always run the rule
|
|
149
153
|
const isTestFile = ignoreInTests && /\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);
|
|
150
154
|
if (isTestFile) {
|
|
151
155
|
return {};
|
|
152
156
|
}
|
|
153
|
-
const sourceCode = context.sourceCode
|
|
157
|
+
const sourceCode = context.sourceCode;
|
|
154
158
|
/**
|
|
155
159
|
* Check JSX attributes for unnecessary re-renders
|
|
156
160
|
*/
|
|
@@ -13,6 +13,7 @@ exports.reactNoInlineFunctions = (0, eslint_devkit_2.createRule)({
|
|
|
13
13
|
meta: {
|
|
14
14
|
type: 'suggestion',
|
|
15
15
|
docs: {
|
|
16
|
+
url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/react-no-inline-functions.md',
|
|
16
17
|
description: 'Prevent inline functions in React renders with performance metrics',
|
|
17
18
|
},
|
|
18
19
|
fixable: 'code',
|
|
@@ -98,6 +99,7 @@ exports.reactNoInlineFunctions = (0, eslint_devkit_2.createRule)({
|
|
|
98
99
|
/**
|
|
99
100
|
* Check if node is inside JSX
|
|
100
101
|
*/
|
|
102
|
+
// oxlint-disable-next-line consistent-function-scoping
|
|
101
103
|
const isInJSX = (node) => {
|
|
102
104
|
let parent = node.parent;
|
|
103
105
|
while (parent) {
|
|
@@ -127,6 +129,7 @@ exports.reactNoInlineFunctions = (0, eslint_devkit_2.createRule)({
|
|
|
127
129
|
/**
|
|
128
130
|
* Calculate performance impact
|
|
129
131
|
*/
|
|
132
|
+
// oxlint-disable-next-line consistent-function-scoping
|
|
130
133
|
const calculateImpact = (arrayInfo) => {
|
|
131
134
|
if (arrayInfo.inArray && arrayInfo.estimatedSize && arrayInfo.estimatedSize > 50) {
|
|
132
135
|
return {
|
|
@@ -89,6 +89,7 @@ exports.reactRenderOptimization = (0, eslint_devkit_2.createRule)({
|
|
|
89
89
|
meta: {
|
|
90
90
|
type: 'suggestion',
|
|
91
91
|
docs: {
|
|
92
|
+
url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/react-render-optimization.md',
|
|
92
93
|
description: 'Detects unnecessary re-renders and expensive computations in React',
|
|
93
94
|
},
|
|
94
95
|
messages: {
|
|
@@ -187,7 +188,7 @@ exports.reactRenderOptimization = (0, eslint_devkit_2.createRule)({
|
|
|
187
188
|
],
|
|
188
189
|
create(context, [options = {}]) {
|
|
189
190
|
const { detectInlineProps = true, detectInlineFunctions = true, detectExpensiveComputations = true, minComputationComplexity = 3, ignoreInTests = true, } = options || {};
|
|
190
|
-
const filename = context.
|
|
191
|
+
const filename = context.filename;
|
|
191
192
|
const isTestFile = ignoreInTests && /\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);
|
|
192
193
|
if (isTestFile) {
|
|
193
194
|
return {};
|
|
@@ -13,6 +13,7 @@ exports.checkedRequiresOnchangeOrReadonly = (0, eslint_devkit_1.createRule)({
|
|
|
13
13
|
meta: {
|
|
14
14
|
type: 'problem',
|
|
15
15
|
docs: {
|
|
16
|
+
url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/checked-requires-onchange-or-readonly.md',
|
|
16
17
|
description: 'Ensure controlled inputs have onChange or readOnly',
|
|
17
18
|
},
|
|
18
19
|
schema: [],
|
|
@@ -13,6 +13,7 @@ exports.defaultPropsMatchPropTypes = (0, eslint_devkit_1.createRule)({
|
|
|
13
13
|
meta: {
|
|
14
14
|
type: 'problem',
|
|
15
15
|
docs: {
|
|
16
|
+
url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/default-props-match-prop-types.md',
|
|
16
17
|
description: 'Validate default props match prop types',
|
|
17
18
|
},
|
|
18
19
|
schema: [],
|