[Refactor] Prefer includes over indexOf -1 (#646)

Enables ESLint auto-fix rule.
This commit is contained in:
filtered
2025-02-28 19:53:29 +11:00
committed by GitHub
parent 7b19abf83a
commit b4688e18f9
3 changed files with 4 additions and 5 deletions

View File

@@ -71,7 +71,6 @@ export default tseslint.config(
"unicorn/prefer-structured-clone": "off",
"unicorn/prefer-switch": "off",
"unicorn/prefer-ternary": "off",
"unicorn/prefer-includes": "off",
// Disable rules
"unicorn/consistent-function-scoping": "off",

View File

@@ -836,7 +836,7 @@ export class LGraphCanvas implements ConnectionColorContext {
: base_category + category_name + "/"
let name = category_name
if (name.indexOf("::") != -1)
if (name.includes("::"))
// in case it has a namespace like "shader::math/rand" it hides the namespace
name = name.split("::")[1]
@@ -6493,8 +6493,8 @@ export class LGraphCanvas implements ConnectionColorContext {
if (filter && ctor.filter != filter) return false
if (
(!options.show_all_if_empty || str) &&
type.toLowerCase().indexOf(str) === -1 &&
(!ctor.title || ctor.title.toLowerCase().indexOf(str) === -1)
!type.toLowerCase().includes(str) &&
(!ctor.title || !ctor.title.toLowerCase().includes(str))
) {
return false
}

View File

@@ -613,7 +613,7 @@ export class LiteGraphGlobal {
type_b = type_b.toLowerCase()
// For nodes supporting multiple connection types
if (type_a.indexOf(",") == -1 && type_b.indexOf(",") == -1)
if (!type_a.includes(",") && !type_b.includes(","))
return type_a == type_b
// Check all permutations to see if one is valid