Skip to content

Commit bb70eb9

Browse files
committed
fix(typescript): Enable auto-fix for ban-types 'object' case
1 parent c05d872 commit bb70eb9

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

packages/eslint-config-zillow-typescript/rules/recommended.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,22 @@ module.exports = {
2020
],
2121

2222
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/ban-types.md
23-
'@typescript-eslint/ban-types': 'error',
23+
'@typescript-eslint/ban-types': [
24+
'error',
25+
{
26+
extendDefaults: true,
27+
types: {
28+
// make default 'object' rule fixable
29+
object: {
30+
fixWith: 'Record<string, unknown>',
31+
message: [
32+
'The `object` type is currently hard to use ([see this issue](https://github.com/microsoft/TypeScript/issues/21732)).',
33+
'Consider using `Record<string, unknown>` instead, as it allows you to more easily inspect and use the keys.',
34+
].join('\n'),
35+
},
36+
},
37+
},
38+
],
2439

2540
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md
2641
'@typescript-eslint/explicit-module-boundary-types': [

packages/eslint-plugin-zillow/test/__snapshots__/eslint-plugin-zillow.test.js.snap

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3054,6 +3054,16 @@ Object {
30543054
],
30553055
"zillow/@typescript-eslint/ban-types": Array [
30563056
"error",
3057+
Object {
3058+
"extendDefaults": true,
3059+
"types": Object {
3060+
"object": Object {
3061+
"fixWith": "Record<string, unknown>",
3062+
"message": "The \`object\` type is currently hard to use ([see this issue](https://github.com/microsoft/TypeScript/issues/21732)).
3063+
Consider using \`Record<string, unknown>\` instead, as it allows you to more easily inspect and use the keys.",
3064+
},
3065+
},
3066+
},
30573067
],
30583068
"zillow/@typescript-eslint/brace-style": Array [
30593069
"off",

0 commit comments

Comments
 (0)