eslint-plugin-total-functions
eslint-plugin-total-functions copied to clipboard
[no-unsafe-mutable-readonly-assignment] add fixer
For examples where the RHS is an array or object literal we should be able to automatically fix by appending as const
.
Example:
const foo: ReadonlyArray<string> = ["foo"];
Should be automatically fixable to this:
const foo: ReadonlyArray<string> = ["foo"] as const;
This fixer would only work if all properties on LHS are readonly, recursively. Otherwise the as const
RHS after fixing would fall afoul of the inverse rule: unsafe readonly -> mutable assignment.
We should be able to detect that and only enable the fixer when the LHS in entirely readonly.