src/content/docs/linter/rules/use-literal-keys.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> ## Summary - Rule available since: `v1.0.0` - Diagnostic Category: [`lint/complexity/useLiteralKeys`](/reference/diagnostics#diagnostic-category) - This rule is **recommended**, meaning it is enabled by default. - This rule has an [**unsafe**](/linter/#unsafe-fixes) fix. - The default severity of this rule is [**information**](/reference/diagnostics#information). - Sources: - Same as [`dot-notation`](https://eslint.org/docs/latest/rules/dot-notation) - Same as [`no-useless-computed-key`](https://eslint.org/docs/latest/rules/no-useless-computed-key) - Same as [`@typescript-eslint/dot-notation`](https://typescript-eslint.io/rules/dot-notation){
"linter": {
"rules": {
"complexity": {
"useLiteralKeys": "error"
}
}
}
}
Enforce the usage of a literal access to properties over computed property access.
a.b["c"];
a.c[`d`]
a.c[`d`] = "something"
a = {
['b']: d
}
a["c" + "d"];
a[d.c];