eslint-plugin-react-x 1.42.2-beta.5 → 1.42.2-next.1
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 +1 -1
- package/dist/index.js +35 -28
- package/dist/index.mjs +35 -28
- package/package.json +10 -10
package/README.md
CHANGED
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');
|
|
7
8
|
var VAR2 = require('@eslint-react/var');
|
|
8
9
|
var tsPattern = require('ts-pattern');
|
|
9
10
|
var kit = require('@eslint-react/kit');
|
|
10
11
|
var ts = require('typescript');
|
|
11
12
|
var AST8 = require('@eslint-react/ast');
|
|
12
13
|
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-
|
|
144
|
+
var version = "1.42.2-next.1";
|
|
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(() => eff._);
|
|
277
277
|
if (name5 == null) return;
|
|
278
278
|
if (name5 === "this") return;
|
|
279
279
|
if (/^[a-z]/u.test(name5)) return;
|
|
@@ -645,9 +645,7 @@ function create8(context) {
|
|
|
645
645
|
if (!("value" in prop)) {
|
|
646
646
|
continue;
|
|
647
647
|
}
|
|
648
|
-
|
|
649
|
-
report(descriptor);
|
|
650
|
-
}
|
|
648
|
+
getReportDescriptors(prop.value).forEach(report);
|
|
651
649
|
}
|
|
652
650
|
},
|
|
653
651
|
"CallExpression:exit"() {
|
|
@@ -663,9 +661,7 @@ function create8(context) {
|
|
|
663
661
|
if (node.value?.type !== types.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
664
662
|
return;
|
|
665
663
|
}
|
|
666
|
-
|
|
667
|
-
report(descriptor);
|
|
668
|
-
}
|
|
664
|
+
getReportDescriptors(node.value.expression).forEach(report);
|
|
669
665
|
}
|
|
670
666
|
};
|
|
671
667
|
}
|
|
@@ -810,12 +806,15 @@ var no_children_prop_default = createRule({
|
|
|
810
806
|
function create13(context) {
|
|
811
807
|
return {
|
|
812
808
|
JSXElement(node) {
|
|
813
|
-
const
|
|
814
|
-
|
|
815
|
-
|
|
809
|
+
const attribute = JSX8__namespace.getAttribute(
|
|
810
|
+
"children",
|
|
811
|
+
node.openingElement.attributes,
|
|
812
|
+
context.sourceCode.getScope(node)
|
|
813
|
+
);
|
|
814
|
+
if (attribute != null) {
|
|
816
815
|
context.report({
|
|
817
816
|
messageId: "noChildrenProp",
|
|
818
|
-
node:
|
|
817
|
+
node: attribute
|
|
819
818
|
});
|
|
820
819
|
}
|
|
821
820
|
}
|
|
@@ -912,12 +911,13 @@ var no_clone_element_default = createRule({
|
|
|
912
911
|
function create16(context) {
|
|
913
912
|
return {
|
|
914
913
|
CallExpression(node) {
|
|
915
|
-
if (ER21__namespace.isCloneElementCall(context, node)) {
|
|
916
|
-
|
|
917
|
-
messageId: "noCloneElement",
|
|
918
|
-
node
|
|
919
|
-
});
|
|
914
|
+
if (!ER21__namespace.isCloneElementCall(context, node)) {
|
|
915
|
+
return;
|
|
920
916
|
}
|
|
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(() => eff._);
|
|
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(() => eff._);
|
|
1486
1486
|
if (fixedArg0Text == null || fixedArg1Text == null) {
|
|
1487
1487
|
return [];
|
|
1488
1488
|
}
|
|
@@ -1912,15 +1912,22 @@ 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
|
-
|
|
1915
|
+
if (state.isWithinChildrenToArray) {
|
|
1916
|
+
return;
|
|
1917
|
+
}
|
|
1918
|
+
const isMapCall = AST8__namespace.isArrayMapCall(node);
|
|
1919
|
+
if (!isMapCall && !AST8__namespace.isArrayFromCall(node)) {
|
|
1920
|
+
return;
|
|
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);
|
|
1921
1928
|
return;
|
|
1922
1929
|
}
|
|
1923
|
-
report(checkExpression(body));
|
|
1930
|
+
report(checkExpression(fn.body));
|
|
1924
1931
|
},
|
|
1925
1932
|
"CallExpression:exit"(node) {
|
|
1926
1933
|
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';
|
|
5
6
|
import * as VAR2 from '@eslint-react/var';
|
|
6
7
|
import { match, isMatching, P } from 'ts-pattern';
|
|
7
8
|
import { JsxConfig, createReport } from '@eslint-react/kit';
|
|
8
9
|
import ts, { JsxEmit } from 'typescript';
|
|
9
10
|
import * as AST8 from '@eslint-react/ast';
|
|
10
11
|
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-
|
|
116
|
+
var version = "1.42.2-next.1";
|
|
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(() => _);
|
|
249
249
|
if (name5 == null) return;
|
|
250
250
|
if (name5 === "this") return;
|
|
251
251
|
if (/^[a-z]/u.test(name5)) return;
|
|
@@ -617,9 +617,7 @@ function create8(context) {
|
|
|
617
617
|
if (!("value" in prop)) {
|
|
618
618
|
continue;
|
|
619
619
|
}
|
|
620
|
-
|
|
621
|
-
report(descriptor);
|
|
622
|
-
}
|
|
620
|
+
getReportDescriptors(prop.value).forEach(report);
|
|
623
621
|
}
|
|
624
622
|
},
|
|
625
623
|
"CallExpression:exit"() {
|
|
@@ -635,9 +633,7 @@ function create8(context) {
|
|
|
635
633
|
if (node.value?.type !== AST_NODE_TYPES.JSXExpressionContainer) {
|
|
636
634
|
return;
|
|
637
635
|
}
|
|
638
|
-
|
|
639
|
-
report(descriptor);
|
|
640
|
-
}
|
|
636
|
+
getReportDescriptors(node.value.expression).forEach(report);
|
|
641
637
|
}
|
|
642
638
|
};
|
|
643
639
|
}
|
|
@@ -782,12 +778,15 @@ var no_children_prop_default = createRule({
|
|
|
782
778
|
function create13(context) {
|
|
783
779
|
return {
|
|
784
780
|
JSXElement(node) {
|
|
785
|
-
const
|
|
786
|
-
|
|
787
|
-
|
|
781
|
+
const attribute = JSX8.getAttribute(
|
|
782
|
+
"children",
|
|
783
|
+
node.openingElement.attributes,
|
|
784
|
+
context.sourceCode.getScope(node)
|
|
785
|
+
);
|
|
786
|
+
if (attribute != null) {
|
|
788
787
|
context.report({
|
|
789
788
|
messageId: "noChildrenProp",
|
|
790
|
-
node:
|
|
789
|
+
node: attribute
|
|
791
790
|
});
|
|
792
791
|
}
|
|
793
792
|
}
|
|
@@ -884,12 +883,13 @@ var no_clone_element_default = createRule({
|
|
|
884
883
|
function create16(context) {
|
|
885
884
|
return {
|
|
886
885
|
CallExpression(node) {
|
|
887
|
-
if (ER21.isCloneElementCall(context, node)) {
|
|
888
|
-
|
|
889
|
-
messageId: "noCloneElement",
|
|
890
|
-
node
|
|
891
|
-
});
|
|
886
|
+
if (!ER21.isCloneElementCall(context, node)) {
|
|
887
|
+
return;
|
|
892
888
|
}
|
|
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(() => _);
|
|
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(() => _);
|
|
1458
1458
|
if (fixedArg0Text == null || fixedArg1Text == null) {
|
|
1459
1459
|
return [];
|
|
1460
1460
|
}
|
|
@@ -1884,15 +1884,22 @@ 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
|
-
|
|
1887
|
+
if (state.isWithinChildrenToArray) {
|
|
1888
|
+
return;
|
|
1889
|
+
}
|
|
1890
|
+
const isMapCall = AST8.isArrayMapCall(node);
|
|
1891
|
+
if (!isMapCall && !AST8.isArrayFromCall(node)) {
|
|
1892
|
+
return;
|
|
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);
|
|
1893
1900
|
return;
|
|
1894
1901
|
}
|
|
1895
|
-
report(checkExpression(body));
|
|
1902
|
+
report(checkExpression(fn.body));
|
|
1896
1903
|
},
|
|
1897
1904
|
"CallExpression:exit"(node) {
|
|
1898
1905
|
if (!ER21.isChildrenToArrayCall(context, node)) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "1.42.2-
|
|
4
|
-
"description": "A
|
|
3
|
+
"version": "1.42.2-next.1",
|
|
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",
|
|
7
7
|
"eslint",
|
|
@@ -50,17 +50,17 @@
|
|
|
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/
|
|
54
|
-
"@eslint-react/
|
|
55
|
-
"@eslint-react/
|
|
56
|
-
"@eslint-react/
|
|
57
|
-
"@eslint-react/
|
|
58
|
-
"@eslint-react/shared": "1.42.2-
|
|
59
|
-
"@eslint-react/var": "1.42.2-
|
|
53
|
+
"@eslint-react/core": "1.42.2-next.1",
|
|
54
|
+
"@eslint-react/ast": "1.42.2-next.1",
|
|
55
|
+
"@eslint-react/eff": "1.42.2-next.1",
|
|
56
|
+
"@eslint-react/jsx": "1.42.2-next.1",
|
|
57
|
+
"@eslint-react/kit": "1.42.2-next.1",
|
|
58
|
+
"@eslint-react/shared": "1.42.2-next.1",
|
|
59
|
+
"@eslint-react/var": "1.42.2-next.1"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/react": "^19.1.0",
|
|
63
|
-
"@types/react-dom": "^19.1.
|
|
63
|
+
"@types/react-dom": "^19.1.1",
|
|
64
64
|
"ts-api-utils": "^2.1.0",
|
|
65
65
|
"tsup": "^8.4.0",
|
|
66
66
|
"@local/configs": "0.0.0"
|