From 2edd0af76e7b5b78c35b1427dea91de58d730e19 Mon Sep 17 00:00:00 2001 From: Shahar Dawn Or Date: Wed, 14 Dec 2022 14:24:26 +0700 Subject: [PATCH] feat: add rule consistent-indexed-object-style BREAKING CHANGE: add rule consistent-indexed-object-style --- src/index.test.ts | 1 + src/index.ts | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/index.test.ts b/src/index.test.ts index 17367009..18e5c399 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -95,6 +95,7 @@ test('export', (t): void => { tuples: 'ignore' }], '@typescript-eslint/comma-spacing': ['error', { before: false, after: true }], + '@typescript-eslint/consistent-indexed-object-style': ['error', 'record'], '@typescript-eslint/consistent-type-assertions': [ 'error', { diff --git a/src/index.ts b/src/index.ts index 30d3f369..9bf5a33e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -34,8 +34,8 @@ const ruleFromStandard = (name: string): Linter.RuleEntry => { return JSON.parse(JSON.stringify(rule)) } -function fromEntries (iterable: Array<[string, T]>): { [key: string]: T } { - return [...iterable].reduce<{ [key: string]: T }>((obj, [key, val]) => { +function fromEntries (iterable: Array<[string, T]>): Record { + return [...iterable].reduce>((obj, [key, val]) => { obj[key] = val return obj }, {}) @@ -82,6 +82,7 @@ const config: Linter.Config = { generics: 'ignore', tuples: 'ignore' }], + '@typescript-eslint/consistent-indexed-object-style': ['error', 'record'], '@typescript-eslint/consistent-type-assertions': [ 'error', {