Skip to content

Change Request: add TypeScript file extensions to recommended configs #457

@privatenumber

Description

@privatenumber

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

{ 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:

  1. Use @typescript-eslint/parser

    This is probably the most straightforward solution: include @typescript-eslint/parser in the config as a dependency. Alternatively, it could also be added as a peerDependency with documentation.

    This might raise some concerns about dependency bloating and whatnot, but might be a reasonable first step to iterate over.

  2. 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:

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions