-
-
Notifications
You must be signed in to change notification settings - Fork 168
Description
I have the following jsdoc comment to type a shared set of eslint rule overrides:
/** @type { import('@typescript-eslint/utils').TSESLint.FlatConfig.Config['rules'] } */
Here TSESLint
, FlatConfig
and Config
are namespaces, whereas ['rules']
is a property of Config
.
With propertyQuotes: 'null'
(the default) it complaints about the quotes around rules
- but these quotes are required, since rules
is a string literal and properties require bracket notation (as far as I know).
With propertyQuotes: 'single'
or propertyQuotes: 'double'
, it complains about the lack of quotes around TSESLint
, FlatConfig
and Config
- but these are namespaces, which require dot notation (as far as I know).
I think this rule is treating the syntax like properties in JavaScript, where dot notation and bracket notation are often interchangeable - but in types, they have a different purpose.
While on the subject: Even in JavaScript, I wouldn't necessarily conflate dot notation versus bracket notation with the preferred quote style. Bracket notation is a choice between "as needed" or "always", whereas quote style often has the following options:
- "single": Always use
'
quotes - "double": Always use
"
quotes - "prefer-single": Prefer
'
, use"
if it reduces the number of needed backslash escapes - "prefer-double": Prefer
"
, use'
if it reduces the number of needed backslash escapes
And maybe something for using/preferring `
-style quotes, though that's less common.
Some references: