Usage & Features

TypeScript & Node

Configure TypeScript rules, type-aware linting, erasable syntax checks, Unicorn, and pnpm workspaces.

@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:

eslint.config.js
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
eslint.config.js
import { eienjs } from '@eienjs/eslint-config';

export default eienjs({
  typescript: {
    erasableSyntaxOnly: true,
    tsconfigPath: 'tsconfig.json',
  },
});

You can also selectively toggle enums or parameterProperties:

eslint.config.js
import { eienjs } from '@eienjs/eslint-config';

export default eienjs({
  typescript: {
    erasableSyntaxOnly: {
      enums: true,
      parameterProperties: false,
    },
  },
});

TypeScript Options Reference (OptionsTypescript)

OptionTypeDefaultDescription
tsconfigPathstringundefinedPath to tsconfig.json to enable type-aware linting.
erasableSyntaxOnlyboolean | OptionsErasableSyntaxOnlyfalseEnforce erasable TypeScript syntax rules via eslint-plugin-erasable-syntax-only.
filesTypeAwarestring[][GLOB_TS, GLOB_TSX, GLOB_VUE]Globs for files that should receive type-aware rules.
ignoresTypeAwarestring[]['**/*.md/**', '**/*.astro/*.ts']Globs excluded from type-aware linting.
parserOptionsPartial<ParserOptions>{}Additional parser options passed to @typescript-eslint/parser.
overridesRules{}Override standard TypeScript rules.
overridesTypeAwareRules{}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_case Filenames: Enforces unicorn/filename-case with case: 'snakeCase' across source files (ignoring .md and .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:

eslint.config.js
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.yaml logically.
eslint.config.js
import { eienjs } from '@eienjs/eslint-config';

export default eienjs({
  pnpm: {
    catalogs: true,
    json: true,
    sort: true,
    yaml: true,
  },
});