diff --git a/.eslintrc.js b/.eslintrc.js index 65d12fbab7..7d9a788fe8 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -104,6 +104,15 @@ module.exports = { // NOTE: If you add more rules, add the tests to eslint-local-rules/noRestrictedSyntax.ts ], + // We want to have a default case to check for `never` + "@typescript-eslint/switch-exhaustiveness-check": [ + "error", + { + allowDefaultCaseForExhaustiveSwitch: true, + requireDefaultForNonUnion: true, + }, + ], + // Rules that depend on https://github.com/pixiebrix/pixiebrix-extension/issues/775 "@typescript-eslint/restrict-template-expressions": [ "error", diff --git a/package-lock.json b/package-lock.json index 0e6edd3a8f..47f0d4441f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -231,7 +231,7 @@ "css-minimizer-webpack-plugin": "^6.0.0", "dotenv": "^16.4.5", "eslint": "^8.57.0", - "eslint-config-pixiebrix": "^0.34.1", + "eslint-config-pixiebrix": "^0.36.2", "eslint-plugin-local-rules": "^2.0.1", "fake-indexeddb": "^5.0.2", "identity-obj-proxy": "^3.0.0", @@ -5317,6 +5317,177 @@ "eslint": "^8.3.0" } }, + "node_modules/@shopify/eslint-plugin/node_modules/@typescript-eslint/eslint-plugin": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.21.0.tgz", + "integrity": "sha512-oy9+hTPCUFpngkEZUSzbf9MxI65wbKFoQYsgPdILTfbUldp5ovUuphZVe4i30emU9M/kP+T64Di0mxl7dSw3MA==", + "dev": true, + "dependencies": { + "@eslint-community/regexpp": "^4.5.1", + "@typescript-eslint/scope-manager": "6.21.0", + "@typescript-eslint/type-utils": "6.21.0", + "@typescript-eslint/utils": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0", + "debug": "^4.3.4", + "graphemer": "^1.4.0", + "ignore": "^5.2.4", + "natural-compare": "^1.4.0", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^6.0.0 || ^6.0.0-alpha", + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@shopify/eslint-plugin/node_modules/@typescript-eslint/scope-manager": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.21.0.tgz", + "integrity": "sha512-OwLUIWZJry80O99zvqXVEioyniJMa+d2GrqpUTqi5/v5D5rOrppJVBPa0yKCblcigC0/aYAzxxqQ1B+DS2RYsg==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@shopify/eslint-plugin/node_modules/@typescript-eslint/type-utils": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.21.0.tgz", + "integrity": "sha512-rZQI7wHfao8qMX3Rd3xqeYSMCL3SoiSQLBATSiVKARdFGCYSRvmViieZjqc58jKgs8Y8i9YvVVhRbHSTA4VBag==", + "dev": true, + "dependencies": { + "@typescript-eslint/typescript-estree": "6.21.0", + "@typescript-eslint/utils": "6.21.0", + "debug": "^4.3.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@shopify/eslint-plugin/node_modules/@typescript-eslint/types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.21.0.tgz", + "integrity": "sha512-1kFmZ1rOm5epu9NZEZm1kckCDGj5UJEf7P1kliH4LKu/RkwpsfqqGmY2OOcUs18lSlQBKLDYBOGxRVtrMN5lpg==", + "dev": true, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@shopify/eslint-plugin/node_modules/@typescript-eslint/typescript-estree": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.21.0.tgz", + "integrity": "sha512-6npJTkZcO+y2/kr+z0hc4HwNfrrP4kNYh57ek7yCNlrBjWQ1Y0OS7jiZTkgumrvkX5HkEKXFZkkdFNkaW2wmUQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "minimatch": "9.0.3", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@shopify/eslint-plugin/node_modules/@typescript-eslint/utils": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.21.0.tgz", + "integrity": "sha512-NfWVaC8HP9T8cbKQxHcsJBY5YE1O33+jpMwN45qzWWaPDZgLIbo12toGMWnmhvCpd3sIxkpDw3Wv1B3dYrbDQQ==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@types/json-schema": "^7.0.12", + "@types/semver": "^7.5.0", + "@typescript-eslint/scope-manager": "6.21.0", + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/typescript-estree": "6.21.0", + "semver": "^7.5.4" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "node_modules/@shopify/eslint-plugin/node_modules/@typescript-eslint/visitor-keys": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.21.0.tgz", + "integrity": "sha512-JJtkDduxLi9bivAB+cYOVMtbkqdPOhZ+ZI5LC47MIRrDV4Yn2o+ZnW10Nkmr28xRpSpdJ6Sm42Hjf2+REYXm0A==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.21.0", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@shopify/eslint-plugin/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, "node_modules/@shopify/eslint-plugin/node_modules/doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", @@ -5341,6 +5512,21 @@ "eslint": ">=7.0.0" } }, + "node_modules/@shopify/eslint-plugin/node_modules/minimatch": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/@shopify/jest-dom-mocks": { "version": "5.0.0", "integrity": "sha512-Ol/DJZqCZhzUI2hYZILwHTwcLNaqlTs+pxnkEPkVLvyQt0jXkGPen6z7Xm7B5QKJTKy2Qrerx0ECSQmhqSuAUA==", @@ -8708,16 +8894,16 @@ "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "6.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.10.0.tgz", - "integrity": "sha512-uoLj4g2OTL8rfUQVx2AFO1hp/zja1wABJq77P6IclQs6I/m9GLrm7jCdgzZkvWdDCQf1uEvoa8s8CupsgWQgVg==", + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.0.2.tgz", + "integrity": "sha512-/XtVZJtbaphtdrWjr+CJclaCVGPtOdBpFEnvtNf/jRV0IiEemRrL0qABex/nEt8isYcnFacm3nPHYQwL+Wb7qg==", "dev": true, "dependencies": { "@eslint-community/regexpp": "^4.5.1", - "@typescript-eslint/scope-manager": "6.10.0", - "@typescript-eslint/type-utils": "6.10.0", - "@typescript-eslint/utils": "6.10.0", - "@typescript-eslint/visitor-keys": "6.10.0", + "@typescript-eslint/scope-manager": "7.0.2", + "@typescript-eslint/type-utils": "7.0.2", + "@typescript-eslint/utils": "7.0.2", + "@typescript-eslint/visitor-keys": "7.0.2", "debug": "^4.3.4", "graphemer": "^1.4.0", "ignore": "^5.2.4", @@ -8733,8 +8919,8 @@ "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "@typescript-eslint/parser": "^6.0.0 || ^6.0.0-alpha", - "eslint": "^7.0.0 || ^8.0.0" + "@typescript-eslint/parser": "^7.0.0", + "eslint": "^8.56.0" }, "peerDependenciesMeta": { "typescript": { @@ -8868,7 +9054,7 @@ "eslint": "^8.56.0" } }, - "node_modules/@typescript-eslint/rule-tester/node_modules/@typescript-eslint/scope-manager": { + "node_modules/@typescript-eslint/scope-manager": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.0.2.tgz", "integrity": "sha512-l6sa2jF3h+qgN2qUMjVR3uCNGjWw4ahGfzIYsCtFrQJCjhbrDPdiihYT8FnnqFwsWX+20hK592yX9I2rxKTP4g==", @@ -8885,32 +9071,15 @@ "url": "https://opencollective.com/typescript-eslint" } }, - "node_modules/@typescript-eslint/rule-tester/node_modules/@typescript-eslint/types": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.0.2.tgz", - "integrity": "sha512-ZzcCQHj4JaXFjdOql6adYV4B/oFOFjPOC9XYwCaZFRvqN8Llfvv4gSxrkQkd2u4Ci62i2c6W6gkDwQJDaRc4nA==", - "dev": true, - "engines": { - "node": "^16.0.0 || >=18.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/rule-tester/node_modules/@typescript-eslint/typescript-estree": { + "node_modules/@typescript-eslint/type-utils": { "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.0.2.tgz", - "integrity": "sha512-3AMc8khTcELFWcKcPc0xiLviEvvfzATpdPj/DXuOGIdQIIFybf4DMT1vKRbuAEOFMwhWt7NFLXRkbjsvKZQyvw==", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.0.2.tgz", + "integrity": "sha512-IKKDcFsKAYlk8Rs4wiFfEwJTQlHcdn8CLwLaxwd6zb8HNiMcQIFX9sWax2k4Cjj7l7mGS5N1zl7RCHOVwHq2VQ==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.0.2", - "@typescript-eslint/visitor-keys": "7.0.2", + "@typescript-eslint/typescript-estree": "7.0.2", + "@typescript-eslint/utils": "7.0.2", "debug": "^4.3.4", - "globby": "^11.1.0", - "is-glob": "^4.0.3", - "minimatch": "9.0.3", - "semver": "^7.5.4", "ts-api-utils": "^1.0.1" }, "engines": { @@ -8920,45 +9089,42 @@ "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, + "peerDependencies": { + "eslint": "^8.56.0" + }, "peerDependenciesMeta": { "typescript": { "optional": true } } }, - "node_modules/@typescript-eslint/rule-tester/node_modules/@typescript-eslint/utils": { + "node_modules/@typescript-eslint/types": { "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.0.2.tgz", - "integrity": "sha512-PZPIONBIB/X684bhT1XlrkjNZJIEevwkKDsdwfiu1WeqBxYEEdIgVDgm8/bbKHVu+6YOpeRqcfImTdImx/4Bsw==", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.0.2.tgz", + "integrity": "sha512-ZzcCQHj4JaXFjdOql6adYV4B/oFOFjPOC9XYwCaZFRvqN8Llfvv4gSxrkQkd2u4Ci62i2c6W6gkDwQJDaRc4nA==", "dev": true, - "dependencies": { - "@eslint-community/eslint-utils": "^4.4.0", - "@types/json-schema": "^7.0.12", - "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "7.0.2", - "@typescript-eslint/types": "7.0.2", - "@typescript-eslint/typescript-estree": "7.0.2", - "semver": "^7.5.4" - }, "engines": { "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "^8.56.0" } }, - "node_modules/@typescript-eslint/rule-tester/node_modules/@typescript-eslint/visitor-keys": { + "node_modules/@typescript-eslint/typescript-estree": { "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.0.2.tgz", - "integrity": "sha512-8Y+YiBmqPighbm5xA2k4wKTxRzx9EkBu7Rlw+WHqMvRJ3RPz/BMBO9b2ru0LUNmXg120PHUXD5+SWFy2R8DqlQ==", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.0.2.tgz", + "integrity": "sha512-3AMc8khTcELFWcKcPc0xiLviEvvfzATpdPj/DXuOGIdQIIFybf4DMT1vKRbuAEOFMwhWt7NFLXRkbjsvKZQyvw==", "dev": true, "dependencies": { "@typescript-eslint/types": "7.0.2", - "eslint-visitor-keys": "^3.4.1" + "@typescript-eslint/visitor-keys": "7.0.2", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "minimatch": "9.0.3", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" }, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -8966,9 +9132,14 @@ "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } } }, - "node_modules/@typescript-eslint/rule-tester/node_modules/brace-expansion": { + "node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", @@ -8977,7 +9148,7 @@ "balanced-match": "^1.0.0" } }, - "node_modules/@typescript-eslint/rule-tester/node_modules/minimatch": { + "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { "version": "9.0.3", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", @@ -8992,102 +9163,18 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/@typescript-eslint/scope-manager": { - "version": "6.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.10.0.tgz", - "integrity": "sha512-TN/plV7dzqqC2iPNf1KrxozDgZs53Gfgg5ZHyw8erd6jd5Ta/JIEcdCheXFt9b1NYb93a1wmIIVW/2gLkombDg==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "6.10.0", - "@typescript-eslint/visitor-keys": "6.10.0" - }, - "engines": { - "node": "^16.0.0 || >=18.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/type-utils": { - "version": "6.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.10.0.tgz", - "integrity": "sha512-wYpPs3hgTFblMYwbYWPT3eZtaDOjbLyIYuqpwuLBBqhLiuvJ+9sEp2gNRJEtR5N/c9G1uTtQQL5AhV0fEPJYcg==", - "dev": true, - "dependencies": { - "@typescript-eslint/typescript-estree": "6.10.0", - "@typescript-eslint/utils": "6.10.0", - "debug": "^4.3.4", - "ts-api-utils": "^1.0.1" - }, - "engines": { - "node": "^16.0.0 || >=18.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "^7.0.0 || ^8.0.0" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/types": { - "version": "6.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.10.0.tgz", - "integrity": "sha512-36Fq1PWh9dusgo3vH7qmQAj5/AZqARky1Wi6WpINxB6SkQdY5vQoT2/7rW7uBIsPDcvvGCLi4r10p0OJ7ITAeg==", - "dev": true, - "engines": { - "node": "^16.0.0 || >=18.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/typescript-estree": { - "version": "6.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.10.0.tgz", - "integrity": "sha512-ek0Eyuy6P15LJVeghbWhSrBCj/vJpPXXR+EpaRZqou7achUWL8IdYnMSC5WHAeTWswYQuP2hAZgij/bC9fanBg==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "6.10.0", - "@typescript-eslint/visitor-keys": "6.10.0", - "debug": "^4.3.4", - "globby": "^11.1.0", - "is-glob": "^4.0.3", - "semver": "^7.5.4", - "ts-api-utils": "^1.0.1" - }, - "engines": { - "node": "^16.0.0 || >=18.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, "node_modules/@typescript-eslint/utils": { - "version": "6.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.10.0.tgz", - "integrity": "sha512-v+pJ1/RcVyRc0o4wAGux9x42RHmAjIGzPRo538Z8M1tVx6HOnoQBCX/NoadHQlZeC+QO2yr4nNSFWOoraZCAyg==", + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.0.2.tgz", + "integrity": "sha512-PZPIONBIB/X684bhT1XlrkjNZJIEevwkKDsdwfiu1WeqBxYEEdIgVDgm8/bbKHVu+6YOpeRqcfImTdImx/4Bsw==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "6.10.0", - "@typescript-eslint/types": "6.10.0", - "@typescript-eslint/typescript-estree": "6.10.0", + "@typescript-eslint/scope-manager": "7.0.2", + "@typescript-eslint/types": "7.0.2", + "@typescript-eslint/typescript-estree": "7.0.2", "semver": "^7.5.4" }, "engines": { @@ -9098,16 +9185,16 @@ "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "eslint": "^7.0.0 || ^8.0.0" + "eslint": "^8.56.0" } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "6.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.10.0.tgz", - "integrity": "sha512-xMGluxQIEtOM7bqFCo+rCMh5fqI+ZxV5RUUOa29iVPz1OgCZrtc7rFnz5cLUazlkPKYqX+75iuDq7m0HQ48nCg==", + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.0.2.tgz", + "integrity": "sha512-8Y+YiBmqPighbm5xA2k4wKTxRzx9EkBu7Rlw+WHqMvRJ3RPz/BMBO9b2ru0LUNmXg120PHUXD5+SWFy2R8DqlQ==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.10.0", + "@typescript-eslint/types": "7.0.2", "eslint-visitor-keys": "^3.4.1" }, "engines": { @@ -13753,32 +13840,32 @@ } }, "node_modules/eslint-config-pixiebrix": { - "version": "0.34.1", - "resolved": "https://registry.npmjs.org/eslint-config-pixiebrix/-/eslint-config-pixiebrix-0.34.1.tgz", - "integrity": "sha512-m2d3Ks+9DT0O8iU01cPA+W5YkuqKHb3QCF/i3hTXF+VdFO008YB4ll/vBeGouqD01ppv4uloU4qomB+aAFWb7g==", + "version": "0.36.2", + "resolved": "https://registry.npmjs.org/eslint-config-pixiebrix/-/eslint-config-pixiebrix-0.36.2.tgz", + "integrity": "sha512-qYc4+SYuM507DlWKTxI0Nq4M0GfjCdyilDpJ+TMORQ8SH0uEEi2cqYlEaj4sdPl55dd6fgrV8rFHR/1VCqKCmw==", "dev": true, "dependencies": { - "@typescript-eslint/eslint-plugin": "^6.7.0", - "@typescript-eslint/parser": "^6.7.0", - "eslint-config-prettier": "^9.0.0", - "eslint-config-xo": "^0.43.1", - "eslint-config-xo-typescript": "^1.0.1", - "eslint-import-resolver-typescript": "^3.5.5", + "@typescript-eslint/eslint-plugin": "^7.0.2", + "@typescript-eslint/parser": "^7.0.2", + "eslint-config-prettier": "^9.1.0", + "eslint-config-xo": "^0.44.0", + "eslint-config-xo-typescript": "^3.0.0", + "eslint-import-resolver-typescript": "^3.6.1", "eslint-plugin-eslint-comments": "^3.2.0", "eslint-plugin-filenames": "^1.3.2", - "eslint-plugin-import": "^2.27.5", - "eslint-plugin-jest": "^27.2.3", - "eslint-plugin-jsx-a11y": "^6.7.1", + "eslint-plugin-import": "^2.29.1", + "eslint-plugin-jest": "^27.9.0", + "eslint-plugin-jsx-a11y": "^6.8.0", "eslint-plugin-no-use-extend-native": "^0.5.0", "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^6.1.1", - "eslint-plugin-react": "^7.32.2", + "eslint-plugin-react": "^7.33.2", "eslint-plugin-react-hooks": "^4.6.0", - "eslint-plugin-react-redux": "^4.0.0", - "eslint-plugin-security": "^2.1.0", - "eslint-plugin-storybook": "^0.6.15", - "eslint-plugin-testing-library": "^6.0.1", - "eslint-plugin-unicorn": "^50.0.1" + "eslint-plugin-react-redux": "^4.1.0", + "eslint-plugin-security": "^2.1.1", + "eslint-plugin-storybook": "^0.8.0", + "eslint-plugin-testing-library": "^6.2.0", + "eslint-plugin-unicorn": "^51.0.1" }, "engines": { "node": ">=16" @@ -13787,10 +13874,38 @@ "eslint": ">=8.0.0" } }, + "node_modules/eslint-config-pixiebrix/node_modules/@typescript-eslint/parser": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.0.2.tgz", + "integrity": "sha512-GdwfDglCxSmU+QTS9vhz2Sop46ebNCXpPPvsByK7hu0rFGRHL+AusKQJ7SoN+LbLh6APFpQwHKmDSwN35Z700Q==", + "dev": true, + "dependencies": { + "@typescript-eslint/scope-manager": "7.0.2", + "@typescript-eslint/types": "7.0.2", + "@typescript-eslint/typescript-estree": "7.0.2", + "@typescript-eslint/visitor-keys": "7.0.2", + "debug": "^4.3.4" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.56.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, "node_modules/eslint-config-prettier": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.0.0.tgz", - "integrity": "sha512-IcJsTkJae2S35pRsRAwoCE+925rJJStOdkKnLVgtE+tEpqU0EVVM7OqrwxqgptKdX29NUwC82I5pXsGFIgSevw==", + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz", + "integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==", "dev": true, "bin": { "eslint-config-prettier": "bin/cli.js" @@ -13800,39 +13915,39 @@ } }, "node_modules/eslint-config-xo": { - "version": "0.43.1", - "resolved": "https://registry.npmjs.org/eslint-config-xo/-/eslint-config-xo-0.43.1.tgz", - "integrity": "sha512-azv1L2PysRA0NkZOgbndUpN+581L7wPqkgJOgxxw3hxwXAbJgD6Hqb/SjHRiACifXt/AvxCzE/jIKFAlI7XjvQ==", + "version": "0.44.0", + "resolved": "https://registry.npmjs.org/eslint-config-xo/-/eslint-config-xo-0.44.0.tgz", + "integrity": "sha512-YG4gdaor0mJJi8UBeRJqDPO42MedTWYMaUyucF5bhm2pi/HS98JIxfFQmTLuyj6hGpQlAazNfyVnn7JuDn+Sew==", "dev": true, "dependencies": { "confusing-browser-globals": "1.0.11" }, "engines": { - "node": ">=12" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" }, "peerDependencies": { - "eslint": ">=8.27.0" + "eslint": ">=8.56.0" } }, "node_modules/eslint-config-xo-typescript": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/eslint-config-xo-typescript/-/eslint-config-xo-typescript-1.0.1.tgz", - "integrity": "sha512-vPQssnRSUgBFOEfB/KY12CXwltwFSn4RSCfa+w7gjBC2PFQ7Yfgmyei+1XUZ3K+8LRGef2NMJUcxts7PldhDjg==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/eslint-config-xo-typescript/-/eslint-config-xo-typescript-3.0.0.tgz", + "integrity": "sha512-8C1EFMHBHMxnFuY+0gSLrnOfSvGG766L85EEFYNqEfO7XmfAVvEKUDgLMwDQ34Dq/bEpOSvVx8gkN9Owx3iKEw==", "dev": true, "engines": { - "node": ">=16" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" }, "peerDependencies": { - "@typescript-eslint/eslint-plugin": ">=6.0.0", - "@typescript-eslint/parser": ">=6.0.0", - "eslint": ">=8.0.0", - "typescript": ">=4.7" + "@typescript-eslint/eslint-plugin": ">=7.0.2", + "@typescript-eslint/parser": ">=7.0.2", + "eslint": ">=8.56.0", + "typescript": ">=5.0.0" } }, "node_modules/eslint-import-resolver-node": { @@ -13969,9 +14084,9 @@ } }, "node_modules/eslint-plugin-import": { - "version": "2.29.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.29.0.tgz", - "integrity": "sha512-QPOO5NO6Odv5lpoTkddtutccQjysJuFxoPS7fAHO+9m9udNHvTCPSAMW9zGAYj8lAIdr40I8yPCdUYrncXtrwg==", + "version": "2.29.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.29.1.tgz", + "integrity": "sha512-BbPC0cuExzhiMo4Ff1BTVwHpjjv28C5R+btTOGaCRC7UEz801up0JadwkeSk5Ued6TG34uaczuVuH6qyy5YUxw==", "dev": true, "dependencies": { "array-includes": "^3.1.7", @@ -13990,7 +14105,7 @@ "object.groupby": "^1.0.1", "object.values": "^1.1.7", "semver": "^6.3.1", - "tsconfig-paths": "^3.14.2" + "tsconfig-paths": "^3.15.0" }, "engines": { "node": ">=4" @@ -14030,9 +14145,9 @@ } }, "node_modules/eslint-plugin-jest": { - "version": "27.6.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-27.6.0.tgz", - "integrity": "sha512-MTlusnnDMChbElsszJvrwD1dN3x6nZl//s4JD23BxB6MgR66TZlL064su24xEIS3VACfAoHV1vgyMgPw8nkdng==", + "version": "27.9.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-27.9.0.tgz", + "integrity": "sha512-QIT7FH7fNmd9n4se7FFKHbsLKGQiw885Ds6Y/sxKgCZ6natwCsXdgPOADnYVxN2QrRweF0FZWbJ6S7Rsn7llug==", "dev": true, "dependencies": { "@typescript-eslint/utils": "^5.10.0" @@ -14041,7 +14156,7 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" }, "peerDependencies": { - "@typescript-eslint/eslint-plugin": "^5.0.0 || ^6.0.0", + "@typescript-eslint/eslint-plugin": "^5.0.0 || ^6.0.0 || ^7.0.0", "eslint": "^7.0.0 || ^8.0.0", "jest": "*" }, @@ -14385,9 +14500,9 @@ } }, "node_modules/eslint-plugin-security": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-security/-/eslint-plugin-security-2.1.0.tgz", - "integrity": "sha512-ywxclP954bf8d3gr6KOQ/AFc+PRvWuhOxtPOEtiHmVYiZr/mcgQtmSJq6+hTEXC5ylTjHnPPG+PEnzlDiWMXbQ==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-security/-/eslint-plugin-security-2.1.1.tgz", + "integrity": "sha512-7cspIGj7WTfR3EhaILzAPcfCo5R9FbeWvbgsPYWivSurTBKW88VQxtP3c4aWMG9Hz/GfJlJVdXEJ3c8LqS+u2w==", "dev": true, "dependencies": { "safe-regex": "^2.1.1" @@ -14406,18 +14521,18 @@ } }, "node_modules/eslint-plugin-storybook": { - "version": "0.6.15", - "resolved": "https://registry.npmjs.org/eslint-plugin-storybook/-/eslint-plugin-storybook-0.6.15.tgz", - "integrity": "sha512-lAGqVAJGob47Griu29KXYowI4G7KwMoJDOkEip8ujikuDLxU+oWJ1l0WL6F2oDO4QiyUFXvtDkEkISMOPzo+7w==", + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-storybook/-/eslint-plugin-storybook-0.8.0.tgz", + "integrity": "sha512-CZeVO5EzmPY7qghO2t64oaFM+8FTaD4uzOEjHKp516exyTKo+skKAL9GI3QALS2BXhyALJjNtwbmr1XinGE8bA==", "dev": true, "dependencies": { "@storybook/csf": "^0.0.1", - "@typescript-eslint/utils": "^5.45.0", - "requireindex": "^1.1.0", + "@typescript-eslint/utils": "^5.62.0", + "requireindex": "^1.2.0", "ts-dedent": "^2.2.0" }, "engines": { - "node": "12.x || 14.x || >= 16" + "node": ">= 18" }, "peerDependencies": { "eslint": ">=6" @@ -14533,9 +14648,9 @@ } }, "node_modules/eslint-plugin-testing-library": { - "version": "6.1.2", - "resolved": "https://registry.npmjs.org/eslint-plugin-testing-library/-/eslint-plugin-testing-library-6.1.2.tgz", - "integrity": "sha512-Ra16FeBlonfbScOIdZEta9o+OxtwDqiUt+4UCpIM42TuatyLdtfU/SbwnIzPcAszrbl58PGwyZ9YGU9dwIo/tA==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-testing-library/-/eslint-plugin-testing-library-6.2.0.tgz", + "integrity": "sha512-+LCYJU81WF2yQ+Xu4A135CgK8IszcFcyMF4sWkbiu6Oj+Nel0TrkZq/HvDw0/1WuO3dhDQsZA/OpEMGd0NfcUw==", "dev": true, "dependencies": { "@typescript-eslint/utils": "^5.58.0" @@ -14649,9 +14764,9 @@ } }, "node_modules/eslint-plugin-unicorn": { - "version": "50.0.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-50.0.1.tgz", - "integrity": "sha512-KxenCZxqSYW0GWHH18okDlOQcpezcitm5aOSz6EnobyJ6BIByiPDviQRjJIUAjG/tMN11958MxaQ+qCoU6lfDA==", + "version": "51.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-51.0.1.tgz", + "integrity": "sha512-MuR/+9VuB0fydoI0nIn2RDA5WISRn4AsJyNSaNKLVwie9/ONvQhxOBbkfSICBPnzKrB77Fh6CZZXjgTt/4Latw==", "dev": true, "dependencies": { "@babel/helper-validator-identifier": "^7.22.20", @@ -26704,9 +26819,9 @@ } }, "node_modules/tsconfig-paths": { - "version": "3.14.2", - "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.2.tgz", - "integrity": "sha512-o/9iXgCYc5L/JxCHPe3Hvh8Q/2xm5Z+p18PESBU6Ff33695QnCHBEjcytY2q19ua7Mbl/DavtBOLq+oG0RCL+g==", + "version": "3.15.0", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz", + "integrity": "sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==", "dev": true, "dependencies": { "@types/json5": "^0.0.29", diff --git a/package.json b/package.json index fd9e700a85..29079c35ba 100644 --- a/package.json +++ b/package.json @@ -254,7 +254,7 @@ "css-minimizer-webpack-plugin": "^6.0.0", "dotenv": "^16.4.5", "eslint": "^8.57.0", - "eslint-config-pixiebrix": "^0.34.1", + "eslint-config-pixiebrix": "^0.36.2", "eslint-plugin-local-rules": "^2.0.1", "fake-indexeddb": "^5.0.2", "identity-obj-proxy": "^3.0.0", diff --git a/src/activation/activationLinkUtils.ts b/src/activation/activationLinkUtils.ts index 533f58564c..270257d19e 100644 --- a/src/activation/activationLinkUtils.ts +++ b/src/activation/activationLinkUtils.ts @@ -24,6 +24,7 @@ import { DEFAULT_SERVICE_URL } from "@/urlConstants"; import type { ModActivationConfig } from "@/types/modTypes"; import { isEmpty, uniq } from "lodash"; import deepEquals from "fast-deep-equal"; +import { base64ToString, stringToBase64 } from "uint8array-extras"; const ACTIVATE_PATH = "/activate"; @@ -62,14 +63,14 @@ export function createActivationRelativeUrl( nextUrl?: string; } = {}, ): string { - if (mods.length === 0) { + const [firstMod] = mods; + if (!firstMod) { throw new Error("Expected at least one mod to activate"); } const searchParams = new URLSearchParams(); - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- known to be non-empty due to check above - const { initialOptions } = mods[0]!; + const { initialOptions } = firstMod; // In 1.8.8, which introduces initial options, we only support a single set of initial options if (mods.some((mod) => !deepEquals(mod.initialOptions, initialOptions))) { @@ -83,7 +84,10 @@ export function createActivationRelativeUrl( // Only add options if they are present if (mods.some((x) => !isEmpty(x.initialOptions))) { - searchParams.set("activateOptions", btoa(JSON.stringify(initialOptions))); + searchParams.set( + "activateOptions", + stringToBase64(JSON.stringify(initialOptions)), + ); } if (nextUrl) { @@ -137,7 +141,7 @@ function parseEncodedOptions( return {}; } - const json = JSON.parse(atob(encodedOptions)); + const json = JSON.parse(base64ToString(encodedOptions)); if (typeof json !== "object") { throw new TypeError(`Invalid options: ${typeof json}`); diff --git a/src/analysis/analysisVisitors/varAnalysis/parseTemplateVariables.ts b/src/analysis/analysisVisitors/varAnalysis/parseTemplateVariables.ts index 0f2246494e..72cf4109a7 100644 --- a/src/analysis/analysisVisitors/varAnalysis/parseTemplateVariables.ts +++ b/src/analysis/analysisVisitors/varAnalysis/parseTemplateVariables.ts @@ -234,7 +234,7 @@ function parseLookUp(node: any, inLoop = false): Variable[] { : parseLookUp(target, inLoop); if (val instanceof Literal) { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- targetVars can't be empty + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-unnecessary-type-assertion -- targetVars can't be empty const parentVar = targetVars.at(-1)!; const newVar = new Variable(String(val.value), { parent: parentVar, diff --git a/src/analysis/analysisVisitors/varAnalysis/varMap.ts b/src/analysis/analysisVisitors/varAnalysis/varMap.ts index 7518deb3f5..40b2a06daa 100644 --- a/src/analysis/analysisVisitors/varAnalysis/varMap.ts +++ b/src/analysis/analysisVisitors/varAnalysis/varMap.ts @@ -303,7 +303,7 @@ class VarMap { const pathPartsCopy = [...pathParts]; let bag: ExistenceNode | undefined = sourceMap; while (pathPartsCopy.length > 0) { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- Existence verified via `length` check so `!` is fine + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-unnecessary-type-assertion -- Existence verified via `length` check so `!` is fine const part = stripOptionalChaining(pathPartsCopy.shift()!); // Handle the array case (allow only numeric keys) diff --git a/src/auth/ScopeSettings.tsx b/src/auth/ScopeSettings.tsx index 2dcde593b2..9bb8ab0b37 100644 --- a/src/auth/ScopeSettings.tsx +++ b/src/auth/ScopeSettings.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unsafe-enum-comparison -- It seems to be the correct option for now */ /* * Copyright (C) 2024 PixieBrix, Inc. * diff --git a/src/background/partnerIntegrations.ts b/src/background/partnerIntegrations.ts index 8d985ca4ab..4bbbc96913 100644 --- a/src/background/partnerIntegrations.ts +++ b/src/background/partnerIntegrations.ts @@ -33,6 +33,7 @@ import { CONTROL_ROOM_OAUTH_INTEGRATION_ID, CONTROL_ROOM_TOKEN_INTEGRATION_ID, } from "@/integrations/constants"; +import { stringToBase64 } from "uint8array-extras"; const TEN_HOURS = 1000 * 60 * 60 * 10; @@ -208,7 +209,7 @@ export async function _refreshPartnerToken(): Promise { // On 401, throw the error. In the future, we might consider clearing the partnerAuth. However, currently that // would trigger a re-login, which may not be desirable at arbitrary times. const { data } = await axios.post(context.tokenUrl, params, { - headers: { Authorization: `Basic ${btoa(context.client_id)} ` }, + headers: { Authorization: `Basic ${stringToBase64(context.client_id)} ` }, }); // Store for use direct calls to the partner API diff --git a/src/bricks/effects/forms.ts b/src/bricks/effects/forms.ts index 893d7869f6..57189bb7c3 100644 --- a/src/bricks/effects/forms.ts +++ b/src/bricks/effects/forms.ts @@ -261,7 +261,7 @@ export class FormFill extends EffectABC { if (typeof submit === "boolean") { if (submit) { if (!$form.is("form")) { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- Validated above + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-unnecessary-type-assertion -- Validated above const form = $form.get(0)!; if (form instanceof Document) { diff --git a/src/bricks/readers/ImageReader.ts b/src/bricks/readers/ImageReader.ts index 954e338116..66ff1487a8 100644 --- a/src/bricks/readers/ImageReader.ts +++ b/src/bricks/readers/ImageReader.ts @@ -27,7 +27,7 @@ function getBase64Image(img: HTMLImageElement) { canvas.height = img.height; // Copy the image contents to the canvas - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- 2d always exists + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-unnecessary-type-assertion -- 2d always exists const context = canvas.getContext("2d")!; context.drawImage(img, 0, 0); diff --git a/src/bricks/transformers/encode.ts b/src/bricks/transformers/encode.ts index db1bfd4fd8..fbfeb0d0be 100644 --- a/src/bricks/transformers/encode.ts +++ b/src/bricks/transformers/encode.ts @@ -18,6 +18,7 @@ import { TransformerABC } from "@/types/bricks/transformerTypes"; import { type BrickArgs } from "@/types/runtimeTypes"; import { propertiesToSchema } from "@/validators/generic"; +import { stringToBase64 } from "uint8array-extras"; export class Base64Encode extends TransformerABC { override defaultOutputKey = "encoded"; @@ -47,7 +48,7 @@ export class Base64Encode extends TransformerABC { async transform({ stringToEncode, }: BrickArgs<{ stringToEncode: string }>): Promise { - return btoa(stringToEncode); + return stringToBase64(stringToEncode); } } @@ -75,6 +76,6 @@ export class Base64Decode extends TransformerABC { async transform({ encodedData, }: BrickArgs<{ encodedData: string }>): Promise { - return btoa(encodedData); + return stringToBase64(encodedData); } } diff --git a/src/components/documentBuilder/edit/getElementCollectionName.ts b/src/components/documentBuilder/edit/getElementCollectionName.ts index 879bbf7f27..c8bbad90d2 100644 --- a/src/components/documentBuilder/edit/getElementCollectionName.ts +++ b/src/components/documentBuilder/edit/getElementCollectionName.ts @@ -36,7 +36,7 @@ function getElementCollectionName(elementName: string): { ); return { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- Guaranteed by the regexp + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-unnecessary-type-assertion -- Guaranteed by the regexp collectionName: match.collectionName!, elementIndex: Number(match.elementIndex), }; diff --git a/src/components/fields/fieldUtils.ts b/src/components/fields/fieldUtils.ts index 81fc36b4b1..ee0d626c6b 100644 --- a/src/components/fields/fieldUtils.ts +++ b/src/components/fields/fieldUtils.ts @@ -52,7 +52,7 @@ const FIELD_TITLE_ACRONYMS = new Set([ * @param name the form name, including field name separators */ export function fieldLabel(name: string): string { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- Presumably the name is never empty, so there's always a "last item" + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-unnecessary-type-assertion -- Presumably the name is never empty, so there's always a "last item" const namePart = name.split(".").at(-1)!; return startCase(namePart) diff --git a/src/components/fields/schemaFields/getToggleOptions.tsx b/src/components/fields/schemaFields/getToggleOptions.tsx index 1fc3608c28..e0129381e4 100644 --- a/src/components/fields/schemaFields/getToggleOptions.tsx +++ b/src/components/fields/schemaFields/getToggleOptions.tsx @@ -388,9 +388,7 @@ export function getToggleOptions({ }).map((option) => { // Only use the schema description if a custom description wasn't already // set for the input mode option - if (!option.description) { - option.description = subSchema.description; - } + option.description ||= subSchema.description; return option; }); diff --git a/src/components/fields/schemaFields/widgets/varPopup/SourceLabel.tsx b/src/components/fields/schemaFields/widgets/varPopup/SourceLabel.tsx index e53a8323b6..0e13d9d931 100644 --- a/src/components/fields/schemaFields/widgets/varPopup/SourceLabel.tsx +++ b/src/components/fields/schemaFields/widgets/varPopup/SourceLabel.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unsafe-enum-comparison -- It seems to be the correct option for now */ import React from "react"; import { type BlockInfo } from "@/pageEditor/uiState/uiStateTypes"; import { KnownSources } from "@/analysis/analysisVisitors/varAnalysis/varAnalysis"; @@ -19,50 +20,39 @@ const SourceLabel: React.FunctionComponent = ({ }) => { const [kind] = source.split(":"); let label: string; - if ( - [ - KnownSources.INPUT, - KnownSources.OPTIONS, - KnownSources.SERVICE, - KnownSources.MOD, - ].includes(kind) - ) { - switch (kind) { - case KnownSources.INPUT: { - label = `Starter Brick: ${extensionPointLabel}`; - break; - } + switch (kind) { + case KnownSources.INPUT: { + label = `Starter Brick: ${extensionPointLabel}`; + break; + } - case KnownSources.OPTIONS: { - label = "Mod Options"; - break; - } + case KnownSources.OPTIONS: { + label = "Mod Options"; + break; + } - case KnownSources.MOD: { - label = "Mod Variables"; - break; - } + case KnownSources.MOD: { + label = "Mod Variables"; + break; + } - case KnownSources.SERVICE: { - label = "Integrations"; - break; - } + case KnownSources.SERVICE: { + label = "Integrations"; + break; + } - default: { - throw new Error(`Unexpected kind: ${kind}`); + default: { + const blockConfig = blocksInfo.find((block) => block.path === source) + ?.blockConfig; + if (blockConfig == null) { + label = source; + } else { + label = + blockConfig.label ?? + allBlocks.get(blockConfig.id)?.block?.name ?? + source; } } - } else { - const blockConfig = blocksInfo.find((block) => block.path === source) - ?.blockConfig; - if (blockConfig == null) { - label = source; - } else { - label = - blockConfig.label ?? - allBlocks.get(blockConfig.id)?.block?.name ?? - source; - } } return
{label}
; diff --git a/src/components/formBuilder/edit/FieldEditor.tsx b/src/components/formBuilder/edit/FieldEditor.tsx index 644d25295c..2f007d42da 100644 --- a/src/components/formBuilder/edit/FieldEditor.tsx +++ b/src/components/formBuilder/edit/FieldEditor.tsx @@ -212,9 +212,7 @@ const FieldEditor: React.FC<{ target: { value: nextIsRequired }, }: React.ChangeEvent) => { const nextRjsfSchema = produce(rjsfSchema, (draft) => { - if (!draft.schema.required) { - draft.schema.required = []; - } + draft.schema.required ||= []; if (nextIsRequired) { draft.schema.required.push(propertyName); diff --git a/src/components/formBuilder/formBuilderHelpers.ts b/src/components/formBuilder/formBuilderHelpers.ts index 4dbb5d451b..5ebaacbb44 100644 --- a/src/components/formBuilder/formBuilderHelpers.ts +++ b/src/components/formBuilder/formBuilderHelpers.ts @@ -123,8 +123,8 @@ export const moveStringInArray = ( } const toIndex = direction === "up" ? fromIndex - 1 : fromIndex + 1; - // eslint-disable-next-line security/detect-object-injection, @typescript-eslint/no-non-null-assertion -- checked with indexOf - [copy[fromIndex], copy[toIndex]] = [copy[toIndex]!, copy[fromIndex]!]; + // eslint-disable-next-line security/detect-object-injection -- checked with indexOf + [copy[fromIndex], copy[toIndex]] = [copy[toIndex], copy[fromIndex]]; return copy; }; @@ -248,10 +248,7 @@ export const produceSchemaOnUiTypeChange = ( } if (uiWidget) { - if (!draft.uiSchema[propertyName]) { - draft.uiSchema[propertyName] = {}; - } - + draft.uiSchema[propertyName] ??= {}; draft.uiSchema[propertyName][UI_WIDGET] = uiWidget; } else if (draft.uiSchema[propertyName]) { delete draft.uiSchema[propertyName][UI_WIDGET]; @@ -307,9 +304,7 @@ export const normalizeSchema = (rjsfSchemaDraft: Draft) => { rjsfSchemaDraft.schema.required = []; } - if (rjsfSchemaDraft.schema.properties == null) { - rjsfSchemaDraft.schema.properties = {}; - } + rjsfSchemaDraft.schema.properties ??= {}; }; export const getNormalizedUiOrder = ( diff --git a/src/components/formBuilder/preview/FormPreview.tsx b/src/components/formBuilder/preview/FormPreview.tsx index d05d7e0b95..5114ef2718 100644 --- a/src/components/formBuilder/preview/FormPreview.tsx +++ b/src/components/formBuilder/preview/FormPreview.tsx @@ -68,10 +68,7 @@ const FormPreview: React.FC = ({ } if (activeField) { - if (!draftUiSchema[activeField]) { - draftUiSchema[activeField] = {}; - } - + draftUiSchema[activeField] ??= {}; draftUiSchema[activeField][UI_SCHEMA_ACTIVE] = true; } @@ -148,10 +145,8 @@ const FormPreview: React.FC = ({ value[UI_WIDGET] === "select" && propertySchema.oneOf !== undefined ) { - if (propertySchema.default == null) { - // Setting the default value for preview to hide an empty option - propertySchema.default = ""; - } + // Setting the default value for preview to hide an empty option + propertySchema.default ??= ""; if (!propertySchema.oneOf?.length) { propertySchema.oneOf = [{ const: "" }]; diff --git a/src/components/formBuilder/preview/FormPreviewSchemaField.tsx b/src/components/formBuilder/preview/FormPreviewSchemaField.tsx index f368e4a472..191993800b 100644 --- a/src/components/formBuilder/preview/FormPreviewSchemaField.tsx +++ b/src/components/formBuilder/preview/FormPreviewSchemaField.tsx @@ -20,7 +20,7 @@ import { type FieldProps } from "@rjsf/utils"; import React from "react"; import { type SchemaDefinition } from "@/types/schemaTypes"; -// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- Loose types +// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-unnecessary-type-assertion -- Loose types const RjsfSchemaField = getDefaultRegistry().fields.SchemaField!; /** diff --git a/src/contentScript/pageEditor/dynamic.ts b/src/contentScript/pageEditor/dynamic.ts index 1199c17e56..47ff58219b 100644 --- a/src/contentScript/pageEditor/dynamic.ts +++ b/src/contentScript/pageEditor/dynamic.ts @@ -140,9 +140,7 @@ export async function updateDynamicElement({ export async function enableOverlay(selector: string): Promise { expectContext("contentScript"); - if (_overlay == null) { - _overlay = new Overlay(); - } + _overlay ??= new Overlay(); const elements = $safeFind(selector).toArray(); if (elements.length > 0) { diff --git a/src/contentScript/popoverDom.ts b/src/contentScript/popoverDom.ts index a4d9cb8e53..4c8cf6bf04 100644 --- a/src/contentScript/popoverDom.ts +++ b/src/contentScript/popoverDom.ts @@ -79,7 +79,7 @@ function popoverFactory(initialUrl: URL): HTMLElement { // Pass to the EphemeralPanel for useTemporaryPanelDefinition decoratedUrl.searchParams.set("frameNonce", frameNonce); - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- It's being created here, it can't be missing + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-unnecessary-type-assertion -- It's being created here, it can't be missing const tooltip = $(html`