diff --git a/package-lock.json b/package-lock.json index f5a4f88ad7b..f2f65c5e59f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -58,9 +58,9 @@ "@babel/preset-flow": "7.24.1", "@babel/preset-react": "7.24.1", "@eslint-community/regexpp": "4.10.0", - "@typescript-eslint/eslint-plugin": "7.4.0", - "@typescript-eslint/parser": "7.4.0", - "@typescript-eslint/utils": "7.4.0", + "@typescript-eslint/eslint-plugin": "^7.7.1", + "@typescript-eslint/parser": "^7.7.1", + "@typescript-eslint/utils": "^7.7.1", "builtin-modules": "3.3.0", "bytes": "3.1.2", "eslint": "8.57.0", @@ -68,7 +68,7 @@ "eslint-plugin-jsx-a11y": "6.8.0", "eslint-plugin-react": "7.34.1", "eslint-plugin-react-hooks": "4.6.0", - "eslint-plugin-sonarjs": "0.25.0", + "eslint-plugin-sonarjs": "^0.26.0-2910", "express": "4.19.2", "functional-red-black-tree": "1.0.1", "htmlparser2": "9.1.0", @@ -96,7 +96,7 @@ }, "devDependencies": { "@types/bytes": "3.1.4", - "@types/eslint": "8.56.6", + "@types/eslint": "^8.56.10", "@types/eslint-scope": "3.7.7", "@types/estree": "1.0.5", "@types/express": "4.17.21", @@ -3256,9 +3256,9 @@ } }, "node_modules/@types/eslint": { - "version": "8.56.6", - "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@types/eslint/-/eslint-8.56.6.tgz", - "integrity": "sha512-ymwc+qb1XkjT/gfoQwxIeHZ6ixH23A+tCT2ADSA/DPVKzAjwYkTXBMCQ/f6fe4wEa85Lhp26VPeUxI7wMhAi7A==", + "version": "8.56.10", + "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@types/eslint/-/eslint-8.56.10.tgz", + "integrity": "sha512-Shavhk87gCtY2fhXDctcfS3e6FdxWkCx1iUZ9eEUbh7rTqlZT0/IzOkCOVt0fCjcFuZ9FPYfuezTBImfHCDBGQ==", "dev": true, "dependencies": { "@types/estree": "*", @@ -3491,22 +3491,22 @@ } }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "7.4.0", - "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.4.0.tgz", - "integrity": "sha512-yHMQ/oFaM7HZdVrVm/M2WHaNPgyuJH4WelkSVEWSSsir34kxW2kDJCxlXRhhGWEsMN0WAW/vLpKfKVcm8k+MPw==", + "version": "7.7.1", + "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.7.1.tgz", + "integrity": "sha512-KwfdWXJBOviaBVhxO3p5TJiLpNuh2iyXyjmWN0f1nU87pwyvfS0EmjC6ukQVYVFJd/K1+0NWGPDXiyEyQorn0Q==", "inBundle": true, "dependencies": { - "@eslint-community/regexpp": "^4.5.1", - "@typescript-eslint/scope-manager": "7.4.0", - "@typescript-eslint/type-utils": "7.4.0", - "@typescript-eslint/utils": "7.4.0", - "@typescript-eslint/visitor-keys": "7.4.0", + "@eslint-community/regexpp": "^4.10.0", + "@typescript-eslint/scope-manager": "7.7.1", + "@typescript-eslint/type-utils": "7.7.1", + "@typescript-eslint/utils": "7.7.1", + "@typescript-eslint/visitor-keys": "7.7.1", "debug": "^4.3.4", "graphemer": "^1.4.0", - "ignore": "^5.2.4", + "ignore": "^5.3.1", "natural-compare": "^1.4.0", - "semver": "^7.5.4", - "ts-api-utils": "^1.0.1" + "semver": "^7.6.0", + "ts-api-utils": "^1.3.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -3522,15 +3522,15 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "7.4.0", - "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/parser/-/parser-7.4.0.tgz", - "integrity": "sha512-ZvKHxHLusweEUVwrGRXXUVzFgnWhigo4JurEj0dGF1tbcGh6buL+ejDdjxOQxv6ytcY1uhun1p2sm8iWStlgLQ==", + "version": "7.7.1", + "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/parser/-/parser-7.7.1.tgz", + "integrity": "sha512-vmPzBOOtz48F6JAGVS/kZYk4EkXao6iGrD838sp1w3NQQC0W8ry/q641KU4PrG7AKNAf56NOcR8GOpH8l9FPCw==", "inBundle": true, "dependencies": { - "@typescript-eslint/scope-manager": "7.4.0", - "@typescript-eslint/types": "7.4.0", - "@typescript-eslint/typescript-estree": "7.4.0", - "@typescript-eslint/visitor-keys": "7.4.0", + "@typescript-eslint/scope-manager": "7.7.1", + "@typescript-eslint/types": "7.7.1", + "@typescript-eslint/typescript-estree": "7.7.1", + "@typescript-eslint/visitor-keys": "7.7.1", "debug": "^4.3.4" }, "engines": { @@ -3546,28 +3546,28 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "7.4.0", - "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/scope-manager/-/scope-manager-7.4.0.tgz", - "integrity": "sha512-68VqENG5HK27ypafqLVs8qO+RkNc7TezCduYrx8YJpXq2QGZ30vmNZGJJJC48+MVn4G2dCV8m5ZTVnzRexTVtw==", + "version": "7.7.1", + "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/scope-manager/-/scope-manager-7.7.1.tgz", + "integrity": "sha512-PytBif2SF+9SpEUKynYn5g1RHFddJUcyynGpztX3l/ik7KmZEv19WCMhUBkHXPU9es/VWGD3/zg3wg90+Dh2rA==", "inBundle": true, "dependencies": { - "@typescript-eslint/types": "7.4.0", - "@typescript-eslint/visitor-keys": "7.4.0" + "@typescript-eslint/types": "7.7.1", + "@typescript-eslint/visitor-keys": "7.7.1" }, "engines": { "node": "^18.18.0 || >=20.0.0" } }, "node_modules/@typescript-eslint/type-utils": { - "version": "7.4.0", - "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/type-utils/-/type-utils-7.4.0.tgz", - "integrity": "sha512-247ETeHgr9WTRMqHbbQdzwzhuyaJ8dPTuyuUEMANqzMRB1rj/9qFIuIXK7l0FX9i9FXbHeBQl/4uz6mYuCE7Aw==", + "version": "7.7.1", + "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/type-utils/-/type-utils-7.7.1.tgz", + "integrity": "sha512-ZksJLW3WF7o75zaBPScdW1Gbkwhd/lyeXGf1kQCxJaOeITscoSl0MjynVvCzuV5boUz/3fOI06Lz8La55mu29Q==", "inBundle": true, "dependencies": { - "@typescript-eslint/typescript-estree": "7.4.0", - "@typescript-eslint/utils": "7.4.0", + "@typescript-eslint/typescript-estree": "7.7.1", + "@typescript-eslint/utils": "7.7.1", "debug": "^4.3.4", - "ts-api-utils": "^1.0.1" + "ts-api-utils": "^1.3.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -3582,28 +3582,28 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "7.4.0", - "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/types/-/types-7.4.0.tgz", - "integrity": "sha512-mjQopsbffzJskos5B4HmbsadSJQWaRK0UxqQ7GuNA9Ga4bEKeiO6b2DnB6cM6bpc8lemaPseh0H9B/wyg+J7rw==", + "version": "7.7.1", + "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/types/-/types-7.7.1.tgz", + "integrity": "sha512-AmPmnGW1ZLTpWa+/2omPrPfR7BcbUU4oha5VIbSbS1a1Tv966bklvLNXxp3mrbc+P2j4MNOTfDffNsk4o0c6/w==", "inBundle": true, "engines": { "node": "^18.18.0 || >=20.0.0" } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "7.4.0", - "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/typescript-estree/-/typescript-estree-7.4.0.tgz", - "integrity": "sha512-A99j5AYoME/UBQ1ucEbbMEmGkN7SE0BvZFreSnTd1luq7yulcHdyGamZKizU7canpGDWGJ+Q6ZA9SyQobipePg==", + "version": "7.7.1", + "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/typescript-estree/-/typescript-estree-7.7.1.tgz", + "integrity": "sha512-CXe0JHCXru8Fa36dteXqmH2YxngKJjkQLjxzoj6LYwzZ7qZvgsLSc+eqItCrqIop8Vl2UKoAi0StVWu97FQZIQ==", "inBundle": true, "dependencies": { - "@typescript-eslint/types": "7.4.0", - "@typescript-eslint/visitor-keys": "7.4.0", + "@typescript-eslint/types": "7.7.1", + "@typescript-eslint/visitor-keys": "7.7.1", "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" + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^1.3.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -3614,19 +3614,31 @@ } } }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { + "version": "9.0.4", + "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/minimatch/-/minimatch-9.0.4.tgz", + "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", + "inBundle": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, "node_modules/@typescript-eslint/utils": { - "version": "7.4.0", - "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/utils/-/utils-7.4.0.tgz", - "integrity": "sha512-NQt9QLM4Tt8qrlBVY9lkMYzfYtNz8/6qwZg8pI3cMGlPnj6mOpRxxAm7BMJN9K0AiY+1BwJ5lVC650YJqYOuNg==", + "version": "7.7.1", + "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/utils/-/utils-7.7.1.tgz", + "integrity": "sha512-QUvBxPEaBXf41ZBbaidKICgVL8Hin0p6prQDu6bbetWo39BKbWJxRsErOzMNT1rXvTll+J7ChrbmMCXM9rsvOQ==", "inBundle": 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.4.0", - "@typescript-eslint/types": "7.4.0", - "@typescript-eslint/typescript-estree": "7.4.0", - "semver": "^7.5.4" + "@types/json-schema": "^7.0.15", + "@types/semver": "^7.5.8", + "@typescript-eslint/scope-manager": "7.7.1", + "@typescript-eslint/types": "7.7.1", + "@typescript-eslint/typescript-estree": "7.7.1", + "semver": "^7.6.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -3636,13 +3648,13 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "7.4.0", - "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/visitor-keys/-/visitor-keys-7.4.0.tgz", - "integrity": "sha512-0zkC7YM0iX5Y41homUUeW1CHtZR01K3ybjM1l6QczoMuay0XKtrb93kv95AxUGwdjGr64nNqnOCwmEl616N8CA==", + "version": "7.7.1", + "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/visitor-keys/-/visitor-keys-7.7.1.tgz", + "integrity": "sha512-gBL3Eq25uADw1LQ9kVpf3hRM+DWzs0uZknHYK3hq4jcTPqVCClHGDnB6UUUV2SFeBeA4KWHWbbLqmbGcZ4FYbw==", "inBundle": true, "dependencies": { - "@typescript-eslint/types": "7.4.0", - "eslint-visitor-keys": "^3.4.1" + "@typescript-eslint/types": "7.7.1", + "eslint-visitor-keys": "^3.4.3" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -5791,9 +5803,9 @@ } }, "node_modules/eslint-plugin-sonarjs": { - "version": "0.25.0", - "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/eslint-plugin-sonarjs/-/eslint-plugin-sonarjs-0.25.0.tgz", - "integrity": "sha512-DaZOtpUucEZbvowgKxVFwICV6r0h7jSCAx0IHICvCowP+etFussnhtaiCPSnYAuwVJ+P/6UFUhkv7QJklpXFyA==", + "version": "0.26.0-2918", + "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/eslint-plugin-sonarjs/-/eslint-plugin-sonarjs-0.26.0-2918.tgz", + "integrity": "sha512-dvvJlkYqWb60laRNUD/hESiTgjqnhWHh8DVU5weJT+//1dl/N2nn4mAWk7N6VJCnrtvB2BERVja9tLPRA/iKgA==", "inBundle": true, "engines": { "node": ">=16" @@ -6927,9 +6939,9 @@ } }, "node_modules/ignore": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.0.tgz", - "integrity": "sha512-g7dmpshy+gD7mh88OC9NwSGTKoc3kyLAZQRU1mt53Aw/vnvfXnbC+F/7F7QoYVKbV+KNvJx8wArewKy1vXMtlg==", + "version": "5.3.1", + "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/ignore/-/ignore-5.3.1.tgz", + "integrity": "sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==", "inBundle": true, "engines": { "node": ">= 4" @@ -14774,9 +14786,9 @@ } }, "@types/eslint": { - "version": "8.56.6", - "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@types/eslint/-/eslint-8.56.6.tgz", - "integrity": "sha512-ymwc+qb1XkjT/gfoQwxIeHZ6ixH23A+tCT2ADSA/DPVKzAjwYkTXBMCQ/f6fe4wEa85Lhp26VPeUxI7wMhAi7A==", + "version": "8.56.10", + "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@types/eslint/-/eslint-8.56.10.tgz", + "integrity": "sha512-Shavhk87gCtY2fhXDctcfS3e6FdxWkCx1iUZ9eEUbh7rTqlZT0/IzOkCOVt0fCjcFuZ9FPYfuezTBImfHCDBGQ==", "dev": true, "requires": { "@types/estree": "*", @@ -15004,96 +15016,106 @@ } }, "@typescript-eslint/eslint-plugin": { - "version": "7.4.0", - "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.4.0.tgz", - "integrity": "sha512-yHMQ/oFaM7HZdVrVm/M2WHaNPgyuJH4WelkSVEWSSsir34kxW2kDJCxlXRhhGWEsMN0WAW/vLpKfKVcm8k+MPw==", - "requires": { - "@eslint-community/regexpp": "^4.5.1", - "@typescript-eslint/scope-manager": "7.4.0", - "@typescript-eslint/type-utils": "7.4.0", - "@typescript-eslint/utils": "7.4.0", - "@typescript-eslint/visitor-keys": "7.4.0", + "version": "7.7.1", + "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.7.1.tgz", + "integrity": "sha512-KwfdWXJBOviaBVhxO3p5TJiLpNuh2iyXyjmWN0f1nU87pwyvfS0EmjC6ukQVYVFJd/K1+0NWGPDXiyEyQorn0Q==", + "requires": { + "@eslint-community/regexpp": "^4.10.0", + "@typescript-eslint/scope-manager": "7.7.1", + "@typescript-eslint/type-utils": "7.7.1", + "@typescript-eslint/utils": "7.7.1", + "@typescript-eslint/visitor-keys": "7.7.1", "debug": "^4.3.4", "graphemer": "^1.4.0", - "ignore": "^5.2.4", + "ignore": "^5.3.1", "natural-compare": "^1.4.0", - "semver": "^7.5.4", - "ts-api-utils": "^1.0.1" + "semver": "^7.6.0", + "ts-api-utils": "^1.3.0" } }, "@typescript-eslint/parser": { - "version": "7.4.0", - "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/parser/-/parser-7.4.0.tgz", - "integrity": "sha512-ZvKHxHLusweEUVwrGRXXUVzFgnWhigo4JurEj0dGF1tbcGh6buL+ejDdjxOQxv6ytcY1uhun1p2sm8iWStlgLQ==", - "requires": { - "@typescript-eslint/scope-manager": "7.4.0", - "@typescript-eslint/types": "7.4.0", - "@typescript-eslint/typescript-estree": "7.4.0", - "@typescript-eslint/visitor-keys": "7.4.0", + "version": "7.7.1", + "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/parser/-/parser-7.7.1.tgz", + "integrity": "sha512-vmPzBOOtz48F6JAGVS/kZYk4EkXao6iGrD838sp1w3NQQC0W8ry/q641KU4PrG7AKNAf56NOcR8GOpH8l9FPCw==", + "requires": { + "@typescript-eslint/scope-manager": "7.7.1", + "@typescript-eslint/types": "7.7.1", + "@typescript-eslint/typescript-estree": "7.7.1", + "@typescript-eslint/visitor-keys": "7.7.1", "debug": "^4.3.4" } }, "@typescript-eslint/scope-manager": { - "version": "7.4.0", - "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/scope-manager/-/scope-manager-7.4.0.tgz", - "integrity": "sha512-68VqENG5HK27ypafqLVs8qO+RkNc7TezCduYrx8YJpXq2QGZ30vmNZGJJJC48+MVn4G2dCV8m5ZTVnzRexTVtw==", + "version": "7.7.1", + "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/scope-manager/-/scope-manager-7.7.1.tgz", + "integrity": "sha512-PytBif2SF+9SpEUKynYn5g1RHFddJUcyynGpztX3l/ik7KmZEv19WCMhUBkHXPU9es/VWGD3/zg3wg90+Dh2rA==", "requires": { - "@typescript-eslint/types": "7.4.0", - "@typescript-eslint/visitor-keys": "7.4.0" + "@typescript-eslint/types": "7.7.1", + "@typescript-eslint/visitor-keys": "7.7.1" } }, "@typescript-eslint/type-utils": { - "version": "7.4.0", - "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/type-utils/-/type-utils-7.4.0.tgz", - "integrity": "sha512-247ETeHgr9WTRMqHbbQdzwzhuyaJ8dPTuyuUEMANqzMRB1rj/9qFIuIXK7l0FX9i9FXbHeBQl/4uz6mYuCE7Aw==", + "version": "7.7.1", + "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/type-utils/-/type-utils-7.7.1.tgz", + "integrity": "sha512-ZksJLW3WF7o75zaBPScdW1Gbkwhd/lyeXGf1kQCxJaOeITscoSl0MjynVvCzuV5boUz/3fOI06Lz8La55mu29Q==", "requires": { - "@typescript-eslint/typescript-estree": "7.4.0", - "@typescript-eslint/utils": "7.4.0", + "@typescript-eslint/typescript-estree": "7.7.1", + "@typescript-eslint/utils": "7.7.1", "debug": "^4.3.4", - "ts-api-utils": "^1.0.1" + "ts-api-utils": "^1.3.0" } }, "@typescript-eslint/types": { - "version": "7.4.0", - "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/types/-/types-7.4.0.tgz", - "integrity": "sha512-mjQopsbffzJskos5B4HmbsadSJQWaRK0UxqQ7GuNA9Ga4bEKeiO6b2DnB6cM6bpc8lemaPseh0H9B/wyg+J7rw==" + "version": "7.7.1", + "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/types/-/types-7.7.1.tgz", + "integrity": "sha512-AmPmnGW1ZLTpWa+/2omPrPfR7BcbUU4oha5VIbSbS1a1Tv966bklvLNXxp3mrbc+P2j4MNOTfDffNsk4o0c6/w==" }, "@typescript-eslint/typescript-estree": { - "version": "7.4.0", - "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/typescript-estree/-/typescript-estree-7.4.0.tgz", - "integrity": "sha512-A99j5AYoME/UBQ1ucEbbMEmGkN7SE0BvZFreSnTd1luq7yulcHdyGamZKizU7canpGDWGJ+Q6ZA9SyQobipePg==", + "version": "7.7.1", + "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/typescript-estree/-/typescript-estree-7.7.1.tgz", + "integrity": "sha512-CXe0JHCXru8Fa36dteXqmH2YxngKJjkQLjxzoj6LYwzZ7qZvgsLSc+eqItCrqIop8Vl2UKoAi0StVWu97FQZIQ==", "requires": { - "@typescript-eslint/types": "7.4.0", - "@typescript-eslint/visitor-keys": "7.4.0", + "@typescript-eslint/types": "7.7.1", + "@typescript-eslint/visitor-keys": "7.7.1", "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" + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^1.3.0" + }, + "dependencies": { + "minimatch": { + "version": "9.0.4", + "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/minimatch/-/minimatch-9.0.4.tgz", + "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", + "requires": { + "brace-expansion": "^2.0.1" + } + } } }, "@typescript-eslint/utils": { - "version": "7.4.0", - "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/utils/-/utils-7.4.0.tgz", - "integrity": "sha512-NQt9QLM4Tt8qrlBVY9lkMYzfYtNz8/6qwZg8pI3cMGlPnj6mOpRxxAm7BMJN9K0AiY+1BwJ5lVC650YJqYOuNg==", + "version": "7.7.1", + "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/utils/-/utils-7.7.1.tgz", + "integrity": "sha512-QUvBxPEaBXf41ZBbaidKICgVL8Hin0p6prQDu6bbetWo39BKbWJxRsErOzMNT1rXvTll+J7ChrbmMCXM9rsvOQ==", "requires": { "@eslint-community/eslint-utils": "^4.4.0", - "@types/json-schema": "^7.0.12", - "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "7.4.0", - "@typescript-eslint/types": "7.4.0", - "@typescript-eslint/typescript-estree": "7.4.0", - "semver": "^7.5.4" + "@types/json-schema": "^7.0.15", + "@types/semver": "^7.5.8", + "@typescript-eslint/scope-manager": "7.7.1", + "@typescript-eslint/types": "7.7.1", + "@typescript-eslint/typescript-estree": "7.7.1", + "semver": "^7.6.0" } }, "@typescript-eslint/visitor-keys": { - "version": "7.4.0", - "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/visitor-keys/-/visitor-keys-7.4.0.tgz", - "integrity": "sha512-0zkC7YM0iX5Y41homUUeW1CHtZR01K3ybjM1l6QczoMuay0XKtrb93kv95AxUGwdjGr64nNqnOCwmEl616N8CA==", + "version": "7.7.1", + "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/@typescript-eslint/visitor-keys/-/visitor-keys-7.7.1.tgz", + "integrity": "sha512-gBL3Eq25uADw1LQ9kVpf3hRM+DWzs0uZknHYK3hq4jcTPqVCClHGDnB6UUUV2SFeBeA4KWHWbbLqmbGcZ4FYbw==", "requires": { - "@typescript-eslint/types": "7.4.0", - "eslint-visitor-keys": "^3.4.1" + "@typescript-eslint/types": "7.7.1", + "eslint-visitor-keys": "^3.4.3" }, "dependencies": { "eslint-visitor-keys": { @@ -16804,9 +16826,9 @@ "requires": {} }, "eslint-plugin-sonarjs": { - "version": "0.25.0", - "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/eslint-plugin-sonarjs/-/eslint-plugin-sonarjs-0.25.0.tgz", - "integrity": "sha512-DaZOtpUucEZbvowgKxVFwICV6r0h7jSCAx0IHICvCowP+etFussnhtaiCPSnYAuwVJ+P/6UFUhkv7QJklpXFyA==", + "version": "0.26.0-2918", + "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/eslint-plugin-sonarjs/-/eslint-plugin-sonarjs-0.26.0-2918.tgz", + "integrity": "sha512-dvvJlkYqWb60laRNUD/hESiTgjqnhWHh8DVU5weJT+//1dl/N2nn4mAWk7N6VJCnrtvB2BERVja9tLPRA/iKgA==", "requires": {} }, "eslint-scope": { @@ -17540,9 +17562,9 @@ } }, "ignore": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.0.tgz", - "integrity": "sha512-g7dmpshy+gD7mh88OC9NwSGTKoc3kyLAZQRU1mt53Aw/vnvfXnbC+F/7F7QoYVKbV+KNvJx8wArewKy1vXMtlg==" + "version": "5.3.1", + "resolved": "https://repox.jfrog.io/artifactory/api/npm/npm/ignore/-/ignore-5.3.1.tgz", + "integrity": "sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==" }, "import-fresh": { "version": "3.3.0", diff --git a/package.json b/package.json index 08627e44440..4c7322a6f03 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "type": "commonjs", "devDependencies": { "@types/bytes": "3.1.4", - "@types/eslint": "8.56.6", + "@types/eslint": "^8.56.10", "@types/eslint-scope": "3.7.7", "@types/estree": "1.0.5", "@types/express": "4.17.21", @@ -79,9 +79,9 @@ "@babel/preset-flow": "7.24.1", "@babel/preset-react": "7.24.1", "@eslint-community/regexpp": "4.10.0", - "@typescript-eslint/eslint-plugin": "7.4.0", - "@typescript-eslint/utils": "7.4.0", - "@typescript-eslint/parser": "7.4.0", + "@typescript-eslint/eslint-plugin": "^7.7.1", + "@typescript-eslint/parser": "^7.7.1", + "@typescript-eslint/utils": "^7.7.1", "builtin-modules": "3.3.0", "bytes": "3.1.2", "eslint": "8.57.0", @@ -89,7 +89,7 @@ "eslint-plugin-jsx-a11y": "6.8.0", "eslint-plugin-react": "7.34.1", "eslint-plugin-react-hooks": "4.6.0", - "eslint-plugin-sonarjs": "0.25.0", + "eslint-plugin-sonarjs": "^0.26.0-2918", "express": "4.19.2", "functional-red-black-tree": "1.0.1", "htmlparser2": "9.1.0", @@ -105,8 +105,8 @@ "postcss-syntax": "0.36.2", "postcss-value-parser": "4.2.0", "run-node": "2.0.0", - "semver": "7.6.0", "scslre": "0.3.0", + "semver": "7.6.0", "stylelint": "15.10.0", "tar": "6.2.1", "tmp": "0.2.3", @@ -115,7 +115,7 @@ "vue-eslint-parser": "9.4.2", "yaml": "2.4.1" }, - "bundledDependencies": [ + "bundleDependencies": [ "@typescript-eslint/eslint-plugin", "@typescript-eslint/utils", "@typescript-eslint/parser", diff --git a/packages/jsts/src/linter/bundle-loader.ts b/packages/jsts/src/linter/bundle-loader.ts index 5add87c4bc1..d2389b1f895 100755 --- a/packages/jsts/src/linter/bundle-loader.ts +++ b/packages/jsts/src/linter/bundle-loader.ts @@ -79,7 +79,7 @@ const loaders: { [key: string]: Function } = { * Adds the rules from the Sonar ESLint plugin. */ pluginRules(linter: Linter) { - linter.defineRules(pluginRules); + linter.defineRules(pluginRules as unknown as Record); }, /** * Loads internal rules diff --git a/packages/jsts/src/linter/custom-rules/cognitive-complexity.ts b/packages/jsts/src/linter/custom-rules/cognitive-complexity.ts index be2952af067..f5ff84c9602 100644 --- a/packages/jsts/src/linter/custom-rules/cognitive-complexity.ts +++ b/packages/jsts/src/linter/custom-rules/cognitive-complexity.ts @@ -19,6 +19,7 @@ */ import { rules as sonarjsESLintRules } from 'eslint-plugin-sonarjs'; import { CustomRule } from './custom-rule'; +import { Rule } from 'eslint'; /** * The internal _cognitive complexity_ custom rule @@ -27,6 +28,6 @@ import { CustomRule } from './custom-rule'; */ export const rule: CustomRule = { ruleId: 'internal-cognitive-complexity', - ruleModule: sonarjsESLintRules['cognitive-complexity'], + ruleModule: sonarjsESLintRules['cognitive-complexity'] as unknown as Rule.RuleModule, ruleConfig: ['metric'], }; diff --git a/packages/jsts/src/linter/custom-rules/symbol-highlighting.ts b/packages/jsts/src/linter/custom-rules/symbol-highlighting.ts index e666a77aa43..6b76bb2b773 100644 --- a/packages/jsts/src/linter/custom-rules/symbol-highlighting.ts +++ b/packages/jsts/src/linter/custom-rules/symbol-highlighting.ts @@ -19,12 +19,13 @@ */ import { CustomRule } from './custom-rule'; import { rule as symbolHighlightingRule } from '../visitors/symbol-highlighting'; +import { Rule } from 'eslint'; /** * The internal _symbol highlighting_ custom rule */ export const rule: CustomRule = { ruleId: 'internal-symbol-highlighting', - ruleModule: symbolHighlightingRule, + ruleModule: symbolHighlightingRule as unknown as Rule.RuleModule, ruleConfig: [], }; diff --git a/packages/jsts/src/rules/S2310/rule.ts b/packages/jsts/src/rules/S2310/rule.ts index f62fee7095e..5b1de3b8bf1 100644 --- a/packages/jsts/src/rules/S2310/rule.ts +++ b/packages/jsts/src/rules/S2310/rule.ts @@ -47,7 +47,7 @@ export const rule: Rule.RuleModule = { } function checkCounter(counter: estree.Identifier, block: estree.Node) { - const variable = getVariableFromName(context, counter.name); + const variable = getVariableFromName(context, counter.name, block); if (!variable) { return; } diff --git a/packages/jsts/src/rules/S2430/decorator.ts b/packages/jsts/src/rules/S2430/decorator.ts index 570c09b4a96..99583a57ff7 100644 --- a/packages/jsts/src/rules/S2430/decorator.ts +++ b/packages/jsts/src/rules/S2430/decorator.ts @@ -45,7 +45,7 @@ function isNotClassOrFunction(context: Rule.RuleContext, node: estree.CallExpres if (callee.type !== 'Identifier') { return false; } - const variable = getVariableFromName(context, callee.name); + const variable = getVariableFromName(context, callee.name, node); if (variable) { for (const def of variable.defs) { if (!(def.type === 'ClassName' || def.type === 'FunctionName')) { diff --git a/packages/jsts/src/rules/S2598/rule.ts b/packages/jsts/src/rules/S2598/rule.ts index 22f60bf436f..150f5adafd0 100644 --- a/packages/jsts/src/rules/S2598/rule.ts +++ b/packages/jsts/src/rules/S2598/rule.ts @@ -100,7 +100,7 @@ function checkCallExpression(context: Rule.RuleContext, callExpression: estree.C function checkFormidable(context: Rule.RuleContext, callExpression: estree.CallExpression) { if (callExpression.arguments.length === 0) { - const formVariable = getLhsVariable(context); + const formVariable = getLhsVariable(context, callExpression); if (formVariable) { formidableObjects.set(formVariable, { uploadDirSet: false, @@ -220,7 +220,7 @@ export function getVariablePropertyFromAssignment( const memberExpr = assignment.left; if (memberExpr.object.type === 'Identifier' && memberExpr.property.type === 'Identifier') { - const objectVariable = getVariableFromName(context, memberExpr.object.name); + const objectVariable = getVariableFromName(context, memberExpr.object.name, memberExpr); if (objectVariable) { return { objectVariable, property: memberExpr.property.name }; } diff --git a/packages/jsts/src/rules/S2612/rule.ts b/packages/jsts/src/rules/S2612/rule.ts index ca8efc9fe2a..3f0e06df5f8 100644 --- a/packages/jsts/src/rules/S2612/rule.ts +++ b/packages/jsts/src/rules/S2612/rule.ts @@ -99,7 +99,7 @@ export const rule: Rule.RuleModule = { } else if (expr.type === 'Literal') { return modeFromLiteral(expr); } else if (expr.type === 'Identifier') { - const usage = getUniqueWriteUsage(context, expr.name); + const usage = getUniqueWriteUsage(context, expr.name, expr); if (usage && !visited.has(usage)) { visited.add(usage); return modeFromExpression(usage, visited); diff --git a/packages/jsts/src/rules/S3317/rule.ts b/packages/jsts/src/rules/S3317/rule.ts index 5a675f1cdb3..917ab8034ab 100644 --- a/packages/jsts/src/rules/S3317/rule.ts +++ b/packages/jsts/src/rules/S3317/rule.ts @@ -38,7 +38,7 @@ export const rule: Rule.RuleModule = { ExportDefaultDeclaration: (node: estree.Node) => { const declaration = (node as estree.ExportDefaultDeclaration).declaration; if (declaration.type === 'Identifier') { - const variable = getVariableFromName(context, declaration.name); + const variable = getVariableFromName(context, declaration.name, node); if (variable && variable.defs.length === 1) { const def = variable.defs[0]; if (def.type === 'ClassName' || def.type === 'FunctionName' || isConst(def)) { diff --git a/packages/jsts/src/rules/S3686/rule.ts b/packages/jsts/src/rules/S3686/rule.ts index 926f8a966f5..d7c81dd3035 100644 --- a/packages/jsts/src/rules/S3686/rule.ts +++ b/packages/jsts/src/rules/S3686/rule.ts @@ -95,7 +95,7 @@ function checkExpression( function getVariable(node: estree.SimpleCallExpression, context: Rule.RuleContext) { if (node.callee.type === 'Identifier') { - return getVariableFromName(context, node.callee.name); + return getVariableFromName(context, node.callee.name, node); } return undefined; } diff --git a/packages/jsts/src/rules/S4275/rule.ts b/packages/jsts/src/rules/S4275/rule.ts index 32eec638827..e45fe133144 100644 --- a/packages/jsts/src/rules/S4275/rule.ts +++ b/packages/jsts/src/rules/S4275/rule.ts @@ -139,7 +139,7 @@ const noAccessorFieldMismatchRule: Rule.RuleModule = { const accessorNode = node as TSESTree.Property; const accessorInfo = getSingleDescriptorAccessorInfo(accessorNode); if (accessorInfo) { - const fieldMap = getSingleVariableFieldMap(context, accessorInfo.name); + const fieldMap = getSingleVariableFieldMap(context, accessorInfo.name, node); checkAccessorNode(context, accessorNode, fieldMap, accessorInfo); } }, @@ -149,7 +149,7 @@ const noAccessorFieldMismatchRule: Rule.RuleModule = { const accessorNode = node as TSESTree.Property; const accessorInfo = getMultiDescriptorsAccessorInfo(accessorNode); if (accessorInfo) { - const fieldMap = getSingleVariableFieldMap(context, accessorInfo.name); + const fieldMap = getSingleVariableFieldMap(context, accessorInfo.name, node); checkAccessorNode(context, accessorNode, fieldMap, accessorInfo); } }, @@ -373,13 +373,9 @@ function getName(key: TSESTree.Node) { return null; } -function getNodeFieldMap( - context: Rule.RuleContext, - node: TSESTree.Node | undefined | null, - info: AccessorInfo, -) { +function getNodeFieldMap(context: Rule.RuleContext, node: TSESTree.Node, info: AccessorInfo) { if (info.definition === 'descriptor') { - return getSingleVariableFieldMap(context, info.name); + return getSingleVariableFieldMap(context, info.name, node as estree.Node); } else if (node?.type === 'ObjectExpression') { return getObjectExpressionFieldMap(node); } else if (node?.type === 'ClassBody') { @@ -389,10 +385,10 @@ function getNodeFieldMap( } } -function getSingleVariableFieldMap(context: Rule.RuleContext, name: string) { +function getSingleVariableFieldMap(context: Rule.RuleContext, name: string, node: estree.Node) { const fieldMap = new Map(); for (const candidate of [name, `_${name}`, `${name}_`]) { - const variable = getVariableFromName(context, candidate); + const variable = getVariableFromName(context, candidate, node); if (variable != null && variable.defs.length > 0) { fieldMap.set(candidate, { name: candidate, node: variable.defs[0].node }); break; diff --git a/packages/jsts/src/rules/S4327/decorator.ts b/packages/jsts/src/rules/S4327/decorator.ts index 6d2e3d0731a..808d2cf70a6 100644 --- a/packages/jsts/src/rules/S4327/decorator.ts +++ b/packages/jsts/src/rules/S4327/decorator.ts @@ -40,7 +40,7 @@ function reportExempting( } function isReferencedInsideGenerators(context: Rule.RuleContext, node: estree.Identifier) { - const variable = getVariableFromName(context, node.name); + const variable = getVariableFromName(context, node.name, node); if (variable) { for (const reference of variable.references) { let scope: Scope.Scope | null = reference.from; diff --git a/packages/jsts/src/rules/S5122/rule.ts b/packages/jsts/src/rules/S5122/rule.ts index ba3891857ea..87e6016f8dd 100644 --- a/packages/jsts/src/rules/S5122/rule.ts +++ b/packages/jsts/src/rules/S5122/rule.ts @@ -68,7 +68,7 @@ export const rule: Rule.RuleModule = { report(sensitiveCorsProperty); } if (arg?.type === 'Identifier') { - const usage = getUniqueWriteUsage(context, arg.name); + const usage = getUniqueWriteUsage(context, arg.name, arg); sensitiveCorsProperty = getSensitiveCorsProperty(usage, context); if (sensitiveCorsProperty) { report(sensitiveCorsProperty, arg); diff --git a/packages/jsts/src/rules/S5691/rule.ts b/packages/jsts/src/rules/S5691/rule.ts index 5046cdf3193..665a85b5364 100644 --- a/packages/jsts/src/rules/S5691/rule.ts +++ b/packages/jsts/src/rules/S5691/rule.ts @@ -39,7 +39,7 @@ export const rule: Rule.RuleModule = { if (getFullyQualifiedName(context, callee) === SERVE_STATIC && args.length > 1) { let options: estree.Node | undefined = args[1]; if (options.type === 'Identifier') { - options = getUniqueWriteUsage(context, options.name); + options = getUniqueWriteUsage(context, options.name, node); } const dotfilesProperty = getProperty(options, 'dotfiles', context); diff --git a/packages/jsts/src/rules/S5693/rule.ts b/packages/jsts/src/rules/S5693/rule.ts index f4827c9ebd4..c88723a3a63 100644 --- a/packages/jsts/src/rules/S5693/rule.ts +++ b/packages/jsts/src/rules/S5693/rule.ts @@ -104,7 +104,7 @@ function checkCallExpression(context: Rule.RuleContext, callExpression: estree.C function checkFormidable(context: Rule.RuleContext, callExpression: estree.CallExpression) { if (callExpression.arguments.length === 0) { // options will be set later through member assignment - const formVariable = getLhsVariable(context); + const formVariable = getLhsVariable(context, callExpression); if (formVariable) { formidableObjects.set(formVariable, { maxFileSize: FORMIDABLE_DEFAULT_SIZE, diff --git a/packages/jsts/src/rules/S5843/rule.ts b/packages/jsts/src/rules/S5843/rule.ts index 8acbbf052fa..bbc31ded786 100644 --- a/packages/jsts/src/rules/S5843/rule.ts +++ b/packages/jsts/src/rules/S5843/rule.ts @@ -146,7 +146,7 @@ class RegexPartFinder { } else if (isStaticTemplateLiteral(node)) { this.parts.push([node]); } else if (isIdentifier(node)) { - const initializer = getUniqueWriteUsage(this.context, node.name); + const initializer = getUniqueWriteUsage(this.context, node.name, node); if (initializer) { this.find(initializer); } diff --git a/packages/jsts/src/rules/S5860/rule.ts b/packages/jsts/src/rules/S5860/rule.ts index 88fa17b7961..cec3010fb24 100644 --- a/packages/jsts/src/rules/S5860/rule.ts +++ b/packages/jsts/src/rules/S5860/rule.ts @@ -381,7 +381,7 @@ class RegexIntelliSense { const { callee, arguments: args } = callExpr; if (isMethodCall(callExpr) && args.length > 0) { const target = (callee as estree.MemberExpression).object; - const matcher = getLhsVariable(this.context); + const matcher = getLhsVariable(this.context, callExpr); if (matcher) { const method = (callee as estree.MemberExpression).property as estree.Identifier; if (isString(target, this.services) && ['match', 'matchAll'].includes(method.name)) { @@ -415,7 +415,7 @@ class RegexIntelliSense { visited.add(node); const variable = this.findVariable(node); if (variable) { - const value = getUniqueWriteUsage(this.context, variable.name); + const value = getUniqueWriteUsage(this.context, variable.name, node); if (value) { const regex = this.findRegexRec(value, visited); if (regex) { @@ -437,7 +437,7 @@ class RegexIntelliSense { private findVariable(node: estree.Node) { if (node.type === 'Identifier') { - return getVariableFromName(this.context, node.name); + return getVariableFromName(this.context, node.name, node); } return null; } diff --git a/packages/jsts/src/rules/S6351/rule.ts b/packages/jsts/src/rules/S6351/rule.ts index 5ee2d912ef5..74522e21aba 100644 --- a/packages/jsts/src/rules/S6351/rule.ts +++ b/packages/jsts/src/rules/S6351/rule.ts @@ -97,9 +97,9 @@ function extractRegexInvocation( callExpr.callee.object.type === 'Identifier' ) { const { object } = callExpr.callee; - const variable = getVariableFromName(context, object.name); + const variable = getVariableFromName(context, object.name, callExpr); if (variable) { - const value = getUniqueWriteUsage(context, variable.name); + const value = getUniqueWriteUsage(context, variable.name, callExpr); const regex = regexes.find(r => r.node === value); if (regex?.flags.includes('g')) { const usages = invocations.get(variable); @@ -127,9 +127,9 @@ function extractResetRegex( ) { const parent = getParent(context); if (parent?.type === 'AssignmentExpression' && parent.left === node) { - const variable = getVariableFromName(context, node.object.name); + const variable = getVariableFromName(context, node.object.name, node); if (variable) { - const value = getUniqueWriteUsage(context, variable.name); + const value = getUniqueWriteUsage(context, variable.name, node); const regex = regexes.find(r => r.node === value); if (regex) { resets.add(variable); diff --git a/packages/jsts/src/rules/S6442/rule.ts b/packages/jsts/src/rules/S6442/rule.ts index fd6cd47834b..2a322142be2 100644 --- a/packages/jsts/src/rules/S6442/rule.ts +++ b/packages/jsts/src/rules/S6442/rule.ts @@ -117,7 +117,7 @@ export const rule: Rule.RuleModule = { const hookDeclarator = node as HookDeclarator; if (isHookCall(hookDeclarator.init)) { - const variable = getVariableFromName(context, hookDeclarator.id.elements[1].name); + const variable = getVariableFromName(context, hookDeclarator.id.elements[1].name, node); if (variable != null) { setters.push(variable); } @@ -136,7 +136,7 @@ export const rule: Rule.RuleModule = { const maybeSetterCall = node as SetterCall; - const calleeVariable = getVariableFromName(context, maybeSetterCall.callee.name); + const calleeVariable = getVariableFromName(context, maybeSetterCall.callee.name, node); if (setters.some(variable => variable === calleeVariable)) { context.report({ messageId: 'noHookSetterInBody', diff --git a/packages/jsts/src/rules/S6443/rule.ts b/packages/jsts/src/rules/S6443/rule.ts index 79a72bf0a82..f64063bb2dc 100644 --- a/packages/jsts/src/rules/S6443/rule.ts +++ b/packages/jsts/src/rules/S6443/rule.ts @@ -62,14 +62,18 @@ export const rule: Rule.RuleModule = { const { elements } = node.id as estree.ArrayPattern; const setter = (elements[1] as estree.Identifier).name; referencesBySetterName[setter] = { - setter: getVariableFromName(context, setter), - value: getVariableFromName(context, (elements[0] as estree.Identifier).name), + setter: getVariableFromName(context, setter, node), + value: getVariableFromName(context, (elements[0] as estree.Identifier).name, node), }; } }, [callSelector](node: estree.CallExpression) { - const setter = getVariableFromName(context, (node.callee as estree.Identifier).name); - const value = getVariableFromName(context, (node.arguments[0] as estree.Identifier).name); + const setter = getVariableFromName(context, (node.callee as estree.Identifier).name, node); + const value = getVariableFromName( + context, + (node.arguments[0] as estree.Identifier).name, + node, + ); const key = setter?.name as string; if ( setter && diff --git a/packages/jsts/src/rules/S6594/rule.ts b/packages/jsts/src/rules/S6594/rule.ts index 08193b46a32..ab14d3b0dd2 100644 --- a/packages/jsts/src/rules/S6594/rule.ts +++ b/packages/jsts/src/rules/S6594/rule.ts @@ -97,7 +97,7 @@ export const rule: Rule.RuleModule = { ident = parent.left; } if (ident) { - return getVariableFromName(context, ident.name); + return getVariableFromName(context, ident.name, node); } return null; } diff --git a/packages/jsts/src/rules/S6647/rule.ts b/packages/jsts/src/rules/S6647/rule.ts index 499c09e32c8..560fd894e33 100644 --- a/packages/jsts/src/rules/S6647/rule.ts +++ b/packages/jsts/src/rules/S6647/rule.ts @@ -22,6 +22,7 @@ import { Rule } from 'eslint'; import { eslintRules } from '../core'; import { decorate } from './decorator'; import { getVariableFromName } from '../helpers'; +import estree from 'estree'; /** * Check if method with accessibility is not useless @@ -72,7 +73,7 @@ function checkInheritance(node: TSESTree.MethodDefinition, context: Rule.RuleCon node.parent.parent.superClass ) { const superClass = node.parent.parent.superClass as TSESTree.Identifier; - const variable = getVariableFromName(context, superClass.name); + const variable = getVariableFromName(context, superClass.name, node as estree.Node); for (const def of variable?.defs ?? []) { if (def.type === 'ImportBinding') { return false; diff --git a/packages/jsts/src/rules/S6959/rule.ts b/packages/jsts/src/rules/S6959/rule.ts index ef0c819d0cd..e9b85dcbdc4 100644 --- a/packages/jsts/src/rules/S6959/rule.ts +++ b/packages/jsts/src/rules/S6959/rule.ts @@ -36,7 +36,7 @@ export const rule: Rule.RuleModule = { }, }, create(context: Rule.RuleContext) { - const services = context.parserServices; + const services = context.sourceCode.parserServices; function isArray(node: estree.Node) { if (isRequiredParserServices(services)) { diff --git a/packages/jsts/src/rules/S888/rule.ts b/packages/jsts/src/rules/S888/rule.ts index 7b4efb02190..3ac5112679d 100644 --- a/packages/jsts/src/rules/S888/rule.ts +++ b/packages/jsts/src/rules/S888/rule.ts @@ -174,7 +174,7 @@ function isUpdateByOne( function isUsedInsideBody(id: estree.Node, loopBody: estree.Node, context: Rule.RuleContext) { if (id.type === 'Identifier') { - const variable = getVariableFromName(context, id.name); + const variable = getVariableFromName(context, id.name, id); const bodyRange = loopBody.range; if (variable && bodyRange) { return variable.references.some(ref => isInBody(ref.identifier, bodyRange)); diff --git a/packages/jsts/src/rules/helpers/ast.ts b/packages/jsts/src/rules/helpers/ast.ts index 80f5bd52f79..06f8c9f6fc0 100644 --- a/packages/jsts/src/rules/helpers/ast.ts +++ b/packages/jsts/src/rules/helpers/ast.ts @@ -233,8 +233,8 @@ export function isReferenceTo(ref: Scope.Reference, node: estree.Node) { return node.type === 'Identifier' && node === ref.identifier; } -export function getUniqueWriteUsage(context: Rule.RuleContext, name: string) { - const variable = getVariableFromName(context, name); +export function getUniqueWriteUsage(context: Rule.RuleContext, name: string, node: estree.Node) { + const variable = getVariableFromName(context, name, node); return getUniqueWriteReference(variable); } @@ -256,7 +256,7 @@ export function getUniqueWriteUsageOrNode( recursive = false, ): estree.Node { if (node.type === 'Identifier') { - const usage = getUniqueWriteUsage(context, node.name); + const usage = getUniqueWriteUsage(context, node.name, node); if (usage) { return recursive ? getUniqueWriteUsageOrNode(context, usage, recursive) : usage; } else { @@ -280,7 +280,7 @@ export function getValueOfExpression( return expr; } if (expr.type === 'Identifier') { - const usage = getUniqueWriteUsage(context, expr.name); + const usage = getUniqueWriteUsage(context, expr.name, expr); if (usage) { if (isNodeType(usage, type)) { return usage; @@ -305,7 +305,10 @@ function isNodeType( /** * for `x = 42` or `let x = 42` when visiting '42' returns 'x' variable */ -export function getLhsVariable(context: Rule.RuleContext): Scope.Variable | undefined { +export function getLhsVariable( + context: Rule.RuleContext, + node: estree.Node, +): Scope.Variable | undefined { const parent = context.getAncestors()[context.getAncestors().length - 1]; let formIdentifier: estree.Identifier | undefined; if (parent.type === 'VariableDeclarator' && parent.id.type === 'Identifier') { @@ -314,7 +317,7 @@ export function getLhsVariable(context: Rule.RuleContext): Scope.Variable | unde formIdentifier = parent.left; } if (formIdentifier) { - return getVariableFromName(context, formIdentifier.name); + return getVariableFromName(context, formIdentifier.name, node); } return undefined; @@ -329,8 +332,8 @@ export function getVariableFromScope(scope: Scope.Scope | null, name: string) { return variable; } -export function getVariableFromName(context: Rule.RuleContext, name: string) { - const scope: Scope.Scope | null = context.getScope(); +export function getVariableFromName(context: Rule.RuleContext, name: string, node: estree.Node) { + const scope: Scope.Scope | null = context.sourceCode.getScope(node); return getVariableFromScope(scope, name); } @@ -648,7 +651,7 @@ export function isUnresolved(node: estree.Node | undefined | null, ctx: Rule.Rul } if (nodeToCheck.type === 'Identifier') { - const variable = getVariableFromName(ctx, nodeToCheck.name); + const variable = getVariableFromName(ctx, nodeToCheck.name, node); const writeReferences = variable?.references.filter(reference => reference.isWrite()); if (!variable || !writeReferences?.length) { return true; diff --git a/packages/jsts/src/rules/helpers/aws/cdk.ts b/packages/jsts/src/rules/helpers/aws/cdk.ts index 5fdd92803b6..1864f9e4c54 100644 --- a/packages/jsts/src/rules/helpers/aws/cdk.ts +++ b/packages/jsts/src/rules/helpers/aws/cdk.ts @@ -389,7 +389,7 @@ export function getLiteralValue( if (isLiteral(node)) { return node; } else if (isIdentifier(node)) { - const usage = getUniqueWriteUsage(ctx, node.name); + const usage = getUniqueWriteUsage(ctx, node.name, node); if (usage) { return getLiteralValue(ctx, usage); } diff --git a/packages/jsts/src/rules/helpers/regex/extract.ts b/packages/jsts/src/rules/helpers/regex/extract.ts index aca44df4330..3a43c40c943 100644 --- a/packages/jsts/src/rules/helpers/regex/extract.ts +++ b/packages/jsts/src/rules/helpers/regex/extract.ts @@ -71,7 +71,7 @@ export function getPatternFromNode( } else if (isSimpleRawString(node)) { return { pattern: getSimpleRawStringValue(node), flags: '' }; } else if (isIdentifier(node)) { - const assignedExpression = getUniqueWriteUsage(context, node.name); + const assignedExpression = getUniqueWriteUsage(context, node.name, node); if ( assignedExpression && (assignedExpression as TSESTree.Node).parent?.type === 'VariableDeclarator' diff --git a/packages/jsts/tests/tools/sonar-runtime/rule/no-missing-sonar-runtime.ts b/packages/jsts/tests/tools/sonar-runtime/rule/no-missing-sonar-runtime.ts index 1a44ac7941c..dd430d74885 100644 --- a/packages/jsts/tests/tools/sonar-runtime/rule/no-missing-sonar-runtime.ts +++ b/packages/jsts/tests/tools/sonar-runtime/rule/no-missing-sonar-runtime.ts @@ -111,7 +111,7 @@ function getModuleNameOfImportedIdentifier( return importedDeclaration.source.value; } // check if importing using `const f = require('module_name').f` or `const { f } = require('module_name')` - const writeExpression = getUniqueWriteUsage(context, identifier.name); + const writeExpression = getUniqueWriteUsage(context, identifier.name, identifier); if (writeExpression) { let maybeRequireCall: estree.Node; if (