muenzpraeger / eslint-plugin-inclusive-language

An ESLint plugin to raise awareness for using inclusive language not only in your codebase, but in life.
MIT License
57 stars 9 forks source link

Suggestion: option to disable autofixing #26

Closed sharmilajesupaul closed 3 years ago

sharmilajesupaul commented 3 years ago

I love the idea of this plugin, thank you for making it.

We want to use this rule at Airbnb but there are several cases where auto-fixing problems might not be safe. So we'd like to option to disable the auto-fix if possible.

Some examples are non-inclusive terms that may be a part of API calls or rely on references outside of a given file such as named imports. Since we recommend enabling auto-fixing on save in editors, an engineer could save a file and unintentionally introduce bugs due to the result of an autofix.

For example:

If the rule defined config is:

  'inclusive-language/use-inclusive-words': [
    'warn',
    {
      words: [{ word: 'whitelist', suggestions: ['allowlist', 'allowed'] },
    }
  ]

a named import from a module like this:

import { whiteListFoo } from 'bar';

will be fixed to:

import { allowlistFoo } from 'bar';

Similarly, API request code that might look like:

   axios.post({
      baseURL: 'https://api.foo.com/',
     // ...
     data: { whitelist:  [ ] }
    });

will be fixed to:

   axios.post({
      baseURL: 'https://api.foo.com/',
     // ...
     data: { allowlist:  [ ] }
    });

In both of these cases, the resulting code from the autofix might introduce bugs. Could we add a configuration option like "autofix": false that we can use to disable the autofix on this rule?

github-actions[bot] commented 3 years ago

Welcome! 👋

Thanks you for creating the issue. 🙌 I will come back to this as soon as possible.

sharmilajesupaul commented 3 years ago

Also happy to submit a PR if you'll accept it! Thanks!

lencioni commented 3 years ago

It might also be worth considering removing autofix entirely, or making it explicitly opt-in instead of opt-out, since it is likely unsafe to autofix this in general.

muenzpraeger commented 3 years ago

Thanks for the suggestions - very much appreciated!

Just released v2.1.0 that switched autofix to opt-in.