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

Simplify/enable easy rules overrides #255

Closed
3 tasks done
AlexandreBonaventure opened this issue Sep 26, 2023 · 2 comments
Closed
3 tasks done

Simplify/enable easy rules overrides #255

AlexandreBonaventure opened this issue Sep 26, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@AlexandreBonaventure
Copy link

AlexandreBonaventure commented Sep 26, 2023

Clear and concise description of the problem

I recently wanted to migrate our eslint setup to use the new flat config (because it's the best :) ). Found your config in the perfect timing. We're building vite powered vue+ts app so most of your defaults suit us very well, but we have a couple opinionated rules that I'd like to modify. I was surprised that it was not as easy as I thought with the new flat config system for language scope rules.

Here's a minimal repro that is highlighting my problem:
https://stackblitz.com/edit/stackblitz-starters-bcd913?file=eslint.config.js

Trying to override a TS rule to meet my requirements as such:
'ts/consistent-type-definitions': ['error', 'type'],
Running eslint throws this error:
image

It seems like you can get around by making to specify the files pattern to ensure eslint is able to validate against a config that has the rule. see in the repro:
image

This is not ideal and was hoping that I wouldn't have to do this. Here, I copy pasted the GLOB from your sources.

Suggested solution

I believe we're all fairly new and not super familiar yet with flat config, so I am not 100% sure it is expected from eslint perspective (let me know if not). Assuming yes, I'm thinking this repo could provide api/recipe to ease the process of overriding specific rules.

Thinking about 2 possible solutions:

  • allow to pass options in each tree-shaken config that will be merged
    eg:
  // eslint.config.js
  export default [
  ...typescript({
       rules: { 'ts/consistent-type-definitions': ['error', 'type'],  }
  }),
  ...vue(),
]
  • export glob const so that we can at least reuse? (not a big fan of this one)

Alternative

No response

Additional context

ps: Thanks for your work. I'm a big fan of unocss, just started sponsoring you :)

Validations

@AlexandreBonaventure AlexandreBonaventure added the enhancement New feature or request label Sep 26, 2023
@antfu
Copy link
Owner

antfu commented Sep 26, 2023

Made 6a72bf5, 05073cd and 3935399 should make it easier.

@antfu antfu closed this as completed in 3935399 Sep 26, 2023
@AlexandreBonaventure
Copy link
Author

that was fast :D thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants