From 221a71729ba9a51775c1a31656eb7f616a86a031 Mon Sep 17 00:00:00 2001 From: Julien Deniau Date: Sun, 28 Jan 2024 08:37:36 +0000 Subject: [PATCH 1/7] replace tslint by typescript-eslint --- .eslintignore | 1 + .eslintrc.json | 49 ++++- package-lock.json | 516 +++++++++++++++++++++++++++------------------- package.json | 6 +- 4 files changed, 352 insertions(+), 220 deletions(-) diff --git a/.eslintignore b/.eslintignore index 8a056820e4..8667135aeb 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,3 +2,4 @@ /pages/generated/** /dist/** node_modules +/type-definitions/flow-tests diff --git a/.eslintrc.json b/.eslintrc.json index cd48108dc2..524cc77170 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,11 +1,17 @@ { "root": true, + "parser": "@typescript-eslint/parser", "parserOptions": { "ecmaVersion": 6, "sourceType": "module" }, - "extends": ["airbnb", "prettier"], - "plugins": ["react", "prettier"], + "extends": [ + "airbnb", + "plugin:@typescript-eslint/recommended", + "plugin:import/typescript", + "prettier" + ], + "plugins": ["react", "prettier", "@typescript-eslint"], "rules": { "array-callback-return": "off", "block-scoped-var": "off", @@ -35,7 +41,7 @@ "no-this-before-super": "off", "no-underscore-dangle": "off", "no-unused-expressions": "off", - "no-unused-vars": "error", + "no-unused-vars": "off", "no-use-before-define": "off", "no-useless-concat": "error", "no-var": "error", @@ -61,10 +67,15 @@ "react/self-closing-comp": "error", "react/sort-comp": "off", "react/jsx-props-no-spreading": "off", + "react/require-default-props": [ + "error", + { + "functions": "ignore" + } + ], "jsx-a11y/no-static-element-interactions": "off", "import/extensions": [ "error", - "always", { "js": "never", "ts": "never", "tsx": "never" } ], "import/newline-after-import": "error", @@ -75,5 +86,33 @@ "import/no-useless-path-segments": "off", "import/prefer-default-export": "off", "prettier/prettier": "error" - } + }, + "overrides": [ + { + "files": ["__tests__/*"], + "rules": { + "import/no-unresolved": [ + "error", + { + "ignore": ["immutable"] + } + ] + } + }, + + { + "files": ["type-definitions/ts-tests/*"], + "rules": { + "no-lone-blocks": "off", + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-unused-vars": "off", + "import/no-unresolved": [ + "error", + { + "ignore": ["immutable"] + } + ] + } + } + ] } diff --git a/package-lock.json b/package-lock.json index c82205ddc7..acffba0100 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,8 @@ "@size-limit/preset-small-lib": "^8.2.6", "@types/jest": "^29.0.0", "@types/react": "17.0.11", + "@typescript-eslint/eslint-plugin": "^6.19.1", + "@typescript-eslint/parser": "^6.19.1", "benchmark": "2.1.4", "colors": "1.4.0", "cpy-cli": "3.1.1", @@ -48,7 +50,6 @@ "rollup": "3.28.1", "size-limit": "^8.2.6", "transducers-js": "0.4.174", - "tslint": "6.1.3", "tslint-config-prettier": "1.18.0", "typescript": "5.1" }, @@ -2987,6 +2988,12 @@ "parse5": "^7.0.0" } }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true + }, "node_modules/@types/json5": { "version": "0.0.29", "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", @@ -3046,6 +3053,12 @@ "integrity": "sha512-EaCxbanVeyxDRTQBkdLb3Bvl/HK7PBK6UJjsSixB0iHKoWxE5uu2Q/DgtpOhPIojN0Zl1whvOd7PoHs2P0s5eA==", "dev": true }, + "node_modules/@types/semver": { + "version": "7.5.6", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.6.tgz", + "integrity": "sha512-dn1l8LaMea/IjDoHNd9J52uBbInB796CDffS6VdIxvqYCPSG0V0DzHp76GpaWnlhg88uYyPbXCDIowa86ybd5A==", + "dev": true + }, "node_modules/@types/stack-utils": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz", @@ -3073,6 +3086,88 @@ "integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==", "dev": true }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "6.19.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.19.1.tgz", + "integrity": "sha512-roQScUGFruWod9CEyoV5KlCYrubC/fvG8/1zXuT0WTcxX87GnMMmnksMwSg99lo1xiKrBzw2icsJPMAw1OtKxg==", + "dev": true, + "dependencies": { + "@eslint-community/regexpp": "^4.5.1", + "@typescript-eslint/scope-manager": "6.19.1", + "@typescript-eslint/type-utils": "6.19.1", + "@typescript-eslint/utils": "6.19.1", + "@typescript-eslint/visitor-keys": "6.19.1", + "debug": "^4.3.4", + "graphemer": "^1.4.0", + "ignore": "^5.2.4", + "natural-compare": "^1.4.0", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^6.0.0 || ^6.0.0-alpha", + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/eslint-plugin/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==", + "dev": true, + "engines": { + "node": ">= 4" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/@typescript-eslint/parser": { "version": "6.19.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.19.1.tgz", @@ -3141,6 +3236,56 @@ "url": "https://opencollective.com/typescript-eslint" } }, + "node_modules/@typescript-eslint/type-utils": { + "version": "6.19.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.19.1.tgz", + "integrity": "sha512-0vdyld3ecfxJuddDjACUvlAeYNrHP/pDeQk2pWBR2ESeEzQhg52DF53AbI9QCBkYE23lgkhLCZNkHn2hEXXYIg==", + "dev": true, + "dependencies": { + "@typescript-eslint/typescript-estree": "6.19.1", + "@typescript-eslint/utils": "6.19.1", + "debug": "^4.3.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/type-utils/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/type-utils/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, "node_modules/@typescript-eslint/types": { "version": "6.19.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.19.1.tgz", @@ -3244,6 +3389,46 @@ "node": ">=10" } }, + "node_modules/@typescript-eslint/utils": { + "version": "6.19.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.19.1.tgz", + "integrity": "sha512-JvjfEZuP5WoMqwh9SPAPDSHSg9FBHHGhjPugSRxu5jMfjvBpq5/sGTD+9M9aQ5sh6iJ8AY/Kk/oUYVEMAPwi7w==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@types/json-schema": "^7.0.12", + "@types/semver": "^7.5.0", + "@typescript-eslint/scope-manager": "6.19.1", + "@typescript-eslint/types": "6.19.1", + "@typescript-eslint/typescript-estree": "6.19.1", + "semver": "^7.5.4" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "node_modules/@typescript-eslint/utils/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/@typescript-eslint/visitor-keys": { "version": "6.19.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.19.1.tgz", @@ -5250,15 +5435,6 @@ "node": ">=8" } }, - "node_modules/diff": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", - "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", - "dev": true, - "engines": { - "node": ">=0.3.1" - } - }, "node_modules/diff-sequences": { "version": "29.6.3", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.6.3.tgz", @@ -13174,37 +13350,6 @@ "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", "dev": true }, - "node_modules/tslint": { - "version": "6.1.3", - "resolved": "https://registry.npmjs.org/tslint/-/tslint-6.1.3.tgz", - "integrity": "sha512-IbR4nkT96EQOvKE2PW/djGz8iGNeJ4rF2mBfiYaR/nvUWYKJhLwimoJKgjIFEIDibBtOevj7BqCRL4oHeWWUCg==", - "deprecated": "TSLint has been deprecated in favor of ESLint. Please see https://github.com/palantir/tslint/issues/4534 for more information.", - "dev": true, - "dependencies": { - "@babel/code-frame": "^7.0.0", - "builtin-modules": "^1.1.1", - "chalk": "^2.3.0", - "commander": "^2.12.1", - "diff": "^4.0.1", - "glob": "^7.1.1", - "js-yaml": "^3.13.1", - "minimatch": "^3.0.4", - "mkdirp": "^0.5.3", - "resolve": "^1.3.2", - "semver": "^5.3.0", - "tslib": "^1.13.0", - "tsutils": "^2.29.0" - }, - "bin": { - "tslint": "bin/tslint" - }, - "engines": { - "node": ">=4.8.0" - }, - "peerDependencies": { - "typescript": ">=2.3.0-dev || >=2.4.0-dev || >=2.5.0-dev || >=2.6.0-dev || >=2.7.0-dev || >=2.8.0-dev || >=2.9.0-dev || >=3.0.0-dev || >= 3.1.0-dev || >= 3.2.0-dev || >= 4.0.0-dev" - } - }, "node_modules/tslint-config-prettier": { "version": "1.18.0", "resolved": "https://registry.npmjs.org/tslint-config-prettier/-/tslint-config-prettier-1.18.0.tgz", @@ -13217,86 +13362,6 @@ "node": ">=4.0.0" } }, - "node_modules/tslint/node_modules/ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "dependencies": { - "color-convert": "^1.9.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/tslint/node_modules/chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "dependencies": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/tslint/node_modules/color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, - "dependencies": { - "color-name": "1.1.3" - } - }, - "node_modules/tslint/node_modules/color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "dev": true - }, - "node_modules/tslint/node_modules/escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true, - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/tslint/node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/tslint/node_modules/semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true, - "bin": { - "semver": "bin/semver" - } - }, - "node_modules/tslint/node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/tsutils": { "version": "2.29.0", "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", @@ -16235,6 +16300,12 @@ "parse5": "^7.0.0" } }, + "@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true + }, "@types/json5": { "version": "0.0.29", "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", @@ -16294,6 +16365,12 @@ "integrity": "sha512-EaCxbanVeyxDRTQBkdLb3Bvl/HK7PBK6UJjsSixB0iHKoWxE5uu2Q/DgtpOhPIojN0Zl1whvOd7PoHs2P0s5eA==", "dev": true }, + "@types/semver": { + "version": "7.5.6", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.6.tgz", + "integrity": "sha512-dn1l8LaMea/IjDoHNd9J52uBbInB796CDffS6VdIxvqYCPSG0V0DzHp76GpaWnlhg88uYyPbXCDIowa86ybd5A==", + "dev": true + }, "@types/stack-utils": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz", @@ -16321,6 +16398,57 @@ "integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==", "dev": true }, + "@typescript-eslint/eslint-plugin": { + "version": "6.19.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.19.1.tgz", + "integrity": "sha512-roQScUGFruWod9CEyoV5KlCYrubC/fvG8/1zXuT0WTcxX87GnMMmnksMwSg99lo1xiKrBzw2icsJPMAw1OtKxg==", + "dev": true, + "requires": { + "@eslint-community/regexpp": "^4.5.1", + "@typescript-eslint/scope-manager": "6.19.1", + "@typescript-eslint/type-utils": "6.19.1", + "@typescript-eslint/utils": "6.19.1", + "@typescript-eslint/visitor-keys": "6.19.1", + "debug": "^4.3.4", + "graphemer": "^1.4.0", + "ignore": "^5.2.4", + "natural-compare": "^1.4.0", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" + }, + "dependencies": { + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "ignore": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.0.tgz", + "integrity": "sha512-g7dmpshy+gD7mh88OC9NwSGTKoc3kyLAZQRU1mt53Aw/vnvfXnbC+F/7F7QoYVKbV+KNvJx8wArewKy1vXMtlg==", + "dev": true + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + } + } + }, "@typescript-eslint/parser": { "version": "6.19.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.19.1.tgz", @@ -16361,6 +16489,35 @@ "@typescript-eslint/visitor-keys": "6.19.1" } }, + "@typescript-eslint/type-utils": { + "version": "6.19.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.19.1.tgz", + "integrity": "sha512-0vdyld3ecfxJuddDjACUvlAeYNrHP/pDeQk2pWBR2ESeEzQhg52DF53AbI9QCBkYE23lgkhLCZNkHn2hEXXYIg==", + "dev": true, + "requires": { + "@typescript-eslint/typescript-estree": "6.19.1", + "@typescript-eslint/utils": "6.19.1", + "debug": "^4.3.4", + "ts-api-utils": "^1.0.1" + }, + "dependencies": { + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } + } + }, "@typescript-eslint/types": { "version": "6.19.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.19.1.tgz", @@ -16427,6 +16584,32 @@ } } }, + "@typescript-eslint/utils": { + "version": "6.19.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.19.1.tgz", + "integrity": "sha512-JvjfEZuP5WoMqwh9SPAPDSHSg9FBHHGhjPugSRxu5jMfjvBpq5/sGTD+9M9aQ5sh6iJ8AY/Kk/oUYVEMAPwi7w==", + "dev": true, + "requires": { + "@eslint-community/eslint-utils": "^4.4.0", + "@types/json-schema": "^7.0.12", + "@types/semver": "^7.5.0", + "@typescript-eslint/scope-manager": "6.19.1", + "@typescript-eslint/types": "6.19.1", + "@typescript-eslint/typescript-estree": "6.19.1", + "semver": "^7.5.4" + }, + "dependencies": { + "semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + } + } + }, "@typescript-eslint/visitor-keys": { "version": "6.19.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.19.1.tgz", @@ -17974,12 +18157,6 @@ "integrity": "sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==", "dev": true }, - "diff": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", - "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", - "dev": true - }, "diff-sequences": { "version": "29.6.3", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.6.3.tgz", @@ -23938,91 +24115,6 @@ "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", "dev": true }, - "tslint": { - "version": "6.1.3", - "resolved": "https://registry.npmjs.org/tslint/-/tslint-6.1.3.tgz", - "integrity": "sha512-IbR4nkT96EQOvKE2PW/djGz8iGNeJ4rF2mBfiYaR/nvUWYKJhLwimoJKgjIFEIDibBtOevj7BqCRL4oHeWWUCg==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "builtin-modules": "^1.1.1", - "chalk": "^2.3.0", - "commander": "^2.12.1", - "diff": "^4.0.1", - "glob": "^7.1.1", - "js-yaml": "^3.13.1", - "minimatch": "^3.0.4", - "mkdirp": "^0.5.3", - "resolve": "^1.3.2", - "semver": "^5.3.0", - "tslib": "^1.13.0", - "tsutils": "^2.29.0" - }, - "dependencies": { - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "requires": { - "color-convert": "^1.9.0" - } - }, - "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - } - }, - "color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, - "requires": { - "color-name": "1.1.3" - } - }, - "color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "dev": true - }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true - }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true - }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - } - } - }, "tslint-config-prettier": { "version": "1.18.0", "resolved": "https://registry.npmjs.org/tslint-config-prettier/-/tslint-config-prettier-1.18.0.tgz", diff --git a/package.json b/package.json index b133068c40..d2e6ff1912 100644 --- a/package.json +++ b/package.json @@ -59,8 +59,7 @@ "format": "npm run lint:format -- --write", "lint": "run-s lint:*", "lint:format": "prettier --check \"{__tests__,src,type-definitions,website/src,perf,resources}/**/*{.js,.ts,.tsx,.flow,.css}\"", - "lint:js": "eslint \"{__tests__,src,website/src}/**/*.js\"", - "lint:ts": "tslint --project type-definitions/tsconfig.json \"{__tests__,src,type-definitions,website/src}/**/*.{ts,tsx}\"", + "lint:js": "eslint \"{__tests__,src,type-definitions,website/src}/**/*.{js,ts,tsx}\"", "type-check": "run-s type-check:*", "type-check:ts": "tsc --project type-definitions/tsconfig.json && tsc --project __tests__/tsconfig.json && dtslint type-definitions/ts-tests --localTs node_modules/typescript/lib", "type-check:flow": "flow check type-definitions/flow-tests --include-warnings", @@ -92,6 +91,8 @@ "@size-limit/preset-small-lib": "^8.2.6", "@types/jest": "^29.0.0", "@types/react": "17.0.11", + "@typescript-eslint/eslint-plugin": "^6.19.1", + "@typescript-eslint/parser": "^6.19.1", "benchmark": "2.1.4", "colors": "1.4.0", "cpy-cli": "3.1.1", @@ -123,7 +124,6 @@ "rollup": "3.28.1", "size-limit": "^8.2.6", "transducers-js": "0.4.174", - "tslint": "6.1.3", "tslint-config-prettier": "1.18.0", "typescript": "5.1" }, From 93e6215f06601c0d55af79436a378b2d739f2561 Mon Sep 17 00:00:00 2001 From: Julien Deniau Date: Sun, 28 Jan 2024 17:47:02 +0000 Subject: [PATCH 2/7] remove tslint config file and comments --- package-lock.json | 19 ------------------ package.json | 1 - tslint.json | 30 ---------------------------- type-definitions/immutable.d.ts | 3 --- type-definitions/ts-tests/index.d.ts | 1 - website/src/ImmutableConsole.tsx | 2 -- website/src/static/getTypeDefs.ts | 9 +-------- website/src/static/prism.ts | 1 - 8 files changed, 1 insertion(+), 65 deletions(-) delete mode 100644 tslint.json diff --git a/package-lock.json b/package-lock.json index acffba0100..54b03b5488 100644 --- a/package-lock.json +++ b/package-lock.json @@ -50,7 +50,6 @@ "rollup": "3.28.1", "size-limit": "^8.2.6", "transducers-js": "0.4.174", - "tslint-config-prettier": "1.18.0", "typescript": "5.1" }, "engines": { @@ -13350,18 +13349,6 @@ "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", "dev": true }, - "node_modules/tslint-config-prettier": { - "version": "1.18.0", - "resolved": "https://registry.npmjs.org/tslint-config-prettier/-/tslint-config-prettier-1.18.0.tgz", - "integrity": "sha512-xPw9PgNPLG3iKRxmK7DWr+Ea/SzrvfHtjFt5LBl61gk2UBG/DB9kCXRjv+xyIU1rUtnayLeMUVJBcMX8Z17nDg==", - "dev": true, - "bin": { - "tslint-config-prettier-check": "bin/check.js" - }, - "engines": { - "node": ">=4.0.0" - } - }, "node_modules/tsutils": { "version": "2.29.0", "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", @@ -24115,12 +24102,6 @@ "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", "dev": true }, - "tslint-config-prettier": { - "version": "1.18.0", - "resolved": "https://registry.npmjs.org/tslint-config-prettier/-/tslint-config-prettier-1.18.0.tgz", - "integrity": "sha512-xPw9PgNPLG3iKRxmK7DWr+Ea/SzrvfHtjFt5LBl61gk2UBG/DB9kCXRjv+xyIU1rUtnayLeMUVJBcMX8Z17nDg==", - "dev": true - }, "tsutils": { "version": "2.29.0", "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", diff --git a/package.json b/package.json index d2e6ff1912..4bde7d5099 100644 --- a/package.json +++ b/package.json @@ -124,7 +124,6 @@ "rollup": "3.28.1", "size-limit": "^8.2.6", "transducers-js": "0.4.174", - "tslint-config-prettier": "1.18.0", "typescript": "5.1" }, "size-limit": [ diff --git a/tslint.json b/tslint.json deleted file mode 100644 index 4b76e7bdc5..0000000000 --- a/tslint.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "extends": ["tslint:recommended", "tslint-config-prettier"], - "rules": { - "array-type": [true, "generic"], - "quotemark": false, - "no-reference": false, - "no-namespace": false, - "member-access": false, - "interface-name": false, - "member-ordering": false, - "only-arrow-functions": false, - "object-literal-sort-keys": false, - "no-conditional-assignment": false, - "one-variable-per-declaration": false, - "max-classes-per-file": false, - "space-before-function-paren": false, - "trailing-comma": [ - true, - { - "multiline": { - "objects": "always", - "arrays": "always", - "typeLiterals": "always", - "functions": "never" - } - } - ], - "no-console": false - } -} diff --git a/type-definitions/immutable.d.ts b/type-definitions/immutable.d.ts index 6ce86c61df..f2b0eecf90 100644 --- a/type-definitions/immutable.d.ts +++ b/type-definitions/immutable.d.ts @@ -1831,7 +1831,6 @@ declare namespace Immutable { * this Collection or JavaScript Object. */ function fromKeys(iter: Collection.Keyed): Set; - // tslint:disable-next-line unified-signatures function fromKeys(iter: Collection): Set; function fromKeys(obj: { [key: string]: unknown }): Set; @@ -2056,7 +2055,6 @@ declare namespace Immutable { * the keys from this Collection or JavaScript Object. */ function fromKeys(iter: Collection.Keyed): OrderedSet; - // tslint:disable-next-line unified-signatures function fromKeys(iter: Collection): OrderedSet; function fromKeys(obj: { [key: string]: unknown }): OrderedSet; } @@ -4925,7 +4923,6 @@ declare namespace Immutable { * returns Collection */ flatten(depth?: number): Collection; - // tslint:disable-next-line unified-signatures flatten(shallow?: boolean): Collection; /** diff --git a/type-definitions/ts-tests/index.d.ts b/type-definitions/ts-tests/index.d.ts index 11eec1bf41..bd74d4c62d 100644 --- a/type-definitions/ts-tests/index.d.ts +++ b/type-definitions/ts-tests/index.d.ts @@ -1,2 +1 @@ // Minimum TypeScript Version: 4.5 -/* tslint:disable:no-useless-files */ diff --git a/website/src/ImmutableConsole.tsx b/website/src/ImmutableConsole.tsx index 81f417855a..2db83c840e 100644 --- a/website/src/ImmutableConsole.tsx +++ b/website/src/ImmutableConsole.tsx @@ -20,7 +20,6 @@ export function ImmutableConsole({ version }: { version: string }) { installUMD(installSpace, getSourceURL(version)).then(Immutable => { installSpace.Immutable = Immutable; /* eslint-disable no-console */ - // tslint:disable:no-console console.log( '\n' + ' ▄▟████▙▄ _ __ __ __ __ _ _ _______ ____ _ _____ \n' + @@ -35,7 +34,6 @@ export function ImmutableConsole({ version }: { version: string }) { ); console.log(Immutable); /* eslint-enable no-console */ - // tslint:enable:no-console }); }, [version]); return null; diff --git a/website/src/static/getTypeDefs.ts b/website/src/static/getTypeDefs.ts index f890262f5c..0e225ea95e 100644 --- a/website/src/static/getTypeDefs.ts +++ b/website/src/static/getTypeDefs.ts @@ -460,14 +460,7 @@ function typesVisitor(source: ts.SourceFile) { function ensureGroup(node: ts.Node) { for (const trivia of getTrivia(node)) { if (trivia.kind === ts.SyntaxKind.SingleLineCommentTrivia) { - const unfilteredCurrentGroup = source.text.substring( - trivia.pos + 3, - trivia.end - ); - - if (!unfilteredCurrentGroup.startsWith('tslint:')) { - currentGroup = unfilteredCurrentGroup; - } + currentGroup = source.text.substring(trivia.pos + 3, trivia.end); } } } diff --git a/website/src/static/prism.ts b/website/src/static/prism.ts index d1feea779f..6924e982cd 100644 --- a/website/src/static/prism.ts +++ b/website/src/static/prism.ts @@ -1,6 +1,5 @@ // @ts-nocheck /* eslint-disable */ -/* tslint:disable */ /* ********************************************** Begin prism-core.js From dc23c7c4f210481195b569636a457b1d8a36a1ed Mon Sep 17 00:00:00 2001 From: Julien Deniau Date: Sun, 28 Jan 2024 18:58:09 +0000 Subject: [PATCH 3/7] Fix eslint issue in src directory --- src/CollectionImpl.js | 1 + src/Map.js | 2 +- src/Range.js | 1 + src/Repeat.js | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/CollectionImpl.js b/src/CollectionImpl.js index bc33af022a..ee0d60f84c 100644 --- a/src/CollectionImpl.js +++ b/src/CollectionImpl.js @@ -310,6 +310,7 @@ mixin(Collection, { }, entrySeq() { + // eslint-disable-next-line @typescript-eslint/no-this-alias const collection = this; if (collection._cache) { // We cache as an entries array, so we can just return the cache! diff --git a/src/Map.js b/src/Map.js index 61af7c0a7d..dcfe386db9 100644 --- a/src/Map.js +++ b/src/Map.js @@ -552,7 +552,7 @@ BitmapIndexedNode.prototype.iterate = HashArrayMapNode.prototype.iterate = } }; -// eslint-disable-next-line no-unused-vars +// eslint-disable-next-line @typescript-eslint/no-unused-vars ValueNode.prototype.iterate = function (fn, reverse) { return fn(this.entry); }; diff --git a/src/Range.js b/src/Range.js index 6c5a169485..28ddd08bcc 100644 --- a/src/Range.js +++ b/src/Range.js @@ -39,6 +39,7 @@ export class Range extends IndexedSeq { // eslint-disable-next-line no-constructor-return return EMPTY_RANGE; } + // eslint-disable-next-line @typescript-eslint/no-this-alias EMPTY_RANGE = this; } } diff --git a/src/Repeat.js b/src/Repeat.js index 59cffdc26a..658204d721 100644 --- a/src/Repeat.js +++ b/src/Repeat.js @@ -22,6 +22,7 @@ export class Repeat extends IndexedSeq { // eslint-disable-next-line no-constructor-return return EMPTY_REPEAT; } + // eslint-disable-next-line @typescript-eslint/no-this-alias EMPTY_REPEAT = this; } } From 6dd6213f13e914fe647a32e3333878cf05e63b91 Mon Sep 17 00:00:00 2001 From: Julien Deniau Date: Mon, 29 Jan 2024 08:39:04 +0000 Subject: [PATCH 4/7] Migrate simple eslint rules in __test__ directory --- .eslintrc.json | 6 +++++- __tests__/Conversion.ts | 2 +- __tests__/Equality.ts | 2 +- __tests__/IndexedSeq.ts | 2 +- __tests__/KeyedSeq.ts | 5 +++-- __tests__/List.ts | 4 ++-- __tests__/Map.ts | 2 +- __tests__/MultiRequire.js | 2 ++ __tests__/Range.ts | 2 +- __tests__/Record.ts | 8 ++++---- __tests__/Seq.ts | 2 +- __tests__/Stack.ts | 2 +- __tests__/concat.ts | 4 ++-- __tests__/find.ts | 2 +- __tests__/flatten.ts | 2 +- __tests__/getIn.ts | 4 ++-- __tests__/groupBy.ts | 1 - __tests__/hasIn.ts | 4 ++-- __tests__/hash.ts | 2 +- __tests__/issues.ts | 1 + __tests__/join.ts | 2 +- __tests__/minmax.ts | 2 +- __tests__/partition.ts | 1 - __tests__/slice.ts | 2 +- __tests__/splice.ts | 2 +- __tests__/transformerProtocol.ts | 6 +++--- __tests__/updateIn.ts | 4 ++-- __tests__/zip.ts | 2 +- type-definitions/ts-tests/covariance.ts | 3 +++ 29 files changed, 46 insertions(+), 37 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 524cc77170..25f9fb0229 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -85,7 +85,11 @@ "import/no-unresolved": "error", "import/no-useless-path-segments": "off", "import/prefer-default-export": "off", - "prettier/prettier": "error" + "prettier/prettier": "error", + "@typescript-eslint/no-unused-vars": [ + "error", + { "argsIgnorePattern": "^_" } + ] }, "overrides": [ { diff --git a/__tests__/Conversion.ts b/__tests__/Conversion.ts index 5092b4a486..149a860db6 100644 --- a/__tests__/Conversion.ts +++ b/__tests__/Conversion.ts @@ -1,6 +1,6 @@ import { fromJS, is, List, Map, OrderedMap, Record } from 'immutable'; - import * as jasmineCheck from 'jasmine-check'; + jasmineCheck.install(); // Symbols diff --git a/__tests__/Equality.ts b/__tests__/Equality.ts index 8fbfe104ea..f60a104651 100644 --- a/__tests__/Equality.ts +++ b/__tests__/Equality.ts @@ -1,6 +1,6 @@ import { is, List, Map, Seq, Set } from 'immutable'; - import * as jasmineCheck from 'jasmine-check'; + jasmineCheck.install(); describe('Equality', () => { diff --git a/__tests__/IndexedSeq.ts b/__tests__/IndexedSeq.ts index 2cd7f17126..3b29ba7afc 100644 --- a/__tests__/IndexedSeq.ts +++ b/__tests__/IndexedSeq.ts @@ -1,6 +1,6 @@ import { Seq } from 'immutable'; - import * as jasmineCheck from 'jasmine-check'; + jasmineCheck.install(); describe('IndexedSequence', () => { diff --git a/__tests__/KeyedSeq.ts b/__tests__/KeyedSeq.ts index 4bc83c1356..516a48c0fe 100644 --- a/__tests__/KeyedSeq.ts +++ b/__tests__/KeyedSeq.ts @@ -1,6 +1,6 @@ import { Range, Seq } from 'immutable'; - import * as jasmineCheck from 'jasmine-check'; + jasmineCheck.install(); describe('KeyedSeq', () => { @@ -11,7 +11,8 @@ describe('KeyedSeq', () => { const seqEntries = seq.entries(); const keyedEntries = keyed.entries(); - let seqStep, keyedStep; + let seqStep; + let keyedStep; do { seqStep = seqEntries.next(); keyedStep = keyedEntries.next(); diff --git a/__tests__/List.ts b/__tests__/List.ts index 2e6255f052..5227e86fa2 100644 --- a/__tests__/List.ts +++ b/__tests__/List.ts @@ -1,6 +1,6 @@ import { fromJS, List, Map, Range, Seq, Set } from 'immutable'; - import * as jasmineCheck from 'jasmine-check'; + jasmineCheck.install(); function arrayOfSize(s: number) { @@ -38,7 +38,7 @@ describe('List', () => { it('does not accept a scalar', () => { expect(() => { - // @ts-expect-error + // @ts-expect-error -- test that runtime does throw List(3); }).toThrow('Expected Array or collection object of values: 3'); }); diff --git a/__tests__/Map.ts b/__tests__/Map.ts index f7be57167d..dcf67685f3 100644 --- a/__tests__/Map.ts +++ b/__tests__/Map.ts @@ -1,6 +1,6 @@ import { fromJS, is, List, Map, Range, Record, Seq } from 'immutable'; - import * as jasmineCheck from 'jasmine-check'; + jasmineCheck.install(); describe('Map', () => { diff --git a/__tests__/MultiRequire.js b/__tests__/MultiRequire.js index 44fd2e42ad..16b682dc84 100644 --- a/__tests__/MultiRequire.js +++ b/__tests__/MultiRequire.js @@ -1,7 +1,9 @@ +// eslint-disable-next-line @typescript-eslint/no-var-requires const Immutable1 = require('../src/Immutable'); jest.resetModules(); +// eslint-disable-next-line @typescript-eslint/no-var-requires const Immutable2 = require('../src/Immutable'); describe('MultiRequire', () => { diff --git a/__tests__/Range.ts b/__tests__/Range.ts index 915dd592a8..2ba544b2a1 100644 --- a/__tests__/Range.ts +++ b/__tests__/Range.ts @@ -1,6 +1,6 @@ import { Range } from 'immutable'; - import * as jasmineCheck from 'jasmine-check'; + jasmineCheck.install(); describe('Range', () => { diff --git a/__tests__/Record.ts b/__tests__/Record.ts index 4f19c32081..94bcbb5d9c 100644 --- a/__tests__/Record.ts +++ b/__tests__/Record.ts @@ -41,7 +41,7 @@ describe('Record', () => { const MyType = Record({ a: 1, b: 2, c: 3 }); const t1 = MyType({ a: 10, b: 20 }); - // @ts-expect-error + // @ts-expect-error -- try to force an unknown value const t2 = t1.set('d', 4); expect(t2).toBe(t1); @@ -132,7 +132,7 @@ describe('Record', () => { expect(t.get('a')).toEqual(1); expect(t.get('b')).toEqual(20); - // @ts-expect-error + // @ts-expect-error -- unknown key should not return anything expect(t.get('c')).toBeUndefined(); }); @@ -163,7 +163,7 @@ describe('Record', () => { const b: string = t1.b; expect(a).toEqual(1); expect(b).toEqual('foo'); - // @ts-expect-error + // @ts-expect-error -- test that runtime does throw expect(() => (t1.a = 2)).toThrow('Cannot set on an immutable record.'); }); @@ -303,7 +303,7 @@ describe('Record', () => { it('does not accept a non object as constructor', () => { const defaultValues = null; expect(() => { - // @ts-expect-error + // @ts-expect-error -- test that runtime does throw Record(defaultValues); }).toThrowErrorMatchingSnapshot(); }); diff --git a/__tests__/Seq.ts b/__tests__/Seq.ts index dc72f77c2b..c066803cfd 100644 --- a/__tests__/Seq.ts +++ b/__tests__/Seq.ts @@ -94,7 +94,7 @@ describe('Seq', () => { it('does not accept a scalar', () => { expect(() => { - // @ts-expect-error + // @ts-expect-error -- test that runtime does throw Seq(3); }).toThrow( 'Expected Array or collection object of values, or keyed object: 3' diff --git a/__tests__/Stack.ts b/__tests__/Stack.ts index 17509c496b..c613ba8a59 100644 --- a/__tests__/Stack.ts +++ b/__tests__/Stack.ts @@ -1,6 +1,6 @@ import { Seq, Stack } from 'immutable'; - import * as jasmineCheck from 'jasmine-check'; + jasmineCheck.install(); function arrayOfSize(s) { diff --git a/__tests__/concat.ts b/__tests__/concat.ts index b459da93e9..596b1c3fc6 100644 --- a/__tests__/concat.ts +++ b/__tests__/concat.ts @@ -41,7 +41,7 @@ describe('concat', () => { const a = Seq({ a: 1, b: 2, c: 3 }); const b = [4, 5, 6]; expect(() => { - // @ts-expect-error + // @ts-expect-error -- test that runtime does throw a.concat(b).toJS(); }).toThrow('Expected [K, V] tuple: 4'); }); @@ -158,7 +158,7 @@ describe('concat', () => { }); it('lazily reverses indexed sequences with unknown size, maintaining indicies', () => { - const a = Seq([1, 2, 3]).filter(x => true); + const a = Seq([1, 2, 3]).filter(() => true); expect(a.size).toBe(undefined); // Note: lazy filter does not know what size in O(1). expect(a.concat(a, a).toKeyedSeq().reverse().size).toBe(undefined); expect(a.concat(a, a).toKeyedSeq().reverse().toArray()).toEqual([ diff --git a/__tests__/find.ts b/__tests__/find.ts index 46b95f8da6..e439f0500e 100644 --- a/__tests__/find.ts +++ b/__tests__/find.ts @@ -1,6 +1,6 @@ import { Seq } from 'immutable'; - import * as jasmineCheck from 'jasmine-check'; + jasmineCheck.install(); describe('find', () => { diff --git a/__tests__/flatten.ts b/__tests__/flatten.ts index 006511c5fb..692c9b5774 100644 --- a/__tests__/flatten.ts +++ b/__tests__/flatten.ts @@ -1,6 +1,6 @@ import { Collection, fromJS, List, Range, Seq } from 'immutable'; - import * as jasmineCheck from 'jasmine-check'; + jasmineCheck.install(); describe('flatten', () => { diff --git a/__tests__/getIn.ts b/__tests__/getIn.ts index ebab78e1fb..55354a9bc1 100644 --- a/__tests__/getIn.ts +++ b/__tests__/getIn.ts @@ -14,11 +14,11 @@ describe('getIn', () => { }); it('deep get throws without list or array-like', () => { - // @ts-expect-error + // @ts-expect-error -- test that runtime does throw expect(() => Map().getIn(undefined)).toThrow( 'Invalid keyPath: expected Ordered Collection or Array: undefined' ); - // @ts-expect-error + // @ts-expect-error -- test that runtime does throw expect(() => Map().getIn({ a: 1, b: 2 })).toThrow( 'Invalid keyPath: expected Ordered Collection or Array: [object Object]' ); diff --git a/__tests__/groupBy.ts b/__tests__/groupBy.ts index 230ec1f6b2..4235721e07 100644 --- a/__tests__/groupBy.ts +++ b/__tests__/groupBy.ts @@ -8,7 +8,6 @@ import { OrderedSet, Set, Stack, - Record, } from 'immutable'; describe('groupBy', () => { diff --git a/__tests__/hasIn.ts b/__tests__/hasIn.ts index 1e441fec2b..e280b99a6a 100644 --- a/__tests__/hasIn.ts +++ b/__tests__/hasIn.ts @@ -21,11 +21,11 @@ describe('hasIn', () => { }); it('deep has throws without list or array-like', () => { - // @ts-expect-error + // @ts-expect-error -- test that runtime does throw expect(() => Map().hasIn(undefined)).toThrow( 'Invalid keyPath: expected Ordered Collection or Array: undefined' ); - // @ts-expect-error + // @ts-expect-error -- test that runtime does throw expect(() => Map().hasIn({ a: 1, b: 2 })).toThrow( 'Invalid keyPath: expected Ordered Collection or Array: [object Object]' ); diff --git a/__tests__/hash.ts b/__tests__/hash.ts index 050b47c248..6599029540 100644 --- a/__tests__/hash.ts +++ b/__tests__/hash.ts @@ -1,6 +1,6 @@ import { hash } from 'immutable'; - import * as jasmineCheck from 'jasmine-check'; + jasmineCheck.install(); describe('hash', () => { diff --git a/__tests__/issues.ts b/__tests__/issues.ts index 7083a235e3..aa89ec75a8 100644 --- a/__tests__/issues.ts +++ b/__tests__/issues.ts @@ -15,6 +15,7 @@ describe('Issue #1175', () => { equals() { return false; } + hashCode() { return 2 ** 32; } diff --git a/__tests__/join.ts b/__tests__/join.ts index cc47ccb157..02102de7f3 100644 --- a/__tests__/join.ts +++ b/__tests__/join.ts @@ -1,6 +1,6 @@ import { Seq } from 'immutable'; - import * as jasmineCheck from 'jasmine-check'; + jasmineCheck.install(); describe('join', () => { diff --git a/__tests__/minmax.ts b/__tests__/minmax.ts index 225edf2d52..3b6617a0c4 100644 --- a/__tests__/minmax.ts +++ b/__tests__/minmax.ts @@ -1,6 +1,6 @@ import { is, Seq } from 'immutable'; - import * as jasmineCheck from 'jasmine-check'; + jasmineCheck.install(); const genHeterogeneousishArray = gen.oneOf([ diff --git a/__tests__/partition.ts b/__tests__/partition.ts index 044a5ba78b..688638bc24 100644 --- a/__tests__/partition.ts +++ b/__tests__/partition.ts @@ -1,5 +1,4 @@ import { - Collection, isAssociative, isIndexed, isKeyed, diff --git a/__tests__/slice.ts b/__tests__/slice.ts index 2d7177f808..67ba2d7722 100644 --- a/__tests__/slice.ts +++ b/__tests__/slice.ts @@ -1,6 +1,6 @@ import { List, Range, Seq } from 'immutable'; - import * as jasmineCheck from 'jasmine-check'; + jasmineCheck.install(); describe('slice', () => { diff --git a/__tests__/splice.ts b/__tests__/splice.ts index eaad75f78b..4d5dd309ff 100644 --- a/__tests__/splice.ts +++ b/__tests__/splice.ts @@ -1,6 +1,6 @@ import { List, Range, Seq } from 'immutable'; - import * as jasmineCheck from 'jasmine-check'; + jasmineCheck.install(); describe('splice', () => { diff --git a/__tests__/transformerProtocol.ts b/__tests__/transformerProtocol.ts index 07e1578775..895c28d4f1 100644 --- a/__tests__/transformerProtocol.ts +++ b/__tests__/transformerProtocol.ts @@ -1,7 +1,7 @@ import * as t from 'transducers-js'; import { List, Map, Set, Stack } from 'immutable'; - import * as jasmineCheck from 'jasmine-check'; + jasmineCheck.install(); describe('Transformer Protocol', () => { @@ -56,7 +56,7 @@ describe('Transformer Protocol', () => { it('transduces Map without initial values', () => { const m1 = Map({ a: 1, b: 2, c: 3, d: 4 }); const xform = t.comp( - t.filter(([k, v]) => v % 2 === 0), + t.filter(([_k, v]) => v % 2 === 0), t.map(([k, v]) => [k, v * 2]) ); const m2 = t.transduce(xform, Map(), m1); @@ -68,7 +68,7 @@ describe('Transformer Protocol', () => { const m1 = Map({ a: 1, b: 2, c: 3 }); const m2 = Map({ a: 4, b: 5 }); const xform = t.comp( - t.filter(([k, v]) => v % 2 === 0), + t.filter(([_k, v]) => v % 2 === 0), t.map(([k, v]) => [k, v * 2]) ); const m3 = t.transduce(xform, Map(), m1, m2); diff --git a/__tests__/updateIn.ts b/__tests__/updateIn.ts index fda61539f1..086dc9c9f3 100644 --- a/__tests__/updateIn.ts +++ b/__tests__/updateIn.ts @@ -34,11 +34,11 @@ describe('updateIn', () => { }); it('deep edit throws without list or array-like', () => { - // @ts-expect-error + // @ts-expect-error -- test that runtime does throw expect(() => Map().updateIn(undefined, x => x)).toThrow( 'Invalid keyPath: expected Ordered Collection or Array: undefined' ); - // @ts-expect-error + // @ts-expect-error -- test that runtime does th expect(() => Map().updateIn({ a: 1, b: 2 }, x => x)).toThrow( 'Invalid keyPath: expected Ordered Collection or Array: [object Object]' ); diff --git a/__tests__/zip.ts b/__tests__/zip.ts index 4f8e7f538a..7fb2bcfb5d 100644 --- a/__tests__/zip.ts +++ b/__tests__/zip.ts @@ -1,6 +1,6 @@ import { List, Range, Seq } from 'immutable'; - import * as jasmineCheck from 'jasmine-check'; + jasmineCheck.install(); describe('zip', () => { diff --git a/type-definitions/ts-tests/covariance.ts b/type-definitions/ts-tests/covariance.ts index 51ece6d59a..d7b63dacb5 100644 --- a/type-definitions/ts-tests/covariance.ts +++ b/type-definitions/ts-tests/covariance.ts @@ -2,12 +2,14 @@ import { List, Map, OrderedMap, OrderedSet, Set, Stack } from 'immutable'; class A { x: number; + constructor() { this.x = 1; } } class B extends A { y: string; + constructor() { super(); this.y = 'B'; @@ -15,6 +17,7 @@ class B extends A { } class C { z: string; + constructor() { this.z = 'C'; } From 33c0d2be6591aa625fc960448a244db1597282d1 Mon Sep 17 00:00:00 2001 From: Julien Deniau Date: Mon, 29 Jan 2024 11:18:15 +0000 Subject: [PATCH 5/7] use stricter types in __tests__ directory --- __tests__/Comparator.ts | 6 ++- __tests__/Conversion.ts | 15 ++++--- __tests__/Equality.ts | 8 ++-- __tests__/List.ts | 89 +++++++++++++++++++------------------- __tests__/Map.ts | 11 ++--- __tests__/OrderedSet.ts | 5 ++- __tests__/Predicates.ts | 4 +- __tests__/Record.ts | 9 ++-- __tests__/Set.ts | 7 +++ __tests__/Stack.ts | 8 ++-- __tests__/find.ts | 27 +++--------- __tests__/flatten.ts | 3 +- __tests__/hash.ts | 14 +++--- __tests__/issues.ts | 3 +- __tests__/merge.ts | 42 +++++++++--------- __tests__/slice.ts | 2 +- __tests__/updateIn.ts | 95 ++++++++++++++++++++++++++++------------- __tests__/zip.ts | 2 +- 18 files changed, 195 insertions(+), 155 deletions(-) diff --git a/__tests__/Comparator.ts b/__tests__/Comparator.ts index 4cb15fef52..e961ace18f 100644 --- a/__tests__/Comparator.ts +++ b/__tests__/Comparator.ts @@ -6,11 +6,12 @@ const expectedSortedNumbers: readonly number[] = [ 7, 95, 90, 92, 3, 5, 9, 4, 6, 10, 12, ]; +/* eslint-disable no-else-return */ const testComparator: Comparator = (left, right) => { //The number 7 always goes first... - if (left == 7) { + if (left === 7) { return PairSorting.LeftThenRight; - } else if (right == 7) { + } else if (right === 7) { return PairSorting.RightThenLeft; } @@ -31,6 +32,7 @@ const testComparator: Comparator = (left, right) => { //...and, finally, sort the numbers of each subgroup in ascending order. return left - right; }; +/* eslint-enable no-else-return */ describe.each([ ['List', List], diff --git a/__tests__/Conversion.ts b/__tests__/Conversion.ts index 149a860db6..177de494be 100644 --- a/__tests__/Conversion.ts +++ b/__tests__/Conversion.ts @@ -3,9 +3,6 @@ import * as jasmineCheck from 'jasmine-check'; jasmineCheck.install(); -// Symbols -declare function Symbol(name: string): any; - describe('Conversion', () => { // Note: order of keys based on Map's hashing order const js = { @@ -107,7 +104,9 @@ describe('Conversion', () => { }); it('Throws when provided circular reference', () => { - const o = { a: { b: { c: null as any } } }; + type OType = { a: { b: { c: OType | null } } }; + + const o: OType = { a: { b: { c: null } } }; o.a.b.c = o; expect(() => fromJS(o)).toThrow( 'Cannot convert circular structure to Immutable' @@ -117,7 +116,8 @@ describe('Conversion', () => { it('Converts deep JSON with custom conversion', () => { const seq = fromJS(js, function (key, sequence) { if (key === 'point') { - return new Point(sequence as any); + // @ts-expect-error -- to convert to real typing + return new Point(sequence); } return Array.isArray(this[key]) ? sequence.toList() @@ -128,7 +128,8 @@ describe('Conversion', () => { }); it('Converts deep JSON with custom conversion including keypath if requested', () => { - const paths: Array = []; + const paths: Array | undefined> = []; + // eslint-disable-next-line @typescript-eslint/no-unused-vars const seq1 = fromJS(js, function (key, sequence, keypath) { expect(arguments.length).toBe(3); paths.push(keypath); @@ -147,6 +148,8 @@ describe('Conversion', () => { ['point'], ['list'], ]); + + // eslint-disable-next-line @typescript-eslint/no-unused-vars const seq2 = fromJS(js, function (key, sequence) { expect(arguments[2]).toBe(undefined); }); diff --git a/__tests__/Equality.ts b/__tests__/Equality.ts index f60a104651..22d70981e5 100644 --- a/__tests__/Equality.ts +++ b/__tests__/Equality.ts @@ -53,8 +53,8 @@ describe('Equality', () => { }); it('dereferences things', () => { - const ptrA = { foo: 1 }, - ptrB = { foo: 2 }; + const ptrA = { foo: 1 }; + const ptrB = { foo: 2 }; expectIsNot(ptrA, ptrB); ptrA.valueOf = ptrB.valueOf = function () { return 5; @@ -66,11 +66,13 @@ describe('Equality', () => { }; expectIs(ptrA, ptrB); ptrA.valueOf = ptrB.valueOf = function () { + // eslint-disable-next-line @typescript-eslint/no-explicit-any return null as any; }; expectIs(ptrA, ptrB); ptrA.valueOf = ptrB.valueOf = function () { - return void 0 as any; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return undefined as any; }; expectIs(ptrA, ptrB); ptrA.valueOf = function () { diff --git a/__tests__/List.ts b/__tests__/List.ts index 5227e86fa2..2cb28ee6a6 100644 --- a/__tests__/List.ts +++ b/__tests__/List.ts @@ -102,7 +102,9 @@ describe('List', () => { }); it('can setIn on an inexistant index', () => { - const myMap = Map({ a: [], b: [] }); + const myMap = Map<{ a: Array; b: Array; c?: List }>( + { a: [], b: [] } + ); const out = myMap.setIn(['a', 0], 'v').setIn(['c', 0], 'v'); expect(out.getIn(['a', 0])).toEqual('v'); @@ -110,7 +112,7 @@ describe('List', () => { expect(out.get('a')).toBeInstanceOf(Array); expect(out.get('b')).toBeInstanceOf(Array); expect(out.get('c')).toBeInstanceOf(Map); - expect(out.get('c').keySeq().first()).toBe(0); + expect(out.get('c')?.keySeq().first()).toBe(0); }); it('throw when calling setIn on a non data structure', () => { @@ -143,7 +145,7 @@ describe('List', () => { it('can update a value', () => { const l = List.of(5); - // @ts-ignore (Type definition limitation) + // @ts-expect-error -- Type definition limitation expect(l.update(0, v => v * v).toArray()).toEqual([25]); }); @@ -153,7 +155,7 @@ describe('List', () => { aKey: List(['bad', 'good']), }), ]); - // @ts-ignore (Type definition limitation) + // @ts-expect-error -- Type definition limitation l = l.updateIn([0, 'aKey', 1], v => v + v); expect(l.toJS()).toEqual([ { @@ -164,10 +166,12 @@ describe('List', () => { it('returns undefined when getting a null value', () => { const v = List([1, 2, 3]); - expect(v.get(null as any)).toBe(undefined); + // @ts-expect-error -- test runtime + expect(v.get(null)).toBe(undefined); const o = List([{ a: 1 }, { b: 2 }, { c: 3 }]); - expect(o.get(null as any)).toBe(undefined); + // @ts-expect-error -- test runtime + expect(o.get(null)).toBe(undefined); }); it('counts from the end of the list on negative index', () => { @@ -180,6 +184,7 @@ describe('List', () => { it('coerces numeric-string keys', () => { // Of course, TypeScript protects us from this, so cast to "any" to test. + // eslint-disable-next-line @typescript-eslint/no-explicit-any const i: any = List.of(1, 2, 3, 4, 5, 6); expect(i.get('1')).toBe(2); expect(i.set('3', 10).get('3')).toBe(10); @@ -190,37 +195,44 @@ describe('List', () => { }); it('uses not set value for string index', () => { - const list: any = List(); + const list = List(); + // @ts-expect-error -- test runtime expect(list.get('stringKey', 'NOT-SET')).toBe('NOT-SET'); }); it('uses not set value for index {}', () => { - const list: any = List.of(1, 2, 3, 4, 5); + const list = List.of(1, 2, 3, 4, 5); + // @ts-expect-error -- test runtime expect(list.get({}, 'NOT-SET')).toBe('NOT-SET'); }); it('uses not set value for index void 0', () => { - const list: any = List.of(1, 2, 3, 4, 5); + const list = List.of(1, 2, 3, 4, 5); + // @ts-expect-error -- test runtime + // eslint-disable-next-line no-void expect(list.get(void 0, 'NOT-SET')).toBe('NOT-SET'); }); it('uses not set value for index undefined', () => { - const list: any = List.of(1, 2, 3, 4, 5); + const list = List.of(1, 2, 3, 4, 5); + // @ts-expect-error -- test runtime expect(list.get(undefined, 'NOT-SET')).toBe('NOT-SET'); }); it('doesnt coerce empty strings to index 0', () => { - const list: any = List.of(1, 2, 3); + const list = List.of(1, 2, 3); + // @ts-expect-error -- test runtime expect(list.has('')).toBe(false); }); it('doesnt contain elements at non-empty string keys', () => { - const list: any = List.of(1, 2, 3, 4, 5); + const list = List.of(1, 2, 3, 4, 5); + // @ts-expect-error -- test runtime expect(list.has('str')).toBe(false); }); it('hasIn doesnt contain elements at non-empty string keys', () => { - const list: any = List.of(1, 2, 3, 4, 5); + const list = List.of(1, 2, 3, 4, 5); expect(list.hasIn(['str'])).toBe(false); }); @@ -310,11 +322,12 @@ describe('List', () => { .set(6, undefined) .remove(1); expect(v.size).toBe(14); + // eslint-disable-next-line no-sparse-arrays expect(v.toJS()).toEqual(['a', 'c', 'd', , , , , , , , , , , 'o']); }); it('iterates a dense list', () => { - const v = List() + const v = List() .setSize(11) .set(1, 1) .set(3, 3) @@ -323,7 +336,7 @@ describe('List', () => { .set(9, 9); expect(v.size).toBe(11); - const forEachResults: Array = []; + const forEachResults: Array<[number, undefined | number]> = []; v.forEach((val, i) => forEachResults.push([i, val])); expect(forEachResults).toEqual([ [0, undefined], @@ -354,7 +367,7 @@ describe('List', () => { undefined, ]); - const iteratorResults: Array = []; + const iteratorResults: Array<[number, undefined | number]> = []; const iterator = v.entries(); let step; while (!(step = iterator.next()).done) { @@ -446,7 +459,7 @@ describe('List', () => { { maxSize: 2000 }, [gen.posInt], len => { - const a: Array = []; + const a: Array = []; let v = List(); for (let ii = 0; ii < len; ii++) { @@ -557,9 +570,7 @@ describe('List', () => { it('ensures iter is unmodified', () => { const v = List.of(1, 2, 3); - const r = v.map((value, index, iter) => { - return iter.get(index - 1); - }); + const r = v.map((value, index, iter) => iter.get(index - 1)); expect(r.toArray()).toEqual([3, 1, 2]); }); @@ -583,17 +594,12 @@ describe('List', () => { it('filters values based on type', () => { class A {} class B extends A { - b(): void { - return; - } + b(): void {} } class C extends A { - c(): void { - return; - } + c(): void {} } const l1 = List([new B(), new C(), new B(), new C()]); - // tslint:disable-next-line:arrow-parens const l2: List = l1.filter((v): v is C => v instanceof C); expect(l2.size).toEqual(2); expect(l2.every(v => v instanceof C)).toBe(true); @@ -602,17 +608,12 @@ describe('List', () => { it('partitions values based on type', () => { class A {} class B extends A { - b(): void { - return; - } + b(): void {} } class C extends A { - c(): void { - return; - } + c(): void {} } const l1 = List([new B(), new C(), new B(), new C()]); - // tslint:disable-next-line:arrow-parens const [la, lc]: [List, List] = l1.partition( (v): v is C => v instanceof C ); @@ -698,7 +699,7 @@ describe('List', () => { const a = Array(100).join('abcdefghijklmnopqrstuvwxyz').split(''); const v1 = List(a); const v2 = List(a); - // tslint:disable-next-line: triple-equals + // eslint-disable-next-line eqeqeq expect(v1 == v2).not.toBe(true); expect(v1 === v2).not.toBe(true); expect(v1.equals(v2)).toBe(true); @@ -725,7 +726,7 @@ describe('List', () => { it('forEach iterates in the correct order', () => { let n = 0; - const a: Array = []; + const a: Array = []; const v = List.of(0, 1, 2, 3, 4); v.forEach(x => { a.push(x); @@ -737,7 +738,7 @@ describe('List', () => { }); it('forEach iteration terminates when callback returns false', () => { - const a: Array = []; + const a: Array = []; function count(x) { if (x > 2) { return false; @@ -757,7 +758,7 @@ describe('List', () => { [7, 8], Seq([9, 10]), Set.of(11, 12), - null as any + null ); expect(v1.toArray()).toEqual([1, 2, 3]); expect(v2.toArray()).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, null]); @@ -869,26 +870,26 @@ describe('List', () => { }); it('discards truncated elements when using slice', () => { - const list = [1, 2, 3, 4, 5, 6]; - const v1 = fromJS(list) as List; + const list: Array = [1, 2, 3, 4, 5, 6]; + const v1 = fromJS(list) as List; const v2 = v1.slice(0, 3); const v3 = v2.setSize(6); expect(v2.toArray()).toEqual(list.slice(0, 3)); expect(v3.toArray()).toEqual( - list.slice(0, 3).concat([undefined, undefined, undefined] as any) + list.slice(0, 3).concat([undefined, undefined, undefined]) ); }); it('discards truncated elements when using setSize', () => { - const list = [1, 2, 3, 4, 5, 6]; - const v1 = fromJS(list) as List; + const list: Array = [1, 2, 3, 4, 5, 6]; + const v1 = fromJS(list) as List; const v2 = v1.setSize(3); const v3 = v2.setSize(6); expect(v2.toArray()).toEqual(list.slice(0, 3)); expect(v3.toArray()).toEqual( - list.slice(0, 3).concat([undefined, undefined, undefined] as any) + list.slice(0, 3).concat([undefined, undefined, undefined]) ); }); diff --git a/__tests__/Map.ts b/__tests__/Map.ts index dcf67685f3..d9da248c80 100644 --- a/__tests__/Map.ts +++ b/__tests__/Map.ts @@ -106,7 +106,8 @@ describe('Map', () => { }); it('accepts flattened pairs via of()', () => { - const m: Map = Map.of(1, 'a', 2, 'b', 3, 'c'); + // @ts-expect-error Map.of type is , but function is deprecated + const m: Map = Map.of(1, 'a', 2, 'b', 3, 'c'); expect(m.size).toBe(3); expect(m.get(1)).toBe('a'); expect(m.get(2)).toBe('b'); @@ -169,7 +170,7 @@ describe('Map', () => { }); it('accepts null as a key', () => { - const m1 = Map(); + const m1 = Map(); const m2 = m1.set(null, 'null'); const m3 = m2.remove(null); expect(m1.size).toBe(0); @@ -232,7 +233,7 @@ describe('Map', () => { it('can use weird keys', () => { const symbol = Symbol('A'); - const m: Map = Map() + const m = Map() .set(NaN, 1) .set(Infinity, 2) .set(symbol, 'A') @@ -246,7 +247,7 @@ describe('Map', () => { it('can map items known to hash collide', () => { // make a big map, so it hashmaps - let m: Map = Range(0, 32).toMap(); + let m: Map = Range(0, 32).toMap(); m = m.set('AAA', 'letters').set(64545, 'numbers'); expect(m.size).toBe(34); expect(m.get('AAA')).toEqual('letters'); @@ -255,7 +256,7 @@ describe('Map', () => { it('can progressively add items known to collide', () => { // make a big map, so it hashmaps - let map: Map = Range(0, 32).toMap(); + let map: Map = Range(0, 32).toMap(); map = map.set('@', '@'); map = map.set(64, 64); map = map.set(96, 96); diff --git a/__tests__/OrderedSet.ts b/__tests__/OrderedSet.ts index aa14dffed2..6dbf7f4d18 100644 --- a/__tests__/OrderedSet.ts +++ b/__tests__/OrderedSet.ts @@ -100,8 +100,11 @@ describe('OrderedSet', () => { b = b.add(i); } // Set c to 0-23 + // eslint-disable-next-line prefer-const c = b.butLast(); + // Set d to 0-22 + // eslint-disable-next-line prefer-const d = c.butLast(); // Internal list resizing happens on the final `subtract` when subtracting d from a @@ -121,7 +124,7 @@ describe('OrderedSet', () => { const initial = OrderedSet([first, second, third]); const out = initial.map(t => { - if (2 === t.get('id')) { + if (t.get('id') === 2) { return t.set('valid', false); } return t; diff --git a/__tests__/Predicates.ts b/__tests__/Predicates.ts index a34931fc4e..40136c71b9 100644 --- a/__tests__/Predicates.ts +++ b/__tests__/Predicates.ts @@ -36,9 +36,9 @@ describe('isValueObject', () => { it('works on custom types', () => { class MyValueType { - v: any; + v: number; - constructor(val) { + constructor(val: number) { this.v = val; } diff --git a/__tests__/Record.ts b/__tests__/Record.ts index 94bcbb5d9c..baa95f31df 100644 --- a/__tests__/Record.ts +++ b/__tests__/Record.ts @@ -189,11 +189,12 @@ describe('Record', () => { }); it('does not allow overwriting property names', () => { - // tslint:disable:no-console + // eslint-disable-next-line no-console const realWarn = console.warn; try { - const warnings: Array = []; + const warnings: Array = []; + // eslint-disable-next-line no-console console.warn = w => warnings.push(w); // size is a safe key to use @@ -204,12 +205,14 @@ describe('Record', () => { // get() is not safe to use const MyType2 = Record({ get: 0 }); + // eslint-disable-next-line @typescript-eslint/no-unused-vars const t2 = MyType2(); expect(warnings.length).toBe(1); expect(warnings[0]).toBe( 'Cannot define Record with property "get" since that property name is part of the Record API.' ); } finally { + // eslint-disable-next-line no-console console.warn = realWarn; } }); @@ -242,7 +245,7 @@ describe('Record', () => { const MyType = Record({ a: 0, b: 0 }); const t1 = MyType({ a: 10, b: 20 }); - const entries: Array = []; + const entries: Array<[string, number]> = []; for (const entry of t1) { entries.push(entry); } diff --git a/__tests__/Set.ts b/__tests__/Set.ts index 50382758f7..05412a9760 100644 --- a/__tests__/Set.ts +++ b/__tests__/Set.ts @@ -278,8 +278,11 @@ describe('Set', () => { describe('accepts Symbol as entry #579', () => { it('operates on small number of symbols, preserving set uniqueness', () => { + // eslint-disable-next-line symbol-description const a = Symbol(); + // eslint-disable-next-line symbol-description const b = Symbol(); + // eslint-disable-next-line symbol-description const c = Symbol(); const symbolSet = Set([a, b, c, a, b, c, a, b, c, a, b, c]); @@ -332,17 +335,21 @@ describe('Set', () => { describe('deduplicating custom classes that invoke fromJS() as part of equality check', () => { class Entity { entityId: string; + entityKey: string; + constructor(entityId: string, entityKey: string) { this.entityId = entityId; this.entityKey = entityKey; } + asImmutable() { return fromJS({ entityId: this.entityId, entityKey: this.entityKey, }); } + valueOf() { return this.asImmutable().toString(); } diff --git a/__tests__/Stack.ts b/__tests__/Stack.ts index c613ba8a59..60c40466d7 100644 --- a/__tests__/Stack.ts +++ b/__tests__/Stack.ts @@ -74,7 +74,7 @@ describe('Stack', () => { const s = Stack.of('a', 'b', 'c'); expect(s.size).toBe(3); - const forEachResults: Array = []; + const forEachResults: Array<[number, string, string | undefined]> = []; s.forEach((val, i) => forEachResults.push([i, val, s.get(i)])); expect(forEachResults).toEqual([ [0, 'a', 'a'], @@ -85,9 +85,9 @@ describe('Stack', () => { // map will cause reverse iterate expect(s.map(val => val + val).toArray()).toEqual(['aa', 'bb', 'cc']); - let iteratorResults: Array = []; + let iteratorResults: Array<[number, string]> = []; let iterator = s.entries(); - let step; + let step: IteratorResult<[number, string]>; while (!(step = iterator.next()).done) { iteratorResults.push(step.value); } @@ -157,7 +157,7 @@ describe('Stack', () => { { maxSize: 2000 }, [gen.posInt], len => { - const a: Array = []; + const a: Array = []; let s = Stack(); for (let ii = 0; ii < len; ii++) { diff --git a/__tests__/find.ts b/__tests__/find.ts index e439f0500e..b8806d1f95 100644 --- a/__tests__/find.ts +++ b/__tests__/find.ts @@ -5,23 +5,14 @@ jasmineCheck.install(); describe('find', () => { it('find returns notSetValue when match is not found', () => { - expect( - Seq([1, 2, 3, 4, 5, 6]).find( - function () { - return false; - }, - null, - 9 - ) - ).toEqual(9); + expect(Seq([1, 2, 3, 4, 5, 6]).find(() => false, null, 9)).toEqual(9); }); it('findEntry returns notSetValue when match is not found', () => { expect( Seq([1, 2, 3, 4, 5, 6]).findEntry( - function () { - return false; - }, + () => false, + null, 9 ) @@ -29,14 +20,8 @@ describe('find', () => { }); it('findLastEntry returns notSetValue when match is not found', () => { - expect( - Seq([1, 2, 3, 4, 5, 6]).findLastEntry( - function () { - return false; - }, - null, - 9 - ) - ).toEqual(9); + expect(Seq([1, 2, 3, 4, 5, 6]).findLastEntry(() => false, null, 9)).toEqual( + 9 + ); }); }); diff --git a/__tests__/flatten.ts b/__tests__/flatten.ts index 692c9b5774..4f19dec01a 100644 --- a/__tests__/flatten.ts +++ b/__tests__/flatten.ts @@ -26,7 +26,8 @@ describe('flatten', () => { [4, 5, 6], ]); const flat = nested.flatten(); - expect(flat.forEach((x: any) => x < 4)).toEqual(4); + // @ts-expect-error -- `flatten` return type should be improved + expect(flat.forEach((x: number) => x < 4)).toEqual(4); }); type SeqType = number | Array | Collection; diff --git a/__tests__/hash.ts b/__tests__/hash.ts index 6599029540..7cafa60921 100644 --- a/__tests__/hash.ts +++ b/__tests__/hash.ts @@ -28,19 +28,17 @@ describe('hash', () => { }); it('generates different hashes for different symbols', () => { + // eslint-disable-next-line symbol-description const symA = Symbol(); + // eslint-disable-next-line symbol-description const symB = Symbol(); expect(hash(symA)).toBe(hash(symA)); expect(hash(symA)).not.toBe(hash(symB)); }); it('generates different hashes for different functions', () => { - const funA = () => { - return; - }; - const funB = () => { - return; - }; + const funA = () => {}; + const funB = () => {}; expect(hash(funA)).toBe(hash(funA)); expect(hash(funA)).not.toBe(hash(funB)); }); @@ -50,7 +48,7 @@ describe('hash', () => { check.it('generates unsigned 31-bit integers', [genValue], value => { const hashVal = hash(value); expect(Number.isInteger(hashVal)).toBe(true); - expect(hashVal).toBeGreaterThan(-Math.pow(2, 31)); - expect(hashVal).toBeLessThan(Math.pow(2, 31)); + expect(hashVal).toBeGreaterThan(-(2 ** 31)); + expect(hashVal).toBeLessThan(2 ** 31); }); }); diff --git a/__tests__/issues.ts b/__tests__/issues.ts index aa89ec75a8..56ac67ced3 100644 --- a/__tests__/issues.ts +++ b/__tests__/issues.ts @@ -92,7 +92,8 @@ describe('Issue #1252', () => { describe('Issue #1293', () => { it('merge() should not deeply coerce values', () => { - const State = Record({ foo: 'bar' as any, biz: 'baz' }); + type StateObject = { foo: string | { qux: string }; biz?: string }; + const State = Record({ foo: 'bar', biz: 'baz' }); const deepObject = { qux: 'quux' }; const firstState = State({ foo: deepObject }); diff --git a/__tests__/merge.ts b/__tests__/merge.ts index 517f36fb7b..af3b0c8453 100644 --- a/__tests__/merge.ts +++ b/__tests__/merge.ts @@ -25,7 +25,7 @@ describe('merge', () => { it('merges two maps with a merge function', () => { const m1 = Map({ a: 1, b: 2, c: 3 }); const m2 = Map({ d: 10, b: 20, e: 30 }); - expect(m1.mergeWith((a: any, b: any) => a + b, m2)).toEqual( + expect(m1.mergeWith((a: number, b: number) => a + b, m2)).toEqual( Map({ a: 1, b: 22, c: 3, d: 10, e: 30 }) ); }); @@ -33,21 +33,22 @@ describe('merge', () => { it('throws typeError without merge function', () => { const m1 = Map({ a: 1, b: 2, c: 3 }); const m2 = Map({ d: 10, b: 20, e: 30 }); - // @ts-expect-error + // @ts-expect-error -- test that runtime does throw expect(() => m1.mergeWith(1, m2)).toThrowError(TypeError); }); it('provides key as the third argument of merge function', () => { const m1 = Map({ id: 'temp', b: 2, c: 3 }); const m2 = Map({ id: 10, b: 20, e: 30 }); - const add = (a: any, b: any) => a + b; + const add = (a: number, b: number) => a + b; expect( + // @ts-expect-error -- it's difficult to type `a` not as `string | number` m1.mergeWith((a, b, key) => (key !== 'id' ? add(a, b) : b), m2) ).toEqual(Map({ id: 10, b: 22, c: 3, e: 30 })); }); it('deep merges two maps', () => { - const m1 = fromJS({ a: { b: { c: 1, d: 2 } } }) as Map; + const m1 = fromJS({ a: { b: { c: 1, d: 2 } } }); const m2 = fromJS({ a: { b: { c: 10, e: 20 }, f: 30 }, g: 40 }); expect(m1.mergeDeep(m2)).toEqual( fromJS({ a: { b: { c: 10, d: 2, e: 20 }, f: 30 }, g: 40 }) @@ -73,7 +74,7 @@ describe('merge', () => { }); it('deep merges raw JS', () => { - const m1 = fromJS({ a: { b: { c: 1, d: 2 } } }) as Map; + const m1 = fromJS({ a: { b: { c: 1, d: 2 } } }); const js = { a: { b: { c: 10, e: 20 }, f: 30 }, g: 40 }; expect(m1.mergeDeep(js)).toEqual( fromJS({ a: { b: { c: 10, d: 2, e: 20 }, f: 30 }, g: 40 }) @@ -81,9 +82,10 @@ describe('merge', () => { }); it('deep merges raw JS with a merge function', () => { - const m1 = fromJS({ a: { b: { c: 1, d: 2 } } }) as Map; + const m1 = fromJS({ a: { b: { c: 1, d: 2 } } }); const js = { a: { b: { c: 10, e: 20 }, f: 30 }, g: 40 }; - expect(m1.mergeDeepWith((a: any, b: any) => a + b, js)).toEqual( + // @ts-expect-error type of `mergeDeepWith` is too lazy for now + expect(m1.mergeDeepWith((a: number, b: number) => a + b, js)).toEqual( fromJS({ a: { b: { c: 11, d: 2, e: 20 }, f: 30 }, g: 40 }) ); }); @@ -91,7 +93,8 @@ describe('merge', () => { it('deep merges raw JS into raw JS with a merge function', () => { const js1 = { a: { b: { c: 1, d: 2 } } }; const js2 = { a: { b: { c: 10, e: 20 }, f: 30 }, g: 40 }; - expect(mergeDeepWith((a: any, b: any) => a + b, js1, js2)).toEqual({ + // @ts-expect-error type of `mergeDeepWith` is too lazy for now + expect(mergeDeepWith((a: number, b: number) => a + b, js1, js2)).toEqual({ a: { b: { c: 11, d: 2, e: 20 }, f: 30 }, g: 40, }); @@ -100,14 +103,15 @@ describe('merge', () => { it('deep merges collections into raw JS with a merge function', () => { const js = { a: { b: { c: 1, d: 2 } } }; const m = fromJS({ a: { b: { c: 10, e: 20 }, f: 30 }, g: 40 }); - expect(mergeDeepWith((a: any, b: any) => a + b, js, m)).toEqual({ + // @ts-expect-error type of `mergeDeepWith` is too lazy for now + expect(mergeDeepWith((a: number, b: number) => a + b, js, m)).toEqual({ a: { b: { c: 11, d: 2, e: 20 }, f: 30 }, g: 40, }); }); it('returns self when a deep merges is a no-op', () => { - const m1 = fromJS({ a: { b: { c: 1, d: 2 } } }) as Map; + const m1 = fromJS({ a: { b: { c: 1, d: 2 } } }); expect(m1.mergeDeep({ a: { b: { c: 1 } } })).toBe(m1); }); @@ -123,17 +127,13 @@ describe('merge', () => { it('can overwrite existing maps', () => { expect( - ( - fromJS({ a: { x: 1, y: 1 }, b: { x: 2, y: 2 } }) as Map - ).merge({ + fromJS({ a: { x: 1, y: 1 }, b: { x: 2, y: 2 } }).merge({ a: null, b: Map({ x: 10 }), }) ).toEqual(fromJS({ a: null, b: { x: 10 } })); expect( - ( - fromJS({ a: { x: 1, y: 1 }, b: { x: 2, y: 2 } }) as Map - ).mergeDeep({ + fromJS({ a: { x: 1, y: 1 }, b: { x: 2, y: 2 } }).mergeDeep({ a: null, b: { x: 10 }, }) @@ -141,7 +141,7 @@ describe('merge', () => { }); it('can overwrite existing maps with objects', () => { - const m1 = fromJS({ a: { x: 1, y: 1 } }) as Map; // deep conversion. + const m1 = fromJS({ a: { x: 1, y: 1 } }); // deep conversion. const m2 = Map({ a: { z: 10 } }); // shallow conversion to Map. // Raw object simply replaces map. @@ -175,16 +175,14 @@ describe('merge', () => { // Note: merge and mergeDeep do not deeply coerce values, they only merge // with what's there prior. - expect(initial.merge({ b: [2] } as any)).toEqual( - Map({ a: List([1]), b: [2] }) - ); - expect(initial.mergeDeep({ b: [2] } as any)).toEqual( + expect(initial.merge({ b: [2] })).toEqual(Map({ a: List([1]), b: [2] })); + expect(initial.mergeDeep({ b: [2] })).toEqual( fromJS(Map({ a: List([1]), b: [2] })) ); }); it('maintains JS values inside immutable collections', () => { - const m1 = fromJS({ a: { b: { imm: 'map' } } }) as Map; + const m1 = fromJS({ a: { b: { imm: 'map' } } }); const m2 = m1.mergeDeep(Map({ a: Map({ b: { plain: 'obj' } }) })); expect(m1.getIn(['a', 'b'])).toEqual(Map([['imm', 'map']])); diff --git a/__tests__/slice.ts b/__tests__/slice.ts index 67ba2d7722..6503ee2ca8 100644 --- a/__tests__/slice.ts +++ b/__tests__/slice.ts @@ -255,7 +255,7 @@ describe('slice', () => { }), ], (entries, args) => { - const a: Array = []; + const a: Array = []; entries.forEach(entry => (a[entry[0]] = entry[1])); const s = Seq(a); const slicedS = s.slice.apply(s, args); diff --git a/__tests__/updateIn.ts b/__tests__/updateIn.ts index 086dc9c9f3..0de76a75d5 100644 --- a/__tests__/updateIn.ts +++ b/__tests__/updateIn.ts @@ -2,6 +2,7 @@ import { fromJS, List, Map, + MapOf, removeIn, Seq, Set, @@ -11,24 +12,30 @@ import { describe('updateIn', () => { it('deep edit', () => { - const m = fromJS({ a: { b: { c: 10 } } }) as Map; + const m = fromJS({ a: { b: { c: 10 } } }); + // ^? expect( - m.updateIn(['a', 'b', 'c'], (value: any) => value * 2).toJS() + // @ts-expect-error -- type of fromJS may return a MapOf in the future, to help `updateIn` to work, `updateIn` should copy the comportment of `getIn` + m.updateIn(['a', 'b', 'c'], (value: number) => value * 2).toJS() ).toEqual({ a: { b: { c: 20 } }, }); }); it('deep edit with list as keyPath', () => { - const m = fromJS({ a: { b: { c: 10 } } }) as Map; + const m = fromJS({ a: { b: { c: 10 } } }); expect( - m.updateIn(fromJS(['a', 'b', 'c']), (value: any) => value * 2).toJS() + // @ts-expect-error -- type of fromJS may return a MapOf in the future, to help `updateIn` to work, `updateIn` should copy the comportment of `getIn` + m.updateIn(fromJS(['a', 'b', 'c']), (value: number) => value * 2).toJS() ).toEqual({ a: { b: { c: 20 } } }); }); it('deep edit in raw JS', () => { const m = { a: { b: { c: [10] } } }; - expect(updateIn(m, ['a', 'b', 'c', 0], (value: any) => value * 2)).toEqual({ + expect( + // @ts-expect-error -- `updateIn` should copy the comportment of `getIn` + updateIn(m, ['a', 'b', 'c', 0], (value: number) => value * 2) + ).toEqual({ a: { b: { c: [20] } }, }); }); @@ -73,67 +80,93 @@ describe('updateIn', () => { it('shallow remove', () => { const m = Map({ a: 123 }); - expect(m.updateIn([], map => undefined)).toEqual(undefined); + expect(m.updateIn([], () => undefined)).toEqual(undefined); }); it('deep remove', () => { - const m = fromJS({ a: { b: { c: 10 } } }) as Map; + const m = fromJS({ a: { b: { c: 10 } } }); expect( - m.updateIn(['a', 'b'], (map: any) => map.remove('c')).toJS() + m + // @ts-expect-error -- type of fromJS may return a MapOf in the future, to help `updateIn` to work, `updateIn` should copy the comportment of `getIn` + .updateIn(['a', 'b'], (map: MapOf<{ c: number }>) => map.remove('c')) + .toJS() ).toEqual({ a: { b: {} }, }); }); it('deep set', () => { - const m = fromJS({ a: { b: { c: 10 } } }) as Map; + const m = fromJS({ a: { b: { c: 10 } } }); expect( - m.updateIn(['a', 'b'], (map: any) => map.set('d', 20)).toJS() + m + // @ts-expect-error -- type of fromJS may return a MapOf in the future, to help `updateIn` to work, `updateIn` should copy the comportment of `getIn` + .updateIn(['a', 'b'], (map: MapOf<{ c: number }>) => map.set('d', 20)) + .toJS() ).toEqual({ a: { b: { c: 10, d: 20 } }, }); }); it('deep push', () => { - const m = fromJS({ a: { b: [1, 2, 3] } }) as Map; - expect(m.updateIn(['a', 'b'], (list: any) => list.push(4)).toJS()).toEqual({ + const m = fromJS({ a: { b: [1, 2, 3] } }); + expect( + // @ts-expect-error -- type of fromJS may return a MapOf in the future, to help `updateIn` to work, `updateIn` should copy the comportment of `getIn` + m.updateIn(['a', 'b'], (list: List) => list.push(4)).toJS() + ).toEqual({ a: { b: [1, 2, 3, 4] }, }); }); it('deep map', () => { - const m = fromJS({ a: { b: [1, 2, 3] } }) as Map; + const m = fromJS({ a: { b: [1, 2, 3] } }); expect( m - .updateIn(['a', 'b'], (list: any) => list.map(value => value * 10)) + // @ts-expect-error -- type of fromJS may return a MapOf in the future, to help `updateIn` to work, `updateIn` should copy the comportment of `getIn` + .updateIn(['a', 'b'], (list: List) => + list.map(value => value * 10) + ) .toJS() ).toEqual({ a: { b: [10, 20, 30] } }); }); it('creates new maps if path contains gaps', () => { - const m = fromJS({ a: { b: { c: 10 } } }) as Map; + const m = fromJS({ a: { b: { c: 10 } } }); expect( - m.updateIn(['a', 'q', 'z'], Map(), (map: any) => map.set('d', 20)).toJS() + m + .updateIn( + ['a', 'q', 'z'], + Map(), + // @ts-expect-error -- updateIn should handle the `notSetValue` parameter + (map: Map) => map.set('d', 20) + ) + .toJS() ).toEqual({ a: { b: { c: 10 }, q: { z: { d: 20 } } } }); }); it('creates new objects if path contains gaps within raw JS', () => { const m = { a: { b: { c: 10 } } }; expect( - updateIn(m, ['a', 'b', 'z'], Map(), (map: any) => map.set('d', 20)) + updateIn( + m, + ['a', 'b', 'z'], + Map(), + // @ts-expect-error -- updateIn should handle the `notSetValue` parameter + (map: Map) => map.set('d', 20) + ) ).toEqual({ a: { b: { c: 10, z: Map({ d: 20 }) } } }); }); it('throws if path cannot be set', () => { - const m = fromJS({ a: { b: { c: 10 } } }) as Map; + const m = fromJS({ a: { b: { c: 10 } } }); expect(() => { - m.updateIn(['a', 'b', 'c', 'd'], v => 20).toJS(); + m.updateIn(['a', 'b', 'c', 'd'], () => 20).toJS(); }).toThrow(); }); it('update with notSetValue when non-existing key', () => { const m = Map({ a: { b: { c: 10 } } }); - expect(m.updateIn(['x'], 100, (map: any) => map + 1).toJS()).toEqual({ + // @ts-expect-error -- updateIn should handle the `notSetValue` parameter + expect(m.updateIn(['x'], 100, (map: number) => map + 1).toJS()).toEqual({ a: { b: { c: 10 } }, x: 101, }); @@ -141,15 +174,17 @@ describe('updateIn', () => { it('update with notSetValue when non-existing key in raw JS', () => { const m = { a: { b: { c: 10 } } }; - expect(updateIn(m, ['x'], 100, (map: any) => map + 1)).toEqual({ + // @ts-expect-error -- updateIn should handle the `notSetValue` parameter + expect(updateIn(m, ['x'], 100, (map: number) => map + 1)).toEqual({ a: { b: { c: 10 } }, x: 101, }); }); it('updates self for empty path', () => { - const m = fromJS({ a: 1, b: 2, c: 3 }) as Map; - expect(m.updateIn([], (map: any) => map.set('b', 20)).toJS()).toEqual({ + const m = fromJS({ a: 1, b: 2, c: 3 }); + // @ts-expect-error -- type of fromJS may return a MapOf in the future, to help `updateIn` to work, `updateIn` should copy the comportment of `getIn` + expect(m.updateIn([], (map: typeof m) => map.set('b', 20)).toJS()).toEqual({ a: 1, b: 20, c: 3, @@ -157,7 +192,7 @@ describe('updateIn', () => { }); it('does not perform edit when new value is the same as old value', () => { - const m = fromJS({ a: { b: { c: 10 } } }) as Map; + const m = fromJS({ a: { b: { c: 10 } } }); const m2 = m.updateIn(['a', 'b', 'c'], id => id); expect(m2).toBe(m); }); @@ -206,7 +241,7 @@ describe('updateIn', () => { }); it('returns self for a no-op', () => { - const m = fromJS({ a: { b: { c: 123 } } }) as Map; + const m = fromJS({ a: { b: { c: 123 } } }); expect(m.setIn(['a', 'b', 'c'], 123)).toBe(m); }); @@ -289,15 +324,15 @@ describe('updateIn', () => { describe('mergeIn', () => { it('provides shorthand for updateIn to merge a nested value', () => { - const m1 = fromJS({ x: { a: 1, b: 2, c: 3 } }) as Map; - const m2 = fromJS({ d: 10, b: 20, e: 30 }) as Map; + const m1 = fromJS({ x: { a: 1, b: 2, c: 3 } }); + const m2 = fromJS({ d: 10, b: 20, e: 30 }); expect(m1.mergeIn(['x'], m2).toJS()).toEqual({ x: { a: 1, b: 20, c: 3, d: 10, e: 30 }, }); }); it('accepts a list as a keyPath', () => { - const m1 = fromJS({ x: { a: 1, b: 2, c: 3 } }) as Map; + const m1 = fromJS({ x: { a: 1, b: 2, c: 3 } }); const m2 = fromJS({ d: 10, b: 20, e: 30 }); expect(m1.mergeIn(fromJS(['x']), m2).toJS()).toEqual({ x: { a: 1, b: 20, c: 3, d: 10, e: 30 }, @@ -330,7 +365,7 @@ describe('updateIn', () => { describe('mergeDeepIn', () => { it('provides shorthand for updateIn to merge a nested value', () => { - const m1 = fromJS({ x: { a: 1, b: 2, c: 3 } }) as Map; + const m1 = fromJS({ x: { a: 1, b: 2, c: 3 } }); const m2 = fromJS({ d: 10, b: 20, e: 30 }); expect(m1.mergeDeepIn(['x'], m2).toJS()).toEqual({ x: { a: 1, b: 20, c: 3, d: 10, e: 30 }, @@ -338,7 +373,7 @@ describe('updateIn', () => { }); it('accepts a list as a keyPath', () => { - const m1 = fromJS({ x: { a: 1, b: 2, c: 3 } }) as Map; + const m1 = fromJS({ x: { a: 1, b: 2, c: 3 } }); const m2 = fromJS({ d: 10, b: 20, e: 30 }); expect(m1.mergeDeepIn(fromJS(['x']), m2).toJS()).toEqual({ x: { a: 1, b: 20, c: 3, d: 10, e: 30 }, diff --git a/__tests__/zip.ts b/__tests__/zip.ts index 7fb2bcfb5d..c9d98bf733 100644 --- a/__tests__/zip.ts +++ b/__tests__/zip.ts @@ -135,7 +135,7 @@ describe('zip', () => { }); it('with infinite lists', () => { - const r: Seq.Indexed = Range(0, Infinity); + const r: Seq.Indexed = Range(0, Infinity); const i = r.interleave(Seq(['A', 'B', 'C'])); expect(i.size).toBe(6); expect(i.toArray()).toEqual([0, 'A', 1, 'B', 2, 'C']); From 539082174157e9c2582a71a50d6157ea61715ef8 Mon Sep 17 00:00:00 2001 From: Julien Deniau Date: Mon, 29 Jan 2024 16:59:55 +0000 Subject: [PATCH 6/7] Fix or ignore all eslint issues in website directory --- .eslintrc.json | 1 + package-lock.json | 20 +++++++ package.json | 1 + type-definitions/ts-tests/covariance.ts | 10 ++-- website/next.config.js | 7 --- website/src/ArrowDown.tsx | 38 ++++++------ website/src/Defs.tsx | 7 ++- website/src/DocSearch.tsx | 4 +- website/src/Logo.tsx | 14 ++--- website/src/MarkdownContent.tsx | 1 + website/src/RunkitEmbed.tsx | 32 +++++++--- website/src/Sidebar.tsx | 80 ++++++++++++------------- website/src/StarBtn.tsx | 21 +++++-- website/src/static/getTypeDefs.ts | 36 ++++++----- website/src/static/getVersions.js | 1 + website/src/static/markdown.ts | 12 ++-- website/src/static/prism.ts | 1 + 17 files changed, 169 insertions(+), 117 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 25f9fb0229..f13144d93e 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -110,6 +110,7 @@ "no-lone-blocks": "off", "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-unused-vars": "off", + "prefer-const": "off", "import/no-unresolved": [ "error", { diff --git a/package-lock.json b/package-lock.json index 54b03b5488..af3b846f38 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "@size-limit/esbuild-why": "^8.2.6", "@size-limit/preset-small-lib": "^8.2.6", "@types/jest": "^29.0.0", + "@types/marked": "^6.0.0", "@types/react": "17.0.11", "@typescript-eslint/eslint-plugin": "^6.19.1", "@typescript-eslint/parser": "^6.19.1", @@ -2999,6 +3000,16 @@ "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "dev": true }, + "node_modules/@types/marked": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@types/marked/-/marked-6.0.0.tgz", + "integrity": "sha512-jmjpa4BwUsmhxcfsgUit/7A9KbrC48Q0q8KvnY107ogcjGgTFDlIL3RpihNpx2Mu1hM4mdFQjoVc4O6JoGKHsA==", + "deprecated": "This is a stub types definition. marked provides its own type definitions, so you do not need this installed.", + "dev": true, + "dependencies": { + "marked": "*" + } + }, "node_modules/@types/minimatch": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.5.tgz", @@ -16299,6 +16310,15 @@ "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "dev": true }, + "@types/marked": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@types/marked/-/marked-6.0.0.tgz", + "integrity": "sha512-jmjpa4BwUsmhxcfsgUit/7A9KbrC48Q0q8KvnY107ogcjGgTFDlIL3RpihNpx2Mu1hM4mdFQjoVc4O6JoGKHsA==", + "dev": true, + "requires": { + "marked": "*" + } + }, "@types/minimatch": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.5.tgz", diff --git a/package.json b/package.json index 4bde7d5099..3f10f74fce 100644 --- a/package.json +++ b/package.json @@ -90,6 +90,7 @@ "@size-limit/esbuild-why": "^8.2.6", "@size-limit/preset-small-lib": "^8.2.6", "@types/jest": "^29.0.0", + "@types/marked": "^6.0.0", "@types/react": "17.0.11", "@typescript-eslint/eslint-plugin": "^6.19.1", "@typescript-eslint/parser": "^6.19.1", diff --git a/type-definitions/ts-tests/covariance.ts b/type-definitions/ts-tests/covariance.ts index d7b63dacb5..c1bf50ffcb 100644 --- a/type-definitions/ts-tests/covariance.ts +++ b/type-definitions/ts-tests/covariance.ts @@ -34,7 +34,7 @@ listOfA = List([new B()]); let listOfC: List = listOfB; // Map covariance -declare var mapOfB: Map; +declare let mapOfB: Map; let mapOfA: Map = mapOfB; // $ExpectType MapOf<{ b: B; }> @@ -44,7 +44,7 @@ mapOfA = Map({ b: new B() }); let mapOfC: Map = mapOfB; // Set covariance -declare var setOfB: Set; +declare let setOfB: Set; let setOfA: Set = setOfB; // $ExpectType Set @@ -53,7 +53,7 @@ setOfA = Set([new B()]); let setOfC: Set = setOfB; // Stack covariance -declare var stackOfB: Stack; +declare let stackOfB: Stack; let stackOfA: Stack = stackOfB; // $ExpectType Stack stackOfA = Stack([new B()]); @@ -61,7 +61,7 @@ stackOfA = Stack([new B()]); let stackOfC: Stack = stackOfB; // OrderedMap covariance -declare var orderedMapOfB: OrderedMap; +declare let orderedMapOfB: OrderedMap; let orderedMapOfA: OrderedMap = orderedMapOfB; // $ExpectType OrderedMap orderedMapOfA = OrderedMap({ b: new B() }); @@ -69,7 +69,7 @@ orderedMapOfA = OrderedMap({ b: new B() }); let orderedMapOfC: OrderedMap = orderedMapOfB; // OrderedSet covariance -declare var orderedSetOfB: OrderedSet; +declare let orderedSetOfB: OrderedSet; let orderedSetOfA: OrderedSet = orderedSetOfB; // $ExpectType OrderedSet orderedSetOfA = OrderedSet([new B()]); diff --git a/website/next.config.js b/website/next.config.js index 478bf85393..4ebd0af229 100644 --- a/website/next.config.js +++ b/website/next.config.js @@ -2,11 +2,4 @@ module.exports = { reactStrictMode: true, trailingSlash: true, output: 'export', - - // Issues while upgrading from next 11 to 12. - // Possibly related to typescript parser missing ? - // TODO Waiting the migration from tslint to eslint to reactivate this - eslint: { - ignoreDuringBuilds: true, - }, }; diff --git a/website/src/ArrowDown.tsx b/website/src/ArrowDown.tsx index cf71ac58be..5e03c3339f 100644 --- a/website/src/ArrowDown.tsx +++ b/website/src/ArrowDown.tsx @@ -1,16 +1,17 @@ -export const ArrowDown = ({ isActive }: { isActive: boolean }) => ( - - - + + - - -); + fill="currentColor" + /> + + + ); +} diff --git a/website/src/Defs.tsx b/website/src/Defs.tsx index c153aea328..0d25ef7ceb 100644 --- a/website/src/Defs.tsx +++ b/website/src/Defs.tsx @@ -289,7 +289,10 @@ export function MemberDef({ member }: { member: ObjectMember }) { ); } -function functionParams(params: Array = [], shouldWrap: boolean) { +function functionParams( + params: Array | undefined, + shouldWrap: boolean +) { const elements = interpose( shouldWrap ? ( <> @@ -299,7 +302,7 @@ function functionParams(params: Array = [], shouldWrap: boolean) { ) : ( ', ' ), - params.map((t, i) => ( + (params ?? []).map((t, i) => ( {t.varArgs ? '...' : null} {t.name} diff --git a/website/src/DocSearch.tsx b/website/src/DocSearch.tsx index 892009ca34..82e07cf313 100644 --- a/website/src/DocSearch.tsx +++ b/website/src/DocSearch.tsx @@ -14,9 +14,9 @@ export function DocSearch() { 'load', () => { // Initialize Algolia search. - // @ts-ignore + // @ts-expect-error -- algolia is set on windows, need proper type if (window.docsearch) { - // @ts-ignore + // @ts-expect-error -- algolia is set on windows, need proper type window.docsearch({ apiKey: '83f61f865ef4cb682e0432410c2f7809', indexName: 'immutable_js', diff --git a/website/src/Logo.tsx b/website/src/Logo.tsx index 1b427c858f..b9c0bb5e7c 100644 --- a/website/src/Logo.tsx +++ b/website/src/Logo.tsx @@ -1,14 +1,10 @@ -import { memo } from 'react'; - -export const Logo = memo(function _Logo({ - opacity = 1, - inline, - color, -}: { +type Props = { opacity?: number; inline?: boolean; color: string; -}) { +}; + +export function Logo({ opacity = 1, inline, color }: Props) { return !inline ? ( @@ -75,4 +71,4 @@ export const Logo = memo(function _Logo({ /> ); -}); +} diff --git a/website/src/MarkdownContent.tsx b/website/src/MarkdownContent.tsx index 7f90fca400..f046b50406 100644 --- a/website/src/MarkdownContent.tsx +++ b/website/src/MarkdownContent.tsx @@ -24,6 +24,7 @@ export const MarkdownContent = memo(function MarkdownContent({ }; return ( + // eslint-disable-next-line jsx-a11y/click-events-have-key-events
[^\n]*\n?)+$/g, '') ), minHeight: '52px', + // eslint-disable-next-line @typescript-eslint/no-explicit-any onLoad(notebook: any) { notebook.evaluate(); }, }); } +// eslint-disable-next-line @typescript-eslint/no-explicit-any function makeAssert(I: any) { const isIterable = I.isIterable || I.Iterable.isIterable; let html = ` @@ -90,15 +93,26 @@ function makeAssert(I: any) { } `; - function compare(lhs: any, rhs: any, _same: boolean, identical: boolean) { + function compare( + lhs: unknown, + rhs: unknown, + _same: boolean, + identical: boolean + ) { const both = !identical && isIterable(lhs) && isIterable(rhs); + // @ts-expect-error -- this is an immutable value if (both) return lhs.equals(rhs); return lhs === rhs; } - function message(lhs: any, rhs: any, same: boolean, identical: boolean) { + function message( + lhs: unknown, + rhs: unknown, + same: boolean, + identical: boolean + ) { const result = compare(lhs, rhs, same, identical); const comparison = result ? identical @@ -119,19 +133,19 @@ function makeAssert(I: any) {
`); } - function equal(lhs: any, rhs: any) { + function equal(lhs: unknown, rhs: unknown) { return message(lhs, rhs, true, false); } - function notEqual(lhs: any, rhs: any) { + function notEqual(lhs: unknown, rhs: unknown) { return message(lhs, rhs, false, false); } - function strictEqual(lhs: any, rhs: any) { + function strictEqual(lhs: unknown, rhs: unknown) { return message(lhs, rhs, true, true); } - function notStrictEqual(lhs: any, rhs: any) { + function notStrictEqual(lhs: unknown, rhs: unknown) { return message(lhs, rhs, false, true); } diff --git a/website/src/Sidebar.tsx b/website/src/Sidebar.tsx index b19b5ee392..98af397fc5 100644 --- a/website/src/Sidebar.tsx +++ b/website/src/Sidebar.tsx @@ -86,50 +86,48 @@ function Focus({ } return ( - <> -
- {focus.call && ( -
-

Construction

-
- {focus.call.label} -
-
- )} - - {focus.functions && ( -
-

Static Methods

- {Object.values(focus.functions).map(fn => ( -
- {fn.label} -
- ))} -
- )} +
+ {focus.call && ( +
+

Construction

+
+ {focus.call.label} +
+
+ )} + {focus.functions && (
- {collectMemberGroups( - focus.interface, - showInGroups, - showInherited - ).flatMap(([title, groupMembers]) => - groupMembers.length === 0 - ? null - : [ -

- {title || 'Members'} -

, - groupMembers.map(member => ( -
- {member.label} -
- )), - ] - )} +

Static Methods

+ {Object.values(focus.functions).map(fn => ( +
+ {fn.label} +
+ ))}
-
- + )} + +
+ {collectMemberGroups( + focus.interface, + showInGroups, + showInherited + ).flatMap(([title, groupMembers]) => + groupMembers.length === 0 + ? null + : [ +

+ {title || 'Members'} +

, + groupMembers.map(member => ( +
+ {member.label} +
+ )), + ] + )} +
+
); } diff --git a/website/src/StarBtn.tsx b/website/src/StarBtn.tsx index 16f4feffd0..348a70bda8 100644 --- a/website/src/StarBtn.tsx +++ b/website/src/StarBtn.tsx @@ -5,13 +5,18 @@ import { useEffect, useState } from 'react'; // https://api.github.com/repos/immutable-js/immutable-js export function StarBtn() { - const [stars, setStars] = useState(null); + const [stars, setStars] = useState(null); useEffect(() => { loadJSON( 'https://api.github.com/repos/immutable-js/immutable-js', value => { - if (value && value.stargazers_count) { + if ( + typeof value === 'object' && + value !== null && + 'stargazers_count' in value && + typeof value.stargazers_count === 'number' + ) { setStars(value.stargazers_count); } } @@ -173,12 +178,20 @@ export function StarBtn() { ); } -function loadJSON(url: string, then: (value: any) => void) { +function loadJSON(url: string, then: (value: unknown) => void) { const oReq = new XMLHttpRequest(); oReq.onload = event => { + if ( + !event.target || + !('responseText' in event.target) || + typeof event.target.responseText !== 'string' + ) { + return null; + } + let json; try { - json = JSON.parse((event.target as any).responseText); + json = JSON.parse(event.target.responseText); } catch (e) { // ignore error } diff --git a/website/src/static/getTypeDefs.ts b/website/src/static/getTypeDefs.ts index 0e225ea95e..fe919eee1f 100644 --- a/website/src/static/getTypeDefs.ts +++ b/website/src/static/getTypeDefs.ts @@ -180,10 +180,11 @@ function updateInheritedTypeParams( function updateType(type: Type | undefined): Type | undefined; function updateType(type: Type | undefined): Type | undefined { switch (type?.k) { - case TypeKind.Param: + case TypeKind.Param: { // A parameter reference is replaced with the implementing type argument const paramIndex = params.indexOf(type.param); return paramIndex >= 0 ? args[paramIndex] : type; + } case TypeKind.Array: case TypeKind.Indexed: case TypeKind.Operator: @@ -285,18 +286,18 @@ function genTypeDefData(version: string): TypeDefs { function getTypeDefSource(version: string): string { if (version === 'latest@main') { return readFileSync(typeDefPath, { encoding: 'utf8' }); - } else { - // Previous versions used a different name for the type definitions file. - // If the expected file isn't found for this version, try the older name. - try { - return execSync(`git show ${version}:${typeDefPath} 2>/dev/null`, { - encoding: 'utf8', - }); - } catch { - return execSync(`git show ${version}:${typeDefPathOld}`, { - encoding: 'utf8', - }); - } + } + + // Previous versions used a different name for the type definitions file. + // If the expected file isn't found for this version, try the older name. + try { + return execSync(`git show ${version}:${typeDefPath} 2>/dev/null`, { + encoding: 'utf8', + }); + } catch { + return execSync(`git show ${version}:${typeDefPathOld}`, { + encoding: 'utf8', + }); } } @@ -330,7 +331,6 @@ function typesVisitor(source: ts.SourceFile) { return; default: ts.forEachChild(node, visit); - return; } } @@ -624,20 +624,22 @@ function typesVisitor(source: ts.SourceFile) { k: TypeKind.Object, members: (node as ts.TypeLiteralNode).members.map(m => { switch (m.kind) { - case ts.SyntaxKind.IndexSignature: + case ts.SyntaxKind.IndexSignature: { const indexNode = m as ts.IndexSignatureDeclaration; return { index: true, params: indexNode.parameters.map(parseParam), type: parseType(indexNode.type), }; - case ts.SyntaxKind.PropertySignature: + } + case ts.SyntaxKind.PropertySignature: { const propNode = m as ts.PropertySignature; return { // Note: this will break on computed or other complex props. name: (propNode.name as ts.Identifier).text, type: propNode.type && parseType(propNode.type), }; + } } throw new Error('Unknown member kind: ' + ts.SyntaxKind[m.kind]); }), @@ -815,6 +817,7 @@ function pushIn< Array, V extends A[number] >(obj: T, path: readonly [K1, K2, K3], value: V): V; +// eslint-disable-next-line @typescript-eslint/no-explicit-any function pushIn(obj: any, path: ReadonlyArray, value: any) { for (let ii = 0; ii < path.length; ii++) { obj = obj[path[ii]] || (obj[path[ii]] = ii === path.length - 1 ? [] : {}); @@ -854,6 +857,7 @@ function setIn< path: readonly [K1, K2, K3, K4], value: NonNullable[K2]>[K3]>[K4] ): void; +// eslint-disable-next-line @typescript-eslint/no-explicit-any function setIn(obj: any, path: ReadonlyArray, value: any) { for (let ii = 0; ii < path.length - 1; ii++) { obj = obj[path[ii]] || (obj[path[ii]] = {}); diff --git a/website/src/static/getVersions.js b/website/src/static/getVersions.js index b879ed48a9..a2034eff60 100644 --- a/website/src/static/getVersions.js +++ b/website/src/static/getVersions.js @@ -1,3 +1,4 @@ +// eslint-disable-next-line @typescript-eslint/no-var-requires const { execSync } = require('child_process'); let versions; diff --git a/website/src/static/markdown.ts b/website/src/static/markdown.ts index c82f4c8c51..5c332a2b2d 100644 --- a/website/src/static/markdown.ts +++ b/website/src/static/markdown.ts @@ -1,4 +1,3 @@ -// @ts-ignore import marked from 'marked'; import { Prism as prism } from './prism'; import type { TypeDefs, CallSignature, TypeDefinition } from '../TypeDefs'; @@ -9,6 +8,11 @@ export type MarkdownContext = { signatures?: Array; }; +type RunkitContext = { + options: string | object; + activated: boolean; +}; + export function markdown(content: string, context: MarkdownContext) { if (!content) return content; @@ -35,7 +39,7 @@ export function markdown(content: string, context: MarkdownContext) { const renderer = new marked.Renderer(); const runkitRegExp = /^(.|\n)*$/; - const runkitContext = { options: '{}', activated: false }; + const runkitContext: RunkitContext = { options: '{}', activated: false }; renderer.html = function (text: string) { const result = runkitRegExp.exec(text); @@ -46,7 +50,6 @@ export function markdown(content: string, context: MarkdownContext) { try { runkitContext.options = result[1] ? JSON.parse(result[1]) : {}; } catch (e) { - // @ts-ignore runkitContext.options = {}; } return text; @@ -98,7 +101,7 @@ export function markdown(content: string, context: MarkdownContext) { function decorateCodeSpan( text: string, - highlight?: (code: string, lang: string) => string + highlight?: (code: string, lang: string) => string | void ) { if ( context.signatures && @@ -153,6 +156,7 @@ export function markdown(content: string, context: MarkdownContext) { return findDocsUrl(defs, elements); } + // @ts-expect-error -- issue with "context", probably because we are on a really old version of marked return marked(content, { renderer, context }); } diff --git a/website/src/static/prism.ts b/website/src/static/prism.ts index 6924e982cd..905ce5aad4 100644 --- a/website/src/static/prism.ts +++ b/website/src/static/prism.ts @@ -1,3 +1,4 @@ +// eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-nocheck /* eslint-disable */ From a9d9160c049c520946b11113d2d38ee4fe0d8c3e Mon Sep 17 00:00:00 2001 From: Julien Deniau Date: Mon, 29 Jan 2024 17:12:07 +0000 Subject: [PATCH 7/7] Ignore eslint report in main immutable.d.ts file for now --- package-lock.json | 25 +++++++++---------------- package.json | 2 +- type-definitions/immutable.d.ts | 3 +++ 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/package-lock.json b/package-lock.json index af3b846f38..e4073d0ef8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "@size-limit/esbuild-why": "^8.2.6", "@size-limit/preset-small-lib": "^8.2.6", "@types/jest": "^29.0.0", - "@types/marked": "^6.0.0", + "@types/marked": "^2.0.0", "@types/react": "17.0.11", "@typescript-eslint/eslint-plugin": "^6.19.1", "@typescript-eslint/parser": "^6.19.1", @@ -3001,14 +3001,10 @@ "dev": true }, "node_modules/@types/marked": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/@types/marked/-/marked-6.0.0.tgz", - "integrity": "sha512-jmjpa4BwUsmhxcfsgUit/7A9KbrC48Q0q8KvnY107ogcjGgTFDlIL3RpihNpx2Mu1hM4mdFQjoVc4O6JoGKHsA==", - "deprecated": "This is a stub types definition. marked provides its own type definitions, so you do not need this installed.", - "dev": true, - "dependencies": { - "marked": "*" - } + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@types/marked/-/marked-2.0.5.tgz", + "integrity": "sha512-shRZ7XnYFD/8n8zSjKvFdto1QNSf4tONZIlNEZGrJe8GsOE8DL/hG1Hbl8gZlfLnjS7+f5tZGIaTgfpyW38h4w==", + "dev": true }, "node_modules/@types/minimatch": { "version": "3.0.5", @@ -16311,13 +16307,10 @@ "dev": true }, "@types/marked": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/@types/marked/-/marked-6.0.0.tgz", - "integrity": "sha512-jmjpa4BwUsmhxcfsgUit/7A9KbrC48Q0q8KvnY107ogcjGgTFDlIL3RpihNpx2Mu1hM4mdFQjoVc4O6JoGKHsA==", - "dev": true, - "requires": { - "marked": "*" - } + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@types/marked/-/marked-2.0.5.tgz", + "integrity": "sha512-shRZ7XnYFD/8n8zSjKvFdto1QNSf4tONZIlNEZGrJe8GsOE8DL/hG1Hbl8gZlfLnjS7+f5tZGIaTgfpyW38h4w==", + "dev": true }, "@types/minimatch": { "version": "3.0.5", diff --git a/package.json b/package.json index 3f10f74fce..c41eb9bbce 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,7 @@ "@size-limit/esbuild-why": "^8.2.6", "@size-limit/preset-small-lib": "^8.2.6", "@types/jest": "^29.0.0", - "@types/marked": "^6.0.0", + "@types/marked": "^2.0.0", "@types/react": "17.0.11", "@typescript-eslint/eslint-plugin": "^6.19.1", "@typescript-eslint/parser": "^6.19.1", diff --git a/type-definitions/immutable.d.ts b/type-definitions/immutable.d.ts index f2b0eecf90..c7c5f2843d 100644 --- a/type-definitions/immutable.d.ts +++ b/type-definitions/immutable.d.ts @@ -1,3 +1,5 @@ +/** @ignore we should disable this rules, but let's activate it to enable eslint first */ +/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types */ /** * Immutable data encourages pure functions (data-in, data-out) and lends itself * to much simpler application development and enabling techniques from @@ -125,6 +127,7 @@ declare namespace Immutable { : string]: V extends object ? unknown : V; } : // convert IndexedCollection or Immutable.Set to DeepCopy plain JS array + // eslint-disable-next-line @typescript-eslint/no-unused-vars T extends Collection ? Array> : T extends string | number // Iterable scalar types : should be kept as is