diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 95f79cf3..00000000 --- a/.eslintignore +++ /dev/null @@ -1,4 +0,0 @@ -node_modules/ -.github/ -docs/ -images/ \ No newline at end of file diff --git a/eslint.config.cjs b/eslint.config.cjs new file mode 100644 index 00000000..c38e8062 --- /dev/null +++ b/eslint.config.cjs @@ -0,0 +1,41 @@ +const { FlatCompat } = require("@eslint/eslintrc"); + +const compat = new FlatCompat({ + baseDirectory: __dirname, +}); + +const legacyConfig = require("./.eslintrc.json"); + +module.exports = [ + { + ignores: [ + "lib/**", + "dist/**", + "node_modules/**", + ".github/**", + "MathjaxToSVG/**", + "docs/**", + "ea-scripts/**", + "images/**", + "test-data/**", + ], + }, + ...compat.config(legacyConfig), + { + files: ["**/*.{ts,tsx,js,jsx}"], + rules: { + "no-unused-vars": "off", + "@typescript-eslint/no-unused-vars": [ + "error", + { + args: "after-used", + argsIgnorePattern: "^_", + varsIgnorePattern: "^_", + ignoreRestSiblings: true, + caughtErrors: "all", + caughtErrorsIgnorePattern: "^_", + }, + ], + }, + }, +]; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 84497ce9..61a9f96c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,6 +36,7 @@ "@codemirror/search": "6.5.11", "@codemirror/state": "6.5.0", "@codemirror/view": "6.38.6", + "@eslint/eslintrc": "^3.1.0", "@excalidraw/eslint-config": "^1.0.3", "@excalidraw/prettier-config": "^1.0.2", "@rollup/plugin-babel": "^6.0.3", @@ -56,6 +57,7 @@ "cross-env": "^7.0.3", "cssnano": "^6.0.2", "dotenv": "^16.4.5", + "eslint": "^9.27.0", "eslint-config-prettier": "^9.0.0", "eslint-plugin-prettier": "^5.0.0", "fs-extra": "^11.2.0", @@ -1841,7 +1843,6 @@ "integrity": "sha512-phrYmNiYppR7znFEdqgfWHXR6NCkZEK7hwWDHZUjit/2/U0r6XvkDl0SYnoM51Hq7FhCGdLDT6zxCCOY1hexsQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "eslint-visitor-keys": "^3.4.3" }, @@ -1861,121 +1862,158 @@ "integrity": "sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": "^12.0.0 || ^14.0.0 || >=16.0.0" } }, "node_modules/@eslint/config-array": { - "version": "0.23.3", - "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.23.3.tgz", - "integrity": "sha512-j+eEWmB6YYLwcNOdlwQ6L2OsptI/LO6lNBuLIqe5R7RetD658HLoF+Mn7LzYmAWWNNzdC6cqP+L6r8ujeYXWLw==", + "version": "0.21.2", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.21.2.tgz", + "integrity": "sha512-nJl2KGTlrf9GjLimgIru+V/mzgSK0ABCDQRvxw5BjURL7WfH5uoWmizbH7QB6MmnMBd8cIC9uceWnezL1VZWWw==", "dev": true, "license": "Apache-2.0", - "peer": true, "dependencies": { - "@eslint/object-schema": "^3.0.3", + "@eslint/object-schema": "^2.1.7", "debug": "^4.3.1", - "minimatch": "^10.2.4" + "minimatch": "^3.1.5" }, "engines": { - "node": "^20.19.0 || ^22.13.0 || >=24" - } - }, - "node_modules/@eslint/config-array/node_modules/balanced-match": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", - "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", - "dev": true, - "license": "MIT", - "peer": true, - "engines": { - "node": "18 || 20 || >=22" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, "node_modules/@eslint/config-array/node_modules/brace-expansion": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.4.tgz", - "integrity": "sha512-h+DEnpVvxmfVefa4jFbCf5HdH5YMDXRsmKflpf1pILZWRFlTbJpxeU55nJl4Smt5HQaGzg1o6RHFPJaOqnmBDg==", + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.14.tgz", + "integrity": "sha512-MWPGfDxnyzKU7rNOW9SP/c50vi3xrmrua/+6hfPbCS2ABNWfx24vPidzvC7krjU/RTo235sV776ymlsMtGKj8g==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { - "balanced-match": "^4.0.2" - }, - "engines": { - "node": "18 || 20 || >=22" + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" } }, "node_modules/@eslint/config-array/node_modules/minimatch": { - "version": "10.2.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.4.tgz", - "integrity": "sha512-oRjTw/97aTBN0RHbYCdtF1MQfvusSIBQM0IZEgzl6426+8jSC0nF1a/GmnVLpfB9yyr6g6FTqWqiZVbxrtaCIg==", + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", "dev": true, - "license": "BlueOak-1.0.0", - "peer": true, + "license": "ISC", "dependencies": { - "brace-expansion": "^5.0.2" + "brace-expansion": "^1.1.7" }, "engines": { - "node": "18 || 20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" + "node": "*" } }, "node_modules/@eslint/config-helpers": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.5.3.tgz", - "integrity": "sha512-lzGN0onllOZCGroKJmRwY6QcEHxbjBw1gwB8SgRSqK8YbbtEXMvKynsXc3553ckIEBxsbMBU7oOZXKIPGZNeZw==", + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.4.2.tgz", + "integrity": "sha512-gBrxN88gOIf3R7ja5K9slwNayVcZgK6SOUORm2uBzTeIEfeVaIhOpCtTox3P6R7o2jLFwLFTLnC7kU/RGcYEgw==", "dev": true, "license": "Apache-2.0", - "peer": true, "dependencies": { - "@eslint/core": "^1.1.1" + "@eslint/core": "^0.17.0" }, "engines": { - "node": "^20.19.0 || ^22.13.0 || >=24" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, "node_modules/@eslint/core": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@eslint/core/-/core-1.1.1.tgz", - "integrity": "sha512-QUPblTtE51/7/Zhfv8BDwO0qkkzQL7P/aWWbqcf4xWLEYn1oKjdO0gglQBB4GAsu7u6wjijbCmzsUTy6mnk6oQ==", + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.17.0.tgz", + "integrity": "sha512-yL/sLrpmtDaFEiUj1osRP4TI2MDz1AddJL+jZ7KSqvBuliN4xqYY54IfdN8qD8Toa6g1iloph1fxQNkjOxrrpQ==", "dev": true, "license": "Apache-2.0", - "peer": true, "dependencies": { "@types/json-schema": "^7.0.15" }, "engines": { - "node": "^20.19.0 || ^22.13.0 || >=24" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/eslintrc": { + "version": "3.3.5", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.3.5.tgz", + "integrity": "sha512-4IlJx0X0qftVsN5E+/vGujTRIFtwuLbNsVUe7TO6zYPDR1O6nFwvwhIKEKSrl6dZchmYBITazxKoUYOjdtjlRg==", + "dev": true, + "license": "MIT", + "dependencies": { + "ajv": "^6.14.0", + "debug": "^4.3.2", + "espree": "^10.0.1", + "globals": "^14.0.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.1", + "minimatch": "^3.1.5", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/eslintrc/node_modules/brace-expansion": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.14.tgz", + "integrity": "sha512-MWPGfDxnyzKU7rNOW9SP/c50vi3xrmrua/+6hfPbCS2ABNWfx24vPidzvC7krjU/RTo235sV776ymlsMtGKj8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/@eslint/eslintrc/node_modules/minimatch": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/@eslint/js": { + "version": "9.39.4", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.39.4.tgz", + "integrity": "sha512-nE7DEIchvtiFTwBw4Lfbu59PG+kCofhjsKaCWzxTpt4lfRjRMqG6uMBzKXuEcyXhOHoUp9riAm7/aWYGhXZ9cw==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://eslint.org/donate" } }, "node_modules/@eslint/object-schema": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-3.0.3.tgz", - "integrity": "sha512-iM869Pugn9Nsxbh/YHRqYiqd23AmIbxJOcpUMOuWCVNdoQJ5ZtwL6h3t0bcZzJUlC3Dq9jCFCESBZnX0GTv7iQ==", + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.7.tgz", + "integrity": "sha512-VtAOaymWVfZcmZbp6E2mympDIHvyjXs/12LqWYjVw6qjrfF+VK+fyG33kChz3nnK+SU5/NeHOqrTEHS8sXO3OA==", "dev": true, "license": "Apache-2.0", - "peer": true, "engines": { - "node": "^20.19.0 || ^22.13.0 || >=24" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, "node_modules/@eslint/plugin-kit": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.6.1.tgz", - "integrity": "sha512-iH1B076HoAshH1mLpHMgwdGeTs0CYwL0SPMkGuSebZrwBp16v415e9NZXg2jtrqPVQjf6IANe2Vtlr5KswtcZQ==", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.4.1.tgz", + "integrity": "sha512-43/qtrDUokr7LJqoF2c3+RInu/t4zfrpYdoSDfYyhg52rwLV6TnOvdG4fXm7IkSB3wErkcmJS9iEhjVtOSEjjA==", "dev": true, "license": "Apache-2.0", - "peer": true, "dependencies": { - "@eslint/core": "^1.1.1", + "@eslint/core": "^0.17.0", "levn": "^0.4.1" }, "engines": { - "node": "^20.19.0 || ^22.13.0 || >=24" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, "node_modules/@excalidraw/eslint-config": { @@ -2075,7 +2113,6 @@ "integrity": "sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==", "dev": true, "license": "Apache-2.0", - "peer": true, "engines": { "node": ">=18.18.0" } @@ -2086,7 +2123,6 @@ "integrity": "sha512-/zUx+yOsIrG4Y43Eh2peDeKCxlRt/gET6aHfaKpuq267qXdYDFViVHfMaLyygZOnl0kGWxFIgsBy8QFuTLUXEQ==", "dev": true, "license": "Apache-2.0", - "peer": true, "dependencies": { "@humanfs/core": "^0.19.1", "@humanwhocodes/retry": "^0.4.0" @@ -2101,7 +2137,6 @@ "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", "dev": true, "license": "Apache-2.0", - "peer": true, "engines": { "node": ">=12.22" }, @@ -2116,7 +2151,6 @@ "integrity": "sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==", "dev": true, "license": "Apache-2.0", - "peer": true, "engines": { "node": ">=18.18" }, @@ -4269,14 +4303,6 @@ "@types/d3-selection": "*" } }, - "node_modules/@types/esrecurse": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/@types/esrecurse/-/esrecurse-4.3.1.tgz", - "integrity": "sha512-xJBAbDifo5hpffDBuHl0Y8ywswbiAp/Wi7Y/GtAgSlZyIABppyurxVueOPE8LUQOxdlgi6Zqce7uoEpqNTeiUw==", - "dev": true, - "license": "MIT", - "peer": true - }, "node_modules/@types/estree": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", @@ -4329,8 +4355,7 @@ "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/@types/minimatch": { "version": "5.1.2", @@ -4889,7 +4914,6 @@ "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", "dev": true, "license": "MIT", - "peer": true, "peerDependencies": { "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } @@ -4914,7 +4938,6 @@ "integrity": "sha512-IWrosm/yrn43eiKqkfkHis7QioDleaXQHdDVPKg0FSwwd/DuvyX79TZnFOnYpB7dcsFAMmtFztZuXPDvSePkFw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", @@ -5163,6 +5186,16 @@ "dev": true, "license": "MIT" }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/caniuse-api": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/caniuse-api/-/caniuse-api-3.0.0.tgz", @@ -5203,6 +5236,39 @@ "integrity": "sha512-yWq+R3U3jE+coOeEb3a3GgE2j/0MMiDKM/QpLb6h9ihf5fGY9UXtvK9o4vNqjWXoZz7/3EaSVU3IX53TvFFUOw==", "license": "MIT" }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/chalk/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, "node_modules/chevrotain": { "version": "11.0.3", "resolved": "https://registry.npmjs.org/chevrotain/-/chevrotain-11.0.3.tgz", @@ -6091,8 +6157,7 @@ "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/deepmerge": { "version": "4.3.1", @@ -6281,7 +6346,6 @@ "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=10" }, @@ -6290,31 +6354,33 @@ } }, "node_modules/eslint": { - "version": "10.0.3", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-10.0.3.tgz", - "integrity": "sha512-COV33RzXZkqhG9P2rZCFl9ZmJ7WL+gQSCRzE7RhkbclbQPtLAWReL7ysA0Sh4c8Im2U9ynybdR56PV0XcKvqaQ==", + "version": "9.39.4", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.39.4.tgz", + "integrity": "sha512-XoMjdBOwe/esVgEvLmNsD3IRHkm7fbKIUGvrleloJXUZgDHig2IPWNniv+GwjyJXzuNqVjlr5+4yVUZjycJwfQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", - "@eslint-community/regexpp": "^4.12.2", - "@eslint/config-array": "^0.23.3", - "@eslint/config-helpers": "^0.5.2", - "@eslint/core": "^1.1.1", - "@eslint/plugin-kit": "^0.6.1", + "@eslint-community/regexpp": "^4.12.1", + "@eslint/config-array": "^0.21.2", + "@eslint/config-helpers": "^0.4.2", + "@eslint/core": "^0.17.0", + "@eslint/eslintrc": "^3.3.5", + "@eslint/js": "9.39.4", + "@eslint/plugin-kit": "^0.4.1", "@humanfs/node": "^0.16.6", "@humanwhocodes/module-importer": "^1.0.1", "@humanwhocodes/retry": "^0.4.2", "@types/estree": "^1.0.6", "ajv": "^6.14.0", + "chalk": "^4.0.0", "cross-spawn": "^7.0.6", "debug": "^4.3.2", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^9.1.2", - "eslint-visitor-keys": "^5.0.1", - "espree": "^11.1.1", - "esquery": "^1.7.0", + "eslint-scope": "^8.4.0", + "eslint-visitor-keys": "^4.2.1", + "espree": "^10.4.0", + "esquery": "^1.5.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", "file-entry-cache": "^8.0.0", @@ -6324,7 +6390,8 @@ "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "json-stable-stringify-without-jsonify": "^1.0.1", - "minimatch": "^10.2.4", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.5", "natural-compare": "^1.4.0", "optionator": "^0.9.3" }, @@ -6332,7 +6399,7 @@ "eslint": "bin/eslint.js" }, "engines": { - "node": "^20.19.0 || ^22.13.0 || >=24" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "url": "https://eslint.org/donate" @@ -6391,20 +6458,17 @@ } }, "node_modules/eslint-scope": { - "version": "9.1.2", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-9.1.2.tgz", - "integrity": "sha512-xS90H51cKw0jltxmvmHy2Iai1LIqrfbw57b79w/J7MfvDfkIkFZ+kj6zC3BjtUwh150HsSSdxXZcsuv72miDFQ==", + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.4.0.tgz", + "integrity": "sha512-sNXOfKCn74rt8RICKMvJS7XKV/Xk9kA7DyJr8mJik3S7Cwgy3qlkkmyS2uQB3jiJg6VNdZd/pDBJu0nvG2NlTg==", "dev": true, "license": "BSD-2-Clause", - "peer": true, "dependencies": { - "@types/esrecurse": "^4.3.1", - "@types/estree": "^1.0.8", "esrecurse": "^4.3.0", "estraverse": "^5.2.0" }, "engines": { - "node": "^20.19.0 || ^22.13.0 || >=24" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "url": "https://opencollective.com/eslint" @@ -6416,7 +6480,6 @@ "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", "dev": true, "license": "Apache-2.0", - "peer": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, @@ -6424,40 +6487,25 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/eslint/node_modules/balanced-match": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", - "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", - "dev": true, - "license": "MIT", - "peer": true, - "engines": { - "node": "18 || 20 || >=22" - } - }, "node_modules/eslint/node_modules/brace-expansion": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.4.tgz", - "integrity": "sha512-h+DEnpVvxmfVefa4jFbCf5HdH5YMDXRsmKflpf1pILZWRFlTbJpxeU55nJl4Smt5HQaGzg1o6RHFPJaOqnmBDg==", + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.14.tgz", + "integrity": "sha512-MWPGfDxnyzKU7rNOW9SP/c50vi3xrmrua/+6hfPbCS2ABNWfx24vPidzvC7krjU/RTo235sV776ymlsMtGKj8g==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { - "balanced-match": "^4.0.2" - }, - "engines": { - "node": "18 || 20 || >=22" + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" } }, "node_modules/eslint/node_modules/eslint-visitor-keys": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-5.0.1.tgz", - "integrity": "sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==", + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz", + "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==", "dev": true, "license": "Apache-2.0", - "peer": true, "engines": { - "node": "^20.19.0 || ^22.13.0 || >=24" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "url": "https://opencollective.com/eslint" @@ -6469,7 +6517,6 @@ "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "locate-path": "^6.0.0", "path-exists": "^4.0.0" @@ -6487,7 +6534,6 @@ "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", "dev": true, "license": "ISC", - "peer": true, "dependencies": { "is-glob": "^4.0.3" }, @@ -6501,7 +6547,6 @@ "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "p-locate": "^5.0.0" }, @@ -6513,20 +6558,16 @@ } }, "node_modules/eslint/node_modules/minimatch": { - "version": "10.2.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.4.tgz", - "integrity": "sha512-oRjTw/97aTBN0RHbYCdtF1MQfvusSIBQM0IZEgzl6426+8jSC0nF1a/GmnVLpfB9yyr6g6FTqWqiZVbxrtaCIg==", + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", "dev": true, - "license": "BlueOak-1.0.0", - "peer": true, + "license": "ISC", "dependencies": { - "brace-expansion": "^5.0.2" + "brace-expansion": "^1.1.7" }, "engines": { - "node": "18 || 20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" + "node": "*" } }, "node_modules/eslint/node_modules/p-limit": { @@ -6535,7 +6576,6 @@ "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "yocto-queue": "^0.1.0" }, @@ -6552,7 +6592,6 @@ "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "p-limit": "^3.0.2" }, @@ -6573,33 +6612,31 @@ } }, "node_modules/espree": { - "version": "11.2.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-11.2.0.tgz", - "integrity": "sha512-7p3DrVEIopW1B1avAGLuCSh1jubc01H2JHc8B4qqGblmg5gI9yumBgACjWo4JlIc04ufug4xJ3SQI8HkS/Rgzw==", + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.4.0.tgz", + "integrity": "sha512-j6PAQ2uUr79PZhBjP5C5fhl8e39FmRnOjsD5lGnWrFU8i2G776tBK7+nP8KuQUTTyAZUwfQqXAgrVH5MbH9CYQ==", "dev": true, "license": "BSD-2-Clause", - "peer": true, "dependencies": { - "acorn": "^8.16.0", + "acorn": "^8.15.0", "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^5.0.1" + "eslint-visitor-keys": "^4.2.1" }, "engines": { - "node": "^20.19.0 || ^22.13.0 || >=24" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "url": "https://opencollective.com/eslint" } }, "node_modules/espree/node_modules/eslint-visitor-keys": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-5.0.1.tgz", - "integrity": "sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==", + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz", + "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==", "dev": true, "license": "Apache-2.0", - "peer": true, "engines": { - "node": "^20.19.0 || ^22.13.0 || >=24" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "url": "https://opencollective.com/eslint" @@ -6611,7 +6648,6 @@ "integrity": "sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==", "dev": true, "license": "BSD-3-Clause", - "peer": true, "dependencies": { "estraverse": "^5.1.0" }, @@ -6625,7 +6661,6 @@ "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", "dev": true, "license": "BSD-2-Clause", - "peer": true, "dependencies": { "estraverse": "^5.2.0" }, @@ -6639,7 +6674,6 @@ "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", "dev": true, "license": "BSD-2-Clause", - "peer": true, "engines": { "node": ">=4.0" } @@ -6666,8 +6700,7 @@ "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/fast-diff": { "version": "1.3.0", @@ -6698,16 +6731,14 @@ "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/fastq": { "version": "1.20.1", @@ -6744,7 +6775,6 @@ "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "flat-cache": "^4.0.0" }, @@ -6802,7 +6832,6 @@ "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "flatted": "^3.2.9", "keyv": "^4.5.4" @@ -6816,8 +6845,7 @@ "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.4.2.tgz", "integrity": "sha512-PjDse7RzhcPkIJwy5t7KPWQSZ9cAbzQXcafsetQoD7sOJRQlGikNbx7yZp2OotDnJyrDcbyRq3Ttb18iYOqkxA==", "dev": true, - "license": "ISC", - "peer": true + "license": "ISC" }, "node_modules/foreground-child": { "version": "3.3.1", @@ -6949,6 +6977,19 @@ "node": ">= 6" } }, + "node_modules/globals": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/globby": { "version": "10.0.1", "resolved": "https://registry.npmjs.org/globby/-/globby-10.0.1.tgz", @@ -7093,13 +7134,29 @@ "integrity": "sha512-d/Ld9aLbKpNwyl0KiM2CT1WYvkitQ1TSvmRtkcV8FKStiDoA7Slzgjmb/1G2yhKM1p0XeNOieaTbFZmU1d3Xuw==", "license": "MIT" }, + "node_modules/import-fresh": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz", + "integrity": "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=0.8.19" } @@ -7330,24 +7387,21 @@ "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/json5": { "version": "2.2.3", @@ -7404,7 +7458,6 @@ "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "json-buffer": "3.0.1" } @@ -7440,7 +7493,6 @@ "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "prelude-ls": "^1.2.1", "type-check": "~0.4.0" @@ -7493,6 +7545,13 @@ "dev": true, "license": "MIT" }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true, + "license": "MIT" + }, "node_modules/lodash.throttle": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/lodash.throttle/-/lodash.throttle-4.1.1.tgz", @@ -7866,8 +7925,7 @@ "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/node-releases": { "version": "2.0.36", @@ -7954,7 +8012,6 @@ "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "deep-is": "^0.1.3", "fast-levenshtein": "^2.0.6", @@ -8024,6 +8081,19 @@ "integrity": "sha512-WjR1hOeg+kki3ZIOjaf4b5WVcay1jaliKSYiEaB1XzwhMQZJxRdQRv0V31EKBYlxb4T7SK3hjfc/jxyU64BoSw==", "license": "(MIT AND Zlib)" }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "license": "MIT", + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/path-data-parser": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/path-data-parser/-/path-data-parser-0.1.0.tgz", @@ -8730,7 +8800,6 @@ "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">= 0.8.0" } @@ -8770,7 +8839,6 @@ "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=6" } @@ -9086,6 +9154,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/reusify": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz", @@ -9612,6 +9690,19 @@ "node": ">=8" } }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/style-mod": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.3.tgz", @@ -9884,7 +9975,6 @@ "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "prelude-ls": "^1.2.1" }, @@ -10022,7 +10112,6 @@ "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", "dev": true, "license": "BSD-2-Clause", - "peer": true, "dependencies": { "punycode": "^2.1.0" } @@ -10204,7 +10293,6 @@ "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=0.10.0" } @@ -10338,7 +10426,6 @@ "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=10" }, diff --git a/package.json b/package.json index 0b868042..9573ebe5 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,9 @@ "dev": "cross-env NODE_ENV=development rollup --config rollup.config.js", "build": "cross-env NODE_ENV=production rollup --config rollup.config.js", "lib": "cross-env NODE_ENV=lib rollup --config rollup.config.js", + "code": "eslint --max-warnings=0 --ext .ts,.tsx ./src", "code:fix": "eslint --max-warnings=0 --ext .ts,.tsx ./src --fix", + "code:unused": "eslint --max-warnings=0 --ext .ts,.tsx ./src --quiet --format json | node -e \"let d='';process.stdin.on('data',c=>d+=c).on('end',()=>{const r=JSON.parse(d);for(const f of r){for(const m of f.messages||[]){if(m.ruleId==='@typescript-eslint/no-unused-vars'||m.ruleId==='no-unused-vars'){console.log(f.filePath+':'+m.line+':'+m.column+' '+m.ruleId+' '+m.message);}}}})\"", "madge": "madge --circular .", "build:mathjax": "cd MathjaxToSVG && npm run build", "build:all": "npm run build:mathjax && npm run build", @@ -44,6 +46,7 @@ }, "devDependencies": { "jsesc": "^3.0.2", + "@eslint/eslintrc": "^3.1.0", "@babel/core": "^7.22.9", "@babel/preset-env": "^7.22.10", "@babel/preset-react": "^7.22.5", @@ -71,6 +74,7 @@ "cross-env": "^7.0.3", "cssnano": "^6.0.2", "dotenv": "^16.4.5", + "eslint": "^9.27.0", "eslint-config-prettier": "^9.0.0", "eslint-plugin-prettier": "^5.0.0", "lz-string": "^1.5.0", diff --git a/src/core/index.ts b/src/core/index.ts index 5406053d..06623866 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -9,7 +9,7 @@ export type { Point } from "src/types/types"; export const getEA = (view?: ExcalidrawView): ExcalidrawAutomate | null => { try { return window.ExcalidrawAutomate.getAPI(view); - } catch(e) { + } catch(_) { console.log({message: "Excalidraw not available", fn: getEA}); return null; } diff --git a/src/core/main.ts b/src/core/main.ts index ee6770e3..e9fde2ba 100644 --- a/src/core/main.ts +++ b/src/core/main.ts @@ -79,7 +79,7 @@ import { PreviewImageType } from "../types/utilTypes"; import { emulateCTRLClickForLinks,linkClickModifierType,PaneTarget } from "../utils/modifierkeyHelper"; import { imageCache } from "../shared/ImageCache"; import { StylesManager } from "./managers/StylesManager"; -import { CustomMutationObserver,log,setDebugging } from "../utils/debugHelper"; +import { CustomMutationObserver,log } from "../utils/debugHelper"; import { ExcalidrawConfig } from "../shared/ExcalidrawConfig"; import { EditorHandler } from "./editor/EditorHandler"; import { ExcalidrawLib } from "../types/excalidrawLib"; @@ -1592,7 +1592,6 @@ export default class ExcalidrawPlugin extends Plugin { await this.saveData(encryptedPersistedSettings); } if(opts.reEnableAutosave) this.settings.autosave = true; - setDebugging(this.settings.isDebugMode); } async saveSettings() { diff --git a/src/core/managers/CommandManager.ts b/src/core/managers/CommandManager.ts index 75676cb2..3dbe0f76 100644 --- a/src/core/managers/CommandManager.ts +++ b/src/core/managers/CommandManager.ts @@ -1031,7 +1031,6 @@ export class CommandManager { } return false; } - const view = this.app.workspace.getActiveViewOfType(ExcalidrawView); (async()=>{ const isLeftHanded = this.settings.isLeftHanded; await this.plugin.loadSettings(); @@ -1159,7 +1158,6 @@ export class CommandManager { let ef = view.excalidrawData.getFile(el.fileId); if(!ef) { await view.forceSave(); - let ef = view.excalidrawData.getFile(el.fileId); new Notice("Select a single image element and try again"); return false; } @@ -1202,7 +1200,6 @@ export class CommandManager { let ef = view.excalidrawData.getFile(el.fileId); if (!ef) { await view.forceSave(); - let ef = view.excalidrawData.getFile(el.fileId); new Notice("Select a single image element and try again"); return false; } @@ -1525,14 +1522,9 @@ export class CommandManager { ? await getImageSize(ea.imagesDict[el.fileId].dataURL) : null; let fnBase = ""; - let imageLink = ""; if(isFile) { fnBase = imageFile.basename; - imageLink = ref - ? `[[${imageFile.path}#${ref}]]` - : `[[${imageFile.path}]]`; } else { - imageLink = imageURL; const imagename = imageURL.match(/^.*\/([^?]*)\??.*$/)?.[1]; fnBase = imagename.substring(0,imagename.lastIndexOf(".")); } diff --git a/src/core/managers/EventManager.ts b/src/core/managers/EventManager.ts index 3da3adef..f363a945 100644 --- a/src/core/managers/EventManager.ts +++ b/src/core/managers/EventManager.ts @@ -162,7 +162,7 @@ export class EventManager { editorInsertText(editor, `${element.link}`); return; } - } catch (e) { + } catch (_) { } } }; diff --git a/src/core/managers/FileManager.ts b/src/core/managers/FileManager.ts index 18cf77a9..ca4aa4a2 100644 --- a/src/core/managers/FileManager.ts +++ b/src/core/managers/FileManager.ts @@ -455,7 +455,7 @@ export class PluginFileManager { imgMap.set(ext, { oldImgPath, newImgPath }); }); - imgMap.forEach((path, ext) => { + imgMap.forEach((path) => { const imgFile = this.app.vault.getFileByPath( normalizePath(path.oldImgPath), ); @@ -613,7 +613,7 @@ export class PluginFileManager { }); window.setTimeout(() => { - imgMap.forEach((imgPath: string, ext: string) => { + imgMap.forEach((imgPath: string) => { const imgFile = this.app.vault.getFileByPath( normalizePath(imgPath), ); diff --git a/src/core/managers/MarkdownPostProcessor.ts b/src/core/managers/MarkdownPostProcessor.ts index 1b4f01ed..9b96b381 100644 --- a/src/core/managers/MarkdownPostProcessor.ts +++ b/src/core/managers/MarkdownPostProcessor.ts @@ -44,7 +44,6 @@ let plugin: ExcalidrawPlugin; let app: App; let vault: Vault; let metadataCache: MetadataCache; -const DEBUGGING_MPP = false; const getDefaultWidth = (plugin: ExcalidrawPlugin): string => { diff --git a/src/core/managers/PackageManager.ts b/src/core/managers/PackageManager.ts index a8bb338b..c53a3459 100644 --- a/src/core/managers/PackageManager.ts +++ b/src/core/managers/PackageManager.ts @@ -205,7 +205,7 @@ export class PackageManager { try { REACT_PACKAGES = ""; - Array.from(this.packageMap.entries()).forEach(([win, p]) => { + Array.from(this.packageMap.entries()).forEach(([win, _]) => { this.deletePackage(win); }); diff --git a/src/core/settings.ts b/src/core/settings.ts index dbd92617..e2b9fc21 100644 --- a/src/core/settings.ts +++ b/src/core/settings.ts @@ -35,7 +35,6 @@ import { ModifierKeySet,ModifierSetType } from "src/utils/modifierkeyHelper"; import { ModifierKeySettingsComponent } from "src/shared/Dialogs/ModifierKeySettings"; import { ANNOTATED_PREFIX,CROPPED_PREFIX } from "src/utils/carveout"; import { EDITOR_FADEOUT } from "src/core/editor/EditorHandler"; -import { setDebugging } from "src/utils/debugHelper"; import { Rank } from "src/constants/actionIcons"; import { TAG_AUTOEXPORT,TAG_MDREADINGMODE,TAG_PDFEXPORT } from "src/constants/constSettingsTags"; import { HotkeyEditor } from "src/shared/Dialogs/HotkeyEditor"; @@ -256,7 +255,6 @@ export interface ExcalidrawSettings { longPressDesktop: number; longPressMobile: number; doubleClickLinkOpenViewMode: boolean; - isDebugMode: boolean; rank: Rank; modifierKeyOverrides: {modifiers: Modifier[], key: string}[]; showSplashscreen: boolean; @@ -801,7 +799,6 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = { longPressDesktop: 500, longPressMobile: 500, doubleClickLinkOpenViewMode: true, - isDebugMode: false, rank: "Bronze", modifierKeyOverrides: [ {modifiers: ["Mod"], key:"Enter"}, @@ -1529,7 +1526,6 @@ export class ExcalidrawSettingTab extends PluginSettingTab { containerEl.createEl("hr", { cls: "excalidraw-setting-hr" }); containerEl.createDiv({ text: t("AI_DESC"), cls: "setting-item-description" }); detailsEl = this.containerEl.createEl("details"); - const aiDetailsEl = detailsEl; detailsEl.createEl("summary", { text: t("AI_HEAD"), cls: "excalidraw-setting-h1", @@ -3795,7 +3791,6 @@ export class ExcalidrawSettingTab extends PluginSettingTab { setSanitizedHtml(el, t("EA_DESC")); }); detailsEl = containerEl.createEl("details"); - const eaDetailsEl = detailsEl; detailsEl.createEl("summary", { text: t("EA_HEAD"), cls: "excalidraw-setting-h1", @@ -3908,22 +3903,6 @@ export class ExcalidrawSettingTab extends PluginSettingTab { }), ); - if (process.env.NODE_ENV === 'development') { - new Setting(detailsEl) - .setName(t("DEBUGMODE_NAME")) - .setDesc(fragWithHTML(t("DEBUGMODE_DESC"))) - .addToggle((toggle) => - toggle - .setValue(this.plugin.settings.isDebugMode) - .onChange((value) => { - this.plugin.settings.isDebugMode = value; - setDebugging(value); - this.applySettingsUpdate(); - }), - ); - } - - new Setting(detailsEl) .setName(t("SLIDING_PANES_NAME")) .setDesc(fragWithHTML(t("SLIDING_PANES_DESC"))) diff --git a/src/shared/Dialogs/InsertLinkDialog.ts b/src/shared/Dialogs/InsertLinkDialog.ts index 63836324..e0d139c8 100644 --- a/src/shared/Dialogs/InsertLinkDialog.ts +++ b/src/shared/Dialogs/InsertLinkDialog.ts @@ -48,7 +48,6 @@ export class InsertLinkDialog extends FuzzySuggestModal { true, ); } - const link = getLink(this.plugin,{embed: false, path: filepath, alias: item.alias}); this.addText(getLink(this.plugin,{embed: false, path: filepath, alias: item.alias}), filepath, item.alias); } diff --git a/src/shared/Dialogs/ModifierKeySettings.ts b/src/shared/Dialogs/ModifierKeySettings.ts index 70924169..d3ac6988 100644 --- a/src/shared/Dialogs/ModifierKeySettings.ts +++ b/src/shared/Dialogs/ModifierKeySettings.ts @@ -70,7 +70,7 @@ export class ModifierKeySettingsComponent { }); }); - Object.entries(modifierKeys.rules).forEach(([action, rule]) => { + Object.entries(modifierKeys.rules).forEach(([_, rule]) => { const setting = new Setting(detailsEl) //@ts-ignore .setName(modifierKeyTooltipMessages()[modifierSetType][rule.result]); diff --git a/src/shared/Dialogs/Prompt.ts b/src/shared/Dialogs/Prompt.ts index 7681f6f1..dfa3ce05 100644 --- a/src/shared/Dialogs/Prompt.ts +++ b/src/shared/Dialogs/Prompt.ts @@ -454,7 +454,7 @@ export class GenericInputPrompt extends Modal { ? btn.setIcon(button.iconId) : btn.setButtonText(button.caption); button.tooltip && btn.setTooltip(button.tooltip); - btn.onClick((evt: MouseEvent) => { + btn.onClick(() => { const res = button.action(this.input); if (res) { this.input = res; diff --git a/src/shared/Dialogs/ReleaseNotes.ts b/src/shared/Dialogs/ReleaseNotes.ts index 0ae6f81a..f6204acc 100644 --- a/src/shared/Dialogs/ReleaseNotes.ts +++ b/src/shared/Dialogs/ReleaseNotes.ts @@ -26,7 +26,7 @@ export class ReleaseNotes extends Modal { onOpen(): void { //@ts-ignore - const { containerEl, contentEl, titleEl, headerEl } = this; + const { containerEl, titleEl, headerEl } = this; //this.contentEl.classList.add("excalidraw-release"); containerEl.classList.add("excalidraw-release"); titleEl.setText(this.options.title ?? `${t("RN_WELCOME")} ${this.version ?? ""}`.trim()); diff --git a/src/shared/EmbeddedFileLoader.ts b/src/shared/EmbeddedFileLoader.ts index 12a61ef1..48b84e50 100644 --- a/src/shared/EmbeddedFileLoader.ts +++ b/src/shared/EmbeddedFileLoader.ts @@ -162,7 +162,7 @@ export class EmbeddedFile { if(this.file && (this.plugin.isExcalidrawFile(this.file) || this.file.extension.toLowerCase() === "svg")) { try { this.colorMap = colorMapJSON ? JSON.parse(colorMapJSON.toLocaleLowerCase()) : null; - } catch (error) { + } catch (_) { this.colorMap = null; } } @@ -625,7 +625,7 @@ export class EmbeddedFilesLoader { if(!isHyperLink && !dataURL && !isLocalLink) { markdownRendererRecursionWatcthdog.add(file); try { - const result = await this.convertMarkdownToSVG(this.plugin, file, linkParts, depth); + const result = await this.convertMarkdownToSVG(this.plugin, file, linkParts); dataURL = result.dataURL; hasSVGwithBitmap = result.hasSVGwithBitmap; } finally { @@ -1150,7 +1150,6 @@ export class EmbeddedFilesLoader { plugin: ExcalidrawPlugin, file: TFile, linkParts: LinkParts, - depth: number, ): Promise<{dataURL: DataURL, hasSVGwithBitmap:boolean}> { //1. //get the markdown text diff --git a/src/shared/ExcalidrawAutomate.ts b/src/shared/ExcalidrawAutomate.ts index 60c0f6d7..5f866c51 100644 --- a/src/shared/ExcalidrawAutomate.ts +++ b/src/shared/ExcalidrawAutomate.ts @@ -94,7 +94,6 @@ import { EXCALIDRAW_AUTOMATE_INFO,EXCALIDRAW_SCRIPTENGINE_INFO } from "./Dialogs import { showColorPicker } from "./Dialogs/ColorPicker"; import { addBackOfTheNoteCard,getViewColorPalette,sceneRemoveInternalLinks } from "../utils/excalidrawViewUtils"; import { log } from "../utils/debugHelper"; -import { ExcalidrawLib } from "../types/excalidrawLib"; import { GlobalPoint } from "@zsviczian/excalidraw/types/math/src/types"; import { AddImageOptions,ImageInfo,KeyBlocker,ScriptSettingValue,SVGColorInfo } from "src/types/excalidrawAutomateTypes"; import { _measureText,cloneElement,createPNG,createSVG,ensureActiveScriptSettingsObject,errorMessage,filterColorMap,getEmbeddedFileForImageElment,getLineBox,getTemplate,isColorStringTransparent,isImageOrPDFTransclusion,isSVGColorInfo,mergeColorMapIntoSVGColorInfo,normalizeBindMode,normalizeFixedPoint,normalizeLinePoints,repositionElementsToCursor,svgColorInfoToColorMap,updateOrAddSVGColorInfo,verifyMinimumPluginVersion } from "src/utils/excalidrawAutomateUtils"; @@ -143,7 +142,6 @@ extendPlugins([ declare const PLUGIN_VERSION:string; declare var LZString: any; -declare const excalidrawLib: typeof ExcalidrawLib; const GAP = 4; @@ -2973,15 +2971,14 @@ export class ExcalidrawAutomate { /** * Gets the color information from an Excalidraw file. * @param {TFile} file - The Excalidraw file. - * @param {ExcalidrawImageElement} img - The image element. + * @param {ExcalidrawImageElement} img? - Optional, if not provided, the function returns colors from all elements. * @returns {Promise} Promise resolving to the SVG color information. */ - async getColosFromExcalidrawFile(file:TFile, img: ExcalidrawImageElement): Promise { + async getColosFromExcalidrawFile(file:TFile, img?: ExcalidrawImageElement): Promise { if(!file || !this.isExcalidrawFile(file)) { errorMessage("Must provide an Excalidraw file as input", "getColosFromExcalidrawFile()"); return; } - const ef = getEmbeddedFileForImageElment(this, img); const ed = new ExcalidrawData(this.plugin); if(file.extension === "excalidraw") { @@ -2993,7 +2990,8 @@ export class ExcalidrawAutomate { if (!ed.loaded) { return svgColors; } - ed.scene.elements.forEach((el:ExcalidrawElement) => { + (img ? ed.scene.elements.filter((el: ExcalidrawElement) => el.id === img.id) : ed.scene.elements) + .forEach((el:ExcalidrawElement) => { if("strokeColor" in el) { updateOrAddSVGColorInfo(svgColors, el.strokeColor, {stroke: true}); } @@ -3814,7 +3812,7 @@ export class ExcalidrawAutomate { return null; } - const {leaf, promise} = openLeaf({ + const { leaf } = openLeaf({ plugin: this.plugin, fnGetLeaf: () => getNewOrAdjacentLeaf(this.plugin, this.targetView.leaf), file, diff --git a/src/shared/ExcalidrawData.ts b/src/shared/ExcalidrawData.ts index 12f8eccb..d4046788 100644 --- a/src/shared/ExcalidrawData.ts +++ b/src/shared/ExcalidrawData.ts @@ -621,7 +621,7 @@ export class ExcalidrawData { container.boundElements = [{ id: textEl.id, type: "text" }].concat( boundEl, ); - } catch (e) {} + } catch (_) {} }); const ellipseAndRhombusContainerWrapping = !isVersionNewerThanOther(saveVersion,"1.8.16"); @@ -838,7 +838,7 @@ export class ExcalidrawData { position = data.search(RE_TEXTELEMENTS_FALLBACK_2); } if (position === -1) { - await this.setTextMode(textMode, false); + await this.setTextMode(textMode); this.loaded = true; return true; //Text Elements header does not exist } @@ -992,7 +992,7 @@ export class ExcalidrawData { //e.g. if the entire text elements section was deleted. this.findNewTextElementsInScene(); this.findNewElementLinksInScene(); //non-text element links - await this.setTextMode(textMode, true); + await this.setTextMode(textMode); this.loaded = true; return true; } @@ -1027,15 +1027,15 @@ export class ExcalidrawData { this.mermaids.clear(); this.findNewTextElementsInScene(); this.findNewElementLinksInScene(); - await this.setTextMode(TextMode.raw, true); //legacy files are always displayed in raw mode. + await this.setTextMode(TextMode.raw); //legacy files are always displayed in raw mode. this.loaded = true; return true; } - public async setTextMode(textMode: TextMode, forceupdate: boolean = false) { + public async setTextMode(textMode: TextMode) { if(!this.scene) return; this.textMode = textMode; - await this.updateSceneTextElements(forceupdate); + await this.updateSceneTextElements(); } @@ -1045,7 +1045,7 @@ export class ExcalidrawData { * @param forceupdate : will update text elements even if text contents has not changed, this will * correct sizing issues */ - private async updateSceneTextElements(forceupdate: boolean = false) { + private async updateSceneTextElements() { //update text in scene based on textElements Map //first get scene text elements const elementsMap = arrayToMap(this.scene.elements); @@ -1067,7 +1067,7 @@ export class ExcalidrawData { te.y = y; te.width = width; te.height = height; - } catch(e) { + } catch(_e) { } } } diff --git a/src/shared/ImageCache.ts b/src/shared/ImageCache.ts index 368b707c..37d3edb8 100644 --- a/src/shared/ImageCache.ts +++ b/src/shared/ImageCache.ts @@ -229,7 +229,7 @@ class ImageCache { new Promise((innerResolve, innerReject) => { const deleteRequest = store.delete(cursor.primaryKey); deleteRequest.onsuccess = () => innerResolve(); - deleteRequest.onerror = (ev: Event) => { + deleteRequest.onerror = () => { const error = deleteRequest.error; const errorMsg = `Failed to delete file with key: ${key}. Error: ${error.message}` innerReject(new Error(errorMsg)); @@ -383,7 +383,7 @@ class ImageCache { } this.touchCacheData(key, cachedData); return { cacheData: cachedData, key }; - } catch (e) { + } catch (_) { return undefined; } } diff --git a/src/shared/Scripts.ts b/src/shared/Scripts.ts index 16d07ed8..c0e86aa4 100644 --- a/src/shared/Scripts.ts +++ b/src/shared/Scripts.ts @@ -405,7 +405,7 @@ export class ScriptEngine { hint, instructions, ); - } catch (e) { + } catch (_) { return undefined; } } diff --git a/src/shared/Suggesters/FileSuggestionModal.ts b/src/shared/Suggesters/FileSuggestionModal.ts index b18882be..0a113bc7 100644 --- a/src/shared/Suggesters/FileSuggestionModal.ts +++ b/src/shared/Suggesters/FileSuggestionModal.ts @@ -102,7 +102,7 @@ export class FileSuggestionModal extends SuggestionModal { const path = item.file?.path ?? item.path; const pathLength = path.length - item.file.name.length; - const matchElements = matches.matches.map((m) => { + const matchElements = matches.matches.map(() => { return createSpan("suggestion-highlight"); }); const itemText = this.getItemText(item); diff --git a/src/shared/Suggesters/FolderSuggestionModal.ts b/src/shared/Suggesters/FolderSuggestionModal.ts index 45373eff..e0019f4d 100644 --- a/src/shared/Suggesters/FolderSuggestionModal.ts +++ b/src/shared/Suggesters/FolderSuggestionModal.ts @@ -67,7 +67,7 @@ export class FolderSuggestionModal extends SuggestionModal { } const pathLength = item.path.length - item.name.length; - const matchElements = matches.matches.map((m) => { + const matchElements = matches.matches.map(() => { return createSpan("suggestion-highlight"); }); for (let i = pathLength; i < item.path.length; i++) { diff --git a/src/shared/Suggesters/InlineLinkSuggester.ts b/src/shared/Suggesters/InlineLinkSuggester.ts index 21b4db82..221dd30d 100644 --- a/src/shared/Suggesters/InlineLinkSuggester.ts +++ b/src/shared/Suggesters/InlineLinkSuggester.ts @@ -268,7 +268,7 @@ export class InlineLinkSuggester extends SuggestionModal imple return tag.startsWith("#") ? tag.substring(1) : tag; } - getSuggestions(query: string): FuzzyMatch[] { + getSuggestions(): FuzzyMatch[] { if (this.mode === "tag") { return fuzzyMatchTextItems(this.activeSearchTerm ?? "", this.tagItems, (t) => this.getTagSearchValue(t.tag)); } diff --git a/src/shared/Suggesters/PathSuggestionModal.ts b/src/shared/Suggesters/PathSuggestionModal.ts index 667aa9f2..ca70c41b 100644 --- a/src/shared/Suggesters/PathSuggestionModal.ts +++ b/src/shared/Suggesters/PathSuggestionModal.ts @@ -107,7 +107,7 @@ export class PathSuggestionModal extends SuggestionModal< if (item instanceof TFile) { const pathLength = item.path.length - item.name.length; - const matchElements = matches.matches.map((m) => { + const matchElements = matches.matches.map(() => { return createSpan("suggestion-highlight"); }); for ( diff --git a/src/shared/Workers/compression-worker.ts b/src/shared/Workers/compression-worker.ts index 4e8c9ceb..c834eebf 100644 --- a/src/shared/Workers/compression-worker.ts +++ b/src/shared/Workers/compression-worker.ts @@ -113,7 +113,7 @@ function canCreateWorkerFromBlob() { worker.terminate(); URL.revokeObjectURL(url); IS_WORKER_SUPPORTED = true; - } catch (e) { + } catch (_) { IS_WORKER_SUPPORTED = false; } } diff --git a/src/shared/svgToExcalidraw/attributes.ts b/src/shared/svgToExcalidraw/attributes.ts index b9dda303..2c9995fc 100644 --- a/src/shared/svgToExcalidraw/attributes.ts +++ b/src/shared/svgToExcalidraw/attributes.ts @@ -18,15 +18,6 @@ export function getNum(el: Element, attr: string, backup?: number): number { return Number.isNaN(numVal) ? backup || 0 : numVal; } -const presAttrs = { - stroke: "stroke", - "stroke-opacity": "stroke-opacity", - "stroke-width": "stroke-width", - fill: "fill", - "fill-opacity": "fill-opacity", - opacity: "opacity", -} as const; - type ExPartialElement = Partial; type AttrHandlerArgs = { @@ -34,8 +25,16 @@ type AttrHandlerArgs = { exVals: ExPartialElement; }; +type PresAttrName = + | "stroke" + | "stroke-opacity" + | "stroke-width" + | "fill" + | "fill-opacity" + | "opacity"; + type PresAttrHandlers = { - [key in keyof typeof presAttrs]: (args: AttrHandlerArgs) => void; + [key in PresAttrName]: (args: AttrHandlerArgs) => void; }; const attrHandlers: PresAttrHandlers = { @@ -84,8 +83,8 @@ export function presAttrsToElementValues( const exVals = [...el.attributes].reduce((exVals, attr) => { const name = attr.name; - if (Object.keys(attrHandlers).includes(name)) { - attrHandlers[name as keyof PresAttrHandlers]({ el, exVals }); + if (name in attrHandlers) { + attrHandlers[name as PresAttrName]({ el, exVals }); } return exVals; diff --git a/src/utils/customEmbeddableUtils.ts b/src/utils/customEmbeddableUtils.ts index f17af6fc..30b50037 100644 --- a/src/utils/customEmbeddableUtils.ts +++ b/src/utils/customEmbeddableUtils.ts @@ -85,18 +85,6 @@ export const processLinkText = (linkText: string, view:ExcalidrawView): { subpat return { subpath, file }; } -export const generateEmbeddableLink = (src: string, theme: "light" | "dark"):string => { -/* const twitterLink = src.match(TWITTER_REG); - if (twitterLink) { - const tweetID = src.match(/.*\/(\d*)\?/)[1]; - if (tweetID) { - return `https://platform.twitter.com/embed/Tweet.html?frame=false&hideCard=false&hideThread=false&id=${tweetID}&lang=en&theme=${theme}&width=550px`; - //src = `https://twitframe.com/show?url=${encodeURIComponent(src)}`; - } - }*/ - return src; -} - export function setFileToLocalGraph(app: App, file: TFile) { let lgv: any; app.workspace.iterateAllLeaves((l) => { diff --git a/src/utils/debugHelper.ts b/src/utils/debugHelper.ts index ccc3a593..298b9731 100644 --- a/src/utils/debugHelper.ts +++ b/src/utils/debugHelper.ts @@ -1,11 +1,5 @@ export const durationTreshold = 0; //0.05; //ms -export function setDebugging(value: boolean) { - DEBUGGING = (process.env.NODE_ENV === 'development') - ? value - : false; -} - export let DEBUGGING = false; export const log = console.log.bind(window.console); diff --git a/src/utils/excalidrawViewUtils.ts b/src/utils/excalidrawViewUtils.ts index 5e721d7c..ae86bc4c 100644 --- a/src/utils/excalidrawViewUtils.ts +++ b/src/utils/excalidrawViewUtils.ts @@ -16,7 +16,6 @@ import { t } from "src/lang/helpers"; import { Mutable } from "@zsviczian/excalidraw/types/common/src/utility-types"; import { EmbeddedFile } from "src/shared/EmbeddedFileLoader"; import { CaptureUpdateAction } from "src/constants/constants"; -import ExcalidrawPlugin from "src/core/main"; import { setSanitizedHtml } from "./htmlUtils"; export async function insertImageToView( @@ -156,7 +155,7 @@ export function sceneRemoveInternalLinks(scene: {elements: readonly ExcalidrawEl return elements; } -export function openExternalLink (link:string, app: App, element?: ExcalidrawElement):boolean { +export function openExternalLink (link:string, app: App):boolean { link = getLinkFromMarkdownLink(link); if (link.match(/^cmd:\/\/.*/)) { const cmd = link.replace("cmd://", ""); @@ -511,7 +510,7 @@ export async function toggleImageAnchoring( ea.destroy(); } -export function onLoadMessages(plugin: ExcalidrawPlugin, scene: {elements: ExcalidrawElement[], appState: AppState}, data: string) { +export function onLoadMessages(scene: {elements: ExcalidrawElement[], appState: AppState}) { window.setTimeout(() => { if(!(scene.appState.frameRendering?.markerEnabled ?? true) && scene.elements.some(el=>el.type === "frame" && el.frameRole === "marker")) { new Notice(t("MARKER_FRAME_RENDERING_DISABLED_NOTICE")); diff --git a/src/utils/exportUtils.ts b/src/utils/exportUtils.ts index 982c190b..777ed987 100644 --- a/src/utils/exportUtils.ts +++ b/src/utils/exportUtils.ts @@ -445,7 +445,6 @@ export async function exportToPDF({ allPagesDiv.style.width = "100%"; allPagesDiv.style.height = "fit-content"; - let j = 0; for (const svg of SVG) { const svgWidth = parseFloat(svg.getAttribute('width') || '0'); const svgHeight = parseFloat(svg.getAttribute('height') || '0'); @@ -463,7 +462,6 @@ export async function exportToPDF({ const { width: pageWidth, height: pageHeight } = getPageSizePixels(pageDimForSvg, false); - let i = 0; for (const tile of tiles) { const pageDiv = createDiv(); pageDiv.addClass('print-page'); @@ -492,9 +490,7 @@ export async function exportToPDF({ pageDiv.appendChild(clonedSVG); allPagesDiv.appendChild(pageDiv); - i++; } - j++; } new Notice(t("EXPORTDIALOG_PDF_PROGRESS_NOTICE")); diff --git a/src/utils/fileUtils.ts b/src/utils/fileUtils.ts index 94d5b1b2..3a504f0d 100644 --- a/src/utils/fileUtils.ts +++ b/src/utils/fileUtils.ts @@ -1,13 +1,13 @@ -import { DataURL } from "@zsviczian/excalidraw/types/excalidraw/types"; -import { App,loadPdfJs,MetadataCache,normalizePath,Notice,requestUrl,RequestUrlResponse,TAbstractFile,TFile,TFolder,Vault } from "obsidian"; -import { DEVICE,EXCALIDRAW_PLUGIN,FRONTMATTER_KEYS,URLFETCHTIMEOUT } from "src/constants/constants"; -import { ExcalidrawSettings } from "src/core/settings"; -import { errorlog,getDataURL } from "./coreUtils"; -import ExcalidrawPlugin from "src/core/main"; -import { getAttachmentsFolderAndFilePath,splitFolderAndFilename } from "./pathUtils"; -import type ExcalidrawView from "src/view/ExcalidrawView"; -import { IMAGE_MIME_TYPES,MimeType } from "src/types/embeddedFileLoaderTypes"; -import { setElementDisplay } from "./htmlUtils"; +import { DataURL } from "@zsviczian/excalidraw/types/excalidraw/types"; +import { App,loadPdfJs,MetadataCache,normalizePath,Notice,requestUrl,RequestUrlResponse,TAbstractFile,TFile,TFolder,Vault } from "obsidian"; +import { DEVICE,EXCALIDRAW_PLUGIN,FRONTMATTER_KEYS,URLFETCHTIMEOUT } from "src/constants/constants"; +import { ExcalidrawSettings } from "src/core/settings"; +import { errorlog,getDataURL } from "./coreUtils"; +import ExcalidrawPlugin from "src/core/main"; +import { getAttachmentsFolderAndFilePath,splitFolderAndFilename } from "./pathUtils"; +import type ExcalidrawView from "src/view/ExcalidrawView"; +import { IMAGE_MIME_TYPES,MimeType } from "src/types/embeddedFileLoaderTypes"; +import { setElementDisplay } from "./htmlUtils"; export { splitFolderAndFilename } from "./pathUtils"; type ImageExtension = keyof typeof IMAGE_MIME_TYPES; @@ -178,7 +178,7 @@ const getFileFromURL = async (url: string, mimeType: MimeType, timeout: number = json: null, text: null, }; - } catch (e) { + } catch (_) { //errorlog({ where: getFileFromURL, message: e.message, url: url }); return null; } @@ -196,7 +196,7 @@ const getFileFromURLFallback = async (url: string, mimeType: MimeType, timeout: timeoutPromise, requestUrl({url: url, throw: false }), //if method: "get" is added it won't load images on Android, contentType: mimeType, ]) - } catch (e) { + } catch (_) { errorlog({where: getFileFromURLFallback, message: `URL did not load within timeout period of ${timeout}ms`, url: url}); return null; } diff --git a/src/utils/modifierkeyHelper.ts b/src/utils/modifierkeyHelper.ts index 2321bad7..6fa485cf 100644 --- a/src/utils/modifierkeyHelper.ts +++ b/src/utils/modifierkeyHelper.ts @@ -111,7 +111,7 @@ export const scaleToFullsizeModifier = (ev: KeyEvent) => { const keySet = ((DEVICE.isMacOS || DEVICE.isIOS) ? settings.modifierKeyConfig.Mac : settings.modifierKeyConfig.Win )["InternalDragAction"]; const rule:ModifierKey = keySet.rules.find((r:ModifierKey) => r.result === "image-fullsize"); if(!rule) return false; - const { shift, ctrl_cmd, alt_opt, meta_ctrl, result } = rule; + const { shift, ctrl_cmd, alt_opt, meta_ctrl } = rule; return ( (isSHIFT(ev) === shift) && (isWinCTRLorMacCMD(ev) === ctrl_cmd) && diff --git a/src/utils/obsidianUtils.ts b/src/utils/obsidianUtils.ts index 37007129..e51b75dd 100644 --- a/src/utils/obsidianUtils.ts +++ b/src/utils/obsidianUtils.ts @@ -1,15 +1,15 @@ -import { -App, -Editor, -FrontMatterCache, -MarkdownView, -OpenViewState,parseFrontMatterEntry,TextFileView,TFile,View,ViewState,Workspace,WorkspaceLeaf,WorkspaceSplit -} from "obsidian"; -import ExcalidrawPlugin from "../core/main"; -import { linkClickModifierType,ModifierKeys } from "./modifierkeyHelper"; -import { DEVICE,EXCALIDRAW_PLUGIN,VIEW_TYPE_EXCALIDRAW } from "src/constants/constants"; -import yaml from "js-yaml"; -import type ExcalidrawView from "src/view/ExcalidrawView"; +import { +App, +Editor, +FrontMatterCache, +MarkdownView, +OpenViewState,parseFrontMatterEntry,TextFileView,TFile,View,ViewState,Workspace,WorkspaceLeaf,WorkspaceSplit +} from "obsidian"; +import ExcalidrawPlugin from "../core/main"; +import { linkClickModifierType,ModifierKeys } from "./modifierkeyHelper"; +import { DEVICE,EXCALIDRAW_PLUGIN,VIEW_TYPE_EXCALIDRAW } from "src/constants/constants"; +import yaml from "js-yaml"; +import type ExcalidrawView from "src/view/ExcalidrawView"; export const getParentOfClass = (element: Element, cssClass: string):HTMLElement | null => { let parent = element.parentElement; @@ -45,7 +45,7 @@ export const getLeaf = ( ) => { const newTab = ():WorkspaceLeaf => { if(!plugin.settings.openInMainWorkspace) return plugin.app.workspace.getLeaf('tab'); - const [leafLoc, mainLeavesIds] = getLeafLoc(origo); + const [leafLoc, _] = getLeafLoc(origo); if(leafLoc === 'main') return plugin.app.workspace.getLeaf('tab'); return getNewOrAdjacentLeaf(plugin,origo); } diff --git a/src/utils/settingsKeyObfuscation.ts b/src/utils/settingsKeyObfuscation.ts index 8f9c23a2..fa7584b8 100644 --- a/src/utils/settingsKeyObfuscation.ts +++ b/src/utils/settingsKeyObfuscation.ts @@ -51,7 +51,7 @@ const decodeBase64 = (value: string): Uint8Array | null => { if (typeof Buffer !== "undefined") { return new Uint8Array(Buffer.from(value, "base64")); } - } catch (error) { + } catch (_) { return null; } @@ -82,7 +82,7 @@ const decodeObfuscatedAPIKeyPayload = (value: string): string | null => { return payload.startsWith(API_KEY_PAYLOAD_MARKER) ? payload.slice(API_KEY_PAYLOAD_MARKER.length) : null; - } catch (error) { + } catch (_) { return null; } }; diff --git a/src/utils/utils.ts b/src/utils/utils.ts index e55e60f1..4f5ad2f2 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -1,49 +1,48 @@ -import { -App, -Notice, -request,requestUrl, -TFile, -TFolder, -} from "obsidian"; -import { Random } from "roughjs/bin/math"; -import { BinaryFileData } from "@zsviczian/excalidraw/types/excalidraw/types"; -import { errorlog,getDataURL } from "./coreUtils"; -import { -exportToSvg, -exportToBlob, -IMAGE_TYPES, -FRONTMATTER_KEYS, -EXCALIDRAW_PLUGIN, -getCommonBoundingBox, -DEVICE, -getContainerElement, -SCRIPT_INSTALL_FOLDER, -VIEW_TYPE_EXCALIDRAW, -} from "../constants/constants"; -import ExcalidrawPlugin from "../core/main"; -import { ExcalidrawElement,ExcalidrawImageElement,ExcalidrawTextElement,ImageCrop } from "@zsviczian/excalidraw/types/element/src/types"; -import { getDataURLFromURL,getIMGFilename,getMimeType,getURLImageExtension } from "./fileUtils"; -import { generateEmbeddableLink } from "./customEmbeddableUtils"; -import { FILENAMEPARTS } from "../types/utilTypes"; -import { Mutable } from "@zsviczian/excalidraw/types/common/src/utility-types"; -import { getExcalidrawViews,getFileCSSClasses } from "./obsidianUtils"; -import { cleanBlockRef,cleanSectionHeading } from "./pathUtils"; -import { addAppendUpdateCustomData } from "./elementCustomDataUtils"; -import { updateElementLinksToObsidianLinks } from "./excalidrawAutomateUtils"; -import { CropImage } from "../shared/CropImage"; -import opentype from 'opentype.js'; -import { runCompressionWorker } from "src/shared/Workers/compression-worker"; -import Pool from "es6-promise-pool"; -import { t } from "src/lang/helpers"; -import { log } from "./debugHelper"; -import { VersionMismatchPrompt } from "src/shared/Dialogs/VersionMismatch"; -import { ExcalidrawSettings } from "src/core/settings"; -import { FileData } from "src/types/embeddedFileLoaderTypes"; -import { ExportSettings } from "src/types/exportUtilTypes"; -import { UIMode } from "src/shared/Dialogs/UIModeSettingComponent"; -import ExcalidrawView from "../view/ExcalidrawView"; -import { emptyDrawingElements } from "src/constants/emptydrawing"; -import { sanitizedFragment } from "./htmlUtils"; +import { +App, +Notice, +request,requestUrl, +TFile, +TFolder, +} from "obsidian"; +import { Random } from "roughjs/bin/math"; +import { BinaryFileData } from "@zsviczian/excalidraw/types/excalidraw/types"; +import { errorlog,getDataURL } from "./coreUtils"; +import { +exportToSvg, +exportToBlob, +IMAGE_TYPES, +FRONTMATTER_KEYS, +EXCALIDRAW_PLUGIN, +getCommonBoundingBox, +DEVICE, +getContainerElement, +SCRIPT_INSTALL_FOLDER, +VIEW_TYPE_EXCALIDRAW, +} from "../constants/constants"; +import ExcalidrawPlugin from "../core/main"; +import { ExcalidrawElement,ExcalidrawImageElement,ExcalidrawTextElement,ImageCrop } from "@zsviczian/excalidraw/types/element/src/types"; +import { getDataURLFromURL,getIMGFilename,getMimeType,getURLImageExtension } from "./fileUtils"; +import { FILENAMEPARTS } from "../types/utilTypes"; +import { Mutable } from "@zsviczian/excalidraw/types/common/src/utility-types"; +import { getExcalidrawViews,getFileCSSClasses } from "./obsidianUtils"; +import { cleanBlockRef,cleanSectionHeading } from "./pathUtils"; +import { addAppendUpdateCustomData } from "./elementCustomDataUtils"; +import { updateElementLinksToObsidianLinks } from "./excalidrawAutomateUtils"; +import { CropImage } from "../shared/CropImage"; +import opentype from 'opentype.js'; +import { runCompressionWorker } from "src/shared/Workers/compression-worker"; +import Pool from "es6-promise-pool"; +import { t } from "src/lang/helpers"; +import { log } from "./debugHelper"; +import { VersionMismatchPrompt } from "src/shared/Dialogs/VersionMismatch"; +import { ExcalidrawSettings } from "src/core/settings"; +import { FileData } from "src/types/embeddedFileLoaderTypes"; +import { ExportSettings } from "src/types/exportUtilTypes"; +import { UIMode } from "src/shared/Dialogs/UIModeSettingComponent"; +import ExcalidrawView from "../view/ExcalidrawView"; +import { emptyDrawingElements } from "src/constants/emptydrawing"; +import { sanitizedFragment } from "./htmlUtils"; export { errorlog, getDataURL } from "./coreUtils"; export { addAppendUpdateCustomData } from "./elementCustomDataUtils"; @@ -219,24 +218,6 @@ export function wrapTextAtCharLength( return outstring.replace(/\n$/, ""); } -const rotate = ( - pointX: number, - pointY: number, - centerX: number, - centerY: number, - angle: number, -): [number, number] => - // π‘Žβ€²π‘₯=(π‘Žπ‘₯βˆ’π‘π‘₯)cosπœƒβˆ’(π‘Žπ‘¦βˆ’π‘π‘¦)sinπœƒ+𝑐π‘₯ - // π‘Žβ€²π‘¦=(π‘Žπ‘₯βˆ’π‘π‘₯)sinπœƒ+(π‘Žπ‘¦βˆ’π‘π‘¦)cosπœƒ+𝑐𝑦. - // https://math.stackexchange.com/questions/2204520/how-do-i-rotate-a-line-segment-in-a-specific-point-on-the-line - [ - (pointX - centerX) * Math.cos(angle) - - (pointY - centerY) * Math.sin(angle) + - centerX, - (pointX - centerX) * Math.sin(angle) + - (pointY - centerY) * Math.cos(angle) + - centerY, - ]; export function rotatedDimensions ( element: ExcalidrawElement, @@ -339,9 +320,6 @@ export async function getSVG ( let elements:ExcalidrawElement[] = scene.elements; if(elements.some(el => el.type === "embeddable")) { elements = JSON.parse(JSON.stringify(elements)); - elements.filter(el => el.type === "embeddable").forEach((el:any) => { - el.link = generateEmbeddableLink(el.link, scene.appState?.theme ?? "light"); - }); } elements = srcFile @@ -393,7 +371,7 @@ export async function getSVG ( } } return svg; - } catch (error) { + } catch (_) { return null; } }; @@ -685,7 +663,7 @@ export async function decompressAsync (data: string): Promise { return await runCompressionWorker(data, "decompress"); }; -export function decompress (data: string, isAsync:boolean = false): string { +export function decompress (data: string): string { let cleanedData = ''; const length = data.length; diff --git a/src/view/ExcalidrawView.ts b/src/view/ExcalidrawView.ts index 0ab323f8..4ae9372a 100644 --- a/src/view/ExcalidrawView.ts +++ b/src/view/ExcalidrawView.ts @@ -136,7 +136,7 @@ import { setDynamicStyle } from "../utils/dynamicStyling"; import { CustomEmbeddable,renderWebView } from "./components/CustomEmbeddable"; import { addBackOfTheNoteCard,deleteAppStateKeys,getExcalidrawFileForwardLinks,getFrameBasedOnFrameNameOrId,getLinkTextFromLink,insertEmbeddableToView,insertImageToView,isTextImageTransclusion,onLoadMessages,openExternalLink,parseObsidianLink,renderContextMenuAction,sceneRemoveInternalLinks,setMobileNavbarPosition,tmpBruteForceCleanup,toggleImageAnchoring } from "../utils/excalidrawViewUtils"; import { imageCache } from "../shared/ImageCache"; -import { CanvasNodeFactory,ObsidianCanvasNode } from "./managers/CanvasNodeFactory"; +import { CanvasNodeFactory } from "./managers/CanvasNodeFactory"; import { EmbeddableMenu } from "./components/menu/EmbeddableActionsMenu"; import { useDefaultExcalidrawFrame } from "../utils/customEmbeddableUtils"; import { UniversalInsertFileModal } from "../shared/Dialogs/UniversalInsertFileModal"; @@ -1122,7 +1122,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{ this, addFiles, ); - this.setDirty(1); + this.setDirty(); }, () => {} ); }; @@ -1145,7 +1145,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{ const nextAnchor = Boolean(link.endsWith("|100%")); ef.resetImage(this.file.path, link); this.excalidrawData.setFile(fileId, ef); - this.setDirty(2); + this.setDirty(); if(originalAnchor !== nextAnchor) { await toggleImageAnchoring(el, this, nextAnchor, ef) } @@ -1717,7 +1717,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{ this.semaphores.scriptsReady = true; - const wheelEvent = (ev:WheelEvent) => { + const wheelEvent = () => { if(this.semaphores.wheelTimeout) window.clearTimeout(this.semaphores.wheelTimeout); if(this.semaphores.hoverSleep && this.excalidrawAPI) this.clearHoverPreview(); this.semaphores.wheelTimeout = window.setTimeout(()=>{ @@ -2049,7 +2049,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{ super.unload(); } - async onUnloadFile(file: TFile): Promise { + async onUnloadFile(): Promise { //deliberately not calling super.onUnloadFile() to avoid autosave (saved in unload) let counter = 0; while (this.semaphores.saving && (counter++ < 200)) { @@ -2563,12 +2563,12 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{ const notice = new Notice(t("MASK_FILE_NOTICE"), 5000); //add click and hold event listner to the notice let noticeTimeout:number; - this.registerDomEvent(notice.noticeEl,"pointerdown", (ev:MouseEvent) => { + this.registerDomEvent(notice.noticeEl,"pointerdown",() => { noticeTimeout = window.setTimeout(()=>{ window.open("https://youtu.be/uHFd0XoHRxE"); },1000); }) - this.registerDomEvent(notice.noticeEl,"pointerup", (ev:MouseEvent) => { + this.registerDomEvent(notice.noticeEl,"pointerup", () => { window.clearTimeout(noticeTimeout); }) } @@ -2702,7 +2702,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{ } await this.loadDrawing(true); - onLoadMessages(this.plugin, this.excalidrawData.scene,this.data); + onLoadMessages(this.excalidrawData.scene); if(this.plugin.ea.onFileOpenHook) { const tempEA = getEA(this); @@ -2756,7 +2756,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{ }); } - private getGridColor(bgColor: string, st: AppState): { Bold: string, Regular: string } { + private getGridColor(bgColor: string): { Bold: string, Regular: string } { const cm = this.plugin.ea.getCM(bgColor); const isDark = cm.isDark(); @@ -3017,7 +3017,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{ //place into correct element layer sequence const currentLayer = sceneElementIds.indexOf(incomingElement.id); //remove current element from scene - const elToMove = sceneElements.splice(currentLayer,1); + sceneElements.splice(currentLayer,1); if(idx === 0) { sceneElements.splice(0,0,incomingElement); if(currentLayer!== 0) { @@ -3069,7 +3069,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{ //changing files could result in a race condition for sync. If at the end of sync there are differences //set dirty will trigger an autosave if(this.getSceneVersion(inData.scene.elements) !== this.previousSceneVersion) { - this.setDirty(3); + this.setDirty(); } this.updateScene({elements: sceneElements, captureUpdate: CaptureUpdateAction.IMMEDIATELY}); if(reloadFiles.size>0) { @@ -3187,7 +3187,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{ this.plugin.settings.compress !== isCompressed && !this.isEditedAsMarkdownInOtherView() ) { - this.setDirty(4); + this.setDirty(); } } @@ -3208,7 +3208,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{ this.setUIMode(uiMode); } - public setDirty(location?:number) { + public setDirty() { if(this.semaphores.saving) return; //do not set dirty if saving if(!this.isDirty()) { //the autosave timer should start when the first stroke was made... thus avoiding an immediate impact by saving right then @@ -3441,7 +3441,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{ await ea.addElementsToView(false, false, false); ea.destroy(); } - } catch(e) { + } catch(_) { }; } @@ -3483,7 +3483,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{ .setTitle(t("EXPORT_IMAGE")) .setIcon(EXPORT_IMG_ICON_NAME) .setSection("pane") - .onClick(async (ev) => { + .onClick(async () => { if (!this.excalidrawAPI || !this.file) { return; } @@ -3933,7 +3933,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{ if (save) { await this.save(false); //preventReload=false will ensure that markdown links are paresed and displayed correctly } else { - this.setDirty(5); + this.setDirty(); } return true; }; @@ -4252,7 +4252,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{ private lastKeyDownPosition: {x: number, y: number} = {x: 0, y: 0}; - private excalidrawDIVonKeyUp = (event: KeyboardEvent) => { + private excalidrawDIVonKeyUp = () => { this.lastKeyDownPosition = {x: 0, y: 0}; }; @@ -4379,7 +4379,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{ this.updateScene( { appState:{ - gridColor: this.getGridColor(canvasColor, st), + gridColor: this.getGridColor(canvasColor), }, captureUpdate: CaptureUpdateAction.NEVER }) @@ -4423,7 +4423,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{ sceneVersion !== this.previousSceneVersion) ) { this.previousSceneVersion = sceneVersion; - this.setDirty(6.1); + this.setDirty(); } } @@ -4473,11 +4473,11 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{ } if(st.theme !== this.previousTheme && this.file === this.excalidrawData.file) { this.previousTheme = st.theme; - this.setDirty(5.1); + this.setDirty(); } if(st.viewBackgroundColor !== this.previousBackgroundColor && this.file === this.excalidrawData.file) { this.previousBackgroundColor = st.viewBackgroundColor; - this.setDirty(6); + this.setDirty(); if(this.colorChangeTimer) { window.clearTimeout(this.colorChangeTimer); } @@ -4627,7 +4627,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{ modal.open(file, this.currentPosition); } } - this.setDirty(9); + this.setDirty(); })) { return false; } @@ -4698,7 +4698,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{ //if there are image elements //first delete corresponding "old" text elements - for(const [el, [link, file]] of imageElementsMap) { + for(const [el, _] of imageElementsMap) { const clone = cloneElement(el); clone.isDeleted = true; this.excalidrawData.deleteTextElement(clone.id); @@ -4807,7 +4807,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{ // parsed textElements cache if (isDeleted) { this.excalidrawData.deleteTextElement(textElement.id); - this.setDirty(7); + this.setDirty(); return {updatedNextOriginalText: null, nextLink: null}; } @@ -4867,7 +4867,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{ modal.open(file, center); } } - this.setDirty(9); + this.setDirty(); } }); })) { @@ -4882,7 +4882,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{ ) { //the user made changes to the text or the text is missing from Excalidraw Data (recently copy/pasted) //setTextElement will attempt a quick parse (without processing transclusions) - this.setDirty(8); + this.setDirty(); // setTextElement will invoke this callback function in case quick parse was not possible, the parsed text contains transclusions // in this case I need to update the scene asynchronously when parsing is complete @@ -4910,7 +4910,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{ elements[elements.indexOf(el[0])] = clone; this.updateScene({elements, captureUpdate: CaptureUpdateAction.NEVER}); if(clone.containerId) this.updateContainerSize(clone.containerId); - this.setDirty(8.1); + this.setDirty(); } api.history.clear(); }; @@ -5164,7 +5164,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{ title = `${title} ${i}`; } addBackOfTheNoteCard(this, title, false, data); - } catch (e) { + } catch (_) { } } @@ -5737,7 +5737,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{ const filecount = this.app.vault.getFiles().filter(f => this.plugin.isExcalidrawFile(f)).length; const rank = filecount < 200 ? "Bronze" : filecount < 750 ? "Silver" : filecount < 2000 ? "Gold" : "Platinum"; const nextRankDelta = filecount < 200 ? 200 - filecount : filecount < 750 ? 750 - filecount : filecount < 2000 ? 2000 - filecount : 0; - const { decoration, title } = SwordColors[rank as Rank]; + const { title } = SwordColors[rank as Rank]; return React.createElement( WelcomeScreen, {}, @@ -5929,7 +5929,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{ } return React.createElement(CustomEmbeddable, {element,view:this, appState, linkText}); - } catch(e) { + } catch(_) { return null; } } diff --git a/src/view/components/menu/ToolsPanel.tsx b/src/view/components/menu/ToolsPanel.tsx index 9be8b1e9..5ce0ef6b 100644 --- a/src/view/components/menu/ToolsPanel.tsx +++ b/src/view/components/menu/ToolsPanel.tsx @@ -134,7 +134,7 @@ export class ToolsPanel extends React.Component { } setTheme(theme: "dark" | "light") { - this.setState((prevState: PanelState) => { + this.setState(() => { return { theme, }; @@ -395,14 +395,14 @@ export class ToolsPanel extends React.Component { ); } - actionImportSVG(e:React.MouseEvent) { + actionImportSVG() { const view = this.getView(); const plugin = view?.plugin; if (!view || !plugin) return; plugin.importSVGDialog.start(view); } - actionCropImage(e:React.MouseEvent) { + actionCropImage() { // @ts-ignore this.view.app.commands.executeCommandById("obsidian-excalidraw-plugin:crop-image"); } @@ -777,7 +777,7 @@ export class ToolsPanel extends React.Component { {isDownloaded ? group : (group === "" ? "User" : "User/"+group)}
{Object.entries(this.state.scriptIconMap) - .filter(([k,v])=>v.group === group) + .filter(([_,v])=>v.group === group) .sort() .map(([key,value])=>(