Hi! It looks like the auto fix on save doesn't work for TypeScript files. JavaScript seems to be fine.
{
"parser": "typescript-eslint-parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"modules": true,
"jsx": true
}
},
"rules": {
"spaced-comment": ["error", "always"]
}
}
{
"eslint.autoFixOnSave": true,
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
]
}
//foo
This will be fixed in a .js file, but not in a .ts file. The error is shown in both cases correctly.
You need to tell ESLint to enable autoFix for TS. This can be done like this:
{
"eslint.autoFixOnSave": true,
"eslint.validate": [
"javascript",
"javascriptreact",
{"language": "typescript", "autoFix": true },
{"language": "typescriptreact", "autoFix": true }
]
}
AutoFix is only enabled by default for JS. There were quite some problems with parser and autofix computing wrong fixes and therefore breaking the code. So I made this an opt in.
Most helpful comment
You need to tell ESLint to enable autoFix for TS. This can be done like this:
AutoFix is only enabled by default for JS. There were quite some problems with parser and autofix computing wrong fixes and therefore breaking the code. So I made this an opt in.