{"id":10836,"library":"eslint-plugin-typeorm-typescript","title":"ESLint Plugin for TypeORM-TypeScript Type Consistency","description":"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.","status":"active","version":"0.5.3","language":"javascript","source_language":"en","source_url":"https://github.com/daniel7grant/eslint-plugin-typeorm-typescript","tags":["javascript","eslint","typeorm","typescript"],"install":[{"cmd":"npm install eslint-plugin-typeorm-typescript","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-typeorm-typescript","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-typeorm-typescript","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core ESLint library, required for any ESLint plugin.","package":"eslint","optional":false},{"reason":"TypeScript-specific ESLint parser and plugin, necessary for analyzing TypeScript code.","package":"typescript-eslint","optional":false},{"reason":"Runtime dependency for projects using this plugin, as it validates TypeORM decorators.","package":"typeorm","optional":true}],"imports":[{"note":"This is the recommended export for ESLint flat configuration (ESM). Prior to v0.4.0, CommonJS `require` was the primary method.","wrong":"const typeormTypescriptRecommended = require('eslint-plugin-typeorm-typescript/recommended');","symbol":"typeormTypescriptRecommended","correct":"import typeormTypescriptRecommended from 'eslint-plugin-typeorm-typescript/recommended';"},{"note":"Use this import for manual rule configuration within ESLint flat config (ESM). The plugin also supports CommonJS `require` for legacy ESLint configs since v0.4.0.","wrong":"const typeormTypescriptPlugin = require('eslint-plugin-typeorm-typescript');","symbol":"typeormTypescriptPlugin","correct":"import typeormTypescriptPlugin from 'eslint-plugin-typeorm-typescript';"},{"note":"For legacy `.eslintrc.json` configurations, the plugin is referenced by its package name string within the `plugins` array, and rules are prefixed with `typeorm-typescript/`.","wrong":"import typeormTypescript from 'eslint-plugin-typeorm-typescript';","symbol":"Rules Object (Legacy)","correct":"{ \"plugins\": [\"typeorm-typescript\"], \"rules\": { \"typeorm-typescript/enforce-column-types\": \"error\" } }"}],"quickstart":{"code":"import eslint from '@eslint/js';\nimport tseslint from 'typescript-eslint';\nimport typeormTypescriptRecommended from 'eslint-plugin-typeorm-typescript/recommended';\n\nexport default tseslint.config(\n  eslint.configs.recommended,\n  ...tseslint.configs.recommended,\n  typeormTypescriptRecommended,\n  {\n    files: ['**/*.ts', '**/*.tsx'],\n    languageOptions: {\n      parserOptions: {\n        project: './tsconfig.json'\n      }\n    },\n    rules: {\n      \"typeorm-typescript/enforce-column-types\": [\"error\", { \"driver\": \"postgres\" }],\n      \"typeorm-typescript/enforce-relation-types\": \"warn\",\n      \"typeorm-typescript/enforce-consistent-nullability\": [\"error\", { \"specifyNullable\": \"always\" }]\n    }\n  }\n);","lang":"typescript","description":"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."},"warnings":[{"fix":"Upgrade your Node.js environment to version 20 or higher to maintain compatibility and receive updates.","message":"Version `0.5.3` drops official support for Node.js 18.","severity":"breaking","affected_versions":">=0.5.3"},{"fix":"Review TypeORM column definitions and their corresponding TypeScript types for `bigint` and `decimal`. For most drivers, these are now parsed as `string` in TypeScript (e.g., `string` instead of `number` for `bigint`). Adjust your TypeScript types accordingly.","message":"The parsing logic for `bigint` and `decimal` column types changed in `v0.5.0` to correctly align with database driver behavior.","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Migrate your ESLint configuration to the new flat config format (e.g., `eslint.config.mjs`). Use `typeormTypescriptRecommended` for a quick setup, or manually configure the plugin as detailed in the 'Flat configuration' section of the README. Ensure your Node.js environment supports ESM if using `import` statements.","message":"Version `0.4.0` introduced support for ESLint v9 and flat configuration, along with dual ES Module and CommonJS support. This requires updating your ESLint configuration file.","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"Utilize the `typeorm-typescript/enforce-relation-types` rule. Additionally, consider enabling the `typeorm-typescript/enforce-consistent-nullability` rule (introduced in v0.3.0) with `\"specifyNullable\": \"always\"` to enforce explicit nullability declarations for all columns and relations.","message":"TypeORM relations are nullable by default, unlike regular columns, which can lead to unexpected type inconsistencies if not explicitly handled.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure `eslint-plugin-typeorm-typescript` is installed as a dev dependency (`npm install -D eslint-plugin-typeorm-typescript`) and correctly referenced in your `.eslintrc.json` (`\"plugins\": [\"typeorm-typescript\"]`) or `eslint.config.mjs` (`typeormTypescriptPlugin` or `typeormTypescriptRecommended`).","cause":"ESLint could not load the plugin, typically due to incorrect installation or an improper path in the configuration.","error":"Plugin 'typeorm-typescript' was referenced but not found."},{"fix":"If using an ESLint flat config file (e.g., `eslint.config.mjs`), ensure your environment (e.g., Node.js 20+) supports ESM. If sticking with CommonJS for legacy `.eslintrc.js` files, use `require()` statements instead of `import`.","cause":"This error often occurs when attempting to use ES Module `import` syntax in a file configured as CommonJS, or in an older Node.js environment without full ESM support.","error":"Parsing error: 'import' and 'export' may only appear at the top level"},{"fix":"When providing options for a rule, ensure they are passed as the second element of an array where the first element is the rule's severity level (e.g., `\"error\"`). The options themselves should be a valid JavaScript object: `[\"error\", { \"driver\": \"sqlite\" }]`.","cause":"An array was provided for rule options where an object was expected, or the object structure for rule options is incorrect.","error":"Configuration for rule 'typeorm-typescript/enforce-column-types' is invalid: Value must be an object."}],"ecosystem":"npm"}