@eslint-react/eslint 5.30.0-beta.6 → 5.30.0-beta.7
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.ts +27 -17
- package/dist/index.js +13 -6
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,9 @@
|
|
|
1
1
|
import * as ESLintUtils from "@typescript-eslint/utils/eslint-utils";
|
|
2
|
+
import * as tseslint from "@typescript-eslint/utils/ts-eslint";
|
|
3
|
+
import { ReportDescriptor, ReportFixFunction, RuleFix, RuleFixer, RuleListener, RuleListener as RuleListener$1 } from "@typescript-eslint/utils/ts-eslint";
|
|
2
4
|
import { TSESTree } from "@typescript-eslint/types";
|
|
3
5
|
import { ParserServicesWithTypeInformation } from "@typescript-eslint/utils";
|
|
4
6
|
import ts from "typescript";
|
|
5
|
-
import * as tseslint from "@typescript-eslint/utils/ts-eslint";
|
|
6
|
-
import { ReportDescriptor, ReportFixFunction, RuleFix, RuleFixer, RuleListener, RuleListener as RuleListener$1 } from "@typescript-eslint/utils/ts-eslint";
|
|
7
|
-
/**
|
|
8
|
-
* Resolves the given node's type. Will return the type's generic constraint, if it has one.
|
|
9
|
-
*
|
|
10
|
-
* Warning - if the type is generic and does _not_ have a constraint, the type will be
|
|
11
|
-
* returned as-is, rather than returning an `unknown` type. This can be checked
|
|
12
|
-
* for by checking for the type flag ts.TypeFlags.TypeParameter.
|
|
13
|
-
*
|
|
14
|
-
* Adapted from `getConstrainedTypeAtLocation` in `@typescript-eslint/type-utils`
|
|
15
|
-
* (MIT License, Copyright (c) 2019 typescript-eslint and other contributors,
|
|
16
|
-
* https://github.com/typescript-eslint/typescript-eslint) so that consumers don't
|
|
17
|
-
* need to load `@typescript-eslint/type-utils`, whose entry point eagerly loads
|
|
18
|
-
* the `eslint` package.
|
|
19
|
-
* @see https://github.com/typescript-eslint/typescript-eslint/issues/10438
|
|
20
|
-
*/
|
|
21
|
-
export declare function getConstrainedTypeAtLocation(services: ParserServicesWithTypeInformation, node: TSESTree.Node): ts.Type;
|
|
22
7
|
/**
|
|
23
8
|
* Represents the ESLint rule context.
|
|
24
9
|
* @since 0.0.1
|
|
@@ -33,6 +18,16 @@ export type RuleFeature = "CFG" | "DBG" | "FIX" | "MOD" | "TSC" | "EXP";
|
|
|
33
18
|
export declare const createRule: <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<Options, MessageIds, unknown>>) => ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener> & {
|
|
34
19
|
name: string;
|
|
35
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Merge the rule options supplied by the user with the rule's default options.
|
|
23
|
+
*
|
|
24
|
+
* Properties whose value is `null` or `undefined` keep the default value.
|
|
25
|
+
*
|
|
26
|
+
* @param options The rule options supplied by the user.
|
|
27
|
+
* @param defaults The rule's default options.
|
|
28
|
+
* @returns The merged rule options.
|
|
29
|
+
*/
|
|
30
|
+
export declare function complete<O extends object, D extends NoInfer<O>>(options: Partial<O> | null | undefined, defaults: D): O & Omit<D, keyof O>;
|
|
36
31
|
/**
|
|
37
32
|
* Gets the source text of the given node or token.
|
|
38
33
|
* Can be used as `(context, node)` to get the text directly,
|
|
@@ -49,6 +44,21 @@ export declare function getText(context: RuleContext): (node: TSESTree.Node | TS
|
|
|
49
44
|
* @returns A function that can be used to report violations.
|
|
50
45
|
*/
|
|
51
46
|
export declare function report(context: RuleContext): (desc?: null | ReportDescriptor<string>) => void;
|
|
47
|
+
/**
|
|
48
|
+
* Resolves the given node's type. Will return the type's generic constraint, if it has one.
|
|
49
|
+
*
|
|
50
|
+
* Warning - if the type is generic and does _not_ have a constraint, the type will be
|
|
51
|
+
* returned as-is, rather than returning an `unknown` type. This can be checked
|
|
52
|
+
* for by checking for the type flag ts.TypeFlags.TypeParameter.
|
|
53
|
+
*
|
|
54
|
+
* Adapted from `getConstrainedTypeAtLocation` in `@typescript-eslint/type-utils`
|
|
55
|
+
* (MIT License, Copyright (c) 2019 typescript-eslint and other contributors,
|
|
56
|
+
* https://github.com/typescript-eslint/typescript-eslint) so that consumers don't
|
|
57
|
+
* need to load `@typescript-eslint/type-utils`, whose entry point eagerly loads
|
|
58
|
+
* the `eslint` package.
|
|
59
|
+
* @see https://github.com/typescript-eslint/typescript-eslint/issues/10438
|
|
60
|
+
*/
|
|
61
|
+
export declare function getConstrainedTypeAtLocation(services: ParserServicesWithTypeInformation, node: TSESTree.Node): ts.Type;
|
|
52
62
|
/**
|
|
53
63
|
* Merge multiple visitor objects into a single visitor object.
|
|
54
64
|
*
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import * as ESLintUtils from "@typescript-eslint/utils/eslint-utils";
|
|
2
|
-
// src/get-constrained-type-at-location.ts
|
|
3
|
-
function getConstrainedTypeAtLocation(services, node) {
|
|
4
|
-
const nodeType = services.getTypeAtLocation(node);
|
|
5
|
-
return services.program.getTypeChecker().getBaseConstraintOfType(nodeType) ?? nodeType;
|
|
6
|
-
}
|
|
7
2
|
// src/utils.ts
|
|
8
3
|
function getDocsUrl(ruleName) {
|
|
9
4
|
return `https://eslint-react.xyz/docs/rules/${ruleName}`;
|
|
10
5
|
}
|
|
11
6
|
const createRule = ESLintUtils.RuleCreator(getDocsUrl);
|
|
7
|
+
function complete(options, defaults) {
|
|
8
|
+
const result = { ...defaults };
|
|
9
|
+
for (const key in options) {
|
|
10
|
+
const value = options[key];
|
|
11
|
+
if (value != null) Reflect.set(result, key, value);
|
|
12
|
+
}
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
12
15
|
function getText(context, ...rest) {
|
|
13
16
|
if (rest.length === 1) return context.sourceCode.getText(rest[0]);
|
|
14
17
|
return (node) => context.sourceCode.getText(node);
|
|
@@ -19,6 +22,10 @@ function report(context) {
|
|
|
19
22
|
context.report(desc);
|
|
20
23
|
};
|
|
21
24
|
}
|
|
25
|
+
function getConstrainedTypeAtLocation(services, node) {
|
|
26
|
+
const nodeType = services.getTypeAtLocation(node);
|
|
27
|
+
return services.program.getTypeChecker().getBaseConstraintOfType(nodeType) ?? nodeType;
|
|
28
|
+
}
|
|
22
29
|
function merge(base, ...rest) {
|
|
23
30
|
for (const r of rest) for (const key in r) {
|
|
24
31
|
const existing = base[key];
|
|
@@ -29,4 +36,4 @@ function merge(base, ...rest) {
|
|
|
29
36
|
}
|
|
30
37
|
return base;
|
|
31
38
|
}
|
|
32
|
-
export { createRule, getConstrainedTypeAtLocation, getText, merge, report };
|
|
39
|
+
export { complete, createRule, getConstrainedTypeAtLocation, getText, merge, report };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/eslint",
|
|
3
|
-
"version": "5.30.0-beta.
|
|
3
|
+
"version": "5.30.0-beta.7",
|
|
4
4
|
"description": "ESLint React's ESLint types and utils.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
"@types/node": "^20.19.43",
|
|
39
39
|
"eslint": "^10.13.0",
|
|
40
40
|
"tsdown": "^0.23.2",
|
|
41
|
-
"typescript": "6.0.3"
|
|
41
|
+
"typescript": "6.0.3",
|
|
42
|
+
"vitest": "^5.0.5"
|
|
42
43
|
},
|
|
43
44
|
"peerDependencies": {
|
|
44
45
|
"eslint": "*",
|