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

fix(eslint): flat config support #51

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Update eslint-plugin/README.md
Co-authored-by: Maxime Malgorn <9255967+utarwyn@users.noreply.github.com>
  • Loading branch information
AMorgaut and utarwyn authored Oct 16, 2024
commit d667571459eeaa7e99a7f6b66d2a5d7d3553953c
2 changes: 1 addition & 1 deletion eslint-plugin/README.md
Original file line number Diff line number Diff line change
@@ -65,7 +65,7 @@ Add `@ecocode` **"recommended"** configuration to `extends` section of your `.es

#### With modern `eslint.config.js`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ESLint documentation talks about "flat configurations", so I think we can keep this term to remain consistent.

Suggested change
#### With modern `eslint.config.js`
#### With modern flat configuration

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure on that one

I think you might be right for new projects from scratch, but for existing projects and projects generated by framework generators (Nx, Angular, preact, Vue, ...) that still generate project with previous eslint configurations (which is what happened to ecocode-dashboard), it it really not obvious, and actually, it took me some time to figure out about the new eslint "flat config". What you first see when you want to add a plugin to your project is the name of your eslint configuration file

I based this part of the documentation on what I saw on another eslint plugin and which looked cristal clear to apply.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure from which plugin I originally took it but the playwright one use both "flat config" and the file name to describe how to add it. It looks to be a good compromise

Flat config (eslint.config.js)
...

Legacy config (.eslintrc)
...

https://github.com/playwright-community/eslint-plugin-playwright/blob/main/README.md

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the feedback! I think this is a great idea, we can go for it 💯


Add the `ecocode` plugin configuration to your `eslint.config.js` and select the rules to activate:
Add the `ecocode` plugin configuration to your `eslint.config.js` and select the rules to activate:

```js
import ecocode from '@ecocode/eslint-plugin'