prettier-plugin-detect-throw weekly downloads statistics
By JQuezada0 · npm · Prettier plugins
A Prettier plugin to detect and enforce rules for throw statements
prettier-plugin-detect-throw has 4 recorded weekly downloads on npm, an increase of 33.3% over the past 30 days, ranking #3234 of 3,247 tracked listings.
About prettier-plugin-detect-throw
prettier-plugin-detect-throw
A Prettier plugin that identifies and highlights throw statements in your TypeScript code, optionally enforcing that only specific error classes are thrown.
Features
- Highlight Throw Statements: Add comments above all throw statements for easy identification
- Enforce Error Classes: Define allowed error classes and receive warnings for non-compliant throws
- Flexible Configuration: Include or exclude files using glob patterns
Installation
# Using npm
npm install --save-dev prettier-plugin-detect-throw
# Using yarn
yarn add --dev prettier-plugin-detect-throw
# Using bun
bun add --dev prettier-plugin-detect-throw
Usage
Add the plugin to your Prettier configuration:
// .prettierrc.js
module.exports = {
plugins: ["prettier-plugin-detect-throw"],
highlightThrows: true,
allowedErrorClasses: '["Error", "CustomError", "ValidationError"]',
enforceAllowedClasses: true,
include: '["**/*.ts", "**/*.tsx"]',
exclude: '["**/node_modules/**"]',
}
Or as JSON:
{
"plugins": ["prettier-plugin-detect-throw"],
"highlightThrows": true,
"allowedErrorClasses": "[\"Error\", \"CustomError\", \"ValidationError\"]",
"enforceAllowedClasses": true,
"include": "[\"**/*.ts\", \"**/*.tsx\"]",
"exclude": "[\"**/node_modules/**\"]"
}
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
highlightThrows | boolean | false | When true, adds a /* THROW STATEMENT */ comment above each throw |
allowedErrorClasses | string (JSON array) | "[]" | JSON string array of allowed error class names |
enforceAllowedClasses | boolean | true | When true, adds warning comments to throws that use non-allowed error classes |
include | string (JSON array) | "[\"**/*.ts\", \"**/*.tsx\"]" | JSON string array of glob patterns for files to include |
exclude | string (JSON array) | "[]" | JSON string array of glob patterns for files to exclude |
Example
Before:
function processData(data) {
if (!data) {
throw new Error("Data is required")
}
if (!isValid(data)) {
throw new InvalidDataError("Invalid data format")
}
try {
return transform(data)
} catch (e) {
throw e
}
}
After (with highlightThrows: true and allowedErrorClasses: ["Error"]):
function processData(data) {
if (!data) {
/* THROW STATEMENT */
throw new Error("Data is required")
}
if (!isValid(data)) {
/* WARNING: Only throw instances of: Error */
/* THROW STATEMENT */
throw new InvalidDataError("Invalid data format")
}
try {
return transform(data)
} catch (e) {
/* THROW STATEMENT */
throw e
}
}
Development
# Install dependencies
bun install
# Build as edits are made
bun run watch
# Build once
bun run build
# Typecheck
bun run typecheck
Description from the npm listing.
- prettier
- prettier-plugin
- error
- throw
- exception
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (170)Similar npm Prettier plugins plugins
All 20 prettier-plugin-detect-throw alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/prettier-plugin-detect-throw. First seen Oct 16, 2026; last successful collection Nov 12, 2026. See the methodology.