|
| 1 | +import type { Audit, Group } from '@code-pushup/models'; |
| 2 | +import { toSentenceCase } from '@code-pushup/utils'; |
| 3 | +import { TS_CODE_RANGE_NAMES } from './runner/ts-error-codes.js'; |
| 4 | +import type { AuditSlug } from './types.js'; |
| 5 | + |
1 | 6 | export const TYPESCRIPT_PLUGIN_SLUG = 'typescript'; |
| 7 | +export const DEFAULT_TS_CONFIG = 'tsconfig.json'; |
| 8 | + |
| 9 | +const AUDIT_DESCRIPTIONS: Record<AuditSlug, string> = { |
| 10 | + 'semantic-errors': |
| 11 | + 'Errors that occur during type checking and type inference', |
| 12 | + 'syntax-errors': |
| 13 | + 'Errors that occur during parsing and lexing of TypeScript source code', |
| 14 | + 'configuration-errors': |
| 15 | + 'Errors that occur when parsing TypeScript configuration files', |
| 16 | + 'declaration-and-language-service-errors': |
| 17 | + 'Errors that occur during TypeScript language service operations', |
| 18 | + 'internal-errors': 'Errors that occur during TypeScript internal operations', |
| 19 | + 'no-implicit-any-errors': 'Errors related to no implicit any compiler option', |
| 20 | + 'unknown-codes': 'Errors that do not match any known TypeScript error code', |
| 21 | +}; |
| 22 | +export const AUDITS: (Audit & { slug: AuditSlug })[] = Object.values( |
| 23 | + TS_CODE_RANGE_NAMES, |
| 24 | +).map(slug => ({ |
| 25 | + slug, |
| 26 | + title: toSentenceCase(slug), |
| 27 | + description: AUDIT_DESCRIPTIONS[slug], |
| 28 | +})); |
| 29 | + |
| 30 | +/** |
| 31 | + * # Diagnostic Code Categories |
| 32 | + * | 🏷️ Category | Diagnostic Code Ranges | Audits | |
| 33 | + * |-------------------|------------------------|--------------------------------------------------------------------------| |
| 34 | + * | **Problems** | 1XXX, 2XXX, 5XXX, 7XXX | `syntax-errors`, `semantic-errors`, `internal-errors`, `no-implicit-any` | |
| 35 | + * | **Suggestions** | 3XXX | `suggestions` | |
| 36 | + * | **Configuration** | 6XXX | `configuration-errors` | |
| 37 | + */ |
| 38 | +export const GROUPS: Group[] = [ |
| 39 | + { |
| 40 | + slug: 'problems-group', |
| 41 | + title: 'Problems', |
| 42 | + description: |
| 43 | + 'Syntax, semantic, and internal compiler errors are critical for identifying and preventing bugs.', |
| 44 | + refs: ( |
| 45 | + [ |
| 46 | + 'syntax-errors', |
| 47 | + 'semantic-errors', |
| 48 | + 'internal-errors', |
| 49 | + 'no-implicit-any-errors', |
| 50 | + ] satisfies AuditSlug[] |
| 51 | + ).map(slug => ({ |
| 52 | + slug, |
| 53 | + weight: 1, |
| 54 | + })), |
| 55 | + }, |
| 56 | + { |
| 57 | + slug: 'ts-configuration-group', |
| 58 | + title: 'Configuration', |
| 59 | + description: |
| 60 | + 'TypeScript configuration and options errors ensure correct project setup, reducing risks from misconfiguration.', |
| 61 | + refs: (['configuration-errors'] satisfies AuditSlug[]).map(slug => ({ |
| 62 | + slug, |
| 63 | + weight: 1, |
| 64 | + })), |
| 65 | + }, |
| 66 | + { |
| 67 | + slug: 'miscellaneous-group', |
| 68 | + title: 'Miscellaneous', |
| 69 | + description: |
| 70 | + 'Errors that do not bring any specific value to the developer, but are still useful to know.', |
| 71 | + refs: ( |
| 72 | + [ |
| 73 | + 'unknown-codes', |
| 74 | + 'declaration-and-language-service-errors', |
| 75 | + ] satisfies AuditSlug[] |
| 76 | + ).map(slug => ({ |
| 77 | + slug, |
| 78 | + weight: 1, |
| 79 | + })), |
| 80 | + }, |
| 81 | +]; |
0 commit comments