prettier-tslint
raw JSON → 0.4.2 verified Sat Apr 25 auth: no javascript deprecated
Formats TypeScript files by running Prettier followed by tslint --fix. Latest version 0.4.2 (Jan 2019) is stable but unmaintained; peer dependencies require prettier ^1.7.4 and typescript ^2.5.3 || ^3.0.0. Provides CLI commands `fix` and `check`, and a programmatic API. No additional configuration beyond existing .prettierrc and tslint.json. Designed for projects migrating from TSLint to Prettier; now deprecated in favor of prettier + eslint.
Common errors
error Error: Cannot find module 'prettier' ↓
cause Peer dependency prettier not installed.
fix
npm install --save-dev prettier
error Error: Cannot find module 'typescript' ↓
cause Peer dependency typescript not installed.
fix
npm install --save-dev typescript
error SyntaxError: Unexpected token (expected an assignment or function call ↓
cause Input file contains unsupported JavaScript syntax or TSLint version mismatch.
fix
Ensure the file is valid TypeScript and use compatible TSLint version (5.x).
error prettier-tslint: error: unknown option `--write' ↓
cause Using CLI option --write which is not supported; only fix and check commands exist.
fix
Use
prettier-tslint fix <files> instead. Warnings
deprecated TSLint itself is deprecated in favor of ESLint; prettier-tslint is unmaintained since 2019 and may not work with newer TypeScript versions. ↓
fix Migrate to prettier + eslint with @typescript-eslint/parser.
breaking The fix function writes to disk and does not return a result; behavior may change before 1.0.0. ↓
fix Assume fix modifies files in place; check file after call for verification.
gotcha Uses tslint --fix which can introduce changes not fully formatted by Prettier; run order is Prettier then tslint. ↓
fix Ensure tslint rules are compatible with Prettier formatting to avoid conflicts.
gotcha Requires both prettier and typescript as peer dependencies; missing either causes runtime errors. ↓
fix Explicitly install prettier and typescript in the project.
Install
npm install prettier-tslint yarn add prettier-tslint pnpm add prettier-tslint Imports
- fix wrong
const fix = require('prettier-tslint').fixcorrectimport { fix } from 'prettier-tslint' - check wrong
import check from 'prettier-tslint'correctimport { check } from 'prettier-tslint' - prettier-tslint (CLI) wrong
npm run prettier-tslint fix file.tscorrectnpx prettier-tslint fix file.ts
Quickstart
npm install --save-dev prettier-tslint prettier typescript
npx prettier-tslint fix 'src/**/*.ts'