remithomas / eslint-plugin-ban

Ban some methods and functions
ISC License
31 stars 4 forks source link

Allow extends with multiple config files #19

Open vinassefranche opened 3 years ago

vinassefranche commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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.