Registry / devops / eslint-plugin-typescript-formatter

eslint-plugin-typescript-formatter

JSON →
library1.0.0jsnpmunverified

An ESLint plugin that integrates TypeScript's built-in formatter as an ESLint rule, allowing developers to apply TypeScript formatting (like indent, semicolons, quotes) directly via ESLint. Version 1.0.0 is the initial stable release. It provides a single rule 'typescript-formatter/format' with comprehensive options mirroring TypeScript's formatting settings. Differentiator: it leverages the official TypeScript formatter, ensuring consistency with the TypeScript compiler's formatting, as opposed to third-party formatters like Prettier or dprint. Requires peer dependencies eslint >=8.0.0 and any TypeScript version.

npm install eslint-plugin-typescript-formatter
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-TYPE
E
eslint-plugin-typescript-formatter
devopsjavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

default
import plugin from 'eslint-plugin-typescript-formatter'
const plugin = require('eslint-plugin-typescript-formatter')
ESM-only package; CJS require will error.
rules
import { rules } from 'eslint-plugin-typescript-formatter'
const { rules } = require('eslint-plugin-typescript-formatter')
Named export for direct rule access; avoid default import destructuring.
Plugin
import type { Plugin } from 'eslint'
import { Plugin } from 'eslint-plugin-typescript-formatter'
TypeScript type import, not a symbol exported by this package.

Configure the typescript-formatter/format rule in ESLint; includes both legacy .eslintrc and flat config examples.

// .eslintrc.json { "plugins": ["typescript-formatter"], "rules": { "typescript-formatter/format": ["warn", { "indentSize": 2, "tabSize": 2, "newLineCharacter": "\n", "convertTabsToSpaces": true, "indentStyle": 2, "trimTrailingWhitespace": true, "semicolons": "insert" }] } } // Or in eslint.config.js (flat config) import typescriptFormatter from 'eslint-plugin-typescript-formatter'; export default [{ plugins: { 'typescript-formatter': typescriptFormatter }, rules: { 'typescript-formatter/format': ['warn', { indentSize: 2 }] } }];
Debug
Known issues
breakingESM-only package: CJS require() will not work.
fix
Use import or dynamic import().
affects: >=1.0.0
deprecatedSome TypeScript formatting options have been deprecated in newer TypeScript versions; check compatibility.
fix
Remove deprecated options like 'baseIndentSize' if using TS >5.0.
affects: >=1.0.0
gotchaThe plugin uses TypeScript's internal formatting API which may change between TypeScript minor versions, causing unexpected formatting differences.
fix
Lock TypeScript version in project and test formatting after updates.
affects: >=1.0.0
gotchaESLint flat config requires explicit plugin import; string plugin name in plugins array does not resolve.
fix
Use import typescriptFormatter from 'eslint-plugin-typescript-formatter'; set plugins['typescript-formatter'] = typescriptFormatter.
affects: >=1.0.0
deprecatedThe option 'indentStyle' (number) is deprecated in TypeScript 5.x; use 'indentStyle' (string) instead.
fix
Use 'indentStyle': 'Smart' or 'Block' string values.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'format')
Plugin not properly loaded in ESLint config
fix
Ensure plugin is added to 'plugins' array and rule is prefixed with 'typescript-formatter/'
Error: Cannot find module 'eslint-plugin-typescript-formatter'
CJS require() used with ESM-only package
fix
Use import syntax or switch to dynamic import()
Configuration for rule "typescript-formatter/format" is invalid: Unknown option "baseIndentSize".
Option removed in newer TypeScript version
fix
Remove 'baseIndentSize' from rule options
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
eslintrequiredCore peer dependency; the plugin operates as an ESLint rule plugin.
typescriptrequiredRequired peer dependency to access TypeScript's formatting API.
Agent activity
2 hits · last 30 days
node
2
Resources
eslint-plugin-typescript-formatter — npm install eslint-plugin-typescript-formatter · libregistry