eslint-plugin-react-web-api 3.0.0-next.4 → 3.0.0-next.41
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 -19
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { DEFAULT_ESLINT_REACT_SETTINGS, WEBSITE_URL, getConfigAdapters } from "@eslint-react/shared";
|
|
1
|
+
import { DEFAULT_ESLINT_REACT_SETTINGS, WEBSITE_URL, defineRuleListener, getConfigAdapters } from "@eslint-react/shared";
|
|
2
2
|
import * as ast from "@eslint-react/ast";
|
|
3
3
|
import * as core from "@eslint-react/core";
|
|
4
4
|
import { dual, or, unit } from "@eslint-react/eff";
|
|
5
|
-
import { findEnclosingAssignmentTarget, findProperty, findVariable,
|
|
5
|
+
import { findEnclosingAssignmentTarget, findProperty, findVariable, getVariableInitializer, isAssignmentTargetEqual, isValueEqual } from "@eslint-react/var";
|
|
6
6
|
import { AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
|
|
7
7
|
import { getStaticValue } from "@typescript-eslint/utils/ast-utils";
|
|
8
8
|
import { P, isMatching, match } from "ts-pattern";
|
|
@@ -43,7 +43,7 @@ const settings = { "react-x": DEFAULT_ESLINT_REACT_SETTINGS };
|
|
|
43
43
|
//#endregion
|
|
44
44
|
//#region package.json
|
|
45
45
|
var name = "eslint-plugin-react-web-api";
|
|
46
|
-
var version = "3.0.0-next.
|
|
46
|
+
var version = "3.0.0-next.41";
|
|
47
47
|
|
|
48
48
|
//#endregion
|
|
49
49
|
//#region src/types/component-phase.ts
|
|
@@ -64,7 +64,7 @@ function getDocsUrl(ruleName) {
|
|
|
64
64
|
const createRule = ESLintUtils.RuleCreator(getDocsUrl);
|
|
65
65
|
|
|
66
66
|
//#endregion
|
|
67
|
-
//#region src/rules/no-leaked-event-listener.ts
|
|
67
|
+
//#region src/rules/no-leaked-event-listener/no-leaked-event-listener.ts
|
|
68
68
|
const RULE_NAME$3 = "no-leaked-event-listener";
|
|
69
69
|
const defaultOptions = {
|
|
70
70
|
capture: false,
|
|
@@ -83,7 +83,7 @@ function getFunctionKind$1(node) {
|
|
|
83
83
|
function getSignalValueExpression(node, initialScope) {
|
|
84
84
|
if (node == null) return unit;
|
|
85
85
|
switch (node.type) {
|
|
86
|
-
case AST_NODE_TYPES.Identifier: return getSignalValueExpression(
|
|
86
|
+
case AST_NODE_TYPES.Identifier: return getSignalValueExpression(getVariableInitializer(findVariable(node, initialScope), 0), initialScope);
|
|
87
87
|
case AST_NODE_TYPES.MemberExpression: return node;
|
|
88
88
|
default: return unit;
|
|
89
89
|
}
|
|
@@ -95,7 +95,7 @@ function getOptions(node, initialScope) {
|
|
|
95
95
|
function getOpts(node) {
|
|
96
96
|
switch (node.type) {
|
|
97
97
|
case AST_NODE_TYPES.Identifier: {
|
|
98
|
-
const variableNode =
|
|
98
|
+
const variableNode = getVariableInitializer(findVariable(node, initialScope), 0);
|
|
99
99
|
if (variableNode?.type === AST_NODE_TYPES.ObjectExpression) return getOpts(variableNode);
|
|
100
100
|
return defaultOptions;
|
|
101
101
|
}
|
|
@@ -154,7 +154,7 @@ function create$3(context) {
|
|
|
154
154
|
const { type: aType, callee: aCallee, capture: aCapture, listener: aListener, phase: aPhase } = aEntry;
|
|
155
155
|
const { type: rType, callee: rCallee, capture: rCapture, listener: rListener, phase: rPhase } = rEntry;
|
|
156
156
|
if (!isInversePhase(aPhase, rPhase)) return false;
|
|
157
|
-
return isSameObject(aCallee, rCallee) && ast.isNodeEqual(aListener, rListener) &&
|
|
157
|
+
return isSameObject(aCallee, rCallee) && ast.isNodeEqual(aListener, rListener) && isValueEqual(aType, rType, [context.sourceCode.getScope(aType), context.sourceCode.getScope(rType)]) && aCapture === rCapture;
|
|
158
158
|
}
|
|
159
159
|
function checkInlineFunction(node, callKind, options) {
|
|
160
160
|
const listener = node.arguments.at(1);
|
|
@@ -166,7 +166,7 @@ function create$3(context) {
|
|
|
166
166
|
data: { eventMethodKind: callKind }
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
|
-
return {
|
|
169
|
+
return defineRuleListener({
|
|
170
170
|
[":function"](node) {
|
|
171
171
|
const kind = getFunctionKind$1(node);
|
|
172
172
|
fEntries.push({
|
|
@@ -239,11 +239,11 @@ function create$3(context) {
|
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
|
-
};
|
|
242
|
+
});
|
|
243
243
|
}
|
|
244
244
|
|
|
245
245
|
//#endregion
|
|
246
|
-
//#region src/rules/no-leaked-interval.ts
|
|
246
|
+
//#region src/rules/no-leaked-interval/no-leaked-interval.ts
|
|
247
247
|
const RULE_NAME$2 = "no-leaked-interval";
|
|
248
248
|
function getCallKind$2(node) {
|
|
249
249
|
switch (true) {
|
|
@@ -275,7 +275,7 @@ function create$2(context) {
|
|
|
275
275
|
function isInverseEntry(a, b) {
|
|
276
276
|
return isAssignmentTargetEqual(context, a.timerId, b.timerId);
|
|
277
277
|
}
|
|
278
|
-
return {
|
|
278
|
+
return defineRuleListener({
|
|
279
279
|
[":function"](node) {
|
|
280
280
|
const kind = getPhaseKindOfFunction(node) ?? "other";
|
|
281
281
|
fEntries.push({
|
|
@@ -349,18 +349,18 @@ function create$2(context) {
|
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
|
-
};
|
|
352
|
+
});
|
|
353
353
|
}
|
|
354
354
|
|
|
355
355
|
//#endregion
|
|
356
|
-
//#region src/rules/no-leaked-resize-observer.ts
|
|
356
|
+
//#region src/rules/no-leaked-resize-observer/no-leaked-resize-observer.ts
|
|
357
357
|
const RULE_NAME$1 = "no-leaked-resize-observer";
|
|
358
358
|
function isNewResizeObserver(node) {
|
|
359
359
|
return node?.type === AST_NODE_TYPES.NewExpression && node.callee.type === AST_NODE_TYPES.Identifier && node.callee.name === "ResizeObserver";
|
|
360
360
|
}
|
|
361
361
|
function isFromObserver(context, node) {
|
|
362
362
|
switch (true) {
|
|
363
|
-
case node.type === AST_NODE_TYPES.Identifier: return isNewResizeObserver(
|
|
363
|
+
case node.type === AST_NODE_TYPES.Identifier: return isNewResizeObserver(getVariableInitializer(findVariable(node, context.sourceCode.getScope(node)), 0));
|
|
364
364
|
case node.type === AST_NODE_TYPES.MemberExpression: return isFromObserver(context, node.object);
|
|
365
365
|
default: return false;
|
|
366
366
|
}
|
|
@@ -397,7 +397,7 @@ function create$1(context) {
|
|
|
397
397
|
const oEntries = [];
|
|
398
398
|
const uEntries = [];
|
|
399
399
|
const dEntries = [];
|
|
400
|
-
return {
|
|
400
|
+
return defineRuleListener({
|
|
401
401
|
[":function"](node) {
|
|
402
402
|
const kind = getFunctionKind(node);
|
|
403
403
|
fEntries.push({
|
|
@@ -491,11 +491,11 @@ function create$1(context) {
|
|
|
491
491
|
}
|
|
492
492
|
}
|
|
493
493
|
}
|
|
494
|
-
};
|
|
494
|
+
});
|
|
495
495
|
}
|
|
496
496
|
|
|
497
497
|
//#endregion
|
|
498
|
-
//#region src/rules/no-leaked-timeout.ts
|
|
498
|
+
//#region src/rules/no-leaked-timeout/no-leaked-timeout.ts
|
|
499
499
|
const RULE_NAME = "no-leaked-timeout";
|
|
500
500
|
function getCallKind(node) {
|
|
501
501
|
switch (true) {
|
|
@@ -527,7 +527,7 @@ function create(context) {
|
|
|
527
527
|
function isInverseEntry(a, b) {
|
|
528
528
|
return isAssignmentTargetEqual(context, a.timerId, b.timerId);
|
|
529
529
|
}
|
|
530
|
-
return {
|
|
530
|
+
return defineRuleListener({
|
|
531
531
|
[":function"](node) {
|
|
532
532
|
const kind = getPhaseKindOfFunction(node) ?? "other";
|
|
533
533
|
fEntries.push({
|
|
@@ -597,7 +597,7 @@ function create(context) {
|
|
|
597
597
|
}
|
|
598
598
|
}
|
|
599
599
|
}
|
|
600
|
-
};
|
|
600
|
+
});
|
|
601
601
|
}
|
|
602
602
|
|
|
603
603
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-web-api",
|
|
3
|
-
"version": "3.0.0-next.
|
|
3
|
+
"version": "3.0.0-next.41",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for interacting with Web APIs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -38,16 +38,16 @@
|
|
|
38
38
|
"./package.json"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@typescript-eslint/scope-manager": "
|
|
42
|
-
"@typescript-eslint/types": "
|
|
43
|
-
"@typescript-eslint/utils": "
|
|
41
|
+
"@typescript-eslint/scope-manager": "canary",
|
|
42
|
+
"@typescript-eslint/types": "canary",
|
|
43
|
+
"@typescript-eslint/utils": "canary",
|
|
44
44
|
"birecord": "^0.1.1",
|
|
45
45
|
"ts-pattern": "^5.9.0",
|
|
46
|
-
"@eslint-react/ast": "3.0.0-next.
|
|
47
|
-
"@eslint-react/core": "3.0.0-next.
|
|
48
|
-
"@eslint-react/
|
|
49
|
-
"@eslint-react/
|
|
50
|
-
"@eslint-react/
|
|
46
|
+
"@eslint-react/ast": "3.0.0-next.41",
|
|
47
|
+
"@eslint-react/core": "3.0.0-next.41",
|
|
48
|
+
"@eslint-react/eff": "3.0.0-next.41",
|
|
49
|
+
"@eslint-react/var": "3.0.0-next.41",
|
|
50
|
+
"@eslint-react/shared": "3.0.0-next.41"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/react": "^19.2.14",
|
|
@@ -68,6 +68,6 @@
|
|
|
68
68
|
"scripts": {
|
|
69
69
|
"build": "tsdown",
|
|
70
70
|
"lint:publish": "publint",
|
|
71
|
-
"lint:ts": "
|
|
71
|
+
"lint:ts": "tsl"
|
|
72
72
|
}
|
|
73
73
|
}
|