Skip to content

Commit

Permalink
feat(eslint-plugin): [ban-types] tighten defaults
Browse files Browse the repository at this point in the history
`Record<string, any>` is not typesafe, so we shouldn't suggest it as the default fixer.
Additionally, using `any` causes errors via the `no-explicit-any` rule.

`Record<string, unknown>` is safe because you have to use type guards to actually use the value.
Also add handling for `object`; it wasn't added because I didn't think about the fact that it's not fixing `Object` -> `object` like the rest of the fixers.

Fixes #842
  • Loading branch information
bradzacher committed Jan 13, 2020
1 parent 9eab26f commit 8aed443
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/eslint-plugin/src/rules/ban-types.ts
Expand Up @@ -102,8 +102,12 @@ export default util.createRule<Options, MessageIds>({
fixWith: 'number',
},
Object: {
message: 'Use Record<string, any> instead',
fixWith: 'Record<string, any>',
message: 'Object is not type safe, use Record<string, unknown> instead',
fixWith: 'Record<string, unknown>',
},
object: {
message: 'Object is not type safe, use Record<string, unknown> instead',
fixWith: 'Record<string, unknown>',
},
Symbol: {
message: 'Use symbol instead',
Expand Down

0 comments on commit 8aed443

Please sign in to comment.