From 8aed443da3dfe53145b799ce6f05898a5022d397 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Tue, 13 Aug 2019 09:36:26 -0700 Subject: [PATCH] feat(eslint-plugin): [ban-types] tighten defaults `Record` 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` 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 --- packages/eslint-plugin/src/rules/ban-types.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/eslint-plugin/src/rules/ban-types.ts b/packages/eslint-plugin/src/rules/ban-types.ts index d15d822de06..53b8f3d7920 100644 --- a/packages/eslint-plugin/src/rules/ban-types.ts +++ b/packages/eslint-plugin/src/rules/ban-types.ts @@ -102,8 +102,12 @@ export default util.createRule({ fixWith: 'number', }, Object: { - message: 'Use Record instead', - fixWith: 'Record', + message: 'Object is not type safe, use Record instead', + fixWith: 'Record', + }, + object: { + message: 'Object is not type safe, use Record instead', + fixWith: 'Record', }, Symbol: { message: 'Use symbol instead',