TypeScript & Node
@eienjs/eslint-config provides deep TypeScript and Node.js integration out of the box.
TypeScript Configuration
TypeScript support is automatically enabled when typescript or @typescript/native-preview is installed in your project.
Type-Aware Linting
To enable type-aware rules (such as @typescript-eslint/no-floating-promises, @typescript-eslint/no-misused-promises, @typescript-eslint/await-thenable, and @typescript-eslint/switch-exhaustiveness-check), provide tsconfigPath:
import { eienjs } from '@eienjs/eslint-config';
export default eienjs({
typescript: {
tsconfigPath: 'tsconfig.json',
},
});
When tsconfigPath is set, @eienjs/eslint-config configures projectService on @typescript-eslint/parser and applies strict type-checked rules to **/*.?([cm])ts, **/*.?([cm])tsx, and **/*.vue (excluding Markdown code blocks and .astro/*.ts virtual files).
Erasable Syntax Only
Node.js native TypeScript execution (--experimental-strip-types) and TypeScript's erasableSyntaxOnly compiler option disallow runtime TypeScript constructs such as enum, namespace, parameter properties, and import = aliases.
You can enforce erasable syntax in ESLint by enabling erasableSyntaxOnly:
pnpm add -D eslint-plugin-erasable-syntax-only
import { eienjs } from '@eienjs/eslint-config';
export default eienjs({
typescript: {
erasableSyntaxOnly: true,
tsconfigPath: 'tsconfig.json',
},
});
You can also selectively toggle enums or parameterProperties:
import { eienjs } from '@eienjs/eslint-config';
export default eienjs({
typescript: {
erasableSyntaxOnly: {
enums: true,
parameterProperties: false,
},
},
});
TypeScript Options Reference (OptionsTypescript)
| Option | Type | Default | Description |
|---|---|---|---|
tsconfigPath | string | undefined | Path to tsconfig.json to enable type-aware linting. |
erasableSyntaxOnly | boolean | OptionsErasableSyntaxOnly | false | Enforce erasable TypeScript syntax rules via eslint-plugin-erasable-syntax-only. |
filesTypeAware | string[] | [GLOB_TS, GLOB_TSX, GLOB_VUE] | Globs for files that should receive type-aware rules. |
ignoresTypeAware | string[] | ['**/*.md/**', '**/*.astro/*.ts'] | Globs excluded from type-aware linting. |
parserOptions | Partial<ParserOptions> | {} | Additional parser options passed to @typescript-eslint/parser. |
overrides | Rules | {} | Override standard TypeScript rules. |
overridesTypeAware | Rules | {} | Override type-aware rules when tsconfigPath is enabled. |
Unicorn & Naming Conventions
eslint-plugin-unicorn is enabled by default with allRecommended: true and curated overrides for EienJS conventions:
snake_caseFilenames: Enforcesunicorn/filename-casewithcase: 'snakeCase'across source files (ignoring.mdand.mdx).- Class Member Ordering: Enforces a consistent order (
static-field,static-block,public-field,private-field,constructor,public-method,static-method,private-method).
To customize or relax Unicorn rules:
import { eienjs } from '@eienjs/eslint-config';
export default eienjs({
unicorn: {
allRecommended: true,
overrides: {
'unicorn/filename-case': 'off',
},
},
});
pnpm Workspaces & Catalogs
When a pnpm-workspace.yaml file is detected (or when pnpm: true is passed), @eienjs/eslint-config lints both package.json and pnpm-workspace.yaml using eslint-plugin-pnpm:
- Validates catalog references (
pnpm/json-valid-catalog,pnpm/yaml-no-duplicate-catalog-item,pnpm/yaml-no-unused-catalog-item). - Enforces workspace security settings in
pnpm-workspace.yaml(minimumReleaseAgeExcludePrune: true,shellEmulator: true,trustPolicy: 'no-downgrade'). - Sorts keys in
pnpm-workspace.yamllogically.
import { eienjs } from '@eienjs/eslint-config';
export default eienjs({
pnpm: {
catalogs: true,
json: true,
sort: true,
yaml: true,
},
});
