|
1 | | -// @tsslint-disable typescript-service-api |
| 1 | +// @tsslint-disable typescript-services-types |
2 | 2 | import { defineRule } from '@tsslint/config'; |
3 | 3 | import type * as ts from 'typescript'; |
4 | 4 |
|
5 | 5 | /* |
6 | | - * service api list: https://github.com/microsoft/TypeScript/blob/38d95c8001300f525fd601dd0ce6d0ff5f12baee/src/services/types.ts |
| 6 | + * services types list: https://github.com/microsoft/TypeScript/blob/38d95c8001300f525fd601dd0ce6d0ff5f12baee/src/services/types.ts |
7 | 7 | * commit: 96acaa52902feb1320e1d8ec8936b8669cca447d (2025-09-25) |
8 | 8 | */ |
9 | | -const SERVICE_API: Record<string, string[]> = { |
| 9 | +const SERVICES_TYPES: Record<string, string[]> = { |
10 | 10 | Node: [ |
11 | 11 | 'getSourceFile', |
12 | 12 | 'getChildCount', |
@@ -98,9 +98,9 @@ const SERVICE_API: Record<string, string[]> = { |
98 | 98 | ], |
99 | 99 | }; |
100 | 100 |
|
101 | | -const typescriptServiceApis: Map<string, Set<string>> = new Map(); |
102 | | -for (const [typeName, properties] of Object.entries(SERVICE_API)) { |
103 | | - typescriptServiceApis.set(typeName, new Set(properties)); |
| 101 | +const tsServicesTypes: Map<string, Set<string>> = new Map(); |
| 102 | +for (const [typeName, properties] of Object.entries(SERVICES_TYPES)) { |
| 103 | + tsServicesTypes.set(typeName, new Set(properties)); |
104 | 104 | } |
105 | 105 |
|
106 | 106 | const TYPESCRIPT_PACKAGE_PATH = '/node_modules/typescript/'; |
@@ -144,13 +144,13 @@ export default defineRule(({ typescript: ts, file, program, report }) => { |
144 | 144 | } |
145 | 145 |
|
146 | 146 | function checkAccess(target: ts.Expression, propertyName: string, start: number, end: number) { |
147 | | - for (const [typeName, properties] of typescriptServiceApis) { |
| 147 | + for (const [typeName, properties] of tsServicesTypes) { |
148 | 148 | if (!properties.has(propertyName)) { |
149 | 149 | continue; |
150 | 150 | } |
151 | 151 | const type = typeChecker.getTypeAtLocation(target); |
152 | 152 | if (isTargetType(type, typeName)) { |
153 | | - report('TypeScript service-only API is used', start, end); |
| 153 | + report('TypeScript services types is used.', start, end); |
154 | 154 | break; |
155 | 155 | } |
156 | 156 | } |
|
0 commit comments