close

dot-notation

Configuration

rslint.config.ts
import { defineConfig, ts } from '@rslint/core';

export default defineConfig([
  ts.configs.recommended,
  {
    rules: {
      '@typescript-eslint/dot-notation': 'error',
    },
  },
]);

Rule Details

Enforce dot notation whenever possible. This is the TypeScript-enhanced version of the ESLint dot-notation rule. Dot notation is generally preferred over bracket notation for readability. The TypeScript version adds options to allow bracket notation for private/protected class members and index signature properties.

The rule provides autofixes to convert bracket notation (obj["prop"]) to dot notation (obj.prop) when safe.

Examples of incorrect code for this rule:

const x = obj['foo'];
const y = obj['bar'];

Examples of correct code for this rule:

const x = obj.foo;
const y = obj.bar;
const z = obj['some-kebab-case']; // not a valid identifier
const w = obj[dynamicKey]; // computed access

Original Documentation