sindresorhus/eslint-plugin-unicorn

Do you want to work on this issue?

You can request for a bounty in order to promote it!

Add `{fix: false}` option to all rules #1770

fisker posted onGitHub

Many of our rules are not 100% safe to fix code, we can add option to disable fix for every rule.

To disable fix for one rule

{
    rules: {
        'unicorn/better-regex': ['error, {fix: false}]
    }
}

To disable fix for all rules use settings:

{
    settings: {
        unicorn: {
            fix: false,
        }
    }
}

It's not hard to implement because our rule all load by this function https://github.com/sindresorhus/eslint-plugin-unicorn/blob/c501243e7f9fb012b09a69ffc4ab66fb3376bb7d/rules/utils/rule.js#L115


I think this should be done in ESLint instead. It makes no sense for all third-party rules to implement this manually. It could be useful for built-in rules too. I would at least recommend opening an ESLint issue about it first.

posted by sindresorhus over 2 years ago

If we were to do this here, I would prefer not littering each rule config with such option. Maybe this:

{
    settings: {
        unicorn: {
            fix: {
                'unicorn/no-abusive-eslint-disable': false
            }
        }
    }
}
posted by sindresorhus over 2 years ago

Fund this Issue

$0.00
Funded
Only logged in users can fund an issue

Pull requests