fix: prefer #eq? for checking equality with one string (#8246)

This commit is contained in:
Riley Bruins
2025-10-29 18:51:42 -07:00
committed by GitHub
parent 9ddd853e7e
commit 2c30e515eb
9 changed files with 19 additions and 15 deletions

View File

@@ -185,6 +185,10 @@
"type": "string",
"arity": "required"
},
{
"type": "string",
"arity": "required"
},
{
"type": "string",
"arity": "variadic"

View File

@@ -79,7 +79,7 @@
; Repeats
((symbol) @keyword.repeat
(#any-of? @keyword.repeat "each"))
(#eq? @keyword.repeat "each"))
; Operators
((symbol) @operator

View File

@@ -137,7 +137,7 @@
((argument) @_cache @keyword.modifier
.
(argument) @_type @type
(#any-of? @_cache "CACHE")
(#eq? @_cache "CACHE")
(#any-of? @_type "BOOL" "FILEPATH" "PATH" "STRING" "INTERNAL"))))
(normal_command

View File

@@ -55,7 +55,7 @@
; Comment
((sym_lit) @comment
(#any-of? @comment "comment"))
(#eq? @comment "comment"))
; Special forms and builtin macros
;

View File

@@ -266,7 +266,7 @@
(begin
name: (curly_group_text
(text) @label)
(#any-of? @label "frame"))
(#eq? @label "frame"))
.
(curly_group
(_) @markup.heading))

View File

@@ -55,7 +55,7 @@
; ========
(pool
name: (identifier) @type.builtin
(#any-of? @type.builtin "console"))
(#eq? @type.builtin "console"))
(build
rule: (identifier) @function.builtin

View File

@@ -54,29 +54,29 @@
(#any-of? @markup.italic "i" "em"))
((tag_name) @markup.link
(#any-of? @markup.link "a"))
(#eq? @markup.link "a"))
; Headings
((tag_name) @markup.heading
(#any-of? @markup.heading "header"))
(#eq? @markup.heading "header"))
((tag_name) @markup.heading.1
(#any-of? @markup.heading.1 "h1"))
(#eq? @markup.heading.1 "h1"))
((tag_name) @markup.heading.2
(#any-of? @markup.heading.2 "h2"))
(#eq? @markup.heading.2 "h2"))
((tag_name) @markup.heading.3
(#any-of? @markup.heading.3 "h3"))
(#eq? @markup.heading.3 "h3"))
((tag_name) @markup.heading.4
(#any-of? @markup.heading.4 "h4"))
(#eq? @markup.heading.4 "h4"))
((tag_name) @markup.heading.5
(#any-of? @markup.heading.5 "h5"))
(#eq? @markup.heading.5 "h5"))
((tag_name) @markup.heading.6
(#any-of? @markup.heading.6 "h6"))
(#eq? @markup.heading.6 "h6"))
((tag_name) @markup.list
(#any-of? @markup.list "ul" "ol" "li" "dl" "dt" "dd"))

View File

@@ -327,7 +327,7 @@ port_name: (simple_identifier) @variable
(method_call_body
arguments: (list_of_arguments
(expression) @variable.builtin
(#any-of? @variable.builtin "this")))
(#eq? @variable.builtin "this")))
(implicit_class_handle) @variable.builtin

View File

@@ -27,7 +27,7 @@
(#eq? @type.builtin "terraform"))
(get_attr
(identifier) @variable.builtin
(#any-of? @variable.builtin "workspace")))
(#eq? @variable.builtin "workspace")))
; Terraform specific keywords
; FIXME: ideally only for identifiers under a `variable` block to minimize false positives