Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Docs: customizing recommended rules with flat config #9993

Open
Labels
accepting prsGo ahead, send a pull request that resolves this issuedocumentationDocumentation ("docs") that needs adding/updating
@altano

Description

@altano

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

Suggested Changes

Thetypescript-eslint documentation (https://typescript-eslint.io/packages/typescript-eslint/) describes two basic use cases:

  1. Using the recommended rules:
tseslint.config(eslint.configs.recommended,  ...tseslint.configs.recommended,);
  1. Fully customizing the rules:
tseslint.config({plugins:{"@typescript-eslint":tseslint.plugin,},languageOptions:{parser:tseslint.parser,parserOptions:{project:true,},},rules:{"@typescript-eslint/no-floating-promises":"error",},},);

These examples both work fine for me: I can either use the recommend rules OR fully customize my own set of rules.

But, there is no example that explains how to use the recommended rules while customizing a few of them. For example, I would like to use the recommended rules PLUS no-floating-promises=error. I cannot figure out how to. I have tried:

      ...tseslint.config({files:["**/*.ts","**/*.tsx"],extends:[eslint.configs.recommended, ...tseslint.configs.recommended],rules:{"@typescript-eslint/no-floating-promises":"error",},}),

Which gives me the error:

Error: Error while loading rule '@typescript-eslint/no-floating-promises': You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.

I've also tried:

[...tseslint.config(eslint.configs.recommended,  ...tseslint.configs.recommended,{rules:{"@typescript-eslint/no-floating-promises":"error",},}),

Which does not enable the rule.

I have no mental model for whattseslint.config is actually doing so I'm having trouble understand what should/shouldn't work here, but by specifying BOTH recommended configurations it looks like I got what I wanted:

tseslint.config(eslint.configs.recommended,  ...tseslint.configs.recommended,{plugins:{"@typescript-eslint":tseslint.plugin,},languageOptions:{parser:tseslint.parser,parserOptions:{project:true,},},rules:{"@typescript-eslint/no-floating-promises":"error",},},)

If this is how you're meant to accomplish recommended config + customizations, it would be good to document it.

Thanks for listening!

Affected URL(s)

https://typescript-eslint.io/packages/typescript-eslint/

Additional Info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuedocumentationDocumentation ("docs") that needs adding/updating

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp