Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(eslint-plugin): [consistent-indexed-object-style] convert readonly index signature to readonly record #2798

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -46,6 +46,14 @@ Examples of **correct** code with `record` option.

```ts
type Foo = Record<string, unknown>;

interface Foo {
readonly [key: string]: unknown;
}

type Foo = {
readonly [key: string]: unknown;
};
```

Examples of **incorrect** code with `index-signature` option.
Expand Down
Expand Up @@ -76,6 +76,10 @@ export default createRule<Options, MessageIds>({
return;
}

if (member.readonly) {
return;
}

const [parameter] = member.parameters;

if (!parameter) {
Expand Down
Expand Up @@ -51,6 +51,18 @@ type Foo = {
};
`,

// Readonly
`
interface Foo {
readonly [key: string]: any;
}
`,
`
type Foo = {
readonly [key: string]: any;
};
`,

// Generic
`
type Foo = Generic<{
Expand Down