eslint-plugin-react-x 1.42.2-next.1 → 1.42.2-next.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/dist/index.js +28 -35
- package/dist/index.mjs +28 -35
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -4,13 +4,13 @@ var shared = require('@eslint-react/shared');
|
|
|
4
4
|
var JSX8 = require('@eslint-react/jsx');
|
|
5
5
|
var utils = require('@typescript-eslint/utils');
|
|
6
6
|
var types = require('@typescript-eslint/types');
|
|
7
|
-
var eff = require('@eslint-react/eff');
|
|
8
7
|
var VAR2 = require('@eslint-react/var');
|
|
9
8
|
var tsPattern = require('ts-pattern');
|
|
10
9
|
var kit = require('@eslint-react/kit');
|
|
11
10
|
var ts = require('typescript');
|
|
12
11
|
var AST8 = require('@eslint-react/ast');
|
|
13
12
|
var ER21 = require('@eslint-react/core');
|
|
13
|
+
var eff = require('@eslint-react/eff');
|
|
14
14
|
var compareVersions = require('compare-versions');
|
|
15
15
|
var typeUtils = require('@typescript-eslint/type-utils');
|
|
16
16
|
var tsApiUtils = require('ts-api-utils');
|
|
@@ -141,7 +141,7 @@ var settings3 = {
|
|
|
141
141
|
|
|
142
142
|
// package.json
|
|
143
143
|
var name4 = "eslint-plugin-react-x";
|
|
144
|
-
var version = "1.42.2-next.
|
|
144
|
+
var version = "1.42.2-next.3";
|
|
145
145
|
var createRule = utils.ESLintUtils.RuleCreator(shared.getDocsUrl("x"));
|
|
146
146
|
|
|
147
147
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -167,7 +167,7 @@ var avoid_shorthand_boolean_default = createRule({
|
|
|
167
167
|
function create(context) {
|
|
168
168
|
return {
|
|
169
169
|
JSXAttribute(node) {
|
|
170
|
-
if (node.value
|
|
170
|
+
if (node.value == null) {
|
|
171
171
|
context.report({
|
|
172
172
|
messageId: "avoidShorthandBoolean",
|
|
173
173
|
node,
|
|
@@ -273,7 +273,7 @@ var jsx_no_undef_default = createRule({
|
|
|
273
273
|
function create4(context) {
|
|
274
274
|
return {
|
|
275
275
|
JSXOpeningElement(node) {
|
|
276
|
-
const name5 = tsPattern.match(node.name).with({ type: types.AST_NODE_TYPES.JSXIdentifier }, (n) => n.name).with({ type: types.AST_NODE_TYPES.JSXMemberExpression, object: { type: types.AST_NODE_TYPES.JSXIdentifier } }, (n) => n.object.name).otherwise(() =>
|
|
276
|
+
const name5 = tsPattern.match(node.name).with({ type: types.AST_NODE_TYPES.JSXIdentifier }, (n) => n.name).with({ type: types.AST_NODE_TYPES.JSXMemberExpression, object: { type: types.AST_NODE_TYPES.JSXIdentifier } }, (n) => n.object.name).otherwise(() => null);
|
|
277
277
|
if (name5 == null) return;
|
|
278
278
|
if (name5 === "this") return;
|
|
279
279
|
if (/^[a-z]/u.test(name5)) return;
|
|
@@ -645,7 +645,9 @@ function create8(context) {
|
|
|
645
645
|
if (!("value" in prop)) {
|
|
646
646
|
continue;
|
|
647
647
|
}
|
|
648
|
-
getReportDescriptors(prop.value)
|
|
648
|
+
for (const descriptor of getReportDescriptors(prop.value)) {
|
|
649
|
+
report(descriptor);
|
|
650
|
+
}
|
|
649
651
|
}
|
|
650
652
|
},
|
|
651
653
|
"CallExpression:exit"() {
|
|
@@ -661,7 +663,9 @@ function create8(context) {
|
|
|
661
663
|
if (node.value?.type !== types.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
662
664
|
return;
|
|
663
665
|
}
|
|
664
|
-
getReportDescriptors(node.value.expression)
|
|
666
|
+
for (const descriptor of getReportDescriptors(node.value.expression)) {
|
|
667
|
+
report(descriptor);
|
|
668
|
+
}
|
|
665
669
|
}
|
|
666
670
|
};
|
|
667
671
|
}
|
|
@@ -806,15 +810,12 @@ var no_children_prop_default = createRule({
|
|
|
806
810
|
function create13(context) {
|
|
807
811
|
return {
|
|
808
812
|
JSXElement(node) {
|
|
809
|
-
const
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
context.sourceCode.getScope(node)
|
|
813
|
-
);
|
|
814
|
-
if (attribute != null) {
|
|
813
|
+
const attributes = node.openingElement.attributes;
|
|
814
|
+
const childrenProp = JSX8__namespace.getAttribute("children", attributes, context.sourceCode.getScope(node));
|
|
815
|
+
if (childrenProp != null) {
|
|
815
816
|
context.report({
|
|
816
817
|
messageId: "noChildrenProp",
|
|
817
|
-
node:
|
|
818
|
+
node: childrenProp
|
|
818
819
|
});
|
|
819
820
|
}
|
|
820
821
|
}
|
|
@@ -911,13 +912,12 @@ var no_clone_element_default = createRule({
|
|
|
911
912
|
function create16(context) {
|
|
912
913
|
return {
|
|
913
914
|
CallExpression(node) {
|
|
914
|
-
if (
|
|
915
|
-
|
|
915
|
+
if (ER21__namespace.isCloneElementCall(context, node)) {
|
|
916
|
+
context.report({
|
|
917
|
+
messageId: "noCloneElement",
|
|
918
|
+
node
|
|
919
|
+
});
|
|
916
920
|
}
|
|
917
|
-
context.report({
|
|
918
|
-
messageId: "noCloneElement",
|
|
919
|
-
node
|
|
920
|
-
});
|
|
921
921
|
}
|
|
922
922
|
};
|
|
923
923
|
}
|
|
@@ -1481,8 +1481,8 @@ function getComponentPropsFixes(context, fixer, node, typeArguments) {
|
|
|
1481
1481
|
if (arg0 == null) {
|
|
1482
1482
|
return [];
|
|
1483
1483
|
}
|
|
1484
|
-
const fixedArg0Text = tsPattern.match(arg0).with({ type: types.AST_NODE_TYPES.Identifier }, (n) => `...${n.name}`).with({ type: types.AST_NODE_TYPES.ObjectPattern }, (n) => n.properties.map(getText).join(", ")).otherwise(() =>
|
|
1485
|
-
const fixedArg1Text = tsPattern.match(arg1).with(tsPattern.P.nullish, () => "ref").with({ type: types.AST_NODE_TYPES.Identifier, name: "ref" }, () => "ref").with({ type: types.AST_NODE_TYPES.Identifier, name: tsPattern.P.string }, (n) => `ref: ${n.name}`).otherwise(() =>
|
|
1484
|
+
const fixedArg0Text = tsPattern.match(arg0).with({ type: types.AST_NODE_TYPES.Identifier }, (n) => `...${n.name}`).with({ type: types.AST_NODE_TYPES.ObjectPattern }, (n) => n.properties.map(getText).join(", ")).otherwise(() => null);
|
|
1485
|
+
const fixedArg1Text = tsPattern.match(arg1).with(tsPattern.P.nullish, () => "ref").with({ type: types.AST_NODE_TYPES.Identifier, name: "ref" }, () => "ref").with({ type: types.AST_NODE_TYPES.Identifier, name: tsPattern.P.string }, (n) => `ref: ${n.name}`).otherwise(() => null);
|
|
1486
1486
|
if (fixedArg0Text == null || fixedArg1Text == null) {
|
|
1487
1487
|
return [];
|
|
1488
1488
|
}
|
|
@@ -1912,22 +1912,15 @@ function create32(context) {
|
|
|
1912
1912
|
},
|
|
1913
1913
|
CallExpression(node) {
|
|
1914
1914
|
state.isWithinChildrenToArray ||= ER21__namespace.isChildrenToArrayCall(context, node);
|
|
1915
|
-
if (state.isWithinChildrenToArray)
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
const
|
|
1919
|
-
if (
|
|
1920
|
-
|
|
1921
|
-
}
|
|
1922
|
-
const fn = node.arguments[isMapCall ? 0 : 1];
|
|
1923
|
-
if (!AST8__namespace.isFunction(fn)) {
|
|
1924
|
-
return;
|
|
1925
|
-
}
|
|
1926
|
-
if (fn.body.type === types.AST_NODE_TYPES.BlockStatement) {
|
|
1927
|
-
checkBlockStatement(fn.body).forEach(report);
|
|
1915
|
+
if (state.isWithinChildrenToArray) return;
|
|
1916
|
+
const callback = tsPattern.match(node).when(AST8__namespace.isArrayMapCall, (n) => n.arguments[0]).when(AST8__namespace.isArrayFromCall, (n) => n.arguments[1]).otherwise(() => null);
|
|
1917
|
+
if (!AST8__namespace.isFunction(callback)) return;
|
|
1918
|
+
const body = callback.body;
|
|
1919
|
+
if (body.type === types.AST_NODE_TYPES.BlockStatement) {
|
|
1920
|
+
checkBlockStatement(body).forEach(report);
|
|
1928
1921
|
return;
|
|
1929
1922
|
}
|
|
1930
|
-
report(checkExpression(
|
|
1923
|
+
report(checkExpression(body));
|
|
1931
1924
|
},
|
|
1932
1925
|
"CallExpression:exit"(node) {
|
|
1933
1926
|
if (!ER21__namespace.isChildrenToArrayCall(context, node)) {
|
package/dist/index.mjs
CHANGED
|
@@ -2,13 +2,13 @@ import { getDocsUrl, getSettingsFromContext, unsafeDecodeSettings, DEFAULT_ESLIN
|
|
|
2
2
|
import * as JSX8 from '@eslint-react/jsx';
|
|
3
3
|
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
4
4
|
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
5
|
-
import { _, flow, getOrUpdate, constTrue, constFalse } from '@eslint-react/eff';
|
|
6
5
|
import * as VAR2 from '@eslint-react/var';
|
|
7
6
|
import { match, isMatching, P } from 'ts-pattern';
|
|
8
7
|
import { JsxConfig, createReport } from '@eslint-react/kit';
|
|
9
8
|
import ts, { JsxEmit } from 'typescript';
|
|
10
9
|
import * as AST8 from '@eslint-react/ast';
|
|
11
10
|
import * as ER21 from '@eslint-react/core';
|
|
11
|
+
import { flow, getOrUpdate, constTrue, constFalse, _ } from '@eslint-react/eff';
|
|
12
12
|
import { compare } from 'compare-versions';
|
|
13
13
|
import { getConstrainedTypeAtLocation, isTypeReadonly } from '@typescript-eslint/type-utils';
|
|
14
14
|
import { unionTypeParts, isTypeFlagSet, isTrueLiteralType, isFalseLiteralType } from 'ts-api-utils';
|
|
@@ -113,7 +113,7 @@ var settings3 = {
|
|
|
113
113
|
|
|
114
114
|
// package.json
|
|
115
115
|
var name4 = "eslint-plugin-react-x";
|
|
116
|
-
var version = "1.42.2-next.
|
|
116
|
+
var version = "1.42.2-next.3";
|
|
117
117
|
var createRule = ESLintUtils.RuleCreator(getDocsUrl("x"));
|
|
118
118
|
|
|
119
119
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -139,7 +139,7 @@ var avoid_shorthand_boolean_default = createRule({
|
|
|
139
139
|
function create(context) {
|
|
140
140
|
return {
|
|
141
141
|
JSXAttribute(node) {
|
|
142
|
-
if (node.value
|
|
142
|
+
if (node.value == null) {
|
|
143
143
|
context.report({
|
|
144
144
|
messageId: "avoidShorthandBoolean",
|
|
145
145
|
node,
|
|
@@ -245,7 +245,7 @@ var jsx_no_undef_default = createRule({
|
|
|
245
245
|
function create4(context) {
|
|
246
246
|
return {
|
|
247
247
|
JSXOpeningElement(node) {
|
|
248
|
-
const name5 = match(node.name).with({ type: AST_NODE_TYPES.JSXIdentifier }, (n) => n.name).with({ type: AST_NODE_TYPES.JSXMemberExpression, object: { type: AST_NODE_TYPES.JSXIdentifier } }, (n) => n.object.name).otherwise(() =>
|
|
248
|
+
const name5 = match(node.name).with({ type: AST_NODE_TYPES.JSXIdentifier }, (n) => n.name).with({ type: AST_NODE_TYPES.JSXMemberExpression, object: { type: AST_NODE_TYPES.JSXIdentifier } }, (n) => n.object.name).otherwise(() => null);
|
|
249
249
|
if (name5 == null) return;
|
|
250
250
|
if (name5 === "this") return;
|
|
251
251
|
if (/^[a-z]/u.test(name5)) return;
|
|
@@ -617,7 +617,9 @@ function create8(context) {
|
|
|
617
617
|
if (!("value" in prop)) {
|
|
618
618
|
continue;
|
|
619
619
|
}
|
|
620
|
-
getReportDescriptors(prop.value)
|
|
620
|
+
for (const descriptor of getReportDescriptors(prop.value)) {
|
|
621
|
+
report(descriptor);
|
|
622
|
+
}
|
|
621
623
|
}
|
|
622
624
|
},
|
|
623
625
|
"CallExpression:exit"() {
|
|
@@ -633,7 +635,9 @@ function create8(context) {
|
|
|
633
635
|
if (node.value?.type !== AST_NODE_TYPES.JSXExpressionContainer) {
|
|
634
636
|
return;
|
|
635
637
|
}
|
|
636
|
-
getReportDescriptors(node.value.expression)
|
|
638
|
+
for (const descriptor of getReportDescriptors(node.value.expression)) {
|
|
639
|
+
report(descriptor);
|
|
640
|
+
}
|
|
637
641
|
}
|
|
638
642
|
};
|
|
639
643
|
}
|
|
@@ -778,15 +782,12 @@ var no_children_prop_default = createRule({
|
|
|
778
782
|
function create13(context) {
|
|
779
783
|
return {
|
|
780
784
|
JSXElement(node) {
|
|
781
|
-
const
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
context.sourceCode.getScope(node)
|
|
785
|
-
);
|
|
786
|
-
if (attribute != null) {
|
|
785
|
+
const attributes = node.openingElement.attributes;
|
|
786
|
+
const childrenProp = JSX8.getAttribute("children", attributes, context.sourceCode.getScope(node));
|
|
787
|
+
if (childrenProp != null) {
|
|
787
788
|
context.report({
|
|
788
789
|
messageId: "noChildrenProp",
|
|
789
|
-
node:
|
|
790
|
+
node: childrenProp
|
|
790
791
|
});
|
|
791
792
|
}
|
|
792
793
|
}
|
|
@@ -883,13 +884,12 @@ var no_clone_element_default = createRule({
|
|
|
883
884
|
function create16(context) {
|
|
884
885
|
return {
|
|
885
886
|
CallExpression(node) {
|
|
886
|
-
if (
|
|
887
|
-
|
|
887
|
+
if (ER21.isCloneElementCall(context, node)) {
|
|
888
|
+
context.report({
|
|
889
|
+
messageId: "noCloneElement",
|
|
890
|
+
node
|
|
891
|
+
});
|
|
888
892
|
}
|
|
889
|
-
context.report({
|
|
890
|
-
messageId: "noCloneElement",
|
|
891
|
-
node
|
|
892
|
-
});
|
|
893
893
|
}
|
|
894
894
|
};
|
|
895
895
|
}
|
|
@@ -1453,8 +1453,8 @@ function getComponentPropsFixes(context, fixer, node, typeArguments) {
|
|
|
1453
1453
|
if (arg0 == null) {
|
|
1454
1454
|
return [];
|
|
1455
1455
|
}
|
|
1456
|
-
const fixedArg0Text = match(arg0).with({ type: AST_NODE_TYPES.Identifier }, (n) => `...${n.name}`).with({ type: AST_NODE_TYPES.ObjectPattern }, (n) => n.properties.map(getText).join(", ")).otherwise(() =>
|
|
1457
|
-
const fixedArg1Text = match(arg1).with(P.nullish, () => "ref").with({ type: AST_NODE_TYPES.Identifier, name: "ref" }, () => "ref").with({ type: AST_NODE_TYPES.Identifier, name: P.string }, (n) => `ref: ${n.name}`).otherwise(() =>
|
|
1456
|
+
const fixedArg0Text = match(arg0).with({ type: AST_NODE_TYPES.Identifier }, (n) => `...${n.name}`).with({ type: AST_NODE_TYPES.ObjectPattern }, (n) => n.properties.map(getText).join(", ")).otherwise(() => null);
|
|
1457
|
+
const fixedArg1Text = match(arg1).with(P.nullish, () => "ref").with({ type: AST_NODE_TYPES.Identifier, name: "ref" }, () => "ref").with({ type: AST_NODE_TYPES.Identifier, name: P.string }, (n) => `ref: ${n.name}`).otherwise(() => null);
|
|
1458
1458
|
if (fixedArg0Text == null || fixedArg1Text == null) {
|
|
1459
1459
|
return [];
|
|
1460
1460
|
}
|
|
@@ -1884,22 +1884,15 @@ function create32(context) {
|
|
|
1884
1884
|
},
|
|
1885
1885
|
CallExpression(node) {
|
|
1886
1886
|
state.isWithinChildrenToArray ||= ER21.isChildrenToArrayCall(context, node);
|
|
1887
|
-
if (state.isWithinChildrenToArray)
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
const
|
|
1891
|
-
if (
|
|
1892
|
-
|
|
1893
|
-
}
|
|
1894
|
-
const fn = node.arguments[isMapCall ? 0 : 1];
|
|
1895
|
-
if (!AST8.isFunction(fn)) {
|
|
1896
|
-
return;
|
|
1897
|
-
}
|
|
1898
|
-
if (fn.body.type === AST_NODE_TYPES.BlockStatement) {
|
|
1899
|
-
checkBlockStatement(fn.body).forEach(report);
|
|
1887
|
+
if (state.isWithinChildrenToArray) return;
|
|
1888
|
+
const callback = match(node).when(AST8.isArrayMapCall, (n) => n.arguments[0]).when(AST8.isArrayFromCall, (n) => n.arguments[1]).otherwise(() => null);
|
|
1889
|
+
if (!AST8.isFunction(callback)) return;
|
|
1890
|
+
const body = callback.body;
|
|
1891
|
+
if (body.type === AST_NODE_TYPES.BlockStatement) {
|
|
1892
|
+
checkBlockStatement(body).forEach(report);
|
|
1900
1893
|
return;
|
|
1901
1894
|
}
|
|
1902
|
-
report(checkExpression(
|
|
1895
|
+
report(checkExpression(body));
|
|
1903
1896
|
},
|
|
1904
1897
|
"CallExpression:exit"(node) {
|
|
1905
1898
|
if (!ER21.isChildrenToArrayCall(context, node)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "1.42.2-next.
|
|
3
|
+
"version": "1.42.2-next.3",
|
|
4
4
|
"description": "A series of composable ESLint rules for for libraries and frameworks that use React as a UI runtime.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
"is-immutable-type": "^5.0.1",
|
|
51
51
|
"string-ts": "^2.2.1",
|
|
52
52
|
"ts-pattern": "^5.7.0",
|
|
53
|
-
"@eslint-react/core": "1.42.2-next.
|
|
54
|
-
"@eslint-react/ast": "1.42.2-next.
|
|
55
|
-
"@eslint-react/eff": "1.42.2-next.
|
|
56
|
-
"@eslint-react/
|
|
57
|
-
"@eslint-react/
|
|
58
|
-
"@eslint-react/
|
|
59
|
-
"@eslint-react/
|
|
53
|
+
"@eslint-react/core": "1.42.2-next.3",
|
|
54
|
+
"@eslint-react/ast": "1.42.2-next.3",
|
|
55
|
+
"@eslint-react/eff": "1.42.2-next.3",
|
|
56
|
+
"@eslint-react/kit": "1.42.2-next.3",
|
|
57
|
+
"@eslint-react/shared": "1.42.2-next.3",
|
|
58
|
+
"@eslint-react/var": "1.42.2-next.3",
|
|
59
|
+
"@eslint-react/jsx": "1.42.2-next.3"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/react": "^19.1.0",
|