Question: Is there a way to disable auto-fixing for a subset of rules
pharmpy-dev-123 opened this issue · 6 comments
I like that @typescript-eslint/ban-types
raises errors when running xo
.
I do not like that @typescript-eslint/ban-types
auto-fixes apply when running xo --fix
.
This is because, in my experience, auto-fixing for this rule almost always produces broken source.
Is it possible to configure xo
so that auto-fixing for @typescript-eslint/ban-types
is disabled but rule-violating lines still raise an error?
There's no way to do that. You will have to propose such a change over at https://github.com/eslint/eslint which is what XO uses underneath.
Is it possible to configure xo so that auto-fixing for @typescript-eslint/ban-types is disabled but rule-violating lines still raise an error?
The ban-types
config has the ability to disable the fixers though. Look at the config. You can do so in your own code by overriding it.
Would you disable fixers for all the banned types or just some? If some, which ones? Out of curiosity.
auto-fixing for this rule almost always produces broken source.
Almost any change can break TS types though. At least it fails loudly.
There's no way to do that. You will have to propose such a change over at https://github.com/eslint/eslint which is what XO uses underneath.
OK
The
ban-types
config has the ability to disable the fixers though. Look at the config. You can do so in your own code by overriding it.
I will look into it, that looks like a solution to my problem.
Would you disable fixers for all the banned types or just some? If some, which ones? Out of curiosity.
A priori, all of them. I have problems with null
being partially fixed to undefined
producing broken source that is later caught by TypeScript.
NB: Naively configuring @typescript-eslint/ban-types
does not work. I get the following errors when trying to lint non-TypeScript file.
/home/runner/work/amdui/amdui/gatsby-config.js: line 1, col 1, Error - Definition for rule '@typescript-eslint/ban-types' was not found. (@typescript-eslint/ban-types)
/home/runner/work/amdui/amdui/lint-staged.config.js: line 1, col 1, Error - Definition for rule '@typescript-eslint/ban-types' was not found. (@typescript-eslint/ban-types)
I think I need to be more specific about the files this rule covers.
@pharmpy-dev-123 just try this: eslint-plugin-no-autofix
eslint’s solution for this is to set the rule as a warning instead: eslint/eslint#8935
I don’t think XO can effectively do this outside ESLint unfortunately.