@jupyter/eslint-plugin 1.0.1 → 1.1.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/lib/index.d.ts +68 -0
- package/lib/index.js +42 -11
- package/lib/rules/galata-prefer-filebrowser-helper.d.ts +5 -0
- package/lib/rules/galata-prefer-filebrowser-helper.js +105 -0
- package/lib/rules/incorrect-translator-usage.d.ts +4 -0
- package/lib/rules/incorrect-translator-usage.js +208 -0
- package/lib/rules/no-dynamic-translation.d.ts +4 -0
- package/lib/rules/no-dynamic-translation.js +92 -0
- package/lib/rules/no-pageconfig-base-url.d.ts +4 -0
- package/lib/rules/no-pageconfig-base-url.js +37 -0
- package/lib/rules/no-translation-concatenation.js +46 -84
- package/lib/rules/no-untranslated-string.js +7 -4
- package/lib/rules/plugin-activation-args.js +1 -2
- package/lib/rules/prefer-signal-this-arg.d.ts +7 -0
- package/lib/rules/prefer-signal-this-arg.js +196 -0
- package/lib/rules/require-disposable-ownership.d.ts +5 -0
- package/lib/rules/require-disposable-ownership.js +120 -0
- package/lib/rules/require-disposable-transfer.d.ts +5 -0
- package/lib/rules/require-disposable-transfer.js +223 -0
- package/lib/rules/require-signal-cleanup.d.ts +8 -0
- package/lib/rules/require-signal-cleanup.js +164 -0
- package/lib/rules/require-signal-this-arg.d.ts +5 -0
- package/lib/rules/require-signal-this-arg.js +74 -0
- package/lib/rules/token-format.js +1 -2
- package/lib/utils/disposables.d.ts +64 -0
- package/lib/utils/disposables.js +1723 -0
- package/lib/utils/playwright-selectors.d.ts +66 -0
- package/lib/utils/playwright-selectors.js +193 -0
- package/lib/utils/signal-lifetime.d.ts +158 -0
- package/lib/utils/signal-lifetime.js +755 -0
- package/lib/utils/signals.d.ts +143 -0
- package/lib/utils/signals.js +601 -0
- package/lib/utils/translation.d.ts +45 -0
- package/lib/utils/translation.js +122 -0
- package/package.json +9 -2
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { TSESTree } from '@typescript-eslint/types';
|
|
2
|
+
import { ParserServices } from '@typescript-eslint/utils';
|
|
3
|
+
import * as ts from 'typescript';
|
|
4
|
+
export type ClassLike = TSESTree.ClassDeclaration | TSESTree.ClassExpression;
|
|
5
|
+
export type SignalClassification = 'signal' | 'not-signal' | 'unknown';
|
|
6
|
+
type ConnectCallExpression = TSESTree.CallExpression & {
|
|
7
|
+
callee: TSESTree.MemberExpression;
|
|
8
|
+
};
|
|
9
|
+
export type WalkAction = 'skip-children' | 'stop' | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Iterative AST walk from `root`, visiting every node. The visitor may return
|
|
12
|
+
* 'skip-children' to avoid descending into a node, or 'stop' to abort the
|
|
13
|
+
* whole walk.
|
|
14
|
+
*/
|
|
15
|
+
export declare function walkFrom(root: TSESTree.Node, visit: (node: TSESTree.Node) => WalkAction): void;
|
|
16
|
+
/**
|
|
17
|
+
* Checks if a node represents `<expr>.connect(...)`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isConnectCall(node: TSESTree.CallExpression): node is ConnectCallExpression;
|
|
20
|
+
/**
|
|
21
|
+
* Checks if a node represents `<expr>.disconnect(...)` or a call to one of
|
|
22
|
+
* the additional cleanup method names.
|
|
23
|
+
*/
|
|
24
|
+
export declare function isDisconnectCall(node: TSESTree.CallExpression, extraMethodNames?: readonly string[]): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Checks if a node represents `<expr>.disposed.connect(...)` — disposal
|
|
27
|
+
* cleanup wired through a `disposed`-style signal.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isDisposedSignalWiring(node: TSESTree.CallExpression): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Collects the names under which the Lumino `Signal` namespace is reachable in
|
|
32
|
+
* this file. Always includes 'Signal' (ambient/global usage), plus local
|
|
33
|
+
* aliases from `import { Signal as X } from '@lumino/signaling'` and the
|
|
34
|
+
* qualified `ns.Signal` form of `import * as ns from '@lumino/signaling'`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function collectSignalNamespaceLocalNames(program: TSESTree.Program): Set<string>;
|
|
37
|
+
/**
|
|
38
|
+
* Checks if a node represents `Signal.clearData(...)` or one of the other
|
|
39
|
+
* static disconnect helpers on the `Signal` namespace (under any local name).
|
|
40
|
+
*/
|
|
41
|
+
export declare function isSignalNamespaceCleanupCall(node: TSESTree.CallExpression, signalLocalNames: ReadonlySet<string>): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Returns the innermost class enclosing `node`, or null if the node is not
|
|
44
|
+
* inside a class body.
|
|
45
|
+
*/
|
|
46
|
+
export declare function getEnclosingClass(node: TSESTree.Node): ClassLike | null;
|
|
47
|
+
export type ThisBinding = 'instance' | 'constructor' | 'none';
|
|
48
|
+
/**
|
|
49
|
+
* What does `this` denote at `node`?
|
|
50
|
+
*
|
|
51
|
+
* - `'instance'`: an instance of the enclosing class.
|
|
52
|
+
* - `'constructor'`: the class object itself — `static` members and static
|
|
53
|
+
* blocks.
|
|
54
|
+
* - `'none'`: neither, because `this` is rebound on the way up: a nested
|
|
55
|
+
* regular function, an object-literal method, or module scope. Whatever
|
|
56
|
+
* `this` is there, it is not decided by the enclosing class.
|
|
57
|
+
*
|
|
58
|
+
* Arrow functions are transparent. Regular functions are not, unless they are
|
|
59
|
+
* the value of a class member — that is the method itself, not a nested one.
|
|
60
|
+
*/
|
|
61
|
+
export declare function getThisBinding(node: TSESTree.Node): ThisBinding;
|
|
62
|
+
/**
|
|
63
|
+
* Finds the class member named `name` in the class body, matching privacy
|
|
64
|
+
* (`this.#name` vs `this.name`) and staticness. Names are compared without
|
|
65
|
+
* the `#` prefix.
|
|
66
|
+
*/
|
|
67
|
+
export declare function resolveClassMember(classNode: ClassLike, name: string, opts: {
|
|
68
|
+
isPrivate: boolean;
|
|
69
|
+
isStatic: boolean;
|
|
70
|
+
}): TSESTree.MethodDefinition | TSESTree.PropertyDefinition | null;
|
|
71
|
+
export interface UnboundThisMethodConnect {
|
|
72
|
+
/** The `this.X` callback argument node. */
|
|
73
|
+
arg: TSESTree.MemberExpression;
|
|
74
|
+
/** Member name, without the `#` prefix. */
|
|
75
|
+
name: string;
|
|
76
|
+
isPrivate: boolean;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Detects the "unbound method" connect shape: a single-argument
|
|
80
|
+
* `signal.connect(this.X)` where `X` resolves in the enclosing class to a
|
|
81
|
+
* regular method (or function-expression property) whose body actually uses
|
|
82
|
+
* `this` — the case where the callback breaks at runtime without a thisArg.
|
|
83
|
+
* Returns null for every other callback shape (arrow properties, methods not
|
|
84
|
+
* using `this`, unresolved members, inline callbacks, free variables, ...).
|
|
85
|
+
*
|
|
86
|
+
* Shared by `require-signal-this-arg` (reports exactly this case) and
|
|
87
|
+
* `prefer-signal-this-arg` (reports everything but this case), so the two
|
|
88
|
+
* rules always partition cleanly.
|
|
89
|
+
*/
|
|
90
|
+
export declare function resolveUnboundThisMethodConnect(node: TSESTree.CallExpression): UnboundThisMethodConnect | null;
|
|
91
|
+
/**
|
|
92
|
+
* Scans an entire class body for any evidence that signal connections are
|
|
93
|
+
* cleaned up somewhere: `Signal.clearData(...)`-style static cleanup calls or
|
|
94
|
+
* `.disconnect(...)` calls (or configured additional cleanup methods). Nested
|
|
95
|
+
* classes are opaque — their cleanup does not count for the outer class.
|
|
96
|
+
*/
|
|
97
|
+
export declare function classHasCleanupEvidence(classNode: ClassLike, signalLocalNames: ReadonlySet<string>, extraMethodNames?: readonly string[]): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Scans a class body for cleanup calls that match connections **by
|
|
100
|
+
* receiver**: `Signal.clearData(this)` / `Signal.disconnectReceiver(this)` /
|
|
101
|
+
* `Signal.disconnectAll(this)` / `Signal.disconnectBetween(sender, this)`
|
|
102
|
+
* (under any local `Signal` alias), or a two-argument
|
|
103
|
+
* `.disconnect(callback, this)` call. A class using these relies on its
|
|
104
|
+
* connections having been registered with `this` as the thisArg. Nested
|
|
105
|
+
* classes are opaque.
|
|
106
|
+
*/
|
|
107
|
+
export declare function classUsesReceiverBasedCleanup(classNode: ClassLike, signalLocalNames: ReadonlySet<string>): boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Type-aware check: does this class (transitively) extend Lumino's `Widget`
|
|
110
|
+
* (any class declared in `@lumino/widgets`)? Those base classes call
|
|
111
|
+
* `Signal.clearData(this)` from `dispose()`, so subclasses rely on
|
|
112
|
+
* receiver-based cleanup. Returns false when type information is
|
|
113
|
+
* unavailable or resolution fails.
|
|
114
|
+
*/
|
|
115
|
+
export declare function classExtendsLuminoWidget(classNode: ClassLike, checker: ts.TypeChecker | null, services: ParserServices | null): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Type-aware check: does `type` (transitively) extend a class declared in
|
|
118
|
+
* `@lumino/widgets`? Used both for "does the receiver class inherit
|
|
119
|
+
* `Widget.dispose()`'s `Signal.clearData(this)`" and for rejecting widget-typed
|
|
120
|
+
* hops when walking a sender expression (a widget reached through a long-lived
|
|
121
|
+
* service is not itself long-lived).
|
|
122
|
+
*/
|
|
123
|
+
export declare function typeExtendsLuminoWidget(type: ts.Type, checker: ts.TypeChecker): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Checks whether a function body references `this` in its own binding.
|
|
126
|
+
* Descends into arrow functions (lexically transparent) but not into nested
|
|
127
|
+
* regular functions, static blocks, or nested classes (own `this` binding).
|
|
128
|
+
*/
|
|
129
|
+
export declare function methodUsesThis(fn: TSESTree.FunctionExpression): boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Syntactic hint that an expression is likely a Lumino signal, based on
|
|
132
|
+
* conventional signal naming (`stateChanged`, `disposed`, `somethingSignal`).
|
|
133
|
+
*/
|
|
134
|
+
export declare function looksLikeSignalByName(objectNode: TSESTree.Expression): boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Classifies the static type of a `.connect()` receiver expression:
|
|
137
|
+
* - 'signal': resolves to Lumino `ISignal`/`Signal` (by symbol name or a
|
|
138
|
+
* declaration living in `@lumino/signaling`)
|
|
139
|
+
* - 'not-signal': resolves to some other concrete type
|
|
140
|
+
* - 'unknown': no type information, `any`/`unknown`, or resolution failure
|
|
141
|
+
*/
|
|
142
|
+
export declare function classifySignalReceiver(objectNode: TSESTree.Expression, checker: ts.TypeChecker | null, services: ParserServices | null): SignalClassification;
|
|
143
|
+
export {};
|