Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Document how to import and configure the parser for flat config #8959

Open
2 tasks done
runspired opened this issue Apr 20, 2024 · 2 comments
Open
2 tasks done
Labels
awaiting response Issues waiting for a reply from the OP or another party documentation Documentation ("docs") that needs adding/updating

Comments

@runspired
Copy link

Before You File a Documentation Request Please Confirm You Have Done The Following...

Suggested Changes

Currently, the documentation for flat config only shows how to dangerously apply global overrides instead of scoping rules to specific files:

export default tseslint.config(
  eslint.configs.recommended,
  ...tseslint.configs.recommendedTypeChecked,
  ...tseslint.configs.stylisticTypeChecked,
);

this means that to construct a safe configuration object a user must inspect the contents of each tseslint.configs.* and carefully merge them together into one object.

When doing so, the surprising thing I found is that tseslint does not currently support flat config correctly, as it still uses extends, the old parser and parserOptions setup, and uses strings to declare the parser and plugins neither of which is supported by eslint anymore:

current parser config:

import type { ClassicConfig } from '@typescript-eslint/utils/ts-eslint';
export = {
parser: '@typescript-eslint/parser',
parserOptions: { sourceType: 'module' },
plugins: ['@typescript-eslint'],
} satisfies ClassicConfig.Config;

which is used by the tseslint recommended config here: https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/recommended.ts

docs for new config: https://eslint.org/docs/latest/use/configure/parser#configure-a-custom-parser

Affected URL(s)

https://typescript-eslint.io/users/configs/

@runspired runspired added documentation Documentation ("docs") that needs adding/updating triage Waiting for maintainers to take a look labels Apr 20, 2024
@bradzacher
Copy link
Member

When doing so, the surprising thing I found is that tseslint does not currently support flat config correctly, as it still uses extends, the old parser and parserOptions setup, and uses strings to declare the parser and plugins neither of which is supported by eslint anymore:

You've gotten to the wrong place. Those are the legacy configs consumed within legacy configs only. The flat configs are accessed via the typescript-eslint package and are thus located within that package:

https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/typescript-eslint/src/configs

You'll notice that these are flat configs.

@bradzacher
Copy link
Member

Did you check out the docs for the typescript-eslint package...?

https://typescript-eslint.io/packages/typescript-eslint#advanced-usage

@bradzacher bradzacher added awaiting response Issues waiting for a reply from the OP or another party and removed triage Waiting for maintainers to take a look labels Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting response Issues waiting for a reply from the OP or another party documentation Documentation ("docs") that needs adding/updating
Projects
None yet
Development

No branches or pull requests

2 participants