eslint-plugin-total-functions
eslint-plugin-total-functions copied to clipboard
An ESLint plugin to enforce the use of total functions (and prevent the use of partial functions) in TypeScript.
* Prevent use of `t.type` unless it is nested within a `t.readonly`. * Prevent use of `t.array`, with fixer to `t.readonlyArray`.
```typescript const x: { readonly a: number } = { a: 1 }; Object.assign(x, { a: 3 }); ``` This should warn, I guess, but it doesn't. Am I missing...
We already bail out early if the type in question is an array. We should do the same for strings, which are only ever immutable. We might get a good...
_NB this issue is distinct from (but related to) #100. That issue is about the return type, this is about the parameter type._ Concatenating a mutable array to another array...
We should report the property name (and the path down through nested properties to get to it) in the eslint error message to make fixing unsafe assignments easier.
As discussed in https://github.com/danielnixon/readonly-types/issues/7, lots of readonly array methods return mutable arrays. An example of this is `concat`. So if you have code like the following very common example, you...
Index signatures lead to all sorts of unsoundness and you're better off using a real [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) in almost every case.
For examples where the RHS is an array or object literal we should be able to automatically fix by appending `as const`. Example: ```ts const foo: ReadonlyArray = ["foo"]; ```...