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
|
@@ -23,6 +23,7 @@ exports.staticPropertyPlacement = (0, eslint_devkit_1.createRule)({
|
|
|
23
23
|
meta: {
|
|
24
24
|
type: 'problem',
|
|
25
25
|
docs: {
|
|
26
|
+
url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/static-property-placement.md',
|
|
26
27
|
description: 'Enforce static property placement',
|
|
27
28
|
},
|
|
28
29
|
schema: [
|
|
@@ -69,6 +70,7 @@ exports.staticPropertyPlacement = (0, eslint_devkit_1.createRule)({
|
|
|
69
70
|
}
|
|
70
71
|
},
|
|
71
72
|
};
|
|
73
|
+
// oxlint-disable-next-line consistent-function-scoping
|
|
72
74
|
function isReactComponent(node) {
|
|
73
75
|
if (!node.superClass)
|
|
74
76
|
return false;
|
|
@@ -124,12 +126,14 @@ exports.staticPropertyPlacement = (0, eslint_devkit_1.createRule)({
|
|
|
124
126
|
}
|
|
125
127
|
}
|
|
126
128
|
}
|
|
129
|
+
// oxlint-disable-next-line consistent-function-scoping
|
|
127
130
|
function isStaticProperty(member) {
|
|
128
131
|
return (
|
|
129
132
|
// Handle PropertyDefinition and MethodDefinition
|
|
130
133
|
(member.type === 'PropertyDefinition' || member.type === 'MethodDefinition') &&
|
|
131
134
|
member.static);
|
|
132
135
|
}
|
|
136
|
+
// oxlint-disable-next-line consistent-function-scoping
|
|
133
137
|
function getPropertyName(member) {
|
|
134
138
|
if (member.key.type === 'Identifier') {
|
|
135
139
|
return member.key.name;
|
|
@@ -137,10 +141,12 @@ exports.staticPropertyPlacement = (0, eslint_devkit_1.createRule)({
|
|
|
137
141
|
return null;
|
|
138
142
|
}
|
|
139
143
|
/* v8 ignore start - only used in unreachable code path above */
|
|
144
|
+
// oxlint-disable-next-line consistent-function-scoping
|
|
140
145
|
function getPropertyKeyNode(member) {
|
|
141
146
|
return member.key;
|
|
142
147
|
}
|
|
143
148
|
/* v8 ignore stop */
|
|
149
|
+
// oxlint-disable-next-line consistent-function-scoping
|
|
144
150
|
function areInSameGroup(name1, name2, groups) {
|
|
145
151
|
for (const group of groups) {
|
|
146
152
|
if (group.properties.includes(name1) && group.properties.includes(name2)) {
|
|
@@ -150,6 +156,7 @@ exports.staticPropertyPlacement = (0, eslint_devkit_1.createRule)({
|
|
|
150
156
|
return false;
|
|
151
157
|
}
|
|
152
158
|
/* v8 ignore start - only used in unreachable code path above */
|
|
159
|
+
// oxlint-disable-next-line consistent-function-scoping
|
|
153
160
|
function shouldBeBetween(name, before, after, groups) {
|
|
154
161
|
for (const group of groups) {
|
|
155
162
|
const beforeIndex = group.properties.indexOf(before);
|
|
@@ -31,6 +31,7 @@ exports.voidDomElementsNoChildren = (0, eslint_devkit_2.createRule)({
|
|
|
31
31
|
meta: {
|
|
32
32
|
type: 'problem',
|
|
33
33
|
docs: {
|
|
34
|
+
url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-react-features/docs/rules/void-dom-elements-no-children.md',
|
|
34
35
|
description: 'Prevent void DOM elements from having children',
|
|
35
36
|
},
|
|
36
37
|
messages: {
|
|
@@ -57,6 +58,7 @@ exports.voidDomElementsNoChildren = (0, eslint_devkit_2.createRule)({
|
|
|
57
58
|
attr.name.type === 'JSXIdentifier' &&
|
|
58
59
|
attr.name.name === 'dangerouslySetInnerHTML');
|
|
59
60
|
}
|
|
61
|
+
// oxlint-disable-next-line consistent-function-scoping
|
|
60
62
|
function hasJSXChildren(node) {
|
|
61
63
|
return node.children.some(child => {
|
|
62
64
|
if (child.type === 'JSXText') {
|