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

Allow extends with multiple config files #19

Open
vinassefranche opened this issue May 17, 2021 · 2 comments
Open

Allow extends with multiple config files #19

vinassefranche opened this issue May 17, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@vinassefranche
Copy link

Hi!
First, thanks for this plugin, it's really useful!

Do you know if there's a possibility to extend the rule if I want to add the ban of a specific function in a folder while keeping the global ban?
The folder structure would be:

.
├── src/
│   ├── folder1/
│   │   └── fileWhereICannotUseFooButCanUseBar.js
│   └── folder2/
│       ├── fileWhereICannotUseFooAndBar.js
│       └── .eslintrc.js
└── .eslintrc.js

The main .eslintrc.js file would be:

module.exports = {
  plugins: ['ban'],
  rules: {
    'ban/ban': [
      'error',
      {
        name: 'foo',
      },
    ],
  },
};

and the one in folder2 would be:

module.exports = {
  rules: {
    'ban/ban': [
      'error',
      {
        name: 'bar',
      },
    ],
  },
};

I know I can put both rules in the second file but I'd like to avoid this so I don't need to update it every time I add something in the first file.

@remithomas
Copy link
Owner

Hello @vinassefranche
Thanks for the encouragement 🙌
This may look like a feature of eslint, are you talking about https://eslint.org/docs/user-guide/configuring/configuration-files#cascading-and-hierarchy ?

@vinassefranche
Copy link
Author

Yes, I think it's linked to this block
image
The config options are not merged when cascading but the last one defined overrides the previous ones. This is a pain as it forces me to re-write all the previously banned methods when I just want to add a new banned method.

I'm not sure it's possible at all but I wanted to know if it was possible to define your rule in a way that would merge the options when cascading.

@remithomas remithomas added the enhancement New feature or request label Jun 25, 2022
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