eslint-plugin-react-x 1.38.0-next.8 → 1.38.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/dist/index.js +19 -38
- package/dist/index.mjs +19 -38
- package/package.json +12 -12
package/dist/index.js
CHANGED
|
@@ -4,11 +4,11 @@ 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');
|
|
9
|
+
var tsPattern = require('ts-pattern');
|
|
8
10
|
var AST11 = require('@eslint-react/ast');
|
|
9
11
|
var core = require('@eslint-react/core');
|
|
10
|
-
var eff = require('@eslint-react/eff');
|
|
11
|
-
var tsPattern = require('ts-pattern');
|
|
12
12
|
var kit = require('@eslint-react/kit');
|
|
13
13
|
var compareVersions = require('compare-versions');
|
|
14
14
|
var typeUtils = require('@typescript-eslint/type-utils');
|
|
@@ -57,7 +57,6 @@ __export(recommended_exports, {
|
|
|
57
57
|
var name = "react-x/recommended";
|
|
58
58
|
var rules = {
|
|
59
59
|
"react-x/jsx-no-duplicate-props": "warn",
|
|
60
|
-
"react-x/jsx-no-undef": "error",
|
|
61
60
|
"react-x/jsx-uses-vars": "warn",
|
|
62
61
|
"react-x/no-access-state-in-setstate": "error",
|
|
63
62
|
"react-x/no-array-index-key": "warn",
|
|
@@ -139,7 +138,7 @@ var settings3 = {
|
|
|
139
138
|
|
|
140
139
|
// package.json
|
|
141
140
|
var name4 = "eslint-plugin-react-x";
|
|
142
|
-
var version = "1.38.0
|
|
141
|
+
var version = "1.38.0";
|
|
143
142
|
var createRule = utils.ESLintUtils.RuleCreator(shared.getDocsUrl("x"));
|
|
144
143
|
|
|
145
144
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -260,7 +259,7 @@ var jsx_no_undef_default = createRule({
|
|
|
260
259
|
[Symbol.for("rule_features")]: RULE_FEATURES4
|
|
261
260
|
},
|
|
262
261
|
messages: {
|
|
263
|
-
jsxNoUndef: "JSX variable {{name}} is not defined."
|
|
262
|
+
jsxNoUndef: "JSX variable '{{name}}' is not defined."
|
|
264
263
|
},
|
|
265
264
|
schema: []
|
|
266
265
|
},
|
|
@@ -270,22 +269,18 @@ var jsx_no_undef_default = createRule({
|
|
|
270
269
|
});
|
|
271
270
|
function create4(context) {
|
|
272
271
|
return {
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
if (/^[a-z]/u.test(
|
|
278
|
-
|
|
279
|
-
}
|
|
280
|
-
if (node.parent.type === types.AST_NODE_TYPES.JSXMemberExpression && node.parent.property === node) {
|
|
281
|
-
return;
|
|
282
|
-
}
|
|
283
|
-
const initialScope = context.sourceCode.getScope(node);
|
|
284
|
-
if (VAR2__namespace.findVariable(node.name, initialScope) == null) {
|
|
272
|
+
JSXOpeningElement(node) {
|
|
273
|
+
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._);
|
|
274
|
+
if (name5 == null) return;
|
|
275
|
+
if (name5 === "this") return;
|
|
276
|
+
if (/^[a-z]/u.test(name5)) return;
|
|
277
|
+
if (VAR2__namespace.findVariable(name5, context.sourceCode.getScope(node)) == null) {
|
|
285
278
|
context.report({
|
|
286
279
|
messageId: "jsxNoUndef",
|
|
287
280
|
node,
|
|
288
|
-
data: {
|
|
281
|
+
data: {
|
|
282
|
+
name: name5
|
|
283
|
+
}
|
|
289
284
|
});
|
|
290
285
|
}
|
|
291
286
|
}
|
|
@@ -297,7 +292,7 @@ var jsx_uses_vars_default = createRule({
|
|
|
297
292
|
meta: {
|
|
298
293
|
type: "problem",
|
|
299
294
|
docs: {
|
|
300
|
-
description: "Marks variables used in JSX as used.",
|
|
295
|
+
description: "Marks variables used in JSX elements as used.",
|
|
301
296
|
[Symbol.for("rule_features")]: RULE_FEATURES5
|
|
302
297
|
},
|
|
303
298
|
messages: {
|
|
@@ -446,20 +441,6 @@ function create6(context) {
|
|
|
446
441
|
var RULE_NAME7 = "no-array-index-key";
|
|
447
442
|
var RULE_FEATURES7 = [];
|
|
448
443
|
var reactChildrenMethod = ["forEach", "map"];
|
|
449
|
-
var iteratorFunctionIndexParamPosition = /* @__PURE__ */ new Map([
|
|
450
|
-
["every", 1],
|
|
451
|
-
["filter", 1],
|
|
452
|
-
["find", 1],
|
|
453
|
-
["findIndex", 1],
|
|
454
|
-
["findLast", 1],
|
|
455
|
-
["findLastIndex", 1],
|
|
456
|
-
["flatMap", 1],
|
|
457
|
-
["forEach", 1],
|
|
458
|
-
["map", 1],
|
|
459
|
-
["reduce", 2],
|
|
460
|
-
["reduceRight", 2],
|
|
461
|
-
["some", 1]
|
|
462
|
-
]);
|
|
463
444
|
function isReactChildrenMethod(name5) {
|
|
464
445
|
return reactChildrenMethod.some((method) => method === name5);
|
|
465
446
|
}
|
|
@@ -490,7 +471,7 @@ function getMapIndexParamName(context, node) {
|
|
|
490
471
|
return eff._;
|
|
491
472
|
}
|
|
492
473
|
const { name: name5 } = callee.property;
|
|
493
|
-
if (!
|
|
474
|
+
if (!AST11__namespace.ITERATOR_FUNCTION_INDEX_PARAM_POSITION.has(name5)) {
|
|
494
475
|
return eff._;
|
|
495
476
|
}
|
|
496
477
|
const callbackArg = node.arguments[isUsingReactChildren(context, node) ? 1 : 0];
|
|
@@ -501,7 +482,7 @@ function getMapIndexParamName(context, node) {
|
|
|
501
482
|
return eff._;
|
|
502
483
|
}
|
|
503
484
|
const { params } = callbackArg;
|
|
504
|
-
const indexParamPosition =
|
|
485
|
+
const indexParamPosition = AST11__namespace.ITERATOR_FUNCTION_INDEX_PARAM_POSITION.get(name5);
|
|
505
486
|
if (indexParamPosition == null) {
|
|
506
487
|
return eff._;
|
|
507
488
|
}
|
|
@@ -1359,7 +1340,7 @@ function create25(context) {
|
|
|
1359
1340
|
break;
|
|
1360
1341
|
}
|
|
1361
1342
|
default: {
|
|
1362
|
-
const call = AST11__namespace.findParentNode(jsxElement, AST11__namespace.
|
|
1343
|
+
const call = AST11__namespace.findParentNode(jsxElement, AST11__namespace.isArrayMapCallLoose);
|
|
1363
1344
|
const iter = AST11__namespace.findParentNode(jsxElement, (n) => n === call || AST11__namespace.isFunction(n));
|
|
1364
1345
|
if (!AST11__namespace.isFunction(iter)) return;
|
|
1365
1346
|
const arg0 = call?.arguments[0];
|
|
@@ -1896,7 +1877,7 @@ function create31(context) {
|
|
|
1896
1877
|
if (state.isWithinChildrenToArray) {
|
|
1897
1878
|
return;
|
|
1898
1879
|
}
|
|
1899
|
-
const isMapCall = AST11__namespace.
|
|
1880
|
+
const isMapCall = AST11__namespace.isArrayMapCallLoose(node);
|
|
1900
1881
|
if (!isMapCall && !isArrayFromCall(node)) {
|
|
1901
1882
|
return;
|
|
1902
1883
|
}
|
|
@@ -1951,7 +1932,7 @@ var no_nested_component_definitions_default = createRule({
|
|
|
1951
1932
|
defaultOptions: []
|
|
1952
1933
|
});
|
|
1953
1934
|
function create32(context) {
|
|
1954
|
-
const hint = core.ERComponentHint.
|
|
1935
|
+
const hint = core.ERComponentHint.SkipArrayMapArgument | core.ERComponentHint.SkipNullLiteral | core.ERComponentHint.SkipUndefined | core.ERComponentHint.SkipBooleanLiteral | core.ERComponentHint.SkipStringLiteral | core.ERComponentHint.SkipNumberLiteral | core.ERComponentHint.StrictLogical | core.ERComponentHint.StrictConditional;
|
|
1955
1936
|
const collector = core.useComponentCollector(context, { hint });
|
|
1956
1937
|
const collectorLegacy = core.useComponentCollectorLegacy();
|
|
1957
1938
|
return {
|
package/dist/index.mjs
CHANGED
|
@@ -2,11 +2,11 @@ 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';
|
|
7
|
+
import { match, isMatching, P } from 'ts-pattern';
|
|
6
8
|
import * as AST11 from '@eslint-react/ast';
|
|
7
9
|
import { isClassComponent, isThisSetState, isChildrenCount, isChildrenForEach, isChildrenMap, isChildrenOnly, isChildrenToArray, useComponentCollectorLegacy, isComponentDidCatch, isGetDerivedStateFromError, isCloneElementCall, isComponentNameLoose, isCreateRefCall, isAssignmentToThisState, isForwardRefCall, useComponentCollector, DEFAULT_COMPONENT_HINT, ERComponentFlag, getInstanceId, isInstanceIdEqual, DISPLAY_NAME_ASSIGNMENT_SELECTOR, isCreateContextCall, isChildrenToArrayCall, ERComponentHint, isDirectValueOfRenderPropertyLoose, isDeclaredInRenderPropLoose, isInsideRenderMethod, isCreateElementCall, isReactHookCall, isReactHookCallWithNameAlias, isGetDerivedStateFromProps, isInitializedFromReact } from '@eslint-react/core';
|
|
8
|
-
import { _, flow, getOrUpdate, constTrue, constFalse } from '@eslint-react/eff';
|
|
9
|
-
import { isMatching, match, P } from 'ts-pattern';
|
|
10
10
|
import { createReport } from '@eslint-react/kit';
|
|
11
11
|
import { compare } from 'compare-versions';
|
|
12
12
|
import { getConstrainedTypeAtLocation, isTypeReadonly } from '@typescript-eslint/type-utils';
|
|
@@ -30,7 +30,6 @@ __export(recommended_exports, {
|
|
|
30
30
|
var name = "react-x/recommended";
|
|
31
31
|
var rules = {
|
|
32
32
|
"react-x/jsx-no-duplicate-props": "warn",
|
|
33
|
-
"react-x/jsx-no-undef": "error",
|
|
34
33
|
"react-x/jsx-uses-vars": "warn",
|
|
35
34
|
"react-x/no-access-state-in-setstate": "error",
|
|
36
35
|
"react-x/no-array-index-key": "warn",
|
|
@@ -112,7 +111,7 @@ var settings3 = {
|
|
|
112
111
|
|
|
113
112
|
// package.json
|
|
114
113
|
var name4 = "eslint-plugin-react-x";
|
|
115
|
-
var version = "1.38.0
|
|
114
|
+
var version = "1.38.0";
|
|
116
115
|
var createRule = ESLintUtils.RuleCreator(getDocsUrl("x"));
|
|
117
116
|
|
|
118
117
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -233,7 +232,7 @@ var jsx_no_undef_default = createRule({
|
|
|
233
232
|
[Symbol.for("rule_features")]: RULE_FEATURES4
|
|
234
233
|
},
|
|
235
234
|
messages: {
|
|
236
|
-
jsxNoUndef: "JSX variable {{name}} is not defined."
|
|
235
|
+
jsxNoUndef: "JSX variable '{{name}}' is not defined."
|
|
237
236
|
},
|
|
238
237
|
schema: []
|
|
239
238
|
},
|
|
@@ -243,22 +242,18 @@ var jsx_no_undef_default = createRule({
|
|
|
243
242
|
});
|
|
244
243
|
function create4(context) {
|
|
245
244
|
return {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
if (/^[a-z]/u.test(
|
|
251
|
-
|
|
252
|
-
}
|
|
253
|
-
if (node.parent.type === AST_NODE_TYPES.JSXMemberExpression && node.parent.property === node) {
|
|
254
|
-
return;
|
|
255
|
-
}
|
|
256
|
-
const initialScope = context.sourceCode.getScope(node);
|
|
257
|
-
if (VAR2.findVariable(node.name, initialScope) == null) {
|
|
245
|
+
JSXOpeningElement(node) {
|
|
246
|
+
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(() => _);
|
|
247
|
+
if (name5 == null) return;
|
|
248
|
+
if (name5 === "this") return;
|
|
249
|
+
if (/^[a-z]/u.test(name5)) return;
|
|
250
|
+
if (VAR2.findVariable(name5, context.sourceCode.getScope(node)) == null) {
|
|
258
251
|
context.report({
|
|
259
252
|
messageId: "jsxNoUndef",
|
|
260
253
|
node,
|
|
261
|
-
data: {
|
|
254
|
+
data: {
|
|
255
|
+
name: name5
|
|
256
|
+
}
|
|
262
257
|
});
|
|
263
258
|
}
|
|
264
259
|
}
|
|
@@ -270,7 +265,7 @@ var jsx_uses_vars_default = createRule({
|
|
|
270
265
|
meta: {
|
|
271
266
|
type: "problem",
|
|
272
267
|
docs: {
|
|
273
|
-
description: "Marks variables used in JSX as used.",
|
|
268
|
+
description: "Marks variables used in JSX elements as used.",
|
|
274
269
|
[Symbol.for("rule_features")]: RULE_FEATURES5
|
|
275
270
|
},
|
|
276
271
|
messages: {
|
|
@@ -419,20 +414,6 @@ function create6(context) {
|
|
|
419
414
|
var RULE_NAME7 = "no-array-index-key";
|
|
420
415
|
var RULE_FEATURES7 = [];
|
|
421
416
|
var reactChildrenMethod = ["forEach", "map"];
|
|
422
|
-
var iteratorFunctionIndexParamPosition = /* @__PURE__ */ new Map([
|
|
423
|
-
["every", 1],
|
|
424
|
-
["filter", 1],
|
|
425
|
-
["find", 1],
|
|
426
|
-
["findIndex", 1],
|
|
427
|
-
["findLast", 1],
|
|
428
|
-
["findLastIndex", 1],
|
|
429
|
-
["flatMap", 1],
|
|
430
|
-
["forEach", 1],
|
|
431
|
-
["map", 1],
|
|
432
|
-
["reduce", 2],
|
|
433
|
-
["reduceRight", 2],
|
|
434
|
-
["some", 1]
|
|
435
|
-
]);
|
|
436
417
|
function isReactChildrenMethod(name5) {
|
|
437
418
|
return reactChildrenMethod.some((method) => method === name5);
|
|
438
419
|
}
|
|
@@ -463,7 +444,7 @@ function getMapIndexParamName(context, node) {
|
|
|
463
444
|
return _;
|
|
464
445
|
}
|
|
465
446
|
const { name: name5 } = callee.property;
|
|
466
|
-
if (!
|
|
447
|
+
if (!AST11.ITERATOR_FUNCTION_INDEX_PARAM_POSITION.has(name5)) {
|
|
467
448
|
return _;
|
|
468
449
|
}
|
|
469
450
|
const callbackArg = node.arguments[isUsingReactChildren(context, node) ? 1 : 0];
|
|
@@ -474,7 +455,7 @@ function getMapIndexParamName(context, node) {
|
|
|
474
455
|
return _;
|
|
475
456
|
}
|
|
476
457
|
const { params } = callbackArg;
|
|
477
|
-
const indexParamPosition =
|
|
458
|
+
const indexParamPosition = AST11.ITERATOR_FUNCTION_INDEX_PARAM_POSITION.get(name5);
|
|
478
459
|
if (indexParamPosition == null) {
|
|
479
460
|
return _;
|
|
480
461
|
}
|
|
@@ -1332,7 +1313,7 @@ function create25(context) {
|
|
|
1332
1313
|
break;
|
|
1333
1314
|
}
|
|
1334
1315
|
default: {
|
|
1335
|
-
const call = AST11.findParentNode(jsxElement, AST11.
|
|
1316
|
+
const call = AST11.findParentNode(jsxElement, AST11.isArrayMapCallLoose);
|
|
1336
1317
|
const iter = AST11.findParentNode(jsxElement, (n) => n === call || AST11.isFunction(n));
|
|
1337
1318
|
if (!AST11.isFunction(iter)) return;
|
|
1338
1319
|
const arg0 = call?.arguments[0];
|
|
@@ -1869,7 +1850,7 @@ function create31(context) {
|
|
|
1869
1850
|
if (state.isWithinChildrenToArray) {
|
|
1870
1851
|
return;
|
|
1871
1852
|
}
|
|
1872
|
-
const isMapCall = AST11.
|
|
1853
|
+
const isMapCall = AST11.isArrayMapCallLoose(node);
|
|
1873
1854
|
if (!isMapCall && !isArrayFromCall(node)) {
|
|
1874
1855
|
return;
|
|
1875
1856
|
}
|
|
@@ -1924,7 +1905,7 @@ var no_nested_component_definitions_default = createRule({
|
|
|
1924
1905
|
defaultOptions: []
|
|
1925
1906
|
});
|
|
1926
1907
|
function create32(context) {
|
|
1927
|
-
const hint = ERComponentHint.
|
|
1908
|
+
const hint = ERComponentHint.SkipArrayMapArgument | ERComponentHint.SkipNullLiteral | ERComponentHint.SkipUndefined | ERComponentHint.SkipBooleanLiteral | ERComponentHint.SkipStringLiteral | ERComponentHint.SkipNumberLiteral | ERComponentHint.StrictLogical | ERComponentHint.StrictConditional;
|
|
1928
1909
|
const collector = useComponentCollector(context, { hint });
|
|
1929
1910
|
const collectorLegacy = useComponentCollectorLegacy();
|
|
1930
1911
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "1.38.0
|
|
3
|
+
"version": "1.38.0",
|
|
4
4
|
"description": "A set of composable linting rules for libraries and frameworks that use React as a UI runtime.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -42,21 +42,21 @@
|
|
|
42
42
|
"./package.json"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@typescript-eslint/scope-manager": "^8.
|
|
46
|
-
"@typescript-eslint/type-utils": "^8.
|
|
47
|
-
"@typescript-eslint/types": "^8.
|
|
48
|
-
"@typescript-eslint/utils": "^8.
|
|
45
|
+
"@typescript-eslint/scope-manager": "^8.28.0",
|
|
46
|
+
"@typescript-eslint/type-utils": "^8.28.0",
|
|
47
|
+
"@typescript-eslint/types": "^8.28.0",
|
|
48
|
+
"@typescript-eslint/utils": "^8.28.0",
|
|
49
49
|
"compare-versions": "^6.1.1",
|
|
50
50
|
"is-immutable-type": "^5.0.1",
|
|
51
51
|
"string-ts": "^2.2.1",
|
|
52
52
|
"ts-pattern": "^5.6.2",
|
|
53
|
-
"@eslint-react/ast": "1.38.0
|
|
54
|
-
"@eslint-react/eff": "1.38.0
|
|
55
|
-
"@eslint-react/
|
|
56
|
-
"@eslint-react/
|
|
57
|
-
"@eslint-react/
|
|
58
|
-
"@eslint-react/
|
|
59
|
-
"@eslint-react/
|
|
53
|
+
"@eslint-react/ast": "1.38.0",
|
|
54
|
+
"@eslint-react/eff": "1.38.0",
|
|
55
|
+
"@eslint-react/core": "1.38.0",
|
|
56
|
+
"@eslint-react/jsx": "1.38.0",
|
|
57
|
+
"@eslint-react/kit": "1.38.0",
|
|
58
|
+
"@eslint-react/var": "1.38.0",
|
|
59
|
+
"@eslint-react/shared": "1.38.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/react": "^19.0.12",
|