Registry / testing / eslint-plugin-typeorm-typescript

eslint-plugin-typeorm-typescript

JSON →
library0.5.3jsnpmunverified

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.

npm install eslint-plugin-typeorm-typescript
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-TYPE
E
eslint-plugin-typeorm-typescript
testingjavascriptv0.5.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

typeormTypescriptRecommended
import typeormTypescriptRecommended from 'eslint-plugin-typeorm-typescript/recommended';
const typeormTypescriptRecommended = require('eslint-plugin-typeorm-typescript/recommended');
This is the recommended export for ESLint flat configuration (ESM). Prior to v0.4.0, CommonJS `require` was the primary method.
typeormTypescriptPlugin
import typeormTypescriptPlugin from 'eslint-plugin-typeorm-typescript';
const typeormTypescriptPlugin = require('eslint-plugin-typeorm-typescript');
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.
Rules Object (Legacy)
{ "plugins": ["typeorm-typescript"], "rules": { "typeorm-typescript/enforce-column-types": "error" } }
import typeormTypescript from 'eslint-plugin-typeorm-typescript';
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/`.

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" }] } } );
Debug
Known issues
breakingVersion `0.5.3` drops official support for Node.js 18.
fix
Upgrade your Node.js environment to version 20 or higher to maintain compatibility and receive updates.
affects: >=0.5.3
breakingThe parsing logic for `bigint` and `decimal` column types changed in `v0.5.0` to correctly align with database driver behavior.
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.
affects: >=0.5.0
breakingVersion `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.
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.
affects: >=0.4.0
gotchaTypeORM relations are nullable by default, unlike regular columns, which can lead to unexpected type inconsistencies if not explicitly handled.
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.
affects: *
Errors
Common errors & fixes
Plugin 'typeorm-typescript' was referenced but not found.
ESLint could not load the plugin, typically due to incorrect installation or an improper path in the configuration.
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`).
Parsing error: 'import' and 'export' may only appear at the top level
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.
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`.
Configuration for rule 'typeorm-typescript/enforce-column-types' is invalid: Value must be an object.
An array was provided for rule options where an object was expected, or the object structure for rule options is incorrect.
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" }]`.
Upgrade
Version history
0.5.3latest on npm
Audit
Dependencies
eslintrequiredCore ESLint library, required for any ESLint plugin.
typescript-eslintrequiredTypeScript-specific ESLint parser and plugin, necessary for analyzing TypeScript code.
typeormoptionalRuntime dependency for projects using this plugin, as it validates TypeORM decorators.
Agent activity
10 hits · last 30 days
node
10
Resources
eslint-plugin-typeorm-typescript — npm install eslint-plugin-typeorm-typescript · libregistry