enforce dot notation whenever possible (dot-notation)

Rule Details

This rule extends the base eslint/dot-notation rule. It adds support for optionally ignoring computed private member access.

How to use

{
  // note you must disable the base rule as it can report incorrect errors
  "dot-notation": "off",
  "@typescript-eslint/dot-notation": ["error"]
}

Options

See eslint/dot-notation options. This rule adds the following options:

interface Options extends BaseDotNotationOptions {
  allowPrivateClassPropertyAccess?: boolean;
}
const defaultOptions: Options = {
  ...baseDotNotationDefaultOptions,
  allowPrivateClassPropertyAccess: false,
};

allowPrivateClassPropertyAccess

Example of a correct code when allowPrivateClassPropertyAccess is set to true

class X {
  private priv_prop = 123;
}

const x = new X();
x['priv_prop'] = 123;

Taken with ❤️ from ESLint core