-
-
Notifications
You must be signed in to change notification settings - Fork 55
Description
eslint-plugin-n version
v17.21.0
What problem do you want to solve?
With Node.js now supporting TypeScript natively via type stripping, it's becoming more common for projects to be written directly in TypeScript—often without any separate build step during development.
Right now, the recommended configs don't apply to .ts, .mts, or .cts files by default. This means users have to manually update their ESLint config to support TypeScript, adding both file globs and a parser. It's an extra step that could be avoided.
What do you think is the correct solution?
Update the recommended configs to include TypeScript file patterns out of the box: **/*.ts, **/*.mts, and **/*.cts in
eslint-plugin-n/lib/configs/recommended.js
Lines 23 to 24 in 8185617
| { files: ["*.cjs", ".*.cjs"], ...scriptConfig.eslintrc }, | |
| { files: ["*.mjs", ".*.mjs"], ...moduleConfig.eslintrc }, |
This would make eslint-plugin-n work seamlessly in modern Node.js projects written in TypeScript—no manual config needed.
Participation
- I am willing to submit a pull request for this change.
Additional comments
I'm thinking the main challenge is likely getting ESLint to parse TypeScript syntax.
Here ideas for how we move forward:
-
Use
@typescript-eslint/parserThis is probably the most straightforward solution: include
@typescript-eslint/parserin the config as a dependency. Alternatively, it could also be added as apeerDependencywith documentation.This might raise some concerns about dependency bloating and whatnot, but might be a reasonable first step to iterate over.
-
Strip types before parsing
A more optimized and novel (but Node-aligned) approach is to use a type-stripper so ESLint can parse the resulting plain JavaScript. Some options include:
- nodejs/amaro – Used internally by Node.js; wraps
@swc/wasm-typescript @swc/wasm-typescript– Strips types while preserving stack traces, no source maps needed. WASM, might be big.- ts-blank-space - Pure JS
oxc-transform- I think smaller and size optimized binary
- nodejs/amaro – Used internally by Node.js; wraps
Ultimately, the goal of this issue is to make the recommended configs apply to TypeScript files.
How that gets implemented is open for discussion—but improving the default experience would be a big win.