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

Dont work with Overrides? #9

Open
douglasjunior opened this issue Aug 2, 2022 · 5 comments
Open

Dont work with Overrides? #9

douglasjunior opened this issue Aug 2, 2022 · 5 comments

Comments

@douglasjunior
Copy link

douglasjunior commented Aug 2, 2022

I'm trying to configure "only-warn" for just one directory in my project, using override: https://eslint.org/docs/latest/user-guide/configuring/configuration-files#configuration-based-on-glob-patterns

module.exports = {
  extends: 'eslint-config-foobar',
  overrides: [
    {
      files: ['src/legacy/**/*.*'],
      extends: 'eslint-config-foobar',
      plugins: ['only-warn'],
    },
  ],
};

But, all files outside src/legacy are parsed with only-warn too. 😢

Is there any option for that?

@bfanger
Copy link
Owner

bfanger commented Aug 6, 2022

Interesting use-case, there currently isn't an option for that.

We don't hook into the eslint's official plugin api's (there is no api for us to hook into) so we run as a post verify() step.
Not sure if it possible to know per message if our plugin was enabled.

@douglasjunior
Copy link
Author

My goal is to make "warn" all the ESLint rules inside a specific directory, because this directory have a "legacy" code base.

And I don't want to disable the rules, but break only if we have Errors outside the "legacy" code base.

@infacto
Copy link

infacto commented Jun 14, 2023

Not sure if I should create a new issue... It's about using this plugin in editor only and fail in Git hook or CI. In the editor, the developer plays with the code which can produce eslint errors. To avoid that annoying behavior, the plugin only-warn is great. But for the CI/Git I would handle all as error. Or all just fail on all warnings. In best case the developer should be stopped during commit process. We already use husky/lint-staged ... Any idea?

@douglasjunior
Copy link
Author

@infacto I think that you will need to create two .eslintrc for this.

@infacto
Copy link

infacto commented Jun 23, 2023

Late but for those who are interested: Add parameter --max-warnings=0 may do the job. So I see warnings only in editor but in CLI/git/CI I get an error on first warning. It may not suit all needs. For example, if you still want to exclude certain rules. So extends with a base config, default (for editor) and test for git/ci may help.

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

No branches or pull requests

3 participants