eslint-rule-forge 0.3.2 → 0.5.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/README.md +47 -40
- package/dist/bindings.d.mts +4 -5
- package/dist/bindings.d.mts.map +1 -1
- package/dist/bindings.mjs +0 -1
- package/dist/bindings.mjs.map +1 -1
- package/dist/comments.d.mts +10 -0
- package/dist/comments.d.mts.map +1 -0
- package/dist/comments.mjs +11 -0
- package/dist/comments.mjs.map +1 -0
- package/dist/imports.d.mts +68 -8
- package/dist/imports.d.mts.map +1 -1
- package/dist/imports.mjs +202 -6
- package/dist/imports.mjs.map +1 -1
- package/dist/index.d.mts +2 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -1
- package/dist/negation.d.mts +8 -9
- package/dist/negation.d.mts.map +1 -1
- package/dist/negation.mjs +18 -18
- package/dist/negation.mjs.map +1 -1
- package/dist/rules/prefer-array-is-array.d.mts.map +1 -1
- package/dist/rules/prefer-array-is-array.mjs +13 -19
- package/dist/rules/prefer-array-is-array.mjs.map +1 -1
- package/dist/rules/prefer-is-non-null-object.d.mts.map +1 -1
- package/dist/rules/prefer-is-non-null-object.mjs +75 -76
- package/dist/rules/prefer-is-non-null-object.mjs.map +1 -1
- package/dist/rules/prefer-is-record-and-has-key.d.mts.map +1 -1
- package/dist/rules/prefer-is-record-and-has-key.mjs +32 -44
- package/dist/rules/prefer-is-record-and-has-key.mjs.map +1 -1
- package/dist/rules/prefer-safe-parse.d.mts +10 -7
- package/dist/rules/prefer-safe-parse.d.mts.map +1 -1
- package/dist/rules/prefer-safe-parse.mjs +50 -34
- package/dist/rules/prefer-safe-parse.mjs.map +1 -1
- package/dist/statements.d.mts +12 -0
- package/dist/statements.d.mts.map +1 -0
- package/dist/statements.mjs +39 -0
- package/dist/statements.mjs.map +1 -0
- package/dist/type-wrappers.d.mts +3 -3
- package/package.json +5 -5
- package/src/bindings.mts +4 -5
- package/src/comments.mts +23 -0
- package/src/imports.mts +363 -19
- package/src/index.mts +2 -0
- package/src/negation.mts +36 -37
- package/src/rules/prefer-array-is-array.mts +23 -36
- package/src/rules/prefer-is-non-null-object.mts +107 -112
- package/src/rules/prefer-is-record-and-has-key.mts +47 -71
- package/src/rules/prefer-safe-parse.mts +92 -77
- package/src/statements.mts +57 -0
- package/src/type-wrappers.mts +3 -3
package/README.md
CHANGED
|
@@ -121,6 +121,12 @@ The range and the text of a node leave out the parentheses written around it.
|
|
|
121
121
|
| `getRangeWithParens` | the node's range including them |
|
|
122
122
|
| `getArgumentText` | the node's text for an argument list, `(a, b)` kept as one argument |
|
|
123
123
|
|
|
124
|
+
## Statements
|
|
125
|
+
|
|
126
|
+
| Helper | What it gives |
|
|
127
|
+
| :---------- | :------------------------------------------------------------------------------------------- |
|
|
128
|
+
| `siblingOf` | the statement after (`1`) or before (`-1`) a node in its statement list, through an `export` |
|
|
129
|
+
|
|
124
130
|
## Imports and bindings
|
|
125
131
|
|
|
126
132
|
| Helper | What it gives |
|
|
@@ -128,19 +134,24 @@ The range and the text of a node leave out the parentheses written around it.
|
|
|
128
134
|
| `getImportDeclarations` | every `import … from '<module>'` in the file, not only the first |
|
|
129
135
|
| `getNamedImports` | the export names those declarations import |
|
|
130
136
|
| `getImportedLocalName` | the local name an export is imported as (`'y'` for `import { x as y }`) |
|
|
137
|
+
| `importedNameOf` | the export name an import specifier imports (`'x'` for `import { x as y }`) |
|
|
131
138
|
| `buildCalleeResolver` | which export a callee calls, through aliases, namespace imports and type wrappers |
|
|
132
|
-
| `
|
|
139
|
+
| `bindValueImports` | the local names to write for exports, and the edits binding them as values (in the existing import) |
|
|
140
|
+
| `buildNamedImportFix` | a fix inserting a new `import { … } from '<module>';` after the directive prologue |
|
|
141
|
+
| `addTypeImports` | the edits importing types: into an `import type { … }`, else as `type X` into another import |
|
|
142
|
+
| `addToImportBraces` | a fix adding specifiers to a declaration's braces, empty ones included, or `undefined` without any |
|
|
133
143
|
| `hasForeignBinding` | whether a name, at a node, is bound to something other than the module's import (a fix must give up) |
|
|
134
144
|
| `isLocallyBound` | whether a name, at a node, is declared in the file rather than a global or a standard-library type |
|
|
145
|
+
| `hasCommentWithin` | whether a comment inside a node lies in ranges a fix would delete (the fix must give up) |
|
|
135
146
|
|
|
136
147
|
```ts
|
|
137
148
|
import type { TSESLint } from '@typescript-eslint/utils';
|
|
138
149
|
import {
|
|
150
|
+
bindValueImports,
|
|
139
151
|
buildCalleeResolver,
|
|
140
|
-
buildNamedImportFix,
|
|
141
152
|
getImportDeclarations,
|
|
142
|
-
getImportedLocalName,
|
|
143
153
|
hasForeignBinding,
|
|
154
|
+
type ValueImportBinding,
|
|
144
155
|
} from 'eslint-rule-forge';
|
|
145
156
|
|
|
146
157
|
const MODULE = 'my-lib';
|
|
@@ -156,9 +167,9 @@ export const preferIsNullish: TSESLint.RuleModule<'preferIsNullish'> = {
|
|
|
156
167
|
defaultOptions: [],
|
|
157
168
|
},
|
|
158
169
|
create: (context) => {
|
|
159
|
-
const
|
|
170
|
+
const sourceCode = context.sourceCode;
|
|
160
171
|
|
|
161
|
-
const declarations = getImportDeclarations(
|
|
172
|
+
const declarations = getImportDeclarations(sourceCode.ast, MODULE);
|
|
162
173
|
|
|
163
174
|
// `isNull(x)`, `n(x)` after `import { isNull as n }` and `lib.isNull(x)`
|
|
164
175
|
// after `import * as lib` all call `isNull`.
|
|
@@ -172,37 +183,33 @@ export const preferIsNullish: TSESLint.RuleModule<'preferIsNullish'> = {
|
|
|
172
183
|
return;
|
|
173
184
|
}
|
|
174
185
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
: (importedAs ?? 'isNullish');
|
|
186
|
+
// `lib.isNullish` needs no import. Otherwise `isNullish` is written by
|
|
187
|
+
// the name it is imported as, added to the existing named import, or
|
|
188
|
+
// has its `type` dropped; `undefined` when none of that can bind it.
|
|
189
|
+
const binding: ValueImportBinding | undefined =
|
|
190
|
+
resolved.isNamespace
|
|
191
|
+
? { localNames: ['isNullish'], edits: () => [] }
|
|
192
|
+
: bindValueImports(sourceCode, MODULE, ['isNullish']);
|
|
183
193
|
|
|
184
|
-
|
|
185
|
-
const canFix =
|
|
186
|
-
resolved.isNamespace ||
|
|
187
|
-
!hasForeignBinding(context.sourceCode, node, name, MODULE);
|
|
194
|
+
const name = binding?.localNames[0];
|
|
188
195
|
|
|
189
196
|
context.report({
|
|
190
197
|
node,
|
|
191
198
|
messageId: 'preferIsNullish',
|
|
192
|
-
fix:
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
199
|
+
fix:
|
|
200
|
+
binding === undefined ||
|
|
201
|
+
name === undefined ||
|
|
202
|
+
// A local `isNullish` that is not `my-lib`'s would capture the call.
|
|
203
|
+
(!resolved.isNamespace &&
|
|
204
|
+
hasForeignBinding(sourceCode, node, name, MODULE))
|
|
205
|
+
? null
|
|
206
|
+
: (fixer) => [
|
|
207
|
+
...binding.edits(fixer),
|
|
208
|
+
fixer.replaceText(
|
|
209
|
+
resolved.propertyNode,
|
|
210
|
+
name,
|
|
211
|
+
),
|
|
212
|
+
],
|
|
206
213
|
});
|
|
207
214
|
},
|
|
208
215
|
};
|
|
@@ -213,18 +220,18 @@ export const preferIsNullish: TSESLint.RuleModule<'preferIsNullish'> = {
|
|
|
213
220
|
## Rule factories
|
|
214
221
|
|
|
215
222
|
Rules that several plugins carry, differing only in the module whose functions
|
|
216
|
-
the fix writes. Each factory takes the module name (and the namespace the
|
|
223
|
+
the fix or suggestion writes. Each factory takes the module name (and the namespace the
|
|
217
224
|
function is reached through, where there is one) and returns a complete rule,
|
|
218
225
|
so that a fix to the rule reaches every plugin that builds it.
|
|
219
226
|
|
|
220
|
-
| Factory | The rule it builds
|
|
221
|
-
| :------------------------------ |
|
|
222
|
-
| `createPreferIsNonNullObject` | `typeof u === 'object' && u !== null` → `isNonNullObject(u)`
|
|
223
|
-
| `createPreferIsRecordAndHasKey` | `Object.hasOwn(obj, key)` and `key in obj` → `isRecord(obj) && hasKey(obj, key)`, or `hasKey` on a record
|
|
224
|
-
| `createPreferArrayIsArray` | `Array.isArray` → `<namespace>.isArray`
|
|
225
|
-
| `createPreferSafeParseInt` | `parseInt(x)`, `parseInt(x, 10)` → `Result.unwrapOkOr(<namespace>.<method>(x), Number.NaN)
|
|
226
|
-
| `createPreferSafeParseFloat` | `parseFloat(x)`, `Number.parseFloat(x)`, `Number(x)` → the same, for a `string` `x
|
|
227
|
-
| `createNoSideEffectImport` | removes `import '<module>';`, with the reason the caller gives
|
|
227
|
+
| Factory | The rule it builds |
|
|
228
|
+
| :------------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
229
|
+
| `createPreferIsNonNullObject` | `typeof u === 'object' && u !== null` → `isNonNullObject(u)` |
|
|
230
|
+
| `createPreferIsRecordAndHasKey` | `Object.hasOwn(obj, key)` and `key in obj` → `isRecord(obj) && hasKey(obj, key)`, or `hasKey` on a record |
|
|
231
|
+
| `createPreferArrayIsArray` | `Array.isArray` → `<namespace>.isArray` |
|
|
232
|
+
| `createPreferSafeParseInt` | `parseInt(x)`, `parseInt(x, 10)` → `Result.unwrapOkOr(<namespace>.<method>(x), Number.NaN)`, as a suggestion only, since some strings parse differently |
|
|
233
|
+
| `createPreferSafeParseFloat` | `parseFloat(x)`, `Number.parseFloat(x)`, `Number(x)` → the same, for a `string` `x`, also a suggestion only |
|
|
234
|
+
| `createNoSideEffectImport` | removes `import '<module>';`, with the reason the caller gives |
|
|
228
235
|
|
|
229
236
|
## License
|
|
230
237
|
|
package/dist/bindings.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type TSESLint, type TSESTree } from '@typescript-eslint/utils';
|
|
2
2
|
/**
|
|
3
|
-
* Whether `name`, read at `node`, resolves to something this file writes down
|
|
4
|
-
*
|
|
3
|
+
* Whether `name`, read at `node`, resolves to something this file writes down —
|
|
4
|
+
* a declaration, a parameter, an import — rather than to a global or a
|
|
5
5
|
* standard-library type of the same name.
|
|
6
6
|
*
|
|
7
7
|
* The scope manager makes an implicit variable for every reference it cannot
|
|
@@ -12,9 +12,8 @@ export declare const isLocallyBound: (sourceCode: TSESLint.SourceCode, node: TSE
|
|
|
12
12
|
/**
|
|
13
13
|
* Whether `name`, read at `node`, resolves to a binding that is not an import
|
|
14
14
|
* from `moduleName` — a declaration, a parameter, or an import from another
|
|
15
|
-
* module. A fix that makes code at `node` refer to `moduleName`'s export
|
|
16
|
-
*
|
|
17
|
-
* instead.
|
|
15
|
+
* module. A fix that makes code at `node` refer to `moduleName`'s export `name`
|
|
16
|
+
* has to give up then, because the name would refer to that binding instead.
|
|
18
17
|
*
|
|
19
18
|
* The innermost binding decides: an import from `moduleName` at the top of the
|
|
20
19
|
* file does not help a name a function shadows around `node`.
|
package/dist/bindings.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bindings.d.mts","sourceRoot":"","sources":["../src/bindings.mts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,QAAQ,EACb,KAAK,QAAQ,EACd,MAAM,0BAA0B,CAAC;AAIlC;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,eACb,QAAQ,CAAC,UAAU,QACzB,QAAQ,CAAC,IAAI,QACb,MAAM,KACX,OAIF,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"bindings.d.mts","sourceRoot":"","sources":["../src/bindings.mts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,QAAQ,EACb,KAAK,QAAQ,EACd,MAAM,0BAA0B,CAAC;AAIlC;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,eACb,QAAQ,CAAC,UAAU,QACzB,QAAQ,CAAC,IAAI,QACb,MAAM,KACX,OAIF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,eAChB,QAAQ,CAAC,UAAU,QACzB,QAAQ,CAAC,IAAI,QACb,MAAM,cACA,MAAM,KACjB,OAIF,CAAC"}
|
package/dist/bindings.mjs
CHANGED
|
@@ -22,7 +22,6 @@ export const isLocallyBound = (sourceCode, node, name) => {
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
|
|
26
25
|
export const hasForeignBinding = (sourceCode, node, name, moduleName) => {
|
|
27
26
|
const variable = ASTUtils.findVariable(sourceCode.getScope(node), name);
|
|
28
27
|
return variable?.defs.some((def) => !isImportFrom(def, moduleName)) ?? false;
|
package/dist/bindings.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bindings.mjs","sourceRoot":"","sources":["../src/bindings.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,QAAQ,GAGT,MAAM,0BAA0B,CAAC;AAElC,uEAAuE;AAEvE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,UAA+B,EAC/B,IAAmB,EACnB,IAAY,EACH,EAAE;IACX,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;IAExE,OAAO,QAAQ,KAAK,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;AACvD,CAAC,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"bindings.mjs","sourceRoot":"","sources":["../src/bindings.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,QAAQ,GAGT,MAAM,0BAA0B,CAAC;AAElC,uEAAuE;AAEvE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,UAA+B,EAC/B,IAAmB,EACnB,IAAY,EACH,EAAE;IACX,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;IAExE,OAAO,QAAQ,KAAK,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;AACvD,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,UAA+B,EAC/B,IAAmB,EACnB,IAAY,EACZ,UAAkB,EACT,EAAE;IACX,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;IAExE,OAAO,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,IAAI,KAAK,CAAC;AAC/E,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,YAAY,GAAG,CACnB,GAA8B,EAC9B,UAAkB,EACT,EAAE,CACX,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,cAAc,CAAC,eAAe;IAC/C,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,cAAc,CAAC,sBAAsB;IACvD,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,cAAc,CAAC,wBAAwB,CAAC;IAC5D,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,cAAc,CAAC,iBAAiB;IACzD,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,KAAK,UAAU,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TSESLint, TSESTree } from '@typescript-eslint/utils';
|
|
2
|
+
import type { DeepReadonly } from 'ts-type-forge';
|
|
3
|
+
/**
|
|
4
|
+
* Whether a comment inside `node` lies within one of `ranges`, which a fix
|
|
5
|
+
* would delete along with it. Such a fix is dropped instead of the comment.
|
|
6
|
+
* Only comments inside `node` are looked at, so each range has to lie within
|
|
7
|
+
* it.
|
|
8
|
+
*/
|
|
9
|
+
export declare const hasCommentWithin: (sourceCode: TSESLint.SourceCode, node: TSESTree.Node, ranges: DeepReadonly<TSESTree.Range[]>) => boolean;
|
|
10
|
+
//# sourceMappingURL=comments.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comments.d.mts","sourceRoot":"","sources":["../src/comments.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAIlD;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,eACf,QAAQ,CAAC,UAAU,QACzB,QAAQ,CAAC,IAAI,UACX,YAAY,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,KACrC,OAOE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export const hasCommentWithin = (sourceCode, node, ranges) => sourceCode
|
|
9
|
+
.getCommentsInside(node)
|
|
10
|
+
.some((comment) => ranges.some(([start, end]) => start <= comment.range[0] && comment.range[1] <= end));
|
|
11
|
+
//# sourceMappingURL=comments.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comments.mjs","sourceRoot":"","sources":["../src/comments.mts"],"names":[],"mappings":"AAGA,uEAAuE;AAEvE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,UAA+B,EAC/B,IAAmB,EACnB,MAAsC,EAC7B,EAAE,CACX,UAAU;KACP,iBAAiB,CAAC,IAAI,CAAC;KACvB,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAChB,MAAM,CAAC,IAAI,CACT,CAAC,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,CACvE,CACF,CAAC"}
|
package/dist/imports.d.mts
CHANGED
|
@@ -22,8 +22,8 @@ export type ResolvedCallee = Readonly<{
|
|
|
22
22
|
/** The exported name, whatever the callee calls it locally. */
|
|
23
23
|
canonicalName: string;
|
|
24
24
|
/**
|
|
25
|
-
* The identifier to rewrite to change what is called: the callee itself for
|
|
26
|
-
*
|
|
25
|
+
* The identifier to rewrite to change what is called: the callee itself for a
|
|
26
|
+
* named import, the property for a namespace import.
|
|
27
27
|
*/
|
|
28
28
|
propertyNode: TSESTree.Identifier;
|
|
29
29
|
/** Whether the call goes through a namespace import (`m.f(...)`). */
|
|
@@ -41,14 +41,74 @@ export type ResolvedCallee = Readonly<{
|
|
|
41
41
|
export declare const buildCalleeResolver: (declarations: DeepReadonly<TSESTree.ImportDeclaration[]>) => ((callee: TSESTree.Expression) => ResolvedCallee | undefined);
|
|
42
42
|
/**
|
|
43
43
|
* A fix that inserts `import { <specifiers> } from '<moduleName>';` at the top
|
|
44
|
-
* of the file,
|
|
44
|
+
* of the file, after its directive prologue (`'use client';` stays a
|
|
45
|
+
* directive), or no fix when `specifiers` is empty. Each specifier is written
|
|
45
46
|
* as given, so `type T` imports a type.
|
|
46
47
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
48
|
+
* Use it only when the file does not import from `moduleName` by name;
|
|
49
|
+
* {@link bindValueImports} adds to an existing declaration instead, which keeps
|
|
50
|
+
* `import-x/no-duplicates` satisfied, and falls back to this. An import sorter
|
|
51
|
+
* orders the declaration afterwards. Put every name one report needs into a
|
|
52
|
+
* single call: ESLint merges the fixes of one report into one edit, and two
|
|
53
|
+
* fixes inserting at the same place conflict, so that one of them is dropped.
|
|
52
54
|
*/
|
|
53
55
|
export declare const buildNamedImportFix: (fixer: TSESLint.RuleFixer, program: TSESTree.Program, moduleName: string, specifiers: readonly string[]) => readonly TSESLint.RuleFix[];
|
|
56
|
+
/**
|
|
57
|
+
* The local names `moduleName`'s exports `exportNames` are bound to as values
|
|
58
|
+
* once `edits` are made, in the same order, or `undefined` when one of them
|
|
59
|
+
* cannot be bound.
|
|
60
|
+
*
|
|
61
|
+
* - Imported as a value: that local name, and no edit.
|
|
62
|
+
* - Imported by `import { type x }`: the edit drops `type`, keeping a comment
|
|
63
|
+
* after it.
|
|
64
|
+
* - Not imported: the edit adds it to the braces of the first import from the
|
|
65
|
+
* module that has a value specifier, or else of the first other one with
|
|
66
|
+
* braces that is not `import type`, empty braces included (`import {}`,
|
|
67
|
+
* `import D, {}`).
|
|
68
|
+
* Adding it there rather than in a new declaration keeps
|
|
69
|
+
* `import-x/no-duplicates` satisfied. Failing that, it goes into new braces
|
|
70
|
+
* after a lone default import (`import D, { x }`), and when the module has
|
|
71
|
+
* neither, a new declaration goes after the directive prologue
|
|
72
|
+
* ({@link buildNamedImportFix}).
|
|
73
|
+
* - Refused when an import already binds the name to something else
|
|
74
|
+
* (`import type { x }`, `import { y as x }`, `import { x } from 'other'`),
|
|
75
|
+
* where adding it would be a duplicate binding.
|
|
76
|
+
*
|
|
77
|
+
* ESLint's default parser leaves `importKind` out, which counts as a value
|
|
78
|
+
* import. Every name a fix writes is bound by that fix's own edits rather than
|
|
79
|
+
* left to another report's: an editor applies one fix at a time, and a fix that
|
|
80
|
+
* loses a conflict with another in the same pass is dropped. Fixes that all add
|
|
81
|
+
* a name overlap, so `--fix` applies one per pass, and the rest in the next, by
|
|
82
|
+
* when the file imports it. Whether something other than an import binds the
|
|
83
|
+
* name where it is written is the caller's to check
|
|
84
|
+
* ({@link hasForeignBinding}).
|
|
85
|
+
*/
|
|
86
|
+
export declare const bindValueImports: (sourceCode: TSESLint.SourceCode, moduleName: string, exportNames: readonly string[]) => ValueImportBinding | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* The edits that import `moduleName`'s types `names` the file does not import
|
|
89
|
+
* yet: added to an existing `import type { … }` from the module (`, X`), else
|
|
90
|
+
* as `type X` to another import from it, chosen as {@link bindValueImports}
|
|
91
|
+
* chooses one, and only failing those as a new
|
|
92
|
+
* `import { type X } from '<module>'` after the directive prologue. Adding to
|
|
93
|
+
* an existing declaration keeps `import-x/no-duplicates` satisfied. Whether the
|
|
94
|
+
* file binds a name to something else is the caller's to check.
|
|
95
|
+
*/
|
|
96
|
+
export declare const addTypeImports: (fixer: TSESLint.RuleFixer, sourceCode: TSESLint.SourceCode, moduleName: string, names: readonly string[]) => readonly TSESLint.RuleFix[];
|
|
97
|
+
/**
|
|
98
|
+
* Adds `specifiers` to the `{ … }` of `declaration`: after its last named
|
|
99
|
+
* specifier, or inside empty braces (`import d, {} from …`). `undefined` when
|
|
100
|
+
* the declaration has no braces (a default or namespace import alone) or there
|
|
101
|
+
* is nothing to add. The braces of import attributes (`with { … }`) are not
|
|
102
|
+
* taken for them.
|
|
103
|
+
*/
|
|
104
|
+
export declare const addToImportBraces: (fixer: TSESLint.RuleFixer, sourceCode: TSESLint.SourceCode, declaration: TSESTree.ImportDeclaration, specifiers: readonly string[]) => TSESLint.RuleFix | undefined;
|
|
105
|
+
/** The exported name `specifier` imports: `x` for `import { x as y }`. */
|
|
106
|
+
export declare const importedNameOf: (specifier: DeepReadonly<TSESTree.ImportSpecifier>) => string;
|
|
107
|
+
/** What {@link bindValueImports} gives. */
|
|
108
|
+
export type ValueImportBinding = Readonly<{
|
|
109
|
+
/** The names to write, in the order of the export names asked for. */
|
|
110
|
+
localNames: readonly string[];
|
|
111
|
+
/** The edits that bring every one of them into scope. */
|
|
112
|
+
edits: (fixer: TSESLint.RuleFixer) => readonly TSESLint.RuleFix[];
|
|
113
|
+
}>;
|
|
54
114
|
//# sourceMappingURL=imports.d.mts.map
|
package/dist/imports.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imports.d.mts","sourceRoot":"","sources":["../src/imports.mts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,QAAQ,EACd,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAKlD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,YACvB,QAAQ,CAAC,OAAO,cACb,MAAM,KACjB,SAAS,QAAQ,CAAC,iBAAiB,EAKnC,CAAC;AAEJ;;;GAGG;AACH,eAAO,MAAM,eAAe,iBACZ,YAAY,CAAC,QAAQ,CAAC,iBAAiB,EAAE,CAAC,KACvD,SAAS,MAAM,EAOf,CAAC;AAEJ;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,iBACjB,YAAY,CAAC,QAAQ,CAAC,iBAAiB,EAAE,CAAC,gBAC1C,MAAM,KACnB,MAAM,GAAG,SAOK,CAAC;AAElB,uEAAuE;AACvE,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;IACpC,+DAA+D;IAC/D,aAAa,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,YAAY,EAAE,QAAQ,CAAC,UAAU,CAAC;IAElC,qEAAqE;IACrE,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,iBAChB,YAAY,CAAC,QAAQ,CAAC,iBAAiB,EAAE,CAAC,KACvD,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,KAAK,cAAc,GAAG,SAAS,CAuD9D,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"imports.d.mts","sourceRoot":"","sources":["../src/imports.mts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,QAAQ,EACd,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAA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,CAAC,UAAU,cACnB,MAAM,SACX,SAAS,MAAM,EAAE,KACvB,SAAS,QAAQ,CAAC,OAAO,EAqB3B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,UACrB,QAAQ,CAAC,SAAS,cACb,QAAQ,CAAC,UAAU,eAClB,QAAQ,CAAC,iBAAiB,cAC3B,SAAS,MAAM,EAAE,KAC5B,QAAQ,CAAC,OAAO,GAAG,SAwBrB,CAAC;AAEF,0EAA0E;AAC1E,eAAO,MAAM,cAAc,cACd,YAAY,CAAC,QAAQ,CAAC,eAAe,CAAC,KAChD,MAG2B,CAAC;AAoD/B,2CAA2C;AAC3C,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IACxC,sEAAsE;IACtE,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IAE9B,yDAAyD;IACzD,KAAK,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,SAAS,KAAK,SAAS,QAAQ,CAAC,OAAO,EAAE,CAAC;CACnE,CAAC,CAAC"}
|
package/dist/imports.mjs
CHANGED
|
@@ -79,12 +79,208 @@ export const buildCalleeResolver = (declarations) => {
|
|
|
79
79
|
|
|
80
80
|
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
export const buildNamedImportFix = (fixer, program, moduleName, specifiers) => {
|
|
85
|
+
if (specifiers.length === 0) {
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
88
|
+
const declaration = `import { ${specifiers.join(', ')} } from '${moduleName}';`;
|
|
89
|
+
const lastDirective = program.body
|
|
90
|
+
.filter((statement) => statement.type === AST_NODE_TYPES.ExpressionStatement &&
|
|
91
|
+
statement.directive !== undefined)
|
|
92
|
+
.at(-1);
|
|
93
|
+
if (lastDirective === undefined) {
|
|
94
|
+
return [fixer.insertTextBefore(program, `${declaration}\n`)];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
const anchor = (program.comments ?? [])
|
|
99
|
+
.filter((comment) => comment.range[0] >= lastDirective.range[1] &&
|
|
100
|
+
comment.loc.start.line === lastDirective.loc.end.line)
|
|
101
|
+
.at(-1) ?? lastDirective;
|
|
102
|
+
return [fixer.insertTextAfter(anchor, `\n${declaration}`)];
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
export const bindValueImports = (sourceCode, moduleName, exportNames) => {
|
|
135
|
+
const program = sourceCode.ast;
|
|
136
|
+
const allImports = program.body.filter((node) => node.type === AST_NODE_TYPES.ImportDeclaration);
|
|
137
|
+
const declarations = getImportDeclarations(program, moduleName);
|
|
138
|
+
const named = declarations.flatMap((declaration) => declaration.specifiers.flatMap((specifier) => specifier.type === AST_NODE_TYPES.ImportSpecifier
|
|
139
|
+
? [{ declaration, specifier }]
|
|
140
|
+
: []));
|
|
141
|
+
const bindings = exportNames.map((exportName) => bindingOf(sourceCode, allImports, named, exportName));
|
|
142
|
+
if (bindings.includes(undefined)) {
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
const defined = bindings.filter((b) => b !== undefined);
|
|
146
|
+
const toAdd = defined.flatMap((b) => (b.isAdded ? [b.localName] : []));
|
|
147
|
+
const hosts = hostsFor(declarations);
|
|
148
|
+
return {
|
|
149
|
+
localNames: defined.map((b) => b.localName),
|
|
150
|
+
edits: (fixer) => [
|
|
151
|
+
...defined.flatMap((b) => b.edits(fixer)),
|
|
152
|
+
...(toAdd.length === 0
|
|
153
|
+
? []
|
|
154
|
+
: addToFirstHost(fixer, sourceCode, moduleName, hosts, toAdd)),
|
|
155
|
+
],
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
export const addTypeImports = (fixer, sourceCode, moduleName, names) => {
|
|
168
|
+
if (names.length === 0) {
|
|
169
|
+
return [];
|
|
170
|
+
}
|
|
171
|
+
const declarations = getImportDeclarations(sourceCode.ast, moduleName);
|
|
172
|
+
const typeOnlyFix = firstFix(declarations.filter(isTypeOnlyDeclaration), (declaration) => addToImportBraces(fixer, sourceCode, declaration, names));
|
|
173
|
+
return typeOnlyFix !== undefined
|
|
174
|
+
? [typeOnlyFix]
|
|
175
|
+
: addToFirstHost(fixer, sourceCode, moduleName, hostsFor(declarations), names.map((name) => `type ${name}`));
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
export const addToImportBraces = (fixer, sourceCode, declaration, specifiers) => {
|
|
185
|
+
if (specifiers.length === 0) {
|
|
186
|
+
return undefined;
|
|
187
|
+
}
|
|
188
|
+
const lastNamed = declaration.specifiers
|
|
189
|
+
.filter((specifier) => specifier.type === AST_NODE_TYPES.ImportSpecifier)
|
|
190
|
+
.at(-1);
|
|
191
|
+
if (lastNamed !== undefined) {
|
|
192
|
+
return fixer.insertTextAfter(lastNamed, `, ${specifiers.join(', ')}`);
|
|
193
|
+
}
|
|
194
|
+
const openingBrace = sourceCode.getFirstToken(declaration, {
|
|
195
|
+
filter: (token) => token.value === '{' && token.range[1] <= declaration.source.range[0],
|
|
196
|
+
});
|
|
197
|
+
return openingBrace === null
|
|
198
|
+
? undefined
|
|
199
|
+
: fixer.insertTextAfter(openingBrace, ` ${specifiers.join(', ')} `);
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
export const importedNameOf = (specifier) => specifier.imported.type === AST_NODE_TYPES.Identifier
|
|
88
203
|
? specifier.imported.name
|
|
89
204
|
: specifier.imported.value;
|
|
205
|
+
|
|
206
|
+
const firstFix = (declarations, toFix) => {
|
|
207
|
+
for (const declaration of declarations) {
|
|
208
|
+
const fix = toFix(declaration);
|
|
209
|
+
if (fix !== undefined) {
|
|
210
|
+
return fix;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return undefined;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
const addToFirstHost = (fixer, sourceCode, moduleName, hosts, specifiers) => {
|
|
222
|
+
const intoBraces = firstFix(hosts, (declaration) => addToImportBraces(fixer, sourceCode, declaration, specifiers));
|
|
223
|
+
if (intoBraces !== undefined) {
|
|
224
|
+
return [intoBraces];
|
|
225
|
+
}
|
|
226
|
+
const defaultHost = hosts.find((declaration) => declaration.specifiers.length === 1 &&
|
|
227
|
+
declaration.specifiers[0]?.type === AST_NODE_TYPES.ImportDefaultSpecifier)?.specifiers[0];
|
|
228
|
+
return defaultHost !== undefined
|
|
229
|
+
? [fixer.insertTextAfter(defaultHost, `, { ${specifiers.join(', ')} }`)]
|
|
230
|
+
: buildNamedImportFix(fixer, sourceCode.ast, moduleName, specifiers);
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
const isTypeOnlyDeclaration = (declaration) => declaration.importKind === 'type';
|
|
234
|
+
|
|
235
|
+
const isNotTypeOnly = ({ declaration }) => !isTypeOnlyDeclaration(declaration);
|
|
236
|
+
|
|
237
|
+
const isValueImport = ({ declaration, specifier }) => isNotTypeOnly({ declaration, specifier }) && specifier.importKind !== 'type';
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
const hostsFor = (declarations) => {
|
|
245
|
+
const notTypeOnly = declarations.filter((declaration) => !isTypeOnlyDeclaration(declaration));
|
|
246
|
+
const hasValueSpecifier = (declaration) => declaration.specifiers.some((specifier) => specifier.type === AST_NODE_TYPES.ImportSpecifier &&
|
|
247
|
+
isValueImport({ declaration, specifier }));
|
|
248
|
+
return [
|
|
249
|
+
...notTypeOnly.filter(hasValueSpecifier),
|
|
250
|
+
...notTypeOnly.filter((declaration) => !hasValueSpecifier(declaration)),
|
|
251
|
+
];
|
|
252
|
+
};
|
|
253
|
+
const bindingOf = (sourceCode, allImports, named, exportName) => {
|
|
254
|
+
const matching = named.filter(({ specifier }) => importedNameOf(specifier) === exportName);
|
|
255
|
+
const value = matching.find(isValueImport);
|
|
256
|
+
if (value !== undefined) {
|
|
257
|
+
return {
|
|
258
|
+
localName: value.specifier.local.name,
|
|
259
|
+
isAdded: false,
|
|
260
|
+
edits: () => [],
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
const inlineType = matching.find(isNotTypeOnly)?.specifier;
|
|
264
|
+
if (inlineType !== undefined) {
|
|
265
|
+
const typeKeyword = sourceCode.getFirstToken(inlineType);
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
const next = typeKeyword === null
|
|
269
|
+
? null
|
|
270
|
+
: sourceCode.getTokenAfter(typeKeyword, { includeComments: true });
|
|
271
|
+
return typeKeyword === null || next === null
|
|
272
|
+
? undefined
|
|
273
|
+
: {
|
|
274
|
+
localName: inlineType.local.name,
|
|
275
|
+
isAdded: false,
|
|
276
|
+
edits: (fixer) => [
|
|
277
|
+
fixer.removeRange([typeKeyword.range[0], next.range[0]]),
|
|
278
|
+
],
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
const isTaken = allImports.some((declaration) => declaration.specifiers.some((specifier) => specifier.local.name === exportName));
|
|
282
|
+
return isTaken
|
|
283
|
+
? undefined
|
|
284
|
+
: { localName: exportName, isAdded: true, edits: () => [] };
|
|
285
|
+
};
|
|
90
286
|
//# sourceMappingURL=imports.mjs.map
|
package/dist/imports.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imports.mjs","sourceRoot":"","sources":["../src/imports.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,GAGf,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEtE,uEAAuE;AAEvE;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,OAAyB,EACzB,UAAkB,EACqB,EAAE,CACzC,OAAO,CAAC,IAAI,CAAC,MAAM,CACjB,CAAC,IAAI,EAAsC,EAAE,CAC3C,IAAI,CAAC,IAAI,KAAK,cAAc,CAAC,iBAAiB;IAC9C,IAAI,CAAC,MAAM,CAAC,KAAK,KAAK,UAAU,CACnC,CAAC;AAEJ;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,YAAwD,EACrC,EAAE,CACrB,YAAY,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,CACnC,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE,CAC3C,SAAS,CAAC,IAAI,KAAK,cAAc,CAAC,eAAe;IAC/C,CAAC,CAAC,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IAC7B,CAAC,CAAC,EAAE,CACP,CACF,CAAC;AAEJ;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,YAAwD,EACxD,YAAoB,EACA,EAAE,CACtB,YAAY;KACT,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,UAAU,CAAC;KAChD,IAAI,CACH,CAAC,SAAS,EAAE,EAAE,CACZ,SAAS,CAAC,IAAI,KAAK,cAAc,CAAC,eAAe;IACjD,cAAc,CAAC,SAAS,CAAC,KAAK,YAA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AAC;AAChE,CAAC,CAAC"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export * from './bindings.mjs';
|
|
2
|
+
export * from './comments.mjs';
|
|
2
3
|
export * from './imports.mjs';
|
|
3
4
|
export * from './negation.mjs';
|
|
4
5
|
export * from './parentheses.mjs';
|
|
5
6
|
export * from './rules/index.mjs';
|
|
7
|
+
export * from './statements.mjs';
|
|
6
8
|
export * from './type-wrappers.mjs';
|
|
7
9
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export * from './bindings.mjs';
|
|
2
|
+
export * from './comments.mjs';
|
|
2
3
|
export * from './imports.mjs';
|
|
3
4
|
export * from './negation.mjs';
|
|
4
5
|
export * from './parentheses.mjs';
|
|
5
6
|
export * from './rules/index.mjs';
|
|
7
|
+
export * from './statements.mjs';
|
|
6
8
|
export * from './type-wrappers.mjs';
|
|
7
9
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC"}
|
package/dist/negation.d.mts
CHANGED
|
@@ -59,10 +59,9 @@ export type NegationContext = Readonly<{
|
|
|
59
59
|
checker: ts.TypeChecker;
|
|
60
60
|
getLayerTypes: GetLayerTypes;
|
|
61
61
|
/**
|
|
62
|
-
* Whether `node`'s value is a boolean, so that the negation of `!node` may
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* node.
|
|
62
|
+
* Whether `node`'s value is a boolean, so that the negation of `!node` may be
|
|
63
|
+
* `node` itself. Where only the truthiness of the negation is read — the test
|
|
64
|
+
* of an `if` — any value will do, and this may answer `true` for every node.
|
|
66
65
|
*/
|
|
67
66
|
isBoolean: (node: DeepReadonly<TSESTree.Expression>) => boolean;
|
|
68
67
|
}>;
|
|
@@ -80,12 +79,12 @@ export type NegationContext = Readonly<{
|
|
|
80
79
|
* | anything else | `!a`, `!(a)` | always |
|
|
81
80
|
*
|
|
82
81
|
* `undefined` when the first two rows' condition does not hold: then the only
|
|
83
|
-
* exact negation is `!!a` or `!(a < b)`, and a caller decides whether to
|
|
84
|
-
*
|
|
85
|
-
*
|
|
82
|
+
* exact negation is `!!a` or `!(a < b)`, and a caller decides whether to write
|
|
83
|
+
* it (with {@link prefixedNegationOf}) or to give up. Inside `&&` and `||`, a
|
|
84
|
+
* side with no short negation is written with `!`.
|
|
86
85
|
*
|
|
87
|
-
* The node is taken as written: a comparison under a type wrapper is not
|
|
88
|
-
*
|
|
86
|
+
* The node is taken as written: a comparison under a type wrapper is not looked
|
|
87
|
+
* into, since inverting it would drop the wrapper.
|
|
89
88
|
*/
|
|
90
89
|
export declare const negationOf: (node: DeepReadonly<TSESTree.Expression>, context: NegationContext, operandOf: '&&' | '||' | undefined) => string | undefined;
|
|
91
90
|
/**
|