dot-notation.md
1.42 KB
dot-notation
)
enforce dot notation whenever possible (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;
allowProtectedClassPropertyAccess?: boolean;
}
const defaultOptions: Options = {
...baseDotNotationDefaultOptions,
allowPrivateClassPropertyAccess: false,
allowProtectedClassPropertyAccess: 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;
allowProtectedClassPropertyAccess
Example of a correct code when allowProtectedClassPropertyAccess
is set to true
class X {
protected protected_prop = 123;
}
const x = new X();
x['protected_prop'] = 123;
Taken with ❤️ from ESLint core