ESLint Plugin for TypeORM-TypeScript Type Consistency

0.5.3 · active · verified Sun Apr 19

eslint-plugin-typeorm-typescript is an ESLint plugin designed to ensure type consistency between TypeORM entity definitions and their corresponding TypeScript types. It identifies discrepancies in primitive types (e.g., `varchar` vs. `number`), handles driver-specific type parsing (notably `bigint` and `decimal` which are often strings), and enforces correct nullability for columns and relations. The current stable version is `0.5.3`. The project appears to have an active release cadence, frequently introducing new rules and updating support for newer ESLint and TypeScript-ESLint versions. A key differentiator is its ability to catch subtle TypeORM-specific type mismatches that static TypeScript analysis alone cannot, particularly around default nullability behaviors and specific database type mappings. It supports both legacy and modern ESLint flat configurations, providing flexibility for different project setups.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates setting up `eslint-plugin-typeorm-typescript` with ESLint flat configuration in a TypeScript project, including recommended rules and custom options for specific rules.

import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import typeormTypescriptRecommended from 'eslint-plugin-typeorm-typescript/recommended';

export default tseslint.config(
  eslint.configs.recommended,
  ...tseslint.configs.recommended,
  typeormTypescriptRecommended,
  {
    files: ['**/*.ts', '**/*.tsx'],
    languageOptions: {
      parserOptions: {
        project: './tsconfig.json'
      }
    },
    rules: {
      "typeorm-typescript/enforce-column-types": ["error", { "driver": "postgres" }],
      "typeorm-typescript/enforce-relation-types": "warn",
      "typeorm-typescript/enforce-consistent-nullability": ["error", { "specifyNullable": "always" }]
    }
  }
);

view raw JSON →