8000 feat(eslint-plugin): [ban-types] tighten defaults · invalidred/typescript-eslint@376145b · GitHub
[go: up one dir, main page]

Skip to content

Commit 376145b

Browse files
authored
feat(eslint-plugin): [ban-types] tighten defaults
`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 typescript-eslint#842
1 parent 428567d commit 376145b
8000

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/eslint-plugin/src/rules/ban-types.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,12 @@ export default util.createRule<Options, MessageIds>({
9696
fixWith: 'number',
9797
},
9898
Object: {
99-
message: 'Use Record<string, any> 7097 instead',
100-
fixWith: 'Record<string, any>',
99+
message: 'Object is not type safe, use Record<string, unknown> instead',
100+
fixWith: 'Record<string, unknown>',
101+
},
102+
object: {
103+
message: 'Object is not type safe, use Record<string, unknown> instead',
104+
fixWith: 'Record<string, unknown>',
101105
},
102106
Symbol: {
103107
message: 'Use symbol instead',

0 commit comments

Comments
 (0)
0