@eslint-react/jsx 1.5.7 → 1.5.8-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/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +57 -54
- package/dist/index.mjs +57 -54
- package/package.json +9 -9
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
|
|
1
2
|
import { RuleContext } from '@eslint-react/types';
|
|
2
3
|
import { TSESTree } from '@typescript-eslint/types';
|
|
3
4
|
import { TSESTreeFunction } from '@eslint-react/ast';
|
|
@@ -5,10 +6,9 @@ import { Scope } from '@typescript-eslint/scope-manager';
|
|
|
5
6
|
import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
|
|
6
7
|
import { Option } from 'effect';
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
declare const isCreateElement: _;
|
|
9
|
+
declare const isCreateElement: (node: TSESTree.Identifier | TSESTree.MemberExpression, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
|
|
10
10
|
declare const isCreateElementCall: (node: TSESTree.CallExpression, context: RuleContext) => boolean;
|
|
11
|
-
declare const isCloneElement:
|
|
11
|
+
declare const isCloneElement: (node: TSESTree.Identifier | TSESTree.MemberExpression, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
|
|
12
12
|
declare const isCloneElementCall: (node: TSESTree.CallExpression, context: RuleContext) => boolean;
|
|
13
13
|
|
|
14
14
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
|
|
1
2
|
import { RuleContext } from '@eslint-react/types';
|
|
2
3
|
import { TSESTree } from '@typescript-eslint/types';
|
|
3
4
|
import { TSESTreeFunction } from '@eslint-react/ast';
|
|
@@ -5,10 +6,9 @@ import { Scope } from '@typescript-eslint/scope-manager';
|
|
|
5
6
|
import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
|
|
6
7
|
import { Option } from 'effect';
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
declare const isCreateElement: _;
|
|
9
|
+
declare const isCreateElement: (node: TSESTree.Identifier | TSESTree.MemberExpression, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
|
|
10
10
|
declare const isCreateElementCall: (node: TSESTree.CallExpression, context: RuleContext) => boolean;
|
|
11
|
-
declare const isCloneElement:
|
|
11
|
+
declare const isCloneElement: (node: TSESTree.Identifier | TSESTree.MemberExpression, context: Readonly<_typescript_eslint_utils_ts_eslint.RuleContext<string, readonly unknown[]>>) => boolean;
|
|
12
12
|
declare const isCloneElementCall: (node: TSESTree.CallExpression, context: RuleContext) => boolean;
|
|
13
13
|
|
|
14
14
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1159,60 +1159,60 @@ var getPragmaFromContext = memo__default.default(
|
|
|
1159
1159
|
}
|
|
1160
1160
|
);
|
|
1161
1161
|
|
|
1162
|
-
// ../../../node_modules/.pnpm/ts-pattern@5.0
|
|
1162
|
+
// ../../../node_modules/.pnpm/ts-pattern@5.1.0/node_modules/ts-pattern/dist/index.js
|
|
1163
1163
|
var t = Symbol.for("@ts-pattern/matcher");
|
|
1164
1164
|
var e = Symbol.for("@ts-pattern/isVariadic");
|
|
1165
1165
|
var n = "@ts-pattern/anonymous-select-key";
|
|
1166
1166
|
var r = (t2) => Boolean(t2 && "object" == typeof t2);
|
|
1167
1167
|
var i = (e2) => e2 && !!e2[t];
|
|
1168
|
-
var
|
|
1168
|
+
var o = (n2, s2, c2) => {
|
|
1169
1169
|
if (i(n2)) {
|
|
1170
|
-
const e2 = n2[t](), { matched: r2, selections: i2 } = e2.match(
|
|
1170
|
+
const e2 = n2[t](), { matched: r2, selections: i2 } = e2.match(s2);
|
|
1171
1171
|
return r2 && i2 && Object.keys(i2).forEach((t2) => c2(t2, i2[t2])), r2;
|
|
1172
1172
|
}
|
|
1173
1173
|
if (r(n2)) {
|
|
1174
|
-
if (!r(
|
|
1174
|
+
if (!r(s2))
|
|
1175
1175
|
return false;
|
|
1176
1176
|
if (Array.isArray(n2)) {
|
|
1177
|
-
if (!Array.isArray(
|
|
1177
|
+
if (!Array.isArray(s2))
|
|
1178
1178
|
return false;
|
|
1179
1179
|
let t2 = [], r2 = [], a2 = [];
|
|
1180
|
-
for (const
|
|
1181
|
-
const
|
|
1182
|
-
i(
|
|
1180
|
+
for (const o2 of n2.keys()) {
|
|
1181
|
+
const s3 = n2[o2];
|
|
1182
|
+
i(s3) && s3[e] ? a2.push(s3) : a2.length ? r2.push(s3) : t2.push(s3);
|
|
1183
1183
|
}
|
|
1184
1184
|
if (a2.length) {
|
|
1185
1185
|
if (a2.length > 1)
|
|
1186
1186
|
throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");
|
|
1187
|
-
if (
|
|
1187
|
+
if (s2.length < t2.length + r2.length)
|
|
1188
1188
|
return false;
|
|
1189
|
-
const e2 =
|
|
1190
|
-
return t2.every((t3, n4) =>
|
|
1189
|
+
const e2 = s2.slice(0, t2.length), n3 = 0 === r2.length ? [] : s2.slice(-r2.length), i2 = s2.slice(t2.length, 0 === r2.length ? Infinity : -r2.length);
|
|
1190
|
+
return t2.every((t3, n4) => o(t3, e2[n4], c2)) && r2.every((t3, e3) => o(t3, n3[e3], c2)) && (0 === a2.length || o(a2[0], i2, c2));
|
|
1191
1191
|
}
|
|
1192
|
-
return n2.length ===
|
|
1192
|
+
return n2.length === s2.length && n2.every((t3, e2) => o(t3, s2[e2], c2));
|
|
1193
1193
|
}
|
|
1194
1194
|
return Object.keys(n2).every((e2) => {
|
|
1195
1195
|
const r2 = n2[e2];
|
|
1196
|
-
return (e2 in
|
|
1196
|
+
return (e2 in s2 || i(a2 = r2) && "optional" === a2[t]().matcherType) && o(r2, s2[e2], c2);
|
|
1197
1197
|
var a2;
|
|
1198
1198
|
});
|
|
1199
1199
|
}
|
|
1200
|
-
return Object.is(
|
|
1200
|
+
return Object.is(s2, n2);
|
|
1201
1201
|
};
|
|
1202
|
-
var
|
|
1203
|
-
var n2,
|
|
1204
|
-
return r(e2) ? i(e2) ? null != (n2 = null == (
|
|
1202
|
+
var s = (e2) => {
|
|
1203
|
+
var n2, o2, a2;
|
|
1204
|
+
return r(e2) ? i(e2) ? null != (n2 = null == (o2 = (a2 = e2[t]()).getSelectionKeys) ? void 0 : o2.call(a2)) ? n2 : [] : Array.isArray(e2) ? c(e2, s) : c(Object.values(e2), s) : [];
|
|
1205
1205
|
};
|
|
1206
1206
|
var c = (t2, e2) => t2.reduce((t3, n2) => t3.concat(e2(n2)), []);
|
|
1207
1207
|
function a(...t2) {
|
|
1208
1208
|
if (1 === t2.length) {
|
|
1209
1209
|
const [e2] = t2;
|
|
1210
|
-
return (t3) =>
|
|
1210
|
+
return (t3) => o(e2, t3, () => {
|
|
1211
1211
|
});
|
|
1212
1212
|
}
|
|
1213
1213
|
if (2 === t2.length) {
|
|
1214
1214
|
const [e2, n2] = t2;
|
|
1215
|
-
return
|
|
1215
|
+
return o(e2, n2, () => {
|
|
1216
1216
|
});
|
|
1217
1217
|
}
|
|
1218
1218
|
throw new Error(`isMatching wasn't given the right number of arguments: expected 1 or 2, received ${t2.length}.`);
|
|
@@ -1236,8 +1236,8 @@ function l(e2) {
|
|
|
1236
1236
|
const r2 = (t3, e3) => {
|
|
1237
1237
|
n2[t3] = e3;
|
|
1238
1238
|
};
|
|
1239
|
-
return void 0 === t2 ? (
|
|
1240
|
-
}, getSelectionKeys: () =>
|
|
1239
|
+
return void 0 === t2 ? (s(e2).forEach((t3) => r2(t3, void 0)), { matched: true, selections: n2 }) : { matched: o(e2, t2, r2), selections: n2 };
|
|
1240
|
+
}, getSelectionKeys: () => s(e2), matcherType: "optional" }) });
|
|
1241
1241
|
}
|
|
1242
1242
|
var f = (t2, e2) => {
|
|
1243
1243
|
for (const n2 of t2)
|
|
@@ -1257,8 +1257,8 @@ function m(...e2) {
|
|
|
1257
1257
|
const r2 = (t3, e3) => {
|
|
1258
1258
|
n2[t3] = e3;
|
|
1259
1259
|
};
|
|
1260
|
-
return { matched: e2.every((e3) =>
|
|
1261
|
-
}, getSelectionKeys: () => c(e2,
|
|
1260
|
+
return { matched: e2.every((e3) => o(e3, t2, r2)), selections: n2 };
|
|
1261
|
+
}, getSelectionKeys: () => c(e2, s), matcherType: "and" }) });
|
|
1262
1262
|
}
|
|
1263
1263
|
function d(...e2) {
|
|
1264
1264
|
return u({ [t]: () => ({ match: (t2) => {
|
|
@@ -1266,8 +1266,8 @@ function d(...e2) {
|
|
|
1266
1266
|
const r2 = (t3, e3) => {
|
|
1267
1267
|
n2[t3] = e3;
|
|
1268
1268
|
};
|
|
1269
|
-
return c(e2,
|
|
1270
|
-
}, getSelectionKeys: () => c(e2,
|
|
1269
|
+
return c(e2, s).forEach((t3) => r2(t3, void 0)), { matched: e2.some((e3) => o(e3, t2, r2)), selections: n2 };
|
|
1270
|
+
}, getSelectionKeys: () => c(e2, s), matcherType: "or" }) });
|
|
1271
1271
|
}
|
|
1272
1272
|
function y(e2) {
|
|
1273
1273
|
return { [t]: () => ({ match: (t2) => ({ matched: Boolean(e2(t2)) }) }) };
|
|
@@ -1276,10 +1276,10 @@ function p(...e2) {
|
|
|
1276
1276
|
const r2 = "string" == typeof e2[0] ? e2[0] : void 0, i2 = 2 === e2.length ? e2[1] : "string" == typeof e2[0] ? void 0 : e2[0];
|
|
1277
1277
|
return u({ [t]: () => ({ match: (t2) => {
|
|
1278
1278
|
let e3 = { [null != r2 ? r2 : n]: t2 };
|
|
1279
|
-
return { matched: void 0 === i2 ||
|
|
1279
|
+
return { matched: void 0 === i2 || o(i2, t2, (t3, n2) => {
|
|
1280
1280
|
e3[t3] = n2;
|
|
1281
1281
|
}), selections: e3 };
|
|
1282
|
-
}, getSelectionKeys: () => [null != r2 ? r2 : n].concat(void 0 === i2 ? [] :
|
|
1282
|
+
}, getSelectionKeys: () => [null != r2 ? r2 : n].concat(void 0 === i2 ? [] : s(i2)) }) });
|
|
1283
1283
|
}
|
|
1284
1284
|
function v(t2) {
|
|
1285
1285
|
return "number" == typeof t2;
|
|
@@ -1321,7 +1321,10 @@ var k = u(y(function(t2) {
|
|
|
1321
1321
|
var B = u(y(function(t2) {
|
|
1322
1322
|
return null == t2;
|
|
1323
1323
|
}));
|
|
1324
|
-
var _ =
|
|
1324
|
+
var _ = u(y(function(t2) {
|
|
1325
|
+
return null != t2;
|
|
1326
|
+
}));
|
|
1327
|
+
var N = { __proto__: null, matcher: t, optional: l, array: function(...e2) {
|
|
1325
1328
|
return h({ [t]: () => ({ match: (t2) => {
|
|
1326
1329
|
if (!Array.isArray(t2))
|
|
1327
1330
|
return { matched: false };
|
|
@@ -1330,14 +1333,14 @@ var _ = { __proto__: null, matcher: t, optional: l, array: function(...e2) {
|
|
|
1330
1333
|
const n2 = e2[0];
|
|
1331
1334
|
let r2 = {};
|
|
1332
1335
|
if (0 === t2.length)
|
|
1333
|
-
return
|
|
1336
|
+
return s(n2).forEach((t3) => {
|
|
1334
1337
|
r2[t3] = [];
|
|
1335
1338
|
}), { matched: true, selections: r2 };
|
|
1336
1339
|
const i2 = (t3, e3) => {
|
|
1337
1340
|
r2[t3] = (r2[t3] || []).concat([e3]);
|
|
1338
1341
|
};
|
|
1339
|
-
return { matched: t2.every((t3) =>
|
|
1340
|
-
}, getSelectionKeys: () => 0 === e2.length ? [] :
|
|
1342
|
+
return { matched: t2.every((t3) => o(n2, t3, i2)), selections: r2 };
|
|
1343
|
+
}, getSelectionKeys: () => 0 === e2.length ? [] : s(e2[0]) }) });
|
|
1341
1344
|
}, set: function(...e2) {
|
|
1342
1345
|
return u({ [t]: () => ({ match: (t2) => {
|
|
1343
1346
|
if (!(t2 instanceof Set))
|
|
@@ -1350,8 +1353,8 @@ var _ = { __proto__: null, matcher: t, optional: l, array: function(...e2) {
|
|
|
1350
1353
|
const r2 = (t3, e3) => {
|
|
1351
1354
|
n2[t3] = (n2[t3] || []).concat([e3]);
|
|
1352
1355
|
}, i2 = e2[0];
|
|
1353
|
-
return { matched: f(t2, (t3) =>
|
|
1354
|
-
}, getSelectionKeys: () => 0 === e2.length ? [] :
|
|
1356
|
+
return { matched: f(t2, (t3) => o(i2, t3, r2)), selections: n2 };
|
|
1357
|
+
}, getSelectionKeys: () => 0 === e2.length ? [] : s(e2[0]) }) });
|
|
1355
1358
|
}, map: function(...e2) {
|
|
1356
1359
|
return u({ [t]: () => ({ match: (t2) => {
|
|
1357
1360
|
if (!(t2 instanceof Map))
|
|
@@ -1367,16 +1370,16 @@ var _ = { __proto__: null, matcher: t, optional: l, array: function(...e2) {
|
|
|
1367
1370
|
var i2;
|
|
1368
1371
|
if (1 === e2.length)
|
|
1369
1372
|
throw new Error(`\`P.map\` wasn't given enough arguments. Expected (key, value), received ${null == (i2 = e2[0]) ? void 0 : i2.toString()}`);
|
|
1370
|
-
const [
|
|
1373
|
+
const [s2, c2] = e2;
|
|
1371
1374
|
return { matched: g(t2, (t3, e3) => {
|
|
1372
|
-
const n3 =
|
|
1375
|
+
const n3 = o(s2, e3, r2), i3 = o(c2, t3, r2);
|
|
1373
1376
|
return n3 && i3;
|
|
1374
1377
|
}), selections: n2 };
|
|
1375
|
-
}, getSelectionKeys: () => 0 === e2.length ? [] : [...
|
|
1378
|
+
}, getSelectionKeys: () => 0 === e2.length ? [] : [...s(e2[0]), ...s(e2[1])] }) });
|
|
1376
1379
|
}, intersection: m, union: d, not: function(e2) {
|
|
1377
|
-
return u({ [t]: () => ({ match: (t2) => ({ matched: !
|
|
1380
|
+
return u({ [t]: () => ({ match: (t2) => ({ matched: !o(e2, t2, () => {
|
|
1378
1381
|
}) }), getSelectionKeys: () => [], matcherType: "not" }) });
|
|
1379
|
-
}, when: y, select: p, any: S, _: O, string: E, number: x, bigint: P, boolean: T, symbol: k, nullish: B, instanceOf: function(t2) {
|
|
1382
|
+
}, when: y, select: p, any: S, _: O, string: E, number: x, bigint: P, boolean: T, symbol: k, nullish: B, nonNullable: _, instanceOf: function(t2) {
|
|
1380
1383
|
return u(y(/* @__PURE__ */ function(t3) {
|
|
1381
1384
|
return (e2) => e2 instanceof t3;
|
|
1382
1385
|
}(t2)));
|
|
@@ -1384,10 +1387,10 @@ var _ = { __proto__: null, matcher: t, optional: l, array: function(...e2) {
|
|
|
1384
1387
|
return u(y(a(t2)));
|
|
1385
1388
|
} };
|
|
1386
1389
|
var W = { matched: false, value: void 0 };
|
|
1387
|
-
function
|
|
1388
|
-
return new
|
|
1390
|
+
function $(t2) {
|
|
1391
|
+
return new z(t2, W);
|
|
1389
1392
|
}
|
|
1390
|
-
var
|
|
1393
|
+
var z = class _z {
|
|
1391
1394
|
constructor(t2, e2) {
|
|
1392
1395
|
this.input = void 0, this.state = void 0, this.input = t2, this.state = e2;
|
|
1393
1396
|
}
|
|
@@ -1397,17 +1400,17 @@ var $ = class _$ {
|
|
|
1397
1400
|
const e2 = t2[t2.length - 1], r2 = [t2[0]];
|
|
1398
1401
|
let i2;
|
|
1399
1402
|
3 === t2.length && "function" == typeof t2[1] ? i2 = t2[1] : t2.length > 2 && r2.push(...t2.slice(1, t2.length - 1));
|
|
1400
|
-
let
|
|
1403
|
+
let s2 = false, c2 = {};
|
|
1401
1404
|
const a2 = (t3, e3) => {
|
|
1402
|
-
|
|
1403
|
-
}, u2 = !r2.some((t3) =>
|
|
1404
|
-
return new
|
|
1405
|
+
s2 = true, c2[t3] = e3;
|
|
1406
|
+
}, u2 = !r2.some((t3) => o(t3, this.input, a2)) || i2 && !Boolean(i2(this.input)) ? W : { matched: true, value: e2(s2 ? n in c2 ? c2[n] : c2 : this.input, this.input) };
|
|
1407
|
+
return new _z(this.input, u2);
|
|
1405
1408
|
}
|
|
1406
1409
|
when(t2, e2) {
|
|
1407
1410
|
if (this.state.matched)
|
|
1408
1411
|
return this;
|
|
1409
1412
|
const n2 = Boolean(t2(this.input));
|
|
1410
|
-
return new
|
|
1413
|
+
return new _z(this.input, n2 ? { matched: true, value: e2(this.input, this.input) } : W);
|
|
1411
1414
|
}
|
|
1412
1415
|
otherwise(t2) {
|
|
1413
1416
|
return this.state.matched ? this.state.value : t2(this.input);
|
|
@@ -1445,7 +1448,7 @@ function isInitializedFromPragma(variableName, context, initialScope, pragma = g
|
|
|
1445
1448
|
return true;
|
|
1446
1449
|
if (a({ type: "Identifier", name: pragma }, init))
|
|
1447
1450
|
return true;
|
|
1448
|
-
const maybeRequireExpression =
|
|
1451
|
+
const maybeRequireExpression = $(init).with({
|
|
1449
1452
|
type: ast.NodeType.CallExpression,
|
|
1450
1453
|
callee: { type: ast.NodeType.Identifier, name: "require" }
|
|
1451
1454
|
}, (exp) => Option_exports.some(exp)).with(
|
|
@@ -1618,8 +1621,8 @@ var DEFAULT_JSX_VALUE_HINT = JSXValueHint.SkipUndefinedLiteral | JSXValueHint.Sk
|
|
|
1618
1621
|
function isJSXValue(node, context, hint = DEFAULT_JSX_VALUE_HINT) {
|
|
1619
1622
|
if (!node)
|
|
1620
1623
|
return false;
|
|
1621
|
-
return
|
|
1622
|
-
return
|
|
1624
|
+
return $(node).with({ type: ast.NodeType.JSXElement }, Function_exports.constTrue).with({ type: ast.NodeType.JSXFragment }, Function_exports.constTrue).with({ type: ast.NodeType.JSXMemberExpression }, Function_exports.constTrue).with({ type: ast.NodeType.JSXNamespacedName }, Function_exports.constTrue).with({ type: ast.NodeType.Literal }, (node2) => {
|
|
1625
|
+
return $(node2.value).with(null, () => !(hint & JSXValueHint.SkipNullLiteral)).with(N.boolean, () => !(hint & JSXValueHint.SkipBooleanLiteral)).with(N.string, () => !(hint & JSXValueHint.SkipStringLiteral)).with(N.number, () => !(hint & JSXValueHint.SkipNumberLiteral)).otherwise(Function_exports.constFalse);
|
|
1623
1626
|
}).with({ type: ast.NodeType.TemplateLiteral }, () => !(hint & JSXValueHint.SkipStringLiteral)).with({ type: ast.NodeType.ArrayExpression }, (node2) => {
|
|
1624
1627
|
if (hint & JSXValueHint.StrictArray)
|
|
1625
1628
|
return node2.elements.every((n2) => isJSXValue(n2, context, hint));
|
|
@@ -1676,7 +1679,7 @@ function isFunctionReturningJSXValue(node, context, hint = DEFAULT_JSX_VALUE_HIN
|
|
|
1676
1679
|
}
|
|
1677
1680
|
var { getStaticValue } = ast.ESLintCommunityESLintUtils;
|
|
1678
1681
|
function getPropName(node) {
|
|
1679
|
-
return
|
|
1682
|
+
return $(node.name).when(ast.is(ast.NodeType.JSXIdentifier), (n2) => n2.name).when(ast.is(ast.NodeType.JSXNamespacedName), (n2) => `${n2.namespace.name}:${n2.name.name}`).exhaustive();
|
|
1680
1683
|
}
|
|
1681
1684
|
function getProp(props, propName, context, initialScope) {
|
|
1682
1685
|
return findPropInAttributes(props, context, initialScope)(propName);
|
|
@@ -1700,10 +1703,10 @@ function findPropInProperties(properties, context, initialScope, seenProps = [])
|
|
|
1700
1703
|
return (propName) => {
|
|
1701
1704
|
return Option_exports.fromNullable(
|
|
1702
1705
|
properties.find((prop) => {
|
|
1703
|
-
return
|
|
1706
|
+
return $(prop).when(ast.is(ast.NodeType.Property), (prop2) => {
|
|
1704
1707
|
return "name" in prop2.key && prop2.key.name === propName;
|
|
1705
1708
|
}).when(ast.is(ast.NodeType.SpreadElement), (prop2) => {
|
|
1706
|
-
return
|
|
1709
|
+
return $(prop2.argument).when(ast.is(ast.NodeType.Identifier), (argument) => {
|
|
1707
1710
|
const { name } = argument;
|
|
1708
1711
|
const maybeInit = Option_exports.flatMap(
|
|
1709
1712
|
_var.findVariable(name, initialScope),
|
|
@@ -1735,8 +1738,8 @@ function findPropInAttributes(attributes, context, initialScope) {
|
|
|
1735
1738
|
return (propName) => {
|
|
1736
1739
|
return Option_exports.fromNullable(
|
|
1737
1740
|
attributes.find((attr) => {
|
|
1738
|
-
return
|
|
1739
|
-
return
|
|
1741
|
+
return $(attr).when(ast.is(ast.NodeType.JSXAttribute), (attr2) => getPropName(attr2) === propName).when(ast.is(ast.NodeType.JSXSpreadAttribute), (attr2) => {
|
|
1742
|
+
return $(attr2.argument).with({ type: ast.NodeType.Identifier }, (argument) => {
|
|
1740
1743
|
const { name } = argument;
|
|
1741
1744
|
const maybeInit = Option_exports.flatMap(
|
|
1742
1745
|
_var.findVariable(name, initialScope),
|
package/dist/index.mjs
CHANGED
|
@@ -1153,60 +1153,60 @@ var getPragmaFromContext = memo(
|
|
|
1153
1153
|
}
|
|
1154
1154
|
);
|
|
1155
1155
|
|
|
1156
|
-
// ../../../node_modules/.pnpm/ts-pattern@5.0
|
|
1156
|
+
// ../../../node_modules/.pnpm/ts-pattern@5.1.0/node_modules/ts-pattern/dist/index.js
|
|
1157
1157
|
var t = Symbol.for("@ts-pattern/matcher");
|
|
1158
1158
|
var e = Symbol.for("@ts-pattern/isVariadic");
|
|
1159
1159
|
var n = "@ts-pattern/anonymous-select-key";
|
|
1160
1160
|
var r = (t2) => Boolean(t2 && "object" == typeof t2);
|
|
1161
1161
|
var i = (e2) => e2 && !!e2[t];
|
|
1162
|
-
var
|
|
1162
|
+
var o = (n2, s2, c2) => {
|
|
1163
1163
|
if (i(n2)) {
|
|
1164
|
-
const e2 = n2[t](), { matched: r2, selections: i2 } = e2.match(
|
|
1164
|
+
const e2 = n2[t](), { matched: r2, selections: i2 } = e2.match(s2);
|
|
1165
1165
|
return r2 && i2 && Object.keys(i2).forEach((t2) => c2(t2, i2[t2])), r2;
|
|
1166
1166
|
}
|
|
1167
1167
|
if (r(n2)) {
|
|
1168
|
-
if (!r(
|
|
1168
|
+
if (!r(s2))
|
|
1169
1169
|
return false;
|
|
1170
1170
|
if (Array.isArray(n2)) {
|
|
1171
|
-
if (!Array.isArray(
|
|
1171
|
+
if (!Array.isArray(s2))
|
|
1172
1172
|
return false;
|
|
1173
1173
|
let t2 = [], r2 = [], a2 = [];
|
|
1174
|
-
for (const
|
|
1175
|
-
const
|
|
1176
|
-
i(
|
|
1174
|
+
for (const o2 of n2.keys()) {
|
|
1175
|
+
const s3 = n2[o2];
|
|
1176
|
+
i(s3) && s3[e] ? a2.push(s3) : a2.length ? r2.push(s3) : t2.push(s3);
|
|
1177
1177
|
}
|
|
1178
1178
|
if (a2.length) {
|
|
1179
1179
|
if (a2.length > 1)
|
|
1180
1180
|
throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");
|
|
1181
|
-
if (
|
|
1181
|
+
if (s2.length < t2.length + r2.length)
|
|
1182
1182
|
return false;
|
|
1183
|
-
const e2 =
|
|
1184
|
-
return t2.every((t3, n4) =>
|
|
1183
|
+
const e2 = s2.slice(0, t2.length), n3 = 0 === r2.length ? [] : s2.slice(-r2.length), i2 = s2.slice(t2.length, 0 === r2.length ? Infinity : -r2.length);
|
|
1184
|
+
return t2.every((t3, n4) => o(t3, e2[n4], c2)) && r2.every((t3, e3) => o(t3, n3[e3], c2)) && (0 === a2.length || o(a2[0], i2, c2));
|
|
1185
1185
|
}
|
|
1186
|
-
return n2.length ===
|
|
1186
|
+
return n2.length === s2.length && n2.every((t3, e2) => o(t3, s2[e2], c2));
|
|
1187
1187
|
}
|
|
1188
1188
|
return Object.keys(n2).every((e2) => {
|
|
1189
1189
|
const r2 = n2[e2];
|
|
1190
|
-
return (e2 in
|
|
1190
|
+
return (e2 in s2 || i(a2 = r2) && "optional" === a2[t]().matcherType) && o(r2, s2[e2], c2);
|
|
1191
1191
|
var a2;
|
|
1192
1192
|
});
|
|
1193
1193
|
}
|
|
1194
|
-
return Object.is(
|
|
1194
|
+
return Object.is(s2, n2);
|
|
1195
1195
|
};
|
|
1196
|
-
var
|
|
1197
|
-
var n2,
|
|
1198
|
-
return r(e2) ? i(e2) ? null != (n2 = null == (
|
|
1196
|
+
var s = (e2) => {
|
|
1197
|
+
var n2, o2, a2;
|
|
1198
|
+
return r(e2) ? i(e2) ? null != (n2 = null == (o2 = (a2 = e2[t]()).getSelectionKeys) ? void 0 : o2.call(a2)) ? n2 : [] : Array.isArray(e2) ? c(e2, s) : c(Object.values(e2), s) : [];
|
|
1199
1199
|
};
|
|
1200
1200
|
var c = (t2, e2) => t2.reduce((t3, n2) => t3.concat(e2(n2)), []);
|
|
1201
1201
|
function a(...t2) {
|
|
1202
1202
|
if (1 === t2.length) {
|
|
1203
1203
|
const [e2] = t2;
|
|
1204
|
-
return (t3) =>
|
|
1204
|
+
return (t3) => o(e2, t3, () => {
|
|
1205
1205
|
});
|
|
1206
1206
|
}
|
|
1207
1207
|
if (2 === t2.length) {
|
|
1208
1208
|
const [e2, n2] = t2;
|
|
1209
|
-
return
|
|
1209
|
+
return o(e2, n2, () => {
|
|
1210
1210
|
});
|
|
1211
1211
|
}
|
|
1212
1212
|
throw new Error(`isMatching wasn't given the right number of arguments: expected 1 or 2, received ${t2.length}.`);
|
|
@@ -1230,8 +1230,8 @@ function l(e2) {
|
|
|
1230
1230
|
const r2 = (t3, e3) => {
|
|
1231
1231
|
n2[t3] = e3;
|
|
1232
1232
|
};
|
|
1233
|
-
return void 0 === t2 ? (
|
|
1234
|
-
}, getSelectionKeys: () =>
|
|
1233
|
+
return void 0 === t2 ? (s(e2).forEach((t3) => r2(t3, void 0)), { matched: true, selections: n2 }) : { matched: o(e2, t2, r2), selections: n2 };
|
|
1234
|
+
}, getSelectionKeys: () => s(e2), matcherType: "optional" }) });
|
|
1235
1235
|
}
|
|
1236
1236
|
var f = (t2, e2) => {
|
|
1237
1237
|
for (const n2 of t2)
|
|
@@ -1251,8 +1251,8 @@ function m(...e2) {
|
|
|
1251
1251
|
const r2 = (t3, e3) => {
|
|
1252
1252
|
n2[t3] = e3;
|
|
1253
1253
|
};
|
|
1254
|
-
return { matched: e2.every((e3) =>
|
|
1255
|
-
}, getSelectionKeys: () => c(e2,
|
|
1254
|
+
return { matched: e2.every((e3) => o(e3, t2, r2)), selections: n2 };
|
|
1255
|
+
}, getSelectionKeys: () => c(e2, s), matcherType: "and" }) });
|
|
1256
1256
|
}
|
|
1257
1257
|
function d(...e2) {
|
|
1258
1258
|
return u({ [t]: () => ({ match: (t2) => {
|
|
@@ -1260,8 +1260,8 @@ function d(...e2) {
|
|
|
1260
1260
|
const r2 = (t3, e3) => {
|
|
1261
1261
|
n2[t3] = e3;
|
|
1262
1262
|
};
|
|
1263
|
-
return c(e2,
|
|
1264
|
-
}, getSelectionKeys: () => c(e2,
|
|
1263
|
+
return c(e2, s).forEach((t3) => r2(t3, void 0)), { matched: e2.some((e3) => o(e3, t2, r2)), selections: n2 };
|
|
1264
|
+
}, getSelectionKeys: () => c(e2, s), matcherType: "or" }) });
|
|
1265
1265
|
}
|
|
1266
1266
|
function y(e2) {
|
|
1267
1267
|
return { [t]: () => ({ match: (t2) => ({ matched: Boolean(e2(t2)) }) }) };
|
|
@@ -1270,10 +1270,10 @@ function p(...e2) {
|
|
|
1270
1270
|
const r2 = "string" == typeof e2[0] ? e2[0] : void 0, i2 = 2 === e2.length ? e2[1] : "string" == typeof e2[0] ? void 0 : e2[0];
|
|
1271
1271
|
return u({ [t]: () => ({ match: (t2) => {
|
|
1272
1272
|
let e3 = { [null != r2 ? r2 : n]: t2 };
|
|
1273
|
-
return { matched: void 0 === i2 ||
|
|
1273
|
+
return { matched: void 0 === i2 || o(i2, t2, (t3, n2) => {
|
|
1274
1274
|
e3[t3] = n2;
|
|
1275
1275
|
}), selections: e3 };
|
|
1276
|
-
}, getSelectionKeys: () => [null != r2 ? r2 : n].concat(void 0 === i2 ? [] :
|
|
1276
|
+
}, getSelectionKeys: () => [null != r2 ? r2 : n].concat(void 0 === i2 ? [] : s(i2)) }) });
|
|
1277
1277
|
}
|
|
1278
1278
|
function v(t2) {
|
|
1279
1279
|
return "number" == typeof t2;
|
|
@@ -1315,7 +1315,10 @@ var k = u(y(function(t2) {
|
|
|
1315
1315
|
var B = u(y(function(t2) {
|
|
1316
1316
|
return null == t2;
|
|
1317
1317
|
}));
|
|
1318
|
-
var _ =
|
|
1318
|
+
var _ = u(y(function(t2) {
|
|
1319
|
+
return null != t2;
|
|
1320
|
+
}));
|
|
1321
|
+
var N = { __proto__: null, matcher: t, optional: l, array: function(...e2) {
|
|
1319
1322
|
return h({ [t]: () => ({ match: (t2) => {
|
|
1320
1323
|
if (!Array.isArray(t2))
|
|
1321
1324
|
return { matched: false };
|
|
@@ -1324,14 +1327,14 @@ var _ = { __proto__: null, matcher: t, optional: l, array: function(...e2) {
|
|
|
1324
1327
|
const n2 = e2[0];
|
|
1325
1328
|
let r2 = {};
|
|
1326
1329
|
if (0 === t2.length)
|
|
1327
|
-
return
|
|
1330
|
+
return s(n2).forEach((t3) => {
|
|
1328
1331
|
r2[t3] = [];
|
|
1329
1332
|
}), { matched: true, selections: r2 };
|
|
1330
1333
|
const i2 = (t3, e3) => {
|
|
1331
1334
|
r2[t3] = (r2[t3] || []).concat([e3]);
|
|
1332
1335
|
};
|
|
1333
|
-
return { matched: t2.every((t3) =>
|
|
1334
|
-
}, getSelectionKeys: () => 0 === e2.length ? [] :
|
|
1336
|
+
return { matched: t2.every((t3) => o(n2, t3, i2)), selections: r2 };
|
|
1337
|
+
}, getSelectionKeys: () => 0 === e2.length ? [] : s(e2[0]) }) });
|
|
1335
1338
|
}, set: function(...e2) {
|
|
1336
1339
|
return u({ [t]: () => ({ match: (t2) => {
|
|
1337
1340
|
if (!(t2 instanceof Set))
|
|
@@ -1344,8 +1347,8 @@ var _ = { __proto__: null, matcher: t, optional: l, array: function(...e2) {
|
|
|
1344
1347
|
const r2 = (t3, e3) => {
|
|
1345
1348
|
n2[t3] = (n2[t3] || []).concat([e3]);
|
|
1346
1349
|
}, i2 = e2[0];
|
|
1347
|
-
return { matched: f(t2, (t3) =>
|
|
1348
|
-
}, getSelectionKeys: () => 0 === e2.length ? [] :
|
|
1350
|
+
return { matched: f(t2, (t3) => o(i2, t3, r2)), selections: n2 };
|
|
1351
|
+
}, getSelectionKeys: () => 0 === e2.length ? [] : s(e2[0]) }) });
|
|
1349
1352
|
}, map: function(...e2) {
|
|
1350
1353
|
return u({ [t]: () => ({ match: (t2) => {
|
|
1351
1354
|
if (!(t2 instanceof Map))
|
|
@@ -1361,16 +1364,16 @@ var _ = { __proto__: null, matcher: t, optional: l, array: function(...e2) {
|
|
|
1361
1364
|
var i2;
|
|
1362
1365
|
if (1 === e2.length)
|
|
1363
1366
|
throw new Error(`\`P.map\` wasn't given enough arguments. Expected (key, value), received ${null == (i2 = e2[0]) ? void 0 : i2.toString()}`);
|
|
1364
|
-
const [
|
|
1367
|
+
const [s2, c2] = e2;
|
|
1365
1368
|
return { matched: g(t2, (t3, e3) => {
|
|
1366
|
-
const n3 =
|
|
1369
|
+
const n3 = o(s2, e3, r2), i3 = o(c2, t3, r2);
|
|
1367
1370
|
return n3 && i3;
|
|
1368
1371
|
}), selections: n2 };
|
|
1369
|
-
}, getSelectionKeys: () => 0 === e2.length ? [] : [...
|
|
1372
|
+
}, getSelectionKeys: () => 0 === e2.length ? [] : [...s(e2[0]), ...s(e2[1])] }) });
|
|
1370
1373
|
}, intersection: m, union: d, not: function(e2) {
|
|
1371
|
-
return u({ [t]: () => ({ match: (t2) => ({ matched: !
|
|
1374
|
+
return u({ [t]: () => ({ match: (t2) => ({ matched: !o(e2, t2, () => {
|
|
1372
1375
|
}) }), getSelectionKeys: () => [], matcherType: "not" }) });
|
|
1373
|
-
}, when: y, select: p, any: S, _: O, string: E, number: x, bigint: P, boolean: T, symbol: k, nullish: B, instanceOf: function(t2) {
|
|
1376
|
+
}, when: y, select: p, any: S, _: O, string: E, number: x, bigint: P, boolean: T, symbol: k, nullish: B, nonNullable: _, instanceOf: function(t2) {
|
|
1374
1377
|
return u(y(/* @__PURE__ */ function(t3) {
|
|
1375
1378
|
return (e2) => e2 instanceof t3;
|
|
1376
1379
|
}(t2)));
|
|
@@ -1378,10 +1381,10 @@ var _ = { __proto__: null, matcher: t, optional: l, array: function(...e2) {
|
|
|
1378
1381
|
return u(y(a(t2)));
|
|
1379
1382
|
} };
|
|
1380
1383
|
var W = { matched: false, value: void 0 };
|
|
1381
|
-
function
|
|
1382
|
-
return new
|
|
1384
|
+
function $(t2) {
|
|
1385
|
+
return new z(t2, W);
|
|
1383
1386
|
}
|
|
1384
|
-
var
|
|
1387
|
+
var z = class _z {
|
|
1385
1388
|
constructor(t2, e2) {
|
|
1386
1389
|
this.input = void 0, this.state = void 0, this.input = t2, this.state = e2;
|
|
1387
1390
|
}
|
|
@@ -1391,17 +1394,17 @@ var $ = class _$ {
|
|
|
1391
1394
|
const e2 = t2[t2.length - 1], r2 = [t2[0]];
|
|
1392
1395
|
let i2;
|
|
1393
1396
|
3 === t2.length && "function" == typeof t2[1] ? i2 = t2[1] : t2.length > 2 && r2.push(...t2.slice(1, t2.length - 1));
|
|
1394
|
-
let
|
|
1397
|
+
let s2 = false, c2 = {};
|
|
1395
1398
|
const a2 = (t3, e3) => {
|
|
1396
|
-
|
|
1397
|
-
}, u2 = !r2.some((t3) =>
|
|
1398
|
-
return new
|
|
1399
|
+
s2 = true, c2[t3] = e3;
|
|
1400
|
+
}, u2 = !r2.some((t3) => o(t3, this.input, a2)) || i2 && !Boolean(i2(this.input)) ? W : { matched: true, value: e2(s2 ? n in c2 ? c2[n] : c2 : this.input, this.input) };
|
|
1401
|
+
return new _z(this.input, u2);
|
|
1399
1402
|
}
|
|
1400
1403
|
when(t2, e2) {
|
|
1401
1404
|
if (this.state.matched)
|
|
1402
1405
|
return this;
|
|
1403
1406
|
const n2 = Boolean(t2(this.input));
|
|
1404
|
-
return new
|
|
1407
|
+
return new _z(this.input, n2 ? { matched: true, value: e2(this.input, this.input) } : W);
|
|
1405
1408
|
}
|
|
1406
1409
|
otherwise(t2) {
|
|
1407
1410
|
return this.state.matched ? this.state.value : t2(this.input);
|
|
@@ -1439,7 +1442,7 @@ function isInitializedFromPragma(variableName, context, initialScope, pragma = g
|
|
|
1439
1442
|
return true;
|
|
1440
1443
|
if (a({ type: "Identifier", name: pragma }, init))
|
|
1441
1444
|
return true;
|
|
1442
|
-
const maybeRequireExpression =
|
|
1445
|
+
const maybeRequireExpression = $(init).with({
|
|
1443
1446
|
type: NodeType.CallExpression,
|
|
1444
1447
|
callee: { type: NodeType.Identifier, name: "require" }
|
|
1445
1448
|
}, (exp) => Option_exports.some(exp)).with(
|
|
@@ -1612,8 +1615,8 @@ var DEFAULT_JSX_VALUE_HINT = JSXValueHint.SkipUndefinedLiteral | JSXValueHint.Sk
|
|
|
1612
1615
|
function isJSXValue(node, context, hint = DEFAULT_JSX_VALUE_HINT) {
|
|
1613
1616
|
if (!node)
|
|
1614
1617
|
return false;
|
|
1615
|
-
return
|
|
1616
|
-
return
|
|
1618
|
+
return $(node).with({ type: NodeType.JSXElement }, Function_exports.constTrue).with({ type: NodeType.JSXFragment }, Function_exports.constTrue).with({ type: NodeType.JSXMemberExpression }, Function_exports.constTrue).with({ type: NodeType.JSXNamespacedName }, Function_exports.constTrue).with({ type: NodeType.Literal }, (node2) => {
|
|
1619
|
+
return $(node2.value).with(null, () => !(hint & JSXValueHint.SkipNullLiteral)).with(N.boolean, () => !(hint & JSXValueHint.SkipBooleanLiteral)).with(N.string, () => !(hint & JSXValueHint.SkipStringLiteral)).with(N.number, () => !(hint & JSXValueHint.SkipNumberLiteral)).otherwise(Function_exports.constFalse);
|
|
1617
1620
|
}).with({ type: NodeType.TemplateLiteral }, () => !(hint & JSXValueHint.SkipStringLiteral)).with({ type: NodeType.ArrayExpression }, (node2) => {
|
|
1618
1621
|
if (hint & JSXValueHint.StrictArray)
|
|
1619
1622
|
return node2.elements.every((n2) => isJSXValue(n2, context, hint));
|
|
@@ -1670,7 +1673,7 @@ function isFunctionReturningJSXValue(node, context, hint = DEFAULT_JSX_VALUE_HIN
|
|
|
1670
1673
|
}
|
|
1671
1674
|
var { getStaticValue } = ESLintCommunityESLintUtils;
|
|
1672
1675
|
function getPropName(node) {
|
|
1673
|
-
return
|
|
1676
|
+
return $(node.name).when(is(NodeType.JSXIdentifier), (n2) => n2.name).when(is(NodeType.JSXNamespacedName), (n2) => `${n2.namespace.name}:${n2.name.name}`).exhaustive();
|
|
1674
1677
|
}
|
|
1675
1678
|
function getProp(props, propName, context, initialScope) {
|
|
1676
1679
|
return findPropInAttributes(props, context, initialScope)(propName);
|
|
@@ -1694,10 +1697,10 @@ function findPropInProperties(properties, context, initialScope, seenProps = [])
|
|
|
1694
1697
|
return (propName) => {
|
|
1695
1698
|
return Option_exports.fromNullable(
|
|
1696
1699
|
properties.find((prop) => {
|
|
1697
|
-
return
|
|
1700
|
+
return $(prop).when(is(NodeType.Property), (prop2) => {
|
|
1698
1701
|
return "name" in prop2.key && prop2.key.name === propName;
|
|
1699
1702
|
}).when(is(NodeType.SpreadElement), (prop2) => {
|
|
1700
|
-
return
|
|
1703
|
+
return $(prop2.argument).when(is(NodeType.Identifier), (argument) => {
|
|
1701
1704
|
const { name } = argument;
|
|
1702
1705
|
const maybeInit = Option_exports.flatMap(
|
|
1703
1706
|
findVariable(name, initialScope),
|
|
@@ -1729,8 +1732,8 @@ function findPropInAttributes(attributes, context, initialScope) {
|
|
|
1729
1732
|
return (propName) => {
|
|
1730
1733
|
return Option_exports.fromNullable(
|
|
1731
1734
|
attributes.find((attr) => {
|
|
1732
|
-
return
|
|
1733
|
-
return
|
|
1735
|
+
return $(attr).when(is(NodeType.JSXAttribute), (attr2) => getPropName(attr2) === propName).when(is(NodeType.JSXSpreadAttribute), (attr2) => {
|
|
1736
|
+
return $(attr2.argument).with({ type: NodeType.Identifier }, (argument) => {
|
|
1734
1737
|
const { name } = argument;
|
|
1735
1738
|
const maybeInit = Option_exports.flatMap(
|
|
1736
1739
|
findVariable(name, initialScope),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/jsx",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.8-next.1",
|
|
4
4
|
"description": "ESLint React's TSESTree AST utility module for static analysis of JSX.",
|
|
5
5
|
"homepage": "https://github.com/rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -35,15 +35,15 @@
|
|
|
35
35
|
"./package.json"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@typescript-eslint/scope-manager": "7.
|
|
39
|
-
"@typescript-eslint/types": "7.
|
|
40
|
-
"@typescript-eslint/utils": "7.
|
|
38
|
+
"@typescript-eslint/scope-manager": "7.5.0",
|
|
39
|
+
"@typescript-eslint/types": "7.5.0",
|
|
40
|
+
"@typescript-eslint/utils": "7.5.0",
|
|
41
41
|
"micro-memoize": "4.1.2",
|
|
42
|
-
"@eslint-react/ast": "1.5.
|
|
43
|
-
"@eslint-react/tools": "1.5.
|
|
44
|
-
"@eslint-react/
|
|
45
|
-
"@eslint-react/
|
|
46
|
-
"@eslint-react/var": "1.5.
|
|
42
|
+
"@eslint-react/ast": "1.5.8-next.1",
|
|
43
|
+
"@eslint-react/tools": "1.5.8-next.1",
|
|
44
|
+
"@eslint-react/types": "1.5.8-next.1",
|
|
45
|
+
"@eslint-react/shared": "1.5.8-next.1",
|
|
46
|
+
"@eslint-react/var": "1.5.8-next.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"effect": "2.4.15"
|