@@ -102,6 +102,10 @@ func checkNode(ctx rule.RuleContext, node *ast.Node, opts DotNotationOptions, al
102
102
case ast .KindStringLiteral :
103
103
propertyName = argument .AsStringLiteral ().Text
104
104
isValidProperty = true
105
+ case ast .KindNoSubstitutionTemplateLiteral :
106
+ // Handle `obj[`foo`]` (no expressions)
107
+ propertyName = argument .AsNoSubstitutionTemplateLiteral ().Text
108
+ isValidProperty = true
105
109
case ast .KindNumericLiteral :
106
110
// Numeric properties should use bracket notation
107
111
return
@@ -159,7 +163,14 @@ func checkPropertyAccessKeywords(ctx rule.RuleContext, node *ast.Node) {
159
163
}
160
164
161
165
propertyName := name .AsIdentifier ().Text
162
- if isReservedWord (propertyName ) {
166
+ // Align with typescript-eslint behavior: do not flag some identifiers even when allowKeywords is false
167
+ skipKeywords := map [string ]bool {
168
+ "arguments" : true ,
169
+ "let" : true ,
170
+ "yield" : true ,
171
+ "eval" : true ,
172
+ }
173
+ if isReservedWord (propertyName ) && ! skipKeywords [propertyName ] {
163
174
ctx .ReportNodeWithFixes (node , rule.RuleMessage {
164
175
Id : "useBrackets" ,
165
176
Description : fmt .Sprintf (".%s is a syntax error." , propertyName ),
@@ -196,10 +207,14 @@ func shouldAllowBracketNotation(ctx rule.RuleContext, node *ast.Node, propertyNa
196
207
}
197
208
}
198
209
199
- // If allowIndexSignaturePropertyAccess is true, check for actual index signatures
210
+ // If allowIndexSignaturePropertyAccess is true, allow bracket only when there is NO named property,
211
+ // but the type has an applicable index signature.
200
212
if allowIndexSignaturePropertyAccess {
201
- if hasIndexSignature (ctx , objectType ) {
202
- return true
213
+ // If there is a named property, prefer dot notation
214
+ if sym := ctx .TypeChecker .GetPropertyOfType (objectType , propertyName ); sym == nil {
215
+ if hasIndexSignature (ctx , objectType ) {
216
+ return true
217
+ }
203
218
}
204
219
}
205
220
0 commit comments