eslint-plugin-functional
eslint-plugin-functional copied to clipboard
Autofix on TypeScript mapped types with `-readonly` cause syntax error
Bug Report
I have the following code:
export type Writable<T> = {
-readonly [K in keyof T]: T[K];
};
ESLint reports "functional/prefer-readonly-type" rule and an option to "--fix" it.
Expected behavior
Autofix should remove -:
export type Writable<T> = {
readonly [K in keyof T]: T[K];
};
Actual behavior
Autofix creates a syntax error:
export type Writable<T> = { readonly
-readonly [K in keyof T]: T[K];
};
Steps to reproduce
ESLint config:
{
// ...
plugins: [
// ...
'functional',
// ...
],
extends: [
// ...
"plugin:functional/external-recommended",
"plugin:functional/recommended",
"plugin:functional/no-object-orientation",
"plugin:functional/no-statements",
"plugin:functional/no-exceptions",
"plugin:functional/currying",
"plugin:functional/stylistic",
// ...
],
// ...
}
Proposed changes
Either disable autofix for -readonly, or hande it properly.
See https://github.com/microsoft/TypeScript/pull/21919
I believe the correct behavior should be for it to not try and auto fix this at all.