@@ -4,39 +4,125 @@ import type {AuditSlug} from '../types.js';
4
4
/**
5
5
* [src/compiler/types.ts](https://github.com/microsoft/TypeScript/blob/56a08250f3516b3f5bc120d6c7ab4450a9a69352/src/compiler/types.ts) -> compilerOptions 7482
6
6
* [src/compiler/utilities.ts](https://github.com/microsoft/TypeScript/blob/56a08250f3516b3f5bc120d6c7ab4450a9a69352/src/compiler/types.ts) 9125
7
- *
8
- * strictNullChecks: {
9
- * dependencies: ["strict"],
10
- * computeValue: compilerOptions => {
11
- * return getStrictOptionValue(compilerOptions, "strictNullChecks");
12
- * },
13
- * },
14
- * microsoft/TypeScript/src/compiler/utilities.ts
15
- * src/compiler/utilities.ts
16
- *
17
- * export function getStrictOptionValue(compilerOptions: CompilerOptions, flag: StrictOptionName): boolean {
18
- * return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag];
19
- * }
20
- *
21
- * Compiler options that are activated by strict: true
22
- *
23
- * strictFunctionTypes?: boolean; // Always combine with strict property
24
- * strictBindCallApply?: boolean; // Always combine with strict property
25
- * strictNullChecks?: boolean; // Always combine with strict property
26
- * strictPropertyInitialization?: boolean; // Always combine with strict property
27
- * strictBuiltinIteratorReturn?: boolean; // Always combine with strict property
28
- * alwaysStrict?: boolean; // Always combine with strict property
29
- * noImplicitAny?: boolean; // Always combine with strict property
30
- * noImplicitThis?: boolean; // Always combine with strict property
31
- *
32
7
*/
33
- export const NEW_SUPPORTED_TS_ERROR_CODES = {
34
- 'strict-types' : [
35
- 2322 , // Type 'X' is not assignable to type 'Y'
36
- ]
8
+
9
+ // Strict checks group
10
+ const noImplicitAnyCodes = [ 7005 , 7006 , 7008 , 7009 , 7010 , 7011 , 7015 , 7016 , 7017 , 7018 , 7019 , 7031 , 7032 , 7033 ] ;
11
+ const noImplicitThisCodes = [ 2683 , 2674 ] ;
12
+ const alwaysStrictCodes = [ 1100 , 1101 , 1102 , 1212 , 1213 , 1214 , 1215 , 1250 , 1251 , 1252 ] ;
13
+ const strictBuiltinIteratorReturn = [ 1065 ] ; // sussy
14
+ const strictPropertyInitializationCodes = [ 2564 , 2565 , 1263 , 1264 ] ;
15
+ const strictNullChecksCodes = [ 2531 , 2532 , 2533 , 2722 , 2721 , 18047 , 18048 , 18049 ] ;
16
+ const strictBindCallApplyCodes = [ 2677 , 2345 , 2769 ] ;
17
+ const strictFunctionTypesCodes = [ 2344 , 2322 , 2345 , 2411 ] ;
18
+
19
+ // Extras checks group
20
+ // Previous groups remain the same...
21
+
22
+ // Build and Emit Options
23
+ const noEmitCodes = [ 6059 ] ;
24
+ const noEmitHelpersCodes = [ 2343 ] ;
25
+ const noEmitOnErrorCodes = [ 2318 , 2354 ] ;
26
+ const preserveConstEnumsCodes = [ 2748 ] ;
27
+ const removeCommentsCodes = [ 2728 ] ;
28
+ const stripInternalCodes = [ 2680 ] ;
29
+ const emitBOMCodes = [ 2427 ] ;
30
+ const importHelpersCodes = [ 2343 , 2344 ] ;
31
+ const downlevelIterationCodes = [ 2569 ] ;
32
+ const emitDeclarationOnlyCodes = [ 5069 ] ;
33
+
34
+ // Code Quality
35
+ const allowUnreachableCodeCodes = [ 7027 ] ;
36
+ const allowUnusedLabelsCodes = [ 7028 ] ;
37
+ const noImplicitReturnsInAsyncFunctionsCodes = [ 7030 , 1064 ] ;
38
+ const noUnusedLabelsCodes = [ 7028 ] ;
39
+ const allowUnusedParametersCodes = [ 6134 ] ;
40
+ const noFallthroughCasesInSwitchCodes = [ 7029 ] ;
41
+ const noImplicitReturnsInGeneratorsCodes = [ 7030 ] ;
42
+ const noPropertyAccessFromComputedKeyCodes = [ 4111 ] ;
43
+
44
+ // Type Checking Behavior
45
+ const noErrorTruncationCodes = [ 2322 , 2345 ] ; // This affects error message display rather than triggering specific errors
46
+ const exactOptionalPropertyTypesCodes = [ 2775 ] ;
47
+ const noFallthroughCasesInSwitchCodes = [ 7029 ] ;
48
+ const noUncheckedIndexedAccessCodes = [ 7061 ] ;
49
+ const noImplicitOverrideCodes = [ 4114 , 4113 ] ;
50
+ const noPropertyAccessFromIndexSignatureCodes = [ 4111 ] ;
51
+
52
+ // Module Resolution
53
+ const moduleResolutionNodeCodes = [ 2307 ] ;
54
+ const moduleResolutionBundlerCodes = [ 1479 ] ;
55
+ const customConditionsCodes = [ 1378 ] ;
56
+ const resolvePackageJsonExportsCodes = [ 1343 ] ;
57
+ const resolvePackageJsonImportsCodes = [ 1344 ] ;
58
+
59
+ // Project References
60
+ const compositeCodes = [ 6372 ] ;
61
+ const disableReferencedProjectLoadCodes = [ 6371 ] ;
62
+ const disableSolutionSearchingCodes = [ 6370 ] ;
63
+ const disableSourceOfProjectReferenceRedirectCodes = [ 6374 ] ;
64
+
65
+ // Watch Options
66
+ const assumeChangesOnlyAffectDirectDependenciesCodes = [ 6373 ] ;
67
+ const preserveWatchOutputCodes = [ 6379 ] ; // This affects watch mode behavior rather than emitting errors
68
+ const watchDirectoryCodes = [ 6378 ] ;
69
+ const watchFileCodes = [ 6377 ] ;
70
+
71
+ // Interop Constraints
72
+ const allowSyntheticDefaultImportsCodes = [ 1192 , 1259 ] ;
73
+ const esModuleInteropCodes = [ 1202 , 1203 , 1204 , 1259 ] ;
74
+ const forceConsistentCasingInFileNamesCodes = [ 1149 , 1261 ] ;
75
+ const isolatedModulesCodes = [ 18055 , 18056 , 18057 ] ;
76
+ const preserveSymlinksCodes = [ 1421 ] ;
77
+
78
+ // Language and Environment
79
+ const experimentalDecorators = [ 1240 , 1241 , 1242 , 1243 , 1244 , 1270 , 1271 , 1272 ] ;
80
+ const emitDecoratorMetadata = [ 1240 , 1241 , 1272 ] ;
81
+ const jsx = [ 1341 , 18007 , 18034 , 18035 , 18053 ] ;
82
+ const jsxFactoryCodes = [ 17004 , 17001 ] ;
83
+ const jsxFragmentFactoryCodes = [ 17002 , 17003 ] ;
84
+ const jsxImportSourceCodes = [ 17004 ] ;
85
+ const libCodes = [ 2318 , 2432 ] ;
86
+ const moduleDetectionCodes = [ 1280 ] ;
87
+ const noLibCodes = [ 2318 , 2354 ] ;
88
+ const reactNamespaceCodes = [ 2503 , 2504 ] ;
89
+ const targetCodes = [ 2322 , 2339 , 2459 ] ;
90
+ const useDefineForClassFieldsCodes = [ 2729 , 2730 ] ;
91
+
92
+ const verbatimModuleSyntaxCodes = [ 1286 , 1287 , 1288 , 1484 , 1485 ] ;
93
+
94
+ export const STRICT_CHECKS = {
95
+ 'no-implicit-any-codes' : noImplicitAnyCodes ,
96
+ 'no-implicit-this-codes' : noImplicitThisCodes ,
97
+ 'always-strict-codes' : alwaysStrictCodes ,
98
+ 'strict-builtin-iterator-return' : strictBuiltinIteratorReturn ,
99
+ 'strict-property-initialization-codes' : strictPropertyInitializationCodes ,
100
+ 'strict-null-checks-codes' : strictNullChecksCodes ,
101
+ 'strict-bind-call-apply-codes' : strictBindCallApplyCodes ,
102
+ 'strict-function-types-codes' : strictFunctionTypesCodes ,
37
103
}
38
- export const SUPPORTED_TS_ERROR_CODES = {
39
104
105
+ /*
106
+ * # Audits
107
+ *
108
+ * - strict-checks - group
109
+ * - no-implicit-any-codes - audit
110
+ * - 1240 - issue
111
+ * - 1241 - issue
112
+ * - 1272 - issue
113
+ * - no-implicit-this-codes - audit
114
+ * - always-strict-codes - audit
115
+ * - strict-builtin-iterator-return - audit
116
+ * - strict-property-initialization-codes - audit
117
+ **/
118
+ // Build Reverse Lookup Map
119
+ export const AUDIT_LOOKUP = new Map < number , string > ( ) ;
120
+
121
+ for ( const [ slug , codes ] of Object . entries ( STRICT_CHECKS ) ) {
122
+ codes . forEach ( ( code ) => AUDIT_LOOKUP . set ( code , slug ) ) ;
123
+ }
124
+
125
+ export const SUPPORTED_TS_ERROR_CODES = {
40
126
2322 : 'strict-type-checks-2322' , // Type 'X' is not assignable to type 'Y'
41
127
2345 : 'strict-function-types-2345' , // Argument of type 'X' is not assignable to parameter of type 'Y'
42
128
2366 : 'strict-missing-return-2366' , // Function lacks ending return statement and return type does not include 'undefined'
0 commit comments