@eslint-react/eslint 5.20.7 → 5.21.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/dist/index.d.ts CHANGED
@@ -1,6 +1,26 @@
1
- import { ESLintUtils } from "@typescript-eslint/utils";
1
+ import * as ESLintUtils from "@typescript-eslint/utils/eslint-utils";
2
+ import { TSESTree } from "@typescript-eslint/types";
3
+ import { ParserServicesWithTypeInformation } from "@typescript-eslint/utils";
4
+ import ts from "typescript";
2
5
  import * as tseslint from "@typescript-eslint/utils/ts-eslint";
3
- import { ReportFixFunction, RuleFix, RuleFixer, RuleListener, RuleListener as RuleListener$1 } from "@typescript-eslint/utils/ts-eslint";
6
+ import { ReportDescriptor, ReportFixFunction, RuleFix, RuleFixer, RuleListener, RuleListener as RuleListener$1 } from "@typescript-eslint/utils/ts-eslint";
7
+ //#region src/get-constrained-type-at-location.d.ts
8
+ /**
9
+ * Resolves the given node's type. Will return the type's generic constraint, if it has one.
10
+ *
11
+ * Warning - if the type is generic and does _not_ have a constraint, the type will be
12
+ * returned as-is, rather than returning an `unknown` type. This can be checked
13
+ * for by checking for the type flag ts.TypeFlags.TypeParameter.
14
+ *
15
+ * Adapted from `getConstrainedTypeAtLocation` in `@typescript-eslint/type-utils`
16
+ * (MIT License, Copyright (c) 2019 typescript-eslint and other contributors,
17
+ * https://github.com/typescript-eslint/typescript-eslint) so that consumers don't
18
+ * need to load `@typescript-eslint/type-utils`, whose entry point eagerly loads
19
+ * the `eslint` package.
20
+ * @see https://github.com/typescript-eslint/typescript-eslint/issues/10438
21
+ */
22
+ export declare function getConstrainedTypeAtLocation(services: ParserServicesWithTypeInformation, node: TSESTree.Node): ts.Type;
23
+ //#endregion
4
24
  //#region src/types.d.ts
5
25
  /**
6
26
  * Represents the ESLint rule context.
@@ -18,6 +38,12 @@ export type RuleFeature = "CFG" | "DBG" | "FIX" | "MOD" | "TSC" | "EXP";
18
38
  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> & {
19
39
  name: string;
20
40
  };
41
+ /**
42
+ * Creates a report function for the given rule context.
43
+ * @param context The ESLint rule context.
44
+ * @returns A function that can be used to report violations.
45
+ */
46
+ export declare function report(context: RuleContext): (desc?: null | ReportDescriptor<string>) => void;
21
47
  /**
22
48
  * Merge multiple visitor objects into a single visitor object.
23
49
  *
package/dist/index.js CHANGED
@@ -1,5 +1,26 @@
1
- import { ESLintUtils } from "@typescript-eslint/utils";
1
+ import * as ESLintUtils from "@typescript-eslint/utils/eslint-utils";
2
2
 
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
+ function getConstrainedTypeAtLocation(services, node) {
19
+ const nodeType = services.getTypeAtLocation(node);
20
+ return services.program.getTypeChecker().getBaseConstraintOfType(nodeType) ?? nodeType;
21
+ }
22
+
23
+ //#endregion
3
24
  //#region src/utils.ts
4
25
  function getDocsUrl(ruleName) {
5
26
  return `https://eslint-react.xyz/docs/rules/${ruleName}`;
@@ -7,6 +28,17 @@ function getDocsUrl(ruleName) {
7
28
  /** The rule creator that generates documentation URLs for ESLint React rules. */
8
29
  const createRule = ESLintUtils.RuleCreator(getDocsUrl);
9
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
+ function report(context) {
36
+ return (desc) => {
37
+ if (desc == null) return;
38
+ context.report(desc);
39
+ };
40
+ }
41
+ /**
10
42
  * Merge multiple visitor objects into a single visitor object.
11
43
  *
12
44
  * @param base The base visitor object (target of merge).
@@ -33,4 +65,4 @@ function merge(base, ...rest) {
33
65
  }
34
66
 
35
67
  //#endregion
36
- export { createRule, merge };
68
+ export { createRule, getConstrainedTypeAtLocation, merge, report };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/eslint",
3
- "version": "5.20.7",
3
+ "version": "5.21.0",
4
4
  "description": "ESLint React's ESLint types and utils.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -29,12 +29,13 @@
29
29
  "dist"
30
30
  ],
31
31
  "dependencies": {
32
- "@typescript-eslint/utils": "^8.70.0"
32
+ "@typescript-eslint/types": "^8.70.1",
33
+ "@typescript-eslint/utils": "^8.70.1"
33
34
  },
34
35
  "devDependencies": {
35
36
  "@local/configs": "0.0.0",
36
37
  "@tsconfig/node24": "^24.0.5",
37
- "@types/node": "^26.6.2",
38
+ "@types/node": "^26.6.3",
38
39
  "eslint": "^10.11.0",
39
40
  "tsdown": "^0.23.0",
40
41
  "typescript": "6.0.3"
@@ -43,6 +44,11 @@
43
44
  "eslint": "*",
44
45
  "typescript": "*"
45
46
  },
47
+ "peerDependenciesMeta": {
48
+ "eslint": {
49
+ "optional": true
50
+ }
51
+ },
46
52
  "engines": {
47
53
  "node": ">=22.0.0"
48
54
  },