@eslint-react/eslint 5.24.1 → 5.24.2
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 +0 -35
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,20 +1,6 @@
|
|
|
1
1
|
import * as ESLintUtils from "@typescript-eslint/utils/eslint-utils";
|
|
2
2
|
|
|
3
3
|
//#region src/get-constrained-type-at-location.ts
|
|
4
|
-
/**
|
|
5
|
-
* Resolves the given node's type. Will return the type's generic constraint, if it has one.
|
|
6
|
-
*
|
|
7
|
-
* Warning - if the type is generic and does _not_ have a constraint, the type will be
|
|
8
|
-
* returned as-is, rather than returning an `unknown` type. This can be checked
|
|
9
|
-
* for by checking for the type flag ts.TypeFlags.TypeParameter.
|
|
10
|
-
*
|
|
11
|
-
* Adapted from `getConstrainedTypeAtLocation` in `@typescript-eslint/type-utils`
|
|
12
|
-
* (MIT License, Copyright (c) 2019 typescript-eslint and other contributors,
|
|
13
|
-
* https://github.com/typescript-eslint/typescript-eslint) so that consumers don't
|
|
14
|
-
* need to load `@typescript-eslint/type-utils`, whose entry point eagerly loads
|
|
15
|
-
* the `eslint` package.
|
|
16
|
-
* @see https://github.com/typescript-eslint/typescript-eslint/issues/10438
|
|
17
|
-
*/
|
|
18
4
|
function getConstrainedTypeAtLocation(services, node) {
|
|
19
5
|
const nodeType = services.getTypeAtLocation(node);
|
|
20
6
|
return services.program.getTypeChecker().getBaseConstraintOfType(nodeType) ?? nodeType;
|
|
@@ -25,34 +11,13 @@ function getConstrainedTypeAtLocation(services, node) {
|
|
|
25
11
|
function getDocsUrl(ruleName) {
|
|
26
12
|
return `https://eslint-react.xyz/docs/rules/${ruleName}`;
|
|
27
13
|
}
|
|
28
|
-
/** The rule creator that generates documentation URLs for ESLint React rules. */
|
|
29
14
|
const createRule = ESLintUtils.RuleCreator(getDocsUrl);
|
|
30
|
-
/**
|
|
31
|
-
* Creates a report function for the given rule context.
|
|
32
|
-
* @param context The ESLint rule context.
|
|
33
|
-
* @returns A function that can be used to report violations.
|
|
34
|
-
*/
|
|
35
15
|
function report(context) {
|
|
36
16
|
return (desc) => {
|
|
37
17
|
if (desc == null) return;
|
|
38
18
|
context.report(desc);
|
|
39
19
|
};
|
|
40
20
|
}
|
|
41
|
-
/**
|
|
42
|
-
* Merge multiple visitor objects into a single visitor object.
|
|
43
|
-
*
|
|
44
|
-
* @param base The base visitor object (target of merge).
|
|
45
|
-
* @param rest The additional visitor objects to merge (one or more).
|
|
46
|
-
* @returns The merged visitor object.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```typescript
|
|
50
|
-
* const visitor1 = { Identifier: () => console.log(1) };
|
|
51
|
-
* const visitor2 = { Identifier: () => console.log(2) };
|
|
52
|
-
* const merged = merge(visitor1, visitor2);
|
|
53
|
-
* // When encountering Identifier nodes, outputs 1 then 2
|
|
54
|
-
* ```
|
|
55
|
-
*/
|
|
56
21
|
function merge(base, ...rest) {
|
|
57
22
|
for (const r of rest) for (const key in r) {
|
|
58
23
|
const existing = base[key];
|