TypeScript
TypeScript support is on when typescript or @typescript/native-preview is installed. You don't need to set typescript: true in a typical project.
import { vinicuncaESLint } from '@vinicunca/eslint-config';
export default vinicuncaESLint();
Turn it off, or pass an object, when you need to:
export default vinicuncaESLint({
typescript: false,
});
Parser and files
@typescript-eslint/parser is used for *.ts, *.tsx, *.mts, *.cts and any componentExts (.vue is added automatically when Vue is on). Config names: vinicunca/typescript/setup, vinicunca/typescript/parser, vinicunca/typescript/rules.
The plugin prefix is ts/* (renamed from @typescript-eslint).
Rules worth knowing
The config starts from TypeScript ESLint's eslint-recommended and strict sets, then changes several:
ts/array-type:Array<T>(notT[])ts/consistent-type-definitions:interfaceovertypets/consistent-type-imports:import typewithseparate-type-importsts/method-signature-style: property syntax (fn: () => void)ts/no-explicit-anyis offts/no-non-null-assertionis off- Unused variables allow a
_prefix
With type: 'lib', ts/explicit-function-return-type is also on (expressions, higher-order functions and IIFEs are allowed).
Type-aware rules
Set tsconfigPath to enable typed linting. The parser uses TypeScript's project service with that file as defaultProject:
export default vinicuncaESLint({
typescript: {
tsconfigPath: 'tsconfig.json',
},
});
That adds vinicunca/typescript/type-aware-parser and vinicunca/typescript/rules-type-aware, including:
ts/await-thenable, ts/no-floating-promises, ts/no-misused-promises, ts/no-unsafe-*, ts/restrict-template-expressions, ts/strict-boolean-expressions (nullable booleans and objects allowed), ts/switch-exhaustiveness-check, ts/return-await (in-try-catch), and others.
ignoresTypeAware, and keep Markdown / Astro virtual files out (already the default).tsconfig.json. Setting it turns type-aware rules on.vinicunca/typescript/rules.vinicunca/typescript/rules-type-aware. Ignored unless tsconfigPath is set.['**/*.?([cm])ts', '**/*.?([cm])tsx'].['**/*.md/**', '**/*.astro/*.ts'].@typescript-eslint/parser options, merged last.React's react/no-leaked-conditional-rendering and Solid's typed parser also follow tsconfigPath. See Frameworks.
Erasable syntax only
For Node.js type stripping (or other pipelines that erase types), forbid syntax that cannot be erased:
export default vinicuncaESLint({
typescript: {
erasableOnly: true,
},
});
Enables eslint-plugin-erasable-syntax-only (bundled) for enums, namespaces, parameter properties, and import/export aliases. Config name: vinicunca/typescript/erasable-syntax-only.