From 11b3698c6c3ea350e323f02505e5d7ca2ef02236 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Oct 2021 10:57:47 -0700 Subject: [PATCH 01/44] chore: bump jest from 27.2.1 to 27.2.4 (#3952) Bumps [jest](https://github.com/facebook/jest) from 27.2.1 to 27.2.4. - [Release notes](https://github.com/facebook/jest/releases) - [Changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md) - [Commits](https://github.com/facebook/jest/compare/v27.2.1...v27.2.4) --- updated-dependencies: - dependency-name: jest dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 649 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 335 insertions(+), 314 deletions(-) diff --git a/yarn.lock b/yarn.lock index e8248b1bd885..7a60b2bd464e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -811,49 +811,48 @@ jest-util "^27.0.6" slash "^3.0.0" -"@jest/console@^27.2.0": - version "27.2.0" - resolved "https://registry.yarnpkg.com/@jest/console/-/console-27.2.0.tgz#57f702837ec52899be58c3794dce5941c77a8b63" - integrity sha512-35z+RqsK2CCgNxn+lWyK8X4KkaDtfL4BggT7oeZ0JffIiAiEYFYPo5B67V50ZubqDS1ehBrdCR2jduFnIrZOYw== +"@jest/console@^27.2.4": + version "27.2.4" + resolved "https://registry.yarnpkg.com/@jest/console/-/console-27.2.4.tgz#2f1a4bf82b9940065d4818fac271def99ec55e5e" + integrity sha512-94znCKynPZpDpYHQ6esRJSc11AmONrVkBOBZiD7S+bSubHhrUfbS95EY5HIOxhm4PQO7cnvZkL3oJcY0oMA+Wg== dependencies: - "@jest/types" "^27.1.1" + "@jest/types" "^27.2.4" "@types/node" "*" chalk "^4.0.0" - jest-message-util "^27.2.0" - jest-util "^27.2.0" + jest-message-util "^27.2.4" + jest-util "^27.2.4" slash "^3.0.0" -"@jest/core@^27.2.1": - version "27.2.1" - resolved "https://registry.yarnpkg.com/@jest/core/-/core-27.2.1.tgz#93dc50e2aaba2c944e5765cf658dcd98d804c970" - integrity sha512-XcGt9UgPyzylThvezwUIMCNVp8xxN78Ic3WwhJZehZt4n2hPHR6Bd85A1nKFZBeqW58Vd+Cx/LaN6YL4n58KlA== +"@jest/core@^27.2.4": + version "27.2.4" + resolved "https://registry.yarnpkg.com/@jest/core/-/core-27.2.4.tgz#0b932da787d64848eab720dbb88e5b7a3f86e539" + integrity sha512-UNQLyy+rXoojNm2MGlapgzWhZD1CT1zcHZQYeiD0xE7MtJfC19Q6J5D/Lm2l7i4V97T30usKDoEtjI8vKwWcLg== dependencies: - "@jest/console" "^27.2.0" - "@jest/reporters" "^27.2.1" - "@jest/test-result" "^27.2.0" - "@jest/transform" "^27.2.1" - "@jest/types" "^27.1.1" + "@jest/console" "^27.2.4" + "@jest/reporters" "^27.2.4" + "@jest/test-result" "^27.2.4" + "@jest/transform" "^27.2.4" + "@jest/types" "^27.2.4" "@types/node" "*" ansi-escapes "^4.2.1" chalk "^4.0.0" emittery "^0.8.1" exit "^0.1.2" graceful-fs "^4.2.4" - jest-changed-files "^27.1.1" - jest-config "^27.2.1" - jest-haste-map "^27.2.0" - jest-message-util "^27.2.0" + jest-changed-files "^27.2.4" + jest-config "^27.2.4" + jest-haste-map "^27.2.4" + jest-message-util "^27.2.4" jest-regex-util "^27.0.6" - jest-resolve "^27.2.0" - jest-resolve-dependencies "^27.2.1" - jest-runner "^27.2.1" - jest-runtime "^27.2.1" - jest-snapshot "^27.2.1" - jest-util "^27.2.0" - jest-validate "^27.2.0" - jest-watcher "^27.2.0" + jest-resolve "^27.2.4" + jest-resolve-dependencies "^27.2.4" + jest-runner "^27.2.4" + jest-runtime "^27.2.4" + jest-snapshot "^27.2.4" + jest-util "^27.2.4" + jest-validate "^27.2.4" + jest-watcher "^27.2.4" micromatch "^4.0.4" - p-each-series "^2.1.0" rimraf "^3.0.0" slash "^3.0.0" strip-ansi "^6.0.0" @@ -868,15 +867,15 @@ "@types/node" "*" jest-mock "^27.0.6" -"@jest/environment@^27.2.0": - version "27.2.0" - resolved "https://registry.yarnpkg.com/@jest/environment/-/environment-27.2.0.tgz#48d1dbfa65f8e4a5a5c6cbeb9c59d1a5c2776f6b" - integrity sha512-iPWmQI0wRIYSZX3wKu4FXHK4eIqkfq6n1DCDJS+v3uby7SOXrHvX4eiTBuEdSvtDRMTIH2kjrSkjHf/F9JIYyQ== +"@jest/environment@^27.2.4": + version "27.2.4" + resolved "https://registry.yarnpkg.com/@jest/environment/-/environment-27.2.4.tgz#db3e60f7dd30ab950f6ce2d6d7293ed9a6b7cbcd" + integrity sha512-wkuui5yr3SSQW0XD0Qm3TATUbL/WE3LDEM3ulC+RCQhMf2yxhci8x7svGkZ4ivJ6Pc94oOzpZ6cdHBAMSYd1ew== dependencies: - "@jest/fake-timers" "^27.2.0" - "@jest/types" "^27.1.1" + "@jest/fake-timers" "^27.2.4" + "@jest/types" "^27.2.4" "@types/node" "*" - jest-mock "^27.1.1" + jest-mock "^27.2.4" "@jest/fake-timers@^27.0.6": version "27.0.6" @@ -890,17 +889,17 @@ jest-mock "^27.0.6" jest-util "^27.0.6" -"@jest/fake-timers@^27.2.0": - version "27.2.0" - resolved "https://registry.yarnpkg.com/@jest/fake-timers/-/fake-timers-27.2.0.tgz#560841bc21ae7fbeff0cbff8de8f5cf43ad3561d" - integrity sha512-gSu3YHvQOoVaTWYGgHFB7IYFtcF2HBzX4l7s47VcjvkUgL4/FBnE20x7TNLa3W6ABERtGd5gStSwsA8bcn+c4w== +"@jest/fake-timers@^27.2.4": + version "27.2.4" + resolved "https://registry.yarnpkg.com/@jest/fake-timers/-/fake-timers-27.2.4.tgz#00df08bd60332bd59503cb5b6db21e4903785f86" + integrity sha512-cs/TzvwWUM7kAA6Qm/890SK6JJ2pD5RfDNM3SSEom6BmdyV6OiWP1qf/pqo6ts6xwpcM36oN0wSEzcZWc6/B6w== dependencies: - "@jest/types" "^27.1.1" - "@sinonjs/fake-timers" "^7.0.2" + "@jest/types" "^27.2.4" + "@sinonjs/fake-timers" "^8.0.1" "@types/node" "*" - jest-message-util "^27.2.0" - jest-mock "^27.1.1" - jest-util "^27.2.0" + jest-message-util "^27.2.4" + jest-mock "^27.2.4" + jest-util "^27.2.4" "@jest/globals@^27.0.6": version "27.0.6" @@ -911,14 +910,14 @@ "@jest/types" "^27.0.6" expect "^27.0.6" -"@jest/globals@^27.2.1": - version "27.2.1" - resolved "https://registry.yarnpkg.com/@jest/globals/-/globals-27.2.1.tgz#6842c70b6713fbe2fcaf89eac20d77eeeb0e282c" - integrity sha512-4P46Zr4cckSitsWtOMRvgMMn7mOKbBsQdYxHeGSIG3kpI4gNR2vk51balPulZHnBQCQb/XBptprtoSv1REfaew== +"@jest/globals@^27.2.4": + version "27.2.4" + resolved "https://registry.yarnpkg.com/@jest/globals/-/globals-27.2.4.tgz#0aeb22b011f8c8c4b8ff3b4dbd1ee0392fe0dd8a" + integrity sha512-DRsRs5dh0i+fA9mGHylTU19+8fhzNJoEzrgsu+zgJoZth3x8/0juCQ8nVVdW1er4Cqifb/ET7/hACYVPD0dBEA== dependencies: - "@jest/environment" "^27.2.0" - "@jest/types" "^27.1.1" - expect "^27.2.1" + "@jest/environment" "^27.2.4" + "@jest/types" "^27.2.4" + expect "^27.2.4" "@jest/reporters@27.0.6": version "27.0.6" @@ -950,16 +949,16 @@ terminal-link "^2.0.0" v8-to-istanbul "^8.0.0" -"@jest/reporters@^27.2.1": - version "27.2.1" - resolved "https://registry.yarnpkg.com/@jest/reporters/-/reporters-27.2.1.tgz#2e43361b962e26975d40eafd7b4f14c70b4fe9a0" - integrity sha512-ILqR+bIIBlhaHjDtQR/0Z20YkKAQVM+NVRuJLaWFCoRx/rKQQSxG01ZLiLV0MsA6wkBHf6J9fzFuXp0k5l7epw== +"@jest/reporters@^27.2.4": + version "27.2.4" + resolved "https://registry.yarnpkg.com/@jest/reporters/-/reporters-27.2.4.tgz#1482ff007f2e919d85c54b1563abb8b2ea2d5198" + integrity sha512-LHeSdDnDZkDnJ8kvnjcqV8P1Yv/32yL4d4XfR5gBiy3xGO0onwll1QEbvtW96fIwhx2nejug0GTaEdNDoyr3fQ== dependencies: "@bcoe/v8-coverage" "^0.2.3" - "@jest/console" "^27.2.0" - "@jest/test-result" "^27.2.0" - "@jest/transform" "^27.2.1" - "@jest/types" "^27.1.1" + "@jest/console" "^27.2.4" + "@jest/test-result" "^27.2.4" + "@jest/transform" "^27.2.4" + "@jest/types" "^27.2.4" chalk "^4.0.0" collect-v8-coverage "^1.0.0" exit "^0.1.2" @@ -970,15 +969,15 @@ istanbul-lib-report "^3.0.0" istanbul-lib-source-maps "^4.0.0" istanbul-reports "^3.0.2" - jest-haste-map "^27.2.0" - jest-resolve "^27.2.0" - jest-util "^27.2.0" - jest-worker "^27.2.0" + jest-haste-map "^27.2.4" + jest-resolve "^27.2.4" + jest-util "^27.2.4" + jest-worker "^27.2.4" slash "^3.0.0" source-map "^0.6.0" string-length "^4.0.1" terminal-link "^2.0.0" - v8-to-istanbul "^8.0.0" + v8-to-istanbul "^8.1.0" "@jest/source-map@^27.0.6": version "27.0.6" @@ -999,13 +998,13 @@ "@types/istanbul-lib-coverage" "^2.0.0" collect-v8-coverage "^1.0.0" -"@jest/test-result@^27.2.0": - version "27.2.0" - resolved "https://registry.yarnpkg.com/@jest/test-result/-/test-result-27.2.0.tgz#377b46a41a6415dd4839fd0bed67b89fecea6b20" - integrity sha512-JPPqn8h0RGr4HyeY1Km+FivDIjTFzDROU46iAvzVjD42ooGwYoqYO/MQTilhfajdz6jpVnnphFrKZI5OYrBONA== +"@jest/test-result@^27.2.4": + version "27.2.4" + resolved "https://registry.yarnpkg.com/@jest/test-result/-/test-result-27.2.4.tgz#d1ca8298d168f1b0be834bfb543b1ac0294c05d7" + integrity sha512-eU+PRo0+lIS01b0dTmMdVZ0TtcRSxEaYquZTRFMQz6CvsehGhx9bRzi9Zdw6VROviJyv7rstU+qAMX5pNBmnfQ== dependencies: - "@jest/console" "^27.2.0" - "@jest/types" "^27.1.1" + "@jest/console" "^27.2.4" + "@jest/types" "^27.2.4" "@types/istanbul-lib-coverage" "^2.0.0" collect-v8-coverage "^1.0.0" @@ -1019,15 +1018,15 @@ jest-haste-map "^27.0.6" jest-runtime "^27.0.6" -"@jest/test-sequencer@^27.2.1": - version "27.2.1" - resolved "https://registry.yarnpkg.com/@jest/test-sequencer/-/test-sequencer-27.2.1.tgz#1682cd3a16198fa358ff9565b0d2792919f36562" - integrity sha512-fWcEgWQXgvU4DFY5YHfQsGwqfJWyuCUzdOzLZTYtyLB3WK1mFPQGYAszM7mCEZjyVon5XRuCa+2/+hif/uMucQ== +"@jest/test-sequencer@^27.2.4": + version "27.2.4" + resolved "https://registry.yarnpkg.com/@jest/test-sequencer/-/test-sequencer-27.2.4.tgz#df66422a3e9e7440ce8b7498e255fa6b52c0bc03" + integrity sha512-fpk5eknU3/DXE2QCCG1wv/a468+cfPo3Asu6d6yUtM9LOPh709ubZqrhuUOYfM8hXMrIpIdrv1CdCrWWabX0rQ== dependencies: - "@jest/test-result" "^27.2.0" + "@jest/test-result" "^27.2.4" graceful-fs "^4.2.4" - jest-haste-map "^27.2.0" - jest-runtime "^27.2.1" + jest-haste-map "^27.2.4" + jest-runtime "^27.2.4" "@jest/transform@^27.0.2": version "27.0.2" @@ -1071,21 +1070,21 @@ source-map "^0.6.1" write-file-atomic "^3.0.0" -"@jest/transform@^27.2.1": - version "27.2.1" - resolved "https://registry.yarnpkg.com/@jest/transform/-/transform-27.2.1.tgz#743443adb84b3b7419951fc702515ce20ba6285e" - integrity sha512-xmB5vh81KK8DiiCMtI5vI59mP+GggNmc9BiN+fg4mKdQHV369+WuZc1Lq2xWFCOCsRPHt24D9h7Idp4YaMB1Ww== +"@jest/transform@^27.2.4": + version "27.2.4" + resolved "https://registry.yarnpkg.com/@jest/transform/-/transform-27.2.4.tgz#2fe5b6836895f7a1b8bdec442c51e83943c62733" + integrity sha512-n5FlX2TH0oQGwyVDKPxdJ5nI2sO7TJBFe3u3KaAtt7TOiV4yL+Y+rSFDl+Ic5MpbiA/eqXmLAQxjnBmWgS2rEA== dependencies: "@babel/core" "^7.1.0" - "@jest/types" "^27.1.1" + "@jest/types" "^27.2.4" babel-plugin-istanbul "^6.0.0" chalk "^4.0.0" convert-source-map "^1.4.0" fast-json-stable-stringify "^2.0.0" graceful-fs "^4.2.4" - jest-haste-map "^27.2.0" + jest-haste-map "^27.2.4" jest-regex-util "^27.0.6" - jest-util "^27.2.0" + jest-util "^27.2.4" micromatch "^4.0.4" pirates "^4.0.1" slash "^3.0.0" @@ -1103,6 +1102,17 @@ "@types/yargs" "^16.0.0" chalk "^4.0.0" +"@jest/types@^27.2.4": + version "27.2.4" + resolved "https://registry.yarnpkg.com/@jest/types/-/types-27.2.4.tgz#2430042a66e00dc5b140c3636f4474d464c21ee8" + integrity sha512-IDO2ezTxeMvQAHxzG/ZvEyA47q0aVfzT95rGFl7bZs/Go0aIucvfDbS2rmnoEdXxlLQhcolmoG/wvL/uKx4tKA== + dependencies: + "@types/istanbul-lib-coverage" "^2.0.0" + "@types/istanbul-reports" "^3.0.0" + "@types/node" "*" + "@types/yargs" "^16.0.0" + chalk "^4.0.0" + "@lerna/add@3.21.0": version "3.21.0" resolved "https://registry.yarnpkg.com/@lerna/add/-/add-3.21.0.tgz#27007bde71cc7b0a2969ab3c2f0ae41578b4577b" @@ -2128,6 +2138,13 @@ dependencies: "@sinonjs/commons" "^1.7.0" +"@sinonjs/fake-timers@^8.0.1": + version "8.0.1" + resolved "https://registry.yarnpkg.com/@sinonjs/fake-timers/-/fake-timers-8.0.1.tgz#1c1c9a91419f804e59ae8df316a07dd1c3a76b94" + integrity sha512-AU7kwFxreVd6OAXcAFlKSmZquiRUU0FvYm44k1Y1QbK7Co4m0aqfGMhjykIeQp/H6rcl+nFmj0zfdUcGVs9Dew== + dependencies: + "@sinonjs/commons" "^1.7.0" + "@tootallnate/once@1": version "1.1.2" resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82" @@ -2779,13 +2796,13 @@ babel-jest@^27.0.6: graceful-fs "^4.2.4" slash "^3.0.0" -babel-jest@^27.2.1: - version "27.2.1" - resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-27.2.1.tgz#48edfa5cf8d59ab293da94321a369ccc7b67a4b1" - integrity sha512-kkaekSJHew1zfDW3cA2QiSBPg4uiLpiW0OwJKqFv0r2/mFgym/IBn7hxPntL6FvS66G/ROh+lz4pRiCJAH1/UQ== +babel-jest@^27.2.4: + version "27.2.4" + resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-27.2.4.tgz#21ed6729d51bdd75470bbbf3c8b08d86209fb0dc" + integrity sha512-f24OmxyWymk5jfgLdlCMu4fTs4ldxFBIdn5sJdhvGC1m08rSkJ5hYbWkNmfBSvE/DjhCVNSHXepxsI6THGfGsg== dependencies: - "@jest/transform" "^27.2.1" - "@jest/types" "^27.1.1" + "@jest/transform" "^27.2.4" + "@jest/types" "^27.2.4" "@types/babel__core" "^7.1.14" babel-plugin-istanbul "^6.0.0" babel-preset-jest "^27.2.0" @@ -4503,16 +4520,16 @@ expect@^27.0.6: jest-message-util "^27.0.6" jest-regex-util "^27.0.6" -expect@^27.2.1: - version "27.2.1" - resolved "https://registry.yarnpkg.com/expect/-/expect-27.2.1.tgz#5f882b308716618613f0106a488b46c303908157" - integrity sha512-ekOA2mBtT2phxcoPVHCXIzbJxCvRXhx2fr7m28IgGdZxUOh8UvxvoRz1FcPlfgZMpE92biHB6woIcAKXqR28hA== +expect@^27.2.4: + version "27.2.4" + resolved "https://registry.yarnpkg.com/expect/-/expect-27.2.4.tgz#4debf546050bcdad8914a8c95fec7662e02bf67c" + integrity sha512-gOtuonQ8TCnbNNCSw2fhVzRf8EFYDII4nB5NmG4IEV0rbUnW1I5zXvoTntU4iicB/Uh0oZr20NGlOLdJiwsOZA== dependencies: - "@jest/types" "^27.1.1" + "@jest/types" "^27.2.4" ansi-styles "^5.0.0" jest-get-type "^27.0.6" - jest-matcher-utils "^27.2.0" - jest-message-util "^27.2.0" + jest-matcher-utils "^27.2.4" + jest-message-util "^27.2.4" jest-regex-util "^27.0.6" extend-shallow@^2.0.1: @@ -5963,12 +5980,12 @@ jake@^10.6.1: filelist "^1.0.1" minimatch "^3.0.4" -jest-changed-files@^27.1.1: - version "27.1.1" - resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-27.1.1.tgz#9b3f67a34cc58e3e811e2e1e21529837653e4200" - integrity sha512-5TV9+fYlC2A6hu3qtoyGHprBwCAn0AuGA77bZdUgYvVlRMjHXo063VcWTEAyx6XAZ85DYHqp0+aHKbPlfRDRvA== +jest-changed-files@^27.2.4: + version "27.2.4" + resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-27.2.4.tgz#d7de46e90e5a599c47e260760f5ab53516e835e6" + integrity sha512-eeO1C1u4ex7pdTroYXezr+rbr957myyVoKGjcY4R1TJi3A+9v+4fu1Iv9J4eLq1bgFyT3O3iRWU9lZsEE7J72Q== dependencies: - "@jest/types" "^27.1.1" + "@jest/types" "^27.2.4" execa "^5.0.0" throat "^6.0.1" @@ -5997,48 +6014,48 @@ jest-circus@^27.0.6: stack-utils "^2.0.3" throat "^6.0.1" -jest-circus@^27.2.1: - version "27.2.1" - resolved "https://registry.yarnpkg.com/jest-circus/-/jest-circus-27.2.1.tgz#c5166052b328c0df932cdaf89f5982085e7b4812" - integrity sha512-9q/8X8DgJmW8IqXsJNnS2E28iarx990hf6D+frS3P0lB+avhFDD33alLwZzKgm45u0wvEi6iFh43WjNbp5fhjw== +jest-circus@^27.2.4: + version "27.2.4" + resolved "https://registry.yarnpkg.com/jest-circus/-/jest-circus-27.2.4.tgz#3bd898a29dcaf6a506f3f1b780dff5f67ca83c23" + integrity sha512-TtheheTElrGjlsY9VxkzUU1qwIx05ItIusMVKnvNkMt4o/PeegLRcjq3Db2Jz0GGdBalJdbzLZBgeulZAJxJWA== dependencies: - "@jest/environment" "^27.2.0" - "@jest/test-result" "^27.2.0" - "@jest/types" "^27.1.1" + "@jest/environment" "^27.2.4" + "@jest/test-result" "^27.2.4" + "@jest/types" "^27.2.4" "@types/node" "*" chalk "^4.0.0" co "^4.6.0" dedent "^0.7.0" - expect "^27.2.1" + expect "^27.2.4" is-generator-fn "^2.0.0" - jest-each "^27.2.0" - jest-matcher-utils "^27.2.0" - jest-message-util "^27.2.0" - jest-runtime "^27.2.1" - jest-snapshot "^27.2.1" - jest-util "^27.2.0" - pretty-format "^27.2.0" + jest-each "^27.2.4" + jest-matcher-utils "^27.2.4" + jest-message-util "^27.2.4" + jest-runtime "^27.2.4" + jest-snapshot "^27.2.4" + jest-util "^27.2.4" + pretty-format "^27.2.4" slash "^3.0.0" stack-utils "^2.0.3" throat "^6.0.1" -jest-cli@^27.2.1: - version "27.2.1" - resolved "https://registry.yarnpkg.com/jest-cli/-/jest-cli-27.2.1.tgz#031e887245945864cc6ed8605c939f1937858c09" - integrity sha512-IfxuGkBZS/ogY7yFvvD1dFidzQRXlSBHtUZQ3UTIHydzNMF4/ZRTdGFso6HkbCkemwLh4hnNybONexEqWmYwjw== +jest-cli@^27.2.4: + version "27.2.4" + resolved "https://registry.yarnpkg.com/jest-cli/-/jest-cli-27.2.4.tgz#acda7f367aa6e674723fc1a7334e0ae1799448d2" + integrity sha512-4kpQQkg74HYLaXo3nzwtg4PYxSLgL7puz1LXHj5Tu85KmlIpxQFjRkXlx4V47CYFFIDoyl3rHA/cXOxUWyMpNg== dependencies: - "@jest/core" "^27.2.1" - "@jest/test-result" "^27.2.0" - "@jest/types" "^27.1.1" + "@jest/core" "^27.2.4" + "@jest/test-result" "^27.2.4" + "@jest/types" "^27.2.4" chalk "^4.0.0" exit "^0.1.2" graceful-fs "^4.2.4" import-local "^3.0.2" - jest-config "^27.2.1" - jest-util "^27.2.0" - jest-validate "^27.2.0" + jest-config "^27.2.4" + jest-util "^27.2.4" + jest-validate "^27.2.4" prompts "^2.0.1" - yargs "^16.0.3" + yargs "^16.2.0" jest-config@27.0.6: version "27.0.6" @@ -6067,34 +6084,34 @@ jest-config@27.0.6: micromatch "^4.0.4" pretty-format "^27.0.6" -jest-config@^27.2.1: - version "27.2.1" - resolved "https://registry.yarnpkg.com/jest-config/-/jest-config-27.2.1.tgz#2e727e023fc4b77a9f067a40c5448a939aa8386b" - integrity sha512-BAOemP8udmFw9nkgaLAac7vXORdvrt4yrJWoh7uYb0nPZeSsu0kGwJU18SwtY4paq9fed5OgAssC3A+Bf4WMQA== +jest-config@^27.2.4: + version "27.2.4" + resolved "https://registry.yarnpkg.com/jest-config/-/jest-config-27.2.4.tgz#0204969f5ae2e5190d47be2c14c04d631b7836e2" + integrity sha512-tWy0UxhdzqiKyp4l5Vq4HxLyD+gH5td+GCF3c22/DJ0bYAOsMo+qi2XtbJI6oYMH5JOJQs9nLW/r34nvFCehjA== dependencies: "@babel/core" "^7.1.0" - "@jest/test-sequencer" "^27.2.1" - "@jest/types" "^27.1.1" - babel-jest "^27.2.1" + "@jest/test-sequencer" "^27.2.4" + "@jest/types" "^27.2.4" + babel-jest "^27.2.4" chalk "^4.0.0" deepmerge "^4.2.2" glob "^7.1.1" graceful-fs "^4.2.4" is-ci "^3.0.0" - jest-circus "^27.2.1" - jest-environment-jsdom "^27.2.0" - jest-environment-node "^27.2.0" + jest-circus "^27.2.4" + jest-environment-jsdom "^27.2.4" + jest-environment-node "^27.2.4" jest-get-type "^27.0.6" - jest-jasmine2 "^27.2.1" + jest-jasmine2 "^27.2.4" jest-regex-util "^27.0.6" - jest-resolve "^27.2.0" - jest-runner "^27.2.1" - jest-util "^27.2.0" - jest-validate "^27.2.0" + jest-resolve "^27.2.4" + jest-runner "^27.2.4" + jest-util "^27.2.4" + jest-validate "^27.2.4" micromatch "^4.0.4" - pretty-format "^27.2.0" + pretty-format "^27.2.4" -jest-diff@^27.0.0, jest-diff@^27.0.2, jest-diff@^27.0.6, jest-diff@^27.2.0: +jest-diff@^27.0.0, jest-diff@^27.0.2, jest-diff@^27.0.6, jest-diff@^27.2.4: version "27.0.6" resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-27.0.6.tgz#4a7a19ee6f04ad70e0e3388f35829394a44c7b5e" integrity sha512-Z1mqgkTCSYaFgwTlP/NUiRzdqgxmmhzHY1Tq17zL94morOHfHu3K4bgSgl+CR4GLhpV8VxkuOYuIWnQ9LnFqmg== @@ -6122,16 +6139,16 @@ jest-each@^27.0.6: jest-util "^27.0.6" pretty-format "^27.0.6" -jest-each@^27.2.0: - version "27.2.0" - resolved "https://registry.yarnpkg.com/jest-each/-/jest-each-27.2.0.tgz#4c531c7223de289429fc7b2473a86e653c86d61f" - integrity sha512-biDmmUQjg+HZOB7MfY2RHSFL3j418nMoC3TK3pGAj880fQQSxvQe1y2Wy23JJJNUlk6YXiGU0yWy86Le1HBPmA== +jest-each@^27.2.4: + version "27.2.4" + resolved "https://registry.yarnpkg.com/jest-each/-/jest-each-27.2.4.tgz#b4f280aafd63129ba82e345f0e74c5a10200aeef" + integrity sha512-w9XVc+0EDBUTJS4xBNJ7N2JCcWItFd006lFjz77OarAQcQ10eFDBMrfDv2GBJMKlXe9aq0HrIIF51AXcZrRJyg== dependencies: - "@jest/types" "^27.1.1" + "@jest/types" "^27.2.4" chalk "^4.0.0" jest-get-type "^27.0.6" - jest-util "^27.2.0" - pretty-format "^27.2.0" + jest-util "^27.2.4" + pretty-format "^27.2.4" jest-environment-jsdom@^27.0.6: version "27.0.6" @@ -6146,17 +6163,17 @@ jest-environment-jsdom@^27.0.6: jest-util "^27.0.6" jsdom "^16.6.0" -jest-environment-jsdom@^27.2.0: - version "27.2.0" - resolved "https://registry.yarnpkg.com/jest-environment-jsdom/-/jest-environment-jsdom-27.2.0.tgz#c654dfae50ca2272c2a2e2bb95ff0af298283a3c" - integrity sha512-wNQJi6Rd/AkUWqTc4gWhuTIFPo7tlMK0RPZXeM6AqRHZA3D3vwvTa9ktAktyVyWYmUoXdYstOfyYMG3w4jt7eA== +jest-environment-jsdom@^27.2.4: + version "27.2.4" + resolved "https://registry.yarnpkg.com/jest-environment-jsdom/-/jest-environment-jsdom-27.2.4.tgz#39ae80bbb8675306bfaf0440be1e5f877554539a" + integrity sha512-X70pTXFSypD7AIzKT1mLnDi5hP9w9mdTRcOGOmoDoBrNyNEg4rYm6d4LQWFLc9ps1VnMuDOkFSG0wjSNYGjkng== dependencies: - "@jest/environment" "^27.2.0" - "@jest/fake-timers" "^27.2.0" - "@jest/types" "^27.1.1" + "@jest/environment" "^27.2.4" + "@jest/fake-timers" "^27.2.4" + "@jest/types" "^27.2.4" "@types/node" "*" - jest-mock "^27.1.1" - jest-util "^27.2.0" + jest-mock "^27.2.4" + jest-util "^27.2.4" jsdom "^16.6.0" jest-environment-node@^27.0.6: @@ -6171,17 +6188,17 @@ jest-environment-node@^27.0.6: jest-mock "^27.0.6" jest-util "^27.0.6" -jest-environment-node@^27.2.0: - version "27.2.0" - resolved "https://registry.yarnpkg.com/jest-environment-node/-/jest-environment-node-27.2.0.tgz#73ef2151cb62206669becb94cd84f33276252de5" - integrity sha512-WbW+vdM4u88iy6Q3ftUEQOSgMPtSgjm3qixYYK2AKEuqmFO2zmACTw1vFUB0qI/QN88X6hA6ZkVKIdIWWzz+yg== +jest-environment-node@^27.2.4: + version "27.2.4" + resolved "https://registry.yarnpkg.com/jest-environment-node/-/jest-environment-node-27.2.4.tgz#b79f98cb36e0c9111aac859c9c99f04eb2f74ff6" + integrity sha512-ZbVbFSnbzTvhLOIkqh5lcLuGCCFvtG4xTXIRPK99rV2KzQT3kNg16KZwfTnLNlIiWCE8do960eToeDfcqmpSAw== dependencies: - "@jest/environment" "^27.2.0" - "@jest/fake-timers" "^27.2.0" - "@jest/types" "^27.1.1" + "@jest/environment" "^27.2.4" + "@jest/fake-timers" "^27.2.4" + "@jest/types" "^27.2.4" "@types/node" "*" - jest-mock "^27.1.1" - jest-util "^27.2.0" + jest-mock "^27.2.4" + jest-util "^27.2.4" jest-get-type@^27.0.1: version "27.0.1" @@ -6233,12 +6250,12 @@ jest-haste-map@^27.0.6: optionalDependencies: fsevents "^2.3.2" -jest-haste-map@^27.2.0: - version "27.2.0" - resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-27.2.0.tgz#703b3a473e3f2e27d75ab07864ffd7bbaad0d75e" - integrity sha512-laFet7QkNlWjwZtMGHCucLvF8o9PAh2cgePRck1+uadSM4E4XH9J4gnx4do+a6do8ZV5XHNEAXEkIoNg5XUH2Q== +jest-haste-map@^27.2.4: + version "27.2.4" + resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-27.2.4.tgz#f8974807bedf07348ca9fd24e5861ab7c8e61aba" + integrity sha512-bkJ4bT00T2K+1NZXbRcyKnbJ42I6QBvoDNMTAQQDBhaGNnZreiQKUNqax0e6hLTx7E75pKDeltVu3V1HAdu+YA== dependencies: - "@jest/types" "^27.1.1" + "@jest/types" "^27.2.4" "@types/graceful-fs" "^4.1.2" "@types/node" "*" anymatch "^3.0.3" @@ -6246,8 +6263,8 @@ jest-haste-map@^27.2.0: graceful-fs "^4.2.4" jest-regex-util "^27.0.6" jest-serializer "^27.0.6" - jest-util "^27.2.0" - jest-worker "^27.2.0" + jest-util "^27.2.4" + jest-worker "^27.2.4" micromatch "^4.0.4" walker "^1.0.7" optionalDependencies: @@ -6277,28 +6294,28 @@ jest-jasmine2@^27.0.6: pretty-format "^27.0.6" throat "^6.0.1" -jest-jasmine2@^27.2.1: - version "27.2.1" - resolved "https://registry.yarnpkg.com/jest-jasmine2/-/jest-jasmine2-27.2.1.tgz#30ee71f38670a621ecf3b6dcb89875933f780de6" - integrity sha512-3vytj3+S49+XYsxGJyjlchDo4xblYzjDY4XK7pV2IAdspbMFOpmeNMOeDonYuvlbUtcV8yrFLA6XtliXapDmMA== +jest-jasmine2@^27.2.4: + version "27.2.4" + resolved "https://registry.yarnpkg.com/jest-jasmine2/-/jest-jasmine2-27.2.4.tgz#4a1608133dbdb4d68b5929bfd785503ed9c9ba51" + integrity sha512-fcffjO/xLWLVnW2ct3No4EksxM5RyPwHDYu9QU+90cC+/eSMLkFAxS55vkqsxexOO5zSsZ3foVpMQcg/amSeIQ== dependencies: "@babel/traverse" "^7.1.0" - "@jest/environment" "^27.2.0" + "@jest/environment" "^27.2.4" "@jest/source-map" "^27.0.6" - "@jest/test-result" "^27.2.0" - "@jest/types" "^27.1.1" + "@jest/test-result" "^27.2.4" + "@jest/types" "^27.2.4" "@types/node" "*" chalk "^4.0.0" co "^4.6.0" - expect "^27.2.1" + expect "^27.2.4" is-generator-fn "^2.0.0" - jest-each "^27.2.0" - jest-matcher-utils "^27.2.0" - jest-message-util "^27.2.0" - jest-runtime "^27.2.1" - jest-snapshot "^27.2.1" - jest-util "^27.2.0" - pretty-format "^27.2.0" + jest-each "^27.2.4" + jest-matcher-utils "^27.2.4" + jest-message-util "^27.2.4" + jest-runtime "^27.2.4" + jest-snapshot "^27.2.4" + jest-util "^27.2.4" + pretty-format "^27.2.4" throat "^6.0.1" jest-leak-detector@^27.0.6: @@ -6309,13 +6326,13 @@ jest-leak-detector@^27.0.6: jest-get-type "^27.0.6" pretty-format "^27.0.6" -jest-leak-detector@^27.2.0: - version "27.2.0" - resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-27.2.0.tgz#9a7ca2dad1a21c4e49ad2a8ad7f1214ffdb86a28" - integrity sha512-e91BIEmbZw5+MHkB4Hnrq7S86coTxUMCkz4n7DLmQYvl9pEKmRx9H/JFH87bBqbIU5B2Ju1soKxRWX6/eGFGpA== +jest-leak-detector@^27.2.4: + version "27.2.4" + resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-27.2.4.tgz#9bb7eab26a73bb280e9298be8d80f389288ec8f1" + integrity sha512-SrcHWbe0EHg/bw2uBjVoHacTo5xosl068x2Q0aWsjr2yYuW2XwqrSkZV4lurUop0jhv1709ymG4or+8E4sH27Q== dependencies: jest-get-type "^27.0.6" - pretty-format "^27.2.0" + pretty-format "^27.2.4" jest-matcher-utils@^27.0.2: version "27.0.2" @@ -6337,15 +6354,15 @@ jest-matcher-utils@^27.0.6: jest-get-type "^27.0.6" pretty-format "^27.0.6" -jest-matcher-utils@^27.2.0: - version "27.2.0" - resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-27.2.0.tgz#b4d224ab88655d5fab64b96b989ac349e2f5da43" - integrity sha512-F+LG3iTwJ0gPjxBX6HCyrARFXq6jjiqhwBQeskkJQgSLeF1j6ui1RTV08SR7O51XTUhtc8zqpDj8iCG4RGmdKw== +jest-matcher-utils@^27.2.4: + version "27.2.4" + resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-27.2.4.tgz#008fff018151415ad1b6cfc083fd70fe1e012525" + integrity sha512-nQeLfFAIPPkyhkDfifAPfP/U5wm1x0fLtAzqXZSSKckXDNuk2aaOfQiDYv1Mgf5GY6yOsxfUnvNm3dDjXM+BXw== dependencies: chalk "^4.0.0" - jest-diff "^27.2.0" + jest-diff "^27.2.4" jest-get-type "^27.0.6" - pretty-format "^27.2.0" + pretty-format "^27.2.4" jest-message-util@^27.0.2: version "27.0.2" @@ -6377,18 +6394,18 @@ jest-message-util@^27.0.6: slash "^3.0.0" stack-utils "^2.0.3" -jest-message-util@^27.2.0: - version "27.2.0" - resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-27.2.0.tgz#2f65c71df55267208686b1d7514e18106c91ceaf" - integrity sha512-y+sfT/94CiP8rKXgwCOzO1mUazIEdEhrLjuiu+RKmCP+8O/TJTSne9dqQRbFIHBtlR2+q7cddJlWGir8UATu5w== +jest-message-util@^27.2.4: + version "27.2.4" + resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-27.2.4.tgz#667e8c0f2b973156d1bac7398a7f677705cafaca" + integrity sha512-wbKT/BNGnBVB9nzi+IoaLkXt6fbSvqUxx+IYY66YFh96J3goY33BAaNG3uPqaw/Sh/FR9YpXGVDfd5DJdbh4nA== dependencies: "@babel/code-frame" "^7.12.13" - "@jest/types" "^27.1.1" + "@jest/types" "^27.2.4" "@types/stack-utils" "^2.0.0" chalk "^4.0.0" graceful-fs "^4.2.4" micromatch "^4.0.4" - pretty-format "^27.2.0" + pretty-format "^27.2.4" slash "^3.0.0" stack-utils "^2.0.3" @@ -6400,12 +6417,12 @@ jest-mock@^27.0.6: "@jest/types" "^27.0.6" "@types/node" "*" -jest-mock@^27.1.1: - version "27.1.1" - resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-27.1.1.tgz#c7a2e81301fdcf3dab114931d23d89ec9d0c3a82" - integrity sha512-SClsFKuYBf+6SSi8jtAYOuPw8DDMsTElUWEae3zq7vDhH01ayVSIHUSIa8UgbDOUalCFp6gNsaikN0rbxN4dbw== +jest-mock@^27.2.4: + version "27.2.4" + resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-27.2.4.tgz#c8f0ef33f73d8ff53e3f60b16d59f1128f4072ae" + integrity sha512-iVRU905rutaAoUcrt5Tm1JoHHWi24YabqEGXjPJI4tAyA6wZ7mzDi3GrZ+M7ebgWBqUkZE93GAx1STk7yCMIQA== dependencies: - "@jest/types" "^27.1.1" + "@jest/types" "^27.2.4" "@types/node" "*" jest-pnp-resolver@^1.2.2: @@ -6423,14 +6440,14 @@ jest-regex-util@^27.0.6: resolved "https://registry.yarnpkg.com/jest-regex-util/-/jest-regex-util-27.0.6.tgz#02e112082935ae949ce5d13b2675db3d8c87d9c5" integrity sha512-SUhPzBsGa1IKm8hx2F4NfTGGp+r7BXJ4CulsZ1k2kI+mGLG+lxGrs76veN2LF/aUdGosJBzKgXmNCw+BzFqBDQ== -jest-resolve-dependencies@^27.2.1: - version "27.2.1" - resolved "https://registry.yarnpkg.com/jest-resolve-dependencies/-/jest-resolve-dependencies-27.2.1.tgz#239be969ece749d4dc2e1efcf3d2b86c99525c2e" - integrity sha512-9bKEwmz4YshGPjGZAVZOVw6jt7pq2/FjWJmyhnWhvDuiRCHVZBcJhycinX+e/EJ7jafsq26bTpzBIQas3xql1g== +jest-resolve-dependencies@^27.2.4: + version "27.2.4" + resolved "https://registry.yarnpkg.com/jest-resolve-dependencies/-/jest-resolve-dependencies-27.2.4.tgz#20c41cc02b66aa45169b282356ec73b133013089" + integrity sha512-i5s7Uh9B3Q6uwxLpMhNKlgBf6pcemvWaORxsW1zNF/YCY3jd5EftvnGBI+fxVwJ1CBxkVfxqCvm1lpZkbaoGmg== dependencies: - "@jest/types" "^27.1.1" + "@jest/types" "^27.2.4" jest-regex-util "^27.0.6" - jest-snapshot "^27.2.1" + jest-snapshot "^27.2.4" jest-resolve@27.0.6, jest-resolve@^27.0.6: version "27.0.6" @@ -6462,19 +6479,19 @@ jest-resolve@^27.0.2: resolve "^1.20.0" slash "^3.0.0" -jest-resolve@^27.2.0: - version "27.2.0" - resolved "https://registry.yarnpkg.com/jest-resolve/-/jest-resolve-27.2.0.tgz#f5d053693ab3806ec2f778e6df8b0aa4cfaef95f" - integrity sha512-v09p9Ib/VtpHM6Cz+i9lEAv1Z/M5NVxsyghRHRMEUOqwPQs3zwTdwp1xS3O/k5LocjKiGS0OTaJoBSpjbM2Jlw== +jest-resolve@^27.2.4: + version "27.2.4" + resolved "https://registry.yarnpkg.com/jest-resolve/-/jest-resolve-27.2.4.tgz#d3b999f073ff84a8ae109ce99ff7f3223048701a" + integrity sha512-IsAO/3+3BZnKjI2I4f3835TBK/90dxR7Otgufn3mnrDFTByOSXclDi3G2XJsawGV4/18IMLARJ+V7Wm7t+J89Q== dependencies: - "@jest/types" "^27.1.1" + "@jest/types" "^27.2.4" chalk "^4.0.0" escalade "^3.1.1" graceful-fs "^4.2.4" - jest-haste-map "^27.2.0" + jest-haste-map "^27.2.4" jest-pnp-resolver "^1.2.2" - jest-util "^27.2.0" - jest-validate "^27.2.0" + jest-util "^27.2.4" + jest-validate "^27.2.4" resolve "^1.20.0" slash "^3.0.0" @@ -6506,31 +6523,31 @@ jest-runner@^27.0.6: source-map-support "^0.5.6" throat "^6.0.1" -jest-runner@^27.2.1: - version "27.2.1" - resolved "https://registry.yarnpkg.com/jest-runner/-/jest-runner-27.2.1.tgz#3443b1fc08b8a50f305dfc2d41dd2badf335843b" - integrity sha512-USHitkUUzcB3Y5mRdzlp+KHgRRR2VsXDq5OeATuDmq1qXfT/RwwnQykUhn+KVx3FotxK3pID74UY7o6HYIR8vA== +jest-runner@^27.2.4: + version "27.2.4" + resolved "https://registry.yarnpkg.com/jest-runner/-/jest-runner-27.2.4.tgz#d816f4cb4af04f3cba703afcf5a35a335b77cad4" + integrity sha512-hIo5PPuNUyVDidZS8EetntuuJbQ+4IHWxmHgYZz9FIDbG2wcZjrP6b52uMDjAEQiHAn8yn8ynNe+TL8UuGFYKg== dependencies: - "@jest/console" "^27.2.0" - "@jest/environment" "^27.2.0" - "@jest/test-result" "^27.2.0" - "@jest/transform" "^27.2.1" - "@jest/types" "^27.1.1" + "@jest/console" "^27.2.4" + "@jest/environment" "^27.2.4" + "@jest/test-result" "^27.2.4" + "@jest/transform" "^27.2.4" + "@jest/types" "^27.2.4" "@types/node" "*" chalk "^4.0.0" emittery "^0.8.1" exit "^0.1.2" graceful-fs "^4.2.4" jest-docblock "^27.0.6" - jest-environment-jsdom "^27.2.0" - jest-environment-node "^27.2.0" - jest-haste-map "^27.2.0" - jest-leak-detector "^27.2.0" - jest-message-util "^27.2.0" - jest-resolve "^27.2.0" - jest-runtime "^27.2.1" - jest-util "^27.2.0" - jest-worker "^27.2.0" + jest-environment-jsdom "^27.2.4" + jest-environment-node "^27.2.4" + jest-haste-map "^27.2.4" + jest-leak-detector "^27.2.4" + jest-message-util "^27.2.4" + jest-resolve "^27.2.4" + jest-runtime "^27.2.4" + jest-util "^27.2.4" + jest-worker "^27.2.4" source-map-support "^0.5.6" throat "^6.0.1" @@ -6566,19 +6583,19 @@ jest-runtime@^27.0.6: strip-bom "^4.0.0" yargs "^16.0.3" -jest-runtime@^27.2.1: - version "27.2.1" - resolved "https://registry.yarnpkg.com/jest-runtime/-/jest-runtime-27.2.1.tgz#db506f679356f5b94b7be20e770f2541b7c2b339" - integrity sha512-QJNnwL4iteDE/Jq4TfQK7AjhPoUZflBKTtUIkRnFYFkTAZTP/o8k7ekaROiVjmo+NYop5+DQPqX6pz4vWbZSOQ== +jest-runtime@^27.2.4: + version "27.2.4" + resolved "https://registry.yarnpkg.com/jest-runtime/-/jest-runtime-27.2.4.tgz#170044041e5d30625ab8d753516bbe503f213a5c" + integrity sha512-ICKzzYdjIi70P17MZsLLIgIQFCQmIjMFf+xYww3aUySiUA/QBPUTdUqo5B2eg4HOn9/KkUsV0z6GVgaqAPBJvg== dependencies: - "@jest/console" "^27.2.0" - "@jest/environment" "^27.2.0" - "@jest/fake-timers" "^27.2.0" - "@jest/globals" "^27.2.1" + "@jest/console" "^27.2.4" + "@jest/environment" "^27.2.4" + "@jest/fake-timers" "^27.2.4" + "@jest/globals" "^27.2.4" "@jest/source-map" "^27.0.6" - "@jest/test-result" "^27.2.0" - "@jest/transform" "^27.2.1" - "@jest/types" "^27.1.1" + "@jest/test-result" "^27.2.4" + "@jest/transform" "^27.2.4" + "@jest/types" "^27.2.4" "@types/yargs" "^16.0.0" chalk "^4.0.0" cjs-module-lexer "^1.0.0" @@ -6587,17 +6604,17 @@ jest-runtime@^27.2.1: exit "^0.1.2" glob "^7.1.3" graceful-fs "^4.2.4" - jest-haste-map "^27.2.0" - jest-message-util "^27.2.0" - jest-mock "^27.1.1" + jest-haste-map "^27.2.4" + jest-message-util "^27.2.4" + jest-mock "^27.2.4" jest-regex-util "^27.0.6" - jest-resolve "^27.2.0" - jest-snapshot "^27.2.1" - jest-util "^27.2.0" - jest-validate "^27.2.0" + jest-resolve "^27.2.4" + jest-snapshot "^27.2.4" + jest-util "^27.2.4" + jest-validate "^27.2.4" slash "^3.0.0" strip-bom "^4.0.0" - yargs "^16.0.3" + yargs "^16.2.0" jest-serializer@^27.0.1: version "27.0.1" @@ -6675,10 +6692,10 @@ jest-snapshot@^27.0.6: pretty-format "^27.0.6" semver "^7.3.2" -jest-snapshot@^27.2.1: - version "27.2.1" - resolved "https://registry.yarnpkg.com/jest-snapshot/-/jest-snapshot-27.2.1.tgz#385accf3bb71ac84e9a6bda4fc9bb458d53abb35" - integrity sha512-8CTg2YrgZuQbPHW7G0YvLTj4yTRXLmSeEO+ka3eC5lbu5dsTRyoDNS1L7x7EFUTyYQhFH9HQG1/TNlbUgR9Lug== +jest-snapshot@^27.2.4: + version "27.2.4" + resolved "https://registry.yarnpkg.com/jest-snapshot/-/jest-snapshot-27.2.4.tgz#277b2269437e3ffcb91d95a73b24becf33c5a871" + integrity sha512-5DFxK31rYS8X8C6WXsFx8XxrxW3PGa6+9IrUcZdTLg1aEyXDGIeiBh4jbwvh655bg/9vTETbEj/njfZicHTZZw== dependencies: "@babel/core" "^7.7.2" "@babel/generator" "^7.7.2" @@ -6686,23 +6703,23 @@ jest-snapshot@^27.2.1: "@babel/plugin-syntax-typescript" "^7.7.2" "@babel/traverse" "^7.7.2" "@babel/types" "^7.0.0" - "@jest/transform" "^27.2.1" - "@jest/types" "^27.1.1" + "@jest/transform" "^27.2.4" + "@jest/types" "^27.2.4" "@types/babel__traverse" "^7.0.4" "@types/prettier" "^2.1.5" babel-preset-current-node-syntax "^1.0.0" chalk "^4.0.0" - expect "^27.2.1" + expect "^27.2.4" graceful-fs "^4.2.4" - jest-diff "^27.2.0" + jest-diff "^27.2.4" jest-get-type "^27.0.6" - jest-haste-map "^27.2.0" - jest-matcher-utils "^27.2.0" - jest-message-util "^27.2.0" - jest-resolve "^27.2.0" - jest-util "^27.2.0" + jest-haste-map "^27.2.4" + jest-matcher-utils "^27.2.4" + jest-message-util "^27.2.4" + jest-resolve "^27.2.4" + jest-util "^27.2.4" natural-compare "^1.4.0" - pretty-format "^27.2.0" + pretty-format "^27.2.4" semver "^7.3.2" jest-specific-snapshot@*, jest-specific-snapshot@^5.0.0: @@ -6724,12 +6741,12 @@ jest-util@27.0.6, jest-util@^27.0.0, jest-util@^27.0.2, jest-util@^27.0.6: is-ci "^3.0.0" picomatch "^2.2.3" -jest-util@^27.2.0: - version "27.2.0" - resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-27.2.0.tgz#bfccb85cfafae752257319e825a5b8d4ada470dc" - integrity sha512-T5ZJCNeFpqcLBpx+Hl9r9KoxBCUqeWlJ1Htli+vryigZVJ1vuLB9j35grEBASp4R13KFkV7jM52bBGnArpJN6A== +jest-util@^27.2.4: + version "27.2.4" + resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-27.2.4.tgz#3d7ce081b2e7f4cfe0156452ac01f3cb456cc656" + integrity sha512-mW++4u+fSvAt3YBWm5IpbmRAceUqa2B++JlUZTiuEt2AmNYn0Yw5oay4cP17TGsMINRNPSGiJ2zNnX60g+VbFg== dependencies: - "@jest/types" "^27.1.1" + "@jest/types" "^27.2.4" "@types/node" "*" chalk "^4.0.0" graceful-fs "^4.2.4" @@ -6760,29 +6777,29 @@ jest-validate@^27.0.6: leven "^3.1.0" pretty-format "^27.0.6" -jest-validate@^27.2.0: - version "27.2.0" - resolved "https://registry.yarnpkg.com/jest-validate/-/jest-validate-27.2.0.tgz#b7535f12d95dd3b4382831f4047384ca098642ab" - integrity sha512-uIEZGkFKk3+4liA81Xu0maG5aGDyPLdp+4ed244c+Ql0k3aLWQYcMbaMLXOIFcb83LPHzYzqQ8hwNnIxTqfAGQ== +jest-validate@^27.2.4: + version "27.2.4" + resolved "https://registry.yarnpkg.com/jest-validate/-/jest-validate-27.2.4.tgz#b66d462b2fb93d7e16a47d1aa8763d5600bf2cfa" + integrity sha512-VMtbxbkd7LHnIH7PChdDtrluCFRJ4b1YV2YJzNwwsASMWftq/HgqiqjvptBOWyWOtevgO3f14wPxkPcLlVBRog== dependencies: - "@jest/types" "^27.1.1" + "@jest/types" "^27.2.4" camelcase "^6.2.0" chalk "^4.0.0" jest-get-type "^27.0.6" leven "^3.1.0" - pretty-format "^27.2.0" + pretty-format "^27.2.4" -jest-watcher@^27.2.0: - version "27.2.0" - resolved "https://registry.yarnpkg.com/jest-watcher/-/jest-watcher-27.2.0.tgz#dc2eef4c13c6d41cebf3f1fc5f900a54b51c2ea0" - integrity sha512-SjRWhnr+qO8aBsrcnYIyF+qRxNZk6MZH8TIDgvi+VlsyrvOyqg0d+Rm/v9KHiTtC9mGGeFi9BFqgavyWib6xLg== +jest-watcher@^27.2.4: + version "27.2.4" + resolved "https://registry.yarnpkg.com/jest-watcher/-/jest-watcher-27.2.4.tgz#b1d5c39ab94f59f4f35f66cc96f7761a10e0cfc4" + integrity sha512-LXC/0+dKxhK7cfF7reflRYlzDIaQE+fL4ynhKhzg8IMILNMuI4xcjXXfUJady7OR4/TZeMg7X8eHx8uan9vqaQ== dependencies: - "@jest/test-result" "^27.2.0" - "@jest/types" "^27.1.1" + "@jest/test-result" "^27.2.4" + "@jest/types" "^27.2.4" "@types/node" "*" ansi-escapes "^4.2.1" chalk "^4.0.0" - jest-util "^27.2.0" + jest-util "^27.2.4" string-length "^4.0.1" jest-worker@^27.0.2: @@ -6803,23 +6820,23 @@ jest-worker@^27.0.6: merge-stream "^2.0.0" supports-color "^8.0.0" -jest-worker@^27.2.0: - version "27.2.0" - resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-27.2.0.tgz#11eef39f1c88f41384ca235c2f48fe50bc229bc0" - integrity sha512-laB0ZVIBz+voh/QQy9dmUuuDsadixeerrKqyVpgPz+CCWiOYjOBabUXHIXZhsdvkWbLqSHbgkAHWl5cg24Q6RA== +jest-worker@^27.2.4: + version "27.2.4" + resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-27.2.4.tgz#881455df75e22e7726a53f43703ab74d6b36f82d" + integrity sha512-Zq9A2Pw59KkVjBBKD1i3iE2e22oSjXhUKKuAK1HGX8flGwkm6NMozyEYzKd41hXc64dbd/0eWFeEEuxqXyhM+g== dependencies: "@types/node" "*" merge-stream "^2.0.0" supports-color "^8.0.0" jest@^27.0.3: - version "27.2.1" - resolved "https://registry.yarnpkg.com/jest/-/jest-27.2.1.tgz#9263102056fe152fd2478d181cf9bbbd2a6a8da4" - integrity sha512-0MyvNS7J1HbkeotYaqKNGioN+p1/AAPtI1Z8iwMtCBE+PwBT+M4l25D9Pve8/KdhktYLgZaGyyj9CoDytD+R2Q== + version "27.2.4" + resolved "https://registry.yarnpkg.com/jest/-/jest-27.2.4.tgz#70e27bef873138afc123aa4769f7124c50ad3efb" + integrity sha512-h4uqb1EQLfPulWyUFFWv9e9Nn8sCqsJ/j3wk/KCY0p4s4s0ICCfP3iMf6hRf5hEhsDyvyrCgKiZXma63gMz16A== dependencies: - "@jest/core" "^27.2.1" + "@jest/core" "^27.2.4" import-local "^3.0.2" - jest-cli "^27.2.1" + jest-cli "^27.2.4" jju@~1.4.0: version "1.4.0" @@ -8095,11 +8112,6 @@ osenv@^0.1.4, osenv@^0.1.5: os-homedir "^1.0.0" os-tmpdir "^1.0.0" -p-each-series@^2.1.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/p-each-series/-/p-each-series-2.2.0.tgz#105ab0357ce72b202a8a8b94933672657b5e2a9a" - integrity sha512-ycIL2+1V32th+8scbpTvyHNaHe02z0sjgh91XXjAk+ZeXoPN4Z46DVUnzdso0aX4KckKw0FNNFHdjZ2UsZvxiA== - p-finally@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" @@ -8475,7 +8487,7 @@ prettier@2.3.2: resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.3.2.tgz#ef280a05ec253712e486233db5c6f23441e7342d" integrity sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ== -pretty-format@*, pretty-format@^27.0.0, pretty-format@^27.0.2, pretty-format@^27.0.6, pretty-format@^27.2.0: +pretty-format@*, pretty-format@^27.0.0, pretty-format@^27.0.2, pretty-format@^27.0.6, pretty-format@^27.2.4: version "27.2.2" resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-27.2.2.tgz#c080f1ab7ac64302e4d438f208596fc649dbeeb3" integrity sha512-+DdLh+rtaElc2SQOE/YPH8k2g3Rf2OXWEpy06p8Szs3hdVSYD87QOOlYRHWAeb/59XTmeVmRKvDD0svHqf6ycA== @@ -10130,6 +10142,15 @@ v8-to-istanbul@^8.0.0: convert-source-map "^1.6.0" source-map "^0.7.3" +v8-to-istanbul@^8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/v8-to-istanbul/-/v8-to-istanbul-8.1.0.tgz#0aeb763894f1a0a1676adf8a8b7612a38902446c" + integrity sha512-/PRhfd8aTNp9Ggr62HPzXg2XasNFGy5PBt0Rp04du7/8GNNSgxFL6WBTkgMKSL9bFjH+8kKEG3f37FmxiTqUUA== + dependencies: + "@types/istanbul-lib-coverage" "^2.0.1" + convert-source-map "^1.6.0" + source-map "^0.7.3" + validate-npm-package-license@^3.0.1, validate-npm-package-license@^3.0.3: version "3.0.4" resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a" @@ -10489,7 +10510,7 @@ yargs@^14.2.2: y18n "^4.0.0" yargs-parser "^15.0.1" -yargs@^16.0.3: +yargs@^16.0.3, yargs@^16.2.0: version "16.2.0" resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== From 6dc71ca0c7f8b5828570bd5d394e9a871060c619 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Oct 2021 10:57:57 -0700 Subject: [PATCH 02/44] chore: bump @commitlint/config-lerna-scopes from 13.1.0 to 13.2.0 (#3953) Bumps [@commitlint/config-lerna-scopes](https://github.com/conventional-changelog/commitlint) from 13.1.0 to 13.2.0. - [Release notes](https://github.com/conventional-changelog/commitlint/releases) - [Changelog](https://github.com/conventional-changelog/commitlint/blob/master/CHANGELOG.md) - [Commits](https://github.com/conventional-changelog/commitlint/compare/v13.1.0...v13.2.0) --- updated-dependencies: - dependency-name: "@commitlint/config-lerna-scopes" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 7a60b2bd464e..89d74239d82a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -336,9 +336,9 @@ conventional-changelog-conventionalcommits "^4.3.1" "@commitlint/config-lerna-scopes@^13.1.0": - version "13.1.0" - resolved "https://registry.yarnpkg.com/@commitlint/config-lerna-scopes/-/config-lerna-scopes-13.1.0.tgz#c30006ff60a2a625184b9c37bc2ba8ce44ff0d60" - integrity sha512-/OTFM75GYHFRm5m1TKOpHsLvAUuGL6GYnA5xJDT4fe2vPIGqgBYVL9hEolKYTJfDtviBq4fEkEWZQjQF5e4KgA== + version "13.2.0" + resolved "https://registry.yarnpkg.com/@commitlint/config-lerna-scopes/-/config-lerna-scopes-13.2.0.tgz#5382831c6562bb94ad889799fa24cf540a79a652" + integrity sha512-d2VqA1EX+G+XvEWIr3B37bydtMm+UHvmAWU6z0v5oOgUvBwZcNMzvTrwdZB6524YCmspi2q+kwgimMR+sBilXQ== dependencies: globby "^11.0.1" import-from "4.0.0" From 0d229e34c61ea04294443fb077f2601823c65921 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Oct 2021 10:58:02 -0700 Subject: [PATCH 03/44] chore: bump cspell from 5.10.1 to 5.11.1 (#3954) Bumps [cspell](https://github.com/streetsidesoftware/cspell) from 5.10.1 to 5.11.1. - [Release notes](https://github.com/streetsidesoftware/cspell/releases) - [Changelog](https://github.com/streetsidesoftware/cspell/blob/main/CHANGELOG.md) - [Commits](https://github.com/streetsidesoftware/cspell/compare/v5.10.1...v5.11.1) --- updated-dependencies: - dependency-name: cspell dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 129 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 72 insertions(+), 57 deletions(-) diff --git a/yarn.lock b/yarn.lock index 89d74239d82a..309bd1614c22 100644 --- a/yarn.lock +++ b/yarn.lock @@ -461,10 +461,10 @@ dependencies: chalk "^4.0.0" -"@cspell/cspell-bundled-dicts@^5.10.1": - version "5.10.1" - resolved "https://registry.yarnpkg.com/@cspell/cspell-bundled-dicts/-/cspell-bundled-dicts-5.10.1.tgz#31108cf2ef630d28601113191bc00a5278650900" - integrity sha512-4NXeyTMXsl0bV6tIG7N6LAeATkBIGCjQEuh9fNjGduOYCXn3HgTSNgOSdgdlLnnLt2zwvoFtwHDU1vXCDN8IrQ== +"@cspell/cspell-bundled-dicts@^5.11.1": + version "5.11.1" + resolved "https://registry.yarnpkg.com/@cspell/cspell-bundled-dicts/-/cspell-bundled-dicts-5.11.1.tgz#3cc1c81b446eb5efc25e60921edb30a23a4dd672" + integrity sha512-i/xbEfAP162BeZRftS+1l/BnOgoyBLauzGLp7c9MgBrB6hJf0fWjYndyLsKKXmHNRjPzqA8C6BHJRQh4ZSXi4g== dependencies: "@cspell/dict-ada" "^1.1.2" "@cspell/dict-aws" "^1.0.14" @@ -495,17 +495,17 @@ "@cspell/dict-php" "^1.0.24" "@cspell/dict-powershell" "^1.0.18" "@cspell/dict-public-licenses" "^1.0.3" - "@cspell/dict-python" "^1.0.37" + "@cspell/dict-python" "^2.0.3" "@cspell/dict-ruby" "^1.0.14" "@cspell/dict-rust" "^1.0.23" "@cspell/dict-scala" "^1.0.21" - "@cspell/dict-software-terms" "^1.0.42" + "@cspell/dict-software-terms" "^1.0.45" "@cspell/dict-typescript" "^1.0.19" -"@cspell/cspell-types@^5.10.0": - version "5.10.0" - resolved "https://registry.yarnpkg.com/@cspell/cspell-types/-/cspell-types-5.10.0.tgz#edf94262b763be67ca5e0b870930604bcc1de413" - integrity sha512-jssGvbGGfAKwrCetyBuFHrSC/8OIYF4fNXLkUQDiftHj/V5YOpAuRE57EzH2nGLkQ1pGGD5fjvLuYYDU1ZcioQ== +"@cspell/cspell-types@^5.11.1": + version "5.11.1" + resolved "https://registry.yarnpkg.com/@cspell/cspell-types/-/cspell-types-5.11.1.tgz#61e744782acb8f1fd21a44f0aa59de0572c6ccab" + integrity sha512-QSPqbrzbGOWDCibFirDQwheNyf0RIO4+GgYN5CQWis0y4ZY9GIBkQkxaqbgLQEu/lTRNyVhg+m/Y9yNv73t59A== "@cspell/dict-ada@^1.1.2": version "1.1.2" @@ -652,10 +652,10 @@ resolved "https://registry.yarnpkg.com/@cspell/dict-public-licenses/-/dict-public-licenses-1.0.3.tgz#d02ee79f7b7aecd696695e5aba135e6553e154ec" integrity sha512-sXjxOHJ9Q4rZvE1UbwpwJQ8EXO3fadKBjJIWmz0z+dZAbvTrmz5Ln1Ef9ruJvLPfwAps8m3TCV6Diz60RAQqHg== -"@cspell/dict-python@^1.0.37": - version "1.0.37" - resolved "https://registry.yarnpkg.com/@cspell/dict-python/-/dict-python-1.0.37.tgz#59d3f7dbcb759463529817156c5ac09649b54f0b" - integrity sha512-RPeYJxC7t6k9uL4aQp5kLarOddEAqfRw9VBTt+cOVSlMqEtEtxJGm8w91V28fwnRX4hQR0yhiHPEYcdLpMtpfQ== +"@cspell/dict-python@^2.0.3": + version "2.0.3" + resolved "https://registry.yarnpkg.com/@cspell/dict-python/-/dict-python-2.0.3.tgz#c0d98903c1242a621d89162e82583597541c08cc" + integrity sha512-b15Dk/nDzeB5mbTSXx4RGKgmM9AW5BpaHyZoUZNUOdPfQbcd02hVblro/MXMw45SvQ3Wr/VFJx32skwuRkvFPg== "@cspell/dict-ruby@^1.0.14": version "1.0.14" @@ -672,10 +672,10 @@ resolved "https://registry.yarnpkg.com/@cspell/dict-scala/-/dict-scala-1.0.21.tgz#bfda392329061e2352fbcd33d228617742c93831" integrity sha512-5V/R7PRbbminTpPS3ywgdAalI9BHzcEjEj9ug4kWYvBIGwSnS7T6QCFCiu+e9LvEGUqQC+NHgLY4zs1NaBj2vA== -"@cspell/dict-software-terms@^1.0.42": - version "1.0.42" - resolved "https://registry.yarnpkg.com/@cspell/dict-software-terms/-/dict-software-terms-1.0.42.tgz#748b7d4b33182b2fbf51924f3242e3b9c03affb4" - integrity sha512-VRIq7b6NnWVHeO0pzpHT10btQNYcRCyiSZc162xGlyO8+IMXq9Noemyqv+POS9oRknhtlF0rL1Hrg4ypHP3B+w== +"@cspell/dict-software-terms@^1.0.45": + version "1.0.46" + resolved "https://registry.yarnpkg.com/@cspell/dict-software-terms/-/dict-software-terms-1.0.46.tgz#edbb4d0585252e1f3deb14ffdacc9d12917118c5" + integrity sha512-W4Lf0AmWo7V/tS0kXKsTUW/edfYOQ7QTVisuuQM7bnttrykhlNuNrmcSSYNg5xn46H6MlaZvk3+oz4tHH30nbg== "@cspell/dict-typescript@^1.0.19": version "1.0.19" @@ -2545,7 +2545,7 @@ ansi-regex@^4.1.0: resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg== -ansi-regex@^5.0.0, ansi-regex@^5.0.1: +ansi-regex@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== @@ -3695,32 +3695,32 @@ crypto-random-string@^2.0.0: resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-2.0.0.tgz#ef2a7a966ec11083388369baa02ebead229b30d5" integrity sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA== -cspell-glob@^5.10.0: - version "5.10.0" - resolved "https://registry.yarnpkg.com/cspell-glob/-/cspell-glob-5.10.0.tgz#04c1ed153fedc2b9bfaafbef4efb4865fbd65893" - integrity sha512-aMt4OxvrdP1QM7rhsOvmkmdKmMY1oq11iHwEf/e/XCezmkab61QJaSM+oGk2Io+xKjdJrJVKOnkikxfQtyP6vw== +cspell-glob@^5.11.1: + version "5.11.1" + resolved "https://registry.yarnpkg.com/cspell-glob/-/cspell-glob-5.11.1.tgz#c8d26a77f9769a291f16288776f3f544ea165d61" + integrity sha512-1/X8ZkC7bMh8kb5RjkIzlfktz4asGfIUHbLm85nXO7wRYFZ/spK11YrPsRNXoEJsoDUkElDUvgN3pJFd9tM3vw== dependencies: micromatch "^4.0.4" -cspell-io@^5.10.0: - version "5.10.0" - resolved "https://registry.yarnpkg.com/cspell-io/-/cspell-io-5.10.0.tgz#5bfe04d5c924aa808d5129034e572b587ada90ef" - integrity sha512-vOJ44cGueqd6GWCmJSAeZ/GbmgJiZdGcvS0mkDhBW3CS5+L8ZH3NItSiH70H/zZUAPCelkyqoJP2zj0MxSVqXA== +cspell-io@^5.11.1: + version "5.11.1" + resolved "https://registry.yarnpkg.com/cspell-io/-/cspell-io-5.11.1.tgz#375c5db629c143aec3e4ecb576a53ad0c3e21176" + integrity sha512-FWCNq1dY6MO1Y494ou3Qdvm1fcWGte6bLLYycgz1CLwU42VAzOTMDzzR53+BExRb4HExp3penmIHGrwwG+BZHQ== -cspell-lib@^5.10.1: - version "5.10.1" - resolved "https://registry.yarnpkg.com/cspell-lib/-/cspell-lib-5.10.1.tgz#e91ac9caa4101c62634b6be149041e1f41c0bf60" - integrity sha512-Oaa+jP90dP1ipeRqoYIGCkgiVg4O4ZzGQr9qGHY1QMu62aknIURo2tzkH6HHtofRRodazGxW0VYl9XAscvOLAA== +cspell-lib@^5.11.1: + version "5.11.1" + resolved "https://registry.yarnpkg.com/cspell-lib/-/cspell-lib-5.11.1.tgz#68aa5b51a3f449fe1e60b65ff38cb0bfe52f8244" + integrity sha512-4o0umOGIdhx8pWqhVbminW14kwAoPOxiBmMUNwttZQ1kQw3WgT/6LwlFHbNL4pEIAgbMAnt4IX7IbTPL1Z+xDw== dependencies: - "@cspell/cspell-bundled-dicts" "^5.10.1" - "@cspell/cspell-types" "^5.10.0" + "@cspell/cspell-bundled-dicts" "^5.11.1" + "@cspell/cspell-types" "^5.11.1" clear-module "^4.1.1" comment-json "^4.1.1" configstore "^5.0.1" cosmiconfig "^7.0.1" - cspell-glob "^5.10.0" - cspell-io "^5.10.0" - cspell-trie-lib "^5.10.1" + cspell-glob "^5.11.1" + cspell-io "^5.11.1" + cspell-trie-lib "^5.11.1" find-up "^5.0.0" fs-extra "^10.0.0" gensequence "^3.1.1" @@ -3729,28 +3729,31 @@ cspell-lib@^5.10.1: resolve-global "^1.0.0" vscode-uri "^3.0.2" -cspell-trie-lib@^5.10.1: - version "5.10.1" - resolved "https://registry.yarnpkg.com/cspell-trie-lib/-/cspell-trie-lib-5.10.1.tgz#5c083e108bc054cb40093698cf61235bc1097188" - integrity sha512-pDlMM4aNBA8pwc6aZTtClr//e2kwyl7bLBRJ8aG608EICzHphfH8Hl0qopnFWCGvr3h52slYyOVuQ/frAcC4dg== +cspell-trie-lib@^5.11.1: + version "5.11.1" + resolved "https://registry.yarnpkg.com/cspell-trie-lib/-/cspell-trie-lib-5.11.1.tgz#041742b39fd9fbc596a3d0aafc13b697a42b85f2" + integrity sha512-2VQqKT+a5YKRy1CDrJOxtwUaPKCugMzg+tgZT0ft+CXZ7dzIxqi1RsC63eDpKVPx06WwTFYMx9FvtVCzU+2LNQ== dependencies: fs-extra "^10.0.0" gensequence "^3.1.1" cspell@^5.5.2: - version "5.10.1" - resolved "https://registry.yarnpkg.com/cspell/-/cspell-5.10.1.tgz#dfbada1536db121342a4606d9a027e3839844be4" - integrity sha512-jTj8gErwM+B0VnB2YULQ2ABHEc4Ch2udSnFoVRBGWRYKVqXYuRdqpX58j/UA9ByeDqXhx7Hoqg/1Q6vsHAJdZQ== + version "5.11.1" + resolved "https://registry.yarnpkg.com/cspell/-/cspell-5.11.1.tgz#654bfec3ce1356282a479544f59caf313c6f734e" + integrity sha512-VO+zPnl7KtGcQICe6dSeCRTT6tODnr79Mm39iY4VXDYKf0q5CtzAbABMiFIwMKD2vuCnc3kCl+1nwHYLjqRJHg== dependencies: chalk "^4.1.2" commander "^8.2.0" comment-json "^4.1.1" - cspell-glob "^5.10.0" - cspell-lib "^5.10.1" + cspell-glob "^5.11.1" + cspell-lib "^5.11.1" + fast-json-stable-stringify "^2.1.0" + file-entry-cache "^6.0.1" fs-extra "^10.0.0" get-stdin "^8.0.0" - glob "^7.1.7" - strip-ansi "^6.0.0" + glob "^7.2.0" + imurmurhash "^0.1.4" + strip-ansi "^6.0.1" vscode-uri "^3.0.2" cssom@^0.4.4: @@ -4614,7 +4617,7 @@ fast-glob@^3.1.1: micromatch "^4.0.2" picomatch "^2.2.1" -fast-json-stable-stringify@2.x, fast-json-stable-stringify@^2.0.0: +fast-json-stable-stringify@2.x, fast-json-stable-stringify@^2.0.0, fast-json-stable-stringify@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== @@ -5101,10 +5104,10 @@ glob-to-regexp@^0.3.0: resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.3.0.tgz#8c5a1494d2066c570cc3bfe4496175acc4d502ab" integrity sha1-jFoUlNIGbFcMw7/kSWF1rMTVAqs= -glob@*, glob@^7.0.0, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4, glob@^7.1.7, glob@~7.1.7: - version "7.1.7" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.7.tgz#3b193e9233f01d42d0b3f78294bbeeb418f94a90" - integrity sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ== +glob@*, glob@^7.0.0, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4, glob@^7.1.7, glob@^7.2.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023" + integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== dependencies: fs.realpath "^1.0.0" inflight "^1.0.4" @@ -5125,6 +5128,18 @@ glob@7.1.4: once "^1.3.0" path-is-absolute "^1.0.0" +glob@~7.1.7: + version "7.1.7" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.7.tgz#3b193e9233f01d42d0b3f78294bbeeb418f94a90" + integrity sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + global-dirs@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/global-dirs/-/global-dirs-0.1.1.tgz#b319c0dd4607f353f3be9cca4c72fc148c49f445" @@ -9491,12 +9506,12 @@ strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0: dependencies: ansi-regex "^4.1.0" -strip-ansi@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532" - integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w== +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== dependencies: - ansi-regex "^5.0.0" + ansi-regex "^5.0.1" strip-bom@4.0.0, strip-bom@^4.0.0: version "4.0.0" From 90cf56268f5299c3ea0f2a29fb9d629beda9dc1d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Oct 2021 10:58:23 -0700 Subject: [PATCH 04/44] chore: bump @commitlint/cli from 13.1.0 to 13.2.0 (#3955) Bumps [@commitlint/cli](https://github.com/conventional-changelog/commitlint) from 13.1.0 to 13.2.0. - [Release notes](https://github.com/conventional-changelog/commitlint/releases) - [Changelog](https://github.com/conventional-changelog/commitlint/blob/master/CHANGELOG.md) - [Commits](https://github.com/conventional-changelog/commitlint/compare/v13.1.0...v13.2.0) --- updated-dependencies: - dependency-name: "@commitlint/cli" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 289 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 201 insertions(+), 88 deletions(-) diff --git a/yarn.lock b/yarn.lock index 309bd1614c22..04a6879fbea7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -314,15 +314,15 @@ integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== "@commitlint/cli@^13.1.0": - version "13.1.0" - resolved "https://registry.yarnpkg.com/@commitlint/cli/-/cli-13.1.0.tgz#3608bb24dbef41aaa0729ffe65c7f9b57409626a" - integrity sha512-xN/uNYWtGTva5OMSd+xA6e6/c2jk8av7MUbdd6w2cw89u6z3fAWoyiH87X0ewdSMNYmW/6B3L/2dIVGHRDID5w== - dependencies: - "@commitlint/format" "^13.1.0" - "@commitlint/lint" "^13.1.0" - "@commitlint/load" "^13.1.0" - "@commitlint/read" "^13.1.0" - "@commitlint/types" "^13.1.0" + version "13.2.0" + resolved "https://registry.yarnpkg.com/@commitlint/cli/-/cli-13.2.0.tgz#9e85756b0d0ee06c34b5635d7ef42d7a6c72bd6f" + integrity sha512-RqG0cxxiwaL9OgQbA2ZEfZaVIRJmbtsZgnj5G07AjN7///s/40grSN4/kDl8YjUgvAZskPfJRoGGYNvHJ4zHWA== + dependencies: + "@commitlint/format" "^13.2.0" + "@commitlint/lint" "^13.2.0" + "@commitlint/load" "^13.2.0" + "@commitlint/read" "^13.2.0" + "@commitlint/types" "^13.2.0" lodash "^4.17.19" resolve-from "5.0.0" resolve-global "1.0.0" @@ -345,119 +345,120 @@ resolve-pkg "2.0.0" semver "7.3.5" -"@commitlint/ensure@^13.1.0": - version "13.1.0" - resolved "https://registry.yarnpkg.com/@commitlint/ensure/-/ensure-13.1.0.tgz#057a325b54f104cbeed2a26bacb5eec29298e7d5" - integrity sha512-NRGyjOdZQnlYwm9it//BZJ2Vm+4x7G9rEnHpLCvNKYY0c6RA8Qf7hamLAB8dWO12RLuFt06JaOpHZoTt/gHutA== +"@commitlint/ensure@^13.2.0": + version "13.2.0" + resolved "https://registry.yarnpkg.com/@commitlint/ensure/-/ensure-13.2.0.tgz#990c24f753781d1f14c1647c52d34a5730892e3d" + integrity sha512-rqhT62RehdLTRBu8OrPHnRCCd/7RmHEE4TiTlT4BLlr5ls5jlZhecOQWJ8np872uCNirrJ5NFjnjYYdbkNoW9Q== dependencies: - "@commitlint/types" "^13.1.0" + "@commitlint/types" "^13.2.0" lodash "^4.17.19" -"@commitlint/execute-rule@^13.0.0": - version "13.0.0" - resolved "https://registry.yarnpkg.com/@commitlint/execute-rule/-/execute-rule-13.0.0.tgz#7823303b82b5d86dac46e67cfa005f4433476981" - integrity sha512-lBz2bJhNAgkkU/rFMAw3XBNujbxhxlaFHY3lfKB/MxpAa+pIfmWB3ig9i1VKe0wCvujk02O0WiMleNaRn2KJqw== +"@commitlint/execute-rule@^13.2.0": + version "13.2.0" + resolved "https://registry.yarnpkg.com/@commitlint/execute-rule/-/execute-rule-13.2.0.tgz#e112159d6647bc5afe2f77c2080ef0f615fd541f" + integrity sha512-6nPwpN0hwTYmsH3WM4hCdN+NrMopgRIuQ0aqZa+jnwMoS/g6ljliQNYfL+m5WO306BaIu1W3yYpbW5aI8gEr0g== -"@commitlint/format@^13.1.0": - version "13.1.0" - resolved "https://registry.yarnpkg.com/@commitlint/format/-/format-13.1.0.tgz#915570d958d83bae5fa645de6b1e6c9dd1362ec0" - integrity sha512-n46rYvzf+6Sm99TJjTLjJBkjm6JVcklt31lDO5Q+pCIV0NnJ4qIUcwa6wIL9a9Vqb1XzlMgtp27E0zyYArkvSg== +"@commitlint/format@^13.2.0": + version "13.2.0" + resolved "https://registry.yarnpkg.com/@commitlint/format/-/format-13.2.0.tgz#eccfff0a09ced8533afb21b2b3a1e28176b109d5" + integrity sha512-yNBQJe6YFhM1pJAta4LvzQxccSKof6axJH7ALYjuhQqfT8AKlad7Y/2SuJ07ioyreNIqwOTuF2UfU8yJ7JzEIQ== dependencies: - "@commitlint/types" "^13.1.0" + "@commitlint/types" "^13.2.0" chalk "^4.0.0" -"@commitlint/is-ignored@^13.1.0": - version "13.1.0" - resolved "https://registry.yarnpkg.com/@commitlint/is-ignored/-/is-ignored-13.1.0.tgz#88a5dfbc8f9ea91e860323af6681aa131322b0c4" - integrity sha512-P6zenLE5Tn3FTNjRzmL9+/KooTXEI0khA2TmUbuei9KiycemeO4q7Xk7w7aXwFPNAbN0O9oI7z3z7cFpzKJWmQ== +"@commitlint/is-ignored@^13.2.0": + version "13.2.0" + resolved "https://registry.yarnpkg.com/@commitlint/is-ignored/-/is-ignored-13.2.0.tgz#532ddfb5d62a489ff4d3ad88bcbee44e8c7d2c8f" + integrity sha512-onnx4WctHFPPkHGFFAZBIWRSaNwuhixIIfbwPhcZ6IewwQX5n4jpjwM1GokA7vhlOnQ57W7AavbKUGjzIVtnRQ== dependencies: - "@commitlint/types" "^13.1.0" + "@commitlint/types" "^13.2.0" semver "7.3.5" -"@commitlint/lint@^13.1.0": - version "13.1.0" - resolved "https://registry.yarnpkg.com/@commitlint/lint/-/lint-13.1.0.tgz#ea56ce0970f9b75ffe7bd2c9968f4f1d4461ba3a" - integrity sha512-qH9AYSQDDTaSWSdtOvB3G1RdPpcYSgddAdFYqpFewlKQ1GJj/L+sM7vwqCG7/ip6AiM04Sry1sgmFzaEoFREUA== +"@commitlint/lint@^13.2.0": + version "13.2.0" + resolved "https://registry.yarnpkg.com/@commitlint/lint/-/lint-13.2.0.tgz#b568c96bd21c8fa8eec359a5e21d22743206761f" + integrity sha512-5XYkh0e9ehHjA7BxAHFpjPgr1qqbFY8OFG1wpBiAhycbYBtJnQmculA2wcwqTM40YCUBqEvWFdq86jTG8fbkMw== dependencies: - "@commitlint/is-ignored" "^13.1.0" - "@commitlint/parse" "^13.1.0" - "@commitlint/rules" "^13.1.0" - "@commitlint/types" "^13.1.0" + "@commitlint/is-ignored" "^13.2.0" + "@commitlint/parse" "^13.2.0" + "@commitlint/rules" "^13.2.0" + "@commitlint/types" "^13.2.0" -"@commitlint/load@>6.1.1", "@commitlint/load@^13.1.0": - version "13.1.0" - resolved "https://registry.yarnpkg.com/@commitlint/load/-/load-13.1.0.tgz#d6c9b547551f2216586d6c1964d93f92e7b04277" - integrity sha512-zlZbjJCWnWmBOSwTXis8H7I6pYk6JbDwOCuARA6B9Y/qt2PD+NCo0E/7EuaaFoxjHl+o56QR5QttuMBrf+BJzg== +"@commitlint/load@>6.1.1", "@commitlint/load@^13.2.0": + version "13.2.0" + resolved "https://registry.yarnpkg.com/@commitlint/load/-/load-13.2.0.tgz#6bd90b803f7fd102766731dad207cca075b67a4a" + integrity sha512-Nhkv+hwWCCxWGjmE9jd1U8kfGGCkZVpwzlTtdKxpY+Aj2VCFg3BjY+qA81pMF3oAsIpxchSaZG5llb8kduVjYg== dependencies: - "@commitlint/execute-rule" "^13.0.0" - "@commitlint/resolve-extends" "^13.0.0" - "@commitlint/types" "^13.1.0" + "@commitlint/execute-rule" "^13.2.0" + "@commitlint/resolve-extends" "^13.2.0" + "@commitlint/types" "^13.2.0" + "@endemolshinegroup/cosmiconfig-typescript-loader" "^3.0.2" chalk "^4.0.0" cosmiconfig "^7.0.0" lodash "^4.17.19" resolve-from "^5.0.0" -"@commitlint/message@^13.0.0": - version "13.0.0" - resolved "https://registry.yarnpkg.com/@commitlint/message/-/message-13.0.0.tgz#4f8d56b59e9cee8b37b8db6b48c26d7faf33762f" - integrity sha512-W/pxhesVEk8747BEWJ+VGQ9ILHmCV27/pEwJ0hGny1wqVquUR8SxvScRCbUjHCB1YtWX4dEnOPXOS9CLH/CX7A== +"@commitlint/message@^13.2.0": + version "13.2.0" + resolved "https://registry.yarnpkg.com/@commitlint/message/-/message-13.2.0.tgz#1a60f578551750a8d6b533be8a40541fc2e928a8" + integrity sha512-+LlErJj2F2AC86xJb33VJIvSt25xqSF1I0b0GApSgoUtQBeJhx4SxIj1BLvGcLVmbRmbgTzAFq/QylwLId7EhA== -"@commitlint/parse@^13.1.0": - version "13.1.0" - resolved "https://registry.yarnpkg.com/@commitlint/parse/-/parse-13.1.0.tgz#b88764be36527a468531e1b8dd2d95693ff9ba34" - integrity sha512-xFybZcqBiKVjt6vTStvQkySWEUYPI0AcO4QQELyy29o8EzYZqWkhUfrb7K61fWiHsplWL1iL6F3qCLoxSgTcrg== +"@commitlint/parse@^13.2.0": + version "13.2.0" + resolved "https://registry.yarnpkg.com/@commitlint/parse/-/parse-13.2.0.tgz#48054602bd73dccbffee4f9ba8b2549c857ba0b7" + integrity sha512-AtfKSQJQADbDhW+kuC5PxOyBANsYCuuJlZRZ2PYslOz2rvWwZ93zt+nKjM4g7C9ETbz0uq4r7/EoOsTJ2nJqfQ== dependencies: - "@commitlint/types" "^13.1.0" + "@commitlint/types" "^13.2.0" conventional-changelog-angular "^5.0.11" - conventional-commits-parser "^3.0.0" + conventional-commits-parser "^3.2.2" -"@commitlint/read@^13.1.0": - version "13.1.0" - resolved "https://registry.yarnpkg.com/@commitlint/read/-/read-13.1.0.tgz#ccb65426b1228b8a598ed36966722d19756eea41" - integrity sha512-NrVe23GMKyL6i1yDJD8IpqCBzhzoS3wtLfDj8QBzc01Ov1cYBmDojzvBklypGb+MLJM1NbzmRM4PR5pNX0U/NQ== +"@commitlint/read@^13.2.0": + version "13.2.0" + resolved "https://registry.yarnpkg.com/@commitlint/read/-/read-13.2.0.tgz#2af580322ec6297478aba84fa8ec24fd27c35a54" + integrity sha512-7db5e1Bn3re6hQN0SqygTMF/QX6/MQauoJn3wJiUHE93lvwO6aFQxT3qAlYeyBPwfWsmDz/uSH454jtrSsv3Uw== dependencies: - "@commitlint/top-level" "^13.0.0" - "@commitlint/types" "^13.1.0" + "@commitlint/top-level" "^13.2.0" + "@commitlint/types" "^13.2.0" fs-extra "^10.0.0" git-raw-commits "^2.0.0" -"@commitlint/resolve-extends@^13.0.0": - version "13.0.0" - resolved "https://registry.yarnpkg.com/@commitlint/resolve-extends/-/resolve-extends-13.0.0.tgz#a38fcd2474483bf9ec6e1e901b27b8a23abe7d73" - integrity sha512-1SyaE+UOsYTkQlTPUOoj4NwxQhGFtYildVS/d0TJuK8a9uAJLw7bhCLH2PEeH5cC2D1do4Eqhx/3bLDrSLH3hg== +"@commitlint/resolve-extends@^13.2.0": + version "13.2.0" + resolved "https://registry.yarnpkg.com/@commitlint/resolve-extends/-/resolve-extends-13.2.0.tgz#74f48512eb1785abe07336a5208225fdf7fec327" + integrity sha512-HLCMkqMKtvl1yYLZ1Pm0UpFvd0kYjsm1meLOGZ7VkOd9G/XX+Fr1S2G5AT2zeiDw7WUVYK8lGVMNa319bnV+aw== dependencies: import-fresh "^3.0.0" lodash "^4.17.19" resolve-from "^5.0.0" resolve-global "^1.0.0" -"@commitlint/rules@^13.1.0": - version "13.1.0" - resolved "https://registry.yarnpkg.com/@commitlint/rules/-/rules-13.1.0.tgz#04f5aaf952884364ebf4e899ec440e3985f0e580" - integrity sha512-b6F+vBqEXsHVghrhomG0Y6YJimHZqkzZ0n5QEpk03dpBXH2OnsezpTw5e+GvbyYCc7PutGbYVQkytuv+7xCxYA== +"@commitlint/rules@^13.2.0": + version "13.2.0" + resolved "https://registry.yarnpkg.com/@commitlint/rules/-/rules-13.2.0.tgz#e272fbd4099c2fe98bca1277d7f8caa3578b8f43" + integrity sha512-O3A9S7blOzvHfzrJrUQe9JxdtGy154ol/GXHwvd8WfMJ10y5ryBB4b6+0YZ1XhItWzrEASOfOKbD++EdLV90dQ== dependencies: - "@commitlint/ensure" "^13.1.0" - "@commitlint/message" "^13.0.0" - "@commitlint/to-lines" "^13.0.0" - "@commitlint/types" "^13.1.0" + "@commitlint/ensure" "^13.2.0" + "@commitlint/message" "^13.2.0" + "@commitlint/to-lines" "^13.2.0" + "@commitlint/types" "^13.2.0" execa "^5.0.0" -"@commitlint/to-lines@^13.0.0": - version "13.0.0" - resolved "https://registry.yarnpkg.com/@commitlint/to-lines/-/to-lines-13.0.0.tgz#5937dd287e3a4f984580ea94bdb994132169a780" - integrity sha512-mzxWwCio1M4/kG9/69TTYqrraQ66LmtJCYTzAZdZ2eJX3I5w52pSjyP/DJzAUVmmJCYf2Kw3s+RtNVShtnZ+Rw== +"@commitlint/to-lines@^13.2.0": + version "13.2.0" + resolved "https://registry.yarnpkg.com/@commitlint/to-lines/-/to-lines-13.2.0.tgz#e65d16340f353b496e90609b452f23f4b0be0b6a" + integrity sha512-ZfWZix2y/CzewReCrj5g0nKOEfj5HW9eBMDrqjJJMPApve00CWv0tYrFCGXuGlv244lW4uvWJt6J/0HLRWsfyg== -"@commitlint/top-level@^13.0.0": - version "13.0.0" - resolved "https://registry.yarnpkg.com/@commitlint/top-level/-/top-level-13.0.0.tgz#f8e1d1425240cd72c600e4da5716418c4ea0bda2" - integrity sha512-baBy3MZBF28sR93yFezd4a5TdHsbXaakeladfHK9dOcGdXo9oQe3GS5hP3BmlN680D6AiQSN7QPgEJgrNUWUCg== +"@commitlint/top-level@^13.2.0": + version "13.2.0" + resolved "https://registry.yarnpkg.com/@commitlint/top-level/-/top-level-13.2.0.tgz#869814e8ac0fec6a6e1f2e9665a318e4dc979e1e" + integrity sha512-knBvWYbIq6VV6VPHrVeDsxDiJq4Zq6cv5NIYU3iesKAsmK2KlLfsZPa+Ig96Y4AqAPU3zNJwjHxYkz9qxdBbfA== dependencies: find-up "^5.0.0" -"@commitlint/types@^13.1.0": - version "13.1.0" - resolved "https://registry.yarnpkg.com/@commitlint/types/-/types-13.1.0.tgz#12cfb6e932372b1816af8900e2d10694add28191" - integrity sha512-zcVjuT+OfKt8h91vhBxt05RMcTGEx6DM7Q9QZeuMbXFk6xgbsSEDMMapbJPA1bCZ81fa/1OQBijSYPrKvtt06g== +"@commitlint/types@^13.2.0": + version "13.2.0" + resolved "https://registry.yarnpkg.com/@commitlint/types/-/types-13.2.0.tgz#ed8128f9e41383f8f0ee1b0370c724826821e581" + integrity sha512-RRVHEqmk1qn/dIaSQhvuca6k/6Z54G+r/KyimZ8gnAFielGiGUpsFRhIY3qhd5rXClVxDaa3nlcyTWckSccotQ== dependencies: chalk "^4.0.0" @@ -694,6 +695,16 @@ dependencies: "@cspotcode/source-map-consumer" "0.8.0" +"@endemolshinegroup/cosmiconfig-typescript-loader@^3.0.2": + version "3.0.2" + resolved "https://registry.yarnpkg.com/@endemolshinegroup/cosmiconfig-typescript-loader/-/cosmiconfig-typescript-loader-3.0.2.tgz#eea4635828dde372838b0909693ebd9aafeec22d" + integrity sha512-QRVtqJuS1mcT56oHpVegkKBlgtWjXw/gHNWO3eL9oyB5Sc7HBoc2OLG/nYpVfT/Jejvo3NUrD0Udk7XgoyDKkA== + dependencies: + lodash.get "^4" + make-error "^1" + ts-node "^9" + tslib "^2" + "@eslint/eslintrc@^0.4.1": version "0.4.1" resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.4.1.tgz#442763b88cecbe3ee0ec7ca6d6dd6168550cbf14" @@ -3567,7 +3578,7 @@ conventional-commits-filter@^2.0.2, conventional-commits-filter@^2.0.6: lodash.ismatch "^4.4.0" modify-values "^1.0.0" -conventional-commits-parser@^3.0.0, conventional-commits-parser@^3.0.3: +conventional-commits-parser@^3.0.3: version "3.1.0" resolved "https://registry.yarnpkg.com/conventional-commits-parser/-/conventional-commits-parser-3.1.0.tgz#10140673d5e7ef5572633791456c5d03b69e8be4" integrity sha512-RSo5S0WIwXZiRxUGTPuYFbqvrR4vpJ1BDdTlthFgvHt5kEdnd1+pdvwWphWn57/oIl4V72NMmOocFqqJ8mFFhA== @@ -3580,6 +3591,18 @@ conventional-commits-parser@^3.0.0, conventional-commits-parser@^3.0.3: through2 "^3.0.0" trim-off-newlines "^1.0.0" +conventional-commits-parser@^3.2.2: + version "3.2.2" + resolved "https://registry.yarnpkg.com/conventional-commits-parser/-/conventional-commits-parser-3.2.2.tgz#190fb9900c6e02be0c0bca9b03d57e24982639fd" + integrity sha512-Jr9KAKgqAkwXMRHjxDwO/zOCDKod1XdAESHAGuJX38iZ7ZzVti/tvVoysO0suMsdAObp9NQ2rHSsSbnAqZ5f5g== + dependencies: + JSONStream "^1.0.4" + is-text-path "^1.0.1" + lodash "^4.17.15" + meow "^8.0.0" + split2 "^3.0.0" + through2 "^4.0.0" + conventional-recommended-bump@^5.0.0: version "5.0.1" resolved "https://registry.yarnpkg.com/conventional-recommended-bump/-/conventional-recommended-bump-5.0.1.tgz#5af63903947b6e089e77767601cb592cabb106ba" @@ -5332,6 +5355,13 @@ hosted-git-info@^2.1.4, hosted-git-info@^2.7.1: resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9" integrity sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw== +hosted-git-info@^4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-4.0.2.tgz#5e425507eede4fea846b7262f0838456c4209961" + integrity sha512-c9OGXbZ3guC/xOlCg1Ci/VgWlwsqDv1yMQL1CWqXDL0hDjXuNcq0zuR4xqPSuasI3kqFDhqSyTjREz5gzq0fXg== + dependencies: + lru-cache "^6.0.0" + html-encoding-sniffer@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/html-encoding-sniffer/-/html-encoding-sniffer-2.0.1.tgz#42a6dc4fd33f00281176e8b23759ca4e4fa185f3" @@ -5682,6 +5712,13 @@ is-core-module@^2.1.0, is-core-module@^2.2.0, is-core-module@^2.6.0: dependencies: has "^1.0.3" +is-core-module@^2.5.0: + version "2.7.0" + resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.7.0.tgz#3c0ef7d31b4acfc574f80c58409d568a836848e3" + integrity sha512-ByY+tjCciCr+9nLryBYcSD50EOGWt95c7tIsKTG1J2ixKKXPvF7Ej3AVd+UfDydAJom3biBGDBALaO79ktwgEQ== + dependencies: + has "^1.0.3" + is-data-descriptor@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56" @@ -7218,7 +7255,7 @@ lodash.flatten@~4.4.0: resolved "https://registry.yarnpkg.com/lodash.flatten/-/lodash.flatten-4.4.0.tgz#f31c22225a9632d2bbf8e4addbef240aa765a61f" integrity sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8= -lodash.get@^4.0.0, lodash.get@^4.4.2: +lodash.get@^4, lodash.get@^4.0.0, lodash.get@^4.4.2: version "4.4.2" resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" integrity sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk= @@ -7355,7 +7392,7 @@ make-dir@^2.1.0: pify "^4.0.1" semver "^5.6.0" -make-error@1.x, make-error@^1.1.1: +make-error@1.x, make-error@^1, make-error@^1.1.1: version "1.3.6" resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== @@ -7517,6 +7554,23 @@ meow@^7.0.0: type-fest "^0.13.1" yargs-parser "^18.1.3" +meow@^8.0.0: + version "8.1.2" + resolved "https://registry.yarnpkg.com/meow/-/meow-8.1.2.tgz#bcbe45bda0ee1729d350c03cffc8395a36c4e897" + integrity sha512-r85E3NdZ+mpYk1C6RjPFEMSE+s1iZMuHtsHAqY0DT3jZczl0diWUZ8g6oU7h0M9cD2EL+PzaYghhCLzR0ZNn5Q== + dependencies: + "@types/minimist" "^1.2.0" + camelcase-keys "^6.2.2" + decamelize-keys "^1.1.0" + hard-rejection "^2.1.0" + minimist-options "4.1.0" + normalize-package-data "^3.0.0" + read-pkg-up "^7.0.1" + redent "^3.0.0" + trim-newlines "^3.0.0" + type-fest "^0.18.0" + yargs-parser "^20.2.3" + merge-stream@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" @@ -7853,6 +7907,16 @@ normalize-package-data@^2.0.0, normalize-package-data@^2.3.0, normalize-package- semver "2 || 3 || 4 || 5" validate-npm-package-license "^3.0.1" +normalize-package-data@^3.0.0: + version "3.0.3" + resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-3.0.3.tgz#dbcc3e2da59509a0983422884cd172eefdfa525e" + integrity sha512-p2W1sgqij3zMMyRC067Dg16bfzVH+w7hyegmpIvZ4JNjqtGOVAIvLmjBx3yP7YTe9vKJgkoNOPjwQGogDoMXFA== + dependencies: + hosted-git-info "^4.0.1" + is-core-module "^2.5.0" + semver "^7.3.4" + validate-npm-package-license "^3.0.1" + normalize-path@^3.0.0, normalize-path@~3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" @@ -8726,7 +8790,7 @@ read@1, read@~1.0.1: string_decoder "~1.1.1" util-deprecate "~1.0.1" -"readable-stream@2 || 3", readable-stream@^3.0.2: +"readable-stream@2 || 3", readable-stream@3, readable-stream@^3.0.0, readable-stream@^3.0.2: version "3.6.0" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== @@ -9075,7 +9139,7 @@ semver@7.3.4: dependencies: lru-cache "^6.0.0" -semver@7.3.5, semver@7.x, semver@^7.2.1, semver@^7.3.2, semver@^7.3.5, semver@~7.3.0: +semver@7.3.5, semver@7.x, semver@^7.2.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@~7.3.0: version "7.3.5" resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7" integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ== @@ -9259,6 +9323,14 @@ source-map-resolve@^0.5.0: source-map-url "^0.4.0" urix "^0.1.0" +source-map-support@^0.5.17: + version "0.5.20" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.20.tgz#12166089f8f5e5e8c56926b377633392dd2cb6c9" + integrity sha512-n1lZZ8Ve4ksRqizaBQgxXDgKwttHDhyfQjA6YZZn8+AroHbsIz+JjwxQDxbp+7y5OYCI8t1Yk7etjD9CRd2hIw== + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + source-map-support@^0.5.6: version "0.5.19" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" @@ -9327,6 +9399,13 @@ split2@^2.0.0: dependencies: through2 "^2.0.2" +split2@^3.0.0: + version "3.2.2" + resolved "https://registry.yarnpkg.com/split2/-/split2-3.2.2.tgz#bf2cf2a37d838312c249c89206fd7a17dd12365f" + integrity sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg== + dependencies: + readable-stream "^3.0.0" + split@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/split/-/split-1.0.1.tgz#605bd9be303aa59fb35f9229fbea0ddec9ea07d9" @@ -9728,6 +9807,13 @@ through2@^3.0.0: inherits "^2.0.4" readable-stream "2 || 3" +through2@^4.0.0: + version "4.0.2" + resolved "https://registry.yarnpkg.com/through2/-/through2-4.0.2.tgz#a7ce3ac2a7a8b0b966c80e7c49f0484c3b239764" + integrity sha512-iOqSav00cVxEEICeD7TjLB1sueEL+81Wpzp2bY17uZjZN0pWZPuo4suZ/61VujxmqSGFfgOcNuTZ85QJwNZQpw== + dependencies: + readable-stream "3" + through@2, "through@>=2.2.7 <3", through@^2.3.4, through@^2.3.6, through@^2.3.8: version "2.3.8" resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" @@ -9877,6 +9963,18 @@ ts-node@^10.0.0: make-error "^1.1.1" yn "3.1.1" +ts-node@^9: + version "9.1.1" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-9.1.1.tgz#51a9a450a3e959401bda5f004a72d54b936d376d" + integrity sha512-hPlt7ZACERQGf03M253ytLY3dHbGNGrAq9qIHWUY9XHYl1z7wYngSr3OQ5xmui8o2AaxsONxIzjafLUiWBo1Fg== + dependencies: + arg "^4.1.0" + create-require "^1.1.0" + diff "^4.0.1" + make-error "^1.1.1" + source-map-support "^0.5.17" + yn "3.1.1" + tsconfig-paths@^3.11.0: version "3.11.0" resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.11.0.tgz#954c1fe973da6339c78e06b03ce2e48810b65f36" @@ -9892,6 +9990,11 @@ tslib@^1.13.0, tslib@^1.8.1, tslib@^1.9.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043" integrity sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q== +tslib@^2: + version "2.3.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01" + integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw== + tslib@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.2.0.tgz#fb2c475977e35e241311ede2693cee1ec6698f5c" @@ -9971,6 +10074,11 @@ type-fest@^0.13.1: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.13.1.tgz#0172cb5bce80b0bd542ea348db50c7e21834d934" integrity sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg== +type-fest@^0.18.0: + version "0.18.1" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.18.1.tgz#db4bc151a4a2cf4eebf9add5db75508db6cc841f" + integrity sha512-OIAYXk8+ISY+qTOwkHtKqzAuxchoMiD9Udx+FSGQDuiRR+PJKJHc2NJAXlbhkGwTt/4/nKZxELY1w3ReWOL8mw== + type-fest@^0.20.2: version "0.20.2" resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4" @@ -10491,6 +10599,11 @@ yargs-parser@^18.1.2, yargs-parser@^18.1.3: camelcase "^5.0.0" decamelize "^1.2.0" +yargs-parser@^20.2.3: + version "20.2.9" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" + integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== + yargs@15.4.1, yargs@^15.0.1: version "15.4.1" resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.4.1.tgz#0d87a16de01aee9d8bec2bfbf74f67851730f4f8" From bbbef82df5a488fd5d5128c9ab47dc5af07d08e5 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Mon, 4 Oct 2021 11:02:53 -0700 Subject: [PATCH 05/44] docs(eslint-plugin): [consistent-type-imports] remove out-of-date note about decorator inlining --- packages/eslint-plugin/docs/rules/consistent-type-imports.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/eslint-plugin/docs/rules/consistent-type-imports.md b/packages/eslint-plugin/docs/rules/consistent-type-imports.md index a5808b455788..3d3acbeca272 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-imports.md +++ b/packages/eslint-plugin/docs/rules/consistent-type-imports.md @@ -61,6 +61,4 @@ const x: import('Bar') = 1; ## When Not To Use It - If you are not using TypeScript 3.8 (or greater), then you will not be able to use this rule, as type-only imports are not allowed. -- Certain libraries use the non-inlined imports to infer information about the variables. For example, for dependency injection.
- type-only imports cannot be used with these libraries. See [#2559](https://github.com/typescript-eslint/typescript-eslint/issues/2559#issuecomment-692780580) - If you specifically want to use both import kinds for stylistic reasons, you can disable this rule. From 836be6ef454e4b0104167a660acacea5502d2743 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Oct 2021 18:46:28 -0700 Subject: [PATCH 06/44] chore: bump @microsoft/api-extractor from 7.18.11 to 7.18.12 (#3960) Bumps [@microsoft/api-extractor](https://github.com/microsoft/rushstack) from 7.18.11 to 7.18.12. - [Release notes](https://github.com/microsoft/rushstack/releases) - [Commits](https://github.com/microsoft/rushstack/compare/@microsoft/api-extractor_v7.18.11...@microsoft/api-extractor_v7.18.12) --- updated-dependencies: - dependency-name: "@microsoft/api-extractor" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/yarn.lock b/yarn.lock index 04a6879fbea7..2c0e571048c0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1819,16 +1819,16 @@ "@rushstack/node-core-library" "3.41.0" "@microsoft/api-extractor@^7.15.2": - version "7.18.11" - resolved "https://registry.yarnpkg.com/@microsoft/api-extractor/-/api-extractor-7.18.11.tgz#24910c2432362b09900b493a0713919b662cdb0f" - integrity sha512-WfN5MZry4TrF60OOcGadFDsGECF9JNKNT+8P/8crYAumAYQRitI2cUiQRlCWrgmFgCWNezsNZeI/2BggdnUqcg== + version "7.18.12" + resolved "https://registry.yarnpkg.com/@microsoft/api-extractor/-/api-extractor-7.18.12.tgz#22644d43dd5c056fbc3d2db9fc692d67ed109e20" + integrity sha512-rFwsegenBjjce09uUr4wK9L9K5y1Lcm1eCHHKbI4w44ZoHdZOQlAGfl16I7pl0AEfkmhJUEcqWixRh07un3XJA== dependencies: "@microsoft/api-extractor-model" "7.13.9" "@microsoft/tsdoc" "0.13.2" "@microsoft/tsdoc-config" "~0.15.2" "@rushstack/node-core-library" "3.41.0" "@rushstack/rig-package" "0.3.1" - "@rushstack/ts-command-line" "4.9.1" + "@rushstack/ts-command-line" "4.10.0" colors "~1.2.1" lodash "~4.17.15" resolve "~1.17.0" @@ -2125,10 +2125,10 @@ resolve "~1.17.0" strip-json-comments "~3.1.1" -"@rushstack/ts-command-line@4.9.1": - version "4.9.1" - resolved "https://registry.yarnpkg.com/@rushstack/ts-command-line/-/ts-command-line-4.9.1.tgz#9fe594a408c7ef1b67f57b41ba931ecd3f420e92" - integrity sha512-zzoWB6OqVbMjnxlxbAUqbZqDWITUSHqwFCx7JbH5CVrjR9kcsB4NeWkN1I8GcR92beiOGvO3yPlB2NRo5Ugh+A== +"@rushstack/ts-command-line@4.10.0": + version "4.10.0" + resolved "https://registry.yarnpkg.com/@rushstack/ts-command-line/-/ts-command-line-4.10.0.tgz#6ddc939bb16410078379956dd97c14020b71b236" + integrity sha512-BRF7O4XQKmrZz8GZ6b/+0+4elrnY2kjZsLrUOJ1dwJZxAR0I1+G0/GD66RVPi0ku1qN4A6t+HrB5p2Nxc9ECrA== dependencies: "@types/argparse" "1.0.38" argparse "~1.0.9" From 27f9674a64589a0ade0902bb343b77d4cdaeeee3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Oct 2021 18:47:08 -0700 Subject: [PATCH 07/44] chore: bump @types/lodash from 4.14.173 to 4.14.175 (#3961) Bumps [@types/lodash](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/lodash) from 4.14.173 to 4.14.175. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/lodash) --- updated-dependencies: - dependency-name: "@types/lodash" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 2c0e571048c0..77ac2f98964f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2306,9 +2306,9 @@ integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4= "@types/lodash@*", "@types/lodash@^4.14.170": - version "4.14.173" - resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.173.tgz#9d3b674c67a26cf673756f6aca7b429f237f91ed" - integrity sha512-vv0CAYoaEjCw/mLy96GBTnRoZrSxkGE0BKzKimdR8P3OzrNYNvBgtW7p055A+E8C31vXNUhWKoFCbhq7gbyhFg== + version "4.14.175" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.175.tgz#b78dfa959192b01fae0ad90e166478769b215f45" + integrity sha512-XmdEOrKQ8a1Y/yxQFOMbC47G/V2VDO1GvMRnl4O75M4GW/abC5tnfzadQYkqEveqRM1dEJGFFegfPNA2vvx2iw== "@types/marked@*", "@types/marked@^2.0.3": version "2.0.5" From 6d7478e3712ba9bb33d74ea37a68af7d82db0c88 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Oct 2021 18:47:18 -0700 Subject: [PATCH 08/44] chore: bump eslint-plugin-eslint-plugin from 3.5.3 to 3.6.1 (#3962) Bumps [eslint-plugin-eslint-plugin](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin) from 3.5.3 to 3.6.1. - [Release notes](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/releases) - [Changelog](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/CHANGELOG.md) - [Commits](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/compare/v3.5.3...v3.6.1) --- updated-dependencies: - dependency-name: eslint-plugin-eslint-plugin dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 77ac2f98964f..ffc3470c393d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4305,9 +4305,9 @@ eslint-plugin-eslint-comments@^3.2.0: ignore "^5.0.5" eslint-plugin-eslint-plugin@^3.0.3: - version "3.5.3" - resolved "https://registry.yarnpkg.com/eslint-plugin-eslint-plugin/-/eslint-plugin-eslint-plugin-3.5.3.tgz#6cac958e944b820962a4cf9e65cc32a2e0415eaf" - integrity sha512-8LnYyjIOLS0gqh3QFVBkahYzkFd5UaMZkkeEvqReSjIBgajYyZaMElU8szHhqDrqr0rWkkZk33j9e4qnFN3x2A== + version "3.6.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-eslint-plugin/-/eslint-plugin-eslint-plugin-3.6.1.tgz#6c93655c9345f36874cc4f8aba4f89c81d47b8fe" + integrity sha512-SOE0aoS2+lvtcEbJmy98gEKaxcpkQdxDtqvqE0VQSiGEFme8yTNjpLAjMqPDmmj8KGTwIFd+cYnVykz+9HAIiw== dependencies: eslint-utils "^2.1.0" From 05b0d71b7256c8e65f003c90dab56bb60f312e36 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Oct 2021 18:47:30 -0700 Subject: [PATCH 09/44] chore: bump @types/prettier from 2.4.0 to 2.4.1 (#3963) Bumps [@types/prettier](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/prettier) from 2.4.0 to 2.4.1. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/prettier) --- updated-dependencies: - dependency-name: "@types/prettier" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index ffc3470c393d..89794b9870fd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2353,9 +2353,9 @@ integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA== "@types/prettier@*", "@types/prettier@^2.1.5", "@types/prettier@^2.2.3": - version "2.4.0" - resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.4.0.tgz#900b13362610ccd3570fb6eefb911a6732973d00" - integrity sha512-WHRsy5nMpjXfU9B0LqOqPT06EI2+8Xv5NERy0pLxJLbU98q7uhcGogQzfX+rXpU7S5mgHsLxHrLCufZcV/P8TQ== + version "2.4.1" + resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.4.1.tgz#e1303048d5389563e130f5bdd89d37a99acb75eb" + integrity sha512-Fo79ojj3vdEZOHg3wR9ksAMRz4P3S5fDB5e/YWZiFnyFQI1WY2Vftu9XoXVVtJfxB7Bpce/QTqWSSntkz2Znrw== "@types/rimraf@^3.0.0": version "3.0.2" From c2373ae1783c123bafeee86302202d34959f2e1e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Oct 2021 18:47:41 -0700 Subject: [PATCH 10/44] chore: bump eslint-plugin-jest from 24.4.2 to 24.5.2 (#3964) Bumps [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) from 24.4.2 to 24.5.2. - [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases) - [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/main/CHANGELOG.md) - [Commits](https://github.com/jest-community/eslint-plugin-jest/compare/v24.4.2...v24.5.2) --- updated-dependencies: - dependency-name: eslint-plugin-jest dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 89794b9870fd..6a403c3585fe 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4333,9 +4333,9 @@ eslint-plugin-import@^2.23.4: tsconfig-paths "^3.11.0" eslint-plugin-jest@^24.3.6: - version "24.4.2" - resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-24.4.2.tgz#9e8cf05ee6a0e3025e6149df2f36950abfa8d5bf" - integrity sha512-jNMnqwX75z0RXRMXkxwb/+9ylKJYJLJ8nT8nBT0XFM5qx4IQGxP4edMawa0qGkSbHae0BDPBmi8I2QF0/F04XQ== + version "24.5.2" + resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-24.5.2.tgz#f71f98f27fd18b50f55246ca090f36d1730e36a6" + integrity sha512-lrI3sGAyZi513RRmP08sIW241Ti/zMnn/6wbE4ZBhb3M2pJ9ztaZMnSKSKKBUfotVdwqU8W1KtD8ao2/FR8DIg== dependencies: "@typescript-eslint/experimental-utils" "^4.0.1" From 0cc509b61df248cfb4b42fe64ec800f3cac69c69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Tue, 5 Oct 2021 19:14:19 +0200 Subject: [PATCH 11/44] feat(experimental-utils): extract `isNodeOfTypes` out of `ast-utils`' `predicates` (#3836) --- .../src/ast-utils/predicates.ts | 148 ++++++------------ 1 file changed, 50 insertions(+), 98 deletions(-) diff --git a/packages/experimental-utils/src/ast-utils/predicates.ts b/packages/experimental-utils/src/ast-utils/predicates.ts index 566cfbda493a..059437ae1665 100644 --- a/packages/experimental-utils/src/ast-utils/predicates.ts +++ b/packages/experimental-utils/src/ast-utils/predicates.ts @@ -6,6 +6,12 @@ const isNodeOfType = node: TSESTree.Node | null | undefined, ): node is TSESTree.Node & { type: NodeType } => node?.type === nodeType; +const isNodeOfTypes = + (nodeTypes: NodeTypes) => + ( + node: TSESTree.Node | null | undefined, + ): node is TSESTree.Node & { type: NodeTypes[number] } => + !!node && nodeTypes.includes(node.type); type ObjectEntry = [keyof BaseType, BaseType[keyof BaseType]]; type ObjectEntries = Array>; @@ -93,89 +99,48 @@ function isTypeAssertion( const isVariableDeclarator = isNodeOfType(AST_NODE_TYPES.VariableDeclarator); -function isFunction( - node: TSESTree.Node | undefined, -): node is - | TSESTree.ArrowFunctionExpression - | TSESTree.FunctionDeclaration - | TSESTree.FunctionExpression { - if (!node) { - return false; - } - - return [ - AST_NODE_TYPES.ArrowFunctionExpression, - AST_NODE_TYPES.FunctionDeclaration, - AST_NODE_TYPES.FunctionExpression, - ].includes(node.type); -} - -function isFunctionType( - node: TSESTree.Node | undefined, -): node is - | TSESTree.TSCallSignatureDeclaration - | TSESTree.TSConstructorType - | TSESTree.TSConstructSignatureDeclaration - | TSESTree.TSEmptyBodyFunctionExpression - | TSESTree.TSFunctionType - | TSESTree.TSMethodSignature { - if (!node) { - return false; - } - - return [ - AST_NODE_TYPES.TSCallSignatureDeclaration, - AST_NODE_TYPES.TSConstructorType, - AST_NODE_TYPES.TSConstructSignatureDeclaration, - AST_NODE_TYPES.TSEmptyBodyFunctionExpression, - AST_NODE_TYPES.TSFunctionType, - AST_NODE_TYPES.TSMethodSignature, - ].includes(node.type); -} - -function isFunctionOrFunctionType( - node: TSESTree.Node | undefined, -): node is - | TSESTree.ArrowFunctionExpression - | TSESTree.FunctionDeclaration - | TSESTree.FunctionExpression - | TSESTree.TSCallSignatureDeclaration - | TSESTree.TSConstructorType - | TSESTree.TSConstructSignatureDeclaration - | TSESTree.TSEmptyBodyFunctionExpression - | TSESTree.TSFunctionType - | TSESTree.TSMethodSignature { - return isFunction(node) || isFunctionType(node); -} +const functionTypes = [ + AST_NODE_TYPES.ArrowFunctionExpression, + AST_NODE_TYPES.FunctionDeclaration, + AST_NODE_TYPES.FunctionExpression, +] as const; +const isFunction = isNodeOfTypes(functionTypes); + +const functionTypeTypes = [ + AST_NODE_TYPES.TSCallSignatureDeclaration, + AST_NODE_TYPES.TSConstructorType, + AST_NODE_TYPES.TSConstructSignatureDeclaration, + AST_NODE_TYPES.TSEmptyBodyFunctionExpression, + AST_NODE_TYPES.TSFunctionType, + AST_NODE_TYPES.TSMethodSignature, +] as const; +const isFunctionType = isNodeOfTypes(functionTypeTypes); + +const isFunctionOrFunctionType = isNodeOfTypes([ + ...functionTypes, + ...functionTypeTypes, +] as const); const isTSFunctionType = isNodeOfType(AST_NODE_TYPES.TSFunctionType); const isTSConstructorType = isNodeOfType(AST_NODE_TYPES.TSConstructorType); -function isClassOrTypeElement( - node: TSESTree.Node | undefined, -): node is TSESTree.ClassElement | TSESTree.TypeElement { - if (!node) { - return false; - } - - return [ - // ClassElement - AST_NODE_TYPES.ClassProperty, - AST_NODE_TYPES.FunctionExpression, - AST_NODE_TYPES.MethodDefinition, - AST_NODE_TYPES.TSAbstractClassProperty, - AST_NODE_TYPES.TSAbstractMethodDefinition, - AST_NODE_TYPES.TSEmptyBodyFunctionExpression, - AST_NODE_TYPES.TSIndexSignature, - // TypeElement - AST_NODE_TYPES.TSCallSignatureDeclaration, - AST_NODE_TYPES.TSConstructSignatureDeclaration, - // AST_NODE_TYPES.TSIndexSignature, - AST_NODE_TYPES.TSMethodSignature, - AST_NODE_TYPES.TSPropertySignature, - ].includes(node.type); -} +const isClassOrTypeElement = isNodeOfTypes([ + // ClassElement + AST_NODE_TYPES.ClassProperty, + AST_NODE_TYPES.FunctionExpression, + AST_NODE_TYPES.MethodDefinition, + AST_NODE_TYPES.TSAbstractClassProperty, + AST_NODE_TYPES.TSAbstractMethodDefinition, + AST_NODE_TYPES.TSEmptyBodyFunctionExpression, + AST_NODE_TYPES.TSIndexSignature, + // TypeElement + AST_NODE_TYPES.TSCallSignatureDeclaration, + AST_NODE_TYPES.TSConstructSignatureDeclaration, + // AST_NODE_TYPES.TSIndexSignature, + AST_NODE_TYPES.TSMethodSignature, + AST_NODE_TYPES.TSPropertySignature, +] as const); /** * Checks if a node is a constructor method. @@ -215,26 +180,13 @@ function isAwaitKeyword( return node?.type === AST_TOKEN_TYPES.Identifier && node.value === 'await'; } -function isLoop( - node: TSESTree.Node | undefined | null, -): node is - | TSESTree.DoWhileStatement - | TSESTree.ForStatement - | TSESTree.ForInStatement - | TSESTree.ForOfStatement - | TSESTree.WhileStatement { - if (!node) { - return false; - } - - return ( - node.type === AST_NODE_TYPES.DoWhileStatement || - node.type === AST_NODE_TYPES.ForStatement || - node.type === AST_NODE_TYPES.ForInStatement || - node.type === AST_NODE_TYPES.ForOfStatement || - node.type === AST_NODE_TYPES.WhileStatement - ); -} +const isLoop = isNodeOfTypes([ + AST_NODE_TYPES.DoWhileStatement, + AST_NODE_TYPES.ForStatement, + AST_NODE_TYPES.ForInStatement, + AST_NODE_TYPES.ForOfStatement, + AST_NODE_TYPES.WhileStatement, +] as const); export { isAwaitExpression, From 021ed2f72c42e48555648e3979293dc78ac55fe4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Oct 2021 10:14:32 -0700 Subject: [PATCH 12/44] chore: bump @commitlint/config-conventional from 13.1.0 to 13.2.0 (#3967) Bumps [@commitlint/config-conventional](https://github.com/conventional-changelog/commitlint) from 13.1.0 to 13.2.0. - [Release notes](https://github.com/conventional-changelog/commitlint/releases) - [Changelog](https://github.com/conventional-changelog/commitlint/blob/master/CHANGELOG.md) - [Commits](https://github.com/conventional-changelog/commitlint/compare/v13.1.0...v13.2.0) --- updated-dependencies: - dependency-name: "@commitlint/config-conventional" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 6a403c3585fe..e4db107245e5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -329,9 +329,9 @@ yargs "^17.0.0" "@commitlint/config-conventional@^13.1.0": - version "13.1.0" - resolved "https://registry.yarnpkg.com/@commitlint/config-conventional/-/config-conventional-13.1.0.tgz#f02871d50c73db0a31b777231f49203b964d9d59" - integrity sha512-zukJXqdr6jtMiVRy3tTHmwgKcUMGfqKDEskRigc5W3k2aYF4gBAtCEjMAJGZgSQE4DMcHeok0pEV2ANmTpb0cw== + version "13.2.0" + resolved "https://registry.yarnpkg.com/@commitlint/config-conventional/-/config-conventional-13.2.0.tgz#2ad24fecc56ae9619dbe0934b98a98b18ace0bec" + integrity sha512-7u7DdOiF+3qSdDlbQGfpvCH8DCQdLFvnI2+VucYmmV7E92iD6t9PBj+UjIoSQCaMAzYp27Vkall78AkcXBh6Xw== dependencies: conventional-changelog-conventionalcommits "^4.3.1" From 131cfbe6db4aa91051eeb9443aa47713a215a60e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Oct 2021 10:14:41 -0700 Subject: [PATCH 13/44] chore: bump pretty-format from 27.2.2 to 27.2.4 (#3968) Bumps [pretty-format](https://github.com/facebook/jest/tree/HEAD/packages/pretty-format) from 27.2.2 to 27.2.4. - [Release notes](https://github.com/facebook/jest/releases) - [Changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md) - [Commits](https://github.com/facebook/jest/commits/v27.2.4/packages/pretty-format) --- updated-dependencies: - dependency-name: pretty-format dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/yarn.lock b/yarn.lock index e4db107245e5..642c168c06cc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1102,18 +1102,7 @@ source-map "^0.6.1" write-file-atomic "^3.0.0" -"@jest/types@^27.0.2", "@jest/types@^27.0.6", "@jest/types@^27.1.1": - version "27.1.1" - resolved "https://registry.yarnpkg.com/@jest/types/-/types-27.1.1.tgz#77a3fc014f906c65752d12123a0134359707c0ad" - integrity sha512-yqJPDDseb0mXgKqmNqypCsb85C22K1aY5+LUxh7syIM9n/b0AsaltxNy+o6tt29VcfGDpYEve175bm3uOhcehA== - dependencies: - "@types/istanbul-lib-coverage" "^2.0.0" - "@types/istanbul-reports" "^3.0.0" - "@types/node" "*" - "@types/yargs" "^16.0.0" - chalk "^4.0.0" - -"@jest/types@^27.2.4": +"@jest/types@^27.0.2", "@jest/types@^27.0.6", "@jest/types@^27.2.4": version "27.2.4" resolved "https://registry.yarnpkg.com/@jest/types/-/types-27.2.4.tgz#2430042a66e00dc5b140c3636f4474d464c21ee8" integrity sha512-IDO2ezTxeMvQAHxzG/ZvEyA47q0aVfzT95rGFl7bZs/Go0aIucvfDbS2rmnoEdXxlLQhcolmoG/wvL/uKx4tKA== @@ -8567,11 +8556,11 @@ prettier@2.3.2: integrity sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ== pretty-format@*, pretty-format@^27.0.0, pretty-format@^27.0.2, pretty-format@^27.0.6, pretty-format@^27.2.4: - version "27.2.2" - resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-27.2.2.tgz#c080f1ab7ac64302e4d438f208596fc649dbeeb3" - integrity sha512-+DdLh+rtaElc2SQOE/YPH8k2g3Rf2OXWEpy06p8Szs3hdVSYD87QOOlYRHWAeb/59XTmeVmRKvDD0svHqf6ycA== + version "27.2.4" + resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-27.2.4.tgz#08ea39c5eab41b082852d7093059a091f6ddc748" + integrity sha512-NUjw22WJHldzxyps2YjLZkUj6q1HvjqFezkB9Y2cklN8NtVZN/kZEXGZdFw4uny3oENzV5EEMESrkI0YDUH8vg== dependencies: - "@jest/types" "^27.1.1" + "@jest/types" "^27.2.4" ansi-regex "^5.0.1" ansi-styles "^5.0.0" react-is "^17.0.1" From 88964645b3426eb4b34a06fe4ab447c624101140 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Oct 2021 11:59:34 -0700 Subject: [PATCH 14/44] chore: bump lint-staged from 11.1.2 to 11.2.0 (#3969) Bumps [lint-staged](https://github.com/okonet/lint-staged) from 11.1.2 to 11.2.0. - [Release notes](https://github.com/okonet/lint-staged/releases) - [Commits](https://github.com/okonet/lint-staged/compare/v11.1.2...v11.2.0) --- updated-dependencies: - dependency-name: lint-staged dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 105 +++++++++++++++++++----------------------------------- 1 file changed, 37 insertions(+), 68 deletions(-) diff --git a/yarn.lock b/yarn.lock index 642c168c06cc..8232ff7dee26 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3252,7 +3252,7 @@ cli-cursor@^3.1.0: dependencies: restore-cursor "^3.1.0" -cli-truncate@^2.1.0: +cli-truncate@2.1.0, cli-truncate@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/cli-truncate/-/cli-truncate-2.1.0.tgz#c39e28bf05edcde5be3b98992a22deed5a2b93c7" integrity sha512-n8fOixwDD6b/ObinzTrp1ZKFzbgvKZvuz/TvejnLn1aQfC6r52XEx85FmuC+3HI+JM7coBRXUvNqEU2PHVrHpg== @@ -3358,10 +3358,10 @@ color-name@~1.1.4: resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== -colorette@^1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.2.2.tgz#cbcc79d5e99caea2dbf10eb3a26fd8b3e6acfa94" - integrity sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w== +colorette@^1.2.2, colorette@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.4.0.tgz#5190fbb87276259a86ad700bff2c6d6faa3fca40" + integrity sha512-Y2oEozpomLn7Q3HFP7dpww7AtMJplbM9lGZP6RDfHqmbeRjiwRg4n6VM6j4KLmRke85uWEI7JqF17f3pqdRA0g== colors@~1.2.1: version "1.2.5" @@ -3388,11 +3388,6 @@ commander@^2.12.1, commander@^2.7.1: resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== -commander@^7.2.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-7.2.0.tgz#a36cb57d0b501ce108e4d20559a150a391d97ab7" - integrity sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw== - commander@^8.2.0: version "8.2.0" resolved "https://registry.yarnpkg.com/commander/-/commander-8.2.0.tgz#37fe2bde301d87d47a53adeff8b5915db1381ca8" @@ -3655,18 +3650,7 @@ cosmiconfig@^5.1.0: js-yaml "^3.13.1" parse-json "^4.0.0" -cosmiconfig@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-7.0.0.tgz#ef9b44d773959cae63ddecd122de23853b60f8d3" - integrity sha512-pondGvTuVYDk++upghXJabWzL6Kxu6f26ljFw64Swq9v6sQPUL3EUlVDV56diOjpCayKihL6hVe8exIACU4XcA== - dependencies: - "@types/parse-json" "^4.0.0" - import-fresh "^3.2.1" - parse-json "^5.0.0" - path-type "^4.0.0" - yaml "^1.10.0" - -cosmiconfig@^7.0.1: +cosmiconfig@^7.0.0, cosmiconfig@^7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-7.0.1.tgz#714d756522cace867867ccb4474c5d01bbae5d6d" integrity sha512-a1YWNUV2HwGimB7dU2s1wUMurNKjpx60HxBB6xUM8Re+2s1g1IIfJvFR0/iCF+XHdE0GMTKTuLR32UQff4TEyQ== @@ -3870,7 +3854,7 @@ debug@3.1.0: dependencies: ms "2.0.0" -debug@4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1: +debug@4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2: version "4.3.2" resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.2.tgz#f0a49c18ac8779e31d4a0c6029dfb76873c7428b" integrity sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw== @@ -4471,10 +4455,10 @@ execa@^1.0.0: signal-exit "^3.0.0" strip-eof "^1.0.0" -execa@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/execa/-/execa-5.0.0.tgz#4029b0007998a841fbd1032e5f4de86a3c1e3376" - integrity sha512-ov6w/2LCiuyO4RLYGdpFGjkcs0wMTgGE8PrkTHikeUy5iJekXyPIKUjifk5CsE0pt7sMCrMZ3YNqoCj6idQOnQ== +execa@^5.0.0, execa@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd" + integrity sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg== dependencies: cross-spawn "^7.0.3" get-stream "^6.0.0" @@ -4672,7 +4656,7 @@ figures@^2.0.0: dependencies: escape-string-regexp "^1.0.5" -figures@^3.0.0, figures@^3.2.0: +figures@^3.0.0: version "3.2.0" resolved "https://registry.yarnpkg.com/figures/-/figures-3.2.0.tgz#625c18bd293c604dc4a8ddb2febf0c88341746af" integrity sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg== @@ -5921,11 +5905,6 @@ is-typedarray@^1.0.0, is-typedarray@~1.0.0: resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" integrity sha1-5HnICFjfDBsR3dppQPlgEfzaSpo= -is-unicode-supported@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz#3f26c76a809593b52bfa2ecb5710ed2779b522a7" - integrity sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw== - is-utf8@^0.2.0, is-utf8@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" @@ -7128,34 +7107,32 @@ linkify-it@^3.0.1: uc.micro "^1.0.1" lint-staged@^11.0.0: - version "11.1.2" - resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-11.1.2.tgz#4dd78782ae43ee6ebf2969cad9af67a46b33cd90" - integrity sha512-6lYpNoA9wGqkL6Hew/4n1H6lRqF3qCsujVT0Oq5Z4hiSAM7S6NksPJ3gnr7A7R52xCtiZMcEUNNQ6d6X5Bvh9w== + version "11.2.0" + resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-11.2.0.tgz#6b9774a74b3eb4bef5c59fb6475bff84d6853008" + integrity sha512-0KIcRuO4HQS2Su7qWtjrfTXgSklvyIb9Fk9qVWRZkGHa5S81Vj6WBbs+ogQBvHUwLJYq1eQ4R+H82GSak4OM7w== dependencies: - chalk "^4.1.1" - cli-truncate "^2.1.0" - commander "^7.2.0" - cosmiconfig "^7.0.0" - debug "^4.3.1" + cli-truncate "2.1.0" + colorette "^1.4.0" + commander "^8.2.0" + cosmiconfig "^7.0.1" + debug "^4.3.2" enquirer "^2.3.6" - execa "^5.0.0" - listr2 "^3.8.2" - log-symbols "^4.1.0" + execa "^5.1.1" + listr2 "^3.12.2" micromatch "^4.0.4" normalize-path "^3.0.0" please-upgrade-node "^3.2.0" string-argv "0.3.1" - stringify-object "^3.3.0" + stringify-object "3.3.0" + supports-color "8.1.1" -listr2@^3.8.2: - version "3.8.2" - resolved "https://registry.yarnpkg.com/listr2/-/listr2-3.8.2.tgz#99b138ad1cfb08f1b0aacd422972e49b2d814b99" - integrity sha512-E28Fw7Zd3HQlCJKzb9a8C8M0HtFWQeucE+S8YrSrqZObuCLPRHMRrR8gNmYt65cU9orXYHwvN5agXC36lYt7VQ== +listr2@^3.12.2: + version "3.12.2" + resolved "https://registry.yarnpkg.com/listr2/-/listr2-3.12.2.tgz#2d55cc627111603ad4768a9e87c9c7bb9b49997e" + integrity sha512-64xC2CJ/As/xgVI3wbhlPWVPx0wfTqbUAkpb7bjDi0thSWMqrf07UFhrfsGoo8YSXmF049Rp9C0cjLC8rZxK9A== dependencies: - chalk "^4.1.1" cli-truncate "^2.1.0" - figures "^3.2.0" - indent-string "^4.0.0" + colorette "^1.4.0" log-update "^4.0.0" p-map "^4.0.0" rxjs "^6.6.7" @@ -7309,14 +7286,6 @@ lodash@4.x, lodash@^4.11.2, lodash@^4.17.12, lodash@^4.17.15, lodash@^4.17.19, l resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== -log-symbols@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-4.1.0.tgz#3fbdbb95b4683ac9fc785111e792e558d4abd503" - integrity sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg== - dependencies: - chalk "^4.1.0" - is-unicode-supported "^0.1.0" - log-update@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/log-update/-/log-update-4.0.0.tgz#589ecd352471f2a1c0c570287543a64dfd20e0a1" @@ -9544,7 +9513,7 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" -stringify-object@^3.3.0: +stringify-object@3.3.0: version "3.3.0" resolved "https://registry.yarnpkg.com/stringify-object/-/stringify-object-3.3.0.tgz#703065aefca19300d3ce88af4f5b3956d7556629" integrity sha512-rHqiFh1elqCQ9WPLIC8I0Q/g/wj5J1eMkyoiD6eoQApWHP0FtlK7rqnhmabL5VUY9JQCcqwwvlOaSuutekgyrw== @@ -9646,6 +9615,13 @@ strong-log-transformer@^2.0.0: minimist "^1.2.0" through "^2.3.4" +supports-color@8.1.1, supports-color@^8.0.0: + version "8.1.1" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" + integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== + dependencies: + has-flag "^4.0.0" + supports-color@^5.3.0: version "5.5.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" @@ -9660,13 +9636,6 @@ supports-color@^7.0.0, supports-color@^7.1.0: dependencies: has-flag "^4.0.0" -supports-color@^8.0.0: - version "8.1.1" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" - integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== - dependencies: - has-flag "^4.0.0" - supports-hyperlinks@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/supports-hyperlinks/-/supports-hyperlinks-2.1.0.tgz#f663df252af5f37c5d49bbd7eeefa9e0b9e59e47" From d2568561d0417fdfbdfd964ad942f9d00434af73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Thu, 7 Oct 2021 06:25:09 +0200 Subject: [PATCH 15/44] fix(experimental-utils): fix `isSetter`'s return type (#3975) --- packages/experimental-utils/src/ast-utils/predicates.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/experimental-utils/src/ast-utils/predicates.ts b/packages/experimental-utils/src/ast-utils/predicates.ts index 059437ae1665..9c274e09c82b 100644 --- a/packages/experimental-utils/src/ast-utils/predicates.ts +++ b/packages/experimental-utils/src/ast-utils/predicates.ts @@ -155,7 +155,7 @@ const isConstructor = isNodeOfTypeWithConditions( */ function isSetter( node: TSESTree.Node | undefined, -): node is TSESTree.MethodDefinition | TSESTree.Property { +): node is (TSESTree.MethodDefinition | TSESTree.Property) & { kind: 'set' } { return ( !!node && (node.type === AST_NODE_TYPES.MethodDefinition || From 9aea46abcf867f3512ccb0c182fa3ff8284b3c40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Thu, 7 Oct 2021 06:26:40 +0200 Subject: [PATCH 16/44] chore(experimental-utils): simplify `isTypeAssertion` predicate (#3973) --- .../src/ast-utils/predicates.ts | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/packages/experimental-utils/src/ast-utils/predicates.ts b/packages/experimental-utils/src/ast-utils/predicates.ts index 9c274e09c82b..5044dfcca6ef 100644 --- a/packages/experimental-utils/src/ast-utils/predicates.ts +++ b/packages/experimental-utils/src/ast-utils/predicates.ts @@ -6,6 +6,7 @@ const isNodeOfType = node: TSESTree.Node | null | undefined, ): node is TSESTree.Node & { type: NodeType } => node?.type === nodeType; + const isNodeOfTypes = (nodeTypes: NodeTypes) => ( @@ -85,17 +86,10 @@ const isLogicalOrOperator = isNodeOfTypeWithConditions( * x * ``` */ -function isTypeAssertion( - node: TSESTree.Node | undefined | null, -): node is TSESTree.TSAsExpression | TSESTree.TSTypeAssertion { - if (!node) { - return false; - } - return ( - node.type === AST_NODE_TYPES.TSAsExpression || - node.type === AST_NODE_TYPES.TSTypeAssertion - ); -} +const isTypeAssertion = isNodeOfTypes([ + AST_NODE_TYPES.TSAsExpression, + AST_NODE_TYPES.TSTypeAssertion, +] as const); const isVariableDeclarator = isNodeOfType(AST_NODE_TYPES.VariableDeclarator); From 0acfafcc655e28dcfc05a5caa567c0d0217ee7ad Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sat, 21 Aug 2021 18:20:55 -0400 Subject: [PATCH 17/44] feat(eslint-plugin): [comma-dangle] align schema with ESLint v8 (#3768) --- packages/eslint-plugin/src/rules/comma-dangle.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-plugin/src/rules/comma-dangle.ts b/packages/eslint-plugin/src/rules/comma-dangle.ts index e0e06a6711d7..1e5049e3fea5 100644 --- a/packages/eslint-plugin/src/rules/comma-dangle.ts +++ b/packages/eslint-plugin/src/rules/comma-dangle.ts @@ -80,6 +80,7 @@ export default util.createRule({ ], }, ], + additionalProperties: false, }, fixable: 'code', messages: baseRule.meta.messages, From b63013adf0239d98ca9368d73fda057f3b0e57f9 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sat, 21 Aug 2021 18:39:56 -0400 Subject: [PATCH 18/44] chore: bump Node to ESLint 8.0 ranges (#3767) --- .github/workflows/ci.yml | 15 +++++++++++---- package.json | 2 +- packages/ast-spec/package.json | 2 +- packages/eslint-plugin-tslint/package.json | 2 +- packages/eslint-plugin/package.json | 2 +- packages/experimental-utils/package.json | 2 +- packages/parser/package.json | 2 +- packages/scope-manager/package.json | 2 +- packages/types/package.json | 2 +- packages/typescript-estree/package.json | 2 +- packages/visitor-keys/package.json | 2 +- 11 files changed, 21 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 680e6437cceb..c77329b856db 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ env: NX_BRANCH: ${{ github.event.number }} NX_RUN_GROUP: ${{ github.run_id }} # Added the - at the end to function as a separator to improve readability in the PR comment from the Nx cloud app - NX_CLOUD_ENV_NAME: "Node 12.x -" + NX_CLOUD_ENV_NAME: 'Node 12.x -' jobs: typecheck: @@ -224,10 +224,10 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [10.x, 14.x] + node-version: [12.x, 14.x, 16.x] env: # Added the - at the end to function as a separator to improve readability in the PR comment from the Nx cloud app - NX_CLOUD_ENV_NAME: "Node ${{ matrix.node-version }} -" + NX_CLOUD_ENV_NAME: 'Node ${{ matrix.node-version }} -' steps: - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node-version }} @@ -296,7 +296,14 @@ jobs: publish_canary_version: name: Publish the latest code as a canary version runs-on: ubuntu-latest - needs: [typecheck, test_on_primary_node_version, unit_tests_on_other_node_versions, linting_and_style, integration_tests] + needs: + [ + typecheck, + test_on_primary_node_version, + unit_tests_on_other_node_versions, + linting_and_style, + integration_tests, + ] if: github.repository == 'typescript-eslint/typescript-eslint' && github.ref == 'refs/heads/master' steps: - uses: actions/checkout@v2 diff --git a/package.json b/package.json index b677dcf76ed3..0a006d6cc617 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ } }, "engines": { - "node": "^10.12.0 || >=12.0.0" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "devDependencies": { "@babel/code-frame": "^7.12.13", diff --git a/packages/ast-spec/package.json b/packages/ast-spec/package.json index 1f08d71f2a81..ccc66b7116f3 100644 --- a/packages/ast-spec/package.json +++ b/packages/ast-spec/package.json @@ -9,7 +9,7 @@ "estree" ], "engines": { - "node": "^8.10.0 || ^10.13.0 || >=11.10.1" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "files": [ "dist", diff --git a/packages/eslint-plugin-tslint/package.json b/packages/eslint-plugin-tslint/package.json index 571092f90253..2a1a36de35ed 100644 --- a/packages/eslint-plugin-tslint/package.json +++ b/packages/eslint-plugin-tslint/package.json @@ -11,7 +11,7 @@ "tslint" ], "engines": { - "node": "^10.12.0 || >=12.0.0" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "files": [ "dist", diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index 5109b38af545..d968a0caf9bf 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -9,7 +9,7 @@ "typescript" ], "engines": { - "node": "^10.12.0 || >=12.0.0" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "files": [ "dist", diff --git a/packages/experimental-utils/package.json b/packages/experimental-utils/package.json index 932a98f8cf57..ed9b0d3dc914 100644 --- a/packages/experimental-utils/package.json +++ b/packages/experimental-utils/package.json @@ -8,7 +8,7 @@ "estree" ], "engines": { - "node": "^10.12.0 || >=12.0.0" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "files": [ "dist", diff --git a/packages/parser/package.json b/packages/parser/package.json index b3e78b7fb870..080af86165f0 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -10,7 +10,7 @@ "LICENSE" ], "engines": { - "node": "^10.12.0 || >=12.0.0" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "repository": { "type": "git", diff --git a/packages/scope-manager/package.json b/packages/scope-manager/package.json index 121285aa5ad4..ac2c2a335f9b 100644 --- a/packages/scope-manager/package.json +++ b/packages/scope-manager/package.json @@ -8,7 +8,7 @@ "estree" ], "engines": { - "node": "^8.10.0 || ^10.13.0 || >=11.10.1" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "files": [ "dist", diff --git a/packages/types/package.json b/packages/types/package.json index f8e56a099e0c..4cb0ba110bda 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -8,7 +8,7 @@ "estree" ], "engines": { - "node": "^8.10.0 || ^10.13.0 || >=11.10.1" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "files": [ "dist", diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index 726092aeda45..2d70c3f50cd1 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -10,7 +10,7 @@ "LICENSE" ], "engines": { - "node": "^10.12.0 || >=12.0.0" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "repository": { "type": "git", diff --git a/packages/visitor-keys/package.json b/packages/visitor-keys/package.json index a4863ea2ad17..aed915b8613d 100644 --- a/packages/visitor-keys/package.json +++ b/packages/visitor-keys/package.json @@ -8,7 +8,7 @@ "estree" ], "engines": { - "node": "^8.10.0 || ^10.13.0 || >=11.10.1" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "files": [ "dist", From dc5a0f5104b400f4422b8d67ecfc6cc7a32613a2 Mon Sep 17 00:00:00 2001 From: Sosuke Suzuki Date: Sun, 22 Aug 2021 09:35:58 +0900 Subject: [PATCH 19/44] fix(typescript-estree): change `source` of ExportNamedDeclaration to Literal from Expression (#3763) * fix(typescript-estree): change of ExportNamedDeclaration to Literal from Expression * fix(typescript-estree): add assertion for module specifier --- .../ExportNamedDeclaration/spec.ts | 4 +- .../invalid-export-module-specifier.src.js | 1 + packages/typescript-estree/src/convert.ts | 21 +- .../semantic-diagnostics-enabled.test.ts.snap | 21 +- ...nvalid-export-module-specifier.src.js.shot | 10 + ...mport-default-module-specifier.src.js.shot | 190 +-------------- ...nvalid-import-module-specifier.src.js.shot | 227 +----------------- 7 files changed, 58 insertions(+), 416 deletions(-) create mode 100644 packages/shared-fixtures/fixtures/javascript/modules/invalid-export-module-specifier.src.js create mode 100644 packages/typescript-estree/tests/snapshots/javascript/modules/invalid-export-module-specifier.src.js.shot diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/spec.ts b/packages/ast-spec/src/declaration/ExportNamedDeclaration/spec.ts index bf4d9ea86d2c..a8f476477a7b 100644 --- a/packages/ast-spec/src/declaration/ExportNamedDeclaration/spec.ts +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/spec.ts @@ -2,13 +2,13 @@ import type { AST_NODE_TYPES } from '../../ast-node-types'; import type { BaseNode } from '../../base/BaseNode'; import type { ExportSpecifier } from '../../special/ExportSpecifier/spec'; import type { ExportDeclaration } from '../../unions/ExportDeclaration'; -import type { Expression } from '../../unions/Expression'; +import type { Literal } from '../../unions/Literal'; import type { ExportKind } from '../ExportAndImportKind'; export interface ExportNamedDeclaration extends BaseNode { type: AST_NODE_TYPES.ExportNamedDeclaration; declaration: ExportDeclaration | null; specifiers: ExportSpecifier[]; - source: Expression | null; + source: Literal | null; exportKind: ExportKind; } diff --git a/packages/shared-fixtures/fixtures/javascript/modules/invalid-export-module-specifier.src.js b/packages/shared-fixtures/fixtures/javascript/modules/invalid-export-module-specifier.src.js new file mode 100644 index 000000000000..29faf851822c --- /dev/null +++ b/packages/shared-fixtures/fixtures/javascript/modules/invalid-export-module-specifier.src.js @@ -0,0 +1 @@ +export { foo } from bar; diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index 8170cedad3c2..86ade612d16a 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -728,6 +728,21 @@ export class Converter { } } + private assertModuleSpecifier( + node: ts.ExportDeclaration | ts.ImportDeclaration, + ): void { + if ( + node.moduleSpecifier && + node.moduleSpecifier.kind !== SyntaxKind.StringLiteral + ) { + throw createError( + this.ast, + node.moduleSpecifier.pos, + 'Module specifier must be a string literal.', + ); + } + } + /** * Converts a TypeScript node into an ESTree node. * The core of the conversion logic: @@ -1694,6 +1709,8 @@ export class Converter { }); case SyntaxKind.ImportDeclaration: { + this.assertModuleSpecifier(node); + const result = this.createNode(node, { type: AST_NODE_TYPES.ImportDeclaration, source: this.convertChild(node.moduleSpecifier), @@ -1752,7 +1769,8 @@ export class Converter { }); } - case SyntaxKind.ExportDeclaration: + case SyntaxKind.ExportDeclaration: { + this.assertModuleSpecifier(node); if (node.exportClause?.kind === SyntaxKind.NamedExports) { return this.createNode(node, { type: AST_NODE_TYPES.ExportNamedDeclaration, @@ -1779,6 +1797,7 @@ export class Converter { : null, }); } + } case SyntaxKind.ExportSpecifier: return this.createNode(node, { diff --git a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.test.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.test.ts.snap index ce8d6b5cc6ec..031e7f61e120 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.test.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.test.ts.snap @@ -908,6 +908,15 @@ TSError { } `; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/modules/invalid-export-module-specifier.src 1`] = ` +TSError { + "column": 19, + "index": 19, + "lineNumber": 1, + "message": "Module specifier must be a string literal.", +} +`; + exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/modules/invalid-export-named-default.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/modules/invalid-export-named-extra-comma.src 1`] = ` @@ -966,10 +975,10 @@ TSError { exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/modules/invalid-import-default-module-specifier.src 1`] = ` TSError { - "column": 16, - "index": 16, + "column": 15, + "index": 15, "lineNumber": 1, - "message": "String literal expected.", + "message": "Module specifier must be a string literal.", } `; @@ -984,10 +993,10 @@ TSError { exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/modules/invalid-import-module-specifier.src 1`] = ` TSError { - "column": 18, - "index": 18, + "column": 17, + "index": 17, "lineNumber": 1, - "message": "String literal expected.", + "message": "Module specifier must be a string literal.", } `; diff --git a/packages/typescript-estree/tests/snapshots/javascript/modules/invalid-export-module-specifier.src.js.shot b/packages/typescript-estree/tests/snapshots/javascript/modules/invalid-export-module-specifier.src.js.shot new file mode 100644 index 000000000000..5467f678c18f --- /dev/null +++ b/packages/typescript-estree/tests/snapshots/javascript/modules/invalid-export-module-specifier.src.js.shot @@ -0,0 +1,10 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`javascript modules invalid-export-module-specifier.src 1`] = ` +TSError { + "column": 19, + "index": 19, + "lineNumber": 1, + "message": "Module specifier must be a string literal.", +} +`; diff --git a/packages/typescript-estree/tests/snapshots/javascript/modules/invalid-import-default-module-specifier.src.js.shot b/packages/typescript-estree/tests/snapshots/javascript/modules/invalid-import-default-module-specifier.src.js.shot index 11bb8f0abb0c..0754b716ae59 100644 --- a/packages/typescript-estree/tests/snapshots/javascript/modules/invalid-import-default-module-specifier.src.js.shot +++ b/packages/typescript-estree/tests/snapshots/javascript/modules/invalid-import-default-module-specifier.src.js.shot @@ -1,190 +1,10 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`javascript modules invalid-import-default-module-specifier.src 1`] = ` -Object { - "body": Array [ - Object { - "importKind": "value", - "loc": Object { - "end": Object { - "column": 20, - "line": 1, - }, - "start": Object { - "column": 0, - "line": 1, - }, - }, - "range": Array [ - 0, - 20, - ], - "source": Object { - "loc": Object { - "end": Object { - "column": 19, - "line": 1, - }, - "start": Object { - "column": 16, - "line": 1, - }, - }, - "name": "bar", - "range": Array [ - 16, - 19, - ], - "type": "Identifier", - }, - "specifiers": Array [ - Object { - "loc": Object { - "end": Object { - "column": 10, - "line": 1, - }, - "start": Object { - "column": 7, - "line": 1, - }, - }, - "local": Object { - "loc": Object { - "end": Object { - "column": 10, - "line": 1, - }, - "start": Object { - "column": 7, - "line": 1, - }, - }, - "name": "foo", - "range": Array [ - 7, - 10, - ], - "type": "Identifier", - }, - "range": Array [ - 7, - 10, - ], - "type": "ImportDefaultSpecifier", - }, - ], - "type": "ImportDeclaration", - }, - ], - "comments": Array [], - "loc": Object { - "end": Object { - "column": 0, - "line": 2, - }, - "start": Object { - "column": 0, - "line": 1, - }, - }, - "range": Array [ - 0, - 21, - ], - "sourceType": "module", - "tokens": Array [ - Object { - "loc": Object { - "end": Object { - "column": 6, - "line": 1, - }, - "start": Object { - "column": 0, - "line": 1, - }, - }, - "range": Array [ - 0, - 6, - ], - "type": "Keyword", - "value": "import", - }, - Object { - "loc": Object { - "end": Object { - "column": 10, - "line": 1, - }, - "start": Object { - "column": 7, - "line": 1, - }, - }, - "range": Array [ - 7, - 10, - ], - "type": "Identifier", - "value": "foo", - }, - Object { - "loc": Object { - "end": Object { - "column": 15, - "line": 1, - }, - "start": Object { - "column": 11, - "line": 1, - }, - }, - "range": Array [ - 11, - 15, - ], - "type": "Identifier", - "value": "from", - }, - Object { - "loc": Object { - "end": Object { - "column": 19, - "line": 1, - }, - "start": Object { - "column": 16, - "line": 1, - }, - }, - "range": Array [ - 16, - 19, - ], - "type": "Identifier", - "value": "bar", - }, - Object { - "loc": Object { - "end": Object { - "column": 20, - "line": 1, - }, - "start": Object { - "column": 19, - "line": 1, - }, - }, - "range": Array [ - 19, - 20, - ], - "type": "Punctuator", - "value": ";", - }, - ], - "type": "Program", +TSError { + "column": 15, + "index": 15, + "lineNumber": 1, + "message": "Module specifier must be a string literal.", } `; diff --git a/packages/typescript-estree/tests/snapshots/javascript/modules/invalid-import-module-specifier.src.js.shot b/packages/typescript-estree/tests/snapshots/javascript/modules/invalid-import-module-specifier.src.js.shot index f810bb25d0c6..d456d2e46791 100644 --- a/packages/typescript-estree/tests/snapshots/javascript/modules/invalid-import-module-specifier.src.js.shot +++ b/packages/typescript-estree/tests/snapshots/javascript/modules/invalid-import-module-specifier.src.js.shot @@ -1,227 +1,10 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`javascript modules invalid-import-module-specifier.src 1`] = ` -Object { - "body": Array [ - Object { - "declaration": null, - "exportKind": "value", - "loc": Object { - "end": Object { - "column": 21, - "line": 1, - }, - "start": Object { - "column": 0, - "line": 1, - }, - }, - "range": Array [ - 0, - 21, - ], - "source": Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 1, - }, - "start": Object { - "column": 18, - "line": 1, - }, - }, - "name": "bar", - "range": Array [ - 18, - 21, - ], - "type": "Identifier", - }, - "specifiers": Array [ - Object { - "exported": Object { - "loc": Object { - "end": Object { - "column": 11, - "line": 1, - }, - "start": Object { - "column": 8, - "line": 1, - }, - }, - "name": "foo", - "range": Array [ - 8, - 11, - ], - "type": "Identifier", - }, - "loc": Object { - "end": Object { - "column": 11, - "line": 1, - }, - "start": Object { - "column": 8, - "line": 1, - }, - }, - "local": Object { - "loc": Object { - "end": Object { - "column": 11, - "line": 1, - }, - "start": Object { - "column": 8, - "line": 1, - }, - }, - "name": "foo", - "range": Array [ - 8, - 11, - ], - "type": "Identifier", - }, - "range": Array [ - 8, - 11, - ], - "type": "ExportSpecifier", - }, - ], - "type": "ExportNamedDeclaration", - }, - ], - "comments": Array [], - "loc": Object { - "end": Object { - "column": 0, - "line": 2, - }, - "start": Object { - "column": 0, - "line": 1, - }, - }, - "range": Array [ - 0, - 22, - ], - "sourceType": "module", - "tokens": Array [ - Object { - "loc": Object { - "end": Object { - "column": 6, - "line": 1, - }, - "start": Object { - "column": 0, - "line": 1, - }, - }, - "range": Array [ - 0, - 6, - ], - "type": "Keyword", - "value": "export", - }, - Object { - "loc": Object { - "end": Object { - "column": 8, - "line": 1, - }, - "start": Object { - "column": 7, - "line": 1, - }, - }, - "range": Array [ - 7, - 8, - ], - "type": "Punctuator", - "value": "{", - }, - Object { - "loc": Object { - "end": Object { - "column": 11, - "line": 1, - }, - "start": Object { - "column": 8, - "line": 1, - }, - }, - "range": Array [ - 8, - 11, - ], - "type": "Identifier", - "value": "foo", - }, - Object { - "loc": Object { - "end": Object { - "column": 12, - "line": 1, - }, - "start": Object { - "column": 11, - "line": 1, - }, - }, - "range": Array [ - 11, - 12, - ], - "type": "Punctuator", - "value": "}", - }, - Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 1, - }, - "start": Object { - "column": 13, - "line": 1, - }, - }, - "range": Array [ - 13, - 17, - ], - "type": "Identifier", - "value": "from", - }, - Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 1, - }, - "start": Object { - "column": 18, - "line": 1, - }, - }, - "range": Array [ - 18, - 21, - ], - "type": "Identifier", - "value": "bar", - }, - ], - "type": "Program", +TSError { + "column": 17, + "index": 17, + "lineNumber": 1, + "message": "Module specifier must be a string literal.", } `; From 165a507970d8e4a0ed12abdd5f0d892f7de83ffe Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sat, 21 Aug 2021 20:37:20 -0400 Subject: [PATCH 20/44] feat(experimental-utils): remove `getComments` from `ESLint` `SourceCode` types (#3766) --- packages/experimental-utils/src/ts-eslint/SourceCode.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/packages/experimental-utils/src/ts-eslint/SourceCode.ts b/packages/experimental-utils/src/ts-eslint/SourceCode.ts index 582f643311ad..669ad7113c92 100644 --- a/packages/experimental-utils/src/ts-eslint/SourceCode.ts +++ b/packages/experimental-utils/src/ts-eslint/SourceCode.ts @@ -245,15 +245,6 @@ declare class SourceCodeBase extends TokenStore { * @returns An array of comment nodes. */ getAllComments(): TSESTree.Comment[]; - /** - * Gets all comments for the given node. - * @param node The AST node to get the comments for. - * @returns An object containing a leading and trailing array of comments indexed by their position. - */ - getComments(node: TSESTree.Node): { - leading: TSESTree.Comment[]; - trailing: TSESTree.Comment[]; - }; /** * Converts a (line, column) pair into a range index. * @param loc A line/column location From 4ca62aee6681d706e762a8db727541ca204364f2 Mon Sep 17 00:00:00 2001 From: Yosuke Ota Date: Sun, 22 Aug 2021 09:59:02 +0900 Subject: [PATCH 21/44] feat: support ESLint v8 (#3737) --- .cspell.json | 1 + .eslintrc.js | 2 +- .github/workflows/ci.yml | 24 ++ package.json | 6 +- .../eslint-plugin-internal/jest.config.js | 1 + .../src/rules/no-poorly-typed-ts-props.ts | 1 + packages/eslint-plugin-tslint/jest.config.js | 1 + packages/eslint-plugin-tslint/package.json | 2 +- packages/eslint-plugin/jest.config.js | 1 + packages/eslint-plugin/package.json | 2 +- .../eslint-plugin/src/rules/brace-style.ts | 5 +- .../eslint-plugin/src/rules/comma-dangle.ts | 5 +- .../eslint-plugin/src/rules/dot-notation.ts | 5 +- packages/eslint-plugin/src/rules/indent.ts | 5 +- .../src/rules/init-declarations.ts | 5 +- .../src/rules/keyword-spacing.ts | 5 +- .../src/rules/lines-between-class-members.ts | 5 +- .../rules/no-confusing-non-null-assertion.ts | 1 + .../src/rules/no-confusing-void-expression.ts | 1 + .../src/rules/no-dupe-class-members.ts | 42 +++- .../src/rules/no-duplicate-imports.ts | 5 +- .../src/rules/no-empty-function.ts | 5 +- .../src/rules/no-empty-interface.ts | 1 + .../src/rules/no-explicit-any.ts | 1 + .../src/rules/no-extra-parens.ts | 5 +- .../eslint-plugin/src/rules/no-extra-semi.ts | 13 +- .../src/rules/no-floating-promises.ts | 1 + .../src/rules/no-implicit-any-catch.ts | 1 + .../src/rules/no-invalid-this.ts | 5 +- .../eslint-plugin/src/rules/no-loop-func.ts | 5 +- .../src/rules/no-loss-of-precision.ts | 20 +- .../src/rules/no-magic-numbers.ts | 5 +- .../no-non-null-asserted-optional-chain.ts | 1 + .../src/rules/no-non-null-assertion.ts | 1 + .../src/rules/no-unused-expressions.ts | 5 +- .../src/rules/no-useless-constructor.ts | 5 +- .../src/rules/object-curly-spacing.ts | 4 +- .../src/rules/prefer-as-const.ts | 1 + .../src/rules/prefer-enum-initializers.ts | 1 + .../src/rules/prefer-nullish-coalescing.ts | 1 + .../src/rules/prefer-optional-chain.ts | 1 + packages/eslint-plugin/src/rules/quotes.ts | 5 +- .../eslint-plugin/src/rules/return-await.ts | 1 + packages/eslint-plugin/src/rules/semi.ts | 5 +- .../sort-type-union-intersection-members.ts | 1 + .../src/rules/space-infix-ops.ts | 5 +- .../src/rules/strict-boolean-expressions.ts | 1 + .../src/rules/switch-exhaustiveness-check.ts | 1 + .../src/util/collectUnusedVariables.ts | 2 +- .../src/util/getESLintCoreRule.ts | 62 +++++ .../tests/eslint-rules/arrow-parens.test.ts | 4 +- .../tests/eslint-rules/no-dupe-args.test.ts | 4 +- .../eslint-rules/no-implicit-globals.test.ts | 3 +- .../no-restricted-globals.test.ts | 4 +- .../tests/eslint-rules/no-undef.test.ts | 4 +- .../tests/eslint-rules/prefer-const.test.ts | 4 +- .../tests/eslint-rules/strict.test.ts | 4 +- .../tests/rules/array-type.test.ts | 2 +- .../tests/rules/no-duplicate-imports.test.ts | 8 - .../tests/rules/require-await.test.ts | 2 +- .../eslint-plugin/typings/eslint-rules.d.ts | 18 +- packages/experimental-utils/jest.config.js | 1 + .../eslint-utils/batchedSingleLineTests.ts | 2 +- .../src/ts-eslint/CLIEngine.ts | 4 +- .../experimental-utils/src/ts-eslint/Rule.ts | 4 + packages/parser/jest.config.js | 3 + packages/parser/package.json | 2 +- patches/eslint-plugin-import+2.24.2.patch | 14 ++ patches/eslint-plugin-jest+24.4.0.patch | 48 ++++ tests/jest-resolver.js | 15 ++ tsconfig.eslint.json | 7 +- yarn.lock | 221 +++++++++++------- 72 files changed, 508 insertions(+), 160 deletions(-) create mode 100644 packages/eslint-plugin/src/util/getESLintCoreRule.ts create mode 100644 patches/eslint-plugin-import+2.24.2.patch create mode 100644 patches/eslint-plugin-jest+24.4.0.patch create mode 100644 tests/jest-resolver.js diff --git a/.cspell.json b/.cspell.json index c74d69186b91..c4de52f54328 100644 --- a/.cspell.json +++ b/.cspell.json @@ -47,6 +47,7 @@ "bigint", "bivariant", "blockless", + "camelcase", "codebases", "Codecov", "contravariant", diff --git a/.eslintrc.js b/.eslintrc.js index 1ef4f373c8d4..1f053bd17d76 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -86,7 +86,7 @@ module.exports = { '@typescript-eslint/internal/prefer-ast-types-enum': 'error', // - // eslint base + // eslint-base // curly: ['error', 'all'], diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c77329b856db..3ce54875bc2e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,6 +47,10 @@ jobs: yarn --ignore-engines --frozen-lockfile --ignore-scripts yarn check-clean-workspace-after-install + - name: Patch Dependencies + run: | + yarn patch-package + - name: Build run: | yarn build @@ -89,6 +93,10 @@ jobs: yarn --ignore-engines --frozen-lockfile --ignore-scripts yarn check-clean-workspace-after-install + - name: Patch Dependencies + run: | + yarn patch-package + - name: Build run: | yarn build @@ -167,6 +175,10 @@ jobs: yarn --ignore-engines --frozen-lockfile --ignore-scripts yarn check-clean-workspace-after-install + - name: Patch Dependencies + run: | + yarn patch-package + - name: Build run: | yarn build @@ -210,6 +222,10 @@ jobs: yarn --ignore-engines --frozen-lockfile --ignore-scripts yarn check-clean-workspace-after-install + - name: Patch Dependencies + run: | + yarn patch-package + - name: Build run: | yarn build @@ -252,6 +268,10 @@ jobs: yarn --ignore-engines --frozen-lockfile --ignore-scripts yarn check-clean-workspace-after-install + - name: Patch Dependencies + run: | + yarn patch-package + - name: Build run: | yarn build @@ -334,6 +354,10 @@ jobs: yarn --ignore-engines --frozen-lockfile --ignore-scripts yarn check-clean-workspace-after-install + - name: Patch Dependencies + run: | + yarn patch-package + - name: Build run: | yarn build diff --git a/package.json b/package.json index 0a006d6cc617..a6b365cfc54a 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "lint-markdown-fix": "yarn lint-markdown --fix", "lint-markdown": "markdownlint \"**/*.md\" --config=.markdownlint.json --ignore-path=.markdownlintignore", "lint": "eslint . --ext .js,.ts", - "postinstall": "yarn husky install && yarn build", + "postinstall": "patch-package && yarn husky install && yarn build", "pre-commit": "yarn lint-staged", "pre-push": "yarn check-format", "test": "nx run-many --target=test --all --parallel", @@ -100,7 +100,8 @@ "cspell": "^5.5.2", "cz-conventional-changelog": "^3.3.0", "downlevel-dts": "^0.7.0", - "eslint": "^7.27.0", + "enhanced-resolve": "^5.8.2", + "eslint": "^8.0.0-0", "eslint-plugin-eslint-comments": "^3.2.0", "eslint-plugin-eslint-plugin": "^3.0.3", "eslint-plugin-import": "^2.23.4", @@ -115,6 +116,7 @@ "make-dir": "^3.1.0", "markdownlint-cli": "^0.28.1", "node-fetch": "^3.0.0", + "patch-package": "^6.4.7", "prettier": "2.3.2", "pretty-format": "^27.0.2", "rimraf": "^3.0.2", diff --git a/packages/eslint-plugin-internal/jest.config.js b/packages/eslint-plugin-internal/jest.config.js index cce8d6c61baf..bf4e270e3760 100644 --- a/packages/eslint-plugin-internal/jest.config.js +++ b/packages/eslint-plugin-internal/jest.config.js @@ -3,6 +3,7 @@ // @ts-check /** @type {import('@jest/types').Config.InitialOptions} */ module.exports = { + resolver: '/../../tests/jest-resolver.js', globals: { 'ts-jest': { isolatedModules: true, diff --git a/packages/eslint-plugin-internal/src/rules/no-poorly-typed-ts-props.ts b/packages/eslint-plugin-internal/src/rules/no-poorly-typed-ts-props.ts index 96c1405c73f0..8ce331b4dad1 100644 --- a/packages/eslint-plugin-internal/src/rules/no-poorly-typed-ts-props.ts +++ b/packages/eslint-plugin-internal/src/rules/no-poorly-typed-ts-props.ts @@ -44,6 +44,7 @@ export default createRule({ requiresTypeChecking: true, }, fixable: 'code', + hasSuggestions: true, schema: [], messages: { doNotUse: 'Do not use {{type}}.{{property}} because it is poorly typed.', diff --git a/packages/eslint-plugin-tslint/jest.config.js b/packages/eslint-plugin-tslint/jest.config.js index 76cf71504591..37b87a10d75b 100644 --- a/packages/eslint-plugin-tslint/jest.config.js +++ b/packages/eslint-plugin-tslint/jest.config.js @@ -3,6 +3,7 @@ // @ts-check /** @type {import('@jest/types').Config.InitialOptions} */ module.exports = { + resolver: '/../../tests/jest-resolver.js', globals: { 'ts-jest': { isolatedModules: true, diff --git a/packages/eslint-plugin-tslint/package.json b/packages/eslint-plugin-tslint/package.json index 2a1a36de35ed..0df408974e52 100644 --- a/packages/eslint-plugin-tslint/package.json +++ b/packages/eslint-plugin-tslint/package.json @@ -42,7 +42,7 @@ "lodash": "^4.17.21" }, "peerDependencies": { - "eslint": "^5.0.0 || ^6.0.0 || ^7.0.0", + "eslint": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0", "tslint": "^5.0.0 || ^6.0.0", "typescript": "*" }, diff --git a/packages/eslint-plugin/jest.config.js b/packages/eslint-plugin/jest.config.js index cce8d6c61baf..bf4e270e3760 100644 --- a/packages/eslint-plugin/jest.config.js +++ b/packages/eslint-plugin/jest.config.js @@ -3,6 +3,7 @@ // @ts-check /** @type {import('@jest/types').Config.InitialOptions} */ module.exports = { + resolver: '/../../tests/jest-resolver.js', globals: { 'ts-jest': { isolatedModules: true, diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index d968a0caf9bf..0546e3d3b09d 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -64,7 +64,7 @@ }, "peerDependencies": { "@typescript-eslint/parser": "^4.0.0", - "eslint": "^5.0.0 || ^6.0.0 || ^7.0.0" + "eslint": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0" }, "peerDependenciesMeta": { "typescript": { diff --git a/packages/eslint-plugin/src/rules/brace-style.ts b/packages/eslint-plugin/src/rules/brace-style.ts index 4d981763cf48..8bd77aa12ff0 100644 --- a/packages/eslint-plugin/src/rules/brace-style.ts +++ b/packages/eslint-plugin/src/rules/brace-style.ts @@ -1,5 +1,5 @@ import { TSESTree } from '@typescript-eslint/experimental-utils'; -import baseRule from 'eslint/lib/rules/brace-style'; +import { getESLintCoreRule } from '../util/getESLintCoreRule'; import { InferOptionsTypeFromRule, InferMessageIdsTypeFromRule, @@ -7,6 +7,8 @@ import { isTokenOnSameLine, } from '../util'; +const baseRule = getESLintCoreRule('brace-style'); + export type Options = InferOptionsTypeFromRule; export type MessageIds = InferMessageIdsTypeFromRule; @@ -22,6 +24,7 @@ export default createRule({ }, messages: baseRule.meta.messages, fixable: baseRule.meta.fixable, + hasSuggestions: baseRule.meta.hasSuggestions, schema: baseRule.meta.schema, }, defaultOptions: ['1tbs'], diff --git a/packages/eslint-plugin/src/rules/comma-dangle.ts b/packages/eslint-plugin/src/rules/comma-dangle.ts index 1e5049e3fea5..9c212cca47e8 100644 --- a/packages/eslint-plugin/src/rules/comma-dangle.ts +++ b/packages/eslint-plugin/src/rules/comma-dangle.ts @@ -1,10 +1,12 @@ import * as util from '../util'; -import baseRule from 'eslint/lib/rules/comma-dangle'; +import { getESLintCoreRule } from '../util/getESLintCoreRule'; import { TSESTree, AST_NODE_TYPES, } from '@typescript-eslint/experimental-utils'; +const baseRule = getESLintCoreRule('comma-dangle'); + export type Options = util.InferOptionsTypeFromRule; export type MessageIds = util.InferMessageIdsTypeFromRule; @@ -83,6 +85,7 @@ export default util.createRule({ additionalProperties: false, }, fixable: 'code', + hasSuggestions: baseRule.meta.hasSuggestions, messages: baseRule.meta.messages, }, defaultOptions: ['never'], diff --git a/packages/eslint-plugin/src/rules/dot-notation.ts b/packages/eslint-plugin/src/rules/dot-notation.ts index becc2a92727c..9d5284b4aa63 100644 --- a/packages/eslint-plugin/src/rules/dot-notation.ts +++ b/packages/eslint-plugin/src/rules/dot-notation.ts @@ -1,7 +1,7 @@ import { TSESTree } from '@typescript-eslint/experimental-utils'; import * as ts from 'typescript'; import * as tsutils from 'tsutils'; -import baseRule from 'eslint/lib/rules/dot-notation'; +import { getESLintCoreRule } from '../util/getESLintCoreRule'; import { createRule, getParserServices, @@ -9,6 +9,8 @@ import { InferOptionsTypeFromRule, } from '../util'; +const baseRule = getESLintCoreRule('dot-notation'); + export type Options = InferOptionsTypeFromRule; export type MessageIds = InferMessageIdsTypeFromRule; @@ -52,6 +54,7 @@ export default createRule({ }, ], fixable: baseRule.meta.fixable, + hasSuggestions: baseRule.meta.hasSuggestions, messages: baseRule.meta.messages, }, defaultOptions: [ diff --git a/packages/eslint-plugin/src/rules/indent.ts b/packages/eslint-plugin/src/rules/indent.ts index b25586a0e8b6..129754543c8f 100644 --- a/packages/eslint-plugin/src/rules/indent.ts +++ b/packages/eslint-plugin/src/rules/indent.ts @@ -9,9 +9,11 @@ import { TSESTree, AST_NODE_TYPES, } from '@typescript-eslint/experimental-utils'; -import baseRule from 'eslint/lib/rules/indent'; +import { getESLintCoreRule } from '../util/getESLintCoreRule'; import * as util from '../util'; +const baseRule = getESLintCoreRule('indent'); + type Options = util.InferOptionsTypeFromRule; type MessageIds = util.InferMessageIdsTypeFromRule; @@ -96,6 +98,7 @@ export default util.createRule({ extendsBaseRule: true, }, fixable: 'whitespace', + hasSuggestions: baseRule.meta.hasSuggestions, schema: baseRule.meta.schema, messages: baseRule.meta.messages ?? { wrongIndentation: diff --git a/packages/eslint-plugin/src/rules/init-declarations.ts b/packages/eslint-plugin/src/rules/init-declarations.ts index 5706006852b2..4557faeb7d77 100644 --- a/packages/eslint-plugin/src/rules/init-declarations.ts +++ b/packages/eslint-plugin/src/rules/init-declarations.ts @@ -2,13 +2,15 @@ import { TSESTree, AST_NODE_TYPES, } from '@typescript-eslint/experimental-utils'; -import baseRule from 'eslint/lib/rules/init-declarations'; +import { getESLintCoreRule } from '../util/getESLintCoreRule'; import { InferOptionsTypeFromRule, InferMessageIdsTypeFromRule, createRule, } from '../util'; +const baseRule = getESLintCoreRule('init-declarations'); + export type Options = InferOptionsTypeFromRule; export type MessageIds = InferMessageIdsTypeFromRule; @@ -23,6 +25,7 @@ export default createRule({ recommended: false, extendsBaseRule: true, }, + hasSuggestions: baseRule.meta.hasSuggestions, schema: baseRule.meta.schema, messages: baseRule.meta.messages ?? { initialized: diff --git a/packages/eslint-plugin/src/rules/keyword-spacing.ts b/packages/eslint-plugin/src/rules/keyword-spacing.ts index 2265b2604436..f7bedfc11943 100644 --- a/packages/eslint-plugin/src/rules/keyword-spacing.ts +++ b/packages/eslint-plugin/src/rules/keyword-spacing.ts @@ -1,7 +1,9 @@ import { AST_TOKEN_TYPES } from '@typescript-eslint/experimental-utils'; -import baseRule from 'eslint/lib/rules/keyword-spacing'; +import { getESLintCoreRule } from '../util/getESLintCoreRule'; import * as util from '../util'; +const baseRule = getESLintCoreRule('keyword-spacing'); + export type Options = util.InferOptionsTypeFromRule; export type MessageIds = util.InferMessageIdsTypeFromRule; @@ -16,6 +18,7 @@ export default util.createRule({ extendsBaseRule: true, }, fixable: 'whitespace', + hasSuggestions: baseRule.meta.hasSuggestions, schema: baseRule.meta.schema, messages: baseRule.meta.messages ?? { expectedBefore: 'Expected space(s) before "{{value}}".', diff --git a/packages/eslint-plugin/src/rules/lines-between-class-members.ts b/packages/eslint-plugin/src/rules/lines-between-class-members.ts index 7317b37c5988..0cca8619c0a5 100644 --- a/packages/eslint-plugin/src/rules/lines-between-class-members.ts +++ b/packages/eslint-plugin/src/rules/lines-between-class-members.ts @@ -2,9 +2,11 @@ import { AST_NODE_TYPES, TSESTree, } from '@typescript-eslint/experimental-utils'; -import baseRule from 'eslint/lib/rules/lines-between-class-members'; +import { getESLintCoreRule } from '../util/getESLintCoreRule'; import * as util from '../util'; +const baseRule = getESLintCoreRule('lines-between-class-members'); + type Options = util.InferOptionsTypeFromRule; type MessageIds = util.InferMessageIdsTypeFromRule; @@ -31,6 +33,7 @@ export default util.createRule({ extendsBaseRule: true, }, fixable: 'whitespace', + hasSuggestions: baseRule.meta.hasSuggestions, schema, messages: baseRule.meta.messages ?? { never: 'Unexpected blank line between class members.', diff --git a/packages/eslint-plugin/src/rules/no-confusing-non-null-assertion.ts b/packages/eslint-plugin/src/rules/no-confusing-non-null-assertion.ts index 446bdd25932b..281c2f9c4632 100644 --- a/packages/eslint-plugin/src/rules/no-confusing-non-null-assertion.ts +++ b/packages/eslint-plugin/src/rules/no-confusing-non-null-assertion.ts @@ -17,6 +17,7 @@ export default util.createRule({ recommended: false, }, fixable: 'code', + hasSuggestions: true, messages: { confusingEqual: 'Confusing combinations of non-null assertion and equal test like "a! == b", which looks very similar to not equal "a !== b".', diff --git a/packages/eslint-plugin/src/rules/no-confusing-void-expression.ts b/packages/eslint-plugin/src/rules/no-confusing-void-expression.ts index 0579fb442541..1ddb60bf73dc 100644 --- a/packages/eslint-plugin/src/rules/no-confusing-void-expression.ts +++ b/packages/eslint-plugin/src/rules/no-confusing-void-expression.ts @@ -71,6 +71,7 @@ export default util.createRule({ ], type: 'problem', fixable: 'code', + hasSuggestions: true, }, defaultOptions: [{}], diff --git a/packages/eslint-plugin/src/rules/no-dupe-class-members.ts b/packages/eslint-plugin/src/rules/no-dupe-class-members.ts index bc48b2a843e8..0756e135fc96 100644 --- a/packages/eslint-plugin/src/rules/no-dupe-class-members.ts +++ b/packages/eslint-plugin/src/rules/no-dupe-class-members.ts @@ -1,7 +1,12 @@ -import { AST_NODE_TYPES } from '@typescript-eslint/experimental-utils'; -import baseRule from 'eslint/lib/rules/no-dupe-class-members'; +import { + AST_NODE_TYPES, + TSESTree, +} from '@typescript-eslint/experimental-utils'; +import { getESLintCoreRule } from '../util/getESLintCoreRule'; import * as util from '../util'; +const baseRule = getESLintCoreRule('no-dupe-class-members'); + type Options = util.InferOptionsTypeFromRule; type MessageIds = util.InferMessageIdsTypeFromRule; @@ -15,6 +20,7 @@ export default util.createRule({ recommended: false, extendsBaseRule: true, }, + hasSuggestions: baseRule.meta.hasSuggestions, schema: baseRule.meta.schema, messages: baseRule.meta.messages, }, @@ -22,9 +28,10 @@ export default util.createRule({ create(context) { const rules = baseRule.create(context); - return { - ...rules, - MethodDefinition(node): void { + function wrapMemberDefinitionListener( + coreListener: (node: TSESTree.MethodDefinition) => void, + ): (node: TSESTree.MethodDefinition) => void { + return (node: TSESTree.MethodDefinition): void => { if (node.computed) { return; } @@ -33,8 +40,29 @@ export default util.createRule({ return; } - return rules.MethodDefinition(node); - }, + return coreListener(node); + }; + } + + return { + ...rules, + // for ESLint <= v7 + ...(rules.MethodDefinition + ? { + MethodDefinition: wrapMemberDefinitionListener( + rules.MethodDefinition, + ), + } + : {}), + // for ESLint v8 + ...(rules['MethodDefinition, PropertyDefinition'] + ? { + 'MethodDefinition, PropertyDefinition': + wrapMemberDefinitionListener( + rules['MethodDefinition, PropertyDefinition'], + ), + } + : {}), }; }, }); diff --git a/packages/eslint-plugin/src/rules/no-duplicate-imports.ts b/packages/eslint-plugin/src/rules/no-duplicate-imports.ts index f58ef76e5fcf..773402e18d4b 100644 --- a/packages/eslint-plugin/src/rules/no-duplicate-imports.ts +++ b/packages/eslint-plugin/src/rules/no-duplicate-imports.ts @@ -2,9 +2,11 @@ import { AST_NODE_TYPES, TSESTree, } from '@typescript-eslint/experimental-utils'; -import baseRule from 'eslint/lib/rules/no-duplicate-imports'; +import { getESLintCoreRule } from '../util/getESLintCoreRule'; import * as util from '../util'; +const baseRule = getESLintCoreRule('no-duplicate-imports'); + type Options = util.InferOptionsTypeFromRule; type MessageIds = util.InferMessageIdsTypeFromRule; @@ -18,6 +20,7 @@ export default util.createRule({ recommended: false, extendsBaseRule: true, }, + hasSuggestions: baseRule.meta.hasSuggestions, schema: baseRule.meta.schema, messages: { ...baseRule.meta.messages, diff --git a/packages/eslint-plugin/src/rules/no-empty-function.ts b/packages/eslint-plugin/src/rules/no-empty-function.ts index 246680c60e34..d34618e0354a 100644 --- a/packages/eslint-plugin/src/rules/no-empty-function.ts +++ b/packages/eslint-plugin/src/rules/no-empty-function.ts @@ -2,9 +2,11 @@ import { AST_NODE_TYPES, TSESTree, } from '@typescript-eslint/experimental-utils'; -import baseRule from 'eslint/lib/rules/no-empty-function'; +import { getESLintCoreRule } from '../util/getESLintCoreRule'; import * as util from '../util'; +const baseRule = getESLintCoreRule('no-empty-function'); + type Options = util.InferOptionsTypeFromRule; type MessageIds = util.InferMessageIdsTypeFromRule; @@ -47,6 +49,7 @@ export default util.createRule({ recommended: 'error', extendsBaseRule: true, }, + hasSuggestions: baseRule.meta.hasSuggestions, schema: [schema], messages: baseRule.meta.messages, }, diff --git a/packages/eslint-plugin/src/rules/no-empty-interface.ts b/packages/eslint-plugin/src/rules/no-empty-interface.ts index 11ed8582c75b..d9c8c2477b8a 100644 --- a/packages/eslint-plugin/src/rules/no-empty-interface.ts +++ b/packages/eslint-plugin/src/rules/no-empty-interface.ts @@ -19,6 +19,7 @@ export default util.createRule({ suggestion: true, }, fixable: 'code', + hasSuggestions: true, messages: { noEmpty: 'An empty interface is equivalent to `{}`.', noEmptyWithSuper: diff --git a/packages/eslint-plugin/src/rules/no-explicit-any.ts b/packages/eslint-plugin/src/rules/no-explicit-any.ts index 9df51ba3d520..71f052923276 100644 --- a/packages/eslint-plugin/src/rules/no-explicit-any.ts +++ b/packages/eslint-plugin/src/rules/no-explicit-any.ts @@ -24,6 +24,7 @@ export default util.createRule({ suggestion: true, }, fixable: 'code', + hasSuggestions: true, messages: { unexpectedAny: 'Unexpected any. Specify a different type.', suggestUnknown: diff --git a/packages/eslint-plugin/src/rules/no-extra-parens.ts b/packages/eslint-plugin/src/rules/no-extra-parens.ts index 774fb44b389a..6aa540a9be56 100644 --- a/packages/eslint-plugin/src/rules/no-extra-parens.ts +++ b/packages/eslint-plugin/src/rules/no-extra-parens.ts @@ -6,9 +6,11 @@ import { TSESTree, TSESLint, } from '@typescript-eslint/experimental-utils'; -import baseRule from 'eslint/lib/rules/no-extra-parens'; +import { getESLintCoreRule } from '../util/getESLintCoreRule'; import * as util from '../util'; +const baseRule = getESLintCoreRule('no-extra-parens'); + type Options = util.InferOptionsTypeFromRule; type MessageIds = util.InferMessageIdsTypeFromRule; @@ -23,6 +25,7 @@ export default util.createRule({ extendsBaseRule: true, }, fixable: 'code', + hasSuggestions: baseRule.meta.hasSuggestions, schema: baseRule.meta.schema, messages: baseRule.meta.messages, }, diff --git a/packages/eslint-plugin/src/rules/no-extra-semi.ts b/packages/eslint-plugin/src/rules/no-extra-semi.ts index d1ffdf61d8d4..d8db4ba7904b 100644 --- a/packages/eslint-plugin/src/rules/no-extra-semi.ts +++ b/packages/eslint-plugin/src/rules/no-extra-semi.ts @@ -1,6 +1,8 @@ -import baseRule from 'eslint/lib/rules/no-extra-semi'; +import { getESLintCoreRule } from '../util/getESLintCoreRule'; import * as util from '../util'; +const baseRule = getESLintCoreRule('no-extra-semi'); + type Options = util.InferOptionsTypeFromRule; type MessageIds = util.InferMessageIdsTypeFromRule; @@ -15,6 +17,7 @@ export default util.createRule({ extendsBaseRule: true, }, fixable: 'code', + hasSuggestions: baseRule.meta.hasSuggestions, schema: baseRule.meta.schema, messages: baseRule.meta.messages, }, @@ -25,7 +28,13 @@ export default util.createRule({ return { ...rules, ClassProperty(node): void { - rules.MethodDefinition(node as never); + if (rules.MethodDefinition) { + // for ESLint <= v7 + rules.MethodDefinition(node as never); + } else { + // for ESLint v8 + rules['MethodDefinition, PropertyDefinition']?.(node as never); + } }, }; }, diff --git a/packages/eslint-plugin/src/rules/no-floating-promises.ts b/packages/eslint-plugin/src/rules/no-floating-promises.ts index 905dfd06fcff..ae196cf52889 100644 --- a/packages/eslint-plugin/src/rules/no-floating-promises.ts +++ b/packages/eslint-plugin/src/rules/no-floating-promises.ts @@ -27,6 +27,7 @@ export default util.createRule({ suggestion: true, requiresTypeChecking: true, }, + hasSuggestions: true, messages: { floating: 'Promises must be handled appropriately.', floatingVoid: diff --git a/packages/eslint-plugin/src/rules/no-implicit-any-catch.ts b/packages/eslint-plugin/src/rules/no-implicit-any-catch.ts index fbbdf59eb31a..85cdd7fd8fc9 100644 --- a/packages/eslint-plugin/src/rules/no-implicit-any-catch.ts +++ b/packages/eslint-plugin/src/rules/no-implicit-any-catch.ts @@ -25,6 +25,7 @@ export default util.createRule({ suggestion: true, }, fixable: 'code', + hasSuggestions: true, messages: { implicitAnyInCatch: 'Implicit any in catch clause.', explicitAnyInCatch: 'Explicit any in catch clause.', diff --git a/packages/eslint-plugin/src/rules/no-invalid-this.ts b/packages/eslint-plugin/src/rules/no-invalid-this.ts index 5d056308771f..2d802cdba04d 100644 --- a/packages/eslint-plugin/src/rules/no-invalid-this.ts +++ b/packages/eslint-plugin/src/rules/no-invalid-this.ts @@ -2,13 +2,15 @@ import { TSESTree, AST_NODE_TYPES, } from '@typescript-eslint/experimental-utils'; -import baseRule from 'eslint/lib/rules/no-invalid-this'; +import { getESLintCoreRule } from '../util/getESLintCoreRule'; import { InferOptionsTypeFromRule, createRule, InferMessageIdsTypeFromRule, } from '../util'; +const baseRule = getESLintCoreRule('no-invalid-this'); + export type Options = InferOptionsTypeFromRule; export type MessageIds = InferMessageIdsTypeFromRule; @@ -26,6 +28,7 @@ export default createRule({ messages: baseRule.meta.messages ?? { unexpectedThis: "Unexpected 'this'.", }, + hasSuggestions: baseRule.meta.hasSuggestions, schema: baseRule.meta.schema, }, defaultOptions: [{ capIsConstructor: true }], diff --git a/packages/eslint-plugin/src/rules/no-loop-func.ts b/packages/eslint-plugin/src/rules/no-loop-func.ts index 44d0178e8670..5560acf0952d 100644 --- a/packages/eslint-plugin/src/rules/no-loop-func.ts +++ b/packages/eslint-plugin/src/rules/no-loop-func.ts @@ -3,9 +3,11 @@ import { TSESLint, TSESTree, } from '@typescript-eslint/experimental-utils'; -import baseRule from 'eslint/lib/rules/no-loop-func'; +import { getESLintCoreRule } from '../util/getESLintCoreRule'; import * as util from '../util'; +const baseRule = getESLintCoreRule('no-loop-func'); + type Options = util.InferOptionsTypeFromRule; type MessageIds = util.InferMessageIdsTypeFromRule; @@ -20,6 +22,7 @@ export default util.createRule({ recommended: false, extendsBaseRule: true, }, + hasSuggestions: baseRule.meta.hasSuggestions, schema: [], messages: baseRule?.meta.messages ?? { unsafeRefs: diff --git a/packages/eslint-plugin/src/rules/no-loss-of-precision.ts b/packages/eslint-plugin/src/rules/no-loss-of-precision.ts index e9d52852668f..3b53661a0266 100644 --- a/packages/eslint-plugin/src/rules/no-loss-of-precision.ts +++ b/packages/eslint-plugin/src/rules/no-loss-of-precision.ts @@ -1,20 +1,13 @@ import { TSESTree } from '@typescript-eslint/experimental-utils'; -import BaseRule from 'eslint/lib/rules/no-loss-of-precision'; import * as util from '../util'; +import { maybeGetESLintCoreRule } from '../util/getESLintCoreRule'; -const baseRule = ((): typeof BaseRule | null => { - try { - return require('eslint/lib/rules/no-loss-of-precision') as - | typeof BaseRule - | null; - } catch { - /* istanbul ignore next */ - return null; - } -})(); +const baseRule = maybeGetESLintCoreRule('no-loss-of-precision'); -type Options = util.InferOptionsTypeFromRule; -type MessageIds = util.InferMessageIdsTypeFromRule; +type Options = util.InferOptionsTypeFromRule>; +type MessageIds = util.InferMessageIdsTypeFromRule< + NonNullable +>; export default util.createRule({ name: 'no-loss-of-precision', @@ -26,6 +19,7 @@ export default util.createRule({ recommended: false, extendsBaseRule: true, }, + hasSuggestions: baseRule?.meta.hasSuggestions, schema: [], messages: baseRule?.meta.messages ?? { noLossOfPrecision: '' }, }, diff --git a/packages/eslint-plugin/src/rules/no-magic-numbers.ts b/packages/eslint-plugin/src/rules/no-magic-numbers.ts index 1f45a489d357..20d06f05f563 100644 --- a/packages/eslint-plugin/src/rules/no-magic-numbers.ts +++ b/packages/eslint-plugin/src/rules/no-magic-numbers.ts @@ -2,9 +2,11 @@ import { TSESTree, AST_NODE_TYPES, } from '@typescript-eslint/experimental-utils'; -import baseRule from 'eslint/lib/rules/no-magic-numbers'; +import { getESLintCoreRule } from '../util/getESLintCoreRule'; import * as util from '../util'; +const baseRule = getESLintCoreRule('no-magic-numbers'); + type Options = util.InferOptionsTypeFromRule; type MessageIds = util.InferMessageIdsTypeFromRule; @@ -22,6 +24,7 @@ export default util.createRule({ recommended: false, extendsBaseRule: true, }, + hasSuggestions: baseRule.meta.hasSuggestions, // Extend base schema with additional property to ignore TS numeric literal types schema: [ { diff --git a/packages/eslint-plugin/src/rules/no-non-null-asserted-optional-chain.ts b/packages/eslint-plugin/src/rules/no-non-null-asserted-optional-chain.ts index f5652b257c14..1d9c8f4aabc2 100644 --- a/packages/eslint-plugin/src/rules/no-non-null-asserted-optional-chain.ts +++ b/packages/eslint-plugin/src/rules/no-non-null-asserted-optional-chain.ts @@ -26,6 +26,7 @@ export default util.createRule({ recommended: 'error', suggestion: true, }, + hasSuggestions: true, messages: { noNonNullOptionalChain: 'Optional chain expressions can return undefined by design - using a non-null assertion is unsafe and wrong.', diff --git a/packages/eslint-plugin/src/rules/no-non-null-assertion.ts b/packages/eslint-plugin/src/rules/no-non-null-assertion.ts index 4012693c7554..ceba7fefd15a 100644 --- a/packages/eslint-plugin/src/rules/no-non-null-assertion.ts +++ b/packages/eslint-plugin/src/rules/no-non-null-assertion.ts @@ -17,6 +17,7 @@ export default util.createRule<[], MessageIds>({ recommended: 'warn', suggestion: true, }, + hasSuggestions: true, messages: { noNonNull: 'Forbidden non-null assertion.', suggestOptionalChain: diff --git a/packages/eslint-plugin/src/rules/no-unused-expressions.ts b/packages/eslint-plugin/src/rules/no-unused-expressions.ts index 8116cbf704e3..f2f0e2c73b2b 100644 --- a/packages/eslint-plugin/src/rules/no-unused-expressions.ts +++ b/packages/eslint-plugin/src/rules/no-unused-expressions.ts @@ -2,9 +2,11 @@ import { AST_NODE_TYPES, TSESTree, } from '@typescript-eslint/experimental-utils'; -import baseRule from 'eslint/lib/rules/no-unused-expressions'; +import { getESLintCoreRule } from '../util/getESLintCoreRule'; import * as util from '../util'; +const baseRule = getESLintCoreRule('no-unused-expressions'); + type MessageIds = util.InferMessageIdsTypeFromRule; type Options = util.InferOptionsTypeFromRule; @@ -18,6 +20,7 @@ export default util.createRule({ recommended: false, extendsBaseRule: true, }, + hasSuggestions: baseRule.meta.hasSuggestions, schema: baseRule.meta.schema, messages: baseRule.meta.messages ?? { unusedExpression: diff --git a/packages/eslint-plugin/src/rules/no-useless-constructor.ts b/packages/eslint-plugin/src/rules/no-useless-constructor.ts index 2ad9c765c4e7..a4532ce72864 100644 --- a/packages/eslint-plugin/src/rules/no-useless-constructor.ts +++ b/packages/eslint-plugin/src/rules/no-useless-constructor.ts @@ -2,9 +2,11 @@ import { TSESTree, AST_NODE_TYPES, } from '@typescript-eslint/experimental-utils'; -import baseRule from 'eslint/lib/rules/no-useless-constructor'; +import { getESLintCoreRule } from '../util/getESLintCoreRule'; import * as util from '../util'; +const baseRule = getESLintCoreRule('no-useless-constructor'); + type Options = util.InferOptionsTypeFromRule; type MessageIds = util.InferMessageIdsTypeFromRule; @@ -53,6 +55,7 @@ export default util.createRule({ recommended: false, extendsBaseRule: true, }, + hasSuggestions: baseRule.meta.hasSuggestions, schema: baseRule.meta.schema, messages: baseRule.meta.messages ?? { noUselessConstructor: 'Useless constructor.', diff --git a/packages/eslint-plugin/src/rules/object-curly-spacing.ts b/packages/eslint-plugin/src/rules/object-curly-spacing.ts index 00c73820fd7c..090bd8e1e952 100644 --- a/packages/eslint-plugin/src/rules/object-curly-spacing.ts +++ b/packages/eslint-plugin/src/rules/object-curly-spacing.ts @@ -3,7 +3,7 @@ import { AST_TOKEN_TYPES, TSESTree, } from '@typescript-eslint/experimental-utils'; -import baseRule from 'eslint/lib/rules/object-curly-spacing'; +import { getESLintCoreRule } from '../util/getESLintCoreRule'; import { createRule, InferMessageIdsTypeFromRule, @@ -13,6 +13,8 @@ import { isTokenOnSameLine, } from '../util'; +const baseRule = getESLintCoreRule('object-curly-spacing'); + export type Options = InferOptionsTypeFromRule; export type MessageIds = InferMessageIdsTypeFromRule; diff --git a/packages/eslint-plugin/src/rules/prefer-as-const.ts b/packages/eslint-plugin/src/rules/prefer-as-const.ts index 91f432420214..aeaa6fcdd7a3 100644 --- a/packages/eslint-plugin/src/rules/prefer-as-const.ts +++ b/packages/eslint-plugin/src/rules/prefer-as-const.ts @@ -16,6 +16,7 @@ export default util.createRule({ suggestion: true, }, fixable: 'code', + hasSuggestions: true, messages: { preferConstAssertion: 'Expected a `const` instead of a literal type assertion.', diff --git a/packages/eslint-plugin/src/rules/prefer-enum-initializers.ts b/packages/eslint-plugin/src/rules/prefer-enum-initializers.ts index 663caa5bedda..9f9d641ec411 100644 --- a/packages/eslint-plugin/src/rules/prefer-enum-initializers.ts +++ b/packages/eslint-plugin/src/rules/prefer-enum-initializers.ts @@ -13,6 +13,7 @@ export default util.createRule<[], MessageIds>({ recommended: false, suggestion: true, }, + hasSuggestions: true, messages: { defineInitializer: "The value of the member '{{ name }}' should be explicitly defined.", diff --git a/packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts b/packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts index fa6c1bb4e216..4fe3d021f700 100644 --- a/packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts +++ b/packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts @@ -26,6 +26,7 @@ export default util.createRule({ suggestion: true, requiresTypeChecking: true, }, + hasSuggestions: true, messages: { preferNullish: 'Prefer using nullish coalescing operator (`??`) instead of a logical or (`||`), as it is a safer operator.', diff --git a/packages/eslint-plugin/src/rules/prefer-optional-chain.ts b/packages/eslint-plugin/src/rules/prefer-optional-chain.ts index 0e15bf8f9794..b1eff5e4ae7e 100644 --- a/packages/eslint-plugin/src/rules/prefer-optional-chain.ts +++ b/packages/eslint-plugin/src/rules/prefer-optional-chain.ts @@ -41,6 +41,7 @@ export default util.createRule({ recommended: false, suggestion: true, }, + hasSuggestions: true, messages: { preferOptionalChain: "Prefer using an optional chain expression instead, as it's more concise and easier to read.", diff --git a/packages/eslint-plugin/src/rules/quotes.ts b/packages/eslint-plugin/src/rules/quotes.ts index 3cbdbce3d875..e4af60fd0412 100644 --- a/packages/eslint-plugin/src/rules/quotes.ts +++ b/packages/eslint-plugin/src/rules/quotes.ts @@ -2,9 +2,11 @@ import { AST_NODE_TYPES, TSESTree, } from '@typescript-eslint/experimental-utils'; -import baseRule from 'eslint/lib/rules/quotes'; +import { getESLintCoreRule } from '../util/getESLintCoreRule'; import * as util from '../util'; +const baseRule = getESLintCoreRule('quotes'); + export type Options = util.InferOptionsTypeFromRule; export type MessageIds = util.InferMessageIdsTypeFromRule; @@ -20,6 +22,7 @@ export default util.createRule({ extendsBaseRule: true, }, fixable: 'code', + hasSuggestions: baseRule.meta.hasSuggestions, messages: baseRule.meta.messages ?? { wrongQuotes: 'Strings must use {{description}}.', }, diff --git a/packages/eslint-plugin/src/rules/return-await.ts b/packages/eslint-plugin/src/rules/return-await.ts index 940dfe94023f..1375d3028e1e 100644 --- a/packages/eslint-plugin/src/rules/return-await.ts +++ b/packages/eslint-plugin/src/rules/return-await.ts @@ -28,6 +28,7 @@ export default util.createRule({ extendsBaseRule: 'no-return-await', }, fixable: 'code', + hasSuggestions: true, type: 'problem', messages: { nonPromiseAwait: diff --git a/packages/eslint-plugin/src/rules/semi.ts b/packages/eslint-plugin/src/rules/semi.ts index eccc264e4613..05c4c6b1c3aa 100644 --- a/packages/eslint-plugin/src/rules/semi.ts +++ b/packages/eslint-plugin/src/rules/semi.ts @@ -3,9 +3,11 @@ import { TSESLint, AST_NODE_TYPES, } from '@typescript-eslint/experimental-utils'; -import baseRule from 'eslint/lib/rules/semi'; +import { getESLintCoreRule } from '../util/getESLintCoreRule'; import * as util from '../util'; +const baseRule = getESLintCoreRule('semi'); + export type Options = util.InferOptionsTypeFromRule; export type MessageIds = util.InferMessageIdsTypeFromRule; @@ -21,6 +23,7 @@ export default util.createRule({ extendsBaseRule: true, }, fixable: 'code', + hasSuggestions: baseRule.meta.hasSuggestions, schema: baseRule.meta.schema, messages: baseRule.meta.messages ?? { missingSemi: 'Missing semicolon.', diff --git a/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts b/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts index af80720c2904..cfcab2c0b2cb 100644 --- a/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts +++ b/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts @@ -111,6 +111,7 @@ export default util.createRule({ recommended: false, }, fixable: 'code', + hasSuggestions: true, messages: { notSorted: '{{type}} type members must be sorted.', notSortedNamed: '{{type}} type {{name}} members must be sorted.', diff --git a/packages/eslint-plugin/src/rules/space-infix-ops.ts b/packages/eslint-plugin/src/rules/space-infix-ops.ts index 3a0a79ff1a32..86fb8d93d53f 100644 --- a/packages/eslint-plugin/src/rules/space-infix-ops.ts +++ b/packages/eslint-plugin/src/rules/space-infix-ops.ts @@ -2,9 +2,11 @@ import { AST_TOKEN_TYPES, TSESTree, } from '@typescript-eslint/experimental-utils'; -import baseRule from 'eslint/lib/rules/space-infix-ops'; +import { getESLintCoreRule } from '../util/getESLintCoreRule'; import * as util from '../util'; +const baseRule = getESLintCoreRule('space-infix-ops'); + export type Options = util.InferOptionsTypeFromRule; export type MessageIds = util.InferMessageIdsTypeFromRule; @@ -22,6 +24,7 @@ export default util.createRule({ extendsBaseRule: true, }, fixable: baseRule.meta.fixable, + hasSuggestions: baseRule.meta.hasSuggestions, schema: baseRule.meta.schema, messages: baseRule.meta.messages ?? { missingSpace: "Operator '{{operator}}' must be spaced.", diff --git a/packages/eslint-plugin/src/rules/strict-boolean-expressions.ts b/packages/eslint-plugin/src/rules/strict-boolean-expressions.ts index 87796f9f4279..1aca481e7439 100644 --- a/packages/eslint-plugin/src/rules/strict-boolean-expressions.ts +++ b/packages/eslint-plugin/src/rules/strict-boolean-expressions.ts @@ -49,6 +49,7 @@ export default util.createRule({ meta: { type: 'suggestion', fixable: 'code', + hasSuggestions: true, docs: { description: 'Restricts the types allowed in boolean expressions', category: 'Best Practices', diff --git a/packages/eslint-plugin/src/rules/switch-exhaustiveness-check.ts b/packages/eslint-plugin/src/rules/switch-exhaustiveness-check.ts index 7535aa6dc54a..65a70a86cc40 100644 --- a/packages/eslint-plugin/src/rules/switch-exhaustiveness-check.ts +++ b/packages/eslint-plugin/src/rules/switch-exhaustiveness-check.ts @@ -21,6 +21,7 @@ export default createRule({ suggestion: true, requiresTypeChecking: true, }, + hasSuggestions: true, schema: [], messages: { switchIsNotExhaustive: diff --git a/packages/eslint-plugin/src/util/collectUnusedVariables.ts b/packages/eslint-plugin/src/util/collectUnusedVariables.ts index b36d07e818cd..a1cfac27232f 100644 --- a/packages/eslint-plugin/src/util/collectUnusedVariables.ts +++ b/packages/eslint-plugin/src/util/collectUnusedVariables.ts @@ -318,7 +318,7 @@ class UnusedVarsVisitor< protected TSMethodSignature = this.visitFunctionTypeSignature; protected TSModuleDeclaration(node: TSESTree.TSModuleDeclaration): void { - // global augmentation can be in any file, and they do not need exports + // -- global augmentation can be in any file, and they do not need exports if (node.global === true) { this.markVariableAsUsed('global', node.parent!); } diff --git a/packages/eslint-plugin/src/util/getESLintCoreRule.ts b/packages/eslint-plugin/src/util/getESLintCoreRule.ts new file mode 100644 index 000000000000..fdb2ca46df87 --- /dev/null +++ b/packages/eslint-plugin/src/util/getESLintCoreRule.ts @@ -0,0 +1,62 @@ +import { version } from 'eslint/package.json'; +import * as semver from 'semver'; +import { nullThrows } from './nullThrows'; + +const isESLintV8 = semver.major(version) >= 8; + +interface RuleMap { + 'arrow-parens': typeof import('eslint/lib/rules/arrow-parens'); + 'brace-style': typeof import('eslint/lib/rules/brace-style'); + 'comma-dangle': typeof import('eslint/lib/rules/comma-dangle'); + 'dot-notation': typeof import('eslint/lib/rules/dot-notation'); + indent: typeof import('eslint/lib/rules/indent'); + 'init-declarations': typeof import('eslint/lib/rules/init-declarations'); + 'keyword-spacing': typeof import('eslint/lib/rules/keyword-spacing'); + 'lines-between-class-members': typeof import('eslint/lib/rules/lines-between-class-members'); + 'no-dupe-args': typeof import('eslint/lib/rules/no-dupe-args'); + 'no-dupe-class-members': typeof import('eslint/lib/rules/no-dupe-class-members'); + 'no-duplicate-imports': typeof import('eslint/lib/rules/no-duplicate-imports'); + 'no-empty-function': typeof import('eslint/lib/rules/no-empty-function'); + 'no-extra-parens': typeof import('eslint/lib/rules/no-extra-parens'); + 'no-extra-semi': typeof import('eslint/lib/rules/no-extra-semi'); + 'no-implicit-globals': typeof import('eslint/lib/rules/no-implicit-globals'); + 'no-invalid-this': typeof import('eslint/lib/rules/no-invalid-this'); + 'no-loop-func': typeof import('eslint/lib/rules/no-loop-func'); + 'no-loss-of-precision': typeof import('eslint/lib/rules/no-loss-of-precision'); + 'no-magic-numbers': typeof import('eslint/lib/rules/no-magic-numbers'); + 'no-undef': typeof import('eslint/lib/rules/no-undef'); + 'no-unused-expressions': typeof import('eslint/lib/rules/no-unused-expressions'); + 'no-useless-constructor': typeof import('eslint/lib/rules/no-useless-constructor'); + 'no-restricted-globals': typeof import('eslint/lib/rules/no-restricted-globals'); + 'object-curly-spacing': typeof import('eslint/lib/rules/object-curly-spacing'); + 'prefer-const': typeof import('eslint/lib/rules/prefer-const'); + quotes: typeof import('eslint/lib/rules/quotes'); + semi: typeof import('eslint/lib/rules/semi'); + 'space-infix-ops': typeof import('eslint/lib/rules/space-infix-ops'); + strict: typeof import('eslint/lib/rules/strict'); +} + +type RuleId = keyof RuleMap; + +export const getESLintCoreRule: (ruleId: R) => RuleMap[R] = + isESLintV8 + ? (ruleId: R): RuleMap[R] => + nullThrows( + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call + require('eslint/use-at-your-own-risk').builtinRules.get( + ruleId, + ) as RuleMap[R], + `ESLint's core rule '${ruleId}' not found.`, + ) + : (ruleId: R): RuleMap[R] => + require(`eslint/lib/rules/${ruleId}`) as RuleMap[R]; + +export function maybeGetESLintCoreRule( + ruleId: R, +): RuleMap[R] | null { + try { + return getESLintCoreRule(ruleId); + } catch { + return null; + } +} diff --git a/packages/eslint-plugin/tests/eslint-rules/arrow-parens.test.ts b/packages/eslint-plugin/tests/eslint-rules/arrow-parens.test.ts index 6d19021fa560..495bbe97e698 100644 --- a/packages/eslint-plugin/tests/eslint-rules/arrow-parens.test.ts +++ b/packages/eslint-plugin/tests/eslint-rules/arrow-parens.test.ts @@ -1,6 +1,8 @@ -import rule from 'eslint/lib/rules/arrow-parens'; +import { getESLintCoreRule } from '../../src/util/getESLintCoreRule'; import { RuleTester, noFormat } from '../RuleTester'; +const rule = getESLintCoreRule('arrow-parens'); + const ruleTester = new RuleTester({ parser: '@typescript-eslint/parser', }); diff --git a/packages/eslint-plugin/tests/eslint-rules/no-dupe-args.test.ts b/packages/eslint-plugin/tests/eslint-rules/no-dupe-args.test.ts index 0dc4807edb15..5bc8d99490d1 100644 --- a/packages/eslint-plugin/tests/eslint-rules/no-dupe-args.test.ts +++ b/packages/eslint-plugin/tests/eslint-rules/no-dupe-args.test.ts @@ -1,6 +1,8 @@ -import rule from 'eslint/lib/rules/no-dupe-args'; +import { getESLintCoreRule } from '../../src/util/getESLintCoreRule'; import { RuleTester } from '../RuleTester'; +const rule = getESLintCoreRule('no-dupe-args'); + const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6, diff --git a/packages/eslint-plugin/tests/eslint-rules/no-implicit-globals.test.ts b/packages/eslint-plugin/tests/eslint-rules/no-implicit-globals.test.ts index 2fc971bdef60..eb3fea348b52 100644 --- a/packages/eslint-plugin/tests/eslint-rules/no-implicit-globals.test.ts +++ b/packages/eslint-plugin/tests/eslint-rules/no-implicit-globals.test.ts @@ -1,6 +1,7 @@ -import rule from 'eslint/lib/rules/no-implicit-globals'; +import { getESLintCoreRule } from '../../src/util/getESLintCoreRule'; import { RuleTester } from '../RuleTester'; +const rule = getESLintCoreRule('no-implicit-globals'); const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6, diff --git a/packages/eslint-plugin/tests/eslint-rules/no-restricted-globals.test.ts b/packages/eslint-plugin/tests/eslint-rules/no-restricted-globals.test.ts index 7a457a617849..6061c8ebb4ee 100644 --- a/packages/eslint-plugin/tests/eslint-rules/no-restricted-globals.test.ts +++ b/packages/eslint-plugin/tests/eslint-rules/no-restricted-globals.test.ts @@ -1,6 +1,8 @@ -import rule from 'eslint/lib/rules/no-restricted-globals'; +import { getESLintCoreRule } from '../../src/util/getESLintCoreRule'; import { RuleTester } from '../RuleTester'; +const rule = getESLintCoreRule('no-restricted-globals'); + const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6, diff --git a/packages/eslint-plugin/tests/eslint-rules/no-undef.test.ts b/packages/eslint-plugin/tests/eslint-rules/no-undef.test.ts index 4f2c9702411b..9cff63994d39 100644 --- a/packages/eslint-plugin/tests/eslint-rules/no-undef.test.ts +++ b/packages/eslint-plugin/tests/eslint-rules/no-undef.test.ts @@ -1,6 +1,8 @@ -import rule from 'eslint/lib/rules/no-undef'; +import { getESLintCoreRule } from '../../src/util/getESLintCoreRule'; import { RuleTester } from '../RuleTester'; +const rule = getESLintCoreRule('no-undef'); + const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6, diff --git a/packages/eslint-plugin/tests/eslint-rules/prefer-const.test.ts b/packages/eslint-plugin/tests/eslint-rules/prefer-const.test.ts index a051ebb68610..d3bce8cfdee9 100644 --- a/packages/eslint-plugin/tests/eslint-rules/prefer-const.test.ts +++ b/packages/eslint-plugin/tests/eslint-rules/prefer-const.test.ts @@ -1,6 +1,8 @@ -import rule from 'eslint/lib/rules/prefer-const'; +import { getESLintCoreRule } from '../../src/util/getESLintCoreRule'; import { RuleTester } from '../RuleTester'; +const rule = getESLintCoreRule('prefer-const'); + const ruleTester = new RuleTester({ parser: '@typescript-eslint/parser', }); diff --git a/packages/eslint-plugin/tests/eslint-rules/strict.test.ts b/packages/eslint-plugin/tests/eslint-rules/strict.test.ts index 51d27c9bde95..83ad25a0605b 100644 --- a/packages/eslint-plugin/tests/eslint-rules/strict.test.ts +++ b/packages/eslint-plugin/tests/eslint-rules/strict.test.ts @@ -1,6 +1,8 @@ -import rule from 'eslint/lib/rules/strict'; +import { getESLintCoreRule } from '../../src/util/getESLintCoreRule'; import { RuleTester } from '../RuleTester'; +const rule = getESLintCoreRule('strict'); + const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6, diff --git a/packages/eslint-plugin/tests/rules/array-type.test.ts b/packages/eslint-plugin/tests/rules/array-type.test.ts index 6551bf6e7b97..3c2c1893a3f8 100644 --- a/packages/eslint-plugin/tests/rules/array-type.test.ts +++ b/packages/eslint-plugin/tests/rules/array-type.test.ts @@ -1664,7 +1664,7 @@ interface FooInterface { ], }); -// eslint rule tester is not working with multi-pass +// -- eslint rule tester is not working with multi-pass // https://github.com/eslint/eslint/issues/11187 describe('array-type (nested)', () => { const linter = new TSESLint.Linter(); diff --git a/packages/eslint-plugin/tests/rules/no-duplicate-imports.test.ts b/packages/eslint-plugin/tests/rules/no-duplicate-imports.test.ts index 98e12fbeb7a8..fae90720e7ed 100644 --- a/packages/eslint-plugin/tests/rules/no-duplicate-imports.test.ts +++ b/packages/eslint-plugin/tests/rules/no-duplicate-imports.test.ts @@ -168,14 +168,6 @@ ruleTester.run('no-duplicate-imports', rule, { `, errors: [{ messageId: 'import' }], }, - { - code: ` - import foo from 'foo'; - export * from 'foo'; - `, - options: [{ includeExports: true }], - errors: [{ messageId: 'exportAs' }], - }, { code: ` import foo from 'foo'; diff --git a/packages/eslint-plugin/tests/rules/require-await.test.ts b/packages/eslint-plugin/tests/rules/require-await.test.ts index 248888b429f0..ec2b178ecbb4 100644 --- a/packages/eslint-plugin/tests/rules/require-await.test.ts +++ b/packages/eslint-plugin/tests/rules/require-await.test.ts @@ -375,7 +375,7 @@ async function foo() { for await (x of xs); } `, - // global await + // -- global await { code: 'await foo();', }, diff --git a/packages/eslint-plugin/typings/eslint-rules.d.ts b/packages/eslint-plugin/typings/eslint-rules.d.ts index ada68c89a769..aa833057ba20 100644 --- a/packages/eslint-plugin/typings/eslint-rules.d.ts +++ b/packages/eslint-plugin/typings/eslint-rules.d.ts @@ -230,7 +230,12 @@ declare module 'eslint/lib/rules/no-dupe-class-members' { Program(): void; ClassBody(): void; 'ClassBody:exit'(): void; - MethodDefinition(node: TSESTree.MethodDefinition): void; + // for ESLint <= v7 + MethodDefinition?: (node: TSESTree.MethodDefinition) => void; + // for ESLint v8 + 'MethodDefinition, PropertyDefinition'?: ( + node: TSESTree.MethodDefinition /* | TSESTree.PropertyDefinition */, + ) => void; } >; export = rule; @@ -520,11 +525,11 @@ declare module 'eslint/lib/rules/no-extra-parens' { ClassExpression(node: TSESTree.ClassExpression): void; ConditionalExpression(node: TSESTree.ConditionalExpression): void; DoWhileStatement(node: TSESTree.DoWhileStatement): void; - // eslint < 7.19.0 + // -- eslint < 7.19.0 'ForInStatement, ForOfStatement'( node: TSESTree.ForInStatement | TSESTree.ForOfStatement, ): void; - // eslint >= 7.19.0 + // -- eslint >= 7.19.0 ForInStatement(node: TSESTree.ForInStatement): void; ForOfStatement(node: TSESTree.ForOfStatement): void; ForStatement(node: TSESTree.ForStatement): void; @@ -637,7 +642,12 @@ declare module 'eslint/lib/rules/no-extra-semi' { { EmptyStatement(node: TSESTree.EmptyStatement): void; ClassBody(node: TSESTree.ClassBody): void; - MethodDefinition(node: TSESTree.MethodDefinition): void; + // for ESLint <= v7 + MethodDefinition?: (node: TSESTree.MethodDefinition) => void; + // for ESLint v8 + 'MethodDefinition, PropertyDefinition'?: ( + node: TSESTree.MethodDefinition /* | TSESTree.PropertyDefinition */, + ) => void; } >; export = rule; diff --git a/packages/experimental-utils/jest.config.js b/packages/experimental-utils/jest.config.js index cce8d6c61baf..bf4e270e3760 100644 --- a/packages/experimental-utils/jest.config.js +++ b/packages/experimental-utils/jest.config.js @@ -3,6 +3,7 @@ // @ts-check /** @type {import('@jest/types').Config.InitialOptions} */ module.exports = { + resolver: '/../../tests/jest-resolver.js', globals: { 'ts-jest': { isolatedModules: true, diff --git a/packages/experimental-utils/src/eslint-utils/batchedSingleLineTests.ts b/packages/experimental-utils/src/eslint-utils/batchedSingleLineTests.ts index 29a56671a351..8eaef6e3f5e9 100644 --- a/packages/experimental-utils/src/eslint-utils/batchedSingleLineTests.ts +++ b/packages/experimental-utils/src/eslint-utils/batchedSingleLineTests.ts @@ -34,7 +34,7 @@ function batchedSingleLineTests< >( options: ValidTestCase | InvalidTestCase, ): (ValidTestCase | InvalidTestCase)[] { - // eslint counts lines from 1 + // -- eslint counts lines from 1 const lineOffset = options.code.startsWith('\n') ? 2 : 1; const output = 'output' in options && options.output diff --git a/packages/experimental-utils/src/ts-eslint/CLIEngine.ts b/packages/experimental-utils/src/ts-eslint/CLIEngine.ts index dfcc2347a5e8..9cc1c97b5c79 100644 --- a/packages/experimental-utils/src/ts-eslint/CLIEngine.ts +++ b/packages/experimental-utils/src/ts-eslint/CLIEngine.ts @@ -175,6 +175,8 @@ namespace CLIEngine { * important information so you can deal with the output yourself. * @deprecated use the ESLint class instead */ -class CLIEngine extends (ESLintCLIEngine as typeof CLIEngineBase) {} +const CLIEngine = ESLintCLIEngine + ? class CLIEngine extends (ESLintCLIEngine as typeof CLIEngineBase) {} + : undefined; export { CLIEngine }; diff --git a/packages/experimental-utils/src/ts-eslint/Rule.ts b/packages/experimental-utils/src/ts-eslint/Rule.ts index f9b5c01576bf..76e8deb24082 100644 --- a/packages/experimental-utils/src/ts-eslint/Rule.ts +++ b/packages/experimental-utils/src/ts-eslint/Rule.ts @@ -57,6 +57,10 @@ interface RuleMetaData { * The fixer category. Omit if there is no fixer */ fixable?: 'code' | 'whitespace'; + /** + * Specifies whether rules can return suggestions. Omit if there is no suggestions + */ + hasSuggestions?: boolean; /** * A map of messages which the rule can report. * The key is the messageId, and the string is the parameterised error string. diff --git a/packages/parser/jest.config.js b/packages/parser/jest.config.js index 309c75f2fd3c..af3026d5c104 100644 --- a/packages/parser/jest.config.js +++ b/packages/parser/jest.config.js @@ -1,6 +1,9 @@ 'use strict'; +// @ts-check +/** @type {import('@jest/types').Config.InitialOptions} */ module.exports = { + resolver: '/../../tests/jest-resolver.js', globals: { 'ts-jest': { isolatedModules: true, diff --git a/packages/parser/package.json b/packages/parser/package.json index 080af86165f0..89c075d6afe6 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -41,7 +41,7 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "peerDependencies": { - "eslint": "^5.0.0 || ^6.0.0 || ^7.0.0" + "eslint": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0" }, "dependencies": { "@typescript-eslint/scope-manager": "4.33.0", diff --git a/patches/eslint-plugin-import+2.24.2.patch b/patches/eslint-plugin-import+2.24.2.patch new file mode 100644 index 000000000000..6157ff155586 --- /dev/null +++ b/patches/eslint-plugin-import+2.24.2.patch @@ -0,0 +1,14 @@ +diff --git a/node_modules/eslint-plugin-import/lib/index.js b/node_modules/eslint-plugin-import/lib/index.js +index 247818e..1b42a54 100644 +--- a/node_modules/eslint-plugin-import/lib/index.js ++++ b/node_modules/eslint-plugin-import/lib/index.js +@@ -19,7 +19,8 @@ + 'no-named-as-default': require('./rules/no-named-as-default'), + 'no-named-as-default-member': require('./rules/no-named-as-default-member'), + 'no-anonymous-default-export': require('./rules/no-anonymous-default-export'), +- 'no-unused-modules': require('./rules/no-unused-modules'), ++ // temporarily removed for the v8 migration as it crashes the lint run ++ // 'no-unused-modules': require('./rules/no-unused-modules'), + + 'no-commonjs': require('./rules/no-commonjs'), + 'no-amd': require('./rules/no-amd'), diff --git a/patches/eslint-plugin-jest+24.4.0.patch b/patches/eslint-plugin-jest+24.4.0.patch new file mode 100644 index 000000000000..da14716ee8ab --- /dev/null +++ b/patches/eslint-plugin-jest+24.4.0.patch @@ -0,0 +1,48 @@ +diff --git a/node_modules/eslint-plugin-jest/lib/rules/no-done-callback.js b/node_modules/eslint-plugin-jest/lib/rules/no-done-callback.js +index 8a09e7b..4f7dffa 100644 +--- a/node_modules/eslint-plugin-jest/lib/rules/no-done-callback.js ++++ b/node_modules/eslint-plugin-jest/lib/rules/no-done-callback.js +@@ -34,6 +34,7 @@ var _default = (0, _utils.createRule)({ + recommended: 'error', + suggestion: true + }, ++ hasSuggestions: true, + messages: { + noDoneCallback: 'Return a Promise instead of relying on callback parameter', + suggestWrappingInPromise: 'Wrap in `new Promise({{ callback }} => ...`', +diff --git a/node_modules/eslint-plugin-jest/lib/rules/no-focused-tests.js b/node_modules/eslint-plugin-jest/lib/rules/no-focused-tests.js +index 159e1fb..b167a83 100644 +--- a/node_modules/eslint-plugin-jest/lib/rules/no-focused-tests.js ++++ b/node_modules/eslint-plugin-jest/lib/rules/no-focused-tests.js +@@ -36,6 +36,7 @@ var _default = (0, _utils.createRule)({ + recommended: 'error', + suggestion: true + }, ++ hasSuggestions: true, + messages: { + focusedTest: 'Unexpected focused test.', + suggestRemoveFocus: 'Remove focus from test.' +diff --git a/node_modules/eslint-plugin-jest/lib/rules/prefer-expect-assertions.js b/node_modules/eslint-plugin-jest/lib/rules/prefer-expect-assertions.js +index cf064ac..c47dc4a 100644 +--- a/node_modules/eslint-plugin-jest/lib/rules/prefer-expect-assertions.js ++++ b/node_modules/eslint-plugin-jest/lib/rules/prefer-expect-assertions.js +@@ -29,6 +29,7 @@ var _default = (0, _utils.createRule)({ + recommended: false, + suggestion: true + }, ++ hasSuggestions: true, + messages: { + hasAssertionsTakesNoArguments: '`expect.hasAssertions` expects no arguments', + assertionsRequiresOneArgument: '`expect.assertions` excepts a single argument of type number', +diff --git a/node_modules/eslint-plugin-jest/lib/rules/prefer-strict-equal.js b/node_modules/eslint-plugin-jest/lib/rules/prefer-strict-equal.js +index 95136e6..c1179c6 100644 +--- a/node_modules/eslint-plugin-jest/lib/rules/prefer-strict-equal.js ++++ b/node_modules/eslint-plugin-jest/lib/rules/prefer-strict-equal.js +@@ -16,6 +16,7 @@ var _default = (0, _utils.createRule)({ + recommended: false, + suggestion: true + }, ++ hasSuggestions: true, + messages: { + useToStrictEqual: 'Use `toStrictEqual()` instead', + suggestReplaceWithStrictEqual: 'Replace with `toStrictEqual()`' diff --git a/tests/jest-resolver.js b/tests/jest-resolver.js new file mode 100644 index 000000000000..f79f54509b79 --- /dev/null +++ b/tests/jest-resolver.js @@ -0,0 +1,15 @@ +// https://github.com/facebook/jest/issues/9771#issuecomment-871585234 + +// temporary workaround while we wait for https://github.com/facebook/jest/issues/9771 +const resolver = require('enhanced-resolve').create.sync({ + conditionNames: ['require', 'node', 'default'], + extensions: ['.js', '.json', '.node', '.ts', '.tsx'], +}); + +module.exports = function (request, options) { + // list global module that must be resolved by defaultResolver here + if (['fs', 'http', 'path'].includes(request)) { + return options.defaultResolver(request, options); + } + return resolver(options.basedir, request); +}; diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json index 0e8da2eba1ce..16ced4c0241c 100644 --- a/tsconfig.eslint.json +++ b/tsconfig.eslint.json @@ -5,5 +5,10 @@ "allowJs": true }, "extends": "./tsconfig.base.json", - "include": ["tests/**/*.ts", "tools/**/*.ts", ".eslintrc.js"] + "include": [ + "tests/**/*.ts", + "tools/**/*.ts", + ".eslintrc.js", + "tests/jest-resolver.js" + ] } diff --git a/yarn.lock b/yarn.lock index 8232ff7dee26..80ea8600a6df 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9,13 +9,6 @@ dependencies: "@babel/highlight" "^7.14.5" -"@babel/code-frame@7.12.11": - version "7.12.11" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.12.11.tgz#f4ad435aa263db935b8f10f2c552d23fb716a63f" - integrity sha512-Zt1yodBx1UcyiePMSkWnU4hPqhwq7hGi2nFL1LeA3EUl+q2LQx16MISgJ0+z7dnmgvP9QtIleuETGOiOH1RcIw== - dependencies: - "@babel/highlight" "^7.10.4" - "@babel/compat-data@^7.14.4": version "7.14.4" resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.14.4.tgz#45720fe0cecf3fd42019e1d12cc3d27fadc98d58" @@ -160,7 +153,7 @@ "@babel/traverse" "^7.14.0" "@babel/types" "^7.14.0" -"@babel/highlight@^7.10.4", "@babel/highlight@^7.14.5": +"@babel/highlight@^7.14.5": version "7.14.5" resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.14.5.tgz#6861a52f03966405001f6aa534a01a24d99e8cd9" integrity sha512-qf9u2WFWVV0MppaL877j2dBtQIDgmidgjGk5VIMw3OadXvYaXn66U1BFlH2t4+t3i+8PhedppRv+i40ABzd+gg== @@ -705,15 +698,15 @@ ts-node "^9" tslib "^2" -"@eslint/eslintrc@^0.4.1": - version "0.4.1" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.4.1.tgz#442763b88cecbe3ee0ec7ca6d6dd6168550cbf14" - integrity sha512-5v7TDE9plVhvxQeWLXDTvFvJBdH6pEsdnl2g/dAptmuFEPedQ4Erq5rsDsX+mvAM610IhNaO2W5V1dOOnDKxkQ== +"@eslint/eslintrc@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.0.0.tgz#08309b915051dbfcfea8c3cdfc832375303396c9" + integrity sha512-FPnE4y+crrKBF0c9PckDHFuPDQl+wRX6S9jeSw2WwM2YNmrdRch3gx3DOTWpqpQu0G9yoJaeSSrJLiV/29tGyQ== dependencies: ajv "^6.12.4" - debug "^4.1.1" - espree "^7.3.0" - globals "^12.1.0" + debug "^4.3.2" + espree "^8.0.0" + globals "^13.9.0" ignore "^4.0.6" import-fresh "^3.2.1" js-yaml "^3.13.1" @@ -794,6 +787,20 @@ unique-filename "^1.1.1" which "^1.3.1" +"@humanwhocodes/config-array@^0.6.0": + version "0.6.0" + resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.6.0.tgz#b5621fdb3b32309d2d16575456cbc277fa8f021a" + integrity sha512-JQlEKbcgEUjBFhLIF4iqM7u/9lwgHRBcpHrmUNCALK0Q3amXN6lxdoXLnF0sm11E9VqTmBALR87IlUg1bZ8A9A== + dependencies: + "@humanwhocodes/object-schema" "^1.2.0" + debug "^4.1.1" + minimatch "^3.0.4" + +"@humanwhocodes/object-schema@^1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.0.tgz#87de7af9c231826fdd68ac7258f77c429e0e5fcf" + integrity sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w== + "@istanbuljs/load-nyc-config@^1.0.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced" @@ -2381,6 +2388,11 @@ dependencies: "@types/yargs-parser" "*" +"@yarnpkg/lockfile@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz#e77a97fbd345b76d83245edcd17d393b1b41fb31" + integrity sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ== + "@zkochan/cmd-shim@^3.1.0": version "3.1.0" resolved "https://registry.yarnpkg.com/@zkochan/cmd-shim/-/cmd-shim-3.1.0.tgz#2ab8ed81f5bb5452a85f25758eb9b8681982fd2e" @@ -2431,7 +2443,7 @@ acorn-walk@^8.1.1: resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.1.1.tgz#3ddab7f84e4a7e2313f6c414c5b7dac85f4e3ebc" integrity sha512-FbJdceMlPHEAWJOILDk1fXD8lnTlEIWFkqtfk+MvmL5q/qlHfN7GEHcsFZWt/Tea9jRNPWUZG4G976nqAAmU9w== -acorn@^7.1.1, acorn@^7.4.0: +acorn@^7.1.1: version "7.4.1" resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa" integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== @@ -2487,16 +2499,6 @@ ajv@^6.10.0, ajv@^6.12.3, ajv@^6.12.4, ajv@~6.12.6: json-schema-traverse "^0.4.1" uri-js "^4.2.2" -ajv@^8.0.1: - version "8.5.0" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.5.0.tgz#695528274bcb5afc865446aa275484049a18ae4b" - integrity sha512-Y2l399Tt1AguU3BPRP9Fn4eN+Or+StUGWCUpbnFyXSo8NZ9S4uj+AG2pjs5apK+ZMOwYOz1+a+VKvKH7CudXgQ== - dependencies: - fast-deep-equal "^3.1.1" - json-schema-traverse "^1.0.0" - require-from-string "^2.0.2" - uri-js "^4.2.2" - all-contributors-cli@^6.20.0: version "6.20.0" resolved "https://registry.yarnpkg.com/all-contributors-cli/-/all-contributors-cli-6.20.0.tgz#9bc98dda38cb29cfe8afc8a78c004e14af25d2f6" @@ -3854,7 +3856,7 @@ debug@3.1.0: dependencies: ms "2.0.0" -debug@4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2: +debug@4, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2: version "4.3.2" resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.2.tgz#f0a49c18ac8779e31d4a0c6029dfb76873c7428b" integrity sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw== @@ -4144,6 +4146,14 @@ end-of-stream@^1.0.0, end-of-stream@^1.1.0: dependencies: once "^1.4.0" +enhanced-resolve@^5.8.2: + version "5.8.2" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.8.2.tgz#15ddc779345cbb73e97c611cd00c01c1e7bf4d8b" + integrity sha512-F27oB3WuHDzvR2DOGNTaYy0D5o0cnrv8TeI482VM4kYgQd/FT9lUQwuNsJ0oOHtBUq7eiW5ytqzp7nBFknL+GA== + dependencies: + graceful-fs "^4.2.4" + tapable "^2.2.0" + enquirer@^2.3.5, enquirer@^2.3.6, enquirer@~2.3.6: version "2.3.6" resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.3.6.tgz#2a7fe5dd634a1e4125a975ec994ff5456dc3734d" @@ -4325,6 +4335,14 @@ eslint-scope@^5.1.1: esrecurse "^4.3.0" estraverse "^4.1.1" +eslint-scope@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-6.0.0.tgz#9cf45b13c5ac8f3d4c50f46a5121f61b3e318978" + integrity sha512-uRDL9MWmQCkaFus8RF5K9/L/2fn+80yoW3jkD53l4shjCh26fCtvJGasxjUqP5OT87SYTxCVA3BwTUzuELx9kA== + dependencies: + esrecurse "^4.3.0" + estraverse "^5.2.0" + eslint-utils@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-2.1.0.tgz#d2de5e03424e707dc10c74068ddedae708741b27" @@ -4339,7 +4357,7 @@ eslint-utils@^3.0.0: dependencies: eslint-visitor-keys "^2.0.0" -eslint-visitor-keys@^1.1.0, eslint-visitor-keys@^1.3.0: +eslint-visitor-keys@^1.1.0: version "1.3.0" resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz#30ebd1ef7c2fdff01c3a4f151044af25fab0523e" integrity sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ== @@ -4349,36 +4367,41 @@ eslint-visitor-keys@^2.0.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz#21fdc8fbcd9c795cc0321f0563702095751511a8" integrity sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ== -eslint@^7.27.0: - version "7.27.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.27.0.tgz#665a1506d8f95655c9274d84bd78f7166b07e9c7" - integrity sha512-JZuR6La2ZF0UD384lcbnd0Cgg6QJjiCwhMD6eU4h/VGPcVGwawNNzKU41tgokGXnfjOOyI6QIffthhJTPzzuRA== +eslint-visitor-keys@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.0.0.tgz#e32e99c6cdc2eb063f204eda5db67bfe58bb4186" + integrity sha512-mJOZa35trBTb3IyRmo8xmKBZlxf+N7OnUl4+ZhJHs/r+0770Wh/LEACE2pqMGMe27G/4y8P2bYGk4J70IC5k1Q== + +eslint@^8.0.0-0: + version "8.0.0-beta.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.0.0-beta.0.tgz#965fa5161b7cc93f1c82fb9c617a3814dc95ba38" + integrity sha512-Q5wCLXSpq+RIa9QBrmHApNCpgqjBU5aeQbVfeAuc9DyBIWzsdivbiirbCmYBrdoFWUoGSYCYWSIpqrS2une7jg== dependencies: - "@babel/code-frame" "7.12.11" - "@eslint/eslintrc" "^0.4.1" + "@eslint/eslintrc" "^1.0.0" + "@humanwhocodes/config-array" "^0.6.0" ajv "^6.10.0" chalk "^4.0.0" cross-spawn "^7.0.2" - debug "^4.0.1" + debug "^4.3.2" doctrine "^3.0.0" enquirer "^2.3.5" escape-string-regexp "^4.0.0" - eslint-scope "^5.1.1" - eslint-utils "^2.1.0" - eslint-visitor-keys "^2.0.0" - espree "^7.3.1" + eslint-scope "^6.0.0" + eslint-utils "^3.0.0" + eslint-visitor-keys "^3.0.0" + espree "^8.0.0" esquery "^1.4.0" esutils "^2.0.2" fast-deep-equal "^3.1.3" file-entry-cache "^6.0.1" functional-red-black-tree "^1.0.1" - glob-parent "^5.0.0" + glob-parent "^6.0.1" globals "^13.6.0" ignore "^4.0.6" import-fresh "^3.0.0" imurmurhash "^0.1.4" is-glob "^4.0.0" - js-yaml "^3.13.1" + js-yaml "^4.1.0" json-stable-stringify-without-jsonify "^1.0.1" levn "^0.4.1" lodash.merge "^4.6.2" @@ -4386,22 +4409,21 @@ eslint@^7.27.0: natural-compare "^1.4.0" optionator "^0.9.1" progress "^2.0.0" - regexpp "^3.1.0" + regexpp "^3.2.0" semver "^7.2.1" strip-ansi "^6.0.0" strip-json-comments "^3.1.0" - table "^6.0.9" text-table "^0.2.0" v8-compile-cache "^2.0.3" -espree@^7.3.0, espree@^7.3.1: - version "7.3.1" - resolved "https://registry.yarnpkg.com/espree/-/espree-7.3.1.tgz#f2df330b752c6f55019f8bd89b7660039c1bbbb6" - integrity sha512-v3JCNCE64umkFpmkFGqzVKsOT0tN1Zr+ueqLZfpV1Ob8e+CEgPWa+OxCoGH3tnhimMKIaBm4m/vaRpJ/krRz2g== +espree@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/espree/-/espree-8.0.0.tgz#08c92c31814c96c96c54d3a35cc80f1cdb420275" + integrity sha512-y/+i23dwTjIDJrYCcjcAMr3c3UGbPIjC6THMQKjWmhP97fW0FPiI89kmpKfmgV/5jrkIi6toQP+CMm3qBE1Hig== dependencies: - acorn "^7.4.0" + acorn "^8.4.1" acorn-jsx "^5.3.1" - eslint-visitor-keys "^1.3.0" + eslint-visitor-keys "^3.0.0" esprima@^4.0.0, esprima@^4.0.1: version "4.0.1" @@ -4745,6 +4767,13 @@ find-up@^5.0.0: locate-path "^6.0.0" path-exists "^4.0.0" +find-yarn-workspace-root@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/find-yarn-workspace-root/-/find-yarn-workspace-root-2.0.0.tgz#f47fb8d239c900eb78179aa81b66673eac88f7bd" + integrity sha512-1IMnbjt4KzsQfnhnzNd8wUEgXZ44IzZaZmnLYx7D5FZlaHt2gW20Cri8Q+E/t5tIj4+epTBub+2Zxu/vNILzqQ== + dependencies: + micromatch "^4.0.2" + findup-sync@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/findup-sync/-/findup-sync-3.0.0.tgz#17b108f9ee512dfb7a5c7f3c8b27ea9e1a9c08d1" @@ -4847,6 +4876,15 @@ fs-extra@^10.0.0: jsonfile "^6.0.1" universalify "^2.0.0" +fs-extra@^7.0.1, fs-extra@~7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9" + integrity sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw== + dependencies: + graceful-fs "^4.1.2" + jsonfile "^4.0.0" + universalify "^0.1.0" + fs-extra@^9.1.0: version "9.1.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.1.0.tgz#5954460c764a8da2094ba3554bf839e6b9a7c86d" @@ -4857,15 +4895,6 @@ fs-extra@^9.1.0: jsonfile "^6.0.1" universalify "^2.0.0" -fs-extra@~7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9" - integrity sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw== - dependencies: - graceful-fs "^4.1.2" - jsonfile "^4.0.0" - universalify "^0.1.0" - fs-minipass@^1.2.7: version "1.2.7" resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.7.tgz#ccff8570841e7fe4265693da88936c55aed7f7c7" @@ -5088,6 +5117,13 @@ glob-parent@^5.0.0, glob-parent@^5.1.0: dependencies: is-glob "^4.0.1" +glob-parent@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-6.0.1.tgz#42054f685eb6a44e7a7d189a96efa40a54971aa7" + integrity sha512-kEVjS71mQazDBHKcsq4E9u/vUzaLcw1A8EtUeydawvIWQCJM0qQ08G1H7/XTjFUulla6XQiDOG6MXSaG0HDKog== + dependencies: + is-glob "^4.0.1" + glob-parent@~5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" @@ -5168,13 +5204,6 @@ globals@^11.1.0: resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== -globals@^12.1.0: - version "12.4.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-12.4.0.tgz#a18813576a41b00a24a97e7f815918c2e19925f8" - integrity sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg== - dependencies: - type-fest "^0.8.1" - globals@^13.6.0: version "13.9.0" resolved "https://registry.yarnpkg.com/globals/-/globals-13.9.0.tgz#4bf2bf635b334a173fb1daf7c5e6b218ecdc06cb" @@ -5182,6 +5211,13 @@ globals@^13.6.0: dependencies: type-fest "^0.20.2" +globals@^13.9.0: + version "13.11.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-13.11.0.tgz#40ef678da117fe7bd2e28f1fab24951bd0255be7" + integrity sha512-08/xrJ7wQjK9kkkRoI3OFUBbLx4f+6x3SGwcPvQ0QH6goFDrOU2oyAWrmh3dJezu65buo+HBMzAMQy6rovVC3g== + dependencies: + type-fest "^0.20.2" + globby@^11.0.1, globby@^11.0.3: version "11.0.4" resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.4.tgz#2cbaff77c2f2a62e71e9b2813a67b97a3a3001a5" @@ -6950,11 +6986,6 @@ json-schema-traverse@^0.4.1: resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== -json-schema-traverse@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz#ae7bcb3656ab77a73ba5c49bf654f38e6b6860e2" - integrity sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug== - json-schema@0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" @@ -7044,6 +7075,13 @@ kind-of@^6.0.0, kind-of@^6.0.2, kind-of@^6.0.3: resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== +klaw-sync@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/klaw-sync/-/klaw-sync-6.0.0.tgz#1fd2cfd56ebb6250181114f0a581167099c2b28c" + integrity sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ== + dependencies: + graceful-fs "^4.1.11" + kleur@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e" @@ -7271,11 +7309,6 @@ lodash.templatesettings@^4.0.0: dependencies: lodash._reinterpolate "^3.0.0" -lodash.truncate@^4.4.2: - version "4.4.2" - resolved "https://registry.yarnpkg.com/lodash.truncate/-/lodash.truncate-4.4.2.tgz#5a350da0b1113b837ecfffd5812cbe58d6eae193" - integrity sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM= - lodash.uniq@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" @@ -8342,6 +8375,25 @@ pascalcase@^0.1.1: resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14" integrity sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ= +patch-package@^6.4.7: + version "6.4.7" + resolved "https://registry.yarnpkg.com/patch-package/-/patch-package-6.4.7.tgz#2282d53c397909a0d9ef92dae3fdeb558382b148" + integrity sha512-S0vh/ZEafZ17hbhgqdnpunKDfzHQibQizx9g8yEf5dcVk3KOflOfdufRXQX8CSEkyOQwuM/bNz1GwKvFj54kaQ== + dependencies: + "@yarnpkg/lockfile" "^1.1.0" + chalk "^2.4.2" + cross-spawn "^6.0.5" + find-yarn-workspace-root "^2.0.0" + fs-extra "^7.0.1" + is-ci "^2.0.0" + klaw-sync "^6.0.0" + minimist "^1.2.0" + open "^7.4.2" + rimraf "^2.6.3" + semver "^5.6.0" + slash "^2.0.0" + tmp "^0.0.33" + path-dirname@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0" @@ -8818,7 +8870,7 @@ regex-not@^1.0.0, regex-not@^1.0.2: extend-shallow "^3.0.2" safe-regex "^1.1.0" -regexpp@^3.1.0: +regexpp@^3.1.0, regexpp@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.2.0.tgz#0425a2768d8f23bad70ca4b90461fa2f1213e1b2" integrity sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg== @@ -8871,7 +8923,7 @@ require-directory@^2.1.1: resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= -require-from-string@^2.0.1, require-from-string@^2.0.2: +require-from-string@^2.0.1: version "2.0.2" resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.2.tgz#89a7fdd938261267318eafe14f9c32e598c36909" integrity sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw== @@ -9649,17 +9701,10 @@ symbol-tree@^3.2.4: resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2" integrity sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw== -table@^6.0.9: - version "6.7.1" - resolved "https://registry.yarnpkg.com/table/-/table-6.7.1.tgz#ee05592b7143831a8c94f3cee6aae4c1ccef33e2" - integrity sha512-ZGum47Yi6KOOFDE8m223td53ath2enHcYLgOCjGr5ngu8bdIARQk6mN/wRMv4yMRcHnCSnHbCEha4sobQx5yWg== - dependencies: - ajv "^8.0.1" - lodash.clonedeep "^4.5.0" - lodash.truncate "^4.4.2" - slice-ansi "^4.0.0" - string-width "^4.2.0" - strip-ansi "^6.0.0" +tapable@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.0.tgz#5c373d281d9c672848213d0e037d1c4165ab426b" + integrity sha512-FBk4IesMV1rBxX2tfiK8RAmogtWn53puLOQlvO8XuwlgxcYbP4mVPS9Ph4aeamSyyVjOl24aYWAuc8U5kCVwMw== tar@6.1.11: version "6.1.11" From 79ae03b8adbae2b0a86276711a9c834af01bbb61 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Sat, 21 Aug 2021 18:19:32 -0700 Subject: [PATCH 22/44] feat(eslint-plugin): remove `no-unused-vars-experimental` --- packages/eslint-plugin/src/rules/index.ts | 2 - .../src/rules/no-unused-vars-experimental.ts | 364 ------------------ 2 files changed, 366 deletions(-) delete mode 100644 packages/eslint-plugin/src/rules/no-unused-vars-experimental.ts diff --git a/packages/eslint-plugin/src/rules/index.ts b/packages/eslint-plugin/src/rules/index.ts index 3ab88b478e2d..2d9730dd8c8a 100644 --- a/packages/eslint-plugin/src/rules/index.ts +++ b/packages/eslint-plugin/src/rules/index.ts @@ -78,7 +78,6 @@ import noUnsafeMemberAccess from './no-unsafe-member-access'; import noUnsafeReturn from './no-unsafe-return'; import noUnusedExpressions from './no-unused-expressions'; import noUnusedVars from './no-unused-vars'; -import noUnusedVarsExperimental from './no-unused-vars-experimental'; import noUseBeforeDefine from './no-use-before-define'; import noUselessConstructor from './no-useless-constructor'; import noVarRequires from './no-var-requires'; @@ -201,7 +200,6 @@ export default { 'no-unsafe-return': noUnsafeReturn, 'no-unused-expressions': noUnusedExpressions, 'no-unused-vars': noUnusedVars, - 'no-unused-vars-experimental': noUnusedVarsExperimental, 'no-use-before-define': noUseBeforeDefine, 'no-useless-constructor': noUselessConstructor, 'no-var-requires': noVarRequires, diff --git a/packages/eslint-plugin/src/rules/no-unused-vars-experimental.ts b/packages/eslint-plugin/src/rules/no-unused-vars-experimental.ts deleted file mode 100644 index 751543295229..000000000000 --- a/packages/eslint-plugin/src/rules/no-unused-vars-experimental.ts +++ /dev/null @@ -1,364 +0,0 @@ -/* eslint-disable @typescript-eslint/internal/prefer-ast-types-enum, no-fallthrough */ -import { TSESTree } from '@typescript-eslint/experimental-utils'; -import * as ts from 'typescript'; -import * as util from '../util'; - -export type Options = [ - { - ignoredNamesRegex?: string | boolean; - ignoreArgsIfArgsAfterAreUsed?: boolean; - }, -]; -export type MessageIds = - | 'unused' - | 'unusedWithIgnorePattern' - | 'unusedImport' - | 'unusedTypeParameters'; - -type NodeWithTypeParams = ts.Node & { - typeParameters: ts.NodeArray; -}; - -export const DEFAULT_IGNORED_REGEX_STRING = '^_'; -export default util.createRule({ - name: 'no-unused-vars-experimental', - meta: { - type: 'problem', - docs: { - description: 'Disallow unused variables and arguments', - category: 'Best Practices', - recommended: false, - }, - deprecated: true, - replacedBy: ['no-unused-vars'], - schema: [ - { - type: 'object', - properties: { - ignoredNamesRegex: { - oneOf: [ - { - type: 'string', - }, - { - type: 'boolean', - enum: [false], - }, - ], - }, - ignoreArgsIfArgsAfterAreUsed: { - type: 'boolean', - }, - }, - additionalProperties: false, - }, - ], - messages: { - unused: "{{type}} '{{name}}' is declared but its value is never read.", - unusedWithIgnorePattern: - "{{type}} '{{name}}' is declared but its value is never read. Allowed unused names must match {{pattern}}.", - unusedImport: 'All imports in import declaration are unused.', - unusedTypeParameters: 'All type parameters are unused.', - }, - }, - defaultOptions: [ - { - ignoredNamesRegex: DEFAULT_IGNORED_REGEX_STRING, - ignoreArgsIfArgsAfterAreUsed: false, - }, - ], - create(context, [userOptions]) { - const parserServices = util.getParserServices(context, true); - const tsProgram = parserServices.program; - const afterAllDiagnosticsCallbacks: (() => void)[] = []; - - const options = { - ignoredNames: - userOptions && typeof userOptions.ignoredNamesRegex === 'string' - ? new RegExp(userOptions.ignoredNamesRegex) - : null, - ignoreArgsIfArgsAfterAreUsed: - userOptions.ignoreArgsIfArgsAfterAreUsed ?? false, - }; - - function handleIdentifier(identifier: ts.Identifier): void { - function report(type: string): void { - const node = parserServices.tsNodeToESTreeNodeMap.get(identifier); - const regex = options.ignoredNames; - const name = identifier.getText(); - if (regex) { - if (!regex.test(name)) { - context.report({ - node, - messageId: 'unusedWithIgnorePattern', - data: { - name, - type, - pattern: regex.toString(), - }, - }); - } - } else { - context.report({ - node, - messageId: 'unused', - data: { - name, - type, - }, - }); - } - } - - const parent = identifier.parent; - - // is a single variable diagnostic - switch (parent.kind) { - case ts.SyntaxKind.BindingElement: - case ts.SyntaxKind.ObjectBindingPattern: - report('Destructured Variable'); - break; - - case ts.SyntaxKind.ClassDeclaration: - report('Class'); - break; - - case ts.SyntaxKind.EnumDeclaration: - report('Enum'); - break; - - case ts.SyntaxKind.FunctionDeclaration: - report('Function'); - break; - - // this won't happen because there are specific nodes that wrap up named/default import identifiers - // case ts.SyntaxKind.ImportDeclaration: - // import equals is always treated as a variable - case ts.SyntaxKind.ImportEqualsDeclaration: - // the default import is NOT used, but a named import is used - case ts.SyntaxKind.ImportClause: - // a named import is NOT used, but either another named import, or the default import is used - case ts.SyntaxKind.ImportSpecifier: - // a namespace import is NOT used, but the default import is used - case ts.SyntaxKind.NamespaceImport: - report('Import'); - break; - - case ts.SyntaxKind.InterfaceDeclaration: - report('Interface'); - break; - - case ts.SyntaxKind.MethodDeclaration: - report('Method'); - break; - - case ts.SyntaxKind.Parameter: - handleParameterDeclaration( - identifier, - parent as ts.ParameterDeclaration, - ); - break; - - case ts.SyntaxKind.PropertyDeclaration: - report('Property'); - break; - - case ts.SyntaxKind.TypeAliasDeclaration: - report('Type'); - break; - - case ts.SyntaxKind.TypeParameter: - handleTypeParam(identifier); - break; - - case ts.SyntaxKind.VariableDeclaration: - report('Variable'); - break; - - default: - throw new Error(`Unknown node with kind ${parent.kind}.`); - // TODO - should we just handle this gracefully? - // report('Unknown Node'); - // break; - } - } - - const unusedParameters = new Set(); - function handleParameterDeclaration( - identifier: ts.Identifier, - parent: ts.ParameterDeclaration, - ): void { - const name = identifier.getText(); - // regardless of if the parameter is ignored, track that it had a diagnostic fired on it - unusedParameters.add(identifier); - - /* - NOTE - Typescript will automatically ignore parameters that have a - leading underscore in their name. We cannot do anything about this. - */ - - function report(): void { - const node = parserServices.tsNodeToESTreeNodeMap.get(identifier); - context.report({ - node, - messageId: 'unused', - data: { - name, - type: 'Parameter', - }, - }); - } - - const isLastParameter = - parent.parent.parameters.indexOf(parent) === - parent.parent.parameters.length - 1; - if (!isLastParameter && options.ignoreArgsIfArgsAfterAreUsed) { - // once all diagnostics are processed, we can check if the following args are unused - afterAllDiagnosticsCallbacks.push(() => { - for (const param of parent.parent.parameters) { - if (!unusedParameters.has(param.name)) { - return; - } - } - - // none of the following params were unused, so report - report(); - }); - } else { - report(); - } - } - - function handleImportDeclaration(parent: ts.ImportDeclaration): void { - // the entire import statement is unused - - /* - NOTE - Typescript will automatically ignore imports that have a - leading underscore in their name. We cannot do anything about this. - */ - - context.report({ - messageId: 'unusedImport', - node: parserServices.tsNodeToESTreeNodeMap.get(parent), - }); - } - - function handleDestructure(parent: ts.BindingPattern): void { - // the entire destructure is unused - // note that this case only ever triggers for simple, single-level destructured objects - // i.e. these will not trigger it: - // - const {a:_a, b, c: {d}} = z; - // - const [a, b] = c; - - parent.elements.forEach(element => { - if (element.kind === ts.SyntaxKind.BindingElement) { - const name = element.name; - if (name.kind === ts.SyntaxKind.Identifier) { - handleIdentifier(name); - } - } - }); - } - - function handleTypeParamList(node: NodeWithTypeParams): void { - // the entire generic decl list is unused - - /* - NOTE - Typescript will automatically ignore generics that have a - leading underscore in their name. We cannot do anything about this. - */ - - const parent = parserServices.tsNodeToESTreeNodeMap.get( - node as never, - ) as { - typeParameters: TSESTree.TSTypeParameterDeclaration; - }; - context.report({ - messageId: 'unusedTypeParameters', - node: parent.typeParameters, - }); - } - function handleTypeParam(identifier: ts.Identifier): void { - context.report({ - node: parserServices.tsNodeToESTreeNodeMap.get(identifier), - messageId: 'unused', - data: { - name: identifier.getText(), - type: 'Type Parameter', - }, - }); - } - - return { - 'Program:exit'(program: TSESTree.Program): void { - const tsNode = parserServices.esTreeNodeToTSNodeMap.get(program); - const sourceFile = util.getSourceFileOfNode(tsNode); - const diagnostics = tsProgram.getSemanticDiagnostics(sourceFile); - - diagnostics.forEach(diag => { - if (isUnusedDiagnostic(diag.code)) { - if (diag.start !== undefined) { - const node = util.getTokenAtPosition(sourceFile, diag.start); - const parent = node.parent; - if (isIdentifier(node)) { - handleIdentifier(node); - } else if (isImport(parent)) { - handleImportDeclaration(parent); - } else if (isDestructure(parent)) { - handleDestructure(parent); - } else if (isGeneric(node, parent)) { - handleTypeParamList(parent); - } - } - } - }); - - // trigger all the checks to be done after all the diagnostics have been evaluated - afterAllDiagnosticsCallbacks.forEach(cb => cb()); - }, - }; - }, -}); - -/** - * Checks if the diagnostic code is one of the expected "unused var" codes - */ -function isUnusedDiagnostic(code: number): boolean { - return [ - 6133, // '{0}' is declared but never used. - 6138, // Property '{0}' is declared but its value is never read. - 6192, // All imports in import declaration are unused. - 6196, // '{0}' is declared but its value is never read. - 6198, // All destructured elements are unused. - 6199, // All variables are unused. - 6205, // All type parameters are unused. - ].includes(code); -} - -/** - * Checks if the given node is a destructuring pattern - */ -function isDestructure(node: ts.Node): node is ts.BindingPattern { - return ( - node.kind === ts.SyntaxKind.ObjectBindingPattern || - node.kind === ts.SyntaxKind.ArrayBindingPattern - ); -} - -function isImport(node: ts.Node): node is ts.ImportDeclaration { - return node.kind === ts.SyntaxKind.ImportDeclaration; -} - -function isIdentifier(node: ts.Node): node is ts.Identifier { - return node.kind === ts.SyntaxKind.Identifier; -} - -function isGeneric( - node: ts.Node, - parent: ts.Node & Partial, -): parent is NodeWithTypeParams { - return ( - node.kind === ts.SyntaxKind.LessThanToken && - parent.typeParameters !== undefined - ); -} From 3ed09bd6d4960e1d1fae0aaf061fcdb2c9bcd533 Mon Sep 17 00:00:00 2001 From: thomas michael wallace Date: Sun, 22 Aug 2021 02:26:22 +0100 Subject: [PATCH 23/44] chore(eslint-plugin): remove support for eslint 5 (#2683) --- packages/eslint-plugin-tslint/package.json | 2 +- packages/eslint-plugin/package.json | 2 +- packages/eslint-plugin/src/rules/indent.ts | 5 +---- packages/eslint-plugin/src/rules/init-declarations.ts | 7 +------ packages/eslint-plugin/src/rules/keyword-spacing.ts | 7 +------ .../eslint-plugin/src/rules/lines-between-class-members.ts | 5 +---- packages/eslint-plugin/src/rules/no-invalid-this.ts | 1 + packages/eslint-plugin/src/rules/no-loop-func.ts | 5 +---- packages/eslint-plugin/src/rules/no-magic-numbers.ts | 5 +---- packages/eslint-plugin/src/rules/no-unused-expressions.ts | 1 + packages/eslint-plugin/src/rules/no-useless-constructor.ts | 1 + packages/eslint-plugin/src/rules/quotes.ts | 1 + packages/eslint-plugin/src/rules/semi.ts | 1 + packages/eslint-plugin/src/rules/space-infix-ops.ts | 4 +++- packages/parser/package.json | 2 +- 15 files changed, 17 insertions(+), 32 deletions(-) diff --git a/packages/eslint-plugin-tslint/package.json b/packages/eslint-plugin-tslint/package.json index 0df408974e52..7917ab0f1709 100644 --- a/packages/eslint-plugin-tslint/package.json +++ b/packages/eslint-plugin-tslint/package.json @@ -42,7 +42,7 @@ "lodash": "^4.17.21" }, "peerDependencies": { - "eslint": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0", + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0-0", "tslint": "^5.0.0 || ^6.0.0", "typescript": "*" }, diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index 0546e3d3b09d..b750d5e02ab8 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -64,7 +64,7 @@ }, "peerDependencies": { "@typescript-eslint/parser": "^4.0.0", - "eslint": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0" + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0-0" }, "peerDependenciesMeta": { "typescript": { diff --git a/packages/eslint-plugin/src/rules/indent.ts b/packages/eslint-plugin/src/rules/indent.ts index 129754543c8f..a87772dd1f66 100644 --- a/packages/eslint-plugin/src/rules/indent.ts +++ b/packages/eslint-plugin/src/rules/indent.ts @@ -100,10 +100,7 @@ export default util.createRule({ fixable: 'whitespace', hasSuggestions: baseRule.meta.hasSuggestions, schema: baseRule.meta.schema, - messages: baseRule.meta.messages ?? { - wrongIndentation: - 'Expected indentation of {{expected}} but found {{actual}}.', - }, + messages: baseRule.meta.messages, }, defaultOptions: [ // typescript docs and playground use 4 space indent diff --git a/packages/eslint-plugin/src/rules/init-declarations.ts b/packages/eslint-plugin/src/rules/init-declarations.ts index 4557faeb7d77..a75d6e031cd0 100644 --- a/packages/eslint-plugin/src/rules/init-declarations.ts +++ b/packages/eslint-plugin/src/rules/init-declarations.ts @@ -27,12 +27,7 @@ export default createRule({ }, hasSuggestions: baseRule.meta.hasSuggestions, schema: baseRule.meta.schema, - messages: baseRule.meta.messages ?? { - initialized: - "Variable '{{idName}}' should be initialized on declaration.", - notInitialized: - "Variable '{{idName}}' should not be initialized on declaration.", - }, + messages: baseRule.meta.messages, }, defaultOptions: ['always'], create(context) { diff --git a/packages/eslint-plugin/src/rules/keyword-spacing.ts b/packages/eslint-plugin/src/rules/keyword-spacing.ts index f7bedfc11943..18c1c60bbb95 100644 --- a/packages/eslint-plugin/src/rules/keyword-spacing.ts +++ b/packages/eslint-plugin/src/rules/keyword-spacing.ts @@ -20,12 +20,7 @@ export default util.createRule({ fixable: 'whitespace', hasSuggestions: baseRule.meta.hasSuggestions, schema: baseRule.meta.schema, - messages: baseRule.meta.messages ?? { - expectedBefore: 'Expected space(s) before "{{value}}".', - expectedAfter: 'Expected space(s) after "{{value}}".', - unexpectedBefore: 'Unexpected space(s) before "{{value}}".', - unexpectedAfter: 'Unexpected space(s) after "{{value}}".', - }, + messages: baseRule.meta.messages, }, defaultOptions: [{}], diff --git a/packages/eslint-plugin/src/rules/lines-between-class-members.ts b/packages/eslint-plugin/src/rules/lines-between-class-members.ts index 0cca8619c0a5..0e52e7b958cc 100644 --- a/packages/eslint-plugin/src/rules/lines-between-class-members.ts +++ b/packages/eslint-plugin/src/rules/lines-between-class-members.ts @@ -35,10 +35,7 @@ export default util.createRule({ fixable: 'whitespace', hasSuggestions: baseRule.meta.hasSuggestions, schema, - messages: baseRule.meta.messages ?? { - never: 'Unexpected blank line between class members.', - always: 'Expected blank line between class members.', - }, + messages: baseRule.meta.messages, }, defaultOptions: [ 'always', diff --git a/packages/eslint-plugin/src/rules/no-invalid-this.ts b/packages/eslint-plugin/src/rules/no-invalid-this.ts index 2d802cdba04d..eb21da3ff8bd 100644 --- a/packages/eslint-plugin/src/rules/no-invalid-this.ts +++ b/packages/eslint-plugin/src/rules/no-invalid-this.ts @@ -25,6 +25,7 @@ export default createRule({ recommended: false, extendsBaseRule: true, }, + // TODO: this rule has only had messages since v7.0 - remove this when we remove support for v6 messages: baseRule.meta.messages ?? { unexpectedThis: "Unexpected 'this'.", }, diff --git a/packages/eslint-plugin/src/rules/no-loop-func.ts b/packages/eslint-plugin/src/rules/no-loop-func.ts index 5560acf0952d..b3e57903dd16 100644 --- a/packages/eslint-plugin/src/rules/no-loop-func.ts +++ b/packages/eslint-plugin/src/rules/no-loop-func.ts @@ -24,10 +24,7 @@ export default util.createRule({ }, hasSuggestions: baseRule.meta.hasSuggestions, schema: [], - messages: baseRule?.meta.messages ?? { - unsafeRefs: - 'Function declared in a loop contains unsafe references to variable(s) {{ varNames }}.', - }, + messages: baseRule.meta.messages, }, defaultOptions: [], create(context) { diff --git a/packages/eslint-plugin/src/rules/no-magic-numbers.ts b/packages/eslint-plugin/src/rules/no-magic-numbers.ts index 20d06f05f563..8171815bb56b 100644 --- a/packages/eslint-plugin/src/rules/no-magic-numbers.ts +++ b/packages/eslint-plugin/src/rules/no-magic-numbers.ts @@ -43,10 +43,7 @@ export default util.createRule({ }, }, ], - messages: baseRule.meta.messages ?? { - useConst: "Number constants declarations must use 'const'.", - noMagic: 'No magic number: {{raw}}.', - }, + messages: baseRule.meta.messages, }, defaultOptions: [ { diff --git a/packages/eslint-plugin/src/rules/no-unused-expressions.ts b/packages/eslint-plugin/src/rules/no-unused-expressions.ts index f2f0e2c73b2b..527ba14e03ce 100644 --- a/packages/eslint-plugin/src/rules/no-unused-expressions.ts +++ b/packages/eslint-plugin/src/rules/no-unused-expressions.ts @@ -22,6 +22,7 @@ export default util.createRule({ }, hasSuggestions: baseRule.meta.hasSuggestions, schema: baseRule.meta.schema, + // TODO: this rule has only had messages since v7.0 - remove this when we remove support for v6 messages: baseRule.meta.messages ?? { unusedExpression: 'Expected an assignment or function call and instead saw an expression.', diff --git a/packages/eslint-plugin/src/rules/no-useless-constructor.ts b/packages/eslint-plugin/src/rules/no-useless-constructor.ts index a4532ce72864..d1134bd09db2 100644 --- a/packages/eslint-plugin/src/rules/no-useless-constructor.ts +++ b/packages/eslint-plugin/src/rules/no-useless-constructor.ts @@ -57,6 +57,7 @@ export default util.createRule({ }, hasSuggestions: baseRule.meta.hasSuggestions, schema: baseRule.meta.schema, + // TODO: this rule has only had messages since v7.0 - remove this when we remove support for v6 messages: baseRule.meta.messages ?? { noUselessConstructor: 'Useless constructor.', }, diff --git a/packages/eslint-plugin/src/rules/quotes.ts b/packages/eslint-plugin/src/rules/quotes.ts index e4af60fd0412..699df89da156 100644 --- a/packages/eslint-plugin/src/rules/quotes.ts +++ b/packages/eslint-plugin/src/rules/quotes.ts @@ -23,6 +23,7 @@ export default util.createRule({ }, fixable: 'code', hasSuggestions: baseRule.meta.hasSuggestions, + // TODO: this rule has only had messages since v7.0 - remove this when we remove support for v6 messages: baseRule.meta.messages ?? { wrongQuotes: 'Strings must use {{description}}.', }, diff --git a/packages/eslint-plugin/src/rules/semi.ts b/packages/eslint-plugin/src/rules/semi.ts index 05c4c6b1c3aa..c8829ab83e34 100644 --- a/packages/eslint-plugin/src/rules/semi.ts +++ b/packages/eslint-plugin/src/rules/semi.ts @@ -25,6 +25,7 @@ export default util.createRule({ fixable: 'code', hasSuggestions: baseRule.meta.hasSuggestions, schema: baseRule.meta.schema, + // TODO: this rule has only had messages since v7.0 - remove this when we remove support for v6 messages: baseRule.meta.messages ?? { missingSemi: 'Missing semicolon.', extraSemi: 'Extra semicolon.', diff --git a/packages/eslint-plugin/src/rules/space-infix-ops.ts b/packages/eslint-plugin/src/rules/space-infix-ops.ts index 86fb8d93d53f..eb92bd2f112c 100644 --- a/packages/eslint-plugin/src/rules/space-infix-ops.ts +++ b/packages/eslint-plugin/src/rules/space-infix-ops.ts @@ -26,8 +26,10 @@ export default util.createRule({ fixable: baseRule.meta.fixable, hasSuggestions: baseRule.meta.hasSuggestions, schema: baseRule.meta.schema, - messages: baseRule.meta.messages ?? { + messages: { + // @ts-expect-error -- we report on this messageId so we need to ensure it's there in case ESLint changes in future missingSpace: "Operator '{{operator}}' must be spaced.", + ...baseRule.meta.messages, }, }, defaultOptions: [ diff --git a/packages/parser/package.json b/packages/parser/package.json index 89c075d6afe6..ba9f66b31764 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -41,7 +41,7 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "peerDependencies": { - "eslint": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0" + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0-0" }, "dependencies": { "@typescript-eslint/scope-manager": "4.33.0", From e2641246571b69df36cde5cb7bce7c4fffc43f98 Mon Sep 17 00:00:00 2001 From: Sergey Date: Sun, 22 Aug 2021 04:29:45 +0300 Subject: [PATCH 24/44] feat(eslint-plugin): [member-ordering] add support for getters and setters (#3611) * Getters/setters * Fix decorated ordering * Add test --- .../docs/rules/member-ordering.md | 159 ++++++++++++++++ .../src/rules/member-ordering.ts | 77 +++++++- .../tests/rules/member-ordering.test.ts | 179 ++++++++++++++++++ 3 files changed, 412 insertions(+), 3 deletions(-) diff --git a/packages/eslint-plugin/docs/rules/member-ordering.md b/packages/eslint-plugin/docs/rules/member-ordering.md index eda1c573c8e9..98cff7da670f 100644 --- a/packages/eslint-plugin/docs/rules/member-ordering.md +++ b/packages/eslint-plugin/docs/rules/member-ordering.md @@ -77,6 +77,64 @@ There are multiple ways to specify the member types. The most explicit and granu "protected-constructor", "private-constructor", + // Getters + "public-static-get", + "protected-static-get", + "private-static-get", + + "public-decorated-get", + "protected-decorated-get", + "private-decorated-get", + + "public-instance-get", + "protected-instance-get", + "private-instance-get", + + "public-abstract-get", + "protected-abstract-get", + "private-abstract-get", + + "public-get", + "protected-get", + "private-get", + + "static-get", + "instance-get", + "abstract-get", + + "decorated-get", + + "get", + + // Setters + "public-static-set", + "protected-static-set", + "private-static-set", + + "public-decorated-set", + "protected-decorated-set", + "private-decorated-set", + + "public-instance-set", + "protected-instance-set", + "private-instance-set", + + "public-abstract-set", + "protected-abstract-set", + "private-abstract-set", + + "public-set", + "protected-set", + "private-set", + + "static-set", + "instance-set", + "abstract-set", + + "decorated-set", + + "set", + // Methods "public-static-method", "protected-static-method", @@ -112,6 +170,16 @@ It is also possible to group member types by their accessibility (`static`, `ins // Constructors // Only the accessibility of constructors is configurable. See below. + // Getters + "public-get", // = ["public-static-get", "public-instance-get"] + "protected-get", // = ["protected-static-get", "protected-instance-get"] + "private-get", // = ["private-static-get", "private-instance-get"] + + // Setters + "public-set", // = ["public-static-set", "public-instance-set"] + "protected-set", // = ["protected-static-set", "protected-instance-set"] + "private-set", // = ["private-static-set", "private-instance-set"] + // Methods "public-method", // = ["public-static-method", "public-instance-method"] "protected-method", // = ["protected-static-method", "protected-instance-method"] @@ -139,6 +207,21 @@ their accessibility. // Constructors // There are no decorators for constructors. + // Getters + "public-decorated-get", + "protected-decorated-get", + "private-decorated-get", + + "decorated-get" // = ["public-decorated-get", "protected-decorated-get", "private-decorated-get"] + + // Setters + "public-decorated-set", + "protected-decorated-set", + "private-decorated-set", + + "decorated-set" // = ["public-decorated-set", "protected-decorated-set", "private-decorated-set"] + + // Methods "public-decorated-method", "protected-decorated-method", "private-decorated-method", @@ -164,6 +247,16 @@ Another option is to group the member types by their scope (`public`, `protected // Constructors "constructor", // = ["public-constructor", "protected-constructor", "private-constructor"] + // Getters + "static-get", // = ["public-static-get", "protected-static-get", "private-static-get"] + "instance-get", // = ["public-instance-get", "protected-instance-get", "private-instance-get"] + "abstract-get" // = ["public-abstract-get", "protected-abstract-get", "private-abstract-get"] + + // Setters + "static-set", // = ["public-static-set", "protected-static-set", "private-static-set"] + "instance-set", // = ["public-instance-set", "protected-instance-set", "private-instance-set"] + "abstract-set" // = ["public-abstract-set", "protected-abstract-set", "private-abstract-set"] + // Methods "static-method", // = ["public-static-method", "protected-static-method", "private-static-method"] "instance-method", // = ["public-instance-method", "protected-instance-method", "private-instance-method"] @@ -187,6 +280,14 @@ The third grouping option is to ignore both scope and accessibility. // Constructors // Only the accessibility of constructors is configurable. See above. + // Getters + "get" // = ["public-static-get", "protected-static-get", "private-static-get", "public-instance-get", "protected-instance-get", "private-instance-get", + // "public-abstract-get", "protected-abstract-get", "private-abstract-get"] + + // Setters + "set" // = ["public-static-set", "protected-static-set", "private-static-set", "public-instance-set", "protected-instance-set", "private-instance-set", + // "public-abstract-set", "protected-abstract-set", "private-abstract-set"] + // Methods "method" // = ["public-static-method", "protected-static-method", "private-static-method", "public-instance-method", "protected-instance-method", "private-instance-method", // "public-abstract-method", "protected-abstract-method", "private-abstract-method"] @@ -239,6 +340,64 @@ The default configuration looks as follows: "constructor", + // Getters + "public-static-get", + "protected-static-get", + "private-static-get", + + "public-decorated-get", + "protected-decorated-get", + "private-decorated-get", + + "public-instance-get", + "protected-instance-get", + "private-instance-get", + + "public-abstract-get", + "protected-abstract-get", + "private-abstract-get", + + "public-get", + "protected-get", + "private-get", + + "static-get", + "instance-get", + "abstract-get", + + "decorated-get", + + "get", + + // Setters + "public-static-set", + "protected-static-set", + "private-static-set", + + "public-decorated-set", + "protected-decorated-set", + "private-decorated-set", + + "public-instance-set", + "protected-instance-set", + "private-instance-set", + + "public-abstract-set", + "protected-abstract-set", + "private-abstract-set", + + "public-set", + "protected-set", + "private-set", + + "static-set", + "instance-set", + "abstract-set", + + "decorated-set", + + "set", + // Methods "public-static-method", "protected-static-method", diff --git a/packages/eslint-plugin/src/rules/member-ordering.ts b/packages/eslint-plugin/src/rules/member-ordering.ts index a6b1b74c20e8..34c922a39181 100644 --- a/packages/eslint-plugin/src/rules/member-ordering.ts +++ b/packages/eslint-plugin/src/rules/member-ordering.ts @@ -93,6 +93,64 @@ export const defaultOrder = [ 'constructor', + // Getters + 'public-static-get', + 'protected-static-get', + 'private-static-get', + + 'public-decorated-get', + 'protected-decorated-get', + 'private-decorated-get', + + 'public-instance-get', + 'protected-instance-get', + 'private-instance-get', + + 'public-abstract-get', + 'protected-abstract-get', + 'private-abstract-get', + + 'public-get', + 'protected-get', + 'private-get', + + 'static-get', + 'instance-get', + 'abstract-get', + + 'decorated-get', + + 'get', + + // Setters + 'public-static-set', + 'protected-static-set', + 'private-static-set', + + 'public-decorated-set', + 'protected-decorated-set', + 'private-decorated-set', + + 'public-instance-set', + 'protected-instance-set', + 'private-instance-set', + + 'public-abstract-set', + 'protected-abstract-set', + 'private-abstract-set', + + 'public-set', + 'protected-set', + 'private-set', + + 'static-set', + 'instance-set', + 'abstract-set', + + 'decorated-set', + + 'set', + // Methods 'public-static-method', 'protected-static-method', @@ -129,6 +187,8 @@ const allMemberTypes = [ 'method', 'call-signature', 'constructor', + 'get', + 'set', ].reduce((all, type) => { all.push(type); @@ -137,8 +197,13 @@ const allMemberTypes = [ all.push(`${accessibility}-${type}`); // e.g. `public-field` } - // Only class instance fields and methods can have decorators attached to them - if (type === 'field' || type === 'method') { + // Only class instance fields, methods, get and set can have decorators attached to them + if ( + type === 'field' || + type === 'method' || + type === 'get' || + type === 'set' + ) { const decoratedMemberType = `${accessibility}-decorated-${type}`; const decoratedMemberTypeNoAccessibility = `decorated-${type}`; if (!all.includes(decoratedMemberType)) { @@ -292,7 +357,13 @@ function getRank( if (supportsModifiers) { const decorated = 'decorators' in node && node.decorators!.length > 0; - if (decorated && (type === 'field' || type === 'method')) { + if ( + decorated && + (type === 'field' || + type === 'method' || + type === 'get' || + type === 'set') + ) { memberGroups.push(`${accessibility}-decorated-${type}`); memberGroups.push(`decorated-${type}`); } diff --git a/packages/eslint-plugin/tests/rules/member-ordering.test.ts b/packages/eslint-plugin/tests/rules/member-ordering.test.ts index b53143866b20..a0bbf7b12233 100644 --- a/packages/eslint-plugin/tests/rules/member-ordering.test.ts +++ b/packages/eslint-plugin/tests/rules/member-ordering.test.ts @@ -5282,6 +5282,61 @@ class Foo { { default: { memberTypes: defaultOrder, order: 'alphabetically' } }, ], }, + + // default option + class + defaultOrder + alphabetically + { + code: ` +class Foo { + public static a: string; + protected static b: string = ""; + private static c: string = ""; + + public d: string = ""; + protected e: string = ""; + private f: string = ""; + + constructor() {} + + get h() {} + + set g() {} +} + `, + options: [ + { + default: { + memberTypes: defaultOrder, + order: 'alphabetically', + }, + }, + ], + }, + + // default option + class + custom + alphabetically + { + code: ` +class Foo { + get a() {} + + @Bar + get b() {} + + set c() {} + + @Bar + set d() {} +} + `, + options: [ + { + default: { + memberTypes: ['get', 'decorated-get', 'set', 'decorated-set'], + order: 'alphabetically', + }, + }, + ], + }, + // default option + class + decorators + default order + alphabetically { code: ` @@ -5377,6 +5432,130 @@ const foo = class Foo { }, ], invalid: [ + // default option + class + wrong order within group and wrong group order + alphabetically + { + code: ` +class FooTestGetter { + public static a: string; + protected static b: string = ""; + private static c: string = ""; + + public d: string = ""; + protected e: string = ""; + private f: string = ""; + + get h() {} + + set g() {} + + constructor() {} +} + `, + options: [ + { + default: { + memberTypes: defaultOrder, + order: 'alphabetically', + }, + }, + ], + errors: [ + { + messageId: 'incorrectGroupOrder', + data: { + name: 'constructor', + rank: 'public instance get', + }, + }, + ], + }, + + // default option + class + custom + alphabetically + { + code: ` +class Foo { + @Bar + get a() {} + + get b() {} + + @Bar + set c() {} + + set d() {} +} + `, + options: [ + { + default: { + memberTypes: ['get', 'decorated-get', 'set', 'decorated-set'], + order: 'alphabetically', + }, + }, + ], + errors: [ + { + messageId: 'incorrectGroupOrder', + data: { + name: 'b', + rank: 'decorated get', + }, + }, + { + messageId: 'incorrectGroupOrder', + data: { + name: 'd', + rank: 'decorated set', + }, + }, + ], + }, + + // default option + class + wrong order within group and wrong group order + alphabetically + { + code: ` +class FooTestGetter { + public static a: string; + protected static b: string = ""; + private static c: string = ""; + + public d: string = ""; + protected e: string = ""; + private f: string = ""; + + set g() {} + + constructor() {} + + get h() {} +} + `, + options: [ + { + default: { + memberTypes: defaultOrder, + order: 'alphabetically', + }, + }, + ], + errors: [ + { + messageId: 'incorrectGroupOrder', + data: { + name: 'constructor', + rank: 'public instance set', + }, + }, + { + messageId: 'incorrectGroupOrder', + data: { + name: 'h', + rank: 'public instance set', + }, + }, + ], + }, + // default option + interface + wrong order within group and wrong group order + alphabetically { code: ` From 9170ca71eb3f48cd9a942bcee1a444a459d40a07 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Sat, 21 Aug 2021 18:40:57 -0700 Subject: [PATCH 25/44] chore: delete no-unused-vars-experimental test oops --- .../rules/no-unused-vars-experimental.test.ts | 1363 ----------------- 1 file changed, 1363 deletions(-) delete mode 100644 packages/eslint-plugin/tests/rules/no-unused-vars-experimental.test.ts diff --git a/packages/eslint-plugin/tests/rules/no-unused-vars-experimental.test.ts b/packages/eslint-plugin/tests/rules/no-unused-vars-experimental.test.ts deleted file mode 100644 index 6beaa6f0a0a6..000000000000 --- a/packages/eslint-plugin/tests/rules/no-unused-vars-experimental.test.ts +++ /dev/null @@ -1,1363 +0,0 @@ -/* eslint-disable @typescript-eslint/internal/prefer-ast-types-enum */ -import { - InvalidTestCase, - ValidTestCase, -} from '@typescript-eslint/experimental-utils/dist/ts-eslint'; -import rule, { - DEFAULT_IGNORED_REGEX_STRING, - MessageIds, - Options, -} from '../../src/rules/no-unused-vars-experimental'; -import { getFixturesRootDir, RuleTester } from '../RuleTester'; - -const rootDir = getFixturesRootDir(); -const ruleTester = new RuleTester({ - parserOptions: { - ecmaVersion: 2018, - sourceType: 'module', - }, - parser: '@typescript-eslint/parser', -}); - -const hasExport = /^export/m; -// const hasImport = /^import .+? from ['"]/m; -function makeExternalModule< - T extends ValidTestCase | InvalidTestCase, ->(tests: T[]): T[] { - return tests.map(t => { - if (!hasExport.test(t.code)) { - return { - ...t, - code: `${t.code}\nexport const __externalModule = 1;`, - }; - } - return t; - }); -} - -const DEFAULT_IGNORED_REGEX = new RegExp( - DEFAULT_IGNORED_REGEX_STRING, -).toString(); -ruleTester.run('no-unused-vars-experimental', rule, { - valid: makeExternalModule([ - /////////////////////// - // #region variables // - /////////////////////// - { code: 'const _x = "unused"' }, - { code: 'export const x = "used";' }, - { - code: ` -const x = "used"; -console.log(x); - `, - }, - { - code: ` -function foo() {} -foo(); - `, - }, - { code: 'function _foo() {}' }, - { - // decorators require the tsconfig compiler option - // or else they are marked as unused because it is not a valid usage - code: ` -function decorator(_clazz: any) {} - -@decorator -export class Foo {} - `, - parser: require.resolve('@typescript-eslint/parser'), - parserOptions: { - project: './tsconfig.json', - tsconfigRootDir: rootDir, - }, - }, - { - code: ` -type Foo = { a?: string }; -export const foo: Foo = {}; - `, - }, - { - code: ` -interface Foo { a?: string }; -export const foo: Foo = {}; - `, - }, - { code: 'type _Foo = { a?: string };' }, - { code: 'interface _Foo { a?: string };' }, - { - code: ` -class Foo {} -new Foo(); - `, - }, - { code: 'class _Foo {}' }, - { - code: ` -export class Foo { - private foo: string; - bar() { - console.log(this.foo); - } -} - `, - }, - { - code: ` -export class Foo { - private _foo: string; -} - `, - }, - { - code: ` -export class Foo { - private foo() {}; - bar() { - this.foo(); - } -} - `, - }, - { - code: ` -export class Foo { - private _foo() {}; -} - `, - }, - { - code: ` -enum Foo { a = 1 } -console.log(Foo.a); - `, - }, - { code: 'enum _Foo { a = 1 }' }, - { code: 'export const {a, b} = c;' }, - { - code: ` -const {a, b: {c}} = d; -console.log(a, c); - `, - }, - { - code: ` -const {a, b} = c; -console.log(a, b); - `, - }, - { - code: ` -const {a: _a, b} = c; -console.log(b); - `, - }, - { code: `const {a: _a, b: _b} = c;` }, - { code: 'export const [a, b] = c;' }, - { - code: ` -const [a, b] = c; -console.log(a, b); - `, - }, - { - code: ` -const [a, [b]] = c; -console.log(a, b); - `, - }, - { - code: ` -const [_a, b] = c; -console.log(b); - `, - }, - { code: `const [_a, _b] = c;` }, - // #endregion variables // - ////////////////////////// - - //////////////////////// - // #region parameters // - //////////////////////// - { - code: ` -export function foo(a) { - console.log(a); -} - `, - }, - { - code: ` -export function foo(a: string, b: string) { - console.log(b); -} - `, - options: [ - { - ignoreArgsIfArgsAfterAreUsed: true, - }, - ], - }, - { - code: ` -export class Clazz { - constructor(a: string, public b: string) {} -} - `, - options: [ - { - ignoreArgsIfArgsAfterAreUsed: true, - }, - ], - }, - { - code: ` -export class Clazz { - constructor(private a: string, public b: string) {} -} - `, - options: [ - { - ignoreArgsIfArgsAfterAreUsed: true, - }, - ], - }, - { - code: ` -export class Clazz { - constructor(private a: string) {} - foo() { console.log(this.a) } -} - `, - }, - { code: 'export function foo({a: _a}) {}' }, - { code: 'export function foo({a: { b: _b }}) {}' }, - { code: 'export function foo([_a]) {}' }, - { code: 'export function foo([[_a]]) {}' }, - { - code: ` -export function foo({a: _a}, used) { - console.log(used); -} - `, - options: [ - { - ignoreArgsIfArgsAfterAreUsed: true, - }, - ], - }, - { - code: ` -export function foo({a: { b: _b }}, used) { - console.log(used); -} - `, - options: [ - { - ignoreArgsIfArgsAfterAreUsed: true, - }, - ], - }, - { - code: ` -export function foo([_a], used) { - console.log(used); -} - `, - options: [ - { - ignoreArgsIfArgsAfterAreUsed: true, - }, - ], - }, - { - code: ` -export function foo([[_a]], used) { - console.log(used); -} - `, - options: [ - { - ignoreArgsIfArgsAfterAreUsed: true, - }, - ], - }, - // #endregion parameters // - /////////////////////////// - - //////////////////// - // #region import // - //////////////////// - { - code: ` -import defaultImp from "thing"; -console.log(defaultImp); - `, - }, - { - code: ` -import { named } from "thing"; -console.log(named); - `, - }, - { - code: ` -import defaultImp, { named } from "thing"; -console.log(defaultImp, named); - `, - }, - { - code: ` -import defaultImp = require("thing"); -console.log(defaultImp, named); - `, - }, - { - code: ` -import * as namespace from "thing"; -console.log(namespace); - `, - }, - { - code: ` -import defaultImp, * as namespace from "thing"; -console.log(defaultImp, namespace); - `, - }, - { code: 'import _defaultImp from "thing";' }, - { code: 'import { named as _named } from "thing";' }, - { code: 'import _defaultImp, { named as _named } from "thing";' }, - { code: 'import _defaultImp = require("thing");' }, - { code: 'import * as _namespace from "thing";' }, - { code: 'import _defaultImp, * as _namespace from "thing";' }, - // #endregion import // - /////////////////////// - - ////////////////////// - // #region generics // - ////////////////////// - { code: 'export function foo(): T {}' }, - { code: 'export function foo(): T & T2 {}' }, - { code: 'export function foo(): T {}' }, - { - code: ` -export class foo { - prop: T -} - `, - }, - { - code: ` -export class foo { - prop: T - prop2: T2 -} - `, - }, - { - code: ` -export class foo { - prop: T - prop2: T2 -} - `, - }, - { - code: ` -export interface foo { - prop: T -} - `, - }, - { - code: ` -export interface foo { - prop: T - prop2: T2 -} - `, - }, - { - code: ` -export interface foo { - prop: T - prop2: T2 -} - `, - }, - { - code: ` -export type foo = { - prop: T - -} - `, - }, - { - code: ` -export type foo = { - prop: T - prop2: T2 -} - `, - }, - { - code: ` -export type foo = { - prop: T - prop2: T2 -} - `, - }, - // #endregion generics // - ///////////////////////// - ]), - invalid: makeExternalModule([ - /////////////////////// - // #region variables // - /////////////////////// - { - code: 'const x = "unused"', - errors: [ - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'x', - type: 'Variable', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 1, - column: 7, - endColumn: 8, - }, - ], - }, - { - code: 'const x: string = "unused"', - errors: [ - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'x', - type: 'Variable', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 1, - column: 7, - endColumn: 16, - }, - ], - }, - { - code: 'const x = "unused"', - options: [ - { - ignoredNamesRegex: false, - }, - ], - errors: [ - { - messageId: 'unused', - data: { - name: 'x', - type: 'Variable', - }, - line: 1, - column: 7, - endColumn: 8, - }, - ], - }, - { - code: 'function foo() {}', - errors: [ - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'foo', - type: 'Function', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 1, - column: 10, - endColumn: 13, - }, - ], - }, - { - code: 'type Foo = { a?: string };', - errors: [ - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'Foo', - type: 'Type', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 1, - column: 6, - endColumn: 9, - }, - ], - }, - { - code: 'interface Foo { a?: string };', - errors: [ - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'Foo', - type: 'Interface', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 1, - column: 11, - endColumn: 14, - }, - ], - }, - { - code: 'class Foo {}', - errors: [ - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'Foo', - type: 'Class', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 1, - column: 7, - endColumn: 10, - }, - ], - }, - { - code: ` -export class Foo { - private foo: string; -} - `, - errors: [ - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'foo', - type: 'Property', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 3, - column: 11, - endColumn: 14, - }, - ], - }, - { - code: ` -export class Foo { - private foo() {}; -} - `, - errors: [ - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'foo', - type: 'Method', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 3, - column: 11, - endColumn: 14, - }, - ], - }, - { - code: 'enum Foo { a = 1 }', - errors: [ - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'Foo', - type: 'Enum', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 1, - column: 6, - endColumn: 9, - }, - ], - }, - { - code: ` -const {foo, bar} = baz; -console.log(foo); - `, - errors: [ - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'bar', - type: 'Destructured Variable', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 2, - column: 13, - endColumn: 16, - }, - ], - }, - { - code: ` -const [foo, bar] = baz; -console.log(foo); - `, - errors: [ - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'bar', - type: 'Destructured Variable', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 2, - column: 13, - endColumn: 16, - }, - ], - }, - { - code: 'const {foo, bar} = baz;', - errors: [ - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'foo', - type: 'Destructured Variable', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 1, - column: 8, - endColumn: 11, - }, - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'bar', - type: 'Destructured Variable', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 1, - column: 13, - endColumn: 16, - }, - ], - }, - { - code: 'const {foo, bar: _bar} = baz;', - errors: [ - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'foo', - type: 'Destructured Variable', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 1, - column: 8, - endColumn: 11, - }, - ], - }, - { - code: 'const [foo, bar] = baz;', - errors: [ - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'foo', - type: 'Destructured Variable', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 1, - column: 8, - endColumn: 11, - }, - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'bar', - type: 'Destructured Variable', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 1, - column: 13, - endColumn: 16, - }, - ], - }, - { - code: 'const [foo, _bar] = baz;', - errors: [ - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'foo', - type: 'Destructured Variable', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 1, - column: 8, - endColumn: 11, - }, - ], - }, - { - code: 'const [foo, [bar]] = baz;', - errors: [ - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'foo', - type: 'Destructured Variable', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 1, - column: 8, - endColumn: 11, - }, - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'bar', - type: 'Destructured Variable', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 1, - column: 14, - endColumn: 17, - }, - ], - }, - { - code: 'const {foo, bar: {baz}} = bam;', - errors: [ - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'foo', - type: 'Destructured Variable', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 1, - column: 8, - endColumn: 11, - }, - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'baz', - type: 'Destructured Variable', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 1, - column: 19, - endColumn: 22, - }, - ], - }, - { - code: 'const {foo, bar: [baz]} = bam;', - errors: [ - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'foo', - type: 'Destructured Variable', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 1, - column: 8, - endColumn: 11, - }, - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'baz', - type: 'Destructured Variable', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 1, - column: 19, - endColumn: 22, - }, - ], - }, - // #endregion variables // - ////////////////////////// - - //////////////////////// - // #region parameters // - //////////////////////// - { - code: ` -export function foo(a, b) { - console.log(b); -} - `, - errors: [ - { - messageId: 'unused', - data: { - name: 'a', - type: 'Parameter', - }, - line: 2, - column: 21, - endColumn: 22, - }, - ], - }, - { - code: ` -export function foo(a: string, b: string) { - console.log(b); -} - `, - errors: [ - { - messageId: 'unused', - data: { - name: 'a', - type: 'Parameter', - }, - line: 2, - column: 21, - endColumn: 30, - }, - ], - }, - { - code: ` -export class Clazz { - constructor(a: string, b: string) { - console.log(b); - } -} - `, - errors: [ - { - messageId: 'unused', - data: { - name: 'a', - type: 'Parameter', - }, - line: 3, - column: 15, - endColumn: 24, - }, - ], - }, - { - code: ` -export class Clazz { - constructor(a: string, public b: string) {} -} - `, - errors: [ - { - messageId: 'unused', - data: { - name: 'a', - type: 'Parameter', - }, - line: 3, - column: 15, - endColumn: 24, - }, - ], - }, - { - code: ` -export function foo({a}, used) { - console.log(used); -} - `, - errors: [ - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'a', - type: 'Destructured Variable', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 2, - column: 22, - endColumn: 23, - }, - ], - }, - { - code: ` -export function foo({a: {b}}, used) { - console.log(used); -} - `, - errors: [ - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'b', - type: 'Destructured Variable', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 2, - column: 26, - endColumn: 27, - }, - ], - }, - { - code: ` -export function foo([a], used) { - console.log(used); -} - `, - errors: [ - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'a', - type: 'Destructured Variable', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 2, - column: 22, - endColumn: 23, - }, - ], - }, - { - code: ` -export function foo([[a]], used) { - console.log(used); -} - `, - errors: [ - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'a', - type: 'Destructured Variable', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 2, - column: 23, - endColumn: 24, - }, - ], - }, - // #endregion parameters // - /////////////////////////// - - //////////////////// - // #region import // - //////////////////// - { - code: 'import foo = require("test")', - errors: [ - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'foo', - type: 'Import', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 1, - column: 8, - endColumn: 11, - }, - ], - }, - { - code: 'import defaultImp from "thing";', - errors: [ - { - messageId: 'unusedImport', - line: 1, - column: 1, - endColumn: 32, - }, - ], - }, - { - code: 'import { named } from "thing";', - errors: [ - { - messageId: 'unusedImport', - line: 1, - column: 1, - endColumn: 31, - }, - ], - }, - { - code: 'import * as namespace from "thing";', - errors: [ - { - messageId: 'unusedImport', - line: 1, - column: 1, - endColumn: 36, - }, - ], - }, - { - code: 'import defaultImp, { named } from "thing";', - errors: [ - { - messageId: 'unusedImport', - line: 1, - column: 1, - endColumn: 43, - }, - ], - }, - { - code: 'import defaultImp, * as namespace from "thing";', - errors: [ - { - messageId: 'unusedImport', - line: 1, - column: 1, - endColumn: 48, - }, - ], - }, - { - code: ` -import defaultImp, { named } from "thing"; -console.log(named); - `, - errors: [ - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'defaultImp', - type: 'Import', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 2, - column: 8, - endColumn: 18, - }, - ], - }, - { - code: ` -import defaultImp, * as named from "thing"; -console.log(named); - `, - errors: [ - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'defaultImp', - type: 'Import', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 2, - column: 8, - endColumn: 18, - }, - ], - }, - { - code: ` -import defaultImp, * as named from "thing"; -console.log(defaultImp); - `, - errors: [ - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'named', - type: 'Import', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 2, - column: 25, - endColumn: 30, - }, - ], - }, - { - code: ` -import defaultImp, { named } from "thing"; -console.log(defaultImp); - `, - errors: [ - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'named', - type: 'Import', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 2, - column: 22, - endColumn: 27, - }, - ], - }, - { - code: ` -import { named1, named2 } from "thing"; -console.log(named1); - `, - errors: [ - { - messageId: 'unusedWithIgnorePattern', - data: { - name: 'named2', - type: 'Import', - pattern: DEFAULT_IGNORED_REGEX, - }, - line: 2, - column: 18, - endColumn: 24, - }, - ], - }, - // #endregion import // - /////////////////////// - - ////////////////////// - // #region generics // - ////////////////////// - { - code: 'export function foo() {}', - errors: [ - { - messageId: 'unusedTypeParameters', - line: 1, - column: 20, - endColumn: 23, - }, - ], - }, - { - code: 'export function foo() {}', - errors: [ - { - messageId: 'unusedTypeParameters', - line: 1, - column: 20, - endColumn: 27, - }, - ], - }, - { - code: 'export function foo(): T2 {}', - errors: [ - { - messageId: 'unused', - data: { - name: 'T', - type: 'Type Parameter', - }, - line: 1, - column: 21, - endColumn: 22, - }, - ], - }, - { - code: 'export function foo() {}', - errors: [ - { - messageId: 'unused', - data: { - name: 'T', - type: 'Type Parameter', - }, - line: 1, - column: 21, - endColumn: 22, - }, - ], - }, - { - code: 'export class foo {}', - errors: [ - { - messageId: 'unusedTypeParameters', - line: 1, - column: 17, - endColumn: 20, - }, - ], - }, - { - code: 'export class foo {}', - errors: [ - { - messageId: 'unusedTypeParameters', - line: 1, - column: 17, - endColumn: 24, - }, - ], - }, - { - code: ` -export class foo { - prop: T2 -} - `, - errors: [ - { - messageId: 'unused', - data: { - name: 'T', - type: 'Type Parameter', - }, - line: 2, - column: 18, - endColumn: 19, - }, - ], - }, - { - code: 'export class foo {}', - errors: [ - { - messageId: 'unused', - data: { - name: 'T', - type: 'Type Parameter', - }, - line: 1, - column: 18, - endColumn: 19, - }, - ], - }, - { - code: 'export interface foo {}', - errors: [ - { - messageId: 'unusedTypeParameters', - line: 1, - column: 21, - endColumn: 24, - }, - ], - }, - { - code: 'export interface foo {}', - errors: [ - { - messageId: 'unusedTypeParameters', - line: 1, - column: 21, - endColumn: 28, - }, - ], - }, - { - code: ` -export interface foo { - prop: T2 -} - `, - errors: [ - { - messageId: 'unused', - data: { - name: 'T', - type: 'Type Parameter', - }, - line: 2, - column: 22, - endColumn: 23, - }, - ], - }, - { - code: 'export interface foo {}', - errors: [ - { - messageId: 'unused', - data: { - name: 'T', - type: 'Type Parameter', - }, - line: 1, - column: 22, - endColumn: 23, - }, - ], - }, - { - code: 'export type foo = {}', - errors: [ - { - messageId: 'unusedTypeParameters', - line: 1, - column: 16, - endColumn: 19, - }, - ], - }, - { - code: 'export type foo = {}', - errors: [ - { - messageId: 'unusedTypeParameters', - line: 1, - column: 16, - endColumn: 23, - }, - ], - }, - { - code: ` -export type foo = { - prop: T2 -} - `, - errors: [ - { - messageId: 'unused', - data: { - name: 'T', - type: 'Type Parameter', - }, - line: 2, - column: 17, - endColumn: 18, - }, - ], - }, - { - code: 'export type foo = {}', - errors: [ - { - messageId: 'unused', - data: { - name: 'T', - type: 'Type Parameter', - }, - line: 1, - column: 17, - endColumn: 18, - }, - ], - }, - // #endregion generics // - ///////////////////////// - ]), -}); From 3034181a856d76c15fffa2325251bbe65bc05f28 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Sat, 21 Aug 2021 18:56:39 -0700 Subject: [PATCH 26/44] chore: remove no-unused-vars-experimental docs jfc I'm an idiot --- .../docs/rules/no-unused-vars-experimental.md | 115 ------------------ 1 file changed, 115 deletions(-) delete mode 100644 packages/eslint-plugin/docs/rules/no-unused-vars-experimental.md diff --git a/packages/eslint-plugin/docs/rules/no-unused-vars-experimental.md b/packages/eslint-plugin/docs/rules/no-unused-vars-experimental.md deleted file mode 100644 index 918cbc595f5d..000000000000 --- a/packages/eslint-plugin/docs/rules/no-unused-vars-experimental.md +++ /dev/null @@ -1,115 +0,0 @@ -# Disallow unused variables and arguments (`no-unused-vars-experimental`) - -Variables that are declared and not used anywhere in the code are most likely an error due to incomplete refactoring. Such variables take up space in the code and can lead to confusion by readers. - -## Rule Details - -This rule leverages the TypeScript compiler's unused variable checks to report. This means that with all rule options set to `false`, it should report the same errors as if you used both the `noUnusedLocals` and `noUnusedParameters` compiler options. - -This rule is vastly different to, and maintains no compatibility with the base ESLint version of the rule. - -### Limitations - -There are two limitations to this rule when compared with ESLint's `no-unused-vars` rule, which are imposed by the fact that it directly uses TypeScript's implementation. - -1. This rule only works on files that TypeScript deems is a module (i.e. it has an `import` or an `export` statement). -2. The rule is significantly less configurable, as it cannot deviate too far from the base implementation. - -## Supported Nodes - -This rule supports checks on the following features: - -- Declarations: - - `var` / `const` / `let` - - `function` - - `class` - - `enum` - - `interface` - - `type` -- Class methods -- Class properties and parameter properties -- Function parameters -- Generic type parameters -- Import statements - -## Options - -```ts -type Options = { - ignoredNamesRegex?: string | boolean; - ignoreArgsIfArgsAfterAreUsed?: boolean; -}; - -const defaultOptions: Options = { - ignoredNamesRegex: '^_', - ignoreArgsIfArgsAfterAreUsed: false, -}; -``` - -### `ignoredNamesRegex` - -This option accepts a regex string to match names against. -Any matched names will be ignored and have no errors reported. -If you set it to false, it will never ignore any names. - -The default value is `'^_'` (i.e. matches any name prefixed with an underscore). - -Examples of valid code with `{ variables: { ignoredNamesRegex: '^_' } }`. - -```ts -const _unusedVar = 'unused'; -class _Unused { - private _unused = 1; - private _unusedMethod() {} -} -function _unusedFunction() {} -enum _UnusedEnum { - a = 1, -} -interface _UnusedInterface {} -type _UnusedType = {}; -``` - -**_NOTE:_** The TypeScript compiler automatically ignores imports, function arguments, type parameter declarations, and object destructuring variables prefixed with an underscore. -As this is hard-coded into the compiler, we cannot change this. - -Examples of valid code based on the unchangeable compiler settings - -```ts -import _UnusedDefault, { _UnusedNamed } from 'foo'; -export function foo(_unusedProp: string) {} -export class Foo<_UnusedGeneric> {} -const { prop: _unusedDestructure } = foo; -``` - -## `ignoreArgsIfArgsAfterAreUsed` - -When true, this option will ignore unused function arguments if the arguments proceeding arguments are used. - -Examples of invalid code with `{ ignoreArgsIfArgsAfterAreUsed: false }` - -```ts -function foo(unused: string, used: number) { - console.log(used); -} - -class Foo { - constructor(unused: string, public used: number) { - console.log(used); - } -} -``` - -Examples of valid code with `{ ignoreArgsIfArgsAfterAreUsed: true }` - -```ts -function foo(unused: string, used: number) { - console.log(used); -} - -class Foo { - constructor(unused: string, public used: number) { - console.log(used); - } -} -``` From c8ee43269faea4c04ec02eaa2b81a0aa6eec5d3e Mon Sep 17 00:00:00 2001 From: Jonas <13821543+sonallux@users.noreply.github.com> Date: Sun, 22 Aug 2021 04:21:54 +0200 Subject: [PATCH 27/44] feat: remove `TSParenthesizedType` (#3340) fixes #3136 Co-authored-by: Brad Zacher --- packages/ast-spec/src/ast-node-types.ts | 1 - .../src/type/TSParenthesizedType/spec.ts | 8 -- packages/ast-spec/src/type/spec.ts | 1 - packages/ast-spec/src/unions/Node.ts | 2 - packages/ast-spec/src/unions/TypeNode.ts | 2 - .../eslint-plugin/src/rules/array-type.ts | 22 ++--- .../src/rules/indent-new-do-not-use/index.ts | 1 - packages/eslint-plugin/src/rules/indent.ts | 1 - .../src/rules/no-extra-parens.ts | 4 +- .../eslint-plugin/src/rules/no-type-alias.ts | 3 - .../sort-type-union-intersection-members.ts | 9 +- .../tests/rules/indent/indent.test.ts | 23 ----- .../tests/rules/no-extra-parens.test.ts | 2 +- ...rt-type-union-intersection-members.test.ts | 2 +- .../experimental-utils/src/ts-eslint/Rule.ts | 1 - packages/typescript-estree/src/convert.ts | 5 +- .../src/ts-estree/estree-to-ts-node-types.ts | 1 - .../tests/ast-alignment/utils.ts | 10 +++ .../conditional-infer-nested.src.ts.shot | 51 ++++------- .../types/conditional-infer.src.ts.shot | 51 ++++------- .../types/parenthesized-type.src.ts.shot | 89 ++++++++----------- .../types/tuple-named-optional.src.ts.shot | 89 ++++++++----------- .../types/tuple-optional.src.ts.shot | 89 ++++++++----------- packages/visitor-keys/src/visitor-keys.ts | 1 - 24 files changed, 169 insertions(+), 299 deletions(-) delete mode 100644 packages/ast-spec/src/type/TSParenthesizedType/spec.ts diff --git a/packages/ast-spec/src/ast-node-types.ts b/packages/ast-spec/src/ast-node-types.ts index 90a18ba8d9ed..9a38d477acfc 100644 --- a/packages/ast-spec/src/ast-node-types.ts +++ b/packages/ast-spec/src/ast-node-types.ts @@ -135,7 +135,6 @@ export enum AST_NODE_TYPES { TSObjectKeyword = 'TSObjectKeyword', TSOptionalType = 'TSOptionalType', TSParameterProperty = 'TSParameterProperty', - TSParenthesizedType = 'TSParenthesizedType', TSPrivateKeyword = 'TSPrivateKeyword', TSPropertySignature = 'TSPropertySignature', TSProtectedKeyword = 'TSProtectedKeyword', diff --git a/packages/ast-spec/src/type/TSParenthesizedType/spec.ts b/packages/ast-spec/src/type/TSParenthesizedType/spec.ts deleted file mode 100644 index 2d20d5d2f2bc..000000000000 --- a/packages/ast-spec/src/type/TSParenthesizedType/spec.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { AST_NODE_TYPES } from '../../ast-node-types'; -import type { BaseNode } from '../../base/BaseNode'; -import type { TypeNode } from '../../unions/TypeNode'; - -export interface TSParenthesizedType extends BaseNode { - type: AST_NODE_TYPES.TSParenthesizedType; - typeAnnotation: TypeNode; -} diff --git a/packages/ast-spec/src/type/spec.ts b/packages/ast-spec/src/type/spec.ts index bbbea76cbd8e..d6209d260673 100644 --- a/packages/ast-spec/src/type/spec.ts +++ b/packages/ast-spec/src/type/spec.ts @@ -17,7 +17,6 @@ export * from './TSNullKeyword/spec'; export * from './TSNumberKeyword/spec'; export * from './TSObjectKeyword/spec'; export * from './TSOptionalType/spec'; -export * from './TSParenthesizedType/spec'; export * from './TSQualifiedName/spec'; export * from './TSRestType/spec'; export * from './TSStringKeyword/spec'; diff --git a/packages/ast-spec/src/unions/Node.ts b/packages/ast-spec/src/unions/Node.ts index f0802b3b6850..7fe5ced96dfc 100644 --- a/packages/ast-spec/src/unions/Node.ts +++ b/packages/ast-spec/src/unions/Node.ts @@ -142,7 +142,6 @@ import type { TSNullKeyword } from '../type/TSNullKeyword/spec'; import type { TSNumberKeyword } from '../type/TSNumberKeyword/spec'; import type { TSObjectKeyword } from '../type/TSObjectKeyword/spec'; import type { TSOptionalType } from '../type/TSOptionalType/spec'; -import type { TSParenthesizedType } from '../type/TSParenthesizedType/spec'; import type { TSQualifiedName } from '../type/TSQualifiedName/spec'; import type { TSRestType } from '../type/TSRestType/spec'; import type { TSStringKeyword } from '../type/TSStringKeyword/spec'; @@ -293,7 +292,6 @@ export type Node = | TSObjectKeyword | TSOptionalType | TSParameterProperty - | TSParenthesizedType | TSPrivateKeyword | TSPropertySignature | TSProtectedKeyword diff --git a/packages/ast-spec/src/unions/TypeNode.ts b/packages/ast-spec/src/unions/TypeNode.ts index c50630e6cd6a..55436b7a44d4 100644 --- a/packages/ast-spec/src/unions/TypeNode.ts +++ b/packages/ast-spec/src/unions/TypeNode.ts @@ -18,7 +18,6 @@ import type { TSNullKeyword } from '../type/TSNullKeyword/spec'; import type { TSNumberKeyword } from '../type/TSNumberKeyword/spec'; import type { TSObjectKeyword } from '../type/TSObjectKeyword/spec'; import type { TSOptionalType } from '../type/TSOptionalType/spec'; -import type { TSParenthesizedType } from '../type/TSParenthesizedType/spec'; import type { TSRestType } from '../type/TSRestType/spec'; import type { TSStringKeyword } from '../type/TSStringKeyword/spec'; import type { TSSymbolKeyword } from '../type/TSSymbolKeyword/spec'; @@ -56,7 +55,6 @@ export type TypeNode = | TSNumberKeyword | TSObjectKeyword | TSOptionalType - | TSParenthesizedType | TSRestType | TSStringKeyword | TSSymbolKeyword diff --git a/packages/eslint-plugin/src/rules/array-type.ts b/packages/eslint-plugin/src/rules/array-type.ts index 8c97729623a7..44de45f19de1 100644 --- a/packages/eslint-plugin/src/rules/array-type.ts +++ b/packages/eslint-plugin/src/rules/array-type.ts @@ -132,13 +132,8 @@ export default util.createRule({ * @param node the node to be evaluated. */ function getMessageType(node: TSESTree.Node): string { - if (node) { - if (node.type === AST_NODE_TYPES.TSParenthesizedType) { - return getMessageType(node.typeAnnotation); - } - if (isSimpleType(node)) { - return sourceCode.getText(node); - } + if (node && isSimpleType(node)) { + return sourceCode.getText(node); } return 'T'; } @@ -172,11 +167,7 @@ export default util.createRule({ type: getMessageType(node.elementType), }, fix(fixer) { - const typeNode = - node.elementType.type === AST_NODE_TYPES.TSParenthesizedType - ? node.elementType.typeAnnotation - : node.elementType; - + const typeNode = node.elementType; const arrayType = isReadonly ? 'ReadonlyArray' : 'Array'; return [ @@ -244,9 +235,12 @@ export default util.createRule({ } const type = typeParams[0]; - const typeParens = typeNeedsParentheses(type); + const typeParens = + !util.isParenthesized(type, sourceCode) && typeNeedsParentheses(type); const parentParens = - readonlyPrefix && node.parent?.type === AST_NODE_TYPES.TSArrayType; + readonlyPrefix && + node.parent?.type === AST_NODE_TYPES.TSArrayType && + !util.isParenthesized(node.parent.elementType, sourceCode); const start = `${parentParens ? '(' : ''}${readonlyPrefix}${ typeParens ? '(' : '' diff --git a/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts b/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts index 68edfe18dbb7..573423135962 100644 --- a/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts +++ b/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts @@ -161,7 +161,6 @@ const KNOWN_NODES = new Set([ AST_NODE_TYPES.TSModuleDeclaration, AST_NODE_TYPES.TSNonNullExpression, AST_NODE_TYPES.TSParameterProperty, - AST_NODE_TYPES.TSParenthesizedType, 'TSPlusToken', AST_NODE_TYPES.TSPropertySignature, AST_NODE_TYPES.TSQualifiedName, diff --git a/packages/eslint-plugin/src/rules/indent.ts b/packages/eslint-plugin/src/rules/indent.ts index a87772dd1f66..42b006177019 100644 --- a/packages/eslint-plugin/src/rules/indent.ts +++ b/packages/eslint-plugin/src/rules/indent.ts @@ -67,7 +67,6 @@ const KNOWN_NODES = new Set([ AST_NODE_TYPES.TSModuleDeclaration, AST_NODE_TYPES.TSNonNullExpression, AST_NODE_TYPES.TSParameterProperty, - AST_NODE_TYPES.TSParenthesizedType, 'TSPlusToken', AST_NODE_TYPES.TSPropertySignature, AST_NODE_TYPES.TSQualifiedName, diff --git a/packages/eslint-plugin/src/rules/no-extra-parens.ts b/packages/eslint-plugin/src/rules/no-extra-parens.ts index 6aa540a9be56..0eeeedf2c2fa 100644 --- a/packages/eslint-plugin/src/rules/no-extra-parens.ts +++ b/packages/eslint-plugin/src/rules/no-extra-parens.ts @@ -84,9 +84,7 @@ export default util.createRule({ if ( node.arguments.length === 1 && node.typeParameters?.params.some( - param => - param.type === AST_NODE_TYPES.TSParenthesizedType || - param.type === AST_NODE_TYPES.TSImportType, + param => param.type === AST_NODE_TYPES.TSImportType, ) ) { return rule({ diff --git a/packages/eslint-plugin/src/rules/no-type-alias.ts b/packages/eslint-plugin/src/rules/no-type-alias.ts index cf56745ca903..4e16216ea720 100644 --- a/packages/eslint-plugin/src/rules/no-type-alias.ts +++ b/packages/eslint-plugin/src/rules/no-type-alias.ts @@ -311,9 +311,6 @@ export default util.createRule({ return acc; }, []); } - if (node.type === AST_NODE_TYPES.TSParenthesizedType) { - return getTypes(node.typeAnnotation, compositionType); - } return [{ node, compositionType }]; } diff --git a/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts b/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts index cfcab2c0b2cb..e7f042162b8c 100644 --- a/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts +++ b/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts @@ -23,9 +23,6 @@ enum Group { function getGroup(node: TSESTree.TypeNode): Group { switch (node.type) { - case AST_NODE_TYPES.TSParenthesizedType: - return getGroup(node.typeAnnotation); - case AST_NODE_TYPES.TSConditionalType: return Group.conditional; @@ -91,6 +88,10 @@ function getGroup(node: TSESTree.TypeNode): Group { } } +function requiresParentheses(node: TSESTree.TypeNode): boolean { + return node.type === AST_NODE_TYPES.TSFunctionType; +} + export type Options = [ { checkIntersections?: boolean; @@ -212,7 +213,7 @@ export default util.createRule({ const fix: TSESLint.ReportFixFunction = fixer => { const sorted = expectedOrder - .map(t => t.text) + .map(t => (requiresParentheses(t.node) ? `(${t.text})` : t.text)) .join( node.type === AST_NODE_TYPES.TSIntersectionType ? ' & ' : ' | ', ); diff --git a/packages/eslint-plugin/tests/rules/indent/indent.test.ts b/packages/eslint-plugin/tests/rules/indent/indent.test.ts index 8296bf19520c..f5c87316c171 100644 --- a/packages/eslint-plugin/tests/rules/indent/indent.test.ts +++ b/packages/eslint-plugin/tests/rules/indent/indent.test.ts @@ -451,29 +451,6 @@ class Foo { `, ], }, - { - node: AST_NODE_TYPES.TSParenthesizedType, - code: [ - ` -const x: Array<( - | { - __typename: "Foo", - } - | { - __typename: "Baz", - } - | ( - | { - __typename: "Baz", - } - | { - __typename: "Buzz", - } - ) -)>; - `, - ], - }, // TSPlusToken - tested in TSMappedType { node: AST_NODE_TYPES.TSPropertySignature, diff --git a/packages/eslint-plugin/tests/rules/no-extra-parens.test.ts b/packages/eslint-plugin/tests/rules/no-extra-parens.test.ts index d0868e8293de..5f5dc37896fa 100644 --- a/packages/eslint-plugin/tests/rules/no-extra-parens.test.ts +++ b/packages/eslint-plugin/tests/rules/no-extra-parens.test.ts @@ -28,7 +28,7 @@ for (a in b, c); for (a in b); a(1); new a(1); -a<(A)>(1); +a(1); `, }), ...batchedSingleLineTests({ diff --git a/packages/eslint-plugin/tests/rules/sort-type-union-intersection-members.test.ts b/packages/eslint-plugin/tests/rules/sort-type-union-intersection-members.test.ts index 7dda416d6b3d..a0cf2d71dd59 100644 --- a/packages/eslint-plugin/tests/rules/sort-type-union-intersection-members.test.ts +++ b/packages/eslint-plugin/tests/rules/sort-type-union-intersection-members.test.ts @@ -127,7 +127,7 @@ const invalid = ( }, { code: noFormat`type T = (B) ${operator} (A);`, - output: noFormat`type T = (A) ${operator} (B);`, + output: noFormat`type T = A ${operator} B;`, errors: [ { messageId: 'notSortedNamed', diff --git a/packages/experimental-utils/src/ts-eslint/Rule.ts b/packages/experimental-utils/src/ts-eslint/Rule.ts index 76e8deb24082..e17de9f6eba3 100644 --- a/packages/experimental-utils/src/ts-eslint/Rule.ts +++ b/packages/experimental-utils/src/ts-eslint/Rule.ts @@ -399,7 +399,6 @@ interface RuleListener { TSObjectKeyword?: RuleFunction; TSOptionalType?: RuleFunction; TSParameterProperty?: RuleFunction; - TSParenthesizedType?: RuleFunction; TSPrivateKeyword?: RuleFunction; TSPropertySignature?: RuleFunction; TSProtectedKeyword?: RuleFunction; diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index 86ade612d16a..3f51f9af0d9b 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -2698,10 +2698,7 @@ export class Converter { // TypeScript specific types case SyntaxKind.ParenthesizedType: { - return this.createNode(node, { - type: AST_NODE_TYPES.TSParenthesizedType, - typeAnnotation: this.convertType(node.type), - }); + return this.convertType(node.type); } case SyntaxKind.UnionType: { return this.createNode(node, { diff --git a/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts b/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts index d5daed093324..65951a856df6 100644 --- a/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts +++ b/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts @@ -192,7 +192,6 @@ export interface EstreeToTsNodeTypes { [AST_NODE_TYPES.TSNonNullExpression]: ts.NonNullExpression; [AST_NODE_TYPES.TSOptionalType]: ts.OptionalTypeNode; [AST_NODE_TYPES.TSParameterProperty]: ts.ParameterDeclaration; - [AST_NODE_TYPES.TSParenthesizedType]: ts.ParenthesizedTypeNode; [AST_NODE_TYPES.TSPropertySignature]: ts.PropertySignature; [AST_NODE_TYPES.TSQualifiedName]: ts.QualifiedName; [AST_NODE_TYPES.TSRestType]: diff --git a/packages/typescript-estree/tests/ast-alignment/utils.ts b/packages/typescript-estree/tests/ast-alignment/utils.ts index 3cecac3f09f6..d7dae6bcafe0 100644 --- a/packages/typescript-estree/tests/ast-alignment/utils.ts +++ b/packages/typescript-estree/tests/ast-alignment/utils.ts @@ -250,6 +250,16 @@ export function preprocessBabylonAST(ast: BabelTypes.File): any { } } }, + /** + * Remove TSParenthesizedType from babel AST. Babel 8 will stop generating the TSParenthesizedType. + * Once we use babel 8, this can be removed. + * @see https://github.com/babel/babel/pull/12608 + */ + TSParenthesizedType(node: any) { + const { typeAnnotation } = node; + Object.keys(node).forEach(key => delete node[key]); + Object.assign(node, typeAnnotation); + }, }, ); } diff --git a/packages/typescript-estree/tests/snapshots/typescript/types/conditional-infer-nested.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/types/conditional-infer-nested.src.ts.shot index 3c06676714fb..50f8f0f7ff82 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/types/conditional-infer-nested.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/types/conditional-infer-nested.src.ts.shot @@ -78,38 +78,33 @@ Object { "elementType": Object { "loc": Object { "end": Object { - "column": 21, + "column": 20, "line": 2, }, "start": Object { - "column": 12, + "column": 13, "line": 2, }, }, "range": Array [ - 31, - 40, + 32, + 39, ], - "type": "TSParenthesizedType", - "typeAnnotation": Object { + "type": "TSInferType", + "typeParameter": Object { + "constraint": undefined, + "default": undefined, "loc": Object { "end": Object { "column": 20, "line": 2, }, "start": Object { - "column": 13, + "column": 19, "line": 2, }, }, - "range": Array [ - 32, - 39, - ], - "type": "TSInferType", - "typeParameter": Object { - "constraint": undefined, - "default": undefined, + "name": Object { "loc": Object { "end": Object { "column": 20, @@ -120,30 +115,18 @@ Object { "line": 2, }, }, - "name": Object { - "loc": Object { - "end": Object { - "column": 20, - "line": 2, - }, - "start": Object { - "column": 19, - "line": 2, - }, - }, - "name": "U", - "range": Array [ - 38, - 39, - ], - "type": "Identifier", - }, + "name": "U", "range": Array [ 38, 39, ], - "type": "TSTypeParameter", + "type": "Identifier", }, + "range": Array [ + 38, + 39, + ], + "type": "TSTypeParameter", }, }, "loc": Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/types/conditional-infer.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/types/conditional-infer.src.ts.shot index 9054692bd03d..d55b6ac728e0 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/types/conditional-infer.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/types/conditional-infer.src.ts.shot @@ -78,38 +78,33 @@ Object { "elementType": Object { "loc": Object { "end": Object { - "column": 37, + "column": 36, "line": 1, }, "start": Object { - "column": 28, + "column": 29, "line": 1, }, }, "range": Array [ - 28, - 37, + 29, + 36, ], - "type": "TSParenthesizedType", - "typeAnnotation": Object { + "type": "TSInferType", + "typeParameter": Object { + "constraint": undefined, + "default": undefined, "loc": Object { "end": Object { "column": 36, "line": 1, }, "start": Object { - "column": 29, + "column": 35, "line": 1, }, }, - "range": Array [ - 29, - 36, - ], - "type": "TSInferType", - "typeParameter": Object { - "constraint": undefined, - "default": undefined, + "name": Object { "loc": Object { "end": Object { "column": 36, @@ -120,30 +115,18 @@ Object { "line": 1, }, }, - "name": Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 1, - }, - "start": Object { - "column": 35, - "line": 1, - }, - }, - "name": "U", - "range": Array [ - 35, - 36, - ], - "type": "Identifier", - }, + "name": "U", "range": Array [ 35, 36, ], - "type": "TSTypeParameter", + "type": "Identifier", }, + "range": Array [ + 35, + 36, + ], + "type": "TSTypeParameter", }, }, "loc": Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/types/parenthesized-type.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/types/parenthesized-type.src.ts.shot index 7aa5ec4571d3..e029fb995167 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/types/parenthesized-type.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/types/parenthesized-type.src.ts.shot @@ -40,72 +40,55 @@ Object { "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 28, + "column": 27, "line": 1, }, "start": Object { - "column": 11, + "column": 12, "line": 1, }, }, "range": Array [ - 11, - 28, + 12, + 27, ], - "type": "TSParenthesizedType", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 1, - }, - "start": Object { - "column": 12, - "line": 1, + "type": "TSUnionType", + "types": Array [ + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, }, + "range": Array [ + 12, + 18, + ], + "type": "TSStringKeyword", }, - "range": Array [ - 12, - 27, - ], - "type": "TSUnionType", - "types": Array [ - Object { - "loc": Object { - "end": Object { - "column": 18, - "line": 1, - }, - "start": Object { - "column": 12, - "line": 1, - }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, }, - "range": Array [ - 12, - 18, - ], - "type": "TSStringKeyword", - }, - Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 1, - }, - "start": Object { - "column": 21, - "line": 1, - }, + "start": Object { + "column": 21, + "line": 1, }, - "range": Array [ - 21, - 27, - ], - "type": "TSNumberKeyword", }, - ], - }, + "range": Array [ + 21, + 27, + ], + "type": "TSNumberKeyword", + }, + ], }, }, ], diff --git a/packages/typescript-estree/tests/snapshots/typescript/types/tuple-named-optional.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/types/tuple-named-optional.src.ts.shot index f07915f0394f..87f7351cba2a 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/types/tuple-named-optional.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/types/tuple-named-optional.src.ts.shot @@ -151,72 +151,55 @@ Object { "elementType": Object { "loc": Object { "end": Object { - "column": 52, + "column": 51, "line": 1, }, "start": Object { - "column": 35, + "column": 36, "line": 1, }, }, "range": Array [ - 35, - 52, + 36, + 51, ], - "type": "TSParenthesizedType", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 51, - "line": 1, - }, - "start": Object { - "column": 36, - "line": 1, + "type": "TSUnionType", + "types": Array [ + Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 1, + }, + "start": Object { + "column": 36, + "line": 1, + }, }, + "range": Array [ + 36, + 42, + ], + "type": "TSStringKeyword", }, - "range": Array [ - 36, - 51, - ], - "type": "TSUnionType", - "types": Array [ - Object { - "loc": Object { - "end": Object { - "column": 42, - "line": 1, - }, - "start": Object { - "column": 36, - "line": 1, - }, + Object { + "loc": Object { + "end": Object { + "column": 51, + "line": 1, }, - "range": Array [ - 36, - 42, - ], - "type": "TSStringKeyword", - }, - Object { - "loc": Object { - "end": Object { - "column": 51, - "line": 1, - }, - "start": Object { - "column": 45, - "line": 1, - }, + "start": Object { + "column": 45, + "line": 1, }, - "range": Array [ - 45, - 51, - ], - "type": "TSNumberKeyword", }, - ], - }, + "range": Array [ + 45, + 51, + ], + "type": "TSNumberKeyword", + }, + ], }, "label": Object { "loc": Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/types/tuple-optional.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/types/tuple-optional.src.ts.shot index 55be898e6a54..b359d09d8895 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/types/tuple-optional.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/types/tuple-optional.src.ts.shot @@ -111,72 +111,55 @@ Object { "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 42, + "column": 41, "line": 1, }, "start": Object { - "column": 25, + "column": 26, "line": 1, }, }, "range": Array [ - 25, - 42, + 26, + 41, ], - "type": "TSParenthesizedType", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 41, - "line": 1, - }, - "start": Object { - "column": 26, - "line": 1, + "type": "TSUnionType", + "types": Array [ + Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, }, + "range": Array [ + 26, + 32, + ], + "type": "TSStringKeyword", }, - "range": Array [ - 26, - 41, - ], - "type": "TSUnionType", - "types": Array [ - Object { - "loc": Object { - "end": Object { - "column": 32, - "line": 1, - }, - "start": Object { - "column": 26, - "line": 1, - }, + Object { + "loc": Object { + "end": Object { + "column": 41, + "line": 1, }, - "range": Array [ - 26, - 32, - ], - "type": "TSStringKeyword", - }, - Object { - "loc": Object { - "end": Object { - "column": 41, - "line": 1, - }, - "start": Object { - "column": 35, - "line": 1, - }, + "start": Object { + "column": 35, + "line": 1, }, - "range": Array [ - 35, - 41, - ], - "type": "TSNumberKeyword", }, - ], - }, + "range": Array [ + 35, + 41, + ], + "type": "TSNumberKeyword", + }, + ], }, }, ], diff --git a/packages/visitor-keys/src/visitor-keys.ts b/packages/visitor-keys/src/visitor-keys.ts index efad2828a376..036bfe5763e3 100644 --- a/packages/visitor-keys/src/visitor-keys.ts +++ b/packages/visitor-keys/src/visitor-keys.ts @@ -115,7 +115,6 @@ const additionalKeys: AdditionalKeys = { TSObjectKeyword: [], TSOptionalType: ['typeAnnotation'], TSParameterProperty: ['decorators', 'parameter'], - TSParenthesizedType: ['typeAnnotation'], TSPrivateKeyword: [], TSPropertySignature: ['typeAnnotation', 'key', 'initializer'], TSProtectedKeyword: [], From 5b84b98fb3cf68d944b7d4e970f39f4e88f0b2d5 Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 22 Aug 2021 04:22:25 +0200 Subject: [PATCH 28/44] feat(typescript-estree): remove legacy `useJSXTextNode` option (#3109) --- packages/typescript-estree/README.md | 9 ------ .../typescript-estree/src/ast-converter.ts | 1 - packages/typescript-estree/src/convert.ts | 28 ++++--------------- .../typescript-estree/src/parser-options.ts | 9 ------ packages/typescript-estree/src/parser.ts | 12 -------- .../src/ts-estree/estree-to-ts-node-types.ts | 1 - .../tests/ast-alignment/parse.ts | 1 - .../tests/lib/convert.test.ts | 11 -------- .../tests/lib/semanticInfo.test.ts | 1 - .../jsx-attr-and-text-with-url.src.js.shot | 2 +- .../comments/jsx-block-comment.src.js.shot | 4 +-- ...sx-generic-with-comment-in-tag.src.js.shot | 18 ++++++------ .../comments/jsx-tag-comments.src.js.shot | 2 +- ...ext-with-multiline-non-comment.src.js.shot | 2 +- .../comments/jsx-text-with-url.src.js.shot | 10 +++---- .../jsx-with-greather-than.src.js.shot | 2 +- .../comments/jsx-with-operators.src.js.shot | 2 +- .../self-closing-tag-inside-tag.src.js.shot | 4 +-- .../test-content.src.js.shot | 2 +- .../snapshots/jsx/attributes.src.js.shot | 2 +- .../jsx/element-keyword-name.src.js.shot | 8 +++--- ...embedded-invalid-js-identifier.src.js.shot | 2 +- .../jsx/escape-patterns-unknown.src.js.shot | 6 ++-- .../jsx/escape-patterns-valid.src.js.shot | 2 +- .../jsx/escape-patters-multi.src.js.shot | 2 +- .../jsx/multiple-blank-spaces.src.js.shot | 2 +- ...d-attribute-and-value-inserted.src.js.shot | 4 +-- .../self-closing-tag-inside-tag.src.js.shot | 4 +-- ...ag-names-with-multi-dots-multi.src.js.shot | 4 +-- .../snapshots/jsx/test-content.src.js.shot | 2 +- .../tsx/react-typed-props.src.tsx.shot | 4 +-- 31 files changed, 51 insertions(+), 112 deletions(-) diff --git a/packages/typescript-estree/README.md b/packages/typescript-estree/README.md index 605836b3c692..25eb1e928294 100644 --- a/packages/typescript-estree/README.md +++ b/packages/typescript-estree/README.md @@ -101,14 +101,6 @@ interface ParseOptions { * Set to true to create a top-level array containing all tokens from the file. */ tokens?: boolean; - - /* - * The JSX AST changed the node type for string literals - * inside a JSX Element from `Literal` to `JSXText`. - * When value is `true`, these nodes will be parsed as type `JSXText`. - * When value is `false`, these nodes will be parsed as type `Literal`. - */ - useJSXTextNode?: boolean; } const PARSE_DEFAULT_OPTIONS: ParseOptions = { @@ -120,7 +112,6 @@ const PARSE_DEFAULT_OPTIONS: ParseOptions = { loggerFn: undefined, range: false, tokens: false, - useJSXTextNode: false, }; declare function parse( diff --git a/packages/typescript-estree/src/ast-converter.ts b/packages/typescript-estree/src/ast-converter.ts index 33c8f9fbc5e5..465a0b955c47 100644 --- a/packages/typescript-estree/src/ast-converter.ts +++ b/packages/typescript-estree/src/ast-converter.ts @@ -25,7 +25,6 @@ export function astConverter( */ const instance = new Converter(ast, { errorOnUnknownASTType: extra.errorOnUnknownASTType || false, - useJSXTextNode: extra.useJSXTextNode || false, shouldPreserveNodeMaps, }); diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index 3f51f9af0d9b..be13f690458c 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -36,7 +36,6 @@ const SyntaxKind = ts.SyntaxKind; interface ConverterOptions { errorOnUnknownASTType: boolean; - useJSXTextNode: boolean; shouldPreserveNodeMaps: boolean; } @@ -2250,32 +2249,17 @@ export class Converter { }); } - /** - * The JSX AST changed the node type for string literals - * inside a JSX Element from `Literal` to `JSXText`. We - * provide a flag to support both types until `Literal` - * node type is deprecated in ESLint v5. - */ case SyntaxKind.JsxText: { const start = node.getFullStart(); const end = node.getEnd(); const text = this.ast.text.slice(start, end); - if (this.options.useJSXTextNode) { - return this.createNode(node, { - type: AST_NODE_TYPES.JSXText, - value: unescapeStringLiteralText(text), - raw: text, - range: [start, end], - }); - } else { - return this.createNode(node, { - type: AST_NODE_TYPES.Literal, - value: unescapeStringLiteralText(text), - raw: text, - range: [start, end], - }); - } + return this.createNode(node, { + type: AST_NODE_TYPES.JSXText, + value: unescapeStringLiteralText(text), + raw: text, + range: [start, end], + }); } case SyntaxKind.JsxSpreadAttribute: diff --git a/packages/typescript-estree/src/parser-options.ts b/packages/typescript-estree/src/parser-options.ts index 55f47ef9041d..fdd71cc55b55 100644 --- a/packages/typescript-estree/src/parser-options.ts +++ b/packages/typescript-estree/src/parser-options.ts @@ -27,7 +27,6 @@ export interface Extra { strict: boolean; tokens: null | TSESTree.Token[]; tsconfigRootDir: string; - useJSXTextNode: boolean; moduleResolver: string; } @@ -100,14 +99,6 @@ interface ParseOptions { * Set to true to create a top-level array containing all tokens from the file. */ tokens?: boolean; - - /* - * The JSX AST changed the node type for string literals - * inside a JSX Element from `Literal` to `JSXText`. - * When value is `true`, these nodes will be parsed as type `JSXText`. - * When value is `false`, these nodes will be parsed as type `Literal`. - */ - useJSXTextNode?: boolean; } interface ParseAndGenerateServicesOptions extends ParseOptions { diff --git a/packages/typescript-estree/src/parser.ts b/packages/typescript-estree/src/parser.ts index 6cb3a2d6c27b..9a9dc04a771e 100644 --- a/packages/typescript-estree/src/parser.ts +++ b/packages/typescript-estree/src/parser.ts @@ -129,7 +129,6 @@ function resetExtra(): void { strict: false, tokens: null, tsconfigRootDir: process.cwd(), - useJSXTextNode: false, /** * Unless we can reliably infer otherwise, we default to assuming that this run could be part * of a long-running session (e.g. in an IDE) and watch programs will therefore be required @@ -251,17 +250,6 @@ function applyParserOptionsToExtra(options: TSESTreeOptions): void { extra.filePath = getFileName(extra); } - /** - * The JSX AST changed the node type for string literals - * inside a JSX Element from `Literal` to `JSXText`. - * - * When value is `true`, these nodes will be parsed as type `JSXText`. - * When value is `false`, these nodes will be parsed as type `Literal`. - */ - if (typeof options.useJSXTextNode === 'boolean' && options.useJSXTextNode) { - extra.useJSXTextNode = true; - } - /** * Allow the user to cause the parser to error if it encounters an unknown AST Node Type * (used in testing) diff --git a/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts b/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts index 65951a856df6..8faaef068d54 100644 --- a/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts +++ b/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts @@ -100,7 +100,6 @@ export interface EstreeToTsNodeTypes { | ts.StringLiteral | ts.NumericLiteral | ts.RegularExpressionLiteral - | ts.JsxText | ts.NullLiteral | ts.BooleanLiteral | ts.BigIntLiteral; diff --git a/packages/typescript-estree/tests/ast-alignment/parse.ts b/packages/typescript-estree/tests/ast-alignment/parse.ts index 484c8ef18d1e..0cf1898a321e 100644 --- a/packages/typescript-estree/tests/ast-alignment/parse.ts +++ b/packages/typescript-estree/tests/ast-alignment/parse.ts @@ -50,7 +50,6 @@ function parseWithTypeScriptESTree(text: string, jsx = true): parser.AST { range: true, tokens: false, comment: false, - useJSXTextNode: true, errorOnUnknownASTType: true, /** * Babel will always throw on these types of issues, so we enable diff --git a/packages/typescript-estree/tests/lib/convert.test.ts b/packages/typescript-estree/tests/lib/convert.test.ts index b26390b7f750..74ce08aa9673 100644 --- a/packages/typescript-estree/tests/lib/convert.test.ts +++ b/packages/typescript-estree/tests/lib/convert.test.ts @@ -27,7 +27,6 @@ describe('convert', () => { const instance = new Converter(ast, { errorOnUnknownASTType: false, - useJSXTextNode: false, shouldPreserveNodeMaps: false, }); expect(instance.convertProgram()).toMatchSnapshot(); @@ -38,7 +37,6 @@ describe('convert', () => { const instance = new Converter(ast, { errorOnUnknownASTType: false, - useJSXTextNode: false, shouldPreserveNodeMaps: false, }) as any; @@ -50,7 +48,6 @@ describe('convert', () => { const instance = new Converter(ast, { errorOnUnknownASTType: false, - useJSXTextNode: false, shouldPreserveNodeMaps: false, }) as any; @@ -62,7 +59,6 @@ describe('convert', () => { const instance = new Converter(ast, { errorOnUnknownASTType: false, - useJSXTextNode: false, shouldPreserveNodeMaps: false, }) as any; @@ -76,7 +72,6 @@ describe('convert', () => { const instance = new Converter(ast, { errorOnUnknownASTType: false, - useJSXTextNode: false, shouldPreserveNodeMaps: false, }) as any; expect(instance.deeplyCopy(ast)).toMatchSnapshot(); @@ -87,7 +82,6 @@ describe('convert', () => { const instance = new Converter(ast, { errorOnUnknownASTType: true, - useJSXTextNode: false, shouldPreserveNodeMaps: false, }) as any; @@ -106,7 +100,6 @@ describe('convert', () => { const instance = new Converter(ast, { errorOnUnknownASTType: false, - useJSXTextNode: false, shouldPreserveNodeMaps: true, }); instance.convertProgram(); @@ -140,7 +133,6 @@ describe('convert', () => { const instance = new Converter(ast, { errorOnUnknownASTType: false, - useJSXTextNode: false, shouldPreserveNodeMaps: true, }); instance.convertProgram(); @@ -173,7 +165,6 @@ describe('convert', () => { const instance = new Converter(ast, { errorOnUnknownASTType: false, - useJSXTextNode: false, shouldPreserveNodeMaps: true, }); const program = instance.convertProgram(); @@ -205,7 +196,6 @@ describe('convert', () => { const ast = convertCode(''); const instance = new Converter(ast, { errorOnUnknownASTType: false, - useJSXTextNode: false, shouldPreserveNodeMaps: true, }); @@ -250,7 +240,6 @@ describe('convert', () => { const instance = new Converter(ast, { errorOnUnknownASTType: false, - useJSXTextNode: false, shouldPreserveNodeMaps: false, }); expect(() => instance.convertProgram()).toThrow( diff --git a/packages/typescript-estree/tests/lib/semanticInfo.test.ts b/packages/typescript-estree/tests/lib/semanticInfo.test.ts index d099342c72e7..ccce1f6e4c8d 100644 --- a/packages/typescript-estree/tests/lib/semanticInfo.test.ts +++ b/packages/typescript-estree/tests/lib/semanticInfo.test.ts @@ -28,7 +28,6 @@ function createOptions(fileName: string): TSESTreeOptions & { cwd?: string } { tokens: true, comment: true, jsx: false, - useJSXTextNode: false, errorOnUnknownASTType: true, filePath: fileName, tsconfigRootDir: path.join(process.cwd(), FIXTURES_DIR), diff --git a/packages/typescript-estree/tests/snapshots/comments/jsx-attr-and-text-with-url.src.js.shot b/packages/typescript-estree/tests/snapshots/comments/jsx-attr-and-text-with-url.src.js.shot index 23e257d45f1d..0313f535de1d 100644 --- a/packages/typescript-estree/tests/snapshots/comments/jsx-attr-and-text-with-url.src.js.shot +++ b/packages/typescript-estree/tests/snapshots/comments/jsx-attr-and-text-with-url.src.js.shot @@ -42,7 +42,7 @@ Object { 61, ], "raw": "http://example.com", - "type": "Literal", + "type": "JSXText", "value": "http://example.com", }, ], diff --git a/packages/typescript-estree/tests/snapshots/comments/jsx-block-comment.src.js.shot b/packages/typescript-estree/tests/snapshots/comments/jsx-block-comment.src.js.shot index f4155967a745..851f8980ab51 100644 --- a/packages/typescript-estree/tests/snapshots/comments/jsx-block-comment.src.js.shot +++ b/packages/typescript-estree/tests/snapshots/comments/jsx-block-comment.src.js.shot @@ -48,7 +48,7 @@ Object { ], "raw": " ", - "type": "Literal", + "type": "JSXText", "value": " ", }, @@ -103,7 +103,7 @@ Object { ], "raw": " ", - "type": "Literal", + "type": "JSXText", "value": " ", }, diff --git a/packages/typescript-estree/tests/snapshots/comments/jsx-generic-with-comment-in-tag.src.js.shot b/packages/typescript-estree/tests/snapshots/comments/jsx-generic-with-comment-in-tag.src.js.shot index 01c1a39e231f..cbf278f9ee7b 100644 --- a/packages/typescript-estree/tests/snapshots/comments/jsx-generic-with-comment-in-tag.src.js.shot +++ b/packages/typescript-estree/tests/snapshots/comments/jsx-generic-with-comment-in-tag.src.js.shot @@ -43,7 +43,7 @@ Object { ], "raw": " ", - "type": "Literal", + "type": "JSXText", "value": " ", }, @@ -190,7 +190,7 @@ Object { ], "raw": " ", - "type": "Literal", + "type": "JSXText", "value": " ", }, @@ -374,7 +374,7 @@ Object { ], "raw": " ", - "type": "Literal", + "type": "JSXText", "value": " ", }, @@ -558,7 +558,7 @@ Object { ], "raw": " ", - "type": "Literal", + "type": "JSXText", "value": " ", }, @@ -779,7 +779,7 @@ Object { "raw": " ", - "type": "Literal", + "type": "JSXText", "value": " ", @@ -927,7 +927,7 @@ Object { ], "raw": " ", - "type": "Literal", + "type": "JSXText", "value": " ", }, @@ -1111,7 +1111,7 @@ Object { ], "raw": " ", - "type": "Literal", + "type": "JSXText", "value": " ", }, @@ -1295,7 +1295,7 @@ Object { ], "raw": " ", - "type": "Literal", + "type": "JSXText", "value": " ", }, @@ -1515,7 +1515,7 @@ Object { ], "raw": " ", - "type": "Literal", + "type": "JSXText", "value": " ", }, diff --git a/packages/typescript-estree/tests/snapshots/comments/jsx-tag-comments.src.js.shot b/packages/typescript-estree/tests/snapshots/comments/jsx-tag-comments.src.js.shot index e14584d71e3f..177f12a16625 100644 --- a/packages/typescript-estree/tests/snapshots/comments/jsx-tag-comments.src.js.shot +++ b/packages/typescript-estree/tests/snapshots/comments/jsx-tag-comments.src.js.shot @@ -48,7 +48,7 @@ Object { ], "raw": " ", - "type": "Literal", + "type": "JSXText", "value": " ", }, diff --git a/packages/typescript-estree/tests/snapshots/comments/jsx-text-with-multiline-non-comment.src.js.shot b/packages/typescript-estree/tests/snapshots/comments/jsx-text-with-multiline-non-comment.src.js.shot index dce1129ff0f1..34ae0afe27e7 100644 --- a/packages/typescript-estree/tests/snapshots/comments/jsx-text-with-multiline-non-comment.src.js.shot +++ b/packages/typescript-estree/tests/snapshots/comments/jsx-text-with-multiline-non-comment.src.js.shot @@ -51,7 +51,7 @@ Object { * test */ ", - "type": "Literal", + "type": "JSXText", "value": " /** * test diff --git a/packages/typescript-estree/tests/snapshots/comments/jsx-text-with-url.src.js.shot b/packages/typescript-estree/tests/snapshots/comments/jsx-text-with-url.src.js.shot index c0b9bcc60388..b51fc4edf9ce 100644 --- a/packages/typescript-estree/tests/snapshots/comments/jsx-text-with-url.src.js.shot +++ b/packages/typescript-estree/tests/snapshots/comments/jsx-text-with-url.src.js.shot @@ -42,7 +42,7 @@ Object { 37, ], "raw": "http://example.com", - "type": "Literal", + "type": "JSXText", "value": "http://example.com", }, ], @@ -208,7 +208,7 @@ Object { 81, ], "raw": "http://example.com", - "type": "Literal", + "type": "JSXText", "value": "http://example.com", }, ], @@ -392,7 +392,7 @@ Object { 130, ], "raw": "http://example.com", - "type": "Literal", + "type": "JSXText", "value": "http://example.com", }, ], @@ -649,7 +649,7 @@ Object { 190, ], "raw": "http://example.com", - "type": "Literal", + "type": "JSXText", "value": "http://example.com", }, ], @@ -849,7 +849,7 @@ Object { 238, ], "raw": "http://example.com", - "type": "Literal", + "type": "JSXText", "value": "http://example.com", }, ], diff --git a/packages/typescript-estree/tests/snapshots/comments/jsx-with-greather-than.src.js.shot b/packages/typescript-estree/tests/snapshots/comments/jsx-with-greather-than.src.js.shot index b2ccc72ae26e..308c14521e5e 100644 --- a/packages/typescript-estree/tests/snapshots/comments/jsx-with-greather-than.src.js.shot +++ b/packages/typescript-estree/tests/snapshots/comments/jsx-with-greather-than.src.js.shot @@ -157,7 +157,7 @@ Object { 61, ], "raw": "//", - "type": "Literal", + "type": "JSXText", "value": "//", }, ], diff --git a/packages/typescript-estree/tests/snapshots/comments/jsx-with-operators.src.js.shot b/packages/typescript-estree/tests/snapshots/comments/jsx-with-operators.src.js.shot index 623f6422eedb..2d5c27d4fe04 100644 --- a/packages/typescript-estree/tests/snapshots/comments/jsx-with-operators.src.js.shot +++ b/packages/typescript-estree/tests/snapshots/comments/jsx-with-operators.src.js.shot @@ -157,7 +157,7 @@ Object { 61, ], "raw": "//", - "type": "Literal", + "type": "JSXText", "value": "//", }, ], diff --git a/packages/typescript-estree/tests/snapshots/jsx-useJSXTextNode/self-closing-tag-inside-tag.src.js.shot b/packages/typescript-estree/tests/snapshots/jsx-useJSXTextNode/self-closing-tag-inside-tag.src.js.shot index f19079709bf4..2e6300509975 100644 --- a/packages/typescript-estree/tests/snapshots/jsx-useJSXTextNode/self-closing-tag-inside-tag.src.js.shot +++ b/packages/typescript-estree/tests/snapshots/jsx-useJSXTextNode/self-closing-tag-inside-tag.src.js.shot @@ -23,7 +23,7 @@ Object { ], "raw": " ", - "type": "Literal", + "type": "JSXText", "value": " ", }, @@ -101,7 +101,7 @@ Object { ], "raw": " ", - "type": "Literal", + "type": "JSXText", "value": " ", }, diff --git a/packages/typescript-estree/tests/snapshots/jsx-useJSXTextNode/test-content.src.js.shot b/packages/typescript-estree/tests/snapshots/jsx-useJSXTextNode/test-content.src.js.shot index 7a64b57e9dac..326c3194f956 100644 --- a/packages/typescript-estree/tests/snapshots/jsx-useJSXTextNode/test-content.src.js.shot +++ b/packages/typescript-estree/tests/snapshots/jsx-useJSXTextNode/test-content.src.js.shot @@ -22,7 +22,7 @@ Object { 18, ], "raw": "@test content", - "type": "Literal", + "type": "JSXText", "value": "@test content", }, ], diff --git a/packages/typescript-estree/tests/snapshots/jsx/attributes.src.js.shot b/packages/typescript-estree/tests/snapshots/jsx/attributes.src.js.shot index 1c6978110358..0c7c49b765a7 100644 --- a/packages/typescript-estree/tests/snapshots/jsx/attributes.src.js.shot +++ b/packages/typescript-estree/tests/snapshots/jsx/attributes.src.js.shot @@ -22,7 +22,7 @@ Object { 39, ], "raw": "test", - "type": "Literal", + "type": "JSXText", "value": "test", }, ], diff --git a/packages/typescript-estree/tests/snapshots/jsx/element-keyword-name.src.js.shot b/packages/typescript-estree/tests/snapshots/jsx/element-keyword-name.src.js.shot index 9a3ca8aae026..a1526ac3de67 100644 --- a/packages/typescript-estree/tests/snapshots/jsx/element-keyword-name.src.js.shot +++ b/packages/typescript-estree/tests/snapshots/jsx/element-keyword-name.src.js.shot @@ -23,7 +23,7 @@ Object { ], "raw": " ", - "type": "Literal", + "type": "JSXText", "value": " ", }, @@ -101,7 +101,7 @@ Object { ], "raw": " ", - "type": "Literal", + "type": "JSXText", "value": " ", }, @@ -179,7 +179,7 @@ Object { ], "raw": " ", - "type": "Literal", + "type": "JSXText", "value": " ", }, @@ -257,7 +257,7 @@ Object { ], "raw": " ", - "type": "Literal", + "type": "JSXText", "value": " ", }, diff --git a/packages/typescript-estree/tests/snapshots/jsx/embedded-invalid-js-identifier.src.js.shot b/packages/typescript-estree/tests/snapshots/jsx/embedded-invalid-js-identifier.src.js.shot index 40d5fc4812c2..e67cf324a956 100644 --- a/packages/typescript-estree/tests/snapshots/jsx/embedded-invalid-js-identifier.src.js.shot +++ b/packages/typescript-estree/tests/snapshots/jsx/embedded-invalid-js-identifier.src.js.shot @@ -79,7 +79,7 @@ Object { 35, ], "raw": "7x invalid-js-identifier", - "type": "Literal", + "type": "JSXText", "value": "7x invalid-js-identifier", }, ], diff --git a/packages/typescript-estree/tests/snapshots/jsx/escape-patterns-unknown.src.js.shot b/packages/typescript-estree/tests/snapshots/jsx/escape-patterns-unknown.src.js.shot index 25cd76ed83d8..141520e983f4 100644 --- a/packages/typescript-estree/tests/snapshots/jsx/escape-patterns-unknown.src.js.shot +++ b/packages/typescript-estree/tests/snapshots/jsx/escape-patterns-unknown.src.js.shot @@ -409,7 +409,7 @@ Object { 70, ], "raw": "&abc;", - "type": "Literal", + "type": "JSXText", "value": "&abc;", }, ], @@ -537,7 +537,7 @@ Object { 92, ], "raw": "¬anentity;", - "type": "Literal", + "type": "JSXText", "value": "¬anentity;", }, ], @@ -665,7 +665,7 @@ Object { 105, ], "raw": "&#x;", - "type": "Literal", + "type": "JSXText", "value": "&#x;", }, ], diff --git a/packages/typescript-estree/tests/snapshots/jsx/escape-patterns-valid.src.js.shot b/packages/typescript-estree/tests/snapshots/jsx/escape-patterns-valid.src.js.shot index 2cc38d57adbe..1856270c740c 100644 --- a/packages/typescript-estree/tests/snapshots/jsx/escape-patterns-valid.src.js.shot +++ b/packages/typescript-estree/tests/snapshots/jsx/escape-patterns-valid.src.js.shot @@ -24,7 +24,7 @@ Object { "raw": "   ", - "type": "Literal", + "type": "JSXText", "value": "   ", diff --git a/packages/typescript-estree/tests/snapshots/jsx/escape-patters-multi.src.js.shot b/packages/typescript-estree/tests/snapshots/jsx/escape-patters-multi.src.js.shot index d3cff5df9bf9..cc3c38b714cd 100644 --- a/packages/typescript-estree/tests/snapshots/jsx/escape-patters-multi.src.js.shot +++ b/packages/typescript-estree/tests/snapshots/jsx/escape-patters-multi.src.js.shot @@ -22,7 +22,7 @@ Object { 44, ], "raw": "  test", - "type": "Literal", + "type": "JSXText", "value": "  test", }, ], diff --git a/packages/typescript-estree/tests/snapshots/jsx/multiple-blank-spaces.src.js.shot b/packages/typescript-estree/tests/snapshots/jsx/multiple-blank-spaces.src.js.shot index 9e5cd8c899c9..17fa0430b73c 100644 --- a/packages/typescript-estree/tests/snapshots/jsx/multiple-blank-spaces.src.js.shot +++ b/packages/typescript-estree/tests/snapshots/jsx/multiple-blank-spaces.src.js.shot @@ -22,7 +22,7 @@ Object { 7, ], "raw": " ", - "type": "Literal", + "type": "JSXText", "value": " ", }, ], diff --git a/packages/typescript-estree/tests/snapshots/jsx/namespaced-attribute-and-value-inserted.src.js.shot b/packages/typescript-estree/tests/snapshots/jsx/namespaced-attribute-and-value-inserted.src.js.shot index 647aa3f85b5e..cfb3f96c345d 100644 --- a/packages/typescript-estree/tests/snapshots/jsx/namespaced-attribute-and-value-inserted.src.js.shot +++ b/packages/typescript-estree/tests/snapshots/jsx/namespaced-attribute-and-value-inserted.src.js.shot @@ -22,7 +22,7 @@ Object { 16, ], "raw": " ", - "type": "Literal", + "type": "JSXText", "value": " ", }, Object { @@ -76,7 +76,7 @@ Object { 24, ], "raw": " ", - "type": "Literal", + "type": "JSXText", "value": " ", }, Object { diff --git a/packages/typescript-estree/tests/snapshots/jsx/self-closing-tag-inside-tag.src.js.shot b/packages/typescript-estree/tests/snapshots/jsx/self-closing-tag-inside-tag.src.js.shot index 373468554f63..cfb82c9a414f 100644 --- a/packages/typescript-estree/tests/snapshots/jsx/self-closing-tag-inside-tag.src.js.shot +++ b/packages/typescript-estree/tests/snapshots/jsx/self-closing-tag-inside-tag.src.js.shot @@ -23,7 +23,7 @@ Object { ], "raw": " ", - "type": "Literal", + "type": "JSXText", "value": " ", }, @@ -101,7 +101,7 @@ Object { ], "raw": " ", - "type": "Literal", + "type": "JSXText", "value": " ", }, diff --git a/packages/typescript-estree/tests/snapshots/jsx/tag-names-with-multi-dots-multi.src.js.shot b/packages/typescript-estree/tests/snapshots/jsx/tag-names-with-multi-dots-multi.src.js.shot index 9edf414fa882..7ef41034fc55 100644 --- a/packages/typescript-estree/tests/snapshots/jsx/tag-names-with-multi-dots-multi.src.js.shot +++ b/packages/typescript-estree/tests/snapshots/jsx/tag-names-with-multi-dots-multi.src.js.shot @@ -23,7 +23,7 @@ Object { ], "raw": " ", - "type": "Literal", + "type": "JSXText", "value": " ", }, @@ -345,7 +345,7 @@ Object { ], "raw": " ", - "type": "Literal", + "type": "JSXText", "value": " ", }, diff --git a/packages/typescript-estree/tests/snapshots/jsx/test-content.src.js.shot b/packages/typescript-estree/tests/snapshots/jsx/test-content.src.js.shot index b400dfee5ad0..4df5e2ed08b0 100644 --- a/packages/typescript-estree/tests/snapshots/jsx/test-content.src.js.shot +++ b/packages/typescript-estree/tests/snapshots/jsx/test-content.src.js.shot @@ -22,7 +22,7 @@ Object { 18, ], "raw": "@test content", - "type": "Literal", + "type": "JSXText", "value": "@test content", }, ], diff --git a/packages/typescript-estree/tests/snapshots/tsx/react-typed-props.src.tsx.shot b/packages/typescript-estree/tests/snapshots/tsx/react-typed-props.src.tsx.shot index 52271fbad013..c526bcc9da4a 100644 --- a/packages/typescript-estree/tests/snapshots/tsx/react-typed-props.src.tsx.shot +++ b/packages/typescript-estree/tests/snapshots/tsx/react-typed-props.src.tsx.shot @@ -231,7 +231,7 @@ Object { ], "raw": " ", - "type": "Literal", + "type": "JSXText", "value": " ", }, @@ -324,7 +324,7 @@ Object { ], "raw": " ", - "type": "Literal", + "type": "JSXText", "value": " ", }, From cf4724b615f9eb081cbdab89e47db1af5df7e3e9 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Tue, 24 Aug 2021 10:19:33 -0700 Subject: [PATCH 29/44] chore: add auto-canary release for v5 (#3776) * chore: add auto-canary release for v5 * chore: fix name --- .github/workflows/ci.yml | 48 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3ce54875bc2e..09e5a49fc8db 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,6 +4,7 @@ on: push: branches: - master + - v5 pull_request: branches: - '**' @@ -366,3 +367,50 @@ jobs: run: npx lerna publish --loglevel=verbose --canary --exact --force-publish --yes env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + publish_canary_version_v5: + name: Publish the latest code as a canary version + runs-on: ubuntu-latest + needs: [typecheck, test_on_primary_node_version, unit_tests_on_other_node_versions, linting_and_style, integration_tests] + if: github.repository == 'typescript-eslint/typescript-eslint' && github.ref == 'refs/heads/v5' + steps: + - uses: actions/checkout@v2 + # Fetch all history for all tags and branches in this job because lerna needs it + - run: | + git fetch --prune --unshallow + + - name: Use Node.js ${{ env.PRIMARY_NODE_VERSION }} + uses: actions/setup-node@v1 + with: + node-version: ${{ env.PRIMARY_NODE_VERSION }} + registry-url: https://registry.npmjs.org/ + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + + - uses: actions/cache@v2 + id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Install dependencies + run: | + yarn --ignore-engines --frozen-lockfile --ignore-scripts + yarn check-clean-workspace-after-install + + - name: Patch Dependencies + run: | + yarn patch-package + + - name: Build + run: | + yarn build + + - name: Publish all packages to npm + run: npx lerna publish premajor --loglevel=verbose --canary --exact --force-publish --yes --dist-tag rc-v5 + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} From 71c93706e55f5f92a1285102b93c6ab1950c6df4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Sat, 28 Aug 2021 23:57:54 +0200 Subject: [PATCH 30/44] feat: remove `meta.docs.category` from rules (#3800) --- .../src/rules/no-poorly-typed-ts-props.ts | 1 - .../src/rules/no-typescript-default-import.ts | 1 - .../src/rules/no-typescript-estree-import.ts | 1 - .../src/rules/plugin-test-formatting.ts | 1 - .../src/rules/prefer-ast-types-enum.ts | 1 - .../eslint-plugin-tslint/src/rules/config.ts | 2 -- .../src/rules/adjacent-overload-signatures.ts | 1 - .../eslint-plugin/src/rules/array-type.ts | 1 - .../eslint-plugin/src/rules/await-thenable.ts | 1 - .../eslint-plugin/src/rules/ban-ts-comment.ts | 1 - .../src/rules/ban-tslint-comment.ts | 1 - packages/eslint-plugin/src/rules/ban-types.ts | 1 - .../eslint-plugin/src/rules/brace-style.ts | 1 - .../src/rules/class-literal-property-style.ts | 1 - .../eslint-plugin/src/rules/comma-dangle.ts | 1 - .../eslint-plugin/src/rules/comma-spacing.ts | 1 - .../rules/consistent-indexed-object-style.ts | 1 - .../src/rules/consistent-type-assertions.ts | 1 - .../src/rules/consistent-type-definitions.ts | 1 - .../src/rules/consistent-type-imports.ts | 1 - .../src/rules/default-param-last.ts | 1 - .../eslint-plugin/src/rules/dot-notation.ts | 1 - .../rules/explicit-function-return-type.ts | 1 - .../rules/explicit-member-accessibility.ts | 1 - .../rules/explicit-module-boundary-types.ts | 1 - .../src/rules/func-call-spacing.ts | 1 - .../src/rules/indent-new-do-not-use/index.ts | 1 - packages/eslint-plugin/src/rules/indent.ts | 1 - .../src/rules/init-declarations.ts | 1 - .../src/rules/keyword-spacing.ts | 1 - .../src/rules/lines-between-class-members.ts | 1 - .../src/rules/member-delimiter-style.ts | 1 - .../src/rules/member-ordering.ts | 1 - .../src/rules/method-signature-style.ts | 1 - .../src/rules/naming-convention.ts | 1 - .../src/rules/no-array-constructor.ts | 1 - .../src/rules/no-base-to-string.ts | 1 - .../rules/no-confusing-non-null-assertion.ts | 1 - .../src/rules/no-confusing-void-expression.ts | 1 - .../src/rules/no-dupe-class-members.ts | 1 - .../src/rules/no-duplicate-imports.ts | 1 - .../src/rules/no-dynamic-delete.ts | 1 - .../src/rules/no-empty-function.ts | 1 - .../src/rules/no-empty-interface.ts | 1 - .../src/rules/no-explicit-any.ts | 1 - .../src/rules/no-extra-non-null-assertion.ts | 1 - .../src/rules/no-extra-parens.ts | 1 - .../eslint-plugin/src/rules/no-extra-semi.ts | 1 - .../src/rules/no-extraneous-class.ts | 1 - .../src/rules/no-floating-promises.ts | 1 - .../src/rules/no-for-in-array.ts | 1 - .../src/rules/no-implicit-any-catch.ts | 1 - .../src/rules/no-implied-eval.ts | 1 - .../src/rules/no-inferrable-types.ts | 1 - .../src/rules/no-invalid-this.ts | 1 - .../src/rules/no-invalid-void-type.ts | 1 - .../eslint-plugin/src/rules/no-loop-func.ts | 1 - .../src/rules/no-loss-of-precision.ts | 1 - .../src/rules/no-magic-numbers.ts | 1 - .../eslint-plugin/src/rules/no-misused-new.ts | 1 - .../src/rules/no-misused-promises.ts | 1 - .../eslint-plugin/src/rules/no-namespace.ts | 1 - .../no-non-null-asserted-optional-chain.ts | 1 - .../src/rules/no-non-null-assertion.ts | 1 - .../src/rules/no-parameter-properties.ts | 1 - .../eslint-plugin/src/rules/no-redeclare.ts | 1 - .../src/rules/no-require-imports.ts | 1 - packages/eslint-plugin/src/rules/no-shadow.ts | 1 - .../eslint-plugin/src/rules/no-this-alias.ts | 1 - .../src/rules/no-throw-literal.ts | 1 - .../eslint-plugin/src/rules/no-type-alias.ts | 1 - .../no-unnecessary-boolean-literal-compare.ts | 1 - .../src/rules/no-unnecessary-condition.ts | 1 - .../src/rules/no-unnecessary-qualifier.ts | 1 - .../rules/no-unnecessary-type-arguments.ts | 1 - .../rules/no-unnecessary-type-assertion.ts | 1 - .../rules/no-unnecessary-type-constraint.ts | 1 - .../src/rules/no-unsafe-argument.ts | 1 - .../src/rules/no-unsafe-assignment.ts | 1 - .../eslint-plugin/src/rules/no-unsafe-call.ts | 1 - .../src/rules/no-unsafe-member-access.ts | 1 - .../src/rules/no-unsafe-return.ts | 1 - .../src/rules/no-unused-expressions.ts | 1 - .../eslint-plugin/src/rules/no-unused-vars.ts | 1 - .../src/rules/no-use-before-define.ts | 1 - .../src/rules/no-useless-constructor.ts | 1 - .../src/rules/no-var-requires.ts | 1 - .../non-nullable-type-assertion-style.ts | 1 - .../src/rules/object-curly-spacing.ts | 1 - .../src/rules/prefer-as-const.ts | 1 - .../src/rules/prefer-enum-initializers.ts | 1 - .../eslint-plugin/src/rules/prefer-for-of.ts | 1 - .../src/rules/prefer-function-type.ts | 1 - .../src/rules/prefer-includes.ts | 1 - .../src/rules/prefer-literal-enum-member.ts | 1 - .../src/rules/prefer-namespace-keyword.ts | 1 - .../src/rules/prefer-nullish-coalescing.ts | 1 - .../src/rules/prefer-optional-chain.ts | 1 - .../rules/prefer-readonly-parameter-types.ts | 1 - .../src/rules/prefer-readonly.ts | 1 - .../src/rules/prefer-reduce-type-parameter.ts | 1 - .../src/rules/prefer-regexp-exec.ts | 1 - .../src/rules/prefer-return-this-type.ts | 1 - .../rules/prefer-string-starts-ends-with.ts | 1 - .../src/rules/prefer-ts-expect-error.ts | 1 - .../src/rules/promise-function-async.ts | 1 - packages/eslint-plugin/src/rules/quotes.ts | 1 - .../src/rules/require-array-sort-compare.ts | 1 - .../eslint-plugin/src/rules/require-await.ts | 1 - .../src/rules/restrict-plus-operands.ts | 1 - .../rules/restrict-template-expressions.ts | 1 - .../eslint-plugin/src/rules/return-await.ts | 1 - packages/eslint-plugin/src/rules/semi.ts | 1 - .../sort-type-union-intersection-members.ts | 1 - .../src/rules/space-before-function-paren.ts | 1 - .../src/rules/space-infix-ops.ts | 1 - .../src/rules/strict-boolean-expressions.ts | 1 - .../src/rules/switch-exhaustiveness-check.ts | 1 - .../src/rules/triple-slash-reference.ts | 1 - .../src/rules/type-annotation-spacing.ts | 1 - packages/eslint-plugin/src/rules/typedef.ts | 1 - .../eslint-plugin/src/rules/unbound-method.ts | 1 - .../src/rules/unified-signatures.ts | 1 - .../tests/util/getWrappingFixer.test.ts | 1 - .../experimental-utils/src/ts-eslint/Rule.ts | 20 ++++++------------- .../tests/eslint-utils/RuleCreator.test.ts | 2 -- yarn.lock | 6 +++--- 127 files changed, 9 insertions(+), 144 deletions(-) diff --git a/packages/eslint-plugin-internal/src/rules/no-poorly-typed-ts-props.ts b/packages/eslint-plugin-internal/src/rules/no-poorly-typed-ts-props.ts index 8ce331b4dad1..f91068d9ffe0 100644 --- a/packages/eslint-plugin-internal/src/rules/no-poorly-typed-ts-props.ts +++ b/packages/eslint-plugin-internal/src/rules/no-poorly-typed-ts-props.ts @@ -38,7 +38,6 @@ export default createRule({ docs: { description: "Enforces rules don't use TS API properties with known bad type definitions", - category: 'Possible Errors', recommended: 'error', suggestion: true, requiresTypeChecking: true, diff --git a/packages/eslint-plugin-internal/src/rules/no-typescript-default-import.ts b/packages/eslint-plugin-internal/src/rules/no-typescript-default-import.ts index ff4e35dc4f60..c82561312496 100644 --- a/packages/eslint-plugin-internal/src/rules/no-typescript-default-import.ts +++ b/packages/eslint-plugin-internal/src/rules/no-typescript-default-import.ts @@ -22,7 +22,6 @@ export default createRule({ docs: { description: "Enforces that packages rules don't do `import ts from 'typescript';`", - category: 'Possible Errors', recommended: 'error', }, fixable: 'code', diff --git a/packages/eslint-plugin-internal/src/rules/no-typescript-estree-import.ts b/packages/eslint-plugin-internal/src/rules/no-typescript-estree-import.ts index b3c3a71c60d6..3cc96a0f6003 100644 --- a/packages/eslint-plugin-internal/src/rules/no-typescript-estree-import.ts +++ b/packages/eslint-plugin-internal/src/rules/no-typescript-estree-import.ts @@ -16,7 +16,6 @@ export default createRule({ type: 'problem', docs: { description: `Enforces that eslint-plugin rules don't require anything from ${TSESTREE_NAME} or ${TYPES_NAME}`, - category: 'Possible Errors', recommended: 'error', }, fixable: 'code', diff --git a/packages/eslint-plugin-internal/src/rules/plugin-test-formatting.ts b/packages/eslint-plugin-internal/src/rules/plugin-test-formatting.ts index ed03e0fe1caf..81fcb8c41cf2 100644 --- a/packages/eslint-plugin-internal/src/rules/plugin-test-formatting.ts +++ b/packages/eslint-plugin-internal/src/rules/plugin-test-formatting.ts @@ -108,7 +108,6 @@ export default createRule({ type: 'problem', docs: { description: `Enforces that eslint-plugin test snippets are correctly formatted`, - category: 'Stylistic Issues', recommended: 'error', }, fixable: 'code', diff --git a/packages/eslint-plugin-internal/src/rules/prefer-ast-types-enum.ts b/packages/eslint-plugin-internal/src/rules/prefer-ast-types-enum.ts index c4a95695d967..e98d0904af52 100755 --- a/packages/eslint-plugin-internal/src/rules/prefer-ast-types-enum.ts +++ b/packages/eslint-plugin-internal/src/rules/prefer-ast-types-enum.ts @@ -15,7 +15,6 @@ export default createRule({ meta: { type: 'problem', docs: { - category: 'Best Practices', recommended: 'error', description: 'Ensures consistent usage of `AST_NODE_TYPES`, `AST_TOKEN_TYPES` and `DefinitionType` enums.', diff --git a/packages/eslint-plugin-tslint/src/rules/config.ts b/packages/eslint-plugin-tslint/src/rules/config.ts index 41326a8959c1..e865d8cbcdce 100644 --- a/packages/eslint-plugin-tslint/src/rules/config.ts +++ b/packages/eslint-plugin-tslint/src/rules/config.ts @@ -63,8 +63,6 @@ export default createRule({ docs: { description: 'Wraps a TSLint configuration and lints the whole source using TSLint', - // @ts-expect-error - We know this is a one off special category for this plugin - category: 'TSLint', recommended: false, }, fixable: 'code', diff --git a/packages/eslint-plugin/src/rules/adjacent-overload-signatures.ts b/packages/eslint-plugin/src/rules/adjacent-overload-signatures.ts index 05f120b4cf24..273b6c6bfb9b 100644 --- a/packages/eslint-plugin/src/rules/adjacent-overload-signatures.ts +++ b/packages/eslint-plugin/src/rules/adjacent-overload-signatures.ts @@ -21,7 +21,6 @@ export default util.createRule({ type: 'suggestion', docs: { description: 'Require that member overloads be consecutive', - category: 'Best Practices', recommended: 'error', }, schema: [], diff --git a/packages/eslint-plugin/src/rules/array-type.ts b/packages/eslint-plugin/src/rules/array-type.ts index 44de45f19de1..da2bfdef518b 100644 --- a/packages/eslint-plugin/src/rules/array-type.ts +++ b/packages/eslint-plugin/src/rules/array-type.ts @@ -92,7 +92,6 @@ export default util.createRule({ type: 'suggestion', docs: { description: 'Requires using either `T[]` or `Array` for arrays', - category: 'Stylistic Issues', // too opinionated to be recommended recommended: false, }, diff --git a/packages/eslint-plugin/src/rules/await-thenable.ts b/packages/eslint-plugin/src/rules/await-thenable.ts index 9858bad8ba2a..e1decc5ad3df 100644 --- a/packages/eslint-plugin/src/rules/await-thenable.ts +++ b/packages/eslint-plugin/src/rules/await-thenable.ts @@ -7,7 +7,6 @@ export default util.createRule({ meta: { docs: { description: 'Disallows awaiting a value that is not a Thenable', - category: 'Best Practices', recommended: 'error', requiresTypeChecking: true, }, diff --git a/packages/eslint-plugin/src/rules/ban-ts-comment.ts b/packages/eslint-plugin/src/rules/ban-ts-comment.ts index 4bf17c25d95b..a9e0caf0fe47 100644 --- a/packages/eslint-plugin/src/rules/ban-ts-comment.ts +++ b/packages/eslint-plugin/src/rules/ban-ts-comment.ts @@ -22,7 +22,6 @@ export default util.createRule<[Options], MessageIds>({ docs: { description: 'Bans `@ts-` comments from being used or requires descriptions after directive', - category: 'Best Practices', recommended: 'error', }, messages: { diff --git a/packages/eslint-plugin/src/rules/ban-tslint-comment.ts b/packages/eslint-plugin/src/rules/ban-tslint-comment.ts index 37dfefd380e5..14d32e72d889 100644 --- a/packages/eslint-plugin/src/rules/ban-tslint-comment.ts +++ b/packages/eslint-plugin/src/rules/ban-tslint-comment.ts @@ -20,7 +20,6 @@ export default util.createRule({ type: 'suggestion', docs: { description: 'Bans `// tslint:` comments from being used', - category: 'Stylistic Issues', recommended: false, }, messages: { diff --git a/packages/eslint-plugin/src/rules/ban-types.ts b/packages/eslint-plugin/src/rules/ban-types.ts index c9f03c89b969..32f05e9c1208 100644 --- a/packages/eslint-plugin/src/rules/ban-types.ts +++ b/packages/eslint-plugin/src/rules/ban-types.ts @@ -124,7 +124,6 @@ export default util.createRule({ type: 'suggestion', docs: { description: 'Bans specific types from being used', - category: 'Best Practices', recommended: 'error', }, fixable: 'code', diff --git a/packages/eslint-plugin/src/rules/brace-style.ts b/packages/eslint-plugin/src/rules/brace-style.ts index 8bd77aa12ff0..6635303b3865 100644 --- a/packages/eslint-plugin/src/rules/brace-style.ts +++ b/packages/eslint-plugin/src/rules/brace-style.ts @@ -18,7 +18,6 @@ export default createRule({ type: 'layout', docs: { description: 'Enforce consistent brace style for blocks', - category: 'Stylistic Issues', recommended: false, extendsBaseRule: true, }, diff --git a/packages/eslint-plugin/src/rules/class-literal-property-style.ts b/packages/eslint-plugin/src/rules/class-literal-property-style.ts index 0a257427ec10..dd3878e77a2f 100644 --- a/packages/eslint-plugin/src/rules/class-literal-property-style.ts +++ b/packages/eslint-plugin/src/rules/class-literal-property-style.ts @@ -44,7 +44,6 @@ export default util.createRule({ docs: { description: 'Ensures that literals on classes are exposed in a consistent style', - category: 'Best Practices', recommended: false, }, fixable: 'code', diff --git a/packages/eslint-plugin/src/rules/comma-dangle.ts b/packages/eslint-plugin/src/rules/comma-dangle.ts index 9c212cca47e8..298a3e92639c 100644 --- a/packages/eslint-plugin/src/rules/comma-dangle.ts +++ b/packages/eslint-plugin/src/rules/comma-dangle.ts @@ -45,7 +45,6 @@ export default util.createRule({ type: 'layout', docs: { description: 'Require or disallow trailing comma', - category: 'Stylistic Issues', recommended: false, extendsBaseRule: true, }, diff --git a/packages/eslint-plugin/src/rules/comma-spacing.ts b/packages/eslint-plugin/src/rules/comma-spacing.ts index 019a82a2e76e..c78322be8ea3 100644 --- a/packages/eslint-plugin/src/rules/comma-spacing.ts +++ b/packages/eslint-plugin/src/rules/comma-spacing.ts @@ -23,7 +23,6 @@ export default createRule({ type: 'suggestion', docs: { description: 'Enforces consistent spacing before and after commas', - category: 'Stylistic Issues', recommended: false, extendsBaseRule: true, }, diff --git a/packages/eslint-plugin/src/rules/consistent-indexed-object-style.ts b/packages/eslint-plugin/src/rules/consistent-indexed-object-style.ts index fcce191b2b53..29c5e534b4af 100644 --- a/packages/eslint-plugin/src/rules/consistent-indexed-object-style.ts +++ b/packages/eslint-plugin/src/rules/consistent-indexed-object-style.ts @@ -14,7 +14,6 @@ export default createRule({ type: 'suggestion', docs: { description: 'Enforce or disallow the use of the record type', - category: 'Stylistic Issues', // too opinionated to be recommended recommended: false, }, diff --git a/packages/eslint-plugin/src/rules/consistent-type-assertions.ts b/packages/eslint-plugin/src/rules/consistent-type-assertions.ts index 3b431b80675c..617381790665 100644 --- a/packages/eslint-plugin/src/rules/consistent-type-assertions.ts +++ b/packages/eslint-plugin/src/rules/consistent-type-assertions.ts @@ -25,7 +25,6 @@ export default util.createRule({ meta: { type: 'suggestion', docs: { - category: 'Best Practices', description: 'Enforces consistent usage of type assertions', recommended: false, }, diff --git a/packages/eslint-plugin/src/rules/consistent-type-definitions.ts b/packages/eslint-plugin/src/rules/consistent-type-definitions.ts index 07d848db298a..bacccf9143f9 100644 --- a/packages/eslint-plugin/src/rules/consistent-type-definitions.ts +++ b/packages/eslint-plugin/src/rules/consistent-type-definitions.ts @@ -13,7 +13,6 @@ export default util.createRule({ docs: { description: 'Consistent with type definition either `interface` or `type`', - category: 'Stylistic Issues', // too opinionated to be recommended recommended: false, }, diff --git a/packages/eslint-plugin/src/rules/consistent-type-imports.ts b/packages/eslint-plugin/src/rules/consistent-type-imports.ts index 34f264ff0c7d..1bfb695f27be 100644 --- a/packages/eslint-plugin/src/rules/consistent-type-imports.ts +++ b/packages/eslint-plugin/src/rules/consistent-type-imports.ts @@ -56,7 +56,6 @@ export default util.createRule({ type: 'suggestion', docs: { description: 'Enforces consistent usage of type imports', - category: 'Stylistic Issues', recommended: false, }, messages: { diff --git a/packages/eslint-plugin/src/rules/default-param-last.ts b/packages/eslint-plugin/src/rules/default-param-last.ts index dea41116911b..9673d852dd1d 100644 --- a/packages/eslint-plugin/src/rules/default-param-last.ts +++ b/packages/eslint-plugin/src/rules/default-param-last.ts @@ -10,7 +10,6 @@ export default createRule({ type: 'suggestion', docs: { description: 'Enforce default parameters to be last', - category: 'Best Practices', recommended: false, extendsBaseRule: true, }, diff --git a/packages/eslint-plugin/src/rules/dot-notation.ts b/packages/eslint-plugin/src/rules/dot-notation.ts index 9d5284b4aa63..01db4680cbec 100644 --- a/packages/eslint-plugin/src/rules/dot-notation.ts +++ b/packages/eslint-plugin/src/rules/dot-notation.ts @@ -20,7 +20,6 @@ export default createRule({ type: 'suggestion', docs: { description: 'enforce dot notation whenever possible', - category: 'Best Practices', recommended: false, extendsBaseRule: true, requiresTypeChecking: true, diff --git a/packages/eslint-plugin/src/rules/explicit-function-return-type.ts b/packages/eslint-plugin/src/rules/explicit-function-return-type.ts index f0904f07744e..e9a27b2b1fc0 100644 --- a/packages/eslint-plugin/src/rules/explicit-function-return-type.ts +++ b/packages/eslint-plugin/src/rules/explicit-function-return-type.ts @@ -26,7 +26,6 @@ export default util.createRule({ docs: { description: 'Require explicit return types on functions and class methods', - category: 'Stylistic Issues', recommended: false, }, messages: { diff --git a/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts b/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts index ece09d8bc71f..89671fa7567a 100644 --- a/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts +++ b/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts @@ -36,7 +36,6 @@ export default util.createRule({ docs: { description: 'Require explicit accessibility modifiers on class properties and methods', - category: 'Stylistic Issues', // too opinionated to be recommended recommended: false, }, diff --git a/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts b/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts index 33caf65f19b4..67301afc4406 100644 --- a/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts +++ b/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts @@ -37,7 +37,6 @@ export default util.createRule({ docs: { description: "Require explicit return and argument types on exported functions' and classes' public class methods", - category: 'Stylistic Issues', recommended: 'warn', }, messages: { diff --git a/packages/eslint-plugin/src/rules/func-call-spacing.ts b/packages/eslint-plugin/src/rules/func-call-spacing.ts index 08d72181eeb6..254f89396601 100644 --- a/packages/eslint-plugin/src/rules/func-call-spacing.ts +++ b/packages/eslint-plugin/src/rules/func-call-spacing.ts @@ -19,7 +19,6 @@ export default util.createRule({ docs: { description: 'Require or disallow spacing between function identifiers and their invocations', - category: 'Stylistic Issues', recommended: false, extendsBaseRule: true, }, diff --git a/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts b/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts index 573423135962..863e7d0889d0 100644 --- a/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts +++ b/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts @@ -257,7 +257,6 @@ export default createRule({ type: 'layout', docs: { description: 'Enforce consistent indentation.', - category: 'Stylistic Issues', recommended: false, }, fixable: 'whitespace', diff --git a/packages/eslint-plugin/src/rules/indent.ts b/packages/eslint-plugin/src/rules/indent.ts index 42b006177019..7835fd0e58d9 100644 --- a/packages/eslint-plugin/src/rules/indent.ts +++ b/packages/eslint-plugin/src/rules/indent.ts @@ -91,7 +91,6 @@ export default util.createRule({ type: 'layout', docs: { description: 'Enforce consistent indentation', - category: 'Stylistic Issues', // too opinionated to be recommended recommended: false, extendsBaseRule: true, diff --git a/packages/eslint-plugin/src/rules/init-declarations.ts b/packages/eslint-plugin/src/rules/init-declarations.ts index a75d6e031cd0..3a97a2c8eda1 100644 --- a/packages/eslint-plugin/src/rules/init-declarations.ts +++ b/packages/eslint-plugin/src/rules/init-declarations.ts @@ -21,7 +21,6 @@ export default createRule({ docs: { description: 'require or disallow initialization in variable declarations', - category: 'Variables', recommended: false, extendsBaseRule: true, }, diff --git a/packages/eslint-plugin/src/rules/keyword-spacing.ts b/packages/eslint-plugin/src/rules/keyword-spacing.ts index 18c1c60bbb95..a5620fb7d530 100644 --- a/packages/eslint-plugin/src/rules/keyword-spacing.ts +++ b/packages/eslint-plugin/src/rules/keyword-spacing.ts @@ -13,7 +13,6 @@ export default util.createRule({ type: 'layout', docs: { description: 'Enforce consistent spacing before and after keywords', - category: 'Stylistic Issues', recommended: false, extendsBaseRule: true, }, diff --git a/packages/eslint-plugin/src/rules/lines-between-class-members.ts b/packages/eslint-plugin/src/rules/lines-between-class-members.ts index 0e52e7b958cc..95c2f811e8a4 100644 --- a/packages/eslint-plugin/src/rules/lines-between-class-members.ts +++ b/packages/eslint-plugin/src/rules/lines-between-class-members.ts @@ -28,7 +28,6 @@ export default util.createRule({ type: 'layout', docs: { description: 'Require or disallow an empty line between class members', - category: 'Stylistic Issues', recommended: false, extendsBaseRule: true, }, diff --git a/packages/eslint-plugin/src/rules/member-delimiter-style.ts b/packages/eslint-plugin/src/rules/member-delimiter-style.ts index de0a60f013cf..5fa5a863a6fd 100644 --- a/packages/eslint-plugin/src/rules/member-delimiter-style.ts +++ b/packages/eslint-plugin/src/rules/member-delimiter-style.ts @@ -120,7 +120,6 @@ export default util.createRule({ docs: { description: 'Require a specific member delimiter style for interfaces and type literals', - category: 'Stylistic Issues', recommended: false, }, fixable: 'code', diff --git a/packages/eslint-plugin/src/rules/member-ordering.ts b/packages/eslint-plugin/src/rules/member-ordering.ts index 34c922a39181..13a4fb65ae5c 100644 --- a/packages/eslint-plugin/src/rules/member-ordering.ts +++ b/packages/eslint-plugin/src/rules/member-ordering.ts @@ -423,7 +423,6 @@ export default util.createRule({ type: 'suggestion', docs: { description: 'Require a consistent member declaration order', - category: 'Stylistic Issues', recommended: false, }, messages: { diff --git a/packages/eslint-plugin/src/rules/method-signature-style.ts b/packages/eslint-plugin/src/rules/method-signature-style.ts index 4775a1fec718..3e24263ab502 100644 --- a/packages/eslint-plugin/src/rules/method-signature-style.ts +++ b/packages/eslint-plugin/src/rules/method-signature-style.ts @@ -13,7 +13,6 @@ export default util.createRule({ type: 'suggestion', docs: { description: 'Enforces using a particular method signature syntax.', - category: 'Best Practices', recommended: false, }, fixable: 'code', diff --git a/packages/eslint-plugin/src/rules/naming-convention.ts b/packages/eslint-plugin/src/rules/naming-convention.ts index 6b4b55309cf6..91456c7ccb23 100644 --- a/packages/eslint-plugin/src/rules/naming-convention.ts +++ b/packages/eslint-plugin/src/rules/naming-convention.ts @@ -55,7 +55,6 @@ export default util.createRule({ name: 'naming-convention', meta: { docs: { - category: 'Variables', description: 'Enforces naming conventions for everything across a codebase', recommended: false, diff --git a/packages/eslint-plugin/src/rules/no-array-constructor.ts b/packages/eslint-plugin/src/rules/no-array-constructor.ts index f9d09439cbb4..c0eac4a75af8 100644 --- a/packages/eslint-plugin/src/rules/no-array-constructor.ts +++ b/packages/eslint-plugin/src/rules/no-array-constructor.ts @@ -10,7 +10,6 @@ export default util.createRule({ type: 'suggestion', docs: { description: 'Disallow generic `Array` constructors', - category: 'Stylistic Issues', recommended: 'error', extendsBaseRule: true, }, diff --git a/packages/eslint-plugin/src/rules/no-base-to-string.ts b/packages/eslint-plugin/src/rules/no-base-to-string.ts index b1593c23d8b0..11962363c642 100644 --- a/packages/eslint-plugin/src/rules/no-base-to-string.ts +++ b/packages/eslint-plugin/src/rules/no-base-to-string.ts @@ -25,7 +25,6 @@ export default util.createRule({ docs: { description: 'Requires that `.toString()` is only called on objects which provide useful information when stringified', - category: 'Best Practices', recommended: false, requiresTypeChecking: true, }, diff --git a/packages/eslint-plugin/src/rules/no-confusing-non-null-assertion.ts b/packages/eslint-plugin/src/rules/no-confusing-non-null-assertion.ts index 281c2f9c4632..f578c5d3a1da 100644 --- a/packages/eslint-plugin/src/rules/no-confusing-non-null-assertion.ts +++ b/packages/eslint-plugin/src/rules/no-confusing-non-null-assertion.ts @@ -13,7 +13,6 @@ export default util.createRule({ docs: { description: 'Disallow non-null assertion in locations that may be confusing', - category: 'Stylistic Issues', recommended: false, }, fixable: 'code', diff --git a/packages/eslint-plugin/src/rules/no-confusing-void-expression.ts b/packages/eslint-plugin/src/rules/no-confusing-void-expression.ts index 1ddb60bf73dc..696c3d7af2dc 100644 --- a/packages/eslint-plugin/src/rules/no-confusing-void-expression.ts +++ b/packages/eslint-plugin/src/rules/no-confusing-void-expression.ts @@ -30,7 +30,6 @@ export default util.createRule({ docs: { description: 'Requires expressions of type void to appear in statement position', - category: 'Best Practices', recommended: false, requiresTypeChecking: true, }, diff --git a/packages/eslint-plugin/src/rules/no-dupe-class-members.ts b/packages/eslint-plugin/src/rules/no-dupe-class-members.ts index 0756e135fc96..dcc8b705038a 100644 --- a/packages/eslint-plugin/src/rules/no-dupe-class-members.ts +++ b/packages/eslint-plugin/src/rules/no-dupe-class-members.ts @@ -16,7 +16,6 @@ export default util.createRule({ type: 'problem', docs: { description: 'Disallow duplicate class members', - category: 'Possible Errors', recommended: false, extendsBaseRule: true, }, diff --git a/packages/eslint-plugin/src/rules/no-duplicate-imports.ts b/packages/eslint-plugin/src/rules/no-duplicate-imports.ts index 773402e18d4b..5445b50cec46 100644 --- a/packages/eslint-plugin/src/rules/no-duplicate-imports.ts +++ b/packages/eslint-plugin/src/rules/no-duplicate-imports.ts @@ -16,7 +16,6 @@ export default util.createRule({ type: 'problem', docs: { description: 'Disallow duplicate imports', - category: 'Best Practices', recommended: false, extendsBaseRule: true, }, diff --git a/packages/eslint-plugin/src/rules/no-dynamic-delete.ts b/packages/eslint-plugin/src/rules/no-dynamic-delete.ts index 71ce7f2d91e8..716590c66b66 100644 --- a/packages/eslint-plugin/src/rules/no-dynamic-delete.ts +++ b/packages/eslint-plugin/src/rules/no-dynamic-delete.ts @@ -10,7 +10,6 @@ export default util.createRule({ name: 'no-dynamic-delete', meta: { docs: { - category: 'Best Practices', description: 'Disallow the delete operator with computed key expressions', recommended: false, }, diff --git a/packages/eslint-plugin/src/rules/no-empty-function.ts b/packages/eslint-plugin/src/rules/no-empty-function.ts index d34618e0354a..06c04cb4ecad 100644 --- a/packages/eslint-plugin/src/rules/no-empty-function.ts +++ b/packages/eslint-plugin/src/rules/no-empty-function.ts @@ -45,7 +45,6 @@ export default util.createRule({ type: 'suggestion', docs: { description: 'Disallow empty functions', - category: 'Best Practices', recommended: 'error', extendsBaseRule: true, }, diff --git a/packages/eslint-plugin/src/rules/no-empty-interface.ts b/packages/eslint-plugin/src/rules/no-empty-interface.ts index d9c8c2477b8a..ee472e703903 100644 --- a/packages/eslint-plugin/src/rules/no-empty-interface.ts +++ b/packages/eslint-plugin/src/rules/no-empty-interface.ts @@ -14,7 +14,6 @@ export default util.createRule({ type: 'suggestion', docs: { description: 'Disallow the declaration of empty interfaces', - category: 'Best Practices', recommended: 'error', suggestion: true, }, diff --git a/packages/eslint-plugin/src/rules/no-explicit-any.ts b/packages/eslint-plugin/src/rules/no-explicit-any.ts index 71f052923276..a41d443e9243 100644 --- a/packages/eslint-plugin/src/rules/no-explicit-any.ts +++ b/packages/eslint-plugin/src/rules/no-explicit-any.ts @@ -19,7 +19,6 @@ export default util.createRule({ type: 'suggestion', docs: { description: 'Disallow usage of the `any` type', - category: 'Best Practices', recommended: 'warn', suggestion: true, }, diff --git a/packages/eslint-plugin/src/rules/no-extra-non-null-assertion.ts b/packages/eslint-plugin/src/rules/no-extra-non-null-assertion.ts index f507f37218f0..1ea8970da2fe 100644 --- a/packages/eslint-plugin/src/rules/no-extra-non-null-assertion.ts +++ b/packages/eslint-plugin/src/rules/no-extra-non-null-assertion.ts @@ -7,7 +7,6 @@ export default util.createRule({ type: 'problem', docs: { description: 'Disallow extra non-null assertion', - category: 'Stylistic Issues', recommended: 'error', }, fixable: 'code', diff --git a/packages/eslint-plugin/src/rules/no-extra-parens.ts b/packages/eslint-plugin/src/rules/no-extra-parens.ts index 0eeeedf2c2fa..743c22596c18 100644 --- a/packages/eslint-plugin/src/rules/no-extra-parens.ts +++ b/packages/eslint-plugin/src/rules/no-extra-parens.ts @@ -20,7 +20,6 @@ export default util.createRule({ type: 'layout', docs: { description: 'Disallow unnecessary parentheses', - category: 'Possible Errors', recommended: false, extendsBaseRule: true, }, diff --git a/packages/eslint-plugin/src/rules/no-extra-semi.ts b/packages/eslint-plugin/src/rules/no-extra-semi.ts index d8db4ba7904b..5ed7372b08cc 100644 --- a/packages/eslint-plugin/src/rules/no-extra-semi.ts +++ b/packages/eslint-plugin/src/rules/no-extra-semi.ts @@ -12,7 +12,6 @@ export default util.createRule({ type: 'suggestion', docs: { description: 'Disallow unnecessary semicolons', - category: 'Possible Errors', recommended: 'error', extendsBaseRule: true, }, diff --git a/packages/eslint-plugin/src/rules/no-extraneous-class.ts b/packages/eslint-plugin/src/rules/no-extraneous-class.ts index e57ee5546a39..2686ab0f478d 100644 --- a/packages/eslint-plugin/src/rules/no-extraneous-class.ts +++ b/packages/eslint-plugin/src/rules/no-extraneous-class.ts @@ -20,7 +20,6 @@ export default util.createRule({ type: 'suggestion', docs: { description: 'Forbids the use of classes as namespaces', - category: 'Best Practices', recommended: false, }, schema: [ diff --git a/packages/eslint-plugin/src/rules/no-floating-promises.ts b/packages/eslint-plugin/src/rules/no-floating-promises.ts index ae196cf52889..b1a88336e198 100644 --- a/packages/eslint-plugin/src/rules/no-floating-promises.ts +++ b/packages/eslint-plugin/src/rules/no-floating-promises.ts @@ -22,7 +22,6 @@ export default util.createRule({ meta: { docs: { description: 'Requires Promise-like values to be handled appropriately', - category: 'Best Practices', recommended: 'error', suggestion: true, requiresTypeChecking: true, diff --git a/packages/eslint-plugin/src/rules/no-for-in-array.ts b/packages/eslint-plugin/src/rules/no-for-in-array.ts index f89d2ffd08d7..c382a11021c1 100644 --- a/packages/eslint-plugin/src/rules/no-for-in-array.ts +++ b/packages/eslint-plugin/src/rules/no-for-in-array.ts @@ -6,7 +6,6 @@ export default util.createRule({ meta: { docs: { description: 'Disallow iterating over an array with a for-in loop', - category: 'Best Practices', recommended: 'error', requiresTypeChecking: true, }, diff --git a/packages/eslint-plugin/src/rules/no-implicit-any-catch.ts b/packages/eslint-plugin/src/rules/no-implicit-any-catch.ts index 85cdd7fd8fc9..f933336866b7 100644 --- a/packages/eslint-plugin/src/rules/no-implicit-any-catch.ts +++ b/packages/eslint-plugin/src/rules/no-implicit-any-catch.ts @@ -20,7 +20,6 @@ export default util.createRule({ type: 'suggestion', docs: { description: 'Disallow usage of the implicit `any` type in catch clauses', - category: 'Best Practices', recommended: false, suggestion: true, }, diff --git a/packages/eslint-plugin/src/rules/no-implied-eval.ts b/packages/eslint-plugin/src/rules/no-implied-eval.ts index 34b1c70b16d0..91bf0d0d3199 100644 --- a/packages/eslint-plugin/src/rules/no-implied-eval.ts +++ b/packages/eslint-plugin/src/rules/no-implied-eval.ts @@ -20,7 +20,6 @@ export default util.createRule({ meta: { docs: { description: 'Disallow the use of `eval()`-like methods', - category: 'Best Practices', recommended: 'error', extendsBaseRule: true, requiresTypeChecking: true, diff --git a/packages/eslint-plugin/src/rules/no-inferrable-types.ts b/packages/eslint-plugin/src/rules/no-inferrable-types.ts index 4edcf69c9758..23d8616e934e 100644 --- a/packages/eslint-plugin/src/rules/no-inferrable-types.ts +++ b/packages/eslint-plugin/src/rules/no-inferrable-types.ts @@ -20,7 +20,6 @@ export default util.createRule({ docs: { description: 'Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean', - category: 'Best Practices', recommended: 'error', }, fixable: 'code', diff --git a/packages/eslint-plugin/src/rules/no-invalid-this.ts b/packages/eslint-plugin/src/rules/no-invalid-this.ts index eb21da3ff8bd..9b8a4ac8d8af 100644 --- a/packages/eslint-plugin/src/rules/no-invalid-this.ts +++ b/packages/eslint-plugin/src/rules/no-invalid-this.ts @@ -21,7 +21,6 @@ export default createRule({ docs: { description: 'Disallow `this` keywords outside of classes or class-like objects', - category: 'Best Practices', recommended: false, extendsBaseRule: true, }, diff --git a/packages/eslint-plugin/src/rules/no-invalid-void-type.ts b/packages/eslint-plugin/src/rules/no-invalid-void-type.ts index 62c1aa679cf1..5c7829cde6cf 100644 --- a/packages/eslint-plugin/src/rules/no-invalid-void-type.ts +++ b/packages/eslint-plugin/src/rules/no-invalid-void-type.ts @@ -23,7 +23,6 @@ export default util.createRule<[Options], MessageIds>({ docs: { description: 'Disallows usage of `void` type outside of generic or return types', - category: 'Best Practices', recommended: false, }, messages: { diff --git a/packages/eslint-plugin/src/rules/no-loop-func.ts b/packages/eslint-plugin/src/rules/no-loop-func.ts index b3e57903dd16..4496dea91fc8 100644 --- a/packages/eslint-plugin/src/rules/no-loop-func.ts +++ b/packages/eslint-plugin/src/rules/no-loop-func.ts @@ -18,7 +18,6 @@ export default util.createRule({ docs: { description: 'Disallow function declarations that contain unsafe references inside loop statements', - category: 'Best Practices', recommended: false, extendsBaseRule: true, }, diff --git a/packages/eslint-plugin/src/rules/no-loss-of-precision.ts b/packages/eslint-plugin/src/rules/no-loss-of-precision.ts index 3b53661a0266..955032474755 100644 --- a/packages/eslint-plugin/src/rules/no-loss-of-precision.ts +++ b/packages/eslint-plugin/src/rules/no-loss-of-precision.ts @@ -15,7 +15,6 @@ export default util.createRule({ type: 'problem', docs: { description: 'Disallow literal numbers that lose precision', - category: 'Possible Errors', recommended: false, extendsBaseRule: true, }, diff --git a/packages/eslint-plugin/src/rules/no-magic-numbers.ts b/packages/eslint-plugin/src/rules/no-magic-numbers.ts index 8171815bb56b..a434a06dcf9a 100644 --- a/packages/eslint-plugin/src/rules/no-magic-numbers.ts +++ b/packages/eslint-plugin/src/rules/no-magic-numbers.ts @@ -20,7 +20,6 @@ export default util.createRule({ type: 'suggestion', docs: { description: 'Disallow magic numbers', - category: 'Best Practices', recommended: false, extendsBaseRule: true, }, diff --git a/packages/eslint-plugin/src/rules/no-misused-new.ts b/packages/eslint-plugin/src/rules/no-misused-new.ts index d0331e19fa35..ae79c28a6f2e 100644 --- a/packages/eslint-plugin/src/rules/no-misused-new.ts +++ b/packages/eslint-plugin/src/rules/no-misused-new.ts @@ -10,7 +10,6 @@ export default util.createRule({ type: 'problem', docs: { description: 'Enforce valid definition of `new` and `constructor`', - category: 'Best Practices', recommended: 'error', }, schema: [], diff --git a/packages/eslint-plugin/src/rules/no-misused-promises.ts b/packages/eslint-plugin/src/rules/no-misused-promises.ts index 58d4ac9f9c6c..353b7d4a8038 100644 --- a/packages/eslint-plugin/src/rules/no-misused-promises.ts +++ b/packages/eslint-plugin/src/rules/no-misused-promises.ts @@ -20,7 +20,6 @@ export default util.createRule({ meta: { docs: { description: 'Avoid using promises in places not designed to handle them', - category: 'Best Practices', recommended: 'error', requiresTypeChecking: true, }, diff --git a/packages/eslint-plugin/src/rules/no-namespace.ts b/packages/eslint-plugin/src/rules/no-namespace.ts index f8cc05b10471..f7fb0ea1e328 100644 --- a/packages/eslint-plugin/src/rules/no-namespace.ts +++ b/packages/eslint-plugin/src/rules/no-namespace.ts @@ -19,7 +19,6 @@ export default util.createRule({ docs: { description: 'Disallow the use of custom TypeScript modules and namespaces', - category: 'Best Practices', recommended: 'error', }, messages: { diff --git a/packages/eslint-plugin/src/rules/no-non-null-asserted-optional-chain.ts b/packages/eslint-plugin/src/rules/no-non-null-asserted-optional-chain.ts index 1d9c8f4aabc2..9fdba130b97e 100644 --- a/packages/eslint-plugin/src/rules/no-non-null-asserted-optional-chain.ts +++ b/packages/eslint-plugin/src/rules/no-non-null-asserted-optional-chain.ts @@ -22,7 +22,6 @@ export default util.createRule({ docs: { description: 'Disallows using a non-null assertion after an optional chain expression', - category: 'Possible Errors', recommended: 'error', suggestion: true, }, diff --git a/packages/eslint-plugin/src/rules/no-non-null-assertion.ts b/packages/eslint-plugin/src/rules/no-non-null-assertion.ts index ceba7fefd15a..cd9f0dbb2552 100644 --- a/packages/eslint-plugin/src/rules/no-non-null-assertion.ts +++ b/packages/eslint-plugin/src/rules/no-non-null-assertion.ts @@ -13,7 +13,6 @@ export default util.createRule<[], MessageIds>({ docs: { description: 'Disallows non-null assertions using the `!` postfix operator', - category: 'Stylistic Issues', recommended: 'warn', suggestion: true, }, diff --git a/packages/eslint-plugin/src/rules/no-parameter-properties.ts b/packages/eslint-plugin/src/rules/no-parameter-properties.ts index 9b6bb31e6541..613b839bbdfa 100644 --- a/packages/eslint-plugin/src/rules/no-parameter-properties.ts +++ b/packages/eslint-plugin/src/rules/no-parameter-properties.ts @@ -26,7 +26,6 @@ export default util.createRule({ docs: { description: 'Disallow the use of parameter properties in class constructors', - category: 'Stylistic Issues', // too opinionated to be recommended recommended: false, }, diff --git a/packages/eslint-plugin/src/rules/no-redeclare.ts b/packages/eslint-plugin/src/rules/no-redeclare.ts index ae4b2e9a3f5a..914dd074d33f 100644 --- a/packages/eslint-plugin/src/rules/no-redeclare.ts +++ b/packages/eslint-plugin/src/rules/no-redeclare.ts @@ -19,7 +19,6 @@ export default util.createRule({ type: 'suggestion', docs: { description: 'Disallow variable redeclaration', - category: 'Best Practices', recommended: false, extendsBaseRule: true, }, diff --git a/packages/eslint-plugin/src/rules/no-require-imports.ts b/packages/eslint-plugin/src/rules/no-require-imports.ts index 9aa4b685dd22..49bd5f237b06 100644 --- a/packages/eslint-plugin/src/rules/no-require-imports.ts +++ b/packages/eslint-plugin/src/rules/no-require-imports.ts @@ -7,7 +7,6 @@ export default util.createRule({ type: 'problem', docs: { description: 'Disallows invocation of `require()`', - category: 'Best Practices', recommended: false, }, schema: [], diff --git a/packages/eslint-plugin/src/rules/no-shadow.ts b/packages/eslint-plugin/src/rules/no-shadow.ts index a49afd502cfe..27c689309310 100644 --- a/packages/eslint-plugin/src/rules/no-shadow.ts +++ b/packages/eslint-plugin/src/rules/no-shadow.ts @@ -30,7 +30,6 @@ export default util.createRule({ docs: { description: 'Disallow variable declarations from shadowing variables declared in the outer scope', - category: 'Variables', recommended: false, extendsBaseRule: true, }, diff --git a/packages/eslint-plugin/src/rules/no-this-alias.ts b/packages/eslint-plugin/src/rules/no-this-alias.ts index 8865fad2c3fb..82ab9b22b0fa 100644 --- a/packages/eslint-plugin/src/rules/no-this-alias.ts +++ b/packages/eslint-plugin/src/rules/no-this-alias.ts @@ -18,7 +18,6 @@ export default util.createRule({ type: 'suggestion', docs: { description: 'Disallow aliasing `this`', - category: 'Best Practices', recommended: 'error', }, schema: [ diff --git a/packages/eslint-plugin/src/rules/no-throw-literal.ts b/packages/eslint-plugin/src/rules/no-throw-literal.ts index 92bf3b02a135..178f1f39f9ca 100644 --- a/packages/eslint-plugin/src/rules/no-throw-literal.ts +++ b/packages/eslint-plugin/src/rules/no-throw-literal.ts @@ -11,7 +11,6 @@ export default util.createRule({ type: 'problem', docs: { description: 'Disallow throwing literals as exceptions', - category: 'Best Practices', recommended: false, extendsBaseRule: true, requiresTypeChecking: true, diff --git a/packages/eslint-plugin/src/rules/no-type-alias.ts b/packages/eslint-plugin/src/rules/no-type-alias.ts index 4e16216ea720..347e36f0a425 100644 --- a/packages/eslint-plugin/src/rules/no-type-alias.ts +++ b/packages/eslint-plugin/src/rules/no-type-alias.ts @@ -47,7 +47,6 @@ export default util.createRule({ type: 'suggestion', docs: { description: 'Disallow the use of type aliases', - category: 'Stylistic Issues', // too opinionated to be recommended recommended: false, }, diff --git a/packages/eslint-plugin/src/rules/no-unnecessary-boolean-literal-compare.ts b/packages/eslint-plugin/src/rules/no-unnecessary-boolean-literal-compare.ts index 55719d857dab..8583e657f915 100644 --- a/packages/eslint-plugin/src/rules/no-unnecessary-boolean-literal-compare.ts +++ b/packages/eslint-plugin/src/rules/no-unnecessary-boolean-literal-compare.ts @@ -38,7 +38,6 @@ export default util.createRule({ docs: { description: 'Flags unnecessary equality comparisons against boolean literals', - category: 'Stylistic Issues', recommended: false, requiresTypeChecking: true, }, diff --git a/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts b/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts index caca4f8bedb9..4e73c0623ad1 100644 --- a/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts +++ b/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts @@ -90,7 +90,6 @@ export default createRule({ docs: { description: 'Prevents conditionals where the type is always truthy or always falsy', - category: 'Best Practices', recommended: false, requiresTypeChecking: true, }, diff --git a/packages/eslint-plugin/src/rules/no-unnecessary-qualifier.ts b/packages/eslint-plugin/src/rules/no-unnecessary-qualifier.ts index 014b2c220e41..1f4652085bda 100644 --- a/packages/eslint-plugin/src/rules/no-unnecessary-qualifier.ts +++ b/packages/eslint-plugin/src/rules/no-unnecessary-qualifier.ts @@ -10,7 +10,6 @@ export default util.createRule({ name: 'no-unnecessary-qualifier', meta: { docs: { - category: 'Best Practices', description: 'Warns when a namespace qualifier is unnecessary', recommended: false, requiresTypeChecking: true, diff --git a/packages/eslint-plugin/src/rules/no-unnecessary-type-arguments.ts b/packages/eslint-plugin/src/rules/no-unnecessary-type-arguments.ts index 2df933084dcf..9f7d718c2d92 100644 --- a/packages/eslint-plugin/src/rules/no-unnecessary-type-arguments.ts +++ b/packages/eslint-plugin/src/rules/no-unnecessary-type-arguments.ts @@ -22,7 +22,6 @@ export default util.createRule<[], MessageIds>({ docs: { description: 'Enforces that type arguments will not be used if not required', - category: 'Best Practices', recommended: false, requiresTypeChecking: true, }, diff --git a/packages/eslint-plugin/src/rules/no-unnecessary-type-assertion.ts b/packages/eslint-plugin/src/rules/no-unnecessary-type-assertion.ts index d16f494fc4af..cd5bce1845d5 100644 --- a/packages/eslint-plugin/src/rules/no-unnecessary-type-assertion.ts +++ b/packages/eslint-plugin/src/rules/no-unnecessary-type-assertion.ts @@ -25,7 +25,6 @@ export default util.createRule({ docs: { description: 'Warns if a type assertion does not change the type of an expression', - category: 'Best Practices', recommended: 'error', requiresTypeChecking: true, }, diff --git a/packages/eslint-plugin/src/rules/no-unnecessary-type-constraint.ts b/packages/eslint-plugin/src/rules/no-unnecessary-type-constraint.ts index 6d5036c2d75a..535cae96023b 100644 --- a/packages/eslint-plugin/src/rules/no-unnecessary-type-constraint.ts +++ b/packages/eslint-plugin/src/rules/no-unnecessary-type-constraint.ts @@ -32,7 +32,6 @@ export default util.createRule({ name: 'no-unnecessary-type-constraint', meta: { docs: { - category: 'Best Practices', description: 'Disallows unnecessary constraints on generic types', recommended: false, suggestion: true, diff --git a/packages/eslint-plugin/src/rules/no-unsafe-argument.ts b/packages/eslint-plugin/src/rules/no-unsafe-argument.ts index 053485f9228f..46ed36a0dc3d 100644 --- a/packages/eslint-plugin/src/rules/no-unsafe-argument.ts +++ b/packages/eslint-plugin/src/rules/no-unsafe-argument.ts @@ -138,7 +138,6 @@ export default util.createRule<[], MessageIds>({ type: 'problem', docs: { description: 'Disallows calling a function with an any type value', - category: 'Possible Errors', // TODO - enable this with next breaking recommended: false, requiresTypeChecking: true, diff --git a/packages/eslint-plugin/src/rules/no-unsafe-assignment.ts b/packages/eslint-plugin/src/rules/no-unsafe-assignment.ts index ae900b14f0cd..b14f43fe27f9 100644 --- a/packages/eslint-plugin/src/rules/no-unsafe-assignment.ts +++ b/packages/eslint-plugin/src/rules/no-unsafe-assignment.ts @@ -22,7 +22,6 @@ export default util.createRule({ type: 'problem', docs: { description: 'Disallows assigning any to variables and properties', - category: 'Possible Errors', recommended: 'error', requiresTypeChecking: true, }, diff --git a/packages/eslint-plugin/src/rules/no-unsafe-call.ts b/packages/eslint-plugin/src/rules/no-unsafe-call.ts index b08214d36c27..781908f9497b 100644 --- a/packages/eslint-plugin/src/rules/no-unsafe-call.ts +++ b/packages/eslint-plugin/src/rules/no-unsafe-call.ts @@ -15,7 +15,6 @@ export default util.createRule<[], MessageIds>({ type: 'problem', docs: { description: 'Disallows calling an any type value', - category: 'Possible Errors', recommended: 'error', requiresTypeChecking: true, }, diff --git a/packages/eslint-plugin/src/rules/no-unsafe-member-access.ts b/packages/eslint-plugin/src/rules/no-unsafe-member-access.ts index 121e826053e2..6e9555a5a3e4 100644 --- a/packages/eslint-plugin/src/rules/no-unsafe-member-access.ts +++ b/packages/eslint-plugin/src/rules/no-unsafe-member-access.ts @@ -17,7 +17,6 @@ export default util.createRule({ type: 'problem', docs: { description: 'Disallows member access on any typed variables', - category: 'Possible Errors', recommended: 'error', requiresTypeChecking: true, }, diff --git a/packages/eslint-plugin/src/rules/no-unsafe-return.ts b/packages/eslint-plugin/src/rules/no-unsafe-return.ts index d460dd04c9bf..e226d526bca0 100644 --- a/packages/eslint-plugin/src/rules/no-unsafe-return.ts +++ b/packages/eslint-plugin/src/rules/no-unsafe-return.ts @@ -12,7 +12,6 @@ export default util.createRule({ type: 'problem', docs: { description: 'Disallows returning any from a function', - category: 'Possible Errors', recommended: 'error', requiresTypeChecking: true, }, diff --git a/packages/eslint-plugin/src/rules/no-unused-expressions.ts b/packages/eslint-plugin/src/rules/no-unused-expressions.ts index 527ba14e03ce..4bef50b44a8a 100644 --- a/packages/eslint-plugin/src/rules/no-unused-expressions.ts +++ b/packages/eslint-plugin/src/rules/no-unused-expressions.ts @@ -16,7 +16,6 @@ export default util.createRule({ type: 'suggestion', docs: { description: 'Disallow unused expressions', - category: 'Best Practices', recommended: false, extendsBaseRule: true, }, diff --git a/packages/eslint-plugin/src/rules/no-unused-vars.ts b/packages/eslint-plugin/src/rules/no-unused-vars.ts index 2e6633afc57f..bf9548ec888d 100644 --- a/packages/eslint-plugin/src/rules/no-unused-vars.ts +++ b/packages/eslint-plugin/src/rules/no-unused-vars.ts @@ -37,7 +37,6 @@ export default util.createRule({ type: 'problem', docs: { description: 'Disallow unused variables', - category: 'Variables', recommended: 'warn', extendsBaseRule: true, }, diff --git a/packages/eslint-plugin/src/rules/no-use-before-define.ts b/packages/eslint-plugin/src/rules/no-use-before-define.ts index ef39ec9a5b7c..83cf552fda52 100644 --- a/packages/eslint-plugin/src/rules/no-use-before-define.ts +++ b/packages/eslint-plugin/src/rules/no-use-before-define.ts @@ -232,7 +232,6 @@ export default util.createRule({ type: 'problem', docs: { description: 'Disallow the use of variables before they are defined', - category: 'Variables', recommended: false, extendsBaseRule: true, }, diff --git a/packages/eslint-plugin/src/rules/no-useless-constructor.ts b/packages/eslint-plugin/src/rules/no-useless-constructor.ts index d1134bd09db2..f656af264818 100644 --- a/packages/eslint-plugin/src/rules/no-useless-constructor.ts +++ b/packages/eslint-plugin/src/rules/no-useless-constructor.ts @@ -51,7 +51,6 @@ export default util.createRule({ type: 'problem', docs: { description: 'Disallow unnecessary constructors', - category: 'Best Practices', recommended: false, extendsBaseRule: true, }, diff --git a/packages/eslint-plugin/src/rules/no-var-requires.ts b/packages/eslint-plugin/src/rules/no-var-requires.ts index d7ed1d16f7fb..b599d4cb87a6 100644 --- a/packages/eslint-plugin/src/rules/no-var-requires.ts +++ b/packages/eslint-plugin/src/rules/no-var-requires.ts @@ -14,7 +14,6 @@ export default util.createRule({ docs: { description: 'Disallows the use of require statements except in import statements', - category: 'Best Practices', recommended: 'error', }, messages: { diff --git a/packages/eslint-plugin/src/rules/non-nullable-type-assertion-style.ts b/packages/eslint-plugin/src/rules/non-nullable-type-assertion-style.ts index 647fbcddd4c5..1577c3b94489 100644 --- a/packages/eslint-plugin/src/rules/non-nullable-type-assertion-style.ts +++ b/packages/eslint-plugin/src/rules/non-nullable-type-assertion-style.ts @@ -11,7 +11,6 @@ export default util.createRule({ name: 'non-nullable-type-assertion-style', meta: { docs: { - category: 'Best Practices', description: 'Prefers a non-null assertion over explicit type cast when possible', recommended: false, diff --git a/packages/eslint-plugin/src/rules/object-curly-spacing.ts b/packages/eslint-plugin/src/rules/object-curly-spacing.ts index 090bd8e1e952..5e93dff61a03 100644 --- a/packages/eslint-plugin/src/rules/object-curly-spacing.ts +++ b/packages/eslint-plugin/src/rules/object-curly-spacing.ts @@ -24,7 +24,6 @@ export default createRule({ ...baseRule.meta, docs: { description: 'Enforce consistent spacing inside braces', - category: 'Stylistic Issues', recommended: false, extendsBaseRule: true, }, diff --git a/packages/eslint-plugin/src/rules/prefer-as-const.ts b/packages/eslint-plugin/src/rules/prefer-as-const.ts index aeaa6fcdd7a3..93bcce50889d 100644 --- a/packages/eslint-plugin/src/rules/prefer-as-const.ts +++ b/packages/eslint-plugin/src/rules/prefer-as-const.ts @@ -11,7 +11,6 @@ export default util.createRule({ type: 'suggestion', docs: { description: 'Prefer usage of `as const` over literal type', - category: 'Best Practices', recommended: 'error', suggestion: true, }, diff --git a/packages/eslint-plugin/src/rules/prefer-enum-initializers.ts b/packages/eslint-plugin/src/rules/prefer-enum-initializers.ts index 9f9d641ec411..5ad6dccd7cce 100644 --- a/packages/eslint-plugin/src/rules/prefer-enum-initializers.ts +++ b/packages/eslint-plugin/src/rules/prefer-enum-initializers.ts @@ -9,7 +9,6 @@ export default util.createRule<[], MessageIds>({ type: 'suggestion', docs: { description: 'Prefer initializing each enums member value', - category: 'Best Practices', recommended: false, suggestion: true, }, diff --git a/packages/eslint-plugin/src/rules/prefer-for-of.ts b/packages/eslint-plugin/src/rules/prefer-for-of.ts index 361ad5ec2cf7..25043615f81e 100644 --- a/packages/eslint-plugin/src/rules/prefer-for-of.ts +++ b/packages/eslint-plugin/src/rules/prefer-for-of.ts @@ -12,7 +12,6 @@ export default util.createRule({ docs: { description: 'Prefer a ‘for-of’ loop over a standard ‘for’ loop if the index is only used to access the array being iterated', - category: 'Stylistic Issues', recommended: false, }, messages: { diff --git a/packages/eslint-plugin/src/rules/prefer-function-type.ts b/packages/eslint-plugin/src/rules/prefer-function-type.ts index 761e8bc98eb9..ceeafcd841c3 100644 --- a/packages/eslint-plugin/src/rules/prefer-function-type.ts +++ b/packages/eslint-plugin/src/rules/prefer-function-type.ts @@ -17,7 +17,6 @@ export default util.createRule({ docs: { description: 'Use function types instead of interfaces with call signatures', - category: 'Best Practices', recommended: false, }, fixable: 'code', diff --git a/packages/eslint-plugin/src/rules/prefer-includes.ts b/packages/eslint-plugin/src/rules/prefer-includes.ts index 13a6021c8069..f15a756abc4a 100644 --- a/packages/eslint-plugin/src/rules/prefer-includes.ts +++ b/packages/eslint-plugin/src/rules/prefer-includes.ts @@ -20,7 +20,6 @@ export default createRule({ type: 'suggestion', docs: { description: 'Enforce `includes` method over `indexOf` method', - category: 'Best Practices', recommended: false, requiresTypeChecking: true, }, diff --git a/packages/eslint-plugin/src/rules/prefer-literal-enum-member.ts b/packages/eslint-plugin/src/rules/prefer-literal-enum-member.ts index 77b6746a06b0..8f10eb9be369 100644 --- a/packages/eslint-plugin/src/rules/prefer-literal-enum-member.ts +++ b/packages/eslint-plugin/src/rules/prefer-literal-enum-member.ts @@ -8,7 +8,6 @@ export default createRule({ docs: { description: 'Require that all enum members be literal values to prevent unintended enum member name shadow issues', - category: 'Best Practices', recommended: false, requiresTypeChecking: false, }, diff --git a/packages/eslint-plugin/src/rules/prefer-namespace-keyword.ts b/packages/eslint-plugin/src/rules/prefer-namespace-keyword.ts index 9137fe912aa6..4af7c9812534 100644 --- a/packages/eslint-plugin/src/rules/prefer-namespace-keyword.ts +++ b/packages/eslint-plugin/src/rules/prefer-namespace-keyword.ts @@ -11,7 +11,6 @@ export default util.createRule({ docs: { description: 'Require the use of the `namespace` keyword instead of the `module` keyword to declare custom TypeScript modules', - category: 'Best Practices', recommended: 'error', }, fixable: 'code', diff --git a/packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts b/packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts index 4fe3d021f700..6975576edcaa 100644 --- a/packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts +++ b/packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts @@ -21,7 +21,6 @@ export default util.createRule({ docs: { description: 'Enforce the usage of the nullish coalescing operator instead of logical chaining', - category: 'Best Practices', recommended: false, suggestion: true, requiresTypeChecking: true, diff --git a/packages/eslint-plugin/src/rules/prefer-optional-chain.ts b/packages/eslint-plugin/src/rules/prefer-optional-chain.ts index b1eff5e4ae7e..84c2e15e3975 100644 --- a/packages/eslint-plugin/src/rules/prefer-optional-chain.ts +++ b/packages/eslint-plugin/src/rules/prefer-optional-chain.ts @@ -37,7 +37,6 @@ export default util.createRule({ docs: { description: 'Prefer using concise optional chain expressions instead of chained logical ands', - category: 'Best Practices', recommended: false, suggestion: true, }, diff --git a/packages/eslint-plugin/src/rules/prefer-readonly-parameter-types.ts b/packages/eslint-plugin/src/rules/prefer-readonly-parameter-types.ts index fdf48395eae5..478a15b66b76 100644 --- a/packages/eslint-plugin/src/rules/prefer-readonly-parameter-types.ts +++ b/packages/eslint-plugin/src/rules/prefer-readonly-parameter-types.ts @@ -19,7 +19,6 @@ export default util.createRule({ docs: { description: 'Requires that function parameters are typed as readonly to prevent accidental mutation of inputs', - category: 'Possible Errors', recommended: false, requiresTypeChecking: true, }, diff --git a/packages/eslint-plugin/src/rules/prefer-readonly.ts b/packages/eslint-plugin/src/rules/prefer-readonly.ts index 36c6c7ea81a6..7b0fbfee3af7 100644 --- a/packages/eslint-plugin/src/rules/prefer-readonly.ts +++ b/packages/eslint-plugin/src/rules/prefer-readonly.ts @@ -28,7 +28,6 @@ export default util.createRule({ docs: { description: "Requires that private members are marked as `readonly` if they're never modified outside of the constructor", - category: 'Best Practices', recommended: false, requiresTypeChecking: true, }, diff --git a/packages/eslint-plugin/src/rules/prefer-reduce-type-parameter.ts b/packages/eslint-plugin/src/rules/prefer-reduce-type-parameter.ts index 8656c8d2376d..a797bfdf48f3 100644 --- a/packages/eslint-plugin/src/rules/prefer-reduce-type-parameter.ts +++ b/packages/eslint-plugin/src/rules/prefer-reduce-type-parameter.ts @@ -30,7 +30,6 @@ export default util.createRule({ meta: { type: 'problem', docs: { - category: 'Best Practices', recommended: false, description: 'Prefer using type parameter when calling `Array#reduce` instead of casting', diff --git a/packages/eslint-plugin/src/rules/prefer-regexp-exec.ts b/packages/eslint-plugin/src/rules/prefer-regexp-exec.ts index bbb7d9aac746..93ac0cda6409 100644 --- a/packages/eslint-plugin/src/rules/prefer-regexp-exec.ts +++ b/packages/eslint-plugin/src/rules/prefer-regexp-exec.ts @@ -29,7 +29,6 @@ export default createRule({ docs: { description: 'Enforce that `RegExp#exec` is used instead of `String#match` if no global flag is provided', - category: 'Best Practices', recommended: 'error', requiresTypeChecking: true, }, diff --git a/packages/eslint-plugin/src/rules/prefer-return-this-type.ts b/packages/eslint-plugin/src/rules/prefer-return-this-type.ts index 9fcfcb042006..b6be29efc043 100644 --- a/packages/eslint-plugin/src/rules/prefer-return-this-type.ts +++ b/packages/eslint-plugin/src/rules/prefer-return-this-type.ts @@ -22,7 +22,6 @@ export default createRule({ docs: { description: 'Enforce that `this` is used when only `this` type is returned', - category: 'Best Practices', recommended: false, requiresTypeChecking: true, }, diff --git a/packages/eslint-plugin/src/rules/prefer-string-starts-ends-with.ts b/packages/eslint-plugin/src/rules/prefer-string-starts-ends-with.ts index f4697b7c01de..c90bb0a1a746 100644 --- a/packages/eslint-plugin/src/rules/prefer-string-starts-ends-with.ts +++ b/packages/eslint-plugin/src/rules/prefer-string-starts-ends-with.ts @@ -27,7 +27,6 @@ export default createRule({ docs: { description: 'Enforce the use of `String#startsWith` and `String#endsWith` instead of other equivalent methods of checking substrings', - category: 'Best Practices', recommended: false, requiresTypeChecking: true, }, diff --git a/packages/eslint-plugin/src/rules/prefer-ts-expect-error.ts b/packages/eslint-plugin/src/rules/prefer-ts-expect-error.ts index d696fc045735..15c070298cb1 100644 --- a/packages/eslint-plugin/src/rules/prefer-ts-expect-error.ts +++ b/packages/eslint-plugin/src/rules/prefer-ts-expect-error.ts @@ -16,7 +16,6 @@ export default util.createRule<[], MessageIds>({ type: 'problem', docs: { description: 'Recommends using `@ts-expect-error` over `@ts-ignore`', - category: 'Best Practices', recommended: false, }, fixable: 'code', diff --git a/packages/eslint-plugin/src/rules/promise-function-async.ts b/packages/eslint-plugin/src/rules/promise-function-async.ts index 68b1d42567c5..6b3f29b8d97e 100644 --- a/packages/eslint-plugin/src/rules/promise-function-async.ts +++ b/packages/eslint-plugin/src/rules/promise-function-async.ts @@ -26,7 +26,6 @@ export default util.createRule({ docs: { description: 'Requires any function or method that returns a Promise to be marked async', - category: 'Best Practices', recommended: false, requiresTypeChecking: true, }, diff --git a/packages/eslint-plugin/src/rules/quotes.ts b/packages/eslint-plugin/src/rules/quotes.ts index 699df89da156..e03556af63dd 100644 --- a/packages/eslint-plugin/src/rules/quotes.ts +++ b/packages/eslint-plugin/src/rules/quotes.ts @@ -17,7 +17,6 @@ export default util.createRule({ docs: { description: 'Enforce the consistent use of either backticks, double, or single quotes', - category: 'Stylistic Issues', recommended: false, extendsBaseRule: true, }, diff --git a/packages/eslint-plugin/src/rules/require-array-sort-compare.ts b/packages/eslint-plugin/src/rules/require-array-sort-compare.ts index 6e0c49f31a8b..25476314d73f 100644 --- a/packages/eslint-plugin/src/rules/require-array-sort-compare.ts +++ b/packages/eslint-plugin/src/rules/require-array-sort-compare.ts @@ -21,7 +21,6 @@ export default util.createRule({ docs: { description: 'Requires `Array#sort` calls to always provide a `compareFunction`', - category: 'Best Practices', recommended: false, requiresTypeChecking: true, }, diff --git a/packages/eslint-plugin/src/rules/require-await.ts b/packages/eslint-plugin/src/rules/require-await.ts index 99c455cd0f6a..a1e92e8f91d8 100644 --- a/packages/eslint-plugin/src/rules/require-await.ts +++ b/packages/eslint-plugin/src/rules/require-await.ts @@ -25,7 +25,6 @@ export default util.createRule({ type: 'suggestion', docs: { description: 'Disallow async functions which have no `await` expression', - category: 'Best Practices', recommended: 'error', requiresTypeChecking: true, extendsBaseRule: true, diff --git a/packages/eslint-plugin/src/rules/restrict-plus-operands.ts b/packages/eslint-plugin/src/rules/restrict-plus-operands.ts index 0f3b07e9fb27..659509f81ef1 100644 --- a/packages/eslint-plugin/src/rules/restrict-plus-operands.ts +++ b/packages/eslint-plugin/src/rules/restrict-plus-operands.ts @@ -16,7 +16,6 @@ export default util.createRule({ docs: { description: 'When adding two variables, operands must both be of type number or of type string', - category: 'Best Practices', recommended: 'error', requiresTypeChecking: true, }, diff --git a/packages/eslint-plugin/src/rules/restrict-template-expressions.ts b/packages/eslint-plugin/src/rules/restrict-template-expressions.ts index b20bd5c62bc2..f39bc88cfe59 100644 --- a/packages/eslint-plugin/src/rules/restrict-template-expressions.ts +++ b/packages/eslint-plugin/src/rules/restrict-template-expressions.ts @@ -23,7 +23,6 @@ export default util.createRule({ type: 'problem', docs: { description: 'Enforce template literal expressions to be of string type', - category: 'Best Practices', recommended: 'error', requiresTypeChecking: true, }, diff --git a/packages/eslint-plugin/src/rules/return-await.ts b/packages/eslint-plugin/src/rules/return-await.ts index 1375d3028e1e..93b863757a0b 100644 --- a/packages/eslint-plugin/src/rules/return-await.ts +++ b/packages/eslint-plugin/src/rules/return-await.ts @@ -22,7 +22,6 @@ export default util.createRule({ meta: { docs: { description: 'Enforces consistent returning of awaited values', - category: 'Best Practices', recommended: false, requiresTypeChecking: true, extendsBaseRule: 'no-return-await', diff --git a/packages/eslint-plugin/src/rules/semi.ts b/packages/eslint-plugin/src/rules/semi.ts index c8829ab83e34..40e631482aaf 100644 --- a/packages/eslint-plugin/src/rules/semi.ts +++ b/packages/eslint-plugin/src/rules/semi.ts @@ -17,7 +17,6 @@ export default util.createRule({ type: 'layout', docs: { description: 'Require or disallow semicolons instead of ASI', - category: 'Stylistic Issues', // too opinionated to be recommended recommended: false, extendsBaseRule: true, diff --git a/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts b/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts index e7f042162b8c..3d14b55e9d74 100644 --- a/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts +++ b/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts @@ -108,7 +108,6 @@ export default util.createRule({ docs: { description: 'Enforces that members of a type union/intersection are sorted alphabetically', - category: 'Stylistic Issues', recommended: false, }, fixable: 'code', diff --git a/packages/eslint-plugin/src/rules/space-before-function-paren.ts b/packages/eslint-plugin/src/rules/space-before-function-paren.ts index e2ccfa5182db..b13af67163c5 100644 --- a/packages/eslint-plugin/src/rules/space-before-function-paren.ts +++ b/packages/eslint-plugin/src/rules/space-before-function-paren.ts @@ -23,7 +23,6 @@ export default util.createRule({ type: 'layout', docs: { description: 'Enforces consistent spacing before function parenthesis', - category: 'Stylistic Issues', recommended: false, extendsBaseRule: true, }, diff --git a/packages/eslint-plugin/src/rules/space-infix-ops.ts b/packages/eslint-plugin/src/rules/space-infix-ops.ts index eb92bd2f112c..80294cd26718 100644 --- a/packages/eslint-plugin/src/rules/space-infix-ops.ts +++ b/packages/eslint-plugin/src/rules/space-infix-ops.ts @@ -19,7 +19,6 @@ export default util.createRule({ docs: { description: 'This rule is aimed at ensuring there are spaces around infix operators.', - category: 'Stylistic Issues', recommended: false, extendsBaseRule: true, }, diff --git a/packages/eslint-plugin/src/rules/strict-boolean-expressions.ts b/packages/eslint-plugin/src/rules/strict-boolean-expressions.ts index 1aca481e7439..10b48b5e9b37 100644 --- a/packages/eslint-plugin/src/rules/strict-boolean-expressions.ts +++ b/packages/eslint-plugin/src/rules/strict-boolean-expressions.ts @@ -52,7 +52,6 @@ export default util.createRule({ hasSuggestions: true, docs: { description: 'Restricts the types allowed in boolean expressions', - category: 'Best Practices', recommended: false, requiresTypeChecking: true, }, diff --git a/packages/eslint-plugin/src/rules/switch-exhaustiveness-check.ts b/packages/eslint-plugin/src/rules/switch-exhaustiveness-check.ts index 65a70a86cc40..08f21e3364ca 100644 --- a/packages/eslint-plugin/src/rules/switch-exhaustiveness-check.ts +++ b/packages/eslint-plugin/src/rules/switch-exhaustiveness-check.ts @@ -16,7 +16,6 @@ export default createRule({ type: 'suggestion', docs: { description: 'Exhaustiveness checking in switch with union type', - category: 'Best Practices', recommended: false, suggestion: true, requiresTypeChecking: true, diff --git a/packages/eslint-plugin/src/rules/triple-slash-reference.ts b/packages/eslint-plugin/src/rules/triple-slash-reference.ts index 525febe2be3c..ba8bce5ae8a7 100644 --- a/packages/eslint-plugin/src/rules/triple-slash-reference.ts +++ b/packages/eslint-plugin/src/rules/triple-slash-reference.ts @@ -21,7 +21,6 @@ export default util.createRule({ docs: { description: 'Sets preference level for triple slash directives versus ES6-style import declarations', - category: 'Best Practices', recommended: 'error', }, messages: { diff --git a/packages/eslint-plugin/src/rules/type-annotation-spacing.ts b/packages/eslint-plugin/src/rules/type-annotation-spacing.ts index 0cf3e34b8b88..d02b8777d5ff 100644 --- a/packages/eslint-plugin/src/rules/type-annotation-spacing.ts +++ b/packages/eslint-plugin/src/rules/type-annotation-spacing.ts @@ -114,7 +114,6 @@ export default util.createRule({ type: 'layout', docs: { description: 'Require consistent spacing around type annotations', - category: 'Stylistic Issues', recommended: false, }, fixable: 'whitespace', diff --git a/packages/eslint-plugin/src/rules/typedef.ts b/packages/eslint-plugin/src/rules/typedef.ts index 766401040224..35655a9a803d 100644 --- a/packages/eslint-plugin/src/rules/typedef.ts +++ b/packages/eslint-plugin/src/rules/typedef.ts @@ -24,7 +24,6 @@ export default util.createRule<[Options], MessageIds>({ meta: { docs: { description: 'Requires type annotations to exist', - category: 'Stylistic Issues', recommended: false, }, messages: { diff --git a/packages/eslint-plugin/src/rules/unbound-method.ts b/packages/eslint-plugin/src/rules/unbound-method.ts index ecf9e6528190..15ddf8b89109 100644 --- a/packages/eslint-plugin/src/rules/unbound-method.ts +++ b/packages/eslint-plugin/src/rules/unbound-method.ts @@ -128,7 +128,6 @@ export default util.createRule({ name: 'unbound-method', meta: { docs: { - category: 'Best Practices', description: 'Enforces unbound methods are called with their expected scope', recommended: 'error', diff --git a/packages/eslint-plugin/src/rules/unified-signatures.ts b/packages/eslint-plugin/src/rules/unified-signatures.ts index dced203f1756..7481dcd70312 100644 --- a/packages/eslint-plugin/src/rules/unified-signatures.ts +++ b/packages/eslint-plugin/src/rules/unified-signatures.ts @@ -57,7 +57,6 @@ export default util.createRule({ docs: { description: 'Warns for any two overloads that could be unified into one by using a union or an optional/rest parameter', - category: 'Variables', // too opinionated to be recommended recommended: false, }, diff --git a/packages/eslint-plugin/tests/util/getWrappingFixer.test.ts b/packages/eslint-plugin/tests/util/getWrappingFixer.test.ts index 223061762115..bcbb4c6d5fbb 100644 --- a/packages/eslint-plugin/tests/util/getWrappingFixer.test.ts +++ b/packages/eslint-plugin/tests/util/getWrappingFixer.test.ts @@ -10,7 +10,6 @@ const rule = createRule({ fixable: 'code', docs: { description: 'Add void operator in random places for test purposes.', - category: 'Stylistic Issues', recommended: false, }, messages: { diff --git a/packages/experimental-utils/src/ts-eslint/Rule.ts b/packages/experimental-utils/src/ts-eslint/Rule.ts index e17de9f6eba3..9db521b2850c 100644 --- a/packages/experimental-utils/src/ts-eslint/Rule.ts +++ b/packages/experimental-utils/src/ts-eslint/Rule.ts @@ -1,19 +1,11 @@ -import { JSONSchema4 } from '../json-schema'; -import { ParserServices, TSESTree } from '../ts-estree'; -import { AST } from './AST'; -import { Linter } from './Linter'; -import { Scope } from './Scope'; -import { SourceCode } from './SourceCode'; +import type { JSONSchema4 } from '../json-schema'; +import type { ParserServices, TSESTree } from '../ts-estree'; +import type { AST } from './AST'; +import type { Linter } from './Linter'; +import type { Scope } from './Scope'; +import type { SourceCode } from './SourceCode'; interface RuleMetaDataDocs { - /** - * The general category the rule falls within - */ - category: - | 'Best Practices' - | 'Stylistic Issues' - | 'Variables' - | 'Possible Errors'; /** * Concise description of the rule */ diff --git a/packages/experimental-utils/tests/eslint-utils/RuleCreator.test.ts b/packages/experimental-utils/tests/eslint-utils/RuleCreator.test.ts index 343d5f0e1aad..34b314b8a261 100644 --- a/packages/experimental-utils/tests/eslint-utils/RuleCreator.test.ts +++ b/packages/experimental-utils/tests/eslint-utils/RuleCreator.test.ts @@ -13,7 +13,6 @@ describe('RuleCreator', () => { meta: { docs: { description: 'some description', - category: 'Best Practices', recommended: 'error', requiresTypeChecking: true, }, @@ -31,7 +30,6 @@ describe('RuleCreator', () => { expect(rule.meta).toEqual({ docs: { description: 'some description', - category: 'Best Practices', url: 'test/test', recommended: 'error', requiresTypeChecking: true, diff --git a/yarn.lock b/yarn.lock index 80ea8600a6df..83194d3d9c8d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4373,9 +4373,9 @@ eslint-visitor-keys@^3.0.0: integrity sha512-mJOZa35trBTb3IyRmo8xmKBZlxf+N7OnUl4+ZhJHs/r+0770Wh/LEACE2pqMGMe27G/4y8P2bYGk4J70IC5k1Q== eslint@^8.0.0-0: - version "8.0.0-beta.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.0.0-beta.0.tgz#965fa5161b7cc93f1c82fb9c617a3814dc95ba38" - integrity sha512-Q5wCLXSpq+RIa9QBrmHApNCpgqjBU5aeQbVfeAuc9DyBIWzsdivbiirbCmYBrdoFWUoGSYCYWSIpqrS2une7jg== + version "8.0.0-beta.1" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.0.0-beta.1.tgz#5cd74684dbcfd8abee08cc10de578294124539b5" + integrity sha512-+3EHhCIJHUXuksq6dUSe1Nv9+sdFaLfct6ZiWdFYrHU8u9tX6QQWGdKJQuQXUlUdhMMh6cchRFIQ7OqSAcyq7A== dependencies: "@eslint/eslintrc" "^1.0.0" "@humanwhocodes/config-array" "^0.6.0" From 58235241714596b641a1e8b39c569e561e0039b4 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sat, 28 Aug 2021 18:42:30 -0400 Subject: [PATCH 31/44] feat(eslint-plugin): removed value from abstract property nodes (#3765) * chore: bump @types/jest from 26.0.24 to 27.0.1 (#3748) Bumps [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest) from 26.0.24 to 27.0.1. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jest) --- updated-dependencies: - dependency-name: "@types/jest" dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: address comments Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Brad Zacher --- .../element/TSAbstractClassProperty/spec.ts | 2 + .../rules/explicit-module-boundary-types.ts | 1 - .../src/rules/member-ordering.ts | 1 + .../tests/rules/member-ordering.test.ts | 18 ++--- .../eslint-plugin/tests/rules/quotes.test.ts | 63 +++++----------- .../src/referencer/ClassVisitor.ts | 4 +- ...ract-class-with-abstract-properties.src.ts | 2 +- ...ass-with-abstract-readonly-property.src.ts | 2 +- packages/typescript-estree/src/convert.ts | 2 +- .../tests/ast-alignment/utils.ts | 1 + ...class-with-abstract-properties.src.ts.shot | 74 +++++++++++-------- ...ith-abstract-readonly-property.src.ts.shot | 74 +++++++++++-------- ...t-class-with-override-property.src.ts.shot | 20 +---- packages/visitor-keys/src/visitor-keys.ts | 2 +- 14 files changed, 128 insertions(+), 138 deletions(-) diff --git a/packages/ast-spec/src/element/TSAbstractClassProperty/spec.ts b/packages/ast-spec/src/element/TSAbstractClassProperty/spec.ts index 0d845a893290..a7f1dc56b2d5 100644 --- a/packages/ast-spec/src/element/TSAbstractClassProperty/spec.ts +++ b/packages/ast-spec/src/element/TSAbstractClassProperty/spec.ts @@ -7,11 +7,13 @@ import type { export interface TSAbstractClassPropertyComputedName extends ClassPropertyComputedNameBase { type: AST_NODE_TYPES.TSAbstractClassProperty; + value: null; } export interface TSAbstractClassPropertyNonComputedName extends ClassPropertyNonComputedNameBase { type: AST_NODE_TYPES.TSAbstractClassProperty; + value: null; } export type TSAbstractClassProperty = diff --git a/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts b/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts index 67301afc4406..23ac46434dac 100644 --- a/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts +++ b/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts @@ -337,7 +337,6 @@ export default util.createRule({ return; case AST_NODE_TYPES.ClassProperty: - case AST_NODE_TYPES.TSAbstractClassProperty: if (node.accessibility === 'private') { return; } diff --git a/packages/eslint-plugin/src/rules/member-ordering.ts b/packages/eslint-plugin/src/rules/member-ordering.ts index 13a4fb65ae5c..b913f91b871b 100644 --- a/packages/eslint-plugin/src/rules/member-ordering.ts +++ b/packages/eslint-plugin/src/rules/member-ordering.ts @@ -251,6 +251,7 @@ function getNodeType(node: Member): string | null { case AST_NODE_TYPES.TSConstructSignatureDeclaration: return 'constructor'; case AST_NODE_TYPES.TSAbstractClassProperty: + return 'field'; case AST_NODE_TYPES.ClassProperty: return node.value && functionExpressions.includes(node.value.type) ? 'method' diff --git a/packages/eslint-plugin/tests/rules/member-ordering.test.ts b/packages/eslint-plugin/tests/rules/member-ordering.test.ts index a0bbf7b12233..e457ef3daf4a 100644 --- a/packages/eslint-plugin/tests/rules/member-ordering.test.ts +++ b/packages/eslint-plugin/tests/rules/member-ordering.test.ts @@ -1311,7 +1311,7 @@ abstract class Foo { private D: string; protected static F(): {}; public E(): {}; - public abstract A = () => {}; + public abstract A(): void; protected abstract G(): void; } `, @@ -3618,7 +3618,7 @@ type Foo = { { code: ` abstract class Foo { - abstract A = () => {}; + abstract A(): void; B: string; } `, @@ -3639,9 +3639,6 @@ abstract class Foo { abstract class Foo { abstract A: () => {}; B: string; - public C() {}; - private D() {}; - abstract E() {}; } `, errors: [ @@ -3659,18 +3656,19 @@ abstract class Foo { { code: ` abstract class Foo { - B: string; - abstract C = () => {}; abstract A: () => {}; + B: string; + public C() {}; + private D() {}; + abstract E() {}; } `, - options: [{ default: ['method', 'constructor', 'field'] }], errors: [ { messageId: 'incorrectGroupOrder', data: { - name: 'C', - rank: 'field', + name: 'B', + rank: 'public abstract field', }, line: 4, column: 5, diff --git a/packages/eslint-plugin/tests/rules/quotes.test.ts b/packages/eslint-plugin/tests/rules/quotes.test.ts index ec757dda3e54..0d2549d7e101 100644 --- a/packages/eslint-plugin/tests/rules/quotes.test.ts +++ b/packages/eslint-plugin/tests/rules/quotes.test.ts @@ -455,16 +455,16 @@ class Foo { { code: ` abstract class Foo { - public abstract a = ""; - public abstract "a-b" = ""; + public abstract a: ""; + public abstract "a-b": ""; } `, }, { code: ` abstract class Foo { - public abstract a = ''; - public abstract 'a-b' = ''; + public abstract a: ''; + public abstract 'a-b': ''; } `, options: ['single'], @@ -472,8 +472,8 @@ abstract class Foo { { code: ` abstract class Foo { - public abstract a = \`\`; - public abstract 'a-b' = \`\`; + public abstract a: \`\`; + public abstract 'a-b': \`\`; } `, options: ['backtick'], @@ -1047,21 +1047,21 @@ class Foo { { code: ` abstract class Foo { - public abstract a = ''; - public abstract 'a-b' = ''; + public abstract a: ''; + public abstract 'a-b': ''; } `, output: ` abstract class Foo { - public abstract a = ""; - public abstract "a-b" = ""; + public abstract a: ""; + public abstract "a-b": ""; } `, errors: [ { ...useDoubleQuote, line: 3, - column: 23, + column: 22, }, { ...useDoubleQuote, @@ -1071,28 +1071,28 @@ abstract class Foo { { ...useDoubleQuote, line: 4, - column: 27, + column: 26, }, ], }, { code: ` abstract class Foo { - public abstract a = ""; - public abstract "a-b" = ""; + public abstract a: ""; + public abstract "a-b": ""; } `, output: ` abstract class Foo { - public abstract a = ''; - public abstract 'a-b' = ''; + public abstract a: ''; + public abstract 'a-b': ''; } `, errors: [ { ...useSingleQuote, line: 3, - column: 23, + column: 22, }, { ...useSingleQuote, @@ -1102,38 +1102,11 @@ abstract class Foo { { ...useSingleQuote, line: 4, - column: 27, + column: 26, }, ], options: ['single'], }, - { - code: ` -abstract class Foo { - public abstract a = ""; - public abstract "a-b" = ""; -} - `, - output: ` -abstract class Foo { - public abstract a = \`\`; - public abstract "a-b" = \`\`; -} - `, - errors: [ - { - ...useBacktick, - line: 3, - column: 23, - }, - { - ...useBacktick, - line: 4, - column: 27, - }, - ], - options: ['backtick'], - }, // TSAbstractMethodDefinition { diff --git a/packages/scope-manager/src/referencer/ClassVisitor.ts b/packages/scope-manager/src/referencer/ClassVisitor.ts index fff575831910..497c3a92ca83 100644 --- a/packages/scope-manager/src/referencer/ClassVisitor.ts +++ b/packages/scope-manager/src/referencer/ClassVisitor.ts @@ -237,7 +237,9 @@ class ClassVisitor extends Visitor { this.#referencer.visit(node.key); } - this.#referencer.visit(node.value); + if (node.type !== AST_NODE_TYPES.TSAbstractClassProperty) { + this.#referencer.visit(node.value); + } if ('decorators' in node) { node.decorators?.forEach(d => this.#referencer.visit(d)); diff --git a/packages/shared-fixtures/fixtures/typescript/basics/abstract-class-with-abstract-properties.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/abstract-class-with-abstract-properties.src.ts index 42128953cb7d..223917818db9 100644 --- a/packages/shared-fixtures/fixtures/typescript/basics/abstract-class-with-abstract-properties.src.ts +++ b/packages/shared-fixtures/fixtures/typescript/basics/abstract-class-with-abstract-properties.src.ts @@ -1,4 +1,4 @@ abstract class Foo { abstract bar; - abstract baz = 3; + abstract baz: number; } diff --git a/packages/shared-fixtures/fixtures/typescript/basics/abstract-class-with-abstract-readonly-property.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/abstract-class-with-abstract-readonly-property.src.ts index 8c28567ce8e7..d00921ef4674 100644 --- a/packages/shared-fixtures/fixtures/typescript/basics/abstract-class-with-abstract-readonly-property.src.ts +++ b/packages/shared-fixtures/fixtures/typescript/basics/abstract-class-with-abstract-readonly-property.src.ts @@ -1,3 +1,3 @@ abstract class Foo { - public abstract readonly foo = 'string'; + public abstract readonly foo: string; } diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index be13f690458c..da5ba78fbf86 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -1109,7 +1109,7 @@ export class Converter { ? AST_NODE_TYPES.TSAbstractClassProperty : AST_NODE_TYPES.ClassProperty, key: this.convertChild(node.name), - value: this.convertChild(node.initializer), + value: isAbstract ? null : this.convertChild(node.initializer), computed: isComputedProperty(node.name), static: hasModifier(SyntaxKind.StaticKeyword, node), readonly: hasModifier(SyntaxKind.ReadonlyKeyword, node) || undefined, diff --git a/packages/typescript-estree/tests/ast-alignment/utils.ts b/packages/typescript-estree/tests/ast-alignment/utils.ts index d7dae6bcafe0..1bfd73b2cb88 100644 --- a/packages/typescript-estree/tests/ast-alignment/utils.ts +++ b/packages/typescript-estree/tests/ast-alignment/utils.ts @@ -176,6 +176,7 @@ export function preprocessBabylonAST(ast: BabelTypes.File): any { if (node.abstract) { node.type = AST_NODE_TYPES.TSAbstractClassProperty; delete node.abstract; + node.value = null; } /** * TS 3.7: declare class properties diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-class-with-abstract-properties.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-class-with-abstract-properties.src.ts.shot index 8c70b312e051..ffbc6466b98a 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-class-with-abstract-properties.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-class-with-abstract-properties.src.ts.shot @@ -71,7 +71,7 @@ Object { }, "loc": Object { "end": Object { - "column": 21, + "column": 25, "line": 3, }, "start": Object { @@ -82,30 +82,46 @@ Object { "override": false, "range": Array [ 43, - 60, + 64, ], "readonly": undefined, "static": false, "type": "TSAbstractClassProperty", - "value": Object { + "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 20, + "column": 24, "line": 3, }, "start": Object { - "column": 19, + "column": 16, "line": 3, }, }, "range": Array [ - 58, - 59, + 55, + 63, ], - "raw": "3", - "type": "Literal", - "value": 3, + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 3, + }, + "start": Object { + "column": 18, + "line": 3, + }, + }, + "range": Array [ + 57, + 63, + ], + "type": "TSNumberKeyword", + }, }, + "value": null, }, ], "loc": Object { @@ -120,7 +136,7 @@ Object { }, "range": Array [ 19, - 62, + 66, ], "type": "ClassBody", }, @@ -154,7 +170,7 @@ Object { }, "range": Array [ 0, - 62, + 66, ], "superClass": null, "type": "ClassDeclaration", @@ -173,7 +189,7 @@ Object { }, "range": Array [ 0, - 63, + 67, ], "sourceType": "script", "tokens": Array [ @@ -342,53 +358,53 @@ Object { Object { "loc": Object { "end": Object { - "column": 18, + "column": 17, "line": 3, }, "start": Object { - "column": 17, + "column": 16, "line": 3, }, }, "range": Array [ + 55, 56, - 57, ], "type": "Punctuator", - "value": "=", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 20, + "column": 24, "line": 3, }, "start": Object { - "column": 19, + "column": 18, "line": 3, }, }, "range": Array [ - 58, - 59, + 57, + 63, ], - "type": "Numeric", - "value": "3", + "type": "Identifier", + "value": "number", }, Object { "loc": Object { "end": Object { - "column": 21, + "column": 25, "line": 3, }, "start": Object { - "column": 20, + "column": 24, "line": 3, }, }, "range": Array [ - 59, - 60, + 63, + 64, ], "type": "Punctuator", "value": ";", @@ -405,8 +421,8 @@ Object { }, }, "range": Array [ - 61, - 62, + 65, + 66, ], "type": "Punctuator", "value": "}", diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-class-with-abstract-readonly-property.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-class-with-abstract-readonly-property.src.ts.shot index 44ba579e1f77..61229f3a6121 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-class-with-abstract-readonly-property.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-class-with-abstract-readonly-property.src.ts.shot @@ -31,7 +31,7 @@ Object { }, "loc": Object { "end": Object { - "column": 42, + "column": 39, "line": 2, }, "start": Object { @@ -42,30 +42,46 @@ Object { "override": false, "range": Array [ 23, - 63, + 60, ], "readonly": true, "static": false, "type": "TSAbstractClassProperty", - "value": Object { + "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 41, + "column": 38, "line": 2, }, "start": Object { - "column": 33, + "column": 30, "line": 2, }, }, "range": Array [ - 54, - 62, + 51, + 59, ], - "raw": "'string'", - "type": "Literal", - "value": "string", + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 2, + }, + "start": Object { + "column": 32, + "line": 2, + }, + }, + "range": Array [ + 53, + 59, + ], + "type": "TSStringKeyword", + }, }, + "value": null, }, ], "loc": Object { @@ -80,7 +96,7 @@ Object { }, "range": Array [ 19, - 65, + 62, ], "type": "ClassBody", }, @@ -114,7 +130,7 @@ Object { }, "range": Array [ 0, - 65, + 62, ], "superClass": null, "type": "ClassDeclaration", @@ -133,7 +149,7 @@ Object { }, "range": Array [ 0, - 66, + 63, ], "sourceType": "script", "tokens": Array [ @@ -284,53 +300,53 @@ Object { Object { "loc": Object { "end": Object { - "column": 32, + "column": 31, "line": 2, }, "start": Object { - "column": 31, + "column": 30, "line": 2, }, }, "range": Array [ + 51, 52, - 53, ], "type": "Punctuator", - "value": "=", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 41, + "column": 38, "line": 2, }, "start": Object { - "column": 33, + "column": 32, "line": 2, }, }, "range": Array [ - 54, - 62, + 53, + 59, ], - "type": "String", - "value": "'string'", + "type": "Identifier", + "value": "string", }, Object { "loc": Object { "end": Object { - "column": 42, + "column": 39, "line": 2, }, "start": Object { - "column": 41, + "column": 38, "line": 2, }, }, "range": Array [ - 62, - 63, + 59, + 60, ], "type": "Punctuator", "value": ";", @@ -347,8 +363,8 @@ Object { }, }, "range": Array [ - 64, - 65, + 61, + 62, ], "type": "Punctuator", "value": "}", diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-class-with-override-property.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-class-with-override-property.src.ts.shot index ec1973cbc7ed..005003a72ef8 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-class-with-override-property.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-class-with-override-property.src.ts.shot @@ -46,25 +46,7 @@ Object { "readonly": undefined, "static": false, "type": "TSAbstractClassProperty", - "value": Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 2, - }, - "start": Object { - "column": 26, - "line": 2, - }, - }, - "range": Array [ - 86, - 87, - ], - "raw": "1", - "type": "Literal", - "value": 1, - }, + "value": null, }, ], "loc": Object { diff --git a/packages/visitor-keys/src/visitor-keys.ts b/packages/visitor-keys/src/visitor-keys.ts index 036bfe5763e3..6430592217c2 100644 --- a/packages/visitor-keys/src/visitor-keys.ts +++ b/packages/visitor-keys/src/visitor-keys.ts @@ -63,7 +63,7 @@ const additionalKeys: AdditionalKeys = { Decorator: ['expression'], // TS-prefixed nodes - TSAbstractClassProperty: ['decorators', 'key', 'typeAnnotation', 'value'], + TSAbstractClassProperty: ['decorators', 'key', 'typeAnnotation'], TSAbstractKeyword: [], TSAbstractMethodDefinition: ['key', 'value'], TSAnyKeyword: [], From 22fa5c0c4705ed2898f00b7cacc5dd642d859275 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Sat, 28 Aug 2021 16:21:58 -0700 Subject: [PATCH 32/44] feat: align class property representation with ESTree (#3806) Half of #3430 Closes #3077 --- packages/ast-spec/src/ast-node-types.ts | 4 +- ...pertyBase.ts => PropertyDefinitionBase.ts} | 8 +- .../src/element/ClassProperty/spec.ts | 19 ---- .../src/element/PropertyDefinition/spec.ts | 19 ++++ .../element/TSAbstractClassProperty/spec.ts | 21 ---- .../TSAbstractPropertyDefinition/spec.ts | 21 ++++ packages/ast-spec/src/element/spec.ts | 4 +- packages/ast-spec/src/unions/ClassElement.ts | 8 +- packages/ast-spec/src/unions/Node.ts | 8 +- .../src/rules/class-literal-property-style.ts | 2 +- .../rules/explicit-member-accessibility.ts | 26 +++-- .../rules/explicit-module-boundary-types.ts | 2 +- .../src/rules/indent-new-do-not-use/index.ts | 4 +- packages/eslint-plugin/src/rules/indent.ts | 12 +-- .../src/rules/member-ordering.ts | 10 +- .../src/rules/naming-convention.ts | 26 ++--- .../eslint-plugin/src/rules/no-extra-semi.ts | 8 +- .../src/rules/no-inferrable-types.ts | 8 +- .../src/rules/no-invalid-this.ts | 4 +- .../src/rules/no-invalid-void-type.ts | 2 +- .../src/rules/no-magic-numbers.ts | 6 +- .../src/rules/no-unsafe-assignment.ts | 4 +- .../src/rules/prefer-return-this-type.ts | 4 +- packages/eslint-plugin/src/rules/quotes.ts | 4 +- packages/eslint-plugin/src/rules/semi.ts | 4 +- .../src/rules/space-infix-ops.ts | 6 +- packages/eslint-plugin/src/rules/typedef.ts | 2 +- .../src/util/explicitReturnTypeUtils.ts | 14 +-- packages/eslint-plugin/src/util/misc.ts | 6 +- .../tests/rules/indent/indent.test.ts | 2 +- .../tests/rules/no-extra-semi.test.ts | 99 ++++++++++++++--- .../eslint-plugin/tests/rules/quotes.test.ts | 8 +- .../src/ast-utils/predicates.ts | 4 +- .../experimental-utils/src/ts-eslint/Rule.ts | 8 +- packages/scope-manager/src/ScopeManager.ts | 10 ++ .../src/referencer/ClassVisitor.ts | 30 ++++-- .../src/scope/ClassFieldInitializerScope.ts | 28 +++++ packages/scope-manager/src/scope/Scope.ts | 2 + packages/scope-manager/src/scope/ScopeBase.ts | 3 +- packages/scope-manager/src/scope/ScopeType.ts | 1 + packages/scope-manager/src/scope/index.ts | 1 + .../tests/eslint-scope/class-fields.test.ts | 101 ++++++++++++++++++ .../class/declaration/computed-member.ts.shot | 13 ++- .../fixtures/class/declaration/properties.ts | 6 +- .../class/declaration/properties.ts.shot | 94 ++++++++++++---- .../class/expression/computed-member.ts.shot | 13 ++- .../fixtures/class/expression/properties.ts | 4 +- .../class/expression/properties.ts.shot | 78 +++++++++++--- packages/scope-manager/tests/util/expect.ts | 7 ++ packages/typescript-estree/src/convert.ts | 6 +- .../src/ts-estree/estree-to-ts-node-types.ts | 4 +- .../tests/ast-alignment/parse.ts | 9 +- .../tests/ast-alignment/utils.ts | 6 +- .../__snapshots__/semanticInfo.test.ts.snap | 2 +- .../tests/lib/semanticInfo.test.ts | 2 +- ...class-with-abstract-properties.src.ts.shot | 4 +- ...ith-abstract-readonly-property.src.ts.shot | 2 +- ...-class-with-declare-properties.src.ts.shot | 10 +- ...t-class-with-override-property.src.ts.shot | 2 +- .../basics/class-static-blocks.src.ts.shot | 2 +- ...s-with-accessibility-modifiers.src.ts.shot | 4 +- .../class-with-declare-properties.src.ts.shot | 14 +-- ...class-with-definite-assignment.src.ts.shot | 2 +- ...ith-optional-computed-property.src.ts.shot | 2 +- ...class-with-optional-properties.src.ts.shot | 18 ++-- ...th-optional-property-undefined.src.ts.shot | 2 +- .../class-with-override-property.src.ts.shot | 2 +- .../class-with-property-function.src.ts.shot | 4 +- .../class-with-property-values.src.ts.shot | 10 +- .../class-with-readonly-property.src.ts.shot | 2 +- ...object-with-escaped-properties.src.ts.shot | 2 +- .../type-assertion-in-method.src.ts.shot | 2 +- ...assertion-with-guard-in-method.src.ts.shot | 2 +- .../basics/type-guard-in-method.src.ts.shot | 2 +- .../type-reference-comments.src.ts.shot | 2 +- ...orator-factory-instance-member.src.ts.shot | 4 +- ...ecorator-factory-static-member.src.ts.shot | 4 +- ...erty-decorator-instance-member.src.ts.shot | 4 +- ...operty-decorator-static-member.src.ts.shot | 4 +- .../types/this-type-expanded.src.ts.shot | 2 +- packages/visitor-keys/src/visitor-keys.ts | 4 +- 81 files changed, 651 insertions(+), 268 deletions(-) rename packages/ast-spec/src/base/{ClassPropertyBase.ts => PropertyDefinitionBase.ts} (77%) delete mode 100644 packages/ast-spec/src/element/ClassProperty/spec.ts create mode 100644 packages/ast-spec/src/element/PropertyDefinition/spec.ts delete mode 100644 packages/ast-spec/src/element/TSAbstractClassProperty/spec.ts create mode 100644 packages/ast-spec/src/element/TSAbstractPropertyDefinition/spec.ts create mode 100644 packages/scope-manager/src/scope/ClassFieldInitializerScope.ts create mode 100644 packages/scope-manager/tests/eslint-scope/class-fields.test.ts diff --git a/packages/ast-spec/src/ast-node-types.ts b/packages/ast-spec/src/ast-node-types.ts index 9a38d477acfc..3f6b2a81082a 100644 --- a/packages/ast-spec/src/ast-node-types.ts +++ b/packages/ast-spec/src/ast-node-types.ts @@ -14,7 +14,6 @@ export enum AST_NODE_TYPES { ClassBody = 'ClassBody', ClassDeclaration = 'ClassDeclaration', ClassExpression = 'ClassExpression', - ClassProperty = 'ClassProperty', ConditionalExpression = 'ConditionalExpression', ContinueStatement = 'ContinueStatement', DebuggerStatement = 'DebuggerStatement', @@ -64,6 +63,7 @@ export enum AST_NODE_TYPES { ObjectPattern = 'ObjectPattern', Program = 'Program', Property = 'Property', + PropertyDefinition = 'PropertyDefinition', RestElement = 'RestElement', ReturnStatement = 'ReturnStatement', SequenceExpression = 'SequenceExpression', @@ -88,9 +88,9 @@ export enum AST_NODE_TYPES { /** * TS-prefixed nodes */ - TSAbstractClassProperty = 'TSAbstractClassProperty', TSAbstractKeyword = 'TSAbstractKeyword', TSAbstractMethodDefinition = 'TSAbstractMethodDefinition', + TSAbstractPropertyDefinition = 'TSAbstractPropertyDefinition', TSAnyKeyword = 'TSAnyKeyword', TSArrayType = 'TSArrayType', TSAsExpression = 'TSAsExpression', diff --git a/packages/ast-spec/src/base/ClassPropertyBase.ts b/packages/ast-spec/src/base/PropertyDefinitionBase.ts similarity index 77% rename from packages/ast-spec/src/base/ClassPropertyBase.ts rename to packages/ast-spec/src/base/PropertyDefinitionBase.ts index 7717e02c4ca3..a70a21479ae7 100644 --- a/packages/ast-spec/src/base/ClassPropertyBase.ts +++ b/packages/ast-spec/src/base/PropertyDefinitionBase.ts @@ -9,7 +9,7 @@ import type { import type { Accessibility } from './Accessibility'; import type { BaseNode } from './BaseNode'; -interface ClassPropertyBase extends BaseNode { +interface PropertyDefinitionBase extends BaseNode { key: PropertyName; value: Expression | null; computed: boolean; @@ -24,12 +24,14 @@ interface ClassPropertyBase extends BaseNode { override?: boolean; } -export interface ClassPropertyComputedNameBase extends ClassPropertyBase { +export interface PropertyDefinitionComputedNameBase + extends PropertyDefinitionBase { key: PropertyNameComputed; computed: true; } -export interface ClassPropertyNonComputedNameBase extends ClassPropertyBase { +export interface PropertyDefinitionNonComputedNameBase + extends PropertyDefinitionBase { key: PropertyNameNonComputed; computed: false; } diff --git a/packages/ast-spec/src/element/ClassProperty/spec.ts b/packages/ast-spec/src/element/ClassProperty/spec.ts deleted file mode 100644 index 29fe75aa84e6..000000000000 --- a/packages/ast-spec/src/element/ClassProperty/spec.ts +++ /dev/null @@ -1,19 +0,0 @@ -import type { AST_NODE_TYPES } from '../../ast-node-types'; -import type { - ClassPropertyComputedNameBase, - ClassPropertyNonComputedNameBase, -} from '../../base/ClassPropertyBase'; - -export interface ClassPropertyComputedName - extends ClassPropertyComputedNameBase { - type: AST_NODE_TYPES.ClassProperty; -} - -export interface ClassPropertyNonComputedName - extends ClassPropertyNonComputedNameBase { - type: AST_NODE_TYPES.ClassProperty; -} - -export type ClassProperty = - | ClassPropertyComputedName - | ClassPropertyNonComputedName; diff --git a/packages/ast-spec/src/element/PropertyDefinition/spec.ts b/packages/ast-spec/src/element/PropertyDefinition/spec.ts new file mode 100644 index 000000000000..4f79c2eb8345 --- /dev/null +++ b/packages/ast-spec/src/element/PropertyDefinition/spec.ts @@ -0,0 +1,19 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { + PropertyDefinitionComputedNameBase, + PropertyDefinitionNonComputedNameBase, +} from '../../base/PropertyDefinitionBase'; + +export interface PropertyDefinitionComputedName + extends PropertyDefinitionComputedNameBase { + type: AST_NODE_TYPES.PropertyDefinition; +} + +export interface PropertyDefinitionNonComputedName + extends PropertyDefinitionNonComputedNameBase { + type: AST_NODE_TYPES.PropertyDefinition; +} + +export type PropertyDefinition = + | PropertyDefinitionComputedName + | PropertyDefinitionNonComputedName; diff --git a/packages/ast-spec/src/element/TSAbstractClassProperty/spec.ts b/packages/ast-spec/src/element/TSAbstractClassProperty/spec.ts deleted file mode 100644 index a7f1dc56b2d5..000000000000 --- a/packages/ast-spec/src/element/TSAbstractClassProperty/spec.ts +++ /dev/null @@ -1,21 +0,0 @@ -import type { AST_NODE_TYPES } from '../../ast-node-types'; -import type { - ClassPropertyComputedNameBase, - ClassPropertyNonComputedNameBase, -} from '../../base/ClassPropertyBase'; - -export interface TSAbstractClassPropertyComputedName - extends ClassPropertyComputedNameBase { - type: AST_NODE_TYPES.TSAbstractClassProperty; - value: null; -} - -export interface TSAbstractClassPropertyNonComputedName - extends ClassPropertyNonComputedNameBase { - type: AST_NODE_TYPES.TSAbstractClassProperty; - value: null; -} - -export type TSAbstractClassProperty = - | TSAbstractClassPropertyComputedName - | TSAbstractClassPropertyNonComputedName; diff --git a/packages/ast-spec/src/element/TSAbstractPropertyDefinition/spec.ts b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/spec.ts new file mode 100644 index 000000000000..c7032669fc9f --- /dev/null +++ b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/spec.ts @@ -0,0 +1,21 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { + PropertyDefinitionComputedNameBase, + PropertyDefinitionNonComputedNameBase, +} from '../../base/PropertyDefinitionBase'; + +export interface TSAbstractPropertyDefinitionComputedName + extends PropertyDefinitionComputedNameBase { + type: AST_NODE_TYPES.TSAbstractPropertyDefinition; + value: null; +} + +export interface TSAbstractPropertyDefinitionNonComputedName + extends PropertyDefinitionNonComputedNameBase { + type: AST_NODE_TYPES.TSAbstractPropertyDefinition; + value: null; +} + +export type TSAbstractPropertyDefinition = + | TSAbstractPropertyDefinitionComputedName + | TSAbstractPropertyDefinitionNonComputedName; diff --git a/packages/ast-spec/src/element/spec.ts b/packages/ast-spec/src/element/spec.ts index a31caecced39..77ed3f2f283d 100644 --- a/packages/ast-spec/src/element/spec.ts +++ b/packages/ast-spec/src/element/spec.ts @@ -1,9 +1,9 @@ -export * from './ClassProperty/spec'; +export * from './PropertyDefinition/spec'; export * from './MethodDefinition/spec'; export * from './Property/spec'; export * from './SpreadElement/spec'; export * from './StaticBlock/spec'; -export * from './TSAbstractClassProperty/spec'; +export * from './TSAbstractPropertyDefinition/spec'; export * from './TSAbstractMethodDefinition/spec'; export * from './TSCallSignatureDeclaration/spec'; export * from './TSConstructSignatureDeclaration/spec'; diff --git a/packages/ast-spec/src/unions/ClassElement.ts b/packages/ast-spec/src/unions/ClassElement.ts index c174c4ce6c72..27d4ec4d752c 100644 --- a/packages/ast-spec/src/unions/ClassElement.ts +++ b/packages/ast-spec/src/unions/ClassElement.ts @@ -1,14 +1,14 @@ -import type { ClassProperty } from '../element/ClassProperty/spec'; import type { MethodDefinition } from '../element/MethodDefinition/spec'; +import type { PropertyDefinition } from '../element/PropertyDefinition/spec'; import type { StaticBlock } from '../element/StaticBlock/spec'; -import type { TSAbstractClassProperty } from '../element/TSAbstractClassProperty/spec'; import type { TSAbstractMethodDefinition } from '../element/TSAbstractMethodDefinition/spec'; +import type { TSAbstractPropertyDefinition } from '../element/TSAbstractPropertyDefinition/spec'; import type { TSIndexSignature } from '../element/TSIndexSignature/spec'; export type ClassElement = - | ClassProperty | MethodDefinition + | PropertyDefinition | StaticBlock - | TSAbstractClassProperty | TSAbstractMethodDefinition + | TSAbstractPropertyDefinition | TSIndexSignature; diff --git a/packages/ast-spec/src/unions/Node.ts b/packages/ast-spec/src/unions/Node.ts index 7fe5ced96dfc..4b3c54a09eb9 100644 --- a/packages/ast-spec/src/unions/Node.ts +++ b/packages/ast-spec/src/unions/Node.ts @@ -12,13 +12,13 @@ import type { TSModuleDeclaration } from '../declaration/TSModuleDeclaration/spe import type { TSNamespaceExportDeclaration } from '../declaration/TSNamespaceExportDeclaration/spec'; import type { TSTypeAliasDeclaration } from '../declaration/TSTypeAliasDeclaration/spec'; import type { VariableDeclaration } from '../declaration/VariableDeclaration/spec'; -import type { ClassProperty } from '../element/ClassProperty/spec'; import type { MethodDefinition } from '../element/MethodDefinition/spec'; import type { Property } from '../element/Property/spec'; +import type { PropertyDefinition } from '../element/PropertyDefinition/spec'; import type { SpreadElement } from '../element/SpreadElement/spec'; import type { StaticBlock } from '../element/StaticBlock/spec'; -import type { TSAbstractClassProperty } from '../element/TSAbstractClassProperty/spec'; import type { TSAbstractMethodDefinition } from '../element/TSAbstractMethodDefinition/spec'; +import type { TSAbstractPropertyDefinition } from '../element/TSAbstractPropertyDefinition/spec'; import type { TSCallSignatureDeclaration } from '../element/TSCallSignatureDeclaration/spec'; import type { TSConstructSignatureDeclaration } from '../element/TSConstructSignatureDeclaration/spec'; import type { TSEnumMember } from '../element/TSEnumMember/spec'; @@ -181,7 +181,6 @@ export type Node = | ClassBody | ClassDeclaration | ClassExpression - | ClassProperty | ConditionalExpression | ContinueStatement | DebuggerStatement @@ -231,6 +230,7 @@ export type Node = | ObjectPattern | Program | Property + | PropertyDefinition | RestElement | ReturnStatement | SequenceExpression @@ -245,9 +245,9 @@ export type Node = | ThisExpression | ThrowStatement | TryStatement - | TSAbstractClassProperty | TSAbstractKeyword | TSAbstractMethodDefinition + | TSAbstractPropertyDefinition | TSAnyKeyword | TSArrayType | TSAsExpression diff --git a/packages/eslint-plugin/src/rules/class-literal-property-style.ts b/packages/eslint-plugin/src/rules/class-literal-property-style.ts index dd3878e77a2f..b08161450155 100644 --- a/packages/eslint-plugin/src/rules/class-literal-property-style.ts +++ b/packages/eslint-plugin/src/rules/class-literal-property-style.ts @@ -99,7 +99,7 @@ export default util.createRule({ } return { - ClassProperty(node: TSESTree.ClassProperty): void { + PropertyDefinition(node: TSESTree.PropertyDefinition): void { if (!node.readonly || node.declare) { return; } diff --git a/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts b/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts index 89671fa7567a..2e73af17354b 100644 --- a/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts +++ b/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts @@ -162,7 +162,7 @@ export default util.createRule({ function getUnwantedPublicAccessibilityFixer( node: | TSESTree.MethodDefinition - | TSESTree.ClassProperty + | TSESTree.PropertyDefinition | TSESTree.TSParameterProperty, ): TSESLint.ReportFixFunction { return function (fixer: TSESLint.RuleFixer): TSESLint.RuleFix { @@ -198,30 +198,36 @@ export default util.createRule({ /** * Checks if property has an accessibility modifier. - * @param classProperty The node representing a ClassProperty. + * @param propertyDefinition The node representing a PropertyDefinition. */ function checkPropertyAccessibilityModifier( - classProperty: TSESTree.ClassProperty, + propertyDefinition: TSESTree.PropertyDefinition, ): void { const nodeType = 'class property'; - const propertyName = util.getNameFromMember(classProperty, sourceCode); + const propertyName = util.getNameFromMember( + propertyDefinition, + sourceCode, + ); if ( propCheck === 'no-public' && - classProperty.accessibility === 'public' + propertyDefinition.accessibility === 'public' ) { reportIssue( 'unwantedPublicAccessibility', nodeType, - classProperty, + propertyDefinition, propertyName, - getUnwantedPublicAccessibilityFixer(classProperty), + getUnwantedPublicAccessibilityFixer(propertyDefinition), ); - } else if (propCheck === 'explicit' && !classProperty.accessibility) { + } else if ( + propCheck === 'explicit' && + !propertyDefinition.accessibility + ) { reportIssue( 'missingAccessibility', nodeType, - classProperty, + propertyDefinition, propertyName, ); } @@ -273,7 +279,7 @@ export default util.createRule({ return { TSParameterProperty: checkParameterPropertyAccessibilityModifier, - ClassProperty: checkPropertyAccessibilityModifier, + PropertyDefinition: checkPropertyAccessibilityModifier, MethodDefinition: checkMethodAccessibilityModifier, }; }, diff --git a/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts b/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts index 23ac46434dac..f9670cc98ee3 100644 --- a/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts +++ b/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts @@ -336,7 +336,7 @@ export default util.createRule({ } return; - case AST_NODE_TYPES.ClassProperty: + case AST_NODE_TYPES.PropertyDefinition: if (node.accessibility === 'private') { return; } diff --git a/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts b/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts index 863e7d0889d0..58da2c044e10 100644 --- a/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts +++ b/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts @@ -113,7 +113,7 @@ const KNOWN_NODES = new Set([ AST_NODE_TYPES.ImportNamespaceSpecifier, // Class properties aren't yet supported by eslint... - AST_NODE_TYPES.ClassProperty, + AST_NODE_TYPES.PropertyDefinition, // ts keywords AST_NODE_TYPES.TSAbstractKeyword, @@ -129,7 +129,7 @@ const KNOWN_NODES = new Set([ AST_NODE_TYPES.TSNullKeyword, // ts specific nodes we want to support - AST_NODE_TYPES.TSAbstractClassProperty, + AST_NODE_TYPES.TSAbstractPropertyDefinition, AST_NODE_TYPES.TSAbstractMethodDefinition, AST_NODE_TYPES.TSArrayType, AST_NODE_TYPES.TSAsExpression, diff --git a/packages/eslint-plugin/src/rules/indent.ts b/packages/eslint-plugin/src/rules/indent.ts index 7835fd0e58d9..e057ca9886b3 100644 --- a/packages/eslint-plugin/src/rules/indent.ts +++ b/packages/eslint-plugin/src/rules/indent.ts @@ -19,7 +19,7 @@ type MessageIds = util.InferMessageIdsTypeFromRule; const KNOWN_NODES = new Set([ // Class properties aren't yet supported by eslint... - AST_NODE_TYPES.ClassProperty, + AST_NODE_TYPES.PropertyDefinition, // ts keywords AST_NODE_TYPES.TSAbstractKeyword, @@ -35,7 +35,7 @@ const KNOWN_NODES = new Set([ AST_NODE_TYPES.TSNullKeyword, // ts specific nodes we want to support - AST_NODE_TYPES.TSAbstractClassProperty, + AST_NODE_TYPES.TSAbstractPropertyDefinition, AST_NODE_TYPES.TSAbstractMethodDefinition, AST_NODE_TYPES.TSArrayType, AST_NODE_TYPES.TSAsExpression, @@ -136,7 +136,7 @@ export default util.createRule({ | TSESTree.TSEnumMember | TSESTree.TypeElement, type: - | AST_NODE_TYPES.ClassProperty + | AST_NODE_TYPES.PropertyDefinition | AST_NODE_TYPES.Property = AST_NODE_TYPES.Property, ): TSESTree.Node | null { const base = { @@ -168,7 +168,7 @@ export default util.createRule({ readonly: false, declare: false, ...base, - } as TSESTree.ClassProperty; + } as TSESTree.PropertyDefinition; } } @@ -330,8 +330,8 @@ export default util.createRule({ p => TSPropertySignatureToProperty( p, - AST_NODE_TYPES.ClassProperty, - ) as TSESTree.ClassProperty, + AST_NODE_TYPES.PropertyDefinition, + ) as TSESTree.PropertyDefinition, ), // location data diff --git a/packages/eslint-plugin/src/rules/member-ordering.ts b/packages/eslint-plugin/src/rules/member-ordering.ts index b913f91b871b..9f88228449b4 100644 --- a/packages/eslint-plugin/src/rules/member-ordering.ts +++ b/packages/eslint-plugin/src/rules/member-ordering.ts @@ -250,9 +250,9 @@ function getNodeType(node: Member): string | null { return 'call-signature'; case AST_NODE_TYPES.TSConstructSignatureDeclaration: return 'constructor'; - case AST_NODE_TYPES.TSAbstractClassProperty: + case AST_NODE_TYPES.TSAbstractPropertyDefinition: return 'field'; - case AST_NODE_TYPES.ClassProperty: + case AST_NODE_TYPES.PropertyDefinition: return node.value && functionExpressions.includes(node.value.type) ? 'method' : 'field'; @@ -278,8 +278,8 @@ function getMemberName( switch (node.type) { case AST_NODE_TYPES.TSPropertySignature: case AST_NODE_TYPES.TSMethodSignature: - case AST_NODE_TYPES.TSAbstractClassProperty: - case AST_NODE_TYPES.ClassProperty: + case AST_NODE_TYPES.TSAbstractPropertyDefinition: + case AST_NODE_TYPES.PropertyDefinition: return util.getNameFromMember(node, sourceCode); case AST_NODE_TYPES.TSAbstractMethodDefinition: case AST_NODE_TYPES.MethodDefinition: @@ -339,7 +339,7 @@ function getRank( } const abstract = - node.type === AST_NODE_TYPES.TSAbstractClassProperty || + node.type === AST_NODE_TYPES.TSAbstractPropertyDefinition || node.type === AST_NODE_TYPES.TSAbstractMethodDefinition; const scope = diff --git a/packages/eslint-plugin/src/rules/naming-convention.ts b/packages/eslint-plugin/src/rules/naming-convention.ts index 91456c7ccb23..6915c841473f 100644 --- a/packages/eslint-plugin/src/rules/naming-convention.ts +++ b/packages/eslint-plugin/src/rules/naming-convention.ts @@ -102,8 +102,8 @@ export default util.createRule({ validator: ValidatorFunction | null, node: | TSESTree.PropertyNonComputedName - | TSESTree.ClassPropertyNonComputedName - | TSESTree.TSAbstractClassPropertyNonComputedName + | TSESTree.PropertyDefinitionNonComputedName + | TSESTree.TSAbstractPropertyDefinitionNonComputedName | TSESTree.TSPropertySignatureNonComputedName | TSESTree.MethodDefinitionNonComputedName | TSESTree.TSAbstractMethodDefinitionNonComputedName @@ -124,8 +124,8 @@ export default util.createRule({ function getMemberModifiers( node: - | TSESTree.ClassProperty - | TSESTree.TSAbstractClassProperty + | TSESTree.PropertyDefinition + | TSESTree.TSAbstractPropertyDefinition | TSESTree.MethodDefinition | TSESTree.TSAbstractMethodDefinition | TSESTree.TSParameterProperty, @@ -143,7 +143,7 @@ export default util.createRule({ modifiers.add(Modifiers.readonly); } if ( - node.type === AST_NODE_TYPES.TSAbstractClassProperty || + node.type === AST_NODE_TYPES.TSAbstractPropertyDefinition || node.type === AST_NODE_TYPES.TSAbstractMethodDefinition ) { modifiers.add(Modifiers.abstract); @@ -330,10 +330,10 @@ export default util.createRule({ handleMember(validators.objectLiteralProperty, node, modifiers); }, - ':matches(ClassProperty, TSAbstractClassProperty)[computed = false][value.type != "ArrowFunctionExpression"][value.type != "FunctionExpression"][value.type != "TSEmptyBodyFunctionExpression"]'( + ':matches(PropertyDefinition, TSAbstractPropertyDefinition)[computed = false][value.type != "ArrowFunctionExpression"][value.type != "FunctionExpression"][value.type != "TSEmptyBodyFunctionExpression"]'( node: - | TSESTree.ClassPropertyNonComputedName - | TSESTree.TSAbstractClassPropertyNonComputedName, + | TSESTree.PropertyDefinitionNonComputedName + | TSESTree.TSAbstractPropertyDefinitionNonComputedName, ): void { const modifiers = getMemberModifiers(node); handleMember(validators.classProperty, node, modifiers); @@ -368,14 +368,14 @@ export default util.createRule({ }, [[ - ':matches(ClassProperty, TSAbstractClassProperty)[computed = false][value.type = "ArrowFunctionExpression"]', - ':matches(ClassProperty, TSAbstractClassProperty)[computed = false][value.type = "FunctionExpression"]', - ':matches(ClassProperty, TSAbstractClassProperty)[computed = false][value.type = "TSEmptyBodyFunctionExpression"]', + ':matches(PropertyDefinition, TSAbstractPropertyDefinition)[computed = false][value.type = "ArrowFunctionExpression"]', + ':matches(PropertyDefinition, TSAbstractPropertyDefinition)[computed = false][value.type = "FunctionExpression"]', + ':matches(PropertyDefinition, TSAbstractPropertyDefinition)[computed = false][value.type = "TSEmptyBodyFunctionExpression"]', ':matches(MethodDefinition, TSAbstractMethodDefinition)[computed = false][kind = "method"]', ].join(', ')]( node: - | TSESTree.ClassPropertyNonComputedName - | TSESTree.TSAbstractClassPropertyNonComputedName + | TSESTree.PropertyDefinitionNonComputedName + | TSESTree.TSAbstractPropertyDefinitionNonComputedName | TSESTree.MethodDefinitionNonComputedName | TSESTree.TSAbstractMethodDefinitionNonComputedName, ): void { diff --git a/packages/eslint-plugin/src/rules/no-extra-semi.ts b/packages/eslint-plugin/src/rules/no-extra-semi.ts index 5ed7372b08cc..4ae5cb5c396b 100644 --- a/packages/eslint-plugin/src/rules/no-extra-semi.ts +++ b/packages/eslint-plugin/src/rules/no-extra-semi.ts @@ -26,13 +26,15 @@ export default util.createRule({ return { ...rules, - ClassProperty(node): void { + 'TSAbstractMethodDefinition, TSAbstractPropertyDefinition'( + node: never, + ): void { if (rules.MethodDefinition) { // for ESLint <= v7 - rules.MethodDefinition(node as never); + rules.MethodDefinition(node); } else { // for ESLint v8 - rules['MethodDefinition, PropertyDefinition']?.(node as never); + rules['MethodDefinition, PropertyDefinition']?.(node); } }, }; diff --git a/packages/eslint-plugin/src/rules/no-inferrable-types.ts b/packages/eslint-plugin/src/rules/no-inferrable-types.ts index 23d8616e934e..9c8a1a14c20b 100644 --- a/packages/eslint-plugin/src/rules/no-inferrable-types.ts +++ b/packages/eslint-plugin/src/rules/no-inferrable-types.ts @@ -194,7 +194,7 @@ export default util.createRule({ node: | TSESTree.VariableDeclarator | TSESTree.Parameter - | TSESTree.ClassProperty, + | TSESTree.PropertyDefinition, typeNode: TSESTree.TSTypeAnnotation | undefined, initNode: TSESTree.Expression | null | undefined, ): void { @@ -252,7 +252,9 @@ export default util.createRule({ }); } - function inferrablePropertyVisitor(node: TSESTree.ClassProperty): void { + function inferrablePropertyVisitor( + node: TSESTree.PropertyDefinition, + ): void { // We ignore `readonly` because of Microsoft/TypeScript#14416 // Essentially a readonly property without a type // will result in its value being the type, leading to @@ -268,7 +270,7 @@ export default util.createRule({ FunctionExpression: inferrableParameterVisitor, FunctionDeclaration: inferrableParameterVisitor, ArrowFunctionExpression: inferrableParameterVisitor, - ClassProperty: inferrablePropertyVisitor, + PropertyDefinition: inferrablePropertyVisitor, }; }, }); diff --git a/packages/eslint-plugin/src/rules/no-invalid-this.ts b/packages/eslint-plugin/src/rules/no-invalid-this.ts index 9b8a4ac8d8af..1cd1be027b94 100644 --- a/packages/eslint-plugin/src/rules/no-invalid-this.ts +++ b/packages/eslint-plugin/src/rules/no-invalid-this.ts @@ -53,10 +53,10 @@ export default createRule({ return { ...rules, - ClassProperty(): void { + PropertyDefinition(): void { thisIsValidStack.push(true); }, - 'ClassProperty:exit'(): void { + 'PropertyDefinition:exit'(): void { thisIsValidStack.pop(); }, FunctionDeclaration(node: TSESTree.FunctionDeclaration): void { diff --git a/packages/eslint-plugin/src/rules/no-invalid-void-type.ts b/packages/eslint-plugin/src/rules/no-invalid-void-type.ts index 5c7829cde6cf..dceffa6d893e 100644 --- a/packages/eslint-plugin/src/rules/no-invalid-void-type.ts +++ b/packages/eslint-plugin/src/rules/no-invalid-void-type.ts @@ -68,7 +68,7 @@ export default util.createRule<[Options], MessageIds>({ const invalidGrandParents: AST_NODE_TYPES[] = [ AST_NODE_TYPES.TSPropertySignature, AST_NODE_TYPES.CallExpression, - AST_NODE_TYPES.ClassProperty, + AST_NODE_TYPES.PropertyDefinition, AST_NODE_TYPES.Identifier, ]; const validUnionMembers: AST_NODE_TYPES[] = [ diff --git a/packages/eslint-plugin/src/rules/no-magic-numbers.ts b/packages/eslint-plugin/src/rules/no-magic-numbers.ts index a434a06dcf9a..e63c80686c3d 100644 --- a/packages/eslint-plugin/src/rules/no-magic-numbers.ts +++ b/packages/eslint-plugin/src/rules/no-magic-numbers.ts @@ -77,7 +77,7 @@ export default util.createRule({ // Check if the node is a readonly class property if ( typeof node.value === 'number' && - isParentTSReadonlyClassProperty(node) + isParentTSReadonlyPropertyDefinition(node) ) { if (options.ignoreReadonlyClassProperties) { return; @@ -211,10 +211,10 @@ function isTSNumericLiteralType(node: TSESTree.Node): boolean { * @returns true if the node parent is a readonly class property * @private */ -function isParentTSReadonlyClassProperty(node: TSESTree.Literal): boolean { +function isParentTSReadonlyPropertyDefinition(node: TSESTree.Literal): boolean { const parent = getLiteralParent(node); - if (parent?.type === AST_NODE_TYPES.ClassProperty && parent.readonly) { + if (parent?.type === AST_NODE_TYPES.PropertyDefinition && parent.readonly) { return true; } diff --git a/packages/eslint-plugin/src/rules/no-unsafe-assignment.ts b/packages/eslint-plugin/src/rules/no-unsafe-assignment.ts index b14f43fe27f9..cb4b8e7c636a 100644 --- a/packages/eslint-plugin/src/rules/no-unsafe-assignment.ts +++ b/packages/eslint-plugin/src/rules/no-unsafe-assignment.ts @@ -336,7 +336,9 @@ export default util.createRule({ checkObjectDestructureHelper(node.id, init); } }, - 'ClassProperty[value != null]'(node: TSESTree.ClassProperty): void { + 'PropertyDefinition[value != null]'( + node: TSESTree.PropertyDefinition, + ): void { checkAssignment( node.key, node.value!, diff --git a/packages/eslint-plugin/src/rules/prefer-return-this-type.ts b/packages/eslint-plugin/src/rules/prefer-return-this-type.ts index b6be29efc043..15faf74d1ed3 100644 --- a/packages/eslint-plugin/src/rules/prefer-return-this-type.ts +++ b/packages/eslint-plugin/src/rules/prefer-return-this-type.ts @@ -154,7 +154,9 @@ export default createRule({ 'ClassBody > MethodDefinition'(node: TSESTree.MethodDefinition): void { checkFunction(node.value, node.parent!.parent as ClassLikeDeclaration); }, - 'ClassBody > ClassProperty'(node: TSESTree.ClassProperty): void { + 'ClassBody > PropertyDefinition'( + node: TSESTree.PropertyDefinition, + ): void { if ( !( node.value?.type === AST_NODE_TYPES.FunctionExpression || diff --git a/packages/eslint-plugin/src/rules/quotes.ts b/packages/eslint-plugin/src/rules/quotes.ts index e03556af63dd..a22782cc08ea 100644 --- a/packages/eslint-plugin/src/rules/quotes.ts +++ b/packages/eslint-plugin/src/rules/quotes.ts @@ -53,8 +53,8 @@ export default util.createRule({ case AST_NODE_TYPES.TSEnumMember: return node === parent.id; - case AST_NODE_TYPES.TSAbstractClassProperty: - case AST_NODE_TYPES.ClassProperty: + case AST_NODE_TYPES.TSAbstractPropertyDefinition: + case AST_NODE_TYPES.PropertyDefinition: return node === parent.key; default: diff --git a/packages/eslint-plugin/src/rules/semi.ts b/packages/eslint-plugin/src/rules/semi.ts index 40e631482aaf..647d2c21b3eb 100644 --- a/packages/eslint-plugin/src/rules/semi.ts +++ b/packages/eslint-plugin/src/rules/semi.ts @@ -51,8 +51,8 @@ export default util.createRule({ AST_NODE_TYPES.TSPropertySignature, */ const nodesToCheck = [ - AST_NODE_TYPES.ClassProperty, - AST_NODE_TYPES.TSAbstractClassProperty, + AST_NODE_TYPES.PropertyDefinition, + AST_NODE_TYPES.TSAbstractPropertyDefinition, AST_NODE_TYPES.TSAbstractMethodDefinition, AST_NODE_TYPES.TSDeclareFunction, AST_NODE_TYPES.TSExportAssignment, diff --git a/packages/eslint-plugin/src/rules/space-infix-ops.ts b/packages/eslint-plugin/src/rules/space-infix-ops.ts index 80294cd26718..fddeaac6fb6f 100644 --- a/packages/eslint-plugin/src/rules/space-infix-ops.ts +++ b/packages/eslint-plugin/src/rules/space-infix-ops.ts @@ -122,8 +122,8 @@ export default util.createRule({ * Check if it has an assignment char and report if it's faulty * @param node The node to report */ - function checkForClassPropertyAssignmentSpace( - node: TSESTree.ClassProperty, + function checkForPropertyDefinitionAssignmentSpace( + node: TSESTree.PropertyDefinition, ): void { const leftNode = sourceCode.getTokenByRangeStart( node.typeAnnotation?.range[0] ?? node.range[0], @@ -179,7 +179,7 @@ export default util.createRule({ return { ...rules, TSEnumMember: checkForEnumAssignmentSpace, - ClassProperty: checkForClassPropertyAssignmentSpace, + PropertyDefinition: checkForPropertyDefinitionAssignmentSpace, TSTypeAliasDeclaration: checkForTypeAliasAssignment, TSUnionType: checkForTypeAnnotationSpace, TSIntersectionType: checkForTypeAnnotationSpace, diff --git a/packages/eslint-plugin/src/rules/typedef.ts b/packages/eslint-plugin/src/rules/typedef.ts index 35655a9a803d..eaca1be209e9 100644 --- a/packages/eslint-plugin/src/rules/typedef.ts +++ b/packages/eslint-plugin/src/rules/typedef.ts @@ -159,7 +159,7 @@ export default util.createRule<[Options], MessageIds>({ checkParameters(node.params); } }, - ClassProperty(node): void { + PropertyDefinition(node): void { if (node.value && isVariableDeclarationIgnoreFunction(node.value)) { return; } diff --git a/packages/eslint-plugin/src/util/explicitReturnTypeUtils.ts b/packages/eslint-plugin/src/util/explicitReturnTypeUtils.ts index 881102b7e848..fd512749dfb0 100644 --- a/packages/eslint-plugin/src/util/explicitReturnTypeUtils.ts +++ b/packages/eslint-plugin/src/util/explicitReturnTypeUtils.ts @@ -32,10 +32,12 @@ function isVariableDeclaratorWithTypeAnnotation( * public x: Foo = ... * ``` */ -function isClassPropertyWithTypeAnnotation( +function isPropertyDefinitionWithTypeAnnotation( node: TSESTree.Node, -): node is TSESTree.ClassProperty { - return node.type === AST_NODE_TYPES.ClassProperty && !!node.typeAnnotation; +): node is TSESTree.PropertyDefinition { + return ( + node.type === AST_NODE_TYPES.PropertyDefinition && !!node.typeAnnotation + ); } /** @@ -81,7 +83,7 @@ function isPropertyOfObjectWithType( return ( isTypeAssertion(parent) || - isClassPropertyWithTypeAnnotation(parent) || + isPropertyDefinitionWithTypeAnnotation(parent) || isVariableDeclaratorWithTypeAnnotation(parent) || isFunctionArgument(parent) || isPropertyOfObjectWithType(parent) @@ -194,7 +196,7 @@ function isTypedFunctionExpression( return ( isTypeAssertion(parent) || isVariableDeclaratorWithTypeAnnotation(parent) || - isClassPropertyWithTypeAnnotation(parent) || + isPropertyDefinitionWithTypeAnnotation(parent) || isPropertyOfObjectWithType(parent) || isFunctionArgument(parent, node) || isConstructorArgument(parent) @@ -219,7 +221,7 @@ function isValidFunctionExpressionReturnType( parent.type !== AST_NODE_TYPES.VariableDeclarator && parent.type !== AST_NODE_TYPES.MethodDefinition && parent.type !== AST_NODE_TYPES.ExportDefaultDeclaration && - parent.type !== AST_NODE_TYPES.ClassProperty + parent.type !== AST_NODE_TYPES.PropertyDefinition ) { return true; } diff --git a/packages/eslint-plugin/src/util/misc.ts b/packages/eslint-plugin/src/util/misc.ts index e7e0991ba6a0..748a5cec6a6b 100644 --- a/packages/eslint-plugin/src/util/misc.ts +++ b/packages/eslint-plugin/src/util/misc.ts @@ -66,15 +66,15 @@ function getNameFromIndexSignature(node: TSESTree.TSIndexSignature): string { /** * Gets a string name representation of the name of the given MethodDefinition - * or ClassProperty node, with handling for computed property names. + * or PropertyDefinition node, with handling for computed property names. */ function getNameFromMember( member: | TSESTree.MethodDefinition | TSESTree.TSMethodSignature | TSESTree.TSAbstractMethodDefinition - | TSESTree.ClassProperty - | TSESTree.TSAbstractClassProperty + | TSESTree.PropertyDefinition + | TSESTree.TSAbstractPropertyDefinition | TSESTree.Property | TSESTree.TSPropertySignature, sourceCode: TSESLint.SourceCode, diff --git a/packages/eslint-plugin/tests/rules/indent/indent.test.ts b/packages/eslint-plugin/tests/rules/indent/indent.test.ts index f5c87316c171..3d6b58725f8b 100644 --- a/packages/eslint-plugin/tests/rules/indent/indent.test.ts +++ b/packages/eslint-plugin/tests/rules/indent/indent.test.ts @@ -39,7 +39,7 @@ abstract class Foo { ], }, { - node: AST_NODE_TYPES.TSAbstractClassProperty, + node: AST_NODE_TYPES.TSAbstractPropertyDefinition, code: [ ` class Foo { diff --git a/packages/eslint-plugin/tests/rules/no-extra-semi.test.ts b/packages/eslint-plugin/tests/rules/no-extra-semi.test.ts index db3ca1735325..4d2d870e7e50 100644 --- a/packages/eslint-plugin/tests/rules/no-extra-semi.test.ts +++ b/packages/eslint-plugin/tests/rules/no-extra-semi.test.ts @@ -32,7 +32,6 @@ ruleTester.run('no-extra-semi', rule, { }, { code: 'for(a of b);', - parserOptions: { ecmaVersion: 6 }, }, { code: 'if(true);', @@ -50,23 +49,18 @@ ruleTester.run('no-extra-semi', rule, { // Class body. { code: 'class A { }', - parserOptions: { ecmaVersion: 6 }, }, { code: 'var A = class { };', - parserOptions: { ecmaVersion: 6 }, }, { code: 'class A { a() { this; } }', - parserOptions: { ecmaVersion: 6 }, }, { code: 'var A = class { a() { this; } };', - parserOptions: { ecmaVersion: 6 }, }, { code: 'class A { } a;', - parserOptions: { ecmaVersion: 6 }, }, // modules @@ -159,7 +153,6 @@ export class Foo { { code: 'for(a of b);;', output: 'for(a of b);', - parserOptions: { ecmaVersion: 6 }, errors: [ { messageId: 'unexpected', @@ -228,7 +221,6 @@ export class Foo { { code: 'class A { ; }', output: 'class A { }', - parserOptions: { ecmaVersion: 6 }, errors: [ { messageId: 'unexpected', @@ -239,7 +231,6 @@ export class Foo { { code: 'class A { /*a*/; }', output: 'class A { /*a*/ }', - parserOptions: { ecmaVersion: 6 }, errors: [ { messageId: 'unexpected', @@ -250,7 +241,6 @@ export class Foo { { code: 'class A { ; a() {} }', output: 'class A { a() {} }', - parserOptions: { ecmaVersion: 6 }, errors: [ { messageId: 'unexpected', @@ -261,7 +251,6 @@ export class Foo { { code: 'class A { a() {}; }', output: 'class A { a() {} }', - parserOptions: { ecmaVersion: 6 }, errors: [ { messageId: 'unexpected', @@ -272,7 +261,6 @@ export class Foo { { code: 'class A { a() {}; b() {} }', output: 'class A { a() {} b() {} }', - parserOptions: { ecmaVersion: 6 }, errors: [ { messageId: 'unexpected', @@ -283,7 +271,6 @@ export class Foo { { code: 'class A {; a() {}; b() {}; }', output: 'class A { a() {} b() {} }', - parserOptions: { ecmaVersion: 6 }, errors: [ { messageId: 'unexpected', @@ -302,7 +289,6 @@ export class Foo { { code: 'class A { a() {}; get b() {} }', output: 'class A { a() {} get b() {} }', - parserOptions: { ecmaVersion: 6 }, errors: [ { messageId: 'unexpected', @@ -321,7 +307,6 @@ class Foo { public foo: number = 0; } `, - parserOptions: { ecmaVersion: 6 }, errors: [ { messageId: 'unexpected', @@ -342,7 +327,6 @@ class Foo { public baz: number = 1; } `, - parserOptions: { ecmaVersion: 6 }, errors: [ { messageId: 'unexpected', @@ -361,5 +345,88 @@ class Foo { }, ], }, + + // abstract prop/method + { + code: ` +class Foo { + abstract foo: number;; abstract bar: number;; + abstract baz: number;; +} + `, + output: ` +class Foo { + abstract foo: number; abstract bar: number; + abstract baz: number; +} + `, + errors: [ + { + messageId: 'unexpected', + line: 3, + column: 24, + }, + { + messageId: 'unexpected', + line: 3, + column: 47, + }, + { + messageId: 'unexpected', + line: 4, + column: 24, + }, + ], + }, + { + code: ` +class Foo { + abstract foo();; abstract bar();; + abstract baz();; + abstract foo(): void;; abstract bar(): void;; + abstract baz(): void;; +} + `, + output: ` +class Foo { + abstract foo(); abstract bar(); + abstract baz(); + abstract foo(): void; abstract bar(): void; + abstract baz(): void; +} + `, + errors: [ + { + messageId: 'unexpected', + line: 3, + column: 18, + }, + { + messageId: 'unexpected', + line: 3, + column: 35, + }, + { + messageId: 'unexpected', + line: 4, + column: 18, + }, + { + messageId: 'unexpected', + line: 5, + column: 24, + }, + { + messageId: 'unexpected', + line: 5, + column: 47, + }, + { + messageId: 'unexpected', + line: 6, + column: 24, + }, + ], + }, ], }); diff --git a/packages/eslint-plugin/tests/rules/quotes.test.ts b/packages/eslint-plugin/tests/rules/quotes.test.ts index 0d2549d7e101..003d4fd19d7e 100644 --- a/packages/eslint-plugin/tests/rules/quotes.test.ts +++ b/packages/eslint-plugin/tests/rules/quotes.test.ts @@ -423,7 +423,7 @@ interface Foo { options: ['backtick'], }, - // ClassProperty + // PropertyDefinition { code: ` class Foo { @@ -451,7 +451,7 @@ class Foo { options: ['backtick'], }, - // TSAbstractClassProperty + // TSAbstractPropertyDefinition { code: ` abstract class Foo { @@ -951,7 +951,7 @@ interface Foo { options: ['single'], }, - // ClassProperty + // PropertyDefinition { code: ` class Foo { @@ -1043,7 +1043,7 @@ class Foo { options: ['backtick'], }, - // TSAbstractClassProperty + // TSAbstractPropertyDefinition { code: ` abstract class Foo { diff --git a/packages/experimental-utils/src/ast-utils/predicates.ts b/packages/experimental-utils/src/ast-utils/predicates.ts index 5044dfcca6ef..825591978023 100644 --- a/packages/experimental-utils/src/ast-utils/predicates.ts +++ b/packages/experimental-utils/src/ast-utils/predicates.ts @@ -121,10 +121,10 @@ const isTSConstructorType = isNodeOfType(AST_NODE_TYPES.TSConstructorType); const isClassOrTypeElement = isNodeOfTypes([ // ClassElement - AST_NODE_TYPES.ClassProperty, + AST_NODE_TYPES.PropertyDefinition, AST_NODE_TYPES.FunctionExpression, AST_NODE_TYPES.MethodDefinition, - AST_NODE_TYPES.TSAbstractClassProperty, + AST_NODE_TYPES.TSAbstractPropertyDefinition, AST_NODE_TYPES.TSAbstractMethodDefinition, AST_NODE_TYPES.TSEmptyBodyFunctionExpression, AST_NODE_TYPES.TSIndexSignature, diff --git a/packages/experimental-utils/src/ts-eslint/Rule.ts b/packages/experimental-utils/src/ts-eslint/Rule.ts index 9db521b2850c..1759a20eff5a 100644 --- a/packages/experimental-utils/src/ts-eslint/Rule.ts +++ b/packages/experimental-utils/src/ts-eslint/Rule.ts @@ -271,8 +271,8 @@ interface RuleListener { ArrayExpression?: RuleFunction; ArrayPattern?: RuleFunction; ArrowFunctionExpression?: RuleFunction; - AssignmentPattern?: RuleFunction; AssignmentExpression?: RuleFunction; + AssignmentPattern?: RuleFunction; AwaitExpression?: RuleFunction; BigIntLiteral?: RuleFunction; BinaryExpression?: RuleFunction; @@ -284,7 +284,6 @@ interface RuleListener { ClassBody?: RuleFunction; ClassDeclaration?: RuleFunction; ClassExpression?: RuleFunction; - ClassProperty?: RuleFunction; ConditionalExpression?: RuleFunction; ContinueStatement?: RuleFunction; DebuggerStatement?: RuleFunction; @@ -333,6 +332,7 @@ interface RuleListener { ObjectPattern?: RuleFunction; Program?: RuleFunction; Property?: RuleFunction; + PropertyDefinition?: RuleFunction; RestElement?: RuleFunction; ReturnStatement?: RuleFunction; SequenceExpression?: RuleFunction; @@ -346,9 +346,9 @@ interface RuleListener { ThisExpression?: RuleFunction; ThrowStatement?: RuleFunction; TryStatement?: RuleFunction; - TSAbstractClassProperty?: RuleFunction; TSAbstractKeyword?: RuleFunction; TSAbstractMethodDefinition?: RuleFunction; + TSAbstractPropertyDefinition?: RuleFunction; TSAnyKeyword?: RuleFunction; TSArrayType?: RuleFunction; TSAsExpression?: RuleFunction; @@ -360,8 +360,8 @@ interface RuleListener { TSConditionalType?: RuleFunction; TSConstructorType?: RuleFunction; TSConstructSignatureDeclaration?: RuleFunction; - TSDeclareKeyword?: RuleFunction; TSDeclareFunction?: RuleFunction; + TSDeclareKeyword?: RuleFunction; TSEmptyBodyFunctionExpression?: RuleFunction; TSEnumDeclaration?: RuleFunction; TSEnumMember?: RuleFunction; diff --git a/packages/scope-manager/src/ScopeManager.ts b/packages/scope-manager/src/ScopeManager.ts index e4c9b4d3cdc4..3f360710cb0b 100644 --- a/packages/scope-manager/src/ScopeManager.ts +++ b/packages/scope-manager/src/ScopeManager.ts @@ -19,6 +19,7 @@ import { TypeScope, WithScope, } from './scope'; +import { ClassFieldInitializerScope } from './scope/ClassFieldInitializerScope'; import { Variable } from './variable'; @@ -168,6 +169,15 @@ class ScopeManager { return this.nestScope(new ClassScope(this, this.currentScope, node)); } + public nestClassFieldInitializerScope( + node: ClassFieldInitializerScope['block'], + ): ClassFieldInitializerScope { + assert(this.currentScope); + return this.nestScope( + new ClassFieldInitializerScope(this, this.currentScope, node), + ); + } + public nestConditionalTypeScope( node: ConditionalTypeScope['block'], ): ConditionalTypeScope { diff --git a/packages/scope-manager/src/referencer/ClassVisitor.ts b/packages/scope-manager/src/referencer/ClassVisitor.ts index 497c3a92ca83..d33e362ea41a 100644 --- a/packages/scope-manager/src/referencer/ClassVisitor.ts +++ b/packages/scope-manager/src/referencer/ClassVisitor.ts @@ -80,8 +80,8 @@ class ClassVisitor extends Visitor { this.#referencer.close(node); } - protected visitClassProperty( - node: TSESTree.TSAbstractClassProperty | TSESTree.ClassProperty, + protected visitPropertyDefinition( + node: TSESTree.TSAbstractPropertyDefinition | TSESTree.PropertyDefinition, ): void { this.visitProperty(node); /** @@ -229,16 +229,26 @@ class ClassVisitor extends Visitor { protected visitProperty( node: - | TSESTree.ClassProperty - | TSESTree.TSAbstractClassProperty + | TSESTree.PropertyDefinition + | TSESTree.TSAbstractPropertyDefinition | TSESTree.TSAbstractMethodDefinition, ): void { if (node.computed) { this.#referencer.visit(node.key); } - if (node.type !== AST_NODE_TYPES.TSAbstractClassProperty) { + if (node.value) { + if (node.type === AST_NODE_TYPES.PropertyDefinition) { + this.#referencer.scopeManager.nestClassFieldInitializerScope( + node.value, + ); + } + this.#referencer.visit(node.value); + + if (node.type === AST_NODE_TYPES.PropertyDefinition) { + this.#referencer.close(node.value); + } } if ('decorators' in node) { @@ -320,18 +330,18 @@ class ClassVisitor extends Visitor { this.visitChildren(node); } - protected ClassProperty(node: TSESTree.ClassProperty): void { - this.visitClassProperty(node); + protected PropertyDefinition(node: TSESTree.PropertyDefinition): void { + this.visitPropertyDefinition(node); } protected MethodDefinition(node: TSESTree.MethodDefinition): void { this.visitMethod(node); } - protected TSAbstractClassProperty( - node: TSESTree.TSAbstractClassProperty, + protected TSAbstractPropertyDefinition( + node: TSESTree.TSAbstractPropertyDefinition, ): void { - this.visitClassProperty(node); + this.visitPropertyDefinition(node); } protected TSAbstractMethodDefinition( diff --git a/packages/scope-manager/src/scope/ClassFieldInitializerScope.ts b/packages/scope-manager/src/scope/ClassFieldInitializerScope.ts new file mode 100644 index 000000000000..b176fb2060fc --- /dev/null +++ b/packages/scope-manager/src/scope/ClassFieldInitializerScope.ts @@ -0,0 +1,28 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { Scope } from './Scope'; +import { ScopeBase } from './ScopeBase'; +import { ScopeType } from './ScopeType'; +import { ScopeManager } from '../ScopeManager'; + +class ClassFieldInitializerScope extends ScopeBase< + ScopeType.classFieldInitializer, + // the value expression itself is the block + TSESTree.Expression, + Scope +> { + constructor( + scopeManager: ScopeManager, + upperScope: ClassFieldInitializerScope['upper'], + block: ClassFieldInitializerScope['block'], + ) { + super( + scopeManager, + ScopeType.classFieldInitializer, + upperScope, + block, + false, + ); + } +} + +export { ClassFieldInitializerScope }; diff --git a/packages/scope-manager/src/scope/Scope.ts b/packages/scope-manager/src/scope/Scope.ts index 7df3f941629c..966e52a9456a 100644 --- a/packages/scope-manager/src/scope/Scope.ts +++ b/packages/scope-manager/src/scope/Scope.ts @@ -1,5 +1,6 @@ import { BlockScope } from './BlockScope'; import { CatchScope } from './CatchScope'; +import { ClassFieldInitializerScope } from './ClassFieldInitializerScope'; import { ClassScope } from './ClassScope'; import { ConditionalTypeScope } from './ConditionalTypeScope'; import { ForScope } from './ForScope'; @@ -19,6 +20,7 @@ type Scope = | BlockScope | CatchScope | ClassScope + | ClassFieldInitializerScope | ConditionalTypeScope | ForScope | FunctionExpressionNameScope diff --git a/packages/scope-manager/src/scope/ScopeBase.ts b/packages/scope-manager/src/scope/ScopeBase.ts index c06a7002c48b..34c9a338b5b1 100644 --- a/packages/scope-manager/src/scope/ScopeBase.ts +++ b/packages/scope-manager/src/scope/ScopeBase.ts @@ -125,8 +125,9 @@ const generator = createIdGenerator(); type VariableScope = GlobalScope | FunctionScope | ModuleScope | TSModuleScope; const VARIABLE_SCOPE_TYPES = new Set([ - ScopeType.global, + ScopeType.classFieldInitializer, ScopeType.function, + ScopeType.global, ScopeType.module, ScopeType.tsModule, ]); diff --git a/packages/scope-manager/src/scope/ScopeType.ts b/packages/scope-manager/src/scope/ScopeType.ts index 23d70fedbe80..8a63ffbdea7f 100644 --- a/packages/scope-manager/src/scope/ScopeType.ts +++ b/packages/scope-manager/src/scope/ScopeType.ts @@ -2,6 +2,7 @@ enum ScopeType { block = 'block', catch = 'catch', class = 'class', + classFieldInitializer = 'class-field-initializer', conditionalType = 'conditionalType', for = 'for', function = 'function', diff --git a/packages/scope-manager/src/scope/index.ts b/packages/scope-manager/src/scope/index.ts index 8e4683dbe68a..c94cc2982e1f 100644 --- a/packages/scope-manager/src/scope/index.ts +++ b/packages/scope-manager/src/scope/index.ts @@ -1,5 +1,6 @@ export * from './BlockScope'; export * from './CatchScope'; +export * from './ClassFieldInitializerScope'; export * from './ClassScope'; export * from './ConditionalTypeScope'; export * from './ForScope'; diff --git a/packages/scope-manager/tests/eslint-scope/class-fields.test.ts b/packages/scope-manager/tests/eslint-scope/class-fields.test.ts new file mode 100644 index 000000000000..541b46a2fff2 --- /dev/null +++ b/packages/scope-manager/tests/eslint-scope/class-fields.test.ts @@ -0,0 +1,101 @@ +import { + expectToBeClassFieldInitializerScope, + expectToBeIdentifier, +} from '../util'; +import { + expectToBeClassScope, + expectToBeGlobalScope, + parseAndAnalyze, +} from '../util'; + +describe('Class fields', () => { + it('class C { f = g }', () => { + const { scopeManager } = parseAndAnalyze('class C { f = g }'); + + const globalScope = scopeManager.scopes[0]; + expectToBeGlobalScope(globalScope); + + const classScope = globalScope.childScopes[0]; + // should create a class scope + expectToBeClassScope(classScope); + // The class scope has no references + expect(classScope.references).toHaveLength(0); + // The class scope has only the variable 'C'; it doesn't have the field name 'f'. + expect(classScope.variables).toHaveLength(1); + expect(classScope.variables[0].name).toBe('C'); + + const classFieldInitializerScope = classScope.childScopes[0]; + // The class scope has a class-field-initializer scope. + expectToBeClassFieldInitializerScope(classFieldInitializerScope); + // The class-field-initializer scope's block is the node of the field initializer. + expectToBeIdentifier(classFieldInitializerScope.block); + expect(classFieldInitializerScope.block.name).toBe('g'); + // The class-field-initializer scope's variableScope is itself. + expect(classFieldInitializerScope.variableScope).toBe( + classFieldInitializerScope, + ); + // The class-field-initializer scope has only the reference 'g'. + expect(classFieldInitializerScope.references).toHaveLength(1); + expect(classFieldInitializerScope.references[0].identifier.name).toBe('g'); + // The class-field-initializer scope has no variables. + expect(classFieldInitializerScope.variables).toHaveLength(0); + }); + + describe('class C { f }', () => { + const { scopeManager } = parseAndAnalyze('class C { f }'); + + const globalScope = scopeManager.scopes[0]; + expectToBeGlobalScope(globalScope); + + const classScope = globalScope.childScopes[0]; + // should create a class scope + expectToBeClassScope(classScope); + // The class scope has no references + expect(classScope.references).toHaveLength(0); + // The class scope has no child scopes; fields that don't have initializers don't create any class-field-initializer scopes. + expect(classScope.childScopes).toHaveLength(0); + // The class scope has only the variable 'C'; it doesn't have the field name 'f'. + expect(classScope.variables).toHaveLength(1); + expect(classScope.variables[0].name).toBe('C'); + }); + + describe('class C { [fname] }', () => { + const { scopeManager } = parseAndAnalyze('class C { [fname] }'); + + const globalScope = scopeManager.scopes[0]; + expectToBeGlobalScope(globalScope); + + const classScope = globalScope.childScopes[0]; + // should create a class scope + expectToBeClassScope(classScope); + // The class scope has only the reference `fname`. + expect(classScope.references).toHaveLength(1); + // The class scope has no child scopes; fields that don't have initializers don't create any class-field-initializer scopes. + expect(classScope.childScopes).toHaveLength(0); + }); + + describe('class C { [fname] = value }', () => { + const { scopeManager } = parseAndAnalyze('class C { [fname] = value }'); + + const globalScope = scopeManager.scopes[0]; + expectToBeGlobalScope(globalScope); + + const classScope = globalScope.childScopes[0]; + // should create a class scope + expectToBeClassScope(classScope); + // The class scope has only the reference `fname`; it doesn't have the reference 'value'. + expect(classScope.references).toHaveLength(1); + expect(classScope.references[0].identifier.name).toBe('fname'); + + const classFieldInitializerScope = classScope.childScopes[0]; + // The class scope has a class-field-initializer scope. + expectToBeClassFieldInitializerScope(classFieldInitializerScope); + // The class-field-initializer scope has the reference 'value'. + expect(classFieldInitializerScope.references).toHaveLength(1); + expect(classFieldInitializerScope.references[0].identifier.name).toBe( + 'value', + ); + // The class-field-initializer scope has no variables. + expect(classFieldInitializerScope.variables).toHaveLength(0); + }); +}); diff --git a/packages/scope-manager/tests/fixtures/class/declaration/computed-member.ts.shot b/packages/scope-manager/tests/fixtures/class/declaration/computed-member.ts.shot index fa221e5e540d..87bcc27ae85a 100644 --- a/packages/scope-manager/tests/fixtures/class/declaration/computed-member.ts.shot +++ b/packages/scope-manager/tests/fixtures/class/declaration/computed-member.ts.shot @@ -137,8 +137,17 @@ ScopeManager { Variable$5, ], }, - FunctionScope$3 { - block: FunctionExpression$7, + ClassFieldInitializerScope$3 { + block: Literal$7, + isStrict: true, + references: Array [], + set: Map {}, + type: "class-field-initializer", + upper: ClassScope$2, + variables: Array [], + }, + FunctionScope$4 { + block: FunctionExpression$8, isStrict: true, references: Array [], set: Map { diff --git a/packages/scope-manager/tests/fixtures/class/declaration/properties.ts b/packages/scope-manager/tests/fixtures/class/declaration/properties.ts index c047395435ad..e75d9def3e96 100644 --- a/packages/scope-manager/tests/fixtures/class/declaration/properties.ts +++ b/packages/scope-manager/tests/fixtures/class/declaration/properties.ts @@ -1,5 +1,7 @@ +const x = 1; class A { - prop = 1; + prop1 = 1; + prop2 = x; } -const unresolved = prop; +const unresolved = prop1; diff --git a/packages/scope-manager/tests/fixtures/class/declaration/properties.ts.shot b/packages/scope-manager/tests/fixtures/class/declaration/properties.ts.shot index 3592b97d80a5..180bf6246fb7 100644 --- a/packages/scope-manager/tests/fixtures/class/declaration/properties.ts.shot +++ b/packages/scope-manager/tests/fixtures/class/declaration/properties.ts.shot @@ -6,9 +6,40 @@ ScopeManager { ImplicitGlobalConstTypeVariable, Variable$2 { defs: Array [ - ClassNameDefinition$1 { + VariableDefinition$1 { + name: Identifier<"x">, + node: VariableDeclarator$1, + }, + ], + name: "x", + references: Array [ + Reference$1 { + identifier: Identifier<"x">, + init: true, + isRead: false, + isTypeReference: false, + isValueReference: true, + isWrite: true, + resolved: Variable$2, + writeExpr: Literal$2, + }, + Reference$2 { + identifier: Identifier<"x">, + isRead: true, + isTypeReference: false, + isValueReference: true, + isWrite: false, + resolved: Variable$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [ + ClassNameDefinition$2 { name: Identifier<"A">, - node: ClassDeclaration$1, + node: ClassDeclaration$3, }, ], name: "A", @@ -16,11 +47,11 @@ ScopeManager { isValueVariable: true, isTypeVariable: true, }, - Variable$3 { + Variable$4 { defs: Array [ - ClassNameDefinition$2 { + ClassNameDefinition$3 { name: Identifier<"A">, - node: ClassDeclaration$1, + node: ClassDeclaration$3, }, ], name: "A", @@ -28,24 +59,24 @@ ScopeManager { isValueVariable: true, isTypeVariable: true, }, - Variable$4 { + Variable$5 { defs: Array [ - VariableDefinition$3 { + VariableDefinition$4 { name: Identifier<"unresolved">, - node: VariableDeclarator$2, + node: VariableDeclarator$4, }, ], name: "unresolved", references: Array [ - Reference$1 { + Reference$3 { identifier: Identifier<"unresolved">, init: true, isRead: false, isTypeReference: false, isValueReference: true, isWrite: true, - resolved: Variable$4, - writeExpr: Identifier<"prop">, + resolved: Variable$5, + writeExpr: Identifier<"prop1">, }, ], isValueVariable: true, @@ -54,12 +85,13 @@ ScopeManager { ], scopes: Array [ GlobalScope$1 { - block: Program$3, + block: Program$5, isStrict: false, references: Array [ Reference$1, - Reference$2 { - identifier: Identifier<"prop">, + Reference$3, + Reference$4 { + identifier: Identifier<"prop1">, isRead: true, isTypeReference: false, isValueReference: true, @@ -69,29 +101,51 @@ ScopeManager { ], set: Map { "const" => ImplicitGlobalConstTypeVariable, - "A" => Variable$2, - "unresolved" => Variable$4, + "x" => Variable$2, + "A" => Variable$3, + "unresolved" => Variable$5, }, type: "global", upper: null, variables: Array [ ImplicitGlobalConstTypeVariable, Variable$2, - Variable$4, + Variable$3, + Variable$5, ], }, ClassScope$2 { - block: ClassDeclaration$1, + block: ClassDeclaration$3, isStrict: true, references: Array [], set: Map { - "A" => Variable$3, + "A" => Variable$4, }, type: "class", upper: GlobalScope$1, variables: Array [ - Variable$3, + Variable$4, + ], + }, + ClassFieldInitializerScope$3 { + block: Literal$6, + isStrict: true, + references: Array [], + set: Map {}, + type: "class-field-initializer", + upper: ClassScope$2, + variables: Array [], + }, + ClassFieldInitializerScope$4 { + block: Identifier<"x">, + isStrict: true, + references: Array [ + Reference$2, ], + set: Map {}, + type: "class-field-initializer", + upper: ClassScope$2, + variables: Array [], }, ], } diff --git a/packages/scope-manager/tests/fixtures/class/expression/computed-member.ts.shot b/packages/scope-manager/tests/fixtures/class/expression/computed-member.ts.shot index 25e96169fc75..f9080b0c6ee2 100644 --- a/packages/scope-manager/tests/fixtures/class/expression/computed-member.ts.shot +++ b/packages/scope-manager/tests/fixtures/class/expression/computed-member.ts.shot @@ -133,8 +133,17 @@ ScopeManager { upper: GlobalScope$1, variables: Array [], }, - FunctionScope$3 { - block: FunctionExpression$8, + ClassFieldInitializerScope$3 { + block: Literal$8, + isStrict: true, + references: Array [], + set: Map {}, + type: "class-field-initializer", + upper: ClassScope$2, + variables: Array [], + }, + FunctionScope$4 { + block: FunctionExpression$9, isStrict: true, references: Array [], set: Map { diff --git a/packages/scope-manager/tests/fixtures/class/expression/properties.ts b/packages/scope-manager/tests/fixtures/class/expression/properties.ts index 49b1efe6297e..508292413246 100644 --- a/packages/scope-manager/tests/fixtures/class/expression/properties.ts +++ b/packages/scope-manager/tests/fixtures/class/expression/properties.ts @@ -1,5 +1,7 @@ +const x = 1; const A = class { - prop = 1; + prop1 = 1; + prop2 = x; }; const unresolved = prop; diff --git a/packages/scope-manager/tests/fixtures/class/expression/properties.ts.shot b/packages/scope-manager/tests/fixtures/class/expression/properties.ts.shot index 261a24a50ecc..b5f489d2502b 100644 --- a/packages/scope-manager/tests/fixtures/class/expression/properties.ts.shot +++ b/packages/scope-manager/tests/fixtures/class/expression/properties.ts.shot @@ -7,21 +7,29 @@ ScopeManager { Variable$2 { defs: Array [ VariableDefinition$1 { - name: Identifier<"A">, + name: Identifier<"x">, node: VariableDeclarator$1, }, ], - name: "A", + name: "x", references: Array [ Reference$1 { - identifier: Identifier<"A">, + identifier: Identifier<"x">, init: true, isRead: false, isTypeReference: false, isValueReference: true, isWrite: true, resolved: Variable$2, - writeExpr: ClassExpression$2, + writeExpr: Literal$2, + }, + Reference$3 { + identifier: Identifier<"x">, + isRead: true, + isTypeReference: false, + isValueReference: true, + isWrite: false, + resolved: Variable$2, }, ], isValueVariable: true, @@ -30,20 +38,43 @@ ScopeManager { Variable$3 { defs: Array [ VariableDefinition$2 { - name: Identifier<"unresolved">, + name: Identifier<"A">, node: VariableDeclarator$3, }, ], - name: "unresolved", + name: "A", references: Array [ Reference$2 { - identifier: Identifier<"unresolved">, + identifier: Identifier<"A">, init: true, isRead: false, isTypeReference: false, isValueReference: true, isWrite: true, resolved: Variable$3, + writeExpr: ClassExpression$4, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$4 { + defs: Array [ + VariableDefinition$3 { + name: Identifier<"unresolved">, + node: VariableDeclarator$5, + }, + ], + name: "unresolved", + references: Array [ + Reference$4 { + identifier: Identifier<"unresolved">, + init: true, + isRead: false, + isTypeReference: false, + isValueReference: true, + isWrite: true, + resolved: Variable$4, writeExpr: Identifier<"prop">, }, ], @@ -53,12 +84,13 @@ ScopeManager { ], scopes: Array [ GlobalScope$1 { - block: Program$4, + block: Program$6, isStrict: false, references: Array [ Reference$1, Reference$2, - Reference$3 { + Reference$4, + Reference$5 { identifier: Identifier<"prop">, isRead: true, isTypeReference: false, @@ -69,8 +101,9 @@ ScopeManager { ], set: Map { "const" => ImplicitGlobalConstTypeVariable, - "A" => Variable$2, - "unresolved" => Variable$3, + "x" => Variable$2, + "A" => Variable$3, + "unresolved" => Variable$4, }, type: "global", upper: null, @@ -78,10 +111,11 @@ ScopeManager { ImplicitGlobalConstTypeVariable, Variable$2, Variable$3, + Variable$4, ], }, ClassScope$2 { - block: ClassExpression$2, + block: ClassExpression$4, isStrict: true, references: Array [], set: Map {}, @@ -89,6 +123,26 @@ ScopeManager { upper: GlobalScope$1, variables: Array [], }, + ClassFieldInitializerScope$3 { + block: Literal$7, + isStrict: true, + references: Array [], + set: Map {}, + type: "class-field-initializer", + upper: ClassScope$2, + variables: Array [], + }, + ClassFieldInitializerScope$4 { + block: Identifier<"x">, + isStrict: true, + references: Array [ + Reference$3, + ], + set: Map {}, + type: "class-field-initializer", + upper: ClassScope$2, + variables: Array [], + }, ], } `; diff --git a/packages/scope-manager/tests/util/expect.ts b/packages/scope-manager/tests/util/expect.ts index 0057af9f85c2..5609a923598b 100644 --- a/packages/scope-manager/tests/util/expect.ts +++ b/packages/scope-manager/tests/util/expect.ts @@ -14,6 +14,7 @@ import { BlockScope, CatchScope, ClassScope, + ClassFieldInitializerScope, ForScope, FunctionExpressionNameScope, FunctionScope, @@ -35,6 +36,11 @@ function expectToBeBlockScope(scope: Scope): asserts scope is BlockScope { function expectToBeCatchScope(scope: Scope): asserts scope is CatchScope { expect(scope.type).toBe(ScopeType.catch); } +function expectToBeClassFieldInitializerScope( + scope: Scope, +): asserts scope is ClassFieldInitializerScope { + expect(scope.type).toBe(ScopeType.classFieldInitializer); +} function expectToBeClassScope(scope: Scope): asserts scope is ClassScope { expect(scope.type).toBe(ScopeType.class); } @@ -65,6 +71,7 @@ function expectToBeWithScope(scope: Scope): asserts scope is WithScope { export { expectToBeBlockScope, expectToBeCatchScope, + expectToBeClassFieldInitializerScope, expectToBeClassScope, expectToBeForScope, expectToBeFunctionExpressionNameScope, diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index da5ba78fbf86..0846087759f3 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -1103,11 +1103,11 @@ export class Converter { case SyntaxKind.PropertyDeclaration: { const isAbstract = hasModifier(SyntaxKind.AbstractKeyword, node); const result = this.createNode< - TSESTree.TSAbstractClassProperty | TSESTree.ClassProperty + TSESTree.TSAbstractPropertyDefinition | TSESTree.PropertyDefinition >(node, { type: isAbstract - ? AST_NODE_TYPES.TSAbstractClassProperty - : AST_NODE_TYPES.ClassProperty, + ? AST_NODE_TYPES.TSAbstractPropertyDefinition + : AST_NODE_TYPES.PropertyDefinition, key: this.convertChild(node.name), value: isAbstract ? null : this.convertChild(node.initializer), computed: isComputedProperty(node.name), diff --git a/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts b/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts index 8faaef068d54..07b2bb5db318 100644 --- a/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts +++ b/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts @@ -28,7 +28,7 @@ export interface EstreeToTsNodeTypes { [AST_NODE_TYPES.ClassBody]: ts.ClassDeclaration | ts.ClassExpression; [AST_NODE_TYPES.ClassDeclaration]: ts.ClassDeclaration; [AST_NODE_TYPES.ClassExpression]: ts.ClassExpression; - [AST_NODE_TYPES.ClassProperty]: ts.PropertyDeclaration; + [AST_NODE_TYPES.PropertyDefinition]: ts.PropertyDeclaration; [AST_NODE_TYPES.ConditionalExpression]: ts.ConditionalExpression; [AST_NODE_TYPES.ContinueStatement]: ts.ContinueStatement; [AST_NODE_TYPES.DebuggerStatement]: ts.DebuggerStatement; @@ -150,7 +150,7 @@ export interface EstreeToTsNodeTypes { [AST_NODE_TYPES.ThisExpression]: ts.ThisExpression | ts.KeywordTypeNode; [AST_NODE_TYPES.ThrowStatement]: ts.ThrowStatement; [AST_NODE_TYPES.TryStatement]: ts.TryStatement; - [AST_NODE_TYPES.TSAbstractClassProperty]: ts.PropertyDeclaration; + [AST_NODE_TYPES.TSAbstractPropertyDefinition]: ts.PropertyDeclaration; [AST_NODE_TYPES.TSAbstractMethodDefinition]: | ts.GetAccessorDeclaration | ts.SetAccessorDeclaration diff --git a/packages/typescript-estree/tests/ast-alignment/parse.ts b/packages/typescript-estree/tests/ast-alignment/parse.ts index 0cf1898a321e..7d340278649e 100644 --- a/packages/typescript-estree/tests/ast-alignment/parse.ts +++ b/packages/typescript-estree/tests/ast-alignment/parse.ts @@ -24,10 +24,15 @@ function createError( function parseWithBabelParser(text: string, jsx = true): File { const babel = require('@babel/parser') as typeof babelParser; const plugins: ParserPlugin[] = [ - 'classProperties', + [ + 'estree', + { + // @ts-expect-error -- this isn't exposed in the types yet + classFeatures: true, + }, + ], 'decorators-legacy', 'classStaticBlock', - 'estree', 'typescript', ]; if (jsx) { diff --git a/packages/typescript-estree/tests/ast-alignment/utils.ts b/packages/typescript-estree/tests/ast-alignment/utils.ts index 1bfd73b2cb88..ad3500c89911 100644 --- a/packages/typescript-estree/tests/ast-alignment/utils.ts +++ b/packages/typescript-estree/tests/ast-alignment/utils.ts @@ -168,13 +168,15 @@ export function preprocessBabylonAST(ast: BabelTypes.File): any { node.override = false; } }, - ClassProperty(node) { + PropertyDefinition(node) { + // babel does not + // node.type = AST_NODE_TYPES.PropertyDefinition; /** * Babel: ClassProperty + abstract: true * ts-estree: TSAbstractClassProperty */ if (node.abstract) { - node.type = AST_NODE_TYPES.TSAbstractClassProperty; + node.type = AST_NODE_TYPES.TSAbstractPropertyDefinition; delete node.abstract; node.value = null; } diff --git a/packages/typescript-estree/tests/lib/__snapshots__/semanticInfo.test.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/semanticInfo.test.ts.snap index 0fe1c5a0c57e..ce899d6636cb 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/semanticInfo.test.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/semanticInfo.test.ts.snap @@ -1292,7 +1292,7 @@ Object { 56, ], "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "typeAnnotation": Object { "loc": Object { "end": Object { diff --git a/packages/typescript-estree/tests/lib/semanticInfo.test.ts b/packages/typescript-estree/tests/lib/semanticInfo.test.ts index ccce1f6e4c8d..c003d8d00466 100644 --- a/packages/typescript-estree/tests/lib/semanticInfo.test.ts +++ b/packages/typescript-estree/tests/lib/semanticInfo.test.ts @@ -161,7 +161,7 @@ describe('semanticInfo', () => { const computedPropertyString = ( (parseResult.ast.body[1] as TSESTree.ClassDeclaration).body - .body[0] as TSESTree.ClassProperty + .body[0] as TSESTree.PropertyDefinition ).key; const tsComputedPropertyString = parseResult.services.esTreeNodeToTSNodeMap.get(computedPropertyString); diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-class-with-abstract-properties.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-class-with-abstract-properties.src.ts.shot index ffbc6466b98a..34ca54e31bb1 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-class-with-abstract-properties.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-class-with-abstract-properties.src.ts.shot @@ -45,7 +45,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "TSAbstractClassProperty", + "type": "TSAbstractPropertyDefinition", "value": null, }, Object { @@ -86,7 +86,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "TSAbstractClassProperty", + "type": "TSAbstractPropertyDefinition", "typeAnnotation": Object { "loc": Object { "end": Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-class-with-abstract-readonly-property.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-class-with-abstract-readonly-property.src.ts.shot index 61229f3a6121..66cc1ade4909 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-class-with-abstract-readonly-property.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-class-with-abstract-readonly-property.src.ts.shot @@ -46,7 +46,7 @@ Object { ], "readonly": true, "static": false, - "type": "TSAbstractClassProperty", + "type": "TSAbstractPropertyDefinition", "typeAnnotation": Object { "loc": Object { "end": Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-class-with-declare-properties.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-class-with-declare-properties.src.ts.shot index d6ebb066f30e..2ba070b7a0bc 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-class-with-declare-properties.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-class-with-declare-properties.src.ts.shot @@ -45,7 +45,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "typeAnnotation": Object { "loc": Object { "end": Object { @@ -120,7 +120,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "TSAbstractClassProperty", + "type": "TSAbstractPropertyDefinition", "typeAnnotation": Object { "loc": Object { "end": Object { @@ -196,7 +196,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "TSAbstractClassProperty", + "type": "TSAbstractPropertyDefinition", "typeAnnotation": Object { "loc": Object { "end": Object { @@ -271,7 +271,7 @@ Object { ], "readonly": true, "static": false, - "type": "TSAbstractClassProperty", + "type": "TSAbstractPropertyDefinition", "typeAnnotation": Object { "loc": Object { "end": Object { @@ -347,7 +347,7 @@ Object { ], "readonly": true, "static": false, - "type": "TSAbstractClassProperty", + "type": "TSAbstractPropertyDefinition", "typeAnnotation": Object { "loc": Object { "end": Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-class-with-override-property.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-class-with-override-property.src.ts.shot index 005003a72ef8..d22f508108d0 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-class-with-override-property.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/abstract-class-with-override-property.src.ts.shot @@ -45,7 +45,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "TSAbstractClassProperty", + "type": "TSAbstractPropertyDefinition", "value": null, }, ], diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/class-static-blocks.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/class-static-blocks.src.ts.shot index e370e9e24ea1..761783ccd1d6 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/class-static-blocks.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/class-static-blocks.src.ts.shot @@ -44,7 +44,7 @@ Object { ], "readonly": undefined, "static": true, - "type": "ClassProperty", + "type": "PropertyDefinition", "value": Object { "loc": Object { "end": Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-accessibility-modifiers.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-accessibility-modifiers.src.ts.shot index 67d8ef501e3b..72b6e487ad10 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-accessibility-modifiers.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-accessibility-modifiers.src.ts.shot @@ -45,7 +45,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "typeAnnotation": Object { "loc": Object { "end": Object { @@ -121,7 +121,7 @@ Object { ], "readonly": undefined, "static": true, - "type": "ClassProperty", + "type": "PropertyDefinition", "typeAnnotation": Object { "loc": Object { "end": Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-declare-properties.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-declare-properties.src.ts.shot index 5de10062c2d5..d42896e1914c 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-declare-properties.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-declare-properties.src.ts.shot @@ -44,7 +44,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "typeAnnotation": Object { "loc": Object { "end": Object { @@ -120,7 +120,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "typeAnnotation": Object { "loc": Object { "end": Object { @@ -195,7 +195,7 @@ Object { ], "readonly": undefined, "static": true, - "type": "ClassProperty", + "type": "PropertyDefinition", "typeAnnotation": Object { "loc": Object { "end": Object { @@ -270,7 +270,7 @@ Object { ], "readonly": true, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "typeAnnotation": Object { "loc": Object { "end": Object { @@ -346,7 +346,7 @@ Object { ], "readonly": true, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "typeAnnotation": Object { "loc": Object { "end": Object { @@ -422,7 +422,7 @@ Object { ], "readonly": undefined, "static": true, - "type": "ClassProperty", + "type": "PropertyDefinition", "typeAnnotation": Object { "loc": Object { "end": Object { @@ -498,7 +498,7 @@ Object { ], "readonly": true, "static": true, - "type": "ClassProperty", + "type": "PropertyDefinition", "typeAnnotation": Object { "loc": Object { "end": Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-definite-assignment.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-definite-assignment.src.ts.shot index 00d59df785b5..8c358d12d205 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-definite-assignment.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-definite-assignment.src.ts.shot @@ -45,7 +45,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "typeAnnotation": Object { "loc": Object { "end": Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-optional-computed-property.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-optional-computed-property.src.ts.shot index 31128d9a73bb..13e6452c8591 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-optional-computed-property.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-optional-computed-property.src.ts.shot @@ -47,7 +47,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "value": Object { "loc": Object { "end": Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-optional-properties.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-optional-properties.src.ts.shot index 3905565b51e0..048f000b9e2f 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-optional-properties.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-optional-properties.src.ts.shot @@ -193,7 +193,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "value": null, }, Object { @@ -235,7 +235,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "typeAnnotation": Object { "loc": Object { "end": Object { @@ -312,7 +312,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "typeAnnotation": Object { "loc": Object { "end": Object { @@ -388,7 +388,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "value": null, }, Object { @@ -431,7 +431,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "value": null, }, Object { @@ -474,7 +474,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "value": null, }, Object { @@ -516,7 +516,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "typeAnnotation": Object { "loc": Object { "end": Object { @@ -593,7 +593,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "typeAnnotation": Object { "loc": Object { "end": Object { @@ -670,7 +670,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "typeAnnotation": Object { "loc": Object { "end": Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-optional-property-undefined.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-optional-property-undefined.src.ts.shot index e3f8ea37bde3..c5fd8a1fd1aa 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-optional-property-undefined.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-optional-property-undefined.src.ts.shot @@ -46,7 +46,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "value": Object { "loc": Object { "end": Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-override-property.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-override-property.src.ts.shot index 30a584f5f6da..49a33895f9d4 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-override-property.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-override-property.src.ts.shot @@ -44,7 +44,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "value": Object { "loc": Object { "end": Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-property-function.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-property-function.src.ts.shot index fbf79a0e8592..1705e340f45f 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-property-function.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-property-function.src.ts.shot @@ -44,7 +44,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "typeAnnotation": Object { "loc": Object { "end": Object { @@ -228,7 +228,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "typeAnnotation": Object { "loc": Object { "end": Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-property-values.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-property-values.src.ts.shot index e9ca7ddbc2ac..a2238f57f0db 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-property-values.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-property-values.src.ts.shot @@ -44,7 +44,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "value": Object { "loc": Object { "end": Object { @@ -103,7 +103,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "value": Object { "loc": Object { "end": Object { @@ -161,7 +161,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "value": Object { "elements": Array [], "loc": Object { @@ -219,7 +219,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "value": Object { "loc": Object { "end": Object { @@ -278,7 +278,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "value": Object { "arguments": Array [ Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-readonly-property.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-readonly-property.src.ts.shot index 23d24a88952e..c3fc1acb2af1 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-readonly-property.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/class-with-readonly-property.src.ts.shot @@ -45,7 +45,7 @@ Object { ], "readonly": true, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "value": Object { "loc": Object { "end": Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/object-with-escaped-properties.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/object-with-escaped-properties.src.ts.shot index 8ef720aba18d..4373bd4bb671 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/object-with-escaped-properties.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/object-with-escaped-properties.src.ts.shot @@ -351,7 +351,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "value": Object { "loc": Object { "end": Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/type-assertion-in-method.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/type-assertion-in-method.src.ts.shot index d2ee9293ca2e..8f61a28350af 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/type-assertion-in-method.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/type-assertion-in-method.src.ts.shot @@ -195,7 +195,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "value": Object { "async": false, "body": Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/type-assertion-with-guard-in-method.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/type-assertion-with-guard-in-method.src.ts.shot index e9af3cb75909..abfccafd6245 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/type-assertion-with-guard-in-method.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/type-assertion-with-guard-in-method.src.ts.shot @@ -228,7 +228,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "value": Object { "async": false, "body": Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/type-guard-in-method.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/type-guard-in-method.src.ts.shot index f97f275b6905..9d4fe4c33ca7 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/type-guard-in-method.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/type-guard-in-method.src.ts.shot @@ -280,7 +280,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "value": Object { "async": false, "body": Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/type-reference-comments.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/type-reference-comments.src.ts.shot index 4e24a2d0e02a..50ce8ec40fd5 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/basics/type-reference-comments.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/type-reference-comments.src.ts.shot @@ -44,7 +44,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "typeAnnotation": Object { "loc": Object { "end": Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/decorators/property-decorators/property-decorator-factory-instance-member.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/decorators/property-decorators/property-decorator-factory-instance-member.src.ts.shot index 792ec79028f0..2dec783b8b49 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/decorators/property-decorators/property-decorator-factory-instance-member.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/decorators/property-decorators/property-decorator-factory-instance-member.src.ts.shot @@ -100,7 +100,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "value": null, }, Object { @@ -197,7 +197,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "value": Object { "arguments": Array [], "callee": Object { diff --git a/packages/typescript-estree/tests/snapshots/typescript/decorators/property-decorators/property-decorator-factory-static-member.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/decorators/property-decorators/property-decorator-factory-static-member.src.ts.shot index 616d39ed3670..53043405565c 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/decorators/property-decorators/property-decorator-factory-static-member.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/decorators/property-decorators/property-decorator-factory-static-member.src.ts.shot @@ -120,7 +120,7 @@ Object { ], "readonly": undefined, "static": true, - "type": "ClassProperty", + "type": "PropertyDefinition", "value": null, }, Object { @@ -237,7 +237,7 @@ Object { ], "readonly": undefined, "static": true, - "type": "ClassProperty", + "type": "PropertyDefinition", "value": null, }, ], diff --git a/packages/typescript-estree/tests/snapshots/typescript/decorators/property-decorators/property-decorator-instance-member.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/decorators/property-decorators/property-decorator-instance-member.src.ts.shot index 7ba24aa3ef5d..95ccdf95a30a 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/decorators/property-decorators/property-decorator-instance-member.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/decorators/property-decorators/property-decorator-instance-member.src.ts.shot @@ -81,7 +81,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "value": null, }, Object { @@ -159,7 +159,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "value": null, }, ], diff --git a/packages/typescript-estree/tests/snapshots/typescript/decorators/property-decorators/property-decorator-static-member.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/decorators/property-decorators/property-decorator-static-member.src.ts.shot index 9e4706080cd7..60c9860bfd0b 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/decorators/property-decorators/property-decorator-static-member.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/decorators/property-decorators/property-decorator-static-member.src.ts.shot @@ -81,7 +81,7 @@ Object { ], "readonly": undefined, "static": true, - "type": "ClassProperty", + "type": "PropertyDefinition", "value": null, }, Object { @@ -159,7 +159,7 @@ Object { ], "readonly": undefined, "static": true, - "type": "ClassProperty", + "type": "PropertyDefinition", "value": null, }, ], diff --git a/packages/typescript-estree/tests/snapshots/typescript/types/this-type-expanded.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/types/this-type-expanded.src.ts.shot index d936454024a7..5543bc1a3a01 100644 --- a/packages/typescript-estree/tests/snapshots/typescript/types/this-type-expanded.src.ts.shot +++ b/packages/typescript-estree/tests/snapshots/typescript/types/this-type-expanded.src.ts.shot @@ -45,7 +45,7 @@ Object { ], "readonly": undefined, "static": false, - "type": "ClassProperty", + "type": "PropertyDefinition", "typeAnnotation": Object { "loc": Object { "end": Object { diff --git a/packages/visitor-keys/src/visitor-keys.ts b/packages/visitor-keys/src/visitor-keys.ts index 6430592217c2..bd1f3186d839 100644 --- a/packages/visitor-keys/src/visitor-keys.ts +++ b/packages/visitor-keys/src/visitor-keys.ts @@ -48,6 +48,7 @@ const additionalKeys: AdditionalKeys = { MethodDefinition: ['decorators', 'key', 'value'], NewExpression: ['callee', 'typeParameters', 'arguments'], ObjectPattern: ['decorators', 'properties', 'typeAnnotation'], + PropertyDefinition: ['decorators', 'key', 'typeAnnotation', 'value'], RestElement: ['decorators', 'argument', 'typeAnnotation'], TaggedTemplateExpression: ['tag', 'typeParameters', 'quasi'], StaticBlock: ['body'], @@ -59,13 +60,12 @@ const additionalKeys: AdditionalKeys = { JSXSpreadChild: ['expression'], // Additional Nodes. - ClassProperty: ['decorators', 'key', 'typeAnnotation', 'value'], Decorator: ['expression'], // TS-prefixed nodes - TSAbstractClassProperty: ['decorators', 'key', 'typeAnnotation'], TSAbstractKeyword: [], TSAbstractMethodDefinition: ['key', 'value'], + TSAbstractPropertyDefinition: ['decorators', 'key', 'typeAnnotation'], TSAnyKeyword: [], TSArrayType: ['elementType'], TSAsExpression: ['expression', 'typeAnnotation'], From 0eefe5e49d21af3f1e3e2d9a90c2e49929863ac2 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Sat, 28 Aug 2021 18:18:40 -0700 Subject: [PATCH 33/44] feat: support `PrivateIdentifier` (#3808) Closes #3430 Resolves #2933 --- packages/ast-spec/src/ast-node-types.ts | 1 + .../ast-spec/src/base/MethodDefinitionBase.ts | 7 + .../src/base/PropertyDefinitionBase.ts | 7 + .../src/element/MethodDefinition/spec.ts | 4 +- .../src/element/PropertyDefinition/spec.ts | 4 +- .../TSAbstractMethodDefinition/spec.ts | 1 + .../TSAbstractPropertyDefinition/spec.ts | 1 + .../src/expression/MemberExpression/spec.ts | 5 +- .../src/special/PrivateIdentifier/spec.ts | 7 + packages/ast-spec/src/special/spec.ts | 1 + packages/ast-spec/src/unions/Node.ts | 2 + packages/ast-spec/src/unions/PropertyName.ts | 10 +- .../src/rules/adjacent-overload-signatures.ts | 15 +- .../rules/explicit-member-accessibility.ts | 11 +- .../src/rules/member-ordering.ts | 6 +- .../rules/naming-convention-utils/types.ts | 2 +- .../naming-convention-utils/validator.ts | 19 +- .../src/rules/naming-convention.ts | 7 +- .../eslint-plugin/src/rules/prefer-for-of.ts | 2 +- packages/eslint-plugin/src/util/misc.ts | 40 +- .../adjacent-overload-signatures.test.ts | 37 + .../explicit-member-accessibility.test.ts | 68 ++ .../tests/rules/member-ordering.test.ts | 40 + .../tests/rules/naming-convention.test.ts | 7 + .../src/referencer/ClassVisitor.ts | 4 + .../src/referencer/Referencer.ts | 4 + .../class/declaration/private-identifier.ts | 7 + .../declaration/private-identifier.ts.shot | 83 ++ .../class/expression/private-identifier.ts | 7 + .../expression/private-identifier.ts.shot | 80 ++ .../class-private-identifier-accessor.src.js | 8 + .../class-private-identifier-field.src.js | 8 + .../class-private-identifier-method.src.js | 7 + ...fier-field-with-accessibility-error.src.ts | 5 + ...te-identifier-field-with-annotation.src.ts | 8 + ...s-private-identifier-readonly-field.src.ts | 3 + packages/types/tools/copy-ast-spec.ts | 2 +- packages/typescript-estree/src/convert.ts | 8 + .../src/ts-estree/estree-to-ts-node-types.ts | 1 + .../src/ts-estree/ts-nodes.ts | 3 + .../tests/ast-alignment/fixtures-to-test.ts | 15 + .../semantic-diagnostics-enabled.test.ts.snap | 12 + ...ss-private-identifier-accessor.src.js.shot | 1024 +++++++++++++++++ ...class-private-identifier-field.src.js.shot | 748 ++++++++++++ ...lass-private-identifier-method.src.js.shot | 691 +++++++++++ ...field-with-accessibility-error.src.ts.shot | 597 ++++++++++ ...entifier-field-with-annotation.src.ts.shot | 888 ++++++++++++++ ...vate-identifier-readonly-field.src.ts.shot | 301 +++++ packages/visitor-keys/package.json | 2 +- 49 files changed, 4786 insertions(+), 34 deletions(-) create mode 100644 packages/ast-spec/src/special/PrivateIdentifier/spec.ts create mode 100644 packages/scope-manager/tests/fixtures/class/declaration/private-identifier.ts create mode 100644 packages/scope-manager/tests/fixtures/class/declaration/private-identifier.ts.shot create mode 100644 packages/scope-manager/tests/fixtures/class/expression/private-identifier.ts create mode 100644 packages/scope-manager/tests/fixtures/class/expression/private-identifier.ts.shot create mode 100644 packages/shared-fixtures/fixtures/javascript/classes/class-private-identifier-accessor.src.js create mode 100644 packages/shared-fixtures/fixtures/javascript/classes/class-private-identifier-field.src.js create mode 100644 packages/shared-fixtures/fixtures/javascript/classes/class-private-identifier-method.src.js create mode 100644 packages/shared-fixtures/fixtures/typescript/basics/class-private-identifier-field-with-accessibility-error.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/basics/class-private-identifier-field-with-annotation.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/basics/class-private-identifier-readonly-field.src.ts create mode 100644 packages/typescript-estree/tests/snapshots/javascript/classes/class-private-identifier-accessor.src.js.shot create mode 100644 packages/typescript-estree/tests/snapshots/javascript/classes/class-private-identifier-field.src.js.shot create mode 100644 packages/typescript-estree/tests/snapshots/javascript/classes/class-private-identifier-method.src.js.shot create mode 100644 packages/typescript-estree/tests/snapshots/typescript/basics/class-private-identifier-field-with-accessibility-error.src.ts.shot create mode 100644 packages/typescript-estree/tests/snapshots/typescript/basics/class-private-identifier-field-with-annotation.src.ts.shot create mode 100644 packages/typescript-estree/tests/snapshots/typescript/basics/class-private-identifier-readonly-field.src.ts.shot diff --git a/packages/ast-spec/src/ast-node-types.ts b/packages/ast-spec/src/ast-node-types.ts index 3f6b2a81082a..c5ee4a189df4 100644 --- a/packages/ast-spec/src/ast-node-types.ts +++ b/packages/ast-spec/src/ast-node-types.ts @@ -61,6 +61,7 @@ export enum AST_NODE_TYPES { NewExpression = 'NewExpression', ObjectExpression = 'ObjectExpression', ObjectPattern = 'ObjectPattern', + PrivateIdentifier = 'PrivateIdentifier', Program = 'Program', Property = 'Property', PropertyDefinition = 'PropertyDefinition', diff --git a/packages/ast-spec/src/base/MethodDefinitionBase.ts b/packages/ast-spec/src/base/MethodDefinitionBase.ts index afdea67bcd7b..f1f2087ccae8 100644 --- a/packages/ast-spec/src/base/MethodDefinitionBase.ts +++ b/packages/ast-spec/src/base/MethodDefinitionBase.ts @@ -3,6 +3,7 @@ import type { TSEmptyBodyFunctionExpression } from '../expression/TSEmptyBodyFun import type { Decorator } from '../special/Decorator/spec'; import type { TSTypeParameterDeclaration } from '../special/TSTypeParameterDeclaration/spec'; import type { + ClassPropertyNameNonComputed, PropertyName, PropertyNameComputed, PropertyNameNonComputed, @@ -34,3 +35,9 @@ export interface MethodDefinitionNonComputedNameBase key: PropertyNameNonComputed; computed: false; } + +export interface ClassMethodDefinitionNonComputedNameBase + extends MethodDefinitionBase { + key: ClassPropertyNameNonComputed; + computed: false; +} diff --git a/packages/ast-spec/src/base/PropertyDefinitionBase.ts b/packages/ast-spec/src/base/PropertyDefinitionBase.ts index a70a21479ae7..f1d5b9cc4402 100644 --- a/packages/ast-spec/src/base/PropertyDefinitionBase.ts +++ b/packages/ast-spec/src/base/PropertyDefinitionBase.ts @@ -2,6 +2,7 @@ import type { Decorator } from '../special/Decorator/spec'; import type { TSTypeAnnotation } from '../special/TSTypeAnnotation/spec'; import type { Expression } from '../unions/Expression'; import type { + ClassPropertyNameNonComputed, PropertyName, PropertyNameComputed, PropertyNameNonComputed, @@ -35,3 +36,9 @@ export interface PropertyDefinitionNonComputedNameBase key: PropertyNameNonComputed; computed: false; } + +export interface ClassPropertyDefinitionNonComputedNameBase + extends PropertyDefinitionBase { + key: ClassPropertyNameNonComputed; + computed: false; +} diff --git a/packages/ast-spec/src/element/MethodDefinition/spec.ts b/packages/ast-spec/src/element/MethodDefinition/spec.ts index f097f9f8e854..c02aa19b5df3 100644 --- a/packages/ast-spec/src/element/MethodDefinition/spec.ts +++ b/packages/ast-spec/src/element/MethodDefinition/spec.ts @@ -1,7 +1,7 @@ import type { AST_NODE_TYPES } from '../../ast-node-types'; import type { + ClassMethodDefinitionNonComputedNameBase, MethodDefinitionComputedNameBase, - MethodDefinitionNonComputedNameBase, } from '../../base/MethodDefinitionBase'; export interface MethodDefinitionComputedName @@ -10,7 +10,7 @@ export interface MethodDefinitionComputedName } export interface MethodDefinitionNonComputedName - extends MethodDefinitionNonComputedNameBase { + extends ClassMethodDefinitionNonComputedNameBase { type: AST_NODE_TYPES.MethodDefinition; } diff --git a/packages/ast-spec/src/element/PropertyDefinition/spec.ts b/packages/ast-spec/src/element/PropertyDefinition/spec.ts index 4f79c2eb8345..d249b140e661 100644 --- a/packages/ast-spec/src/element/PropertyDefinition/spec.ts +++ b/packages/ast-spec/src/element/PropertyDefinition/spec.ts @@ -1,7 +1,7 @@ import type { AST_NODE_TYPES } from '../../ast-node-types'; import type { + ClassPropertyDefinitionNonComputedNameBase, PropertyDefinitionComputedNameBase, - PropertyDefinitionNonComputedNameBase, } from '../../base/PropertyDefinitionBase'; export interface PropertyDefinitionComputedName @@ -10,7 +10,7 @@ export interface PropertyDefinitionComputedName } export interface PropertyDefinitionNonComputedName - extends PropertyDefinitionNonComputedNameBase { + extends ClassPropertyDefinitionNonComputedNameBase { type: AST_NODE_TYPES.PropertyDefinition; } diff --git a/packages/ast-spec/src/element/TSAbstractMethodDefinition/spec.ts b/packages/ast-spec/src/element/TSAbstractMethodDefinition/spec.ts index a8f5a05c50ab..ad2c3f7e51ff 100644 --- a/packages/ast-spec/src/element/TSAbstractMethodDefinition/spec.ts +++ b/packages/ast-spec/src/element/TSAbstractMethodDefinition/spec.ts @@ -10,6 +10,7 @@ export interface TSAbstractMethodDefinitionComputedName } export interface TSAbstractMethodDefinitionNonComputedName + // this does not extend ClassMethodDefinitionNonComputedNameBase because abstract private names are not allowed extends MethodDefinitionNonComputedNameBase { type: AST_NODE_TYPES.TSAbstractMethodDefinition; } diff --git a/packages/ast-spec/src/element/TSAbstractPropertyDefinition/spec.ts b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/spec.ts index c7032669fc9f..efa41b3bd364 100644 --- a/packages/ast-spec/src/element/TSAbstractPropertyDefinition/spec.ts +++ b/packages/ast-spec/src/element/TSAbstractPropertyDefinition/spec.ts @@ -11,6 +11,7 @@ export interface TSAbstractPropertyDefinitionComputedName } export interface TSAbstractPropertyDefinitionNonComputedName + // this does not extend ClassPropertyDefinitionNonComputedNameBase because abstract private names are not allowed extends PropertyDefinitionNonComputedNameBase { type: AST_NODE_TYPES.TSAbstractPropertyDefinition; value: null; diff --git a/packages/ast-spec/src/expression/MemberExpression/spec.ts b/packages/ast-spec/src/expression/MemberExpression/spec.ts index 92bad8cf3dc3..260574cc59f9 100644 --- a/packages/ast-spec/src/expression/MemberExpression/spec.ts +++ b/packages/ast-spec/src/expression/MemberExpression/spec.ts @@ -1,12 +1,13 @@ import type { AST_NODE_TYPES } from '../../ast-node-types'; import type { BaseNode } from '../../base/BaseNode'; +import type { PrivateIdentifier } from '../../special/PrivateIdentifier/spec'; import type { Expression } from '../../unions/Expression'; import type { LeftHandSideExpression } from '../../unions/LeftHandSideExpression'; import type { Identifier } from '../Identifier/spec'; interface MemberExpressionBase extends BaseNode { object: LeftHandSideExpression; - property: Expression | Identifier; + property: Expression | Identifier | PrivateIdentifier; computed: boolean; optional: boolean; } @@ -19,7 +20,7 @@ export interface MemberExpressionComputedName extends MemberExpressionBase { export interface MemberExpressionNonComputedName extends MemberExpressionBase { type: AST_NODE_TYPES.MemberExpression; - property: Identifier; + property: Identifier | PrivateIdentifier; computed: false; } diff --git a/packages/ast-spec/src/special/PrivateIdentifier/spec.ts b/packages/ast-spec/src/special/PrivateIdentifier/spec.ts new file mode 100644 index 000000000000..f1d2172b8374 --- /dev/null +++ b/packages/ast-spec/src/special/PrivateIdentifier/spec.ts @@ -0,0 +1,7 @@ +import type { AST_NODE_TYPES } from '../../ast-node-types'; +import type { BaseNode } from '../../base/BaseNode'; + +export interface PrivateIdentifier extends BaseNode { + type: AST_NODE_TYPES.PrivateIdentifier; + name: string; +} diff --git a/packages/ast-spec/src/special/spec.ts b/packages/ast-spec/src/special/spec.ts index 07142e15c8f9..91e5037751d7 100644 --- a/packages/ast-spec/src/special/spec.ts +++ b/packages/ast-spec/src/special/spec.ts @@ -6,6 +6,7 @@ export * from './ExportSpecifier/spec'; export * from './ImportDefaultSpecifier/spec'; export * from './ImportNamespaceSpecifier/spec'; export * from './ImportSpecifier/spec'; +export * from './PrivateIdentifier/spec'; export * from './Program/spec'; export * from './SwitchCase/spec'; export * from './TSClassImplements/spec'; diff --git a/packages/ast-spec/src/unions/Node.ts b/packages/ast-spec/src/unions/Node.ts index 4b3c54a09eb9..ba2b07bf4d4d 100644 --- a/packages/ast-spec/src/unions/Node.ts +++ b/packages/ast-spec/src/unions/Node.ts @@ -82,6 +82,7 @@ import type { ExportSpecifier } from '../special/ExportSpecifier/spec'; import type { ImportDefaultSpecifier } from '../special/ImportDefaultSpecifier/spec'; import type { ImportNamespaceSpecifier } from '../special/ImportNamespaceSpecifier/spec'; import type { ImportSpecifier } from '../special/ImportSpecifier/spec'; +import type { PrivateIdentifier } from '../special/PrivateIdentifier/spec'; import type { Program } from '../special/Program/spec'; import type { SwitchCase } from '../special/SwitchCase/spec'; import type { TemplateElement } from '../special/TemplateElement/spec'; @@ -228,6 +229,7 @@ export type Node = | NewExpression | ObjectExpression | ObjectPattern + | PrivateIdentifier | Program | Property | PropertyDefinition diff --git a/packages/ast-spec/src/unions/PropertyName.ts b/packages/ast-spec/src/unions/PropertyName.ts index 56ba04cabbea..dce45834d7f6 100644 --- a/packages/ast-spec/src/unions/PropertyName.ts +++ b/packages/ast-spec/src/unions/PropertyName.ts @@ -1,11 +1,19 @@ import type { Identifier } from '../expression/Identifier/spec'; import type { NumberLiteral } from '../expression/literal/NumberLiteral/spec'; import type { StringLiteral } from '../expression/literal/StringLiteral/spec'; +import type { PrivateIdentifier } from '../special/PrivateIdentifier/spec'; import type { Expression } from '../unions/Expression'; -export type PropertyName = PropertyNameComputed | PropertyNameNonComputed; +export type PropertyName = + | ClassPropertyNameNonComputed + | PropertyNameComputed + | PropertyNameNonComputed; export type PropertyNameComputed = Expression; export type PropertyNameNonComputed = | Identifier | NumberLiteral | StringLiteral; +export type ClassPropertyNameNonComputed = + | PrivateIdentifier + // only class properties can have private identifiers as their names + | PropertyNameNonComputed; diff --git a/packages/eslint-plugin/src/rules/adjacent-overload-signatures.ts b/packages/eslint-plugin/src/rules/adjacent-overload-signatures.ts index 273b6c6bfb9b..c0eec499ab3e 100644 --- a/packages/eslint-plugin/src/rules/adjacent-overload-signatures.ts +++ b/packages/eslint-plugin/src/rules/adjacent-overload-signatures.ts @@ -25,7 +25,7 @@ export default util.createRule({ }, schema: [], messages: { - adjacentSignature: "All '{{name}}' signatures should be adjacent.", + adjacentSignature: 'All {{name}} signatures should be adjacent.', }, }, defaultOptions: [], @@ -36,6 +36,7 @@ export default util.createRule({ name: string; static: boolean; callSignature: boolean; + type: util.MemberNameType; } /** @@ -71,11 +72,12 @@ export default util.createRule({ name, static: isStatic, callSignature: false, + type: util.MemberNameType.Normal, }; } case AST_NODE_TYPES.TSMethodSignature: return { - name: util.getNameFromMember(member, sourceCode), + ...util.getNameFromMember(member, sourceCode), static: isStatic, callSignature: false, }; @@ -84,16 +86,18 @@ export default util.createRule({ name: 'call', static: isStatic, callSignature: true, + type: util.MemberNameType.Normal, }; case AST_NODE_TYPES.TSConstructSignatureDeclaration: return { name: 'new', static: isStatic, callSignature: false, + type: util.MemberNameType.Normal, }; case AST_NODE_TYPES.MethodDefinition: return { - name: util.getNameFromMember(member, sourceCode), + ...util.getNameFromMember(member, sourceCode), static: isStatic, callSignature: false, }; @@ -107,7 +111,8 @@ export default util.createRule({ !!method2 && method1.name === method2.name && method1.static === method2.static && - method1.callSignature === method2.callSignature + method1.callSignature === method2.callSignature && + method1.type === method2.type ); } @@ -150,7 +155,7 @@ export default util.createRule({ node: member, messageId: 'adjacentSignature', data: { - name: (method.static ? 'static ' : '') + method.name, + name: `${method.static ? 'static ' : ''}${method.name}`, }, }); } else if (index === -1) { diff --git a/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts b/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts index 2e73af17354b..a8522f1b87c0 100644 --- a/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts +++ b/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts @@ -113,6 +113,10 @@ export default util.createRule({ function checkMethodAccessibilityModifier( methodDefinition: TSESTree.MethodDefinition, ): void { + if (methodDefinition.key.type === AST_NODE_TYPES.PrivateIdentifier) { + return; + } + let nodeType = 'method definition'; let check = baseCheck; switch (methodDefinition.kind) { @@ -129,7 +133,10 @@ export default util.createRule({ break; } - const methodName = util.getNameFromMember(methodDefinition, sourceCode); + const { name: methodName } = util.getNameFromMember( + methodDefinition, + sourceCode, + ); if (check === 'off' || ignoredMethodNames.has(methodName)) { return; @@ -205,7 +212,7 @@ export default util.createRule({ ): void { const nodeType = 'class property'; - const propertyName = util.getNameFromMember( + const { name: propertyName } = util.getNameFromMember( propertyDefinition, sourceCode, ); diff --git a/packages/eslint-plugin/src/rules/member-ordering.ts b/packages/eslint-plugin/src/rules/member-ordering.ts index 9f88228449b4..c1e30adc2ef5 100644 --- a/packages/eslint-plugin/src/rules/member-ordering.ts +++ b/packages/eslint-plugin/src/rules/member-ordering.ts @@ -280,12 +280,12 @@ function getMemberName( case AST_NODE_TYPES.TSMethodSignature: case AST_NODE_TYPES.TSAbstractPropertyDefinition: case AST_NODE_TYPES.PropertyDefinition: - return util.getNameFromMember(node, sourceCode); + return util.getNameFromMember(node, sourceCode).name; case AST_NODE_TYPES.TSAbstractMethodDefinition: case AST_NODE_TYPES.MethodDefinition: return node.kind === 'constructor' ? 'constructor' - : util.getNameFromMember(node, sourceCode); + : util.getNameFromMember(node, sourceCode).name; case AST_NODE_TYPES.TSConstructSignatureDeclaration: return 'new'; case AST_NODE_TYPES.TSCallSignatureDeclaration: @@ -428,7 +428,7 @@ export default util.createRule({ }, messages: { incorrectOrder: - 'Member "{{member}}" should be declared before member "{{beforeMember}}".', + 'Member {{member}} should be declared before member {{beforeMember}}.', incorrectGroupOrder: 'Member {{name}} should be declared before all {{rank}} definitions.', }, diff --git a/packages/eslint-plugin/src/rules/naming-convention-utils/types.ts b/packages/eslint-plugin/src/rules/naming-convention-utils/types.ts index d66f9ad13d4f..9cff76129dba 100644 --- a/packages/eslint-plugin/src/rules/naming-convention-utils/types.ts +++ b/packages/eslint-plugin/src/rules/naming-convention-utils/types.ts @@ -60,7 +60,7 @@ interface NormalizedSelector { } type ValidatorFunction = ( - node: TSESTree.Identifier | TSESTree.Literal, + node: TSESTree.Identifier | TSESTree.PrivateIdentifier | TSESTree.Literal, modifiers?: Set, ) => void; type ParsedOptions = Record; diff --git a/packages/eslint-plugin/src/rules/naming-convention-utils/validator.ts b/packages/eslint-plugin/src/rules/naming-convention-utils/validator.ts index a683933d61b4..374302f7f124 100644 --- a/packages/eslint-plugin/src/rules/naming-convention-utils/validator.ts +++ b/packages/eslint-plugin/src/rules/naming-convention-utils/validator.ts @@ -25,7 +25,9 @@ function createValidator( type: SelectorsString, context: Context, allConfigs: NormalizedSelector[], -): (node: TSESTree.Identifier | TSESTree.Literal) => void { +): ( + node: TSESTree.Identifier | TSESTree.PrivateIdentifier | TSESTree.Literal, +) => void { // make sure the "highest priority" configs are checked first const selectorType = Selectors[type]; const configs = allConfigs @@ -70,11 +72,14 @@ function createValidator( }); return ( - node: TSESTree.Identifier | TSESTree.Literal, + node: TSESTree.Identifier | TSESTree.PrivateIdentifier | TSESTree.Literal, modifiers: Set = new Set(), ): void => { const originalName = - node.type === AST_NODE_TYPES.Identifier ? node.name : `${node.value}`; + node.type === AST_NODE_TYPES.Identifier || + node.type === AST_NODE_TYPES.PrivateIdentifier + ? node.name + : `${node.value}`; // return will break the loop and stop checking configs // it is only used when the name is known to have failed or succeeded a config. @@ -178,7 +183,7 @@ function createValidator( position: 'leading' | 'trailing', config: NormalizedSelector, name: string, - node: TSESTree.Identifier | TSESTree.Literal, + node: TSESTree.Identifier | TSESTree.PrivateIdentifier | TSESTree.Literal, originalName: string, ): string | null { const option = @@ -299,7 +304,7 @@ function createValidator( position: 'prefix' | 'suffix', config: NormalizedSelector, name: string, - node: TSESTree.Identifier | TSESTree.Literal, + node: TSESTree.Identifier | TSESTree.PrivateIdentifier | TSESTree.Literal, originalName: string, ): string | null { const affixes = config[position]; @@ -339,7 +344,7 @@ function createValidator( function validateCustom( config: NormalizedSelector, name: string, - node: TSESTree.Identifier | TSESTree.Literal, + node: TSESTree.Identifier | TSESTree.PrivateIdentifier | TSESTree.Literal, originalName: string, ): boolean { const custom = config.custom; @@ -372,7 +377,7 @@ function createValidator( function validatePredefinedFormat( config: NormalizedSelector, name: string, - node: TSESTree.Identifier | TSESTree.Literal, + node: TSESTree.Identifier | TSESTree.PrivateIdentifier | TSESTree.Literal, originalName: string, ): boolean { const formats = config.format; diff --git a/packages/eslint-plugin/src/rules/naming-convention.ts b/packages/eslint-plugin/src/rules/naming-convention.ts index 6915c841473f..db4463edd985 100644 --- a/packages/eslint-plugin/src/rules/naming-convention.ts +++ b/packages/eslint-plugin/src/rules/naming-convention.ts @@ -620,11 +620,14 @@ function isGlobal(scope: TSESLint.Scope.Scope | null): boolean { } function requiresQuoting( - node: TSESTree.Identifier | TSESTree.Literal, + node: TSESTree.Identifier | TSESTree.Literal | TSESTree.PrivateIdentifier, target: ScriptTarget | undefined, ): boolean { const name = - node.type === AST_NODE_TYPES.Identifier ? node.name : `${node.value}`; + node.type === AST_NODE_TYPES.Identifier || + node.type === AST_NODE_TYPES.PrivateIdentifier + ? node.name + : `${node.value}`; return util.requiresQuoting(name, target); } diff --git a/packages/eslint-plugin/src/rules/prefer-for-of.ts b/packages/eslint-plugin/src/rules/prefer-for-of.ts index 25043615f81e..f00868d04097 100644 --- a/packages/eslint-plugin/src/rules/prefer-for-of.ts +++ b/packages/eslint-plugin/src/rules/prefer-for-of.ts @@ -42,7 +42,7 @@ export default util.createRule({ } function isMatchingIdentifier( - node: TSESTree.Expression, + node: TSESTree.Expression | TSESTree.PrivateIdentifier, name: string, ): boolean { return node.type === AST_NODE_TYPES.Identifier && node.name === name; diff --git a/packages/eslint-plugin/src/util/misc.ts b/packages/eslint-plugin/src/util/misc.ts index 748a5cec6a6b..95fa4a359c6e 100644 --- a/packages/eslint-plugin/src/util/misc.ts +++ b/packages/eslint-plugin/src/util/misc.ts @@ -7,6 +7,7 @@ import { TSESLint, TSESTree, } from '@typescript-eslint/experimental-utils'; +import { requiresQuoting } from './requiresQuoting'; /** * Check if the context file name is *.d.ts or *.d.tsx @@ -64,6 +65,13 @@ function getNameFromIndexSignature(node: TSESTree.TSIndexSignature): string { return propName ? propName.name : '(index signature)'; } +enum MemberNameType { + Private = 1, + Quoted = 2, + Normal = 3, + Expression = 4, +} + /** * Gets a string name representation of the name of the given MethodDefinition * or PropertyDefinition node, with handling for computed property names. @@ -78,15 +86,38 @@ function getNameFromMember( | TSESTree.Property | TSESTree.TSPropertySignature, sourceCode: TSESLint.SourceCode, -): string { +): { type: MemberNameType; name: string } { if (member.key.type === AST_NODE_TYPES.Identifier) { - return member.key.name; + return { + type: MemberNameType.Normal, + name: member.key.name, + }; + } + if (member.key.type === AST_NODE_TYPES.PrivateIdentifier) { + return { + type: MemberNameType.Private, + name: `#${member.key.name}`, + }; } if (member.key.type === AST_NODE_TYPES.Literal) { - return `${member.key.value}`; + const name = `${member.key.value}`; + if (requiresQuoting(name)) { + return { + type: MemberNameType.Quoted, + name: `"${name}"`, + }; + } else { + return { + type: MemberNameType.Normal, + name, + }; + } } - return sourceCode.text.slice(...member.key.range); + return { + type: MemberNameType.Expression, + name: sourceCode.text.slice(...member.key.range), + }; } type ExcludeKeys< @@ -111,6 +142,7 @@ export { getNameFromIndexSignature, getNameFromMember, isDefinitionFile, + MemberNameType, RequireKeys, upperCaseFirst, }; diff --git a/packages/eslint-plugin/tests/rules/adjacent-overload-signatures.test.ts b/packages/eslint-plugin/tests/rules/adjacent-overload-signatures.test.ts index 0f034a787f78..12cf859a84a7 100644 --- a/packages/eslint-plugin/tests/rules/adjacent-overload-signatures.test.ts +++ b/packages/eslint-plugin/tests/rules/adjacent-overload-signatures.test.ts @@ -238,6 +238,18 @@ class Test { interface Foo { [Symbol.toStringTag](): void; [Symbol.iterator](): void; +} + `, + // private members + ` +class Test { + #private(): void; + #private(arg: number): void {} + + bar() {} + + '#private'(): void; + '#private'(arg: number): void {} } `, ], @@ -836,5 +848,30 @@ class Foo { }, ], }, + // private members + { + code: ` +class Test { + #private(): void; + '#private'(): void; + #private(arg: number): void {} + '#private'(arg: number): void {} +} + `, + errors: [ + { + messageId: 'adjacentSignature', + data: { name: '#private' }, + line: 5, + column: 3, + }, + { + messageId: 'adjacentSignature', + data: { name: '"#private"' }, + line: 6, + column: 3, + }, + ], + }, ], }); diff --git a/packages/eslint-plugin/tests/rules/explicit-member-accessibility.test.ts b/packages/eslint-plugin/tests/rules/explicit-member-accessibility.test.ts index 906f1b6cc600..4e070acb325c 100644 --- a/packages/eslint-plugin/tests/rules/explicit-member-accessibility.test.ts +++ b/packages/eslint-plugin/tests/rules/explicit-member-accessibility.test.ts @@ -330,6 +330,16 @@ class Test { code: ` class Test { constructor(private { x }: any[]) {} +} + `, + options: [{ accessibility: 'no-public' }], + }, + // private members + { + code: ` +class Test { + #foo = 1; + #bar() {} } `, options: [{ accessibility: 'no-public' }], @@ -1070,6 +1080,64 @@ class EnsureWhiteSPaceSpan { output: ` class EnsureWhiteSPaceSpan { /* */ constructor() {} +} + `, + }, + // quoted names + { + code: noFormat` +class Test { + public 'foo' = 1; + public 'foo foo' = 2; + public 'bar'() {} + public 'bar bar'() {} +} + `, + options: [{ accessibility: 'no-public' }], + errors: [ + { + messageId: 'unwantedPublicAccessibility', + data: { + type: 'class property', + name: 'foo', + }, + line: 3, + column: 3, + }, + { + messageId: 'unwantedPublicAccessibility', + data: { + type: 'class property', + name: '"foo foo"', + }, + line: 4, + column: 3, + }, + { + messageId: 'unwantedPublicAccessibility', + data: { + type: 'method definition', + name: 'bar', + }, + line: 5, + column: 3, + }, + { + messageId: 'unwantedPublicAccessibility', + data: { + type: 'method definition', + name: '"bar bar"', + }, + line: 6, + column: 3, + }, + ], + output: noFormat` +class Test { + 'foo' = 1; + 'foo foo' = 2; + 'bar'() {} + 'bar bar'() {} } `, }, diff --git a/packages/eslint-plugin/tests/rules/member-ordering.test.ts b/packages/eslint-plugin/tests/rules/member-ordering.test.ts index e457ef3daf4a..97b05cfdeffc 100644 --- a/packages/eslint-plugin/tests/rules/member-ordering.test.ts +++ b/packages/eslint-plugin/tests/rules/member-ordering.test.ts @@ -3996,6 +3996,20 @@ class Foo { `, options: [{ default: { memberTypes: 'never', order: 'alphabetically' } }], }, + + // default option + private identifiers + { + code: ` +class Foo { + #a = 1; + #b = 2; + #c = 3; +} + `, + options: [ + { default: { memberTypes: defaultOrder, order: 'alphabetically' } }, + ], + }, ], invalid: [ // default option + interface + wrong order @@ -6349,6 +6363,32 @@ type Foo = { }, ], }, + + // default option + private identifiers + { + code: ` +class Foo { + #c = 3; + #b = 2; + #a = 1; +} + `, + options: [ + { default: { memberTypes: defaultOrder, order: 'alphabetically' } }, + ], + errors: [ + { + messageId: 'incorrectOrder', + line: 4, + column: 3, + }, + { + messageId: 'incorrectOrder', + line: 5, + column: 3, + }, + ], + }, ], }; diff --git a/packages/eslint-plugin/tests/rules/naming-convention.test.ts b/packages/eslint-plugin/tests/rules/naming-convention.test.ts index 1c693b4fde09..d35afe5ed30c 100644 --- a/packages/eslint-plugin/tests/rules/naming-convention.test.ts +++ b/packages/eslint-plugin/tests/rules/naming-convention.test.ts @@ -486,7 +486,9 @@ const cases: Cases = [ 'interface Ignored { %: string }', 'type Ignored = { %: string }', 'class Ignored { private % = 1 }', + 'class Ignored { #% = 1 }', 'class Ignored { constructor(private %) {} }', + 'class Ignored { #%() {} }', 'class Ignored { private %() {} }', 'const ignored = { %() {} };', 'class Ignored { private get %() {} }', @@ -562,6 +564,8 @@ const cases: Cases = [ 'class Ignored { private static readonly % = 1 }', 'class Ignored { abstract % = 1 }', 'class Ignored { declare % }', + 'class Ignored { #% }', + 'class Ignored { static #% }', ], options: { selector: 'classProperty', @@ -617,6 +621,8 @@ const cases: Cases = [ 'class Ignored { private % = () => {} }', 'class Ignored { abstract %() }', 'class Ignored { declare %() }', + 'class Ignored { #%() }', + 'class Ignored { static #%() }', ], options: { selector: 'classMethod', @@ -653,6 +659,7 @@ const cases: Cases = [ 'class Ignored { private get %() {} }', 'class Ignored { private set "%"(ignored) {} }', 'class Ignored { private static get %() {} }', + 'class Ignored { static get #%() {} }', ], options: { selector: 'accessor', diff --git a/packages/scope-manager/src/referencer/ClassVisitor.ts b/packages/scope-manager/src/referencer/ClassVisitor.ts index d33e362ea41a..6f5050442138 100644 --- a/packages/scope-manager/src/referencer/ClassVisitor.ts +++ b/packages/scope-manager/src/referencer/ClassVisitor.ts @@ -353,6 +353,10 @@ class ClassVisitor extends Visitor { protected Identifier(node: TSESTree.Identifier): void { this.#referencer.visit(node); } + + protected PrivateIdentifier(): void { + // intentionally skip + } } /** diff --git a/packages/scope-manager/src/referencer/Referencer.ts b/packages/scope-manager/src/referencer/Referencer.ts index df4c318daddb..9109feb3edb4 100644 --- a/packages/scope-manager/src/referencer/Referencer.ts +++ b/packages/scope-manager/src/referencer/Referencer.ts @@ -551,6 +551,10 @@ class Referencer extends Visitor { this.visitType(node.typeParameters); } + protected PrivateIdentifier(): void { + // private identifiers are members on classes and thus have no variables to to reference + } + protected Program(node: TSESTree.Program): void { const globalScope = this.scopeManager.nestGlobalScope(node); this.populateGlobalsFromLib(globalScope); diff --git a/packages/scope-manager/tests/fixtures/class/declaration/private-identifier.ts b/packages/scope-manager/tests/fixtures/class/declaration/private-identifier.ts new file mode 100644 index 000000000000..13ab5d80c3e9 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/private-identifier.ts @@ -0,0 +1,7 @@ +class Foo { + #bar; + + constructor() { + this.#bar = 1; + } +} diff --git a/packages/scope-manager/tests/fixtures/class/declaration/private-identifier.ts.shot b/packages/scope-manager/tests/fixtures/class/declaration/private-identifier.ts.shot new file mode 100644 index 000000000000..bed463a748a8 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/private-identifier.ts.shot @@ -0,0 +1,83 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`class declaration private-identifier 1`] = ` +ScopeManager { + variables: Array [ + ImplicitGlobalConstTypeVariable, + Variable$2 { + defs: Array [ + ClassNameDefinition$1 { + name: Identifier<"Foo">, + node: ClassDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + ClassNameDefinition$2 { + name: Identifier<"Foo">, + node: ClassDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$2, + isStrict: false, + references: Array [], + set: Map { + "const" => ImplicitGlobalConstTypeVariable, + "Foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + ImplicitGlobalConstTypeVariable, + Variable$2, + ], + }, + ClassScope$2 { + block: ClassDeclaration$1, + isStrict: true, + references: Array [], + set: Map { + "Foo" => Variable$3, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + ], + }, + FunctionScope$3 { + block: FunctionExpression$3, + isStrict: true, + references: Array [], + set: Map { + "arguments" => Variable$4, + }, + type: "function", + upper: ClassScope$2, + variables: Array [ + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/class/expression/private-identifier.ts b/packages/scope-manager/tests/fixtures/class/expression/private-identifier.ts new file mode 100644 index 000000000000..95d1cb660ad4 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/expression/private-identifier.ts @@ -0,0 +1,7 @@ +const Foo = class { + #bar; + + constructor() { + this.#bar = 1; + } +}; diff --git a/packages/scope-manager/tests/fixtures/class/expression/private-identifier.ts.shot b/packages/scope-manager/tests/fixtures/class/expression/private-identifier.ts.shot new file mode 100644 index 000000000000..d9961a857634 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/expression/private-identifier.ts.shot @@ -0,0 +1,80 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`class expression private-identifier 1`] = ` +ScopeManager { + variables: Array [ + ImplicitGlobalConstTypeVariable, + Variable$2 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"Foo">, + node: VariableDeclarator$1, + }, + ], + name: "Foo", + references: Array [ + Reference$1 { + identifier: Identifier<"Foo">, + init: true, + isRead: false, + isTypeReference: false, + isValueReference: true, + isWrite: true, + resolved: Variable$2, + writeExpr: ClassExpression$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "const" => ImplicitGlobalConstTypeVariable, + "Foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + ImplicitGlobalConstTypeVariable, + Variable$2, + ], + }, + ClassScope$2 { + block: ClassExpression$2, + isStrict: true, + references: Array [], + set: Map {}, + type: "class", + upper: GlobalScope$1, + variables: Array [], + }, + FunctionScope$3 { + block: FunctionExpression$4, + isStrict: true, + references: Array [], + set: Map { + "arguments" => Variable$3, + }, + type: "function", + upper: ClassScope$2, + variables: Array [ + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/shared-fixtures/fixtures/javascript/classes/class-private-identifier-accessor.src.js b/packages/shared-fixtures/fixtures/javascript/classes/class-private-identifier-accessor.src.js new file mode 100644 index 000000000000..6a8a89931955 --- /dev/null +++ b/packages/shared-fixtures/fixtures/javascript/classes/class-private-identifier-accessor.src.js @@ -0,0 +1,8 @@ +class Foo { + get #priv1() { return 1 } + set #priv1(value) { } + + constructor() { + this.#priv1 = 1; + } +} diff --git a/packages/shared-fixtures/fixtures/javascript/classes/class-private-identifier-field.src.js b/packages/shared-fixtures/fixtures/javascript/classes/class-private-identifier-field.src.js new file mode 100644 index 000000000000..4519b85cd975 --- /dev/null +++ b/packages/shared-fixtures/fixtures/javascript/classes/class-private-identifier-field.src.js @@ -0,0 +1,8 @@ +class Foo { + #priv1; + #priv2 = 1; + + constructor() { + this.#priv1 = 1; + } +} diff --git a/packages/shared-fixtures/fixtures/javascript/classes/class-private-identifier-method.src.js b/packages/shared-fixtures/fixtures/javascript/classes/class-private-identifier-method.src.js new file mode 100644 index 000000000000..f2694d08e36b --- /dev/null +++ b/packages/shared-fixtures/fixtures/javascript/classes/class-private-identifier-method.src.js @@ -0,0 +1,7 @@ +class Foo { + #bar() {} + + constructor() { + this.#bar(); + } +} diff --git a/packages/shared-fixtures/fixtures/typescript/basics/class-private-identifier-field-with-accessibility-error.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-private-identifier-field-with-accessibility-error.src.ts new file mode 100644 index 000000000000..554ea66635ae --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/basics/class-private-identifier-field-with-accessibility-error.src.ts @@ -0,0 +1,5 @@ +class Foo { + private #priv1: string + public #priv2: string + static #priv3: string +} diff --git a/packages/shared-fixtures/fixtures/typescript/basics/class-private-identifier-field-with-annotation.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-private-identifier-field-with-annotation.src.ts new file mode 100644 index 000000000000..f771a81a83a4 --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/basics/class-private-identifier-field-with-annotation.src.ts @@ -0,0 +1,8 @@ +class Foo { + #priv1: number; + #priv2: number = 1; + + constructor() { + this.#priv1 = 1; + } +} diff --git a/packages/shared-fixtures/fixtures/typescript/basics/class-private-identifier-readonly-field.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/class-private-identifier-readonly-field.src.ts new file mode 100644 index 000000000000..254995a222b1 --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/basics/class-private-identifier-readonly-field.src.ts @@ -0,0 +1,3 @@ +class Foo { + readonly #priv: string +} diff --git a/packages/types/tools/copy-ast-spec.ts b/packages/types/tools/copy-ast-spec.ts index ed231195eeb4..0288453a3100 100644 --- a/packages/types/tools/copy-ast-spec.ts +++ b/packages/types/tools/copy-ast-spec.ts @@ -11,7 +11,7 @@ const AST_SPEC_PATH = path.resolve(__dirname, '../../ast-spec'); const OUTPUT_PATH = path.join(path.resolve(__dirname, '../src/')); // ensure the package is built -chlidProcess.execSync('yarn build', { cwd: AST_SPEC_PATH }); +chlidProcess.execSync('yarn build', { cwd: AST_SPEC_PATH, stdio: 'inherit' }); const HEADER = `\ /********************************************** diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index 0846087759f3..e800233a7106 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -775,6 +775,14 @@ export class Converter { }); } + case SyntaxKind.PrivateIdentifier: { + return this.createNode(node, { + type: AST_NODE_TYPES.PrivateIdentifier, + // typescript includes the `#` in the text + name: node.text.slice(1), + }); + } + case SyntaxKind.WithStatement: return this.createNode(node, { type: AST_NODE_TYPES.WithStatement, diff --git a/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts b/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts index 07b2bb5db318..586aea269eea 100644 --- a/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts +++ b/packages/typescript-estree/src/ts-estree/estree-to-ts-node-types.ts @@ -72,6 +72,7 @@ export interface EstreeToTsNodeTypes { | ts.Identifier | ts.ConstructorDeclaration | ts.Token; + [AST_NODE_TYPES.PrivateIdentifier]: ts.PrivateIdentifier; [AST_NODE_TYPES.IfStatement]: ts.IfStatement; [AST_NODE_TYPES.ImportDeclaration]: ts.ImportDeclaration; [AST_NODE_TYPES.ImportDefaultSpecifier]: ts.ImportClause; diff --git a/packages/typescript-estree/src/ts-estree/ts-nodes.ts b/packages/typescript-estree/src/ts-estree/ts-nodes.ts index 673dd6f9831c..79756053e087 100644 --- a/packages/typescript-estree/src/ts-estree/ts-nodes.ts +++ b/packages/typescript-estree/src/ts-estree/ts-nodes.ts @@ -6,6 +6,8 @@ declare module 'typescript' { /* eslint-disable @typescript-eslint/no-empty-interface */ export interface NamedTupleMember extends ts.Node {} export interface TemplateLiteralTypeNode extends ts.Node {} + export interface PrivateIdentifier extends ts.Node {} + export interface ClassStaticBlockDeclaration extends ts.Node {} /* eslint-enable @typescript-eslint/no-empty-interface */ } @@ -14,6 +16,7 @@ export type TSToken = ts.Token; export type TSNode = | ts.Modifier | ts.Identifier + | ts.PrivateIdentifier | ts.QualifiedName | ts.ComputedPropertyName | ts.Decorator diff --git a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts index a3400b97d336..3f4246b037cc 100644 --- a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts +++ b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts @@ -181,6 +181,12 @@ tester.addFixturePatternConfig('javascript/classes', { * TS3.6 made computed constructors parse as actual constructors. */ 'class-two-methods-computed-constructor', + /** + * Babel emits a `PrivateName` instead of `PrivateIdentifier` + */ + 'class-private-identifier-accessor', + 'class-private-identifier-method', + 'class-private-identifier-field', ], }); @@ -386,6 +392,15 @@ tester.addFixturePatternConfig('typescript/basics', { * This is intentional; babel is not checking types */ 'catch-clause-with-invalid-annotation', + /** + * [BABEL ERRORED, BUT TS-ESTREE DID NOT] + * TODO: enforce that accessibility is not allowed on a private identifier + */ + 'class-private-identifier-field-with-accessibility-error', + /** + * Babel emits a `PrivateName` instead of `PrivateIdentifier` + */ + 'class-private-identifier-field-with-annotation', /** * [TS-ESTREE ERRORED, BUT BABEL DID NOT] * TypeScript 4.4 new feature diff --git a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.test.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.test.ts.snap index 031e7f61e120..2a46c9188cb2 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.test.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.test.ts.snap @@ -273,6 +273,12 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/classes/class-one-method-super.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/classes/class-private-identifier-accessor.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/classes/class-private-identifier-field.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/classes/class-private-identifier-method.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/classes/class-static-method.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/javascript/classes/class-static-method-named-prototype.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; @@ -1751,6 +1757,12 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/class-multi-line-keyword-declare.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/class-private-identifier-field-with-accessibility-error.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/class-private-identifier-field-with-annotation.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/class-private-identifier-readonly-field.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/class-static-blocks.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/class-with-accessibility-modifiers.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; diff --git a/packages/typescript-estree/tests/snapshots/javascript/classes/class-private-identifier-accessor.src.js.shot b/packages/typescript-estree/tests/snapshots/javascript/classes/class-private-identifier-accessor.src.js.shot new file mode 100644 index 000000000000..07249d71dc9a --- /dev/null +++ b/packages/typescript-estree/tests/snapshots/javascript/classes/class-private-identifier-accessor.src.js.shot @@ -0,0 +1,1024 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`javascript classes class-private-identifier-accessor.src 1`] = ` +Object { + "body": Array [ + Object { + "body": Object { + "body": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "name": "priv1", + "range": Array [ + 18, + 24, + ], + "type": "PrivateIdentifier", + }, + "kind": "get", + "loc": Object { + "end": Object { + "column": 27, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "override": false, + "range": Array [ + 14, + 39, + ], + "static": false, + "type": "MethodDefinition", + "value": Object { + "async": false, + "body": Object { + "body": Array [ + Object { + "argument": Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 2, + }, + "start": Object { + "column": 24, + "line": 2, + }, + }, + "range": Array [ + 36, + 37, + ], + "raw": "1", + "type": "Literal", + "value": 1, + }, + "loc": Object { + "end": Object { + "column": 25, + "line": 2, + }, + "start": Object { + "column": 17, + "line": 2, + }, + }, + "range": Array [ + 29, + 37, + ], + "type": "ReturnStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 27, + "line": 2, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "range": Array [ + 27, + 39, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 27, + "line": 2, + }, + "start": Object { + "column": 12, + "line": 2, + }, + }, + "params": Array [], + "range": Array [ + 24, + 39, + ], + "type": "FunctionExpression", + }, + }, + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 3, + }, + "start": Object { + "column": 6, + "line": 3, + }, + }, + "name": "priv1", + "range": Array [ + 46, + 52, + ], + "type": "PrivateIdentifier", + }, + "kind": "set", + "loc": Object { + "end": Object { + "column": 23, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "override": false, + "range": Array [ + 42, + 63, + ], + "static": false, + "type": "MethodDefinition", + "value": Object { + "async": false, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 23, + "line": 3, + }, + "start": Object { + "column": 20, + "line": 3, + }, + }, + "range": Array [ + 60, + 63, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 23, + "line": 3, + }, + "start": Object { + "column": 12, + "line": 3, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 3, + }, + "start": Object { + "column": 13, + "line": 3, + }, + }, + "name": "value", + "range": Array [ + 53, + 58, + ], + "type": "Identifier", + }, + ], + "range": Array [ + 52, + 63, + ], + "type": "FunctionExpression", + }, + }, + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 5, + }, + "start": Object { + "column": 2, + "line": 5, + }, + }, + "name": "constructor", + "range": Array [ + 67, + 78, + ], + "type": "Identifier", + }, + "kind": "constructor", + "loc": Object { + "end": Object { + "column": 3, + "line": 7, + }, + "start": Object { + "column": 2, + "line": 5, + }, + }, + "override": false, + "range": Array [ + 67, + 107, + ], + "static": false, + "type": "MethodDefinition", + "value": Object { + "async": false, + "body": Object { + "body": Array [ + Object { + "expression": Object { + "left": Object { + "computed": false, + "loc": Object { + "end": Object { + "column": 15, + "line": 6, + }, + "start": Object { + "column": 4, + "line": 6, + }, + }, + "object": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 6, + }, + "start": Object { + "column": 4, + "line": 6, + }, + }, + "range": Array [ + 87, + 91, + ], + "type": "ThisExpression", + }, + "optional": false, + "property": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 6, + }, + "start": Object { + "column": 9, + "line": 6, + }, + }, + "name": "priv1", + "range": Array [ + 92, + 98, + ], + "type": "PrivateIdentifier", + }, + "range": Array [ + 87, + 98, + ], + "type": "MemberExpression", + }, + "loc": Object { + "end": Object { + "column": 19, + "line": 6, + }, + "start": Object { + "column": 4, + "line": 6, + }, + }, + "operator": "=", + "range": Array [ + 87, + 102, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 6, + }, + "start": Object { + "column": 18, + "line": 6, + }, + }, + "range": Array [ + 101, + 102, + ], + "raw": "1", + "type": "Literal", + "value": 1, + }, + "type": "AssignmentExpression", + }, + "loc": Object { + "end": Object { + "column": 20, + "line": 6, + }, + "start": Object { + "column": 4, + "line": 6, + }, + }, + "range": Array [ + 87, + 103, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 3, + "line": 7, + }, + "start": Object { + "column": 16, + "line": 5, + }, + }, + "range": Array [ + 81, + 107, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 3, + "line": 7, + }, + "start": Object { + "column": 13, + "line": 5, + }, + }, + "params": Array [], + "range": Array [ + 78, + 107, + ], + "type": "FunctionExpression", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 8, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 109, + ], + "type": "ClassBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 8, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 109, + ], + "superClass": null, + "type": "ClassDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 9, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 110, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "class", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 14, + 17, + ], + "type": "Identifier", + "value": "get", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "range": Array [ + 18, + 24, + ], + "type": "Identifier", + "value": "#priv1", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 2, + }, + "start": Object { + "column": 12, + "line": 2, + }, + }, + "range": Array [ + 24, + 25, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 13, + "line": 2, + }, + }, + "range": Array [ + 25, + 26, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "range": Array [ + 27, + 28, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 2, + }, + "start": Object { + "column": 17, + "line": 2, + }, + }, + "range": Array [ + 29, + 35, + ], + "type": "Keyword", + "value": "return", + }, + Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 2, + }, + "start": Object { + "column": 24, + "line": 2, + }, + }, + "range": Array [ + 36, + 37, + ], + "type": "Numeric", + "value": "1", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 2, + }, + "start": Object { + "column": 26, + "line": 2, + }, + }, + "range": Array [ + 38, + 39, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "range": Array [ + 42, + 45, + ], + "type": "Identifier", + "value": "set", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 3, + }, + "start": Object { + "column": 6, + "line": 3, + }, + }, + "range": Array [ + 46, + 52, + ], + "type": "Identifier", + "value": "#priv1", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 3, + }, + "start": Object { + "column": 12, + "line": 3, + }, + }, + "range": Array [ + 52, + 53, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 3, + }, + "start": Object { + "column": 13, + "line": 3, + }, + }, + "range": Array [ + 53, + 58, + ], + "type": "Identifier", + "value": "value", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 3, + }, + "start": Object { + "column": 18, + "line": 3, + }, + }, + "range": Array [ + 58, + 59, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 3, + }, + "start": Object { + "column": 20, + "line": 3, + }, + }, + "range": Array [ + 60, + 61, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 3, + }, + "start": Object { + "column": 22, + "line": 3, + }, + }, + "range": Array [ + 62, + 63, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 5, + }, + "start": Object { + "column": 2, + "line": 5, + }, + }, + "range": Array [ + 67, + 78, + ], + "type": "Identifier", + "value": "constructor", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 5, + }, + "start": Object { + "column": 13, + "line": 5, + }, + }, + "range": Array [ + 78, + 79, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 5, + }, + "start": Object { + "column": 14, + "line": 5, + }, + }, + "range": Array [ + 79, + 80, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 5, + }, + "start": Object { + "column": 16, + "line": 5, + }, + }, + "range": Array [ + 81, + 82, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 6, + }, + "start": Object { + "column": 4, + "line": 6, + }, + }, + "range": Array [ + 87, + 91, + ], + "type": "Keyword", + "value": "this", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 6, + }, + "start": Object { + "column": 8, + "line": 6, + }, + }, + "range": Array [ + 91, + 92, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 6, + }, + "start": Object { + "column": 9, + "line": 6, + }, + }, + "range": Array [ + 92, + 98, + ], + "type": "Identifier", + "value": "#priv1", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 6, + }, + "start": Object { + "column": 16, + "line": 6, + }, + }, + "range": Array [ + 99, + 100, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 6, + }, + "start": Object { + "column": 18, + "line": 6, + }, + }, + "range": Array [ + 101, + 102, + ], + "type": "Numeric", + "value": "1", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 6, + }, + "start": Object { + "column": 19, + "line": 6, + }, + }, + "range": Array [ + 102, + 103, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 7, + }, + "start": Object { + "column": 2, + "line": 7, + }, + }, + "range": Array [ + 106, + 107, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 8, + }, + "start": Object { + "column": 0, + "line": 8, + }, + }, + "range": Array [ + 108, + 109, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; diff --git a/packages/typescript-estree/tests/snapshots/javascript/classes/class-private-identifier-field.src.js.shot b/packages/typescript-estree/tests/snapshots/javascript/classes/class-private-identifier-field.src.js.shot new file mode 100644 index 000000000000..63586a9fa6df --- /dev/null +++ b/packages/typescript-estree/tests/snapshots/javascript/classes/class-private-identifier-field.src.js.shot @@ -0,0 +1,748 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`javascript classes class-private-identifier-field.src 1`] = ` +Object { + "body": Array [ + Object { + "body": Object { + "body": Array [ + Object { + "computed": false, + "declare": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "name": "priv1", + "range": Array [ + 14, + 20, + ], + "type": "PrivateIdentifier", + }, + "loc": Object { + "end": Object { + "column": 9, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "override": false, + "range": Array [ + 14, + 21, + ], + "readonly": undefined, + "static": false, + "type": "PropertyDefinition", + "value": null, + }, + Object { + "computed": false, + "declare": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "name": "priv2", + "range": Array [ + 24, + 30, + ], + "type": "PrivateIdentifier", + }, + "loc": Object { + "end": Object { + "column": 13, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "override": false, + "range": Array [ + 24, + 35, + ], + "readonly": undefined, + "static": false, + "type": "PropertyDefinition", + "value": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 3, + }, + "start": Object { + "column": 11, + "line": 3, + }, + }, + "range": Array [ + 33, + 34, + ], + "raw": "1", + "type": "Literal", + "value": 1, + }, + }, + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 5, + }, + "start": Object { + "column": 2, + "line": 5, + }, + }, + "name": "constructor", + "range": Array [ + 39, + 50, + ], + "type": "Identifier", + }, + "kind": "constructor", + "loc": Object { + "end": Object { + "column": 3, + "line": 7, + }, + "start": Object { + "column": 2, + "line": 5, + }, + }, + "override": false, + "range": Array [ + 39, + 79, + ], + "static": false, + "type": "MethodDefinition", + "value": Object { + "async": false, + "body": Object { + "body": Array [ + Object { + "expression": Object { + "left": Object { + "computed": false, + "loc": Object { + "end": Object { + "column": 15, + "line": 6, + }, + "start": Object { + "column": 4, + "line": 6, + }, + }, + "object": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 6, + }, + "start": Object { + "column": 4, + "line": 6, + }, + }, + "range": Array [ + 59, + 63, + ], + "type": "ThisExpression", + }, + "optional": false, + "property": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 6, + }, + "start": Object { + "column": 9, + "line": 6, + }, + }, + "name": "priv1", + "range": Array [ + 64, + 70, + ], + "type": "PrivateIdentifier", + }, + "range": Array [ + 59, + 70, + ], + "type": "MemberExpression", + }, + "loc": Object { + "end": Object { + "column": 19, + "line": 6, + }, + "start": Object { + "column": 4, + "line": 6, + }, + }, + "operator": "=", + "range": Array [ + 59, + 74, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 6, + }, + "start": Object { + "column": 18, + "line": 6, + }, + }, + "range": Array [ + 73, + 74, + ], + "raw": "1", + "type": "Literal", + "value": 1, + }, + "type": "AssignmentExpression", + }, + "loc": Object { + "end": Object { + "column": 20, + "line": 6, + }, + "start": Object { + "column": 4, + "line": 6, + }, + }, + "range": Array [ + 59, + 75, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 3, + "line": 7, + }, + "start": Object { + "column": 16, + "line": 5, + }, + }, + "range": Array [ + 53, + 79, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 3, + "line": 7, + }, + "start": Object { + "column": 13, + "line": 5, + }, + }, + "params": Array [], + "range": Array [ + 50, + 79, + ], + "type": "FunctionExpression", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 8, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 81, + ], + "type": "ClassBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 8, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 81, + ], + "superClass": null, + "type": "ClassDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 9, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 82, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "class", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 14, + 20, + ], + "type": "Identifier", + "value": "#priv1", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 2, + }, + "start": Object { + "column": 8, + "line": 2, + }, + }, + "range": Array [ + 20, + 21, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "range": Array [ + 24, + 30, + ], + "type": "Identifier", + "value": "#priv2", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 3, + }, + "start": Object { + "column": 9, + "line": 3, + }, + }, + "range": Array [ + 31, + 32, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 3, + }, + "start": Object { + "column": 11, + "line": 3, + }, + }, + "range": Array [ + 33, + 34, + ], + "type": "Numeric", + "value": "1", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 3, + }, + "start": Object { + "column": 12, + "line": 3, + }, + }, + "range": Array [ + 34, + 35, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 5, + }, + "start": Object { + "column": 2, + "line": 5, + }, + }, + "range": Array [ + 39, + 50, + ], + "type": "Identifier", + "value": "constructor", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 5, + }, + "start": Object { + "column": 13, + "line": 5, + }, + }, + "range": Array [ + 50, + 51, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 5, + }, + "start": Object { + "column": 14, + "line": 5, + }, + }, + "range": Array [ + 51, + 52, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 5, + }, + "start": Object { + "column": 16, + "line": 5, + }, + }, + "range": Array [ + 53, + 54, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 6, + }, + "start": Object { + "column": 4, + "line": 6, + }, + }, + "range": Array [ + 59, + 63, + ], + "type": "Keyword", + "value": "this", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 6, + }, + "start": Object { + "column": 8, + "line": 6, + }, + }, + "range": Array [ + 63, + 64, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 6, + }, + "start": Object { + "column": 9, + "line": 6, + }, + }, + "range": Array [ + 64, + 70, + ], + "type": "Identifier", + "value": "#priv1", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 6, + }, + "start": Object { + "column": 16, + "line": 6, + }, + }, + "range": Array [ + 71, + 72, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 6, + }, + "start": Object { + "column": 18, + "line": 6, + }, + }, + "range": Array [ + 73, + 74, + ], + "type": "Numeric", + "value": "1", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 6, + }, + "start": Object { + "column": 19, + "line": 6, + }, + }, + "range": Array [ + 74, + 75, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 7, + }, + "start": Object { + "column": 2, + "line": 7, + }, + }, + "range": Array [ + 78, + 79, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 8, + }, + "start": Object { + "column": 0, + "line": 8, + }, + }, + "range": Array [ + 80, + 81, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; diff --git a/packages/typescript-estree/tests/snapshots/javascript/classes/class-private-identifier-method.src.js.shot b/packages/typescript-estree/tests/snapshots/javascript/classes/class-private-identifier-method.src.js.shot new file mode 100644 index 000000000000..099a48f546c5 --- /dev/null +++ b/packages/typescript-estree/tests/snapshots/javascript/classes/class-private-identifier-method.src.js.shot @@ -0,0 +1,691 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`javascript classes class-private-identifier-method.src 1`] = ` +Object { + "body": Array [ + Object { + "body": Object { + "body": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "name": "bar", + "range": Array [ + 14, + 18, + ], + "type": "PrivateIdentifier", + }, + "kind": "method", + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "override": false, + "range": Array [ + 14, + 23, + ], + "static": false, + "type": "MethodDefinition", + "value": Object { + "async": false, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "range": Array [ + 21, + 23, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "params": Array [], + "range": Array [ + 18, + 23, + ], + "type": "FunctionExpression", + }, + }, + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 4, + }, + "start": Object { + "column": 2, + "line": 4, + }, + }, + "name": "constructor", + "range": Array [ + 27, + 38, + ], + "type": "Identifier", + }, + "kind": "constructor", + "loc": Object { + "end": Object { + "column": 3, + "line": 6, + }, + "start": Object { + "column": 2, + "line": 4, + }, + }, + "override": false, + "range": Array [ + 27, + 63, + ], + "static": false, + "type": "MethodDefinition", + "value": Object { + "async": false, + "body": Object { + "body": Array [ + Object { + "expression": Object { + "arguments": Array [], + "callee": Object { + "computed": false, + "loc": Object { + "end": Object { + "column": 13, + "line": 5, + }, + "start": Object { + "column": 4, + "line": 5, + }, + }, + "object": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 5, + }, + "start": Object { + "column": 4, + "line": 5, + }, + }, + "range": Array [ + 47, + 51, + ], + "type": "ThisExpression", + }, + "optional": false, + "property": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 5, + }, + "start": Object { + "column": 9, + "line": 5, + }, + }, + "name": "bar", + "range": Array [ + 52, + 56, + ], + "type": "PrivateIdentifier", + }, + "range": Array [ + 47, + 56, + ], + "type": "MemberExpression", + }, + "loc": Object { + "end": Object { + "column": 15, + "line": 5, + }, + "start": Object { + "column": 4, + "line": 5, + }, + }, + "optional": false, + "range": Array [ + 47, + 58, + ], + "type": "CallExpression", + }, + "loc": Object { + "end": Object { + "column": 16, + "line": 5, + }, + "start": Object { + "column": 4, + "line": 5, + }, + }, + "range": Array [ + 47, + 59, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 3, + "line": 6, + }, + "start": Object { + "column": 16, + "line": 4, + }, + }, + "range": Array [ + 41, + 63, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 3, + "line": 6, + }, + "start": Object { + "column": 13, + "line": 4, + }, + }, + "params": Array [], + "range": Array [ + 38, + 63, + ], + "type": "FunctionExpression", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 7, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 65, + ], + "type": "ClassBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 7, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 65, + ], + "superClass": null, + "type": "ClassDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 8, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 66, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "class", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 14, + 18, + ], + "type": "Identifier", + "value": "#bar", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "range": Array [ + 19, + 20, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "range": Array [ + 21, + 22, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 10, + "line": 2, + }, + }, + "range": Array [ + 22, + 23, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 4, + }, + "start": Object { + "column": 2, + "line": 4, + }, + }, + "range": Array [ + 27, + 38, + ], + "type": "Identifier", + "value": "constructor", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 4, + }, + "start": Object { + "column": 13, + "line": 4, + }, + }, + "range": Array [ + 38, + 39, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 4, + }, + "start": Object { + "column": 14, + "line": 4, + }, + }, + "range": Array [ + 39, + 40, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 4, + }, + "start": Object { + "column": 16, + "line": 4, + }, + }, + "range": Array [ + 41, + 42, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 5, + }, + "start": Object { + "column": 4, + "line": 5, + }, + }, + "range": Array [ + 47, + 51, + ], + "type": "Keyword", + "value": "this", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 5, + }, + "start": Object { + "column": 8, + "line": 5, + }, + }, + "range": Array [ + 51, + 52, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 5, + }, + "start": Object { + "column": 9, + "line": 5, + }, + }, + "range": Array [ + 52, + 56, + ], + "type": "Identifier", + "value": "#bar", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 5, + }, + "start": Object { + "column": 13, + "line": 5, + }, + }, + "range": Array [ + 56, + 57, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 5, + }, + "start": Object { + "column": 14, + "line": 5, + }, + }, + "range": Array [ + 57, + 58, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 5, + }, + "start": Object { + "column": 15, + "line": 5, + }, + }, + "range": Array [ + 58, + 59, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 6, + }, + "start": Object { + "column": 2, + "line": 6, + }, + }, + "range": Array [ + 62, + 63, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 7, + }, + "start": Object { + "column": 0, + "line": 7, + }, + }, + "range": Array [ + 64, + 65, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/class-private-identifier-field-with-accessibility-error.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/class-private-identifier-field-with-accessibility-error.src.ts.shot new file mode 100644 index 000000000000..04b127b9d7e9 --- /dev/null +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/class-private-identifier-field-with-accessibility-error.src.ts.shot @@ -0,0 +1,597 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`typescript basics class-private-identifier-field-with-accessibility-error.src 1`] = ` +Object { + "body": Array [ + Object { + "body": Object { + "body": Array [ + Object { + "accessibility": "private", + "computed": false, + "declare": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 10, + "line": 2, + }, + }, + "name": "priv1", + "range": Array [ + 22, + 28, + ], + "type": "PrivateIdentifier", + }, + "loc": Object { + "end": Object { + "column": 24, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "override": false, + "range": Array [ + 14, + 36, + ], + "readonly": undefined, + "static": false, + "type": "PropertyDefinition", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 28, + 36, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 2, + }, + "start": Object { + "column": 18, + "line": 2, + }, + }, + "range": Array [ + 30, + 36, + ], + "type": "TSStringKeyword", + }, + }, + "value": null, + }, + Object { + "accessibility": "public", + "computed": false, + "declare": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 3, + }, + "start": Object { + "column": 9, + "line": 3, + }, + }, + "name": "priv2", + "range": Array [ + 46, + 52, + ], + "type": "PrivateIdentifier", + }, + "loc": Object { + "end": Object { + "column": 23, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "override": false, + "range": Array [ + 39, + 60, + ], + "readonly": undefined, + "static": false, + "type": "PropertyDefinition", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "range": Array [ + 52, + 60, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 3, + }, + "start": Object { + "column": 17, + "line": 3, + }, + }, + "range": Array [ + 54, + 60, + ], + "type": "TSStringKeyword", + }, + }, + "value": null, + }, + Object { + "computed": false, + "declare": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 4, + }, + "start": Object { + "column": 9, + "line": 4, + }, + }, + "name": "priv3", + "range": Array [ + 70, + 76, + ], + "type": "PrivateIdentifier", + }, + "loc": Object { + "end": Object { + "column": 23, + "line": 4, + }, + "start": Object { + "column": 2, + "line": 4, + }, + }, + "override": false, + "range": Array [ + 63, + 84, + ], + "readonly": undefined, + "static": true, + "type": "PropertyDefinition", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 4, + }, + "start": Object { + "column": 15, + "line": 4, + }, + }, + "range": Array [ + 76, + 84, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 4, + }, + "start": Object { + "column": 17, + "line": 4, + }, + }, + "range": Array [ + 78, + 84, + ], + "type": "TSStringKeyword", + }, + }, + "value": null, + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 86, + ], + "type": "ClassBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 86, + ], + "superClass": null, + "type": "ClassDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 6, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 87, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "class", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 14, + 21, + ], + "type": "Keyword", + "value": "private", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 10, + "line": 2, + }, + }, + "range": Array [ + 22, + 28, + ], + "type": "Identifier", + "value": "#priv1", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 28, + 29, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 2, + }, + "start": Object { + "column": 18, + "line": 2, + }, + }, + "range": Array [ + 30, + 36, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "range": Array [ + 39, + 45, + ], + "type": "Keyword", + "value": "public", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 3, + }, + "start": Object { + "column": 9, + "line": 3, + }, + }, + "range": Array [ + 46, + 52, + ], + "type": "Identifier", + "value": "#priv2", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "range": Array [ + 52, + 53, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 3, + }, + "start": Object { + "column": 17, + "line": 3, + }, + }, + "range": Array [ + 54, + 60, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 4, + }, + "start": Object { + "column": 2, + "line": 4, + }, + }, + "range": Array [ + 63, + 69, + ], + "type": "Keyword", + "value": "static", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 4, + }, + "start": Object { + "column": 9, + "line": 4, + }, + }, + "range": Array [ + 70, + 76, + ], + "type": "Identifier", + "value": "#priv3", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 4, + }, + "start": Object { + "column": 15, + "line": 4, + }, + }, + "range": Array [ + 76, + 77, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 4, + }, + "start": Object { + "column": 17, + "line": 4, + }, + }, + "range": Array [ + 78, + 84, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 5, + }, + }, + "range": Array [ + 85, + 86, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/class-private-identifier-field-with-annotation.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/class-private-identifier-field-with-annotation.src.ts.shot new file mode 100644 index 000000000000..c75fc510111c --- /dev/null +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/class-private-identifier-field-with-annotation.src.ts.shot @@ -0,0 +1,888 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`typescript basics class-private-identifier-field-with-annotation.src 1`] = ` +Object { + "body": Array [ + Object { + "body": Object { + "body": Array [ + Object { + "computed": false, + "declare": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "name": "priv1", + "range": Array [ + 14, + 20, + ], + "type": "PrivateIdentifier", + }, + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "override": false, + "range": Array [ + 14, + 29, + ], + "readonly": undefined, + "static": false, + "type": "PropertyDefinition", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 8, + "line": 2, + }, + }, + "range": Array [ + 20, + 28, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 10, + "line": 2, + }, + }, + "range": Array [ + 22, + 28, + ], + "type": "TSNumberKeyword", + }, + }, + "value": null, + }, + Object { + "computed": false, + "declare": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "name": "priv2", + "range": Array [ + 32, + 38, + ], + "type": "PrivateIdentifier", + }, + "loc": Object { + "end": Object { + "column": 21, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "override": false, + "range": Array [ + 32, + 51, + ], + "readonly": undefined, + "static": false, + "type": "PropertyDefinition", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "range": Array [ + 38, + 46, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 3, + }, + }, + "range": Array [ + 40, + 46, + ], + "type": "TSNumberKeyword", + }, + }, + "value": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 3, + }, + "start": Object { + "column": 19, + "line": 3, + }, + }, + "range": Array [ + 49, + 50, + ], + "raw": "1", + "type": "Literal", + "value": 1, + }, + }, + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 5, + }, + "start": Object { + "column": 2, + "line": 5, + }, + }, + "name": "constructor", + "range": Array [ + 55, + 66, + ], + "type": "Identifier", + }, + "kind": "constructor", + "loc": Object { + "end": Object { + "column": 3, + "line": 7, + }, + "start": Object { + "column": 2, + "line": 5, + }, + }, + "override": false, + "range": Array [ + 55, + 95, + ], + "static": false, + "type": "MethodDefinition", + "value": Object { + "async": false, + "body": Object { + "body": Array [ + Object { + "expression": Object { + "left": Object { + "computed": false, + "loc": Object { + "end": Object { + "column": 15, + "line": 6, + }, + "start": Object { + "column": 4, + "line": 6, + }, + }, + "object": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 6, + }, + "start": Object { + "column": 4, + "line": 6, + }, + }, + "range": Array [ + 75, + 79, + ], + "type": "ThisExpression", + }, + "optional": false, + "property": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 6, + }, + "start": Object { + "column": 9, + "line": 6, + }, + }, + "name": "priv1", + "range": Array [ + 80, + 86, + ], + "type": "PrivateIdentifier", + }, + "range": Array [ + 75, + 86, + ], + "type": "MemberExpression", + }, + "loc": Object { + "end": Object { + "column": 19, + "line": 6, + }, + "start": Object { + "column": 4, + "line": 6, + }, + }, + "operator": "=", + "range": Array [ + 75, + 90, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 6, + }, + "start": Object { + "column": 18, + "line": 6, + }, + }, + "range": Array [ + 89, + 90, + ], + "raw": "1", + "type": "Literal", + "value": 1, + }, + "type": "AssignmentExpression", + }, + "loc": Object { + "end": Object { + "column": 20, + "line": 6, + }, + "start": Object { + "column": 4, + "line": 6, + }, + }, + "range": Array [ + 75, + 91, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 3, + "line": 7, + }, + "start": Object { + "column": 16, + "line": 5, + }, + }, + "range": Array [ + 69, + 95, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 3, + "line": 7, + }, + "start": Object { + "column": 13, + "line": 5, + }, + }, + "params": Array [], + "range": Array [ + 66, + 95, + ], + "type": "FunctionExpression", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 8, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 97, + ], + "type": "ClassBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 8, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 97, + ], + "superClass": null, + "type": "ClassDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 9, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 98, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "class", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 14, + 20, + ], + "type": "Identifier", + "value": "#priv1", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 2, + }, + "start": Object { + "column": 8, + "line": 2, + }, + }, + "range": Array [ + 20, + 21, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 10, + "line": 2, + }, + }, + "range": Array [ + 22, + 28, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 28, + 29, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "range": Array [ + 32, + 38, + ], + "type": "Identifier", + "value": "#priv2", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "range": Array [ + 38, + 39, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 3, + }, + }, + "range": Array [ + 40, + 46, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 3, + }, + "start": Object { + "column": 17, + "line": 3, + }, + }, + "range": Array [ + 47, + 48, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 3, + }, + "start": Object { + "column": 19, + "line": 3, + }, + }, + "range": Array [ + 49, + 50, + ], + "type": "Numeric", + "value": "1", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 3, + }, + "start": Object { + "column": 20, + "line": 3, + }, + }, + "range": Array [ + 50, + 51, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 5, + }, + "start": Object { + "column": 2, + "line": 5, + }, + }, + "range": Array [ + 55, + 66, + ], + "type": "Identifier", + "value": "constructor", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 5, + }, + "start": Object { + "column": 13, + "line": 5, + }, + }, + "range": Array [ + 66, + 67, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 5, + }, + "start": Object { + "column": 14, + "line": 5, + }, + }, + "range": Array [ + 67, + 68, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 5, + }, + "start": Object { + "column": 16, + "line": 5, + }, + }, + "range": Array [ + 69, + 70, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 6, + }, + "start": Object { + "column": 4, + "line": 6, + }, + }, + "range": Array [ + 75, + 79, + ], + "type": "Keyword", + "value": "this", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 6, + }, + "start": Object { + "column": 8, + "line": 6, + }, + }, + "range": Array [ + 79, + 80, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 6, + }, + "start": Object { + "column": 9, + "line": 6, + }, + }, + "range": Array [ + 80, + 86, + ], + "type": "Identifier", + "value": "#priv1", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 6, + }, + "start": Object { + "column": 16, + "line": 6, + }, + }, + "range": Array [ + 87, + 88, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 6, + }, + "start": Object { + "column": 18, + "line": 6, + }, + }, + "range": Array [ + 89, + 90, + ], + "type": "Numeric", + "value": "1", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 6, + }, + "start": Object { + "column": 19, + "line": 6, + }, + }, + "range": Array [ + 90, + 91, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 7, + }, + "start": Object { + "column": 2, + "line": 7, + }, + }, + "range": Array [ + 94, + 95, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 8, + }, + "start": Object { + "column": 0, + "line": 8, + }, + }, + "range": Array [ + 96, + 97, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; diff --git a/packages/typescript-estree/tests/snapshots/typescript/basics/class-private-identifier-readonly-field.src.ts.shot b/packages/typescript-estree/tests/snapshots/typescript/basics/class-private-identifier-readonly-field.src.ts.shot new file mode 100644 index 000000000000..1131eb4ab21e --- /dev/null +++ b/packages/typescript-estree/tests/snapshots/typescript/basics/class-private-identifier-readonly-field.src.ts.shot @@ -0,0 +1,301 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`typescript basics class-private-identifier-readonly-field.src 1`] = ` +Object { + "body": Array [ + Object { + "body": Object { + "body": Array [ + Object { + "computed": false, + "declare": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 11, + "line": 2, + }, + }, + "name": "priv", + "range": Array [ + 23, + 28, + ], + "type": "PrivateIdentifier", + }, + "loc": Object { + "end": Object { + "column": 24, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "override": false, + "range": Array [ + 14, + 36, + ], + "readonly": true, + "static": false, + "type": "PropertyDefinition", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 28, + 36, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 2, + }, + "start": Object { + "column": 18, + "line": 2, + }, + }, + "range": Array [ + 30, + 36, + ], + "type": "TSStringKeyword", + }, + }, + "value": null, + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 38, + ], + "type": "ClassBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 38, + ], + "superClass": null, + "type": "ClassDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 39, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "class", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 14, + 22, + ], + "type": "Identifier", + "value": "readonly", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 11, + "line": 2, + }, + }, + "range": Array [ + 23, + 28, + ], + "type": "Identifier", + "value": "#priv", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 28, + 29, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 2, + }, + "start": Object { + "column": 18, + "line": 2, + }, + }, + "range": Array [ + 30, + 36, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 37, + 38, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; diff --git a/packages/visitor-keys/package.json b/packages/visitor-keys/package.json index aed915b8613d..5ea3a984b532 100644 --- a/packages/visitor-keys/package.json +++ b/packages/visitor-keys/package.json @@ -39,7 +39,7 @@ }, "dependencies": { "@typescript-eslint/types": "4.33.0", - "eslint-visitor-keys": "^2.0.0" + "eslint-visitor-keys": "^3.0.0" }, "devDependencies": { "@types/eslint-visitor-keys": "*" From 4b096442f731c0a60926ac0391a4f2c4208aa8d4 Mon Sep 17 00:00:00 2001 From: Yosuke Ota Date: Mon, 30 Aug 2021 04:59:21 +0900 Subject: [PATCH 34/44] fix(eslint-plugin): crash in no-dupe-class-members (v5) (#3813) --- .../src/rules/no-dupe-class-members.ts | 13 ++++++----- .../tests/rules/no-dupe-class-members.test.ts | 22 +++++++++++++++++++ .../eslint-plugin/typings/eslint-rules.d.ts | 4 ++-- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/packages/eslint-plugin/src/rules/no-dupe-class-members.ts b/packages/eslint-plugin/src/rules/no-dupe-class-members.ts index dcc8b705038a..e9cb151d6d69 100644 --- a/packages/eslint-plugin/src/rules/no-dupe-class-members.ts +++ b/packages/eslint-plugin/src/rules/no-dupe-class-members.ts @@ -27,15 +27,18 @@ export default util.createRule({ create(context) { const rules = baseRule.create(context); - function wrapMemberDefinitionListener( - coreListener: (node: TSESTree.MethodDefinition) => void, - ): (node: TSESTree.MethodDefinition) => void { - return (node: TSESTree.MethodDefinition): void => { + function wrapMemberDefinitionListener< + N extends TSESTree.MethodDefinition | TSESTree.PropertyDefinition, + >(coreListener: (node: N) => void): (node: N) => void { + return (node: N): void => { if (node.computed) { return; } - if (node.value.type === AST_NODE_TYPES.TSEmptyBodyFunctionExpression) { + if ( + node.value && + node.value.type === AST_NODE_TYPES.TSEmptyBodyFunctionExpression + ) { return; } diff --git a/packages/eslint-plugin/tests/rules/no-dupe-class-members.test.ts b/packages/eslint-plugin/tests/rules/no-dupe-class-members.test.ts index 50cbdba54107..5cfbc5e3128d 100644 --- a/packages/eslint-plugin/tests/rules/no-dupe-class-members.test.ts +++ b/packages/eslint-plugin/tests/rules/no-dupe-class-members.test.ts @@ -166,6 +166,28 @@ class A { class A { set foo(value) {} foo() {} +} + `, + errors: [ + { line: 4, column: 3, messageId: 'unexpected', data: { name: 'foo' } }, + ], + }, + { + code: ` +class A { + foo; + foo = 42; +} + `, + errors: [ + { line: 4, column: 3, messageId: 'unexpected', data: { name: 'foo' } }, + ], + }, + { + code: ` +class A { + foo; + foo() {} } `, errors: [ diff --git a/packages/eslint-plugin/typings/eslint-rules.d.ts b/packages/eslint-plugin/typings/eslint-rules.d.ts index aa833057ba20..44b679281fbd 100644 --- a/packages/eslint-plugin/typings/eslint-rules.d.ts +++ b/packages/eslint-plugin/typings/eslint-rules.d.ts @@ -234,7 +234,7 @@ declare module 'eslint/lib/rules/no-dupe-class-members' { MethodDefinition?: (node: TSESTree.MethodDefinition) => void; // for ESLint v8 'MethodDefinition, PropertyDefinition'?: ( - node: TSESTree.MethodDefinition /* | TSESTree.PropertyDefinition */, + node: TSESTree.MethodDefinition | TSESTree.PropertyDefinition, ) => void; } >; @@ -646,7 +646,7 @@ declare module 'eslint/lib/rules/no-extra-semi' { MethodDefinition?: (node: TSESTree.MethodDefinition) => void; // for ESLint v8 'MethodDefinition, PropertyDefinition'?: ( - node: TSESTree.MethodDefinition /* | TSESTree.PropertyDefinition */, + node: TSESTree.MethodDefinition | TSESTree.PropertyDefinition, ) => void; } >; From deeb7bb9334d301c6af56aefd37d318231af11ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Mon, 30 Aug 2021 08:16:45 +0200 Subject: [PATCH 35/44] feat(eslint-plugin): update recommended configs (#3809) --- packages/eslint-plugin/README.md | 11 ++-- packages/eslint-plugin/src/configs/all.ts | 1 - .../recommended-requiring-type-checking.ts | 2 +- .../eslint-plugin/src/configs/recommended.ts | 4 +- .../rules/explicit-module-boundary-types.ts | 2 +- .../src/rules/no-implicit-any-catch.ts | 1 + .../src/rules/no-loss-of-precision.ts | 2 +- .../rules/no-unnecessary-type-constraint.ts | 2 +- .../src/rules/no-unsafe-argument.ts | 3 +- .../src/rules/prefer-regexp-exec.ts | 2 +- .../typescript-estree/src/ast-converter.ts | 6 +- packages/typescript-estree/src/convert.ts | 65 +++++++++++++------ .../src/create-program/createWatchProgram.ts | 2 +- .../src/semantic-or-syntactic-errors.ts | 25 +++---- .../tests/ast-alignment/parse.ts | 18 ++--- .../tests/ast-alignment/spec.ts | 15 +++-- .../tests/ast-alignment/utils.ts | 8 +-- .../tests/lib/convert.test.ts | 9 +-- .../typescript-estree/tools/test-utils.ts | 20 +++--- tests/jest-resolver.js | 1 + 20 files changed, 121 insertions(+), 78 deletions(-) diff --git a/packages/eslint-plugin/README.md b/packages/eslint-plugin/README.md index 87ed9c2a276d..6b7c2701ffa0 100644 --- a/packages/eslint-plugin/README.md +++ b/packages/eslint-plugin/README.md @@ -110,7 +110,7 @@ Pro Tip: For larger codebases you may want to consider splitting our linting int | [`@typescript-eslint/consistent-type-imports`](./docs/rules/consistent-type-imports.md) | Enforces consistent usage of type imports | | :wrench: | | | [`@typescript-eslint/explicit-function-return-type`](./docs/rules/explicit-function-return-type.md) | Require explicit return types on functions and class methods | | | | | [`@typescript-eslint/explicit-member-accessibility`](./docs/rules/explicit-member-accessibility.md) | Require explicit accessibility modifiers on class properties and methods | | :wrench: | | -| [`@typescript-eslint/explicit-module-boundary-types`](./docs/rules/explicit-module-boundary-types.md) | Require explicit return and argument types on exported functions' and classes' public class methods | :white_check_mark: | | | +| [`@typescript-eslint/explicit-module-boundary-types`](./docs/rules/explicit-module-boundary-types.md) | Require explicit return and argument types on exported functions' and classes' public class methods | | | | | [`@typescript-eslint/member-delimiter-style`](./docs/rules/member-delimiter-style.md) | Require a specific member delimiter style for interfaces and type literals | | :wrench: | | | [`@typescript-eslint/member-ordering`](./docs/rules/member-ordering.md) | Require a consistent member declaration order | | | | | [`@typescript-eslint/method-signature-style`](./docs/rules/method-signature-style.md) | Enforces using a particular method signature syntax. | | :wrench: | | @@ -125,7 +125,6 @@ Pro Tip: For larger codebases you may want to consider splitting our linting int | [`@typescript-eslint/no-extraneous-class`](./docs/rules/no-extraneous-class.md) | Forbids the use of classes as namespaces | | | | | [`@typescript-eslint/no-floating-promises`](./docs/rules/no-floating-promises.md) | Requires Promise-like values to be handled appropriately | :white_check_mark: | | :thought_balloon: | | [`@typescript-eslint/no-for-in-array`](./docs/rules/no-for-in-array.md) | Disallow iterating over an array with a for-in loop | :white_check_mark: | | :thought_balloon: | -| [`@typescript-eslint/no-implicit-any-catch`](./docs/rules/no-implicit-any-catch.md) | Disallow usage of the implicit `any` type in catch clauses | | :wrench: | | | [`@typescript-eslint/no-inferrable-types`](./docs/rules/no-inferrable-types.md) | Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean | :white_check_mark: | :wrench: | | | [`@typescript-eslint/no-invalid-void-type`](./docs/rules/no-invalid-void-type.md) | Disallows usage of `void` type outside of generic or return types | | | | | [`@typescript-eslint/no-meaningless-void-operator`](./docs/rules/no-meaningless-void-operator.md) | Disallow the `void` operator except when used to discard a value | | :wrench: | :thought_balloon: | @@ -144,8 +143,8 @@ Pro Tip: For larger codebases you may want to consider splitting our linting int | [`@typescript-eslint/no-unnecessary-qualifier`](./docs/rules/no-unnecessary-qualifier.md) | Warns when a namespace qualifier is unnecessary | | :wrench: | :thought_balloon: | | [`@typescript-eslint/no-unnecessary-type-arguments`](./docs/rules/no-unnecessary-type-arguments.md) | Enforces that type arguments will not be used if not required | | :wrench: | :thought_balloon: | | [`@typescript-eslint/no-unnecessary-type-assertion`](./docs/rules/no-unnecessary-type-assertion.md) | Warns if a type assertion does not change the type of an expression | :white_check_mark: | :wrench: | :thought_balloon: | -| [`@typescript-eslint/no-unnecessary-type-constraint`](./docs/rules/no-unnecessary-type-constraint.md) | Disallows unnecessary constraints on generic types | | :wrench: | | -| [`@typescript-eslint/no-unsafe-argument`](./docs/rules/no-unsafe-argument.md) | Disallows calling a function with an any type value | | | :thought_balloon: | +| [`@typescript-eslint/no-unnecessary-type-constraint`](./docs/rules/no-unnecessary-type-constraint.md) | Disallows unnecessary constraints on generic types | :white_check_mark: | :wrench: | | +| [`@typescript-eslint/no-unsafe-argument`](./docs/rules/no-unsafe-argument.md) | Disallows calling a function with an any type value | :white_check_mark: | | :thought_balloon: | | [`@typescript-eslint/no-unsafe-assignment`](./docs/rules/no-unsafe-assignment.md) | Disallows assigning any to variables and properties | :white_check_mark: | | :thought_balloon: | | [`@typescript-eslint/no-unsafe-call`](./docs/rules/no-unsafe-call.md) | Disallows calling an any type value | :white_check_mark: | | :thought_balloon: | | [`@typescript-eslint/no-unsafe-member-access`](./docs/rules/no-unsafe-member-access.md) | Disallows member access on any typed variables | :white_check_mark: | | :thought_balloon: | @@ -164,7 +163,7 @@ Pro Tip: For larger codebases you may want to consider splitting our linting int | [`@typescript-eslint/prefer-readonly`](./docs/rules/prefer-readonly.md) | Requires that private members are marked as `readonly` if they're never modified outside of the constructor | | :wrench: | :thought_balloon: | | [`@typescript-eslint/prefer-readonly-parameter-types`](./docs/rules/prefer-readonly-parameter-types.md) | Requires that function parameters are typed as readonly to prevent accidental mutation of inputs | | | :thought_balloon: | | [`@typescript-eslint/prefer-reduce-type-parameter`](./docs/rules/prefer-reduce-type-parameter.md) | Prefer using type parameter when calling `Array#reduce` instead of casting | | :wrench: | :thought_balloon: | -| [`@typescript-eslint/prefer-regexp-exec`](./docs/rules/prefer-regexp-exec.md) | Enforce that `RegExp#exec` is used instead of `String#match` if no global flag is provided | :white_check_mark: | :wrench: | :thought_balloon: | +| [`@typescript-eslint/prefer-regexp-exec`](./docs/rules/prefer-regexp-exec.md) | Enforce that `RegExp#exec` is used instead of `String#match` if no global flag is provided | | :wrench: | :thought_balloon: | | [`@typescript-eslint/prefer-return-this-type`](./docs/rules/prefer-return-this-type.md) | Enforce that `this` is used when only `this` type is returned | | :wrench: | :thought_balloon: | | [`@typescript-eslint/prefer-string-starts-ends-with`](./docs/rules/prefer-string-starts-ends-with.md) | Enforce the use of `String#startsWith` and `String#endsWith` instead of other equivalent methods of checking substrings | | :wrench: | :thought_balloon: | | [`@typescript-eslint/prefer-ts-expect-error`](./docs/rules/prefer-ts-expect-error.md) | Recommends using `@ts-expect-error` over `@ts-ignore` | | :wrench: | | @@ -213,7 +212,7 @@ In these cases, we create what we call an extension rule; a rule within our plug | [`@typescript-eslint/no-implied-eval`](./docs/rules/no-implied-eval.md) | Disallow the use of `eval()`-like methods | :white_check_mark: | | :thought_balloon: | | [`@typescript-eslint/no-invalid-this`](./docs/rules/no-invalid-this.md) | Disallow `this` keywords outside of classes or class-like objects | | | | | [`@typescript-eslint/no-loop-func`](./docs/rules/no-loop-func.md) | Disallow function declarations that contain unsafe references inside loop statements | | | | -| [`@typescript-eslint/no-loss-of-precision`](./docs/rules/no-loss-of-precision.md) | Disallow literal numbers that lose precision | | | | +| [`@typescript-eslint/no-loss-of-precision`](./docs/rules/no-loss-of-precision.md) | Disallow literal numbers that lose precision | :white_check_mark: | | | | [`@typescript-eslint/no-magic-numbers`](./docs/rules/no-magic-numbers.md) | Disallow magic numbers | | | | | [`@typescript-eslint/no-redeclare`](./docs/rules/no-redeclare.md) | Disallow variable redeclaration | | | | | [`@typescript-eslint/no-restricted-imports`](./docs/rules/no-restricted-imports.md) | Disallow specified modules when loaded by `import` | | | | diff --git a/packages/eslint-plugin/src/configs/all.ts b/packages/eslint-plugin/src/configs/all.ts index eff553b5b9b7..17c06645e61e 100644 --- a/packages/eslint-plugin/src/configs/all.ts +++ b/packages/eslint-plugin/src/configs/all.ts @@ -65,7 +65,6 @@ export = { '@typescript-eslint/no-extraneous-class': 'error', '@typescript-eslint/no-floating-promises': 'error', '@typescript-eslint/no-for-in-array': 'error', - '@typescript-eslint/no-implicit-any-catch': 'error', 'no-implied-eval': 'off', '@typescript-eslint/no-implied-eval': 'error', '@typescript-eslint/no-inferrable-types': 'error', diff --git a/packages/eslint-plugin/src/configs/recommended-requiring-type-checking.ts b/packages/eslint-plugin/src/configs/recommended-requiring-type-checking.ts index fecfa6002af9..369d33d6687e 100644 --- a/packages/eslint-plugin/src/configs/recommended-requiring-type-checking.ts +++ b/packages/eslint-plugin/src/configs/recommended-requiring-type-checking.ts @@ -12,11 +12,11 @@ export = { '@typescript-eslint/no-implied-eval': 'error', '@typescript-eslint/no-misused-promises': 'error', '@typescript-eslint/no-unnecessary-type-assertion': 'error', + '@typescript-eslint/no-unsafe-argument': 'error', '@typescript-eslint/no-unsafe-assignment': 'error', '@typescript-eslint/no-unsafe-call': 'error', '@typescript-eslint/no-unsafe-member-access': 'error', '@typescript-eslint/no-unsafe-return': 'error', - '@typescript-eslint/prefer-regexp-exec': 'error', 'require-await': 'off', '@typescript-eslint/require-await': 'error', '@typescript-eslint/restrict-plus-operands': 'error', diff --git a/packages/eslint-plugin/src/configs/recommended.ts b/packages/eslint-plugin/src/configs/recommended.ts index d9450197c415..10b1d04581fb 100644 --- a/packages/eslint-plugin/src/configs/recommended.ts +++ b/packages/eslint-plugin/src/configs/recommended.ts @@ -8,7 +8,6 @@ export = { '@typescript-eslint/adjacent-overload-signatures': 'error', '@typescript-eslint/ban-ts-comment': 'error', '@typescript-eslint/ban-types': 'error', - '@typescript-eslint/explicit-module-boundary-types': 'warn', 'no-array-constructor': 'off', '@typescript-eslint/no-array-constructor': 'error', 'no-empty-function': 'off', @@ -19,11 +18,14 @@ export = { 'no-extra-semi': 'off', '@typescript-eslint/no-extra-semi': 'error', '@typescript-eslint/no-inferrable-types': 'error', + 'no-loss-of-precision': 'off', + '@typescript-eslint/no-loss-of-precision': 'error', '@typescript-eslint/no-misused-new': 'error', '@typescript-eslint/no-namespace': 'error', '@typescript-eslint/no-non-null-asserted-optional-chain': 'error', '@typescript-eslint/no-non-null-assertion': 'warn', '@typescript-eslint/no-this-alias': 'error', + '@typescript-eslint/no-unnecessary-type-constraint': 'error', 'no-unused-vars': 'off', '@typescript-eslint/no-unused-vars': 'warn', '@typescript-eslint/no-var-requires': 'error', diff --git a/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts b/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts index f9670cc98ee3..94f492bf06ca 100644 --- a/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts +++ b/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts @@ -37,7 +37,7 @@ export default util.createRule({ docs: { description: "Require explicit return and argument types on exported functions' and classes' public class methods", - recommended: 'warn', + recommended: false, }, messages: { missingReturnType: 'Missing return type on function.', diff --git a/packages/eslint-plugin/src/rules/no-implicit-any-catch.ts b/packages/eslint-plugin/src/rules/no-implicit-any-catch.ts index f933336866b7..aa050794c4ae 100644 --- a/packages/eslint-plugin/src/rules/no-implicit-any-catch.ts +++ b/packages/eslint-plugin/src/rules/no-implicit-any-catch.ts @@ -17,6 +17,7 @@ export type MessageIds = export default util.createRule({ name: 'no-implicit-any-catch', meta: { + deprecated: true, type: 'suggestion', docs: { description: 'Disallow usage of the implicit `any` type in catch clauses', diff --git a/packages/eslint-plugin/src/rules/no-loss-of-precision.ts b/packages/eslint-plugin/src/rules/no-loss-of-precision.ts index 955032474755..d095def03cc9 100644 --- a/packages/eslint-plugin/src/rules/no-loss-of-precision.ts +++ b/packages/eslint-plugin/src/rules/no-loss-of-precision.ts @@ -15,7 +15,7 @@ export default util.createRule({ type: 'problem', docs: { description: 'Disallow literal numbers that lose precision', - recommended: false, + recommended: 'error', extendsBaseRule: true, }, hasSuggestions: baseRule?.meta.hasSuggestions, diff --git a/packages/eslint-plugin/src/rules/no-unnecessary-type-constraint.ts b/packages/eslint-plugin/src/rules/no-unnecessary-type-constraint.ts index 535cae96023b..68895c01e71d 100644 --- a/packages/eslint-plugin/src/rules/no-unnecessary-type-constraint.ts +++ b/packages/eslint-plugin/src/rules/no-unnecessary-type-constraint.ts @@ -33,7 +33,7 @@ export default util.createRule({ meta: { docs: { description: 'Disallows unnecessary constraints on generic types', - recommended: false, + recommended: 'error', suggestion: true, }, fixable: 'code', diff --git a/packages/eslint-plugin/src/rules/no-unsafe-argument.ts b/packages/eslint-plugin/src/rules/no-unsafe-argument.ts index 46ed36a0dc3d..3df1e6a486c0 100644 --- a/packages/eslint-plugin/src/rules/no-unsafe-argument.ts +++ b/packages/eslint-plugin/src/rules/no-unsafe-argument.ts @@ -138,8 +138,7 @@ export default util.createRule<[], MessageIds>({ type: 'problem', docs: { description: 'Disallows calling a function with an any type value', - // TODO - enable this with next breaking - recommended: false, + recommended: 'error', requiresTypeChecking: true, }, messages: { diff --git a/packages/eslint-plugin/src/rules/prefer-regexp-exec.ts b/packages/eslint-plugin/src/rules/prefer-regexp-exec.ts index 93ac0cda6409..bb91f3408460 100644 --- a/packages/eslint-plugin/src/rules/prefer-regexp-exec.ts +++ b/packages/eslint-plugin/src/rules/prefer-regexp-exec.ts @@ -29,7 +29,7 @@ export default createRule({ docs: { description: 'Enforce that `RegExp#exec` is used instead of `String#match` if no global flag is provided', - recommended: 'error', + recommended: false, requiresTypeChecking: true, }, messages: { diff --git a/packages/typescript-estree/src/ast-converter.ts b/packages/typescript-estree/src/ast-converter.ts index 465a0b955c47..49ffd28f479e 100644 --- a/packages/typescript-estree/src/ast-converter.ts +++ b/packages/typescript-estree/src/ast-converter.ts @@ -1,9 +1,9 @@ -import { SourceFile } from 'typescript'; +import type { SourceFile } from 'typescript'; import { convertError, Converter, ASTMaps } from './convert'; import { convertComments } from './convert-comments'; import { convertTokens } from './node-utils'; -import { Extra } from './parser-options'; -import { TSESTree } from './ts-estree'; +import type { Extra } from './parser-options'; +import type { TSESTree } from './ts-estree'; import { simpleTraverse } from './simple-traverse'; export function astConverter( diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index e800233a7106..37af8556cca4 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -23,7 +23,11 @@ import { TSError, unescapeStringLiteralText, } from './node-utils'; -import { ParserWeakMap, ParserWeakMapESTreeToTSNode } from './parser-options'; +import type { + ParserWeakMap, + ParserWeakMapESTreeToTSNode, +} from './parser-options'; +import type { SemanticOrSyntacticError } from './semantic-or-syntactic-errors'; import { AST_NODE_TYPES, TSESTree, @@ -31,6 +35,7 @@ import { TSNode, } from './ts-estree'; import { typescriptVersionIsAtLeast } from './version-check'; +import { Expression } from '@typescript-eslint/types/src/ast-spec'; const SyntaxKind = ts.SyntaxKind; @@ -44,11 +49,13 @@ interface ConverterOptions { * @param error the error object * @returns converted error object */ -export function convertError(error: any): TSError { +export function convertError( + error: ts.DiagnosticWithLocation | SemanticOrSyntacticError, +): TSError { return createError( - error.file, - error.start, - error.message || error.messageText, + error.file!, + error.start!, + ('message' in error && error.message) || (error.messageText as string), ); } @@ -264,7 +271,7 @@ export class Converter { tsType: ts.TypeNode | undefined, parent?: ts.Node, ): TSESTree.BindingName { - const id = this.convertPattern(name); + const id = this.convertPattern(name) as TSESTree.BindingName; if (tsType) { id.typeAnnotation = this.convertTypeAnnotation(tsType, parent); @@ -509,10 +516,10 @@ export class Converter { ) .forEach(([key, value]) => { if (Array.isArray(value)) { - result[key] = value.map(el => this.convertChild(el)); + result[key] = value.map(el => this.convertChild(el as TSNode)); } else if (value && typeof value === 'object' && value.kind) { // need to check node[key].kind to ensure we don't try to convert a symbol - result[key] = this.convertChild(value); + result[key] = this.convertChild(value as TSNode); } else { result[key] = value; } @@ -694,7 +701,9 @@ export class Converter { result.declare = true; break; default: - remainingModifiers.push(this.convertChild(modifier)); + remainingModifiers.push( + this.convertChild(modifier) as TSESTree.Modifier, + ); break; } } @@ -1505,8 +1514,12 @@ export class Converter { }); node.templateSpans.forEach(templateSpan => { - result.expressions.push(this.convertChild(templateSpan.expression)); - result.quasis.push(this.convertChild(templateSpan.literal)); + result.expressions.push( + this.convertChild(templateSpan.expression) as TSESTree.Expression, + ); + result.quasis.push( + this.convertChild(templateSpan.literal) as TSESTree.TemplateElement, + ); }); return result; } @@ -1731,14 +1744,18 @@ export class Converter { } if (node.importClause.name) { - result.specifiers.push(this.convertChild(node.importClause)); + result.specifiers.push( + this.convertChild(node.importClause) as TSESTree.ImportClause, + ); } if (node.importClause.namedBindings) { switch (node.importClause.namedBindings.kind) { case SyntaxKind.NamespaceImport: result.specifiers.push( - this.convertChild(node.importClause.namedBindings), + this.convertChild( + node.importClause.namedBindings, + ) as TSESTree.ImportClause, ); break; case SyntaxKind.NamedImports: @@ -1893,7 +1910,7 @@ export class Converter { expressions: [], }); - const left = this.convertChild(node.left); + const left = this.convertChild(node.left) as Expression; if ( left.type === AST_NODE_TYPES.SequenceExpression && node.left.kind !== SyntaxKind.ParenthesizedExpression @@ -1903,7 +1920,9 @@ export class Converter { result.expressions.push(left); } - result.expressions.push(this.convertChild(node.right)); + result.expressions.push( + this.convertChild(node.right) as TSESTree.Expression, + ); return result; } else { const type = getBinaryExpressionType(node.operatorToken); @@ -2584,11 +2603,15 @@ export class Converter { for (const heritageClause of interfaceHeritageClauses) { if (heritageClause.token === SyntaxKind.ExtendsKeyword) { for (const n of heritageClause.types) { - interfaceExtends.push(this.convertChild(n, node)); + interfaceExtends.push( + this.convertChild(n, node) as TSESTree.TSInterfaceHeritage, + ); } } else { for (const n of heritageClause.types) { - interfaceImplements.push(this.convertChild(n, node)); + interfaceImplements.push( + this.convertChild(n, node) as TSESTree.TSInterfaceHeritage, + ); } } } @@ -2830,8 +2853,12 @@ export class Converter { }); node.templateSpans.forEach(templateSpan => { - result.types.push(this.convertChild(templateSpan.type)); - result.quasis.push(this.convertChild(templateSpan.literal)); + result.types.push( + this.convertChild(templateSpan.type) as TSESTree.TypeNode, + ); + result.quasis.push( + this.convertChild(templateSpan.literal) as TSESTree.TemplateElement, + ); }); return result; } diff --git a/packages/typescript-estree/src/create-program/createWatchProgram.ts b/packages/typescript-estree/src/create-program/createWatchProgram.ts index 2142065e47b0..ae2dec4de514 100644 --- a/packages/typescript-estree/src/create-program/createWatchProgram.ts +++ b/packages/typescript-estree/src/create-program/createWatchProgram.ts @@ -370,7 +370,7 @@ function createWatchProgram( log('Running without timeout fix'); // But because of https://github.com/microsoft/TypeScript/pull/37308 we cannot just set it to undefined // instead save it and call before getProgram is called - watchCompilerHost.setTimeout = (cb, _ms, ...args): unknown => { + watchCompilerHost.setTimeout = (cb, _ms, ...args: unknown[]): unknown => { callback = cb.bind(/*this*/ undefined, ...args); return callback; }; diff --git a/packages/typescript-estree/src/semantic-or-syntactic-errors.ts b/packages/typescript-estree/src/semantic-or-syntactic-errors.ts index fab5cd642e09..af6f33918df1 100644 --- a/packages/typescript-estree/src/semantic-or-syntactic-errors.ts +++ b/packages/typescript-estree/src/semantic-or-syntactic-errors.ts @@ -1,6 +1,12 @@ -import * as ts from 'typescript'; +import type { + Diagnostic, + DiagnosticWithLocation, + Program, + SourceFile, +} from 'typescript'; +import { flattenDiagnosticMessageText, sys } from 'typescript'; -interface SemanticOrSyntacticError extends ts.Diagnostic { +export interface SemanticOrSyntacticError extends Diagnostic { message: string; } @@ -12,8 +18,8 @@ interface SemanticOrSyntacticError extends ts.Diagnostic { * the user opts in to throwing errors on semantic issues. */ export function getFirstSemanticOrSyntacticError( - program: ts.Program, - ast: ts.SourceFile, + program: Program, + ast: SourceFile, ): SemanticOrSyntacticError | undefined { try { const supportedSyntacticDiagnostics = whitelistSupportedDiagnostics( @@ -52,8 +58,8 @@ export function getFirstSemanticOrSyntacticError( } function whitelistSupportedDiagnostics( - diagnostics: readonly (ts.DiagnosticWithLocation | ts.Diagnostic)[], -): readonly (ts.DiagnosticWithLocation | ts.Diagnostic)[] { + diagnostics: readonly (DiagnosticWithLocation | Diagnostic)[], +): readonly (DiagnosticWithLocation | Diagnostic)[] { return diagnostics.filter(diagnostic => { switch (diagnostic.code) { case 1013: // "A rest parameter or binding pattern may not have a trailing comma." @@ -103,13 +109,10 @@ function whitelistSupportedDiagnostics( } function convertDiagnosticToSemanticOrSyntacticError( - diagnostic: ts.Diagnostic, + diagnostic: Diagnostic, ): SemanticOrSyntacticError { return { ...diagnostic, - message: ts.flattenDiagnosticMessageText( - diagnostic.messageText, - ts.sys.newLine, - ), + message: flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine), }; } diff --git a/packages/typescript-estree/tests/ast-alignment/parse.ts b/packages/typescript-estree/tests/ast-alignment/parse.ts index 7d340278649e..701cf069ff42 100644 --- a/packages/typescript-estree/tests/ast-alignment/parse.ts +++ b/packages/typescript-estree/tests/ast-alignment/parse.ts @@ -1,11 +1,11 @@ /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */ - import type babelParser from '@babel/parser'; -import { ParserPlugin } from '@babel/parser'; +import type { ParserPlugin } from '@babel/parser'; import { codeFrameColumns } from '@babel/code-frame'; import type { File } from '@babel/types'; -import * as parser from '../../src/parser'; -import { TSESTree } from '@typescript-eslint/types'; +import type { TSESTree } from '@typescript-eslint/types'; +import { AST, parseAndGenerateServices } from '../../src/parser'; +import type { TSError } from '../../src/node-utils'; function createError( message: string, @@ -48,9 +48,9 @@ function parseWithBabelParser(text: string, jsx = true): File { }); } -function parseWithTypeScriptESTree(text: string, jsx = true): parser.AST { +function parseWithTypeScriptESTree(text: string, jsx = true): AST { try { - const result = parser.parseAndGenerateServices(text, { + const result = parseAndGenerateServices(text, { loc: true, range: true, tokens: false, @@ -66,8 +66,10 @@ function parseWithTypeScriptESTree(text: string, jsx = true): parser.AST { jsx, }); return result.ast; - } catch (e: any) { - throw createError(e.message, e.lineNumber, e.column); + } catch (e: unknown) { + const error = e as TSError; + + throw createError(error.message, error.lineNumber, error.column); } } diff --git a/packages/typescript-estree/tests/ast-alignment/spec.ts b/packages/typescript-estree/tests/ast-alignment/spec.ts index 9e308b73c643..8af9996fc9d6 100644 --- a/packages/typescript-estree/tests/ast-alignment/spec.ts +++ b/packages/typescript-estree/tests/ast-alignment/spec.ts @@ -1,7 +1,12 @@ import fs from 'fs'; +import type { File } from '@babel/types'; import { fixturesToTest } from './fixtures-to-test'; import { parse } from './parse'; -import * as parseUtils from './utils'; +import { + preprocessBabylonAST, + preprocessTypescriptAST, + removeLocationDataAndSourceTypeFromProgramNode, +} from './utils'; fixturesToTest.forEach(fixture => { const filename = fixture.filename; @@ -72,13 +77,13 @@ fixturesToTest.forEach(fixture => { * Perform some extra formatting steps on the babel AST before comparing */ expect( - parseUtils.removeLocationDataAndSourceTypeFromProgramNode( - parseUtils.preprocessBabylonAST(babelParserResult.ast), + removeLocationDataAndSourceTypeFromProgramNode( + preprocessBabylonAST(babelParserResult.ast as File), fixture.ignoreSourceType, ), ).toEqual( - parseUtils.removeLocationDataAndSourceTypeFromProgramNode( - parseUtils.preprocessTypescriptAST(typeScriptESTreeResult.ast), + removeLocationDataAndSourceTypeFromProgramNode( + preprocessTypescriptAST(typeScriptESTreeResult.ast), fixture.ignoreSourceType, ), ); diff --git a/packages/typescript-estree/tests/ast-alignment/utils.ts b/packages/typescript-estree/tests/ast-alignment/utils.ts index ad3500c89911..7066686303c3 100644 --- a/packages/typescript-estree/tests/ast-alignment/utils.ts +++ b/packages/typescript-estree/tests/ast-alignment/utils.ts @@ -1,8 +1,8 @@ // babel types are something we don't really care about /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/restrict-plus-operands */ +import type { File, Program } from '@babel/types'; import { AST_NODE_TYPES, TSESTree } from '../../src/ts-estree'; import { deeplyCopy, omitDeep } from '../../tools/test-utils'; -import * as BabelTypes from '@babel/types'; /** * Common predicates for Babylon AST preprocessing @@ -18,8 +18,8 @@ const ifNumber = (val: unknown): boolean => typeof val === 'number'; * @param ast raw babylon AST * @returns processed babylon AST */ -export function preprocessBabylonAST(ast: BabelTypes.File): any { - return omitDeep( +export function preprocessBabylonAST(ast: File): any { + return omitDeep( ast.program, [ { @@ -258,7 +258,7 @@ export function preprocessBabylonAST(ast: BabelTypes.File): any { * Once we use babel 8, this can be removed. * @see https://github.com/babel/babel/pull/12608 */ - TSParenthesizedType(node: any) { + TSParenthesizedType(node) { const { typeAnnotation } = node; Object.keys(node).forEach(key => delete node[key]); Object.assign(node, typeAnnotation); diff --git a/packages/typescript-estree/tests/lib/convert.test.ts b/packages/typescript-estree/tests/lib/convert.test.ts index 74ce08aa9673..277063b9d8cb 100644 --- a/packages/typescript-estree/tests/lib/convert.test.ts +++ b/packages/typescript-estree/tests/lib/convert.test.ts @@ -1,7 +1,8 @@ // deeplyCopy is private internal /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-call */ -import { Converter } from '../../src/convert'; import * as ts from 'typescript'; +import type { TSNode } from '../../src'; +import { Converter } from '../../src/convert'; describe('convert', () => { function convertCode(code: string): ts.SourceFile { @@ -114,7 +115,7 @@ describe('convert', () => { ) { expect(node).toBe( maps.esTreeNodeToTSNodeMap.get( - maps.tsNodeToESTreeNodeMap.get(node as any), + maps.tsNodeToESTreeNodeMap.get(node as TSNode), ), ); } @@ -146,7 +147,7 @@ describe('convert', () => { ) { expect(node).toBe( maps.esTreeNodeToTSNodeMap.get( - maps.tsNodeToESTreeNodeMap.get(node as any), + maps.tsNodeToESTreeNodeMap.get(node as TSNode), ), ); } @@ -187,7 +188,7 @@ describe('convert', () => { expect(maps.esTreeNodeToTSNodeMap.get(program.body[0])).toBeDefined(); expect(program.body[0]).not.toBe( - maps.tsNodeToESTreeNodeMap.get(ast.statements[0] as any), + maps.tsNodeToESTreeNodeMap.get(ast.statements[0] as TSNode), ); checkMaps(ast); }); diff --git a/packages/typescript-estree/tools/test-utils.ts b/packages/typescript-estree/tools/test-utils.ts index c07ab65b831d..65e1cb131e1d 100644 --- a/packages/typescript-estree/tools/test-utils.ts +++ b/packages/typescript-estree/tools/test-utils.ts @@ -1,11 +1,15 @@ -import * as parser from '../src'; -import { TSESTreeOptions } from '../src/parser-options'; +import type { + TSESTree, + TSESTreeOptions, + ParseAndGenerateServicesResult, +} from '../src'; +import { parse as parserParse, parseAndGenerateServices } from '../src'; export function parseCodeAndGenerateServices( code: string, config: TSESTreeOptions, -): parser.ParseAndGenerateServicesResult { - return parser.parseAndGenerateServices(code, config); +): ParseAndGenerateServicesResult { + return parseAndGenerateServices(code, config); } /** @@ -24,10 +28,10 @@ export function createSnapshotTestBlock( /** * @returns the AST object */ - function parse(): parser.TSESTree.Program { + function parse(): TSESTree.Program { const ast = generateServices - ? parser.parseAndGenerateServices(code, config).ast - : parser.parse(code, config); + ? parseAndGenerateServices(code, config).ast + : parserParse(code, config); return deeplyCopy(ast); } @@ -127,7 +131,7 @@ export function omitDeep( continue; } - const child = node[prop]; + const child = node[prop] as UnknownObject | UnknownObject[]; if (Array.isArray(child)) { const value = []; for (const el of child) { diff --git a/tests/jest-resolver.js b/tests/jest-resolver.js index f79f54509b79..a0460ee0ac43 100644 --- a/tests/jest-resolver.js +++ b/tests/jest-resolver.js @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unsafe-argument */ // https://github.com/facebook/jest/issues/9771#issuecomment-871585234 // temporary workaround while we wait for https://github.com/facebook/jest/issues/9771 From ae3fa900d5b4e1f557a52ca58d35a7d098d9efaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Mon, 30 Aug 2021 18:59:56 +0200 Subject: [PATCH 36/44] feat(eslint-plugin): remove `object` from `ban-types`' default types (#3818) BREAKING CHANGE: `ban-types` no longer reports `object` by default --- packages/eslint-plugin/docs/rules/ban-types.md | 14 ++------------ packages/eslint-plugin/src/rules/ban-types.ts | 6 ------ 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/packages/eslint-plugin/docs/rules/ban-types.md b/packages/eslint-plugin/docs/rules/ban-types.md index bf59ffb84618..ebcec5775123 100644 --- a/packages/eslint-plugin/docs/rules/ban-types.md +++ b/packages/eslint-plugin/docs/rules/ban-types.md @@ -75,8 +75,6 @@ The default options provide a set of "best practices", intended to provide safet - Avoid the `Object` and `{}` types, as they mean "any non-nullish value". - This is a point of confusion for many developers, who think it means "any object type". - See [this comment for more information](https://github.com/typescript-eslint/typescript-eslint/issues/2063#issuecomment-675156492). -- Avoid the `object` type, as it is currently hard to use due to not being able to assert that keys exist. - - See [microsoft/TypeScript#21732](https://github.com/microsoft/TypeScript/issues/21732). **_Important note:_** the default options suggest using `Record`; this was a stylistic decision, as the built-in `Record` type is considered to look cleaner. @@ -126,12 +124,6 @@ const defaultTypes = { '- If you want a type meaning "any value", you probably want `unknown` instead.', ].join('\n'), }, - object: { - message: [ - 'The `object` type is currently hard to use ([see this issue](https://github.com/microsoft/TypeScript/issues/21732)).', - 'Consider using `Record` instead, as it allows you to more easily inspect and use the keys.', - ].join('\n'), - }, }; ``` @@ -152,8 +144,6 @@ const symb: Symbol = Symbol('foo'); const func: Function = () => 1; // use safer object types -const lowerObj: object = {}; - const capitalObj1: Object = 1; const capitalObj2: Object = { a: 'string' }; @@ -174,7 +164,7 @@ const symb: symbol = Symbol('foo'); const func: () => number = () => 1; // use safer object types -const lowerObj: Record = {}; +const lowerObj: object = {}; const capitalObj1: number = 1; const capitalObj2: { a: string } = { a: 'string' }; @@ -185,4 +175,4 @@ const curly2: Record<'a', string> = { a: 'string' }; ## Compatibility -- TSLint: [ban-types](https://palantir.github.io/tslint/rules/ban-types/) +- TSLint: [ban-types](https://palantir.github.io/tslint/rules/ban-types) diff --git a/packages/eslint-plugin/src/rules/ban-types.ts b/packages/eslint-plugin/src/rules/ban-types.ts index 32f05e9c1208..dea2e79c4b0e 100644 --- a/packages/eslint-plugin/src/rules/ban-types.ts +++ b/packages/eslint-plugin/src/rules/ban-types.ts @@ -96,12 +96,6 @@ const defaultTypes: Types = { '- If you want a type meaning "empty object", you probably want `Record` instead.', ].join('\n'), }, - object: { - message: [ - 'The `object` type is currently hard to use ([see this issue](https://github.com/microsoft/TypeScript/issues/21732)).', - 'Consider using `Record` instead, as it allows you to more easily inspect and use the keys.', - ].join('\n'), - }, }; export const TYPE_KEYWORDS = { From b34fb7eb3102ea603bb4aef0dbbf9885b3d47557 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Fri, 3 Sep 2021 11:07:12 -0700 Subject: [PATCH 37/44] fix: update new rules from master --- packages/eslint-plugin/src/rules/no-meaningless-void-operator.ts | 1 - .../eslint-plugin/src/rules/padding-line-between-statements.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/eslint-plugin/src/rules/no-meaningless-void-operator.ts b/packages/eslint-plugin/src/rules/no-meaningless-void-operator.ts index 3640cb34630b..ca802e8b5c24 100644 --- a/packages/eslint-plugin/src/rules/no-meaningless-void-operator.ts +++ b/packages/eslint-plugin/src/rules/no-meaningless-void-operator.ts @@ -23,7 +23,6 @@ export default util.createRule< docs: { description: 'Disallow the `void` operator except when used to discard a value', - category: 'Best Practices', recommended: false, suggestion: true, requiresTypeChecking: true, diff --git a/packages/eslint-plugin/src/rules/padding-line-between-statements.ts b/packages/eslint-plugin/src/rules/padding-line-between-statements.ts index e99b0e493460..e9876c7ed363 100644 --- a/packages/eslint-plugin/src/rules/padding-line-between-statements.ts +++ b/packages/eslint-plugin/src/rules/padding-line-between-statements.ts @@ -561,7 +561,6 @@ export default util.createRule({ type: 'layout', docs: { description: 'require or disallow padding lines between statements', - category: 'Stylistic Issues', recommended: false, extendsBaseRule: true, }, From d88a6b44eedcf9dd59569160570aa118851aa86b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Sun, 5 Sep 2021 04:06:57 +0200 Subject: [PATCH 38/44] fix(eslint-plugin): update new rules from master (#3840) --- .../src/rules/no-meaningless-void-operator.ts | 1 + .../rules/padding-line-between-statements.ts | 33 ++++++++++--------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/packages/eslint-plugin/src/rules/no-meaningless-void-operator.ts b/packages/eslint-plugin/src/rules/no-meaningless-void-operator.ts index ca802e8b5c24..28cc7b6b051d 100644 --- a/packages/eslint-plugin/src/rules/no-meaningless-void-operator.ts +++ b/packages/eslint-plugin/src/rules/no-meaningless-void-operator.ts @@ -28,6 +28,7 @@ export default util.createRule< requiresTypeChecking: true, }, fixable: 'code', + hasSuggestions: true, messages: { meaninglessVoidOperator: "void operator shouldn't be used on {{type}}; it should convey that a return value is being ignored", diff --git a/packages/eslint-plugin/src/rules/padding-line-between-statements.ts b/packages/eslint-plugin/src/rules/padding-line-between-statements.ts index e9876c7ed363..334b6928c630 100644 --- a/packages/eslint-plugin/src/rules/padding-line-between-statements.ts +++ b/packages/eslint-plugin/src/rules/padding-line-between-statements.ts @@ -107,7 +107,7 @@ function newNodeTypeTester(type: AST_NODE_TYPES): NodeTestObject { /** * Skips a chain expression node - * @paramnode The node to test + * @param node The node to test * @returnsA non-chain expression * @private */ @@ -119,7 +119,7 @@ function skipChainExpression(node: TSESTree.Node): TSESTree.Node { /** * Checks the given node is an expression statement of IIFE. - * @paramnode The node to check. + * @param node The node to check. * @returns `true` if the node is an expression statement of IIFE. * @private */ @@ -142,7 +142,7 @@ function isIIFEStatement(node: TSESTree.Node): boolean { /** * Checks the given node is a CommonJS require statement - * @paramnode The node to check. + * @param node The node to check. * @returns `true` if the node is a CommonJS require statement. * @private */ @@ -169,7 +169,7 @@ function isCJSRequire(node: TSESTree.Node): boolean { * Checks whether the given node is a block-like statement. * This checks the last token of the node is the closing brace of a block. * @param sourceCode The source code to get tokens. - * @paramnode The node to check. + * @param node The node to check. * @returns `true` if the node is a block-like statement. * @private */ @@ -209,7 +209,7 @@ function isBlockLikeStatement( /** * Check whether the given node is a directive or not. - * @paramnode The node to check. + * @param node The node to check. * @param sourceCode The source code object to get tokens. * @returns `true` if the node is a directive. */ @@ -230,7 +230,7 @@ function isDirective( /** * Check whether the given node is a part of directive prologue or not. - * @paramnode The node to check. + * @param node The node to check. * @param sourceCode The source code object to get tokens. * @returns `true` if the node is a part of directive prologue. */ @@ -259,7 +259,7 @@ function isDirectivePrologue( /** * Checks the given node is a CommonJS export statement - * @paramnode The node to check. + * @param node The node to check. * @returns `true` if the node is a CommonJS export statement. * @private */ @@ -287,7 +287,7 @@ function isCJSExport(node: TSESTree.Node): boolean { /** * Check whether the given node is an expression - * @paramnode The node to check. + * @param node The node to check. * @param sourceCode The source code object to get tokens. * @returns `true` if the node is an expression */ @@ -310,7 +310,7 @@ function isExpression( * foo() * ;[1, 2, 3].forEach(bar) * @param sourceCode The source code to get tokens. - * @paramnode The node to get. + * @param node The node to get. * @returns The actual last token. * @private */ @@ -364,8 +364,8 @@ function verifyForAny(): void { * However, if comments exist between 2 blank lines, it does not remove those * blank lines automatically. * @param context The rule context to report. - * @param_ Unused. The previous node to check. - * @paramnextNode The next node to check. + * @param _ Unused. The previous node to check. + * @param nextNode The next node to check. * @param paddingLines The array of token pairs that blank * lines exist between the pair. * @@ -409,8 +409,8 @@ function verifyForNever( * If the `prevNode` has trailing comments, it inserts a blank line after the * trailing comments. * @param context The rule context to report. - * @paramprevNode The previous node to check. - * @paramnextNode The next node to check. + * @param prevNode The previous node to check. + * @param nextNode The next node to check. * @param paddingLines The array of token pairs that blank * lines exist between the pair. * @@ -565,6 +565,7 @@ export default util.createRule({ extendsBaseRule: true, }, fixable: 'whitespace', + hasSuggestions: true, schema: { definitions: { paddingType: { @@ -639,7 +640,7 @@ export default util.createRule({ /** * Checks whether the given node matches the given type. - * @paramnode The statement node to check. + * @param node The statement node to check. * @param type The statement type to check. * @returns `true` if the statement node matched the type. * @private @@ -714,7 +715,7 @@ export default util.createRule({ /** * Verify padding lines between the given node and the previous node. - * @paramnode The node to verify. + * @param node The node to verify. * * @private */ @@ -749,7 +750,7 @@ export default util.createRule({ /** * Verify padding lines between the given node and the previous node. * Then process to enter to new scope. - * @paramnode The node to verify. + * @param node The node to verify. * * @private */ From 8fc573653228458f36b40eb299c63a00b5fc6e7a Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Mon, 20 Sep 2021 23:21:40 +0200 Subject: [PATCH 39/44] chore: bump eslint-plugin-jest for eslint v8 support (#3895) --- patches/eslint-plugin-jest+24.4.0.patch | 48 ------------------------- 1 file changed, 48 deletions(-) delete mode 100644 patches/eslint-plugin-jest+24.4.0.patch diff --git a/patches/eslint-plugin-jest+24.4.0.patch b/patches/eslint-plugin-jest+24.4.0.patch deleted file mode 100644 index da14716ee8ab..000000000000 --- a/patches/eslint-plugin-jest+24.4.0.patch +++ /dev/null @@ -1,48 +0,0 @@ -diff --git a/node_modules/eslint-plugin-jest/lib/rules/no-done-callback.js b/node_modules/eslint-plugin-jest/lib/rules/no-done-callback.js -index 8a09e7b..4f7dffa 100644 ---- a/node_modules/eslint-plugin-jest/lib/rules/no-done-callback.js -+++ b/node_modules/eslint-plugin-jest/lib/rules/no-done-callback.js -@@ -34,6 +34,7 @@ var _default = (0, _utils.createRule)({ - recommended: 'error', - suggestion: true - }, -+ hasSuggestions: true, - messages: { - noDoneCallback: 'Return a Promise instead of relying on callback parameter', - suggestWrappingInPromise: 'Wrap in `new Promise({{ callback }} => ...`', -diff --git a/node_modules/eslint-plugin-jest/lib/rules/no-focused-tests.js b/node_modules/eslint-plugin-jest/lib/rules/no-focused-tests.js -index 159e1fb..b167a83 100644 ---- a/node_modules/eslint-plugin-jest/lib/rules/no-focused-tests.js -+++ b/node_modules/eslint-plugin-jest/lib/rules/no-focused-tests.js -@@ -36,6 +36,7 @@ var _default = (0, _utils.createRule)({ - recommended: 'error', - suggestion: true - }, -+ hasSuggestions: true, - messages: { - focusedTest: 'Unexpected focused test.', - suggestRemoveFocus: 'Remove focus from test.' -diff --git a/node_modules/eslint-plugin-jest/lib/rules/prefer-expect-assertions.js b/node_modules/eslint-plugin-jest/lib/rules/prefer-expect-assertions.js -index cf064ac..c47dc4a 100644 ---- a/node_modules/eslint-plugin-jest/lib/rules/prefer-expect-assertions.js -+++ b/node_modules/eslint-plugin-jest/lib/rules/prefer-expect-assertions.js -@@ -29,6 +29,7 @@ var _default = (0, _utils.createRule)({ - recommended: false, - suggestion: true - }, -+ hasSuggestions: true, - messages: { - hasAssertionsTakesNoArguments: '`expect.hasAssertions` expects no arguments', - assertionsRequiresOneArgument: '`expect.assertions` excepts a single argument of type number', -diff --git a/node_modules/eslint-plugin-jest/lib/rules/prefer-strict-equal.js b/node_modules/eslint-plugin-jest/lib/rules/prefer-strict-equal.js -index 95136e6..c1179c6 100644 ---- a/node_modules/eslint-plugin-jest/lib/rules/prefer-strict-equal.js -+++ b/node_modules/eslint-plugin-jest/lib/rules/prefer-strict-equal.js -@@ -16,6 +16,7 @@ var _default = (0, _utils.createRule)({ - recommended: false, - suggestion: true - }, -+ hasSuggestions: true, - messages: { - useToStrictEqual: 'Use `toStrictEqual()` instead', - suggestReplaceWithStrictEqual: 'Replace with `toStrictEqual()`' From 82016f99b14825c9c60e1f7eb3b4efcc492bba86 Mon Sep 17 00:00:00 2001 From: Rafael Santana Date: Mon, 20 Sep 2021 21:12:12 -0300 Subject: [PATCH 40/44] fix(eslint-plugin): [explicit-member-accessibility] report `TSAbstractPropertyDefinition` and `TSAbstractMethodDefinition` properly (#3901) --- .../rules/explicit-member-accessibility.ts | 20 +++-- .../explicit-member-accessibility.test.ts | 83 ++++++++++++++++++- 2 files changed, 95 insertions(+), 8 deletions(-) diff --git a/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts b/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts index a8522f1b87c0..dc549fc1411b 100644 --- a/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts +++ b/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts @@ -1,8 +1,8 @@ import { AST_NODE_TYPES, - TSESTree, AST_TOKEN_TYPES, TSESLint, + TSESTree, } from '@typescript-eslint/experimental-utils'; import * as util from '../util'; @@ -96,13 +96,13 @@ export default util.createRule({ fix: TSESLint.ReportFixFunction | null = null, ): void { context.report({ - node: node, - messageId: messageId, + node, + messageId, data: { type: nodeType, name: nodeName, }, - fix: fix, + fix, }); } @@ -170,6 +170,8 @@ export default util.createRule({ node: | TSESTree.MethodDefinition | TSESTree.PropertyDefinition + | TSESTree.TSAbstractMethodDefinition + | TSESTree.TSAbstractPropertyDefinition | TSESTree.TSParameterProperty, ): TSESLint.ReportFixFunction { return function (fixer: TSESLint.RuleFixer): TSESLint.RuleFix { @@ -208,7 +210,9 @@ export default util.createRule({ * @param propertyDefinition The node representing a PropertyDefinition. */ function checkPropertyAccessibilityModifier( - propertyDefinition: TSESTree.PropertyDefinition, + propertyDefinition: + | TSESTree.PropertyDefinition + | TSESTree.TSAbstractPropertyDefinition, ): void { const nodeType = 'class property'; @@ -285,9 +289,11 @@ export default util.createRule({ } return { + 'MethodDefinition, TSAbstractMethodDefinition': + checkMethodAccessibilityModifier, + 'PropertyDefinition, TSAbstractPropertyDefinition': + checkPropertyAccessibilityModifier, TSParameterProperty: checkParameterPropertyAccessibilityModifier, - PropertyDefinition: checkPropertyAccessibilityModifier, - MethodDefinition: checkMethodAccessibilityModifier, }; }, }); diff --git a/packages/eslint-plugin/tests/rules/explicit-member-accessibility.test.ts b/packages/eslint-plugin/tests/rules/explicit-member-accessibility.test.ts index 4e070acb325c..4f2951c6d910 100644 --- a/packages/eslint-plugin/tests/rules/explicit-member-accessibility.test.ts +++ b/packages/eslint-plugin/tests/rules/explicit-member-accessibility.test.ts @@ -1,5 +1,5 @@ import rule from '../../src/rules/explicit-member-accessibility'; -import { RuleTester, noFormat } from '../RuleTester'; +import { noFormat, RuleTester } from '../RuleTester'; const ruleTester = new RuleTester({ parser: '@typescript-eslint/parser', @@ -1138,6 +1138,87 @@ class Test { 'foo foo' = 2; 'bar'() {} 'bar bar'() {} +} + `, + }, + { + code: ` +abstract class SomeClass { + abstract method(): string; +} + `, + options: [{ accessibility: 'explicit' }], + errors: [ + { + messageId: 'missingAccessibility', + line: 3, + column: 3, + }, + ], + }, + { + code: ` +abstract class SomeClass { + public abstract method(): string; +} + `, + options: [ + { + accessibility: 'no-public', + overrides: { parameterProperties: 'no-public' }, + }, + ], + errors: [ + { + messageId: 'unwantedPublicAccessibility', + line: 3, + column: 3, + }, + ], + output: ` +abstract class SomeClass { + abstract method(): string; +} + `, + }, + { + // https://github.com/typescript-eslint/typescript-eslint/issues/3835 + code: ` +abstract class SomeClass { + abstract x: string; +} + `, + options: [{ accessibility: 'explicit' }], + errors: [ + { + messageId: 'missingAccessibility', + line: 3, + column: 3, + }, + ], + }, + { + code: ` +abstract class SomeClass { + public abstract x: string; +} + `, + options: [ + { + accessibility: 'no-public', + overrides: { parameterProperties: 'no-public' }, + }, + ], + errors: [ + { + messageId: 'unwantedPublicAccessibility', + line: 3, + column: 3, + }, + ], + output: ` +abstract class SomeClass { + abstract x: string; } `, }, From 09c47b00987bbae5ee7f1609444c4f0c74a81951 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Mon, 20 Sep 2021 17:56:34 -0700 Subject: [PATCH 41/44] chore: cleanup after rebase --- .../declaration/ExportAllDeclaration/spec.ts | 4 ++-- .../ExportNamedDeclaration/spec.ts | 4 ++-- .../src/declaration/ImportDeclaration/spec.ts | 4 ++-- .../src/rules/consistent-type-imports.ts | 2 +- ...no-non-null-asserted-nullish-coalescing.ts | 3 +-- .../src/rules/no-restricted-imports.ts | 23 ++++++++----------- .../src/util/getESLintCoreRule.ts | 1 + .../tests/rules/no-restricted-imports.test.ts | 8 ------- tests/jest-resolver.js | 10 +++++--- 9 files changed, 26 insertions(+), 33 deletions(-) diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/spec.ts b/packages/ast-spec/src/declaration/ExportAllDeclaration/spec.ts index e6700070b59b..3b50c001f850 100644 --- a/packages/ast-spec/src/declaration/ExportAllDeclaration/spec.ts +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/spec.ts @@ -1,12 +1,12 @@ import type { AST_NODE_TYPES } from '../../ast-node-types'; import type { BaseNode } from '../../base/BaseNode'; import type { Identifier } from '../../expression/Identifier/spec'; -import type { Expression } from '../../unions/Expression'; +import type { StringLiteral } from '../../expression/literal/StringLiteral/spec'; import type { ExportKind } from '../ExportAndImportKind'; export interface ExportAllDeclaration extends BaseNode { type: AST_NODE_TYPES.ExportAllDeclaration; - source: Expression | null; + source: StringLiteral | null; exportKind: ExportKind; exported: Identifier | null; } diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/spec.ts b/packages/ast-spec/src/declaration/ExportNamedDeclaration/spec.ts index a8f476477a7b..b43471428094 100644 --- a/packages/ast-spec/src/declaration/ExportNamedDeclaration/spec.ts +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/spec.ts @@ -1,14 +1,14 @@ import type { AST_NODE_TYPES } from '../../ast-node-types'; import type { BaseNode } from '../../base/BaseNode'; +import type { StringLiteral } from '../../expression/literal/StringLiteral/spec'; import type { ExportSpecifier } from '../../special/ExportSpecifier/spec'; import type { ExportDeclaration } from '../../unions/ExportDeclaration'; -import type { Literal } from '../../unions/Literal'; import type { ExportKind } from '../ExportAndImportKind'; export interface ExportNamedDeclaration extends BaseNode { type: AST_NODE_TYPES.ExportNamedDeclaration; declaration: ExportDeclaration | null; specifiers: ExportSpecifier[]; - source: Literal | null; + source: StringLiteral | null; exportKind: ExportKind; } diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/spec.ts b/packages/ast-spec/src/declaration/ImportDeclaration/spec.ts index 2aeaeae4539f..d9a11f6e3145 100644 --- a/packages/ast-spec/src/declaration/ImportDeclaration/spec.ts +++ b/packages/ast-spec/src/declaration/ImportDeclaration/spec.ts @@ -1,12 +1,12 @@ import type { AST_NODE_TYPES } from '../../ast-node-types'; import type { BaseNode } from '../../base/BaseNode'; +import type { StringLiteral } from '../../expression/literal/StringLiteral/spec'; import type { ImportClause } from '../../unions/ImportClause'; -import type { Literal } from '../../unions/Literal'; import type { ImportKind } from '../ExportAndImportKind'; export interface ImportDeclaration extends BaseNode { type: AST_NODE_TYPES.ImportDeclaration; - source: Literal; + source: StringLiteral; specifiers: ImportClause[]; importKind: ImportKind; } diff --git a/packages/eslint-plugin/src/rules/consistent-type-imports.ts b/packages/eslint-plugin/src/rules/consistent-type-imports.ts index 1bfb695f27be..abefc9a4a8a7 100644 --- a/packages/eslint-plugin/src/rules/consistent-type-imports.ts +++ b/packages/eslint-plugin/src/rules/consistent-type-imports.ts @@ -107,7 +107,7 @@ export default util.createRule({ ? { // prefer type imports ImportDeclaration(node: TSESTree.ImportDeclaration): void { - const source = node.source.value as string; + const source = node.source.value; const sourceImports = sourceImportsMap[source] ?? (sourceImportsMap[source] = { diff --git a/packages/eslint-plugin/src/rules/no-non-null-asserted-nullish-coalescing.ts b/packages/eslint-plugin/src/rules/no-non-null-asserted-nullish-coalescing.ts index b7619f1a82b5..93431950c35d 100644 --- a/packages/eslint-plugin/src/rules/no-non-null-asserted-nullish-coalescing.ts +++ b/packages/eslint-plugin/src/rules/no-non-null-asserted-nullish-coalescing.ts @@ -39,9 +39,7 @@ export default util.createRule({ docs: { description: 'Disallows using a non-null assertion in the left operand of the nullish coalescing operator', - category: 'Possible Errors', recommended: false, - suggestion: true, }, messages: { noNonNullAssertedNullishCoalescing: @@ -49,6 +47,7 @@ export default util.createRule({ suggestRemovingNonNull: 'Remove the non-null assertion.', }, schema: [], + hasSuggestions: true, }, defaultOptions: [], create(context) { diff --git a/packages/eslint-plugin/src/rules/no-restricted-imports.ts b/packages/eslint-plugin/src/rules/no-restricted-imports.ts index 994b9ddba737..7a583a01a1d7 100644 --- a/packages/eslint-plugin/src/rules/no-restricted-imports.ts +++ b/packages/eslint-plugin/src/rules/no-restricted-imports.ts @@ -1,9 +1,10 @@ -import { AST_NODE_TYPES } from '@typescript-eslint/experimental-utils'; -import baseRule, { +import { TSESTree } from '@typescript-eslint/experimental-utils'; +import { ArrayOfStringOrObject, ArrayOfStringOrObjectPatterns, } from 'eslint/lib/rules/no-restricted-imports'; import ignore, { Ignore } from 'ignore'; +import { getESLintCoreRule } from '../util/getESLintCoreRule'; import { createRule, deepMerge, @@ -11,6 +12,8 @@ import { InferOptionsTypeFromRule, } from '../util'; +const baseRule = getESLintCoreRule('no-restricted-imports'); + export type Options = InferOptionsTypeFromRule; export type MessageIds = InferMessageIdsTypeFromRule; @@ -106,7 +109,6 @@ export default createRule({ type: 'suggestion', docs: { description: 'Disallow specified modules when loaded by `import`', - category: 'Best Practices', recommended: false, extendsBaseRule: true, }, @@ -155,9 +157,6 @@ export default createRule({ return { ImportDeclaration(node): void { - if (typeof node.source.value !== 'string') { - return; - } if (node.importKind === 'type') { const importSource = node.source.value.trim(); if ( @@ -170,13 +169,11 @@ export default createRule({ return rules.ImportDeclaration(node); } }, - ExportNamedDeclaration(node): void { - if ( - node.source?.type !== AST_NODE_TYPES.Literal || - typeof node.source.value !== 'string' - ) { - return; - } + 'ExportNamedDeclaration[source]'( + node: TSESTree.ExportNamedDeclaration & { + source: NonNullable; + }, + ): void { if (node.exportKind === 'type') { const importSource = node.source.value.trim(); if ( diff --git a/packages/eslint-plugin/src/util/getESLintCoreRule.ts b/packages/eslint-plugin/src/util/getESLintCoreRule.ts index fdb2ca46df87..1701b4ef1d76 100644 --- a/packages/eslint-plugin/src/util/getESLintCoreRule.ts +++ b/packages/eslint-plugin/src/util/getESLintCoreRule.ts @@ -24,6 +24,7 @@ interface RuleMap { 'no-loop-func': typeof import('eslint/lib/rules/no-loop-func'); 'no-loss-of-precision': typeof import('eslint/lib/rules/no-loss-of-precision'); 'no-magic-numbers': typeof import('eslint/lib/rules/no-magic-numbers'); + 'no-restricted-imports': typeof import('eslint/lib/rules/no-restricted-imports'); 'no-undef': typeof import('eslint/lib/rules/no-undef'); 'no-unused-expressions': typeof import('eslint/lib/rules/no-unused-expressions'); 'no-useless-constructor': typeof import('eslint/lib/rules/no-useless-constructor'); diff --git a/packages/eslint-plugin/tests/rules/no-restricted-imports.test.ts b/packages/eslint-plugin/tests/rules/no-restricted-imports.test.ts index 8f7cb1f88bf4..143bfd95aae9 100644 --- a/packages/eslint-plugin/tests/rules/no-restricted-imports.test.ts +++ b/packages/eslint-plugin/tests/rules/no-restricted-imports.test.ts @@ -217,14 +217,6 @@ ruleTester.run('no-restricted-imports', rule, { code: "export * from 'foo';", options: ['import1'], }, - { - code: 'export { foo } from foo;', - options: ['import1', 'import2'], - }, - { - code: 'import { foo } from foo;', - options: ['import1', 'import2'], - }, ], invalid: [ { diff --git a/tests/jest-resolver.js b/tests/jest-resolver.js index a0460ee0ac43..0636e2feee7e 100644 --- a/tests/jest-resolver.js +++ b/tests/jest-resolver.js @@ -1,12 +1,16 @@ -/* eslint-disable @typescript-eslint/no-unsafe-argument */ -// https://github.com/facebook/jest/issues/9771#issuecomment-871585234 +/* @ts-check */ -// temporary workaround while we wait for https://github.com/facebook/jest/issues/9771 +// temporary workaround - https://github.com/facebook/jest/issues/9771#issuecomment-871585234 const resolver = require('enhanced-resolve').create.sync({ conditionNames: ['require', 'node', 'default'], extensions: ['.js', '.json', '.node', '.ts', '.tsx'], }); +/** + * @param request {unknown} + * @param options {{ defaultResolver(...args: unknown[]): unknown, basedir: unknown }} + * @returns {unknown} + */ module.exports = function (request, options) { // list global module that must be resolved by defaultResolver here if (['fs', 'http', 'path'].includes(request)) { From dd140643b457aa515cc21fcda2b3cd4acc2a1c5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Wed, 22 Sep 2021 19:52:23 +0200 Subject: [PATCH 42/44] feat(ast-spec): bring `Node` objects in line with ESTree (#3771) --- packages/ast-spec/src/base/NodeOrTokenData.ts | 3 +++ .../ast-spec/src/base/{LineAndColumnData.ts => Position.ts} | 2 +- packages/ast-spec/src/base/SourceLocation.ts | 6 +++--- packages/ast-spec/src/index.ts | 2 +- packages/eslint-plugin/src/util/getFunctionHeadLoc.ts | 4 ++-- packages/experimental-utils/src/ts-eslint/Rule.ts | 4 ++-- packages/experimental-utils/src/ts-eslint/SourceCode.ts | 4 ++-- packages/typescript-estree/src/node-utils.ts | 2 +- packages/typescript-estree/tests/ast-alignment/parse.ts | 2 +- 9 files changed, 16 insertions(+), 13 deletions(-) rename packages/ast-spec/src/base/{LineAndColumnData.ts => Position.ts} (78%) diff --git a/packages/ast-spec/src/base/NodeOrTokenData.ts b/packages/ast-spec/src/base/NodeOrTokenData.ts index 8052278bbf02..013f96002fc4 100644 --- a/packages/ast-spec/src/base/NodeOrTokenData.ts +++ b/packages/ast-spec/src/base/NodeOrTokenData.ts @@ -4,6 +4,9 @@ import type { SourceLocation } from './SourceLocation'; export interface NodeOrTokenData { /** * The source location information of the node. + * + * The loc property is defined as nullable by ESTree, but ESLint requires this property. + * * @see {SourceLocation} */ loc: SourceLocation; diff --git a/packages/ast-spec/src/base/LineAndColumnData.ts b/packages/ast-spec/src/base/Position.ts similarity index 78% rename from packages/ast-spec/src/base/LineAndColumnData.ts rename to packages/ast-spec/src/base/Position.ts index 740ebe6fa467..672fe5d5d4d0 100644 --- a/packages/ast-spec/src/base/LineAndColumnData.ts +++ b/packages/ast-spec/src/base/Position.ts @@ -1,4 +1,4 @@ -export interface LineAndColumnData { +export interface Position { /** * Line number (1-indexed) */ diff --git a/packages/ast-spec/src/base/SourceLocation.ts b/packages/ast-spec/src/base/SourceLocation.ts index e1a8e272a6fc..67b5246fed5d 100644 --- a/packages/ast-spec/src/base/SourceLocation.ts +++ b/packages/ast-spec/src/base/SourceLocation.ts @@ -1,12 +1,12 @@ -import type { LineAndColumnData } from './LineAndColumnData'; +import type { Position } from './Position'; export interface SourceLocation { /** * The position of the first character of the parsed source region */ - start: LineAndColumnData; + start: Position; /** * The position of the first character after the parsed source region */ - end: LineAndColumnData; + end: Position; } diff --git a/packages/ast-spec/src/index.ts b/packages/ast-spec/src/index.ts index c0dc09b70b0e..ba9ee6800007 100644 --- a/packages/ast-spec/src/index.ts +++ b/packages/ast-spec/src/index.ts @@ -1,7 +1,7 @@ export * from './base/Accessibility'; export * from './base/BaseNode'; // this is exported so that the `types` package can merge the decl and add the `parent` property -export * from './base/LineAndColumnData'; export * from './base/OptionalRangeAndLoc'; +export * from './base/Position'; export * from './base/Range'; export * from './base/SourceLocation'; diff --git a/packages/eslint-plugin/src/util/getFunctionHeadLoc.ts b/packages/eslint-plugin/src/util/getFunctionHeadLoc.ts index dc18a832f948..7604a8d496fc 100644 --- a/packages/eslint-plugin/src/util/getFunctionHeadLoc.ts +++ b/packages/eslint-plugin/src/util/getFunctionHeadLoc.ts @@ -31,7 +31,7 @@ export function getFunctionHeadLoc( node: FunctionNode, sourceCode: TSESLint.SourceCode, ): TSESTree.SourceLocation { - function getLocStart(): TSESTree.LineAndColumnData { + function getLocStart(): TSESTree.Position { if (node.parent && node.parent.type === AST_NODE_TYPES.MethodDefinition) { // return the start location for class method @@ -58,7 +58,7 @@ export function getFunctionHeadLoc( return node.loc.start; } - function getLocEnd(): TSESTree.LineAndColumnData { + function getLocEnd(): TSESTree.Position { if (node.type === AST_NODE_TYPES.ArrowFunctionExpression) { // find the end location for arrow function expression return sourceCode.getTokenBefore( diff --git a/packages/experimental-utils/src/ts-eslint/Rule.ts b/packages/experimental-utils/src/ts-eslint/Rule.ts index 1759a20eff5a..7750d35dc68a 100644 --- a/packages/experimental-utils/src/ts-eslint/Rule.ts +++ b/packages/experimental-utils/src/ts-eslint/Rule.ts @@ -154,13 +154,13 @@ interface ReportDescriptorNodeOptionalLoc { */ readonly loc?: | Readonly - | Readonly; + | Readonly; } interface ReportDescriptorLocOnly { /** * An override of the location of the report */ - loc: Readonly | Readonly; + loc: Readonly | Readonly; } type ReportDescriptor = ReportDescriptorWithSuggestion & diff --git a/packages/experimental-utils/src/ts-eslint/SourceCode.ts b/packages/experimental-utils/src/ts-eslint/SourceCode.ts index 669ad7113c92..682e2e52012c 100644 --- a/packages/experimental-utils/src/ts-eslint/SourceCode.ts +++ b/packages/experimental-utils/src/ts-eslint/SourceCode.ts @@ -250,7 +250,7 @@ declare class SourceCodeBase extends TokenStore { * @param loc A line/column location * @returns The range index of the location in the file. */ - getIndexFromLoc(location: TSESTree.LineAndColumnData): number; + getIndexFromLoc(location: TSESTree.Position): number; /** * Gets the entire source text split into an array of lines. * @returns The source text as an array of lines. @@ -261,7 +261,7 @@ declare class SourceCodeBase extends TokenStore { * @param index The index of a character in a file * @returns A {line, column} location object with a 0-indexed column */ - getLocFromIndex(index: number): TSESTree.LineAndColumnData; + getLocFromIndex(index: number): TSESTree.Position; /** * Gets the deepest node containing a range index. * @param index Range index of the desired node. diff --git a/packages/typescript-estree/src/node-utils.ts b/packages/typescript-estree/src/node-utils.ts index 82f487b864cc..d8182aa5655e 100644 --- a/packages/typescript-estree/src/node-utils.ts +++ b/packages/typescript-estree/src/node-utils.ts @@ -161,7 +161,7 @@ export function getBinaryExpressionType( export function getLineAndCharacterFor( pos: number, ast: ts.SourceFile, -): TSESTree.LineAndColumnData { +): TSESTree.Position { const loc = ast.getLineAndCharacterOfPosition(pos); return { line: loc.line + 1, diff --git a/packages/typescript-estree/tests/ast-alignment/parse.ts b/packages/typescript-estree/tests/ast-alignment/parse.ts index 701cf069ff42..3429f338d77b 100644 --- a/packages/typescript-estree/tests/ast-alignment/parse.ts +++ b/packages/typescript-estree/tests/ast-alignment/parse.ts @@ -105,7 +105,7 @@ export function parse( ); } } catch (error: any) { - const loc = error.loc as TSESTree.LineAndColumnData | undefined; + const loc = error.loc as TSESTree.Position | undefined; if (loc) { error.codeFrame = codeFrameColumns( text, From c304a55afa4983a807955190202c0dbc0fb9e3aa Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Sun, 10 Oct 2021 14:36:16 -0700 Subject: [PATCH 43/44] chore: bump eslint to 8.0.0 --- package.json | 2 +- packages/eslint-plugin-tslint/package.json | 2 +- packages/eslint-plugin/package.json | 4 +-- packages/parser/package.json | 2 +- yarn.lock | 37 ++++++++++++---------- 5 files changed, 26 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index a6b365cfc54a..941734a0fd14 100644 --- a/package.json +++ b/package.json @@ -101,7 +101,7 @@ "cz-conventional-changelog": "^3.3.0", "downlevel-dts": "^0.7.0", "enhanced-resolve": "^5.8.2", - "eslint": "^8.0.0-0", + "eslint": "^8.0.0", "eslint-plugin-eslint-comments": "^3.2.0", "eslint-plugin-eslint-plugin": "^3.0.3", "eslint-plugin-import": "^2.23.4", diff --git a/packages/eslint-plugin-tslint/package.json b/packages/eslint-plugin-tslint/package.json index 7917ab0f1709..813984697072 100644 --- a/packages/eslint-plugin-tslint/package.json +++ b/packages/eslint-plugin-tslint/package.json @@ -42,7 +42,7 @@ "lodash": "^4.17.21" }, "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0-0", + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0", "tslint": "^5.0.0 || ^6.0.0", "typescript": "*" }, diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index b750d5e02ab8..ed1e439926d5 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -63,8 +63,8 @@ "typescript": "*" }, "peerDependencies": { - "@typescript-eslint/parser": "^4.0.0", - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0-0" + "@typescript-eslint/parser": "^5.0.0", + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" }, "peerDependenciesMeta": { "typescript": { diff --git a/packages/parser/package.json b/packages/parser/package.json index ba9f66b31764..64caa07a14e9 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -41,7 +41,7 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0-0" + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" }, "dependencies": { "@typescript-eslint/scope-manager": "4.33.0", diff --git a/yarn.lock b/yarn.lock index 83194d3d9c8d..293c6e122bb5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -698,14 +698,14 @@ ts-node "^9" tslib "^2" -"@eslint/eslintrc@^1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.0.0.tgz#08309b915051dbfcfea8c3cdfc832375303396c9" - integrity sha512-FPnE4y+crrKBF0c9PckDHFuPDQl+wRX6S9jeSw2WwM2YNmrdRch3gx3DOTWpqpQu0G9yoJaeSSrJLiV/29tGyQ== +"@eslint/eslintrc@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.0.2.tgz#6044884f7f93c4ecc2d1694c7486cce91ef8f746" + integrity sha512-x1ZXdEFsvTcnbTZgqcWUL9w2ybgZCw/qbKTPQnab+XnYA2bMQpJCh+/bBzCRfDJaJdlrrQlOk49jNtru9gL/6Q== dependencies: ajv "^6.12.4" debug "^4.3.2" - espree "^8.0.0" + espree "^9.0.0" globals "^13.9.0" ignore "^4.0.6" import-fresh "^3.2.1" @@ -2453,6 +2453,11 @@ acorn@^8.2.4, acorn@^8.4.1: resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.4.1.tgz#56c36251fc7cabc7096adc18f05afe814321a28c" integrity sha512-asabaBSkEKosYKMITunzX177CXxQ4Q8BSSzMTKD+FefUhipQC70gfW5SiUDhYQ3vk8G+81HqQk7Fv9OXwwn9KA== +acorn@^8.5.0: + version "8.5.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.5.0.tgz#4512ccb99b3698c752591e9bb4472e38ad43cee2" + integrity sha512-yXbYeFy+jUuYd3/CDcg2NkIYE991XYX/bje7LmjJigUciaeO1JR4XxXgCIV1/Zc/dRuFEyw1L0pbA+qynJkW5Q== + agent-base@4, agent-base@^4.3.0: version "4.3.0" resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.3.0.tgz#8165f01c436009bccad0b1d122f05ed770efc6ee" @@ -4372,12 +4377,12 @@ eslint-visitor-keys@^3.0.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.0.0.tgz#e32e99c6cdc2eb063f204eda5db67bfe58bb4186" integrity sha512-mJOZa35trBTb3IyRmo8xmKBZlxf+N7OnUl4+ZhJHs/r+0770Wh/LEACE2pqMGMe27G/4y8P2bYGk4J70IC5k1Q== -eslint@^8.0.0-0: - version "8.0.0-beta.1" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.0.0-beta.1.tgz#5cd74684dbcfd8abee08cc10de578294124539b5" - integrity sha512-+3EHhCIJHUXuksq6dUSe1Nv9+sdFaLfct6ZiWdFYrHU8u9tX6QQWGdKJQuQXUlUdhMMh6cchRFIQ7OqSAcyq7A== +eslint@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.0.0.tgz#2c2d0ac6353755667ac90c9ff4a9c1315e43fcff" + integrity sha512-03spzPzMAO4pElm44m60Nj08nYonPGQXmw6Ceai/S4QK82IgwWO1EXx1s9namKzVlbVu3Jf81hb+N+8+v21/HQ== dependencies: - "@eslint/eslintrc" "^1.0.0" + "@eslint/eslintrc" "^1.0.2" "@humanwhocodes/config-array" "^0.6.0" ajv "^6.10.0" chalk "^4.0.0" @@ -4389,7 +4394,7 @@ eslint@^8.0.0-0: eslint-scope "^6.0.0" eslint-utils "^3.0.0" eslint-visitor-keys "^3.0.0" - espree "^8.0.0" + espree "^9.0.0" esquery "^1.4.0" esutils "^2.0.2" fast-deep-equal "^3.1.3" @@ -4416,12 +4421,12 @@ eslint@^8.0.0-0: text-table "^0.2.0" v8-compile-cache "^2.0.3" -espree@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/espree/-/espree-8.0.0.tgz#08c92c31814c96c96c54d3a35cc80f1cdb420275" - integrity sha512-y/+i23dwTjIDJrYCcjcAMr3c3UGbPIjC6THMQKjWmhP97fW0FPiI89kmpKfmgV/5jrkIi6toQP+CMm3qBE1Hig== +espree@^9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/espree/-/espree-9.0.0.tgz#e90a2965698228502e771c7a58489b1a9d107090" + integrity sha512-r5EQJcYZ2oaGbeR0jR0fFVijGOcwai07/690YRXLINuhmVeRY4UKSAsQPe/0BNuDgwP7Ophoc1PRsr2E3tkbdQ== dependencies: - acorn "^8.4.1" + acorn "^8.5.0" acorn-jsx "^5.3.1" eslint-visitor-keys "^3.0.0" From 101abc72f0baced5cdf609d99418ad9f10830c73 Mon Sep 17 00:00:00 2001 From: James Henry Date: Mon, 11 Oct 2021 18:09:52 +0000 Subject: [PATCH 44/44] chore: publish v5.0.0 --- CHANGELOG.md | 40 ++++++++++++++++++++ lerna.json | 2 +- packages/ast-spec/CHANGELOG.md | 20 ++++++++++ packages/ast-spec/package.json | 2 +- packages/eslint-plugin-internal/CHANGELOG.md | 12 ++++++ packages/eslint-plugin-internal/package.json | 6 +-- packages/eslint-plugin-tslint/CHANGELOG.md | 12 ++++++ packages/eslint-plugin-tslint/package.json | 6 +-- packages/eslint-plugin/CHANGELOG.md | 35 +++++++++++++++++ packages/eslint-plugin/package.json | 6 +-- packages/experimental-utils/CHANGELOG.md | 22 +++++++++++ packages/experimental-utils/package.json | 8 ++-- packages/parser/CHANGELOG.md | 11 ++++++ packages/parser/package.json | 10 ++--- packages/scope-manager/CHANGELOG.md | 13 +++++++ packages/scope-manager/package.json | 8 ++-- packages/shared-fixtures/CHANGELOG.md | 17 +++++++++ packages/shared-fixtures/package.json | 2 +- packages/types/CHANGELOG.md | 11 ++++++ packages/types/package.json | 2 +- packages/typescript-estree/CHANGELOG.md | 22 +++++++++++ packages/typescript-estree/package.json | 8 ++-- packages/visitor-keys/CHANGELOG.md | 14 +++++++ packages/visitor-keys/package.json | 4 +- 24 files changed, 261 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 362f124346f5..3bb0ead323c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,46 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.33.0...v5.0.0) (2021-10-11) + + +### Bug Fixes + +* **eslint-plugin:** [explicit-member-accessibility] report `TSAbstractPropertyDefinition` and `TSAbstractMethodDefinition` properly ([#3901](https://github.com/typescript-eslint/typescript-eslint/issues/3901)) ([82016f9](https://github.com/typescript-eslint/typescript-eslint/commit/82016f99b14825c9c60e1f7eb3b4efcc492bba86)) +* **eslint-plugin:** update new rules from master ([#3840](https://github.com/typescript-eslint/typescript-eslint/issues/3840)) ([d88a6b4](https://github.com/typescript-eslint/typescript-eslint/commit/d88a6b44eedcf9dd59569160570aa118851aa86b)) +* update new rules from master ([b34fb7e](https://github.com/typescript-eslint/typescript-eslint/commit/b34fb7eb3102ea603bb4aef0dbbf9885b3d47557)) +* **eslint-plugin:** crash in no-dupe-class-members (v5) ([#3813](https://github.com/typescript-eslint/typescript-eslint/issues/3813)) ([4b09644](https://github.com/typescript-eslint/typescript-eslint/commit/4b096442f731c0a60926ac0391a4f2c4208aa8d4)) +* **experimental-utils:** fix `isSetter`'s return type ([#3975](https://github.com/typescript-eslint/typescript-eslint/issues/3975)) ([d256856](https://github.com/typescript-eslint/typescript-eslint/commit/d2568561d0417fdfbdfd964ad942f9d00434af73)) +* **typescript-estree:** change `source` of ExportNamedDeclaration to Literal from Expression ([#3763](https://github.com/typescript-eslint/typescript-eslint/issues/3763)) ([dc5a0f5](https://github.com/typescript-eslint/typescript-eslint/commit/dc5a0f5104b400f4422b8d67ecfc6cc7a32613a2)) + + +### Features + +* **ast-spec:** bring `Node` objects in line with ESTree ([#3771](https://github.com/typescript-eslint/typescript-eslint/issues/3771)) ([dd14064](https://github.com/typescript-eslint/typescript-eslint/commit/dd140643b457aa515cc21fcda2b3cd4acc2a1c5c)) +* **eslint-plugin:** remove `object` from `ban-types`' default types ([#3818](https://github.com/typescript-eslint/typescript-eslint/issues/3818)) ([ae3fa90](https://github.com/typescript-eslint/typescript-eslint/commit/ae3fa900d5b4e1f557a52ca58d35a7d098d9efaf)) +* **eslint-plugin:** removed value from abstract property nodes ([#3765](https://github.com/typescript-eslint/typescript-eslint/issues/3765)) ([5823524](https://github.com/typescript-eslint/typescript-eslint/commit/58235241714596b641a1e8b39c569e561e0039b4)), closes [#3748](https://github.com/typescript-eslint/typescript-eslint/issues/3748) +* **eslint-plugin:** update recommended configs ([#3809](https://github.com/typescript-eslint/typescript-eslint/issues/3809)) ([deeb7bb](https://github.com/typescript-eslint/typescript-eslint/commit/deeb7bb9334d301c6af56aefd37d318231af11ef)) +* align class property representation with ESTree ([#3806](https://github.com/typescript-eslint/typescript-eslint/issues/3806)) ([22fa5c0](https://github.com/typescript-eslint/typescript-eslint/commit/22fa5c0c4705ed2898f00b7cacc5dd642d859275)), closes [#3430](https://github.com/typescript-eslint/typescript-eslint/issues/3430) [#3077](https://github.com/typescript-eslint/typescript-eslint/issues/3077) +* remove `meta.docs.category` from rules ([#3800](https://github.com/typescript-eslint/typescript-eslint/issues/3800)) ([71c9370](https://github.com/typescript-eslint/typescript-eslint/commit/71c93706e55f5f92a1285102b93c6ab1950c6df4)) +* remove `TSParenthesizedType` ([#3340](https://github.com/typescript-eslint/typescript-eslint/issues/3340)) ([c8ee432](https://github.com/typescript-eslint/typescript-eslint/commit/c8ee43269faea4c04ec02eaa2b81a0aa6eec5d3e)), closes [#3136](https://github.com/typescript-eslint/typescript-eslint/issues/3136) +* support `PrivateIdentifier` ([#3808](https://github.com/typescript-eslint/typescript-eslint/issues/3808)) ([0eefe5e](https://github.com/typescript-eslint/typescript-eslint/commit/0eefe5e49d21af3f1e3e2d9a90c2e49929863ac2)), closes [#3430](https://github.com/typescript-eslint/typescript-eslint/issues/3430) [#2933](https://github.com/typescript-eslint/typescript-eslint/issues/2933) +* **eslint-plugin:** [comma-dangle] align schema with ESLint v8 ([#3768](https://github.com/typescript-eslint/typescript-eslint/issues/3768)) ([0acfafc](https://github.com/typescript-eslint/typescript-eslint/commit/0acfafcc655e28dcfc05a5caa567c0d0217ee7ad)) +* **eslint-plugin:** [member-ordering] add support for getters and setters ([#3611](https://github.com/typescript-eslint/typescript-eslint/issues/3611)) ([e264124](https://github.com/typescript-eslint/typescript-eslint/commit/e2641246571b69df36cde5cb7bce7c4fffc43f98)) +* **eslint-plugin:** remove `no-unused-vars-experimental` ([79ae03b](https://github.com/typescript-eslint/typescript-eslint/commit/79ae03b8adbae2b0a86276711a9c834af01bbb61)) +* **experimental-utils:** extract `isNodeOfTypes` out of `ast-utils`' `predicates` ([#3836](https://github.com/typescript-eslint/typescript-eslint/issues/3836)) ([0cc509b](https://github.com/typescript-eslint/typescript-eslint/commit/0cc509b61df248cfb4b42fe64ec800f3cac69c69)) +* **typescript-estree:** remove legacy `useJSXTextNode` option ([#3109](https://github.com/typescript-eslint/typescript-eslint/issues/3109)) ([5b84b98](https://github.com/typescript-eslint/typescript-eslint/commit/5b84b98fb3cf68d944b7d4e970f39f4e88f0b2d5)) +* support ESLint v8 ([#3737](https://github.com/typescript-eslint/typescript-eslint/issues/3737)) ([4ca62ae](https://github.com/typescript-eslint/typescript-eslint/commit/4ca62aee6681d706e762a8db727541ca204364f2)) +* **experimental-utils:** remove `getComments` from `ESLint` `SourceCode` types ([#3766](https://github.com/typescript-eslint/typescript-eslint/issues/3766)) ([165a507](https://github.com/typescript-eslint/typescript-eslint/commit/165a507970d8e4a0ed12abdd5f0d892f7de83ffe)) + + +### BREAKING CHANGES + +* **eslint-plugin:** `ban-types` no longer reports `object` by default + + + + + # [4.33.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.32.0...v4.33.0) (2021-10-04) diff --git a/lerna.json b/lerna.json index 2eb92dc282ad..a266c1ab0e92 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "4.33.0", + "version": "5.0.0", "npmClient": "yarn", "useWorkspaces": true, "stream": true diff --git a/packages/ast-spec/CHANGELOG.md b/packages/ast-spec/CHANGELOG.md index d26fe52ec222..9700836b888b 100644 --- a/packages/ast-spec/CHANGELOG.md +++ b/packages/ast-spec/CHANGELOG.md @@ -3,6 +3,26 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.33.0...v5.0.0) (2021-10-11) + + +### Bug Fixes + +* **typescript-estree:** change `source` of ExportNamedDeclaration to Literal from Expression ([#3763](https://github.com/typescript-eslint/typescript-eslint/issues/3763)) ([dc5a0f5](https://github.com/typescript-eslint/typescript-eslint/commit/dc5a0f5104b400f4422b8d67ecfc6cc7a32613a2)) + + +### Features + +* **ast-spec:** bring `Node` objects in line with ESTree ([#3771](https://github.com/typescript-eslint/typescript-eslint/issues/3771)) ([dd14064](https://github.com/typescript-eslint/typescript-eslint/commit/dd140643b457aa515cc21fcda2b3cd4acc2a1c5c)) +* align class property representation with ESTree ([#3806](https://github.com/typescript-eslint/typescript-eslint/issues/3806)) ([22fa5c0](https://github.com/typescript-eslint/typescript-eslint/commit/22fa5c0c4705ed2898f00b7cacc5dd642d859275)), closes [#3430](https://github.com/typescript-eslint/typescript-eslint/issues/3430) [#3077](https://github.com/typescript-eslint/typescript-eslint/issues/3077) +* remove `TSParenthesizedType` ([#3340](https://github.com/typescript-eslint/typescript-eslint/issues/3340)) ([c8ee432](https://github.com/typescript-eslint/typescript-eslint/commit/c8ee43269faea4c04ec02eaa2b81a0aa6eec5d3e)), closes [#3136](https://github.com/typescript-eslint/typescript-eslint/issues/3136) +* support `PrivateIdentifier` ([#3808](https://github.com/typescript-eslint/typescript-eslint/issues/3808)) ([0eefe5e](https://github.com/typescript-eslint/typescript-eslint/commit/0eefe5e49d21af3f1e3e2d9a90c2e49929863ac2)), closes [#3430](https://github.com/typescript-eslint/typescript-eslint/issues/3430) [#2933](https://github.com/typescript-eslint/typescript-eslint/issues/2933) +* **eslint-plugin:** removed value from abstract property nodes ([#3765](https://github.com/typescript-eslint/typescript-eslint/issues/3765)) ([5823524](https://github.com/typescript-eslint/typescript-eslint/commit/58235241714596b641a1e8b39c569e561e0039b4)), closes [#3748](https://github.com/typescript-eslint/typescript-eslint/issues/3748) + + + + + # [4.33.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.32.0...v4.33.0) (2021-10-04) **Note:** Version bump only for package @typescript-eslint/ast-spec diff --git a/packages/ast-spec/package.json b/packages/ast-spec/package.json index ccc66b7116f3..2d8aa0269d79 100644 --- a/packages/ast-spec/package.json +++ b/packages/ast-spec/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/ast-spec", - "version": "4.33.0", + "version": "5.0.0", "description": "TypeScript-ESTree AST spec", "private": true, "keywords": [ diff --git a/packages/eslint-plugin-internal/CHANGELOG.md b/packages/eslint-plugin-internal/CHANGELOG.md index d93af7147d11..fe63a7a67a5c 100644 --- a/packages/eslint-plugin-internal/CHANGELOG.md +++ b/packages/eslint-plugin-internal/CHANGELOG.md @@ -3,6 +3,18 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.33.0...v5.0.0) (2021-10-11) + + +### Features + +* remove `meta.docs.category` from rules ([#3800](https://github.com/typescript-eslint/typescript-eslint/issues/3800)) ([71c9370](https://github.com/typescript-eslint/typescript-eslint/commit/71c93706e55f5f92a1285102b93c6ab1950c6df4)) +* support ESLint v8 ([#3737](https://github.com/typescript-eslint/typescript-eslint/issues/3737)) ([4ca62ae](https://github.com/typescript-eslint/typescript-eslint/commit/4ca62aee6681d706e762a8db727541ca204364f2)) + + + + + # [4.33.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.32.0...v4.33.0) (2021-10-04) **Note:** Version bump only for package @typescript-eslint/eslint-plugin-internal diff --git a/packages/eslint-plugin-internal/package.json b/packages/eslint-plugin-internal/package.json index f5d325e44d05..4ca7567c8b87 100644 --- a/packages/eslint-plugin-internal/package.json +++ b/packages/eslint-plugin-internal/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin-internal", - "version": "4.33.0", + "version": "5.0.0", "private": true, "main": "dist/index.js", "scripts": { @@ -14,8 +14,8 @@ }, "dependencies": { "@types/prettier": "*", - "@typescript-eslint/experimental-utils": "4.33.0", - "@typescript-eslint/scope-manager": "4.33.0", + "@typescript-eslint/experimental-utils": "5.0.0", + "@typescript-eslint/scope-manager": "5.0.0", "prettier": "*" } } diff --git a/packages/eslint-plugin-tslint/CHANGELOG.md b/packages/eslint-plugin-tslint/CHANGELOG.md index c63718c8350f..689580cb9419 100644 --- a/packages/eslint-plugin-tslint/CHANGELOG.md +++ b/packages/eslint-plugin-tslint/CHANGELOG.md @@ -3,6 +3,18 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.33.0...v5.0.0) (2021-10-11) + + +### Features + +* remove `meta.docs.category` from rules ([#3800](https://github.com/typescript-eslint/typescript-eslint/issues/3800)) ([71c9370](https://github.com/typescript-eslint/typescript-eslint/commit/71c93706e55f5f92a1285102b93c6ab1950c6df4)) +* support ESLint v8 ([#3737](https://github.com/typescript-eslint/typescript-eslint/issues/3737)) ([4ca62ae](https://github.com/typescript-eslint/typescript-eslint/commit/4ca62aee6681d706e762a8db727541ca204364f2)) + + + + + # [4.33.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.32.0...v4.33.0) (2021-10-04) **Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint diff --git a/packages/eslint-plugin-tslint/package.json b/packages/eslint-plugin-tslint/package.json index 813984697072..33378ffd2bf3 100644 --- a/packages/eslint-plugin-tslint/package.json +++ b/packages/eslint-plugin-tslint/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin-tslint", - "version": "4.33.0", + "version": "5.0.0", "main": "dist/index.js", "typings": "src/index.ts", "description": "TSLint wrapper plugin for ESLint", @@ -38,7 +38,7 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/experimental-utils": "4.33.0", + "@typescript-eslint/experimental-utils": "5.0.0", "lodash": "^4.17.21" }, "peerDependencies": { @@ -48,6 +48,6 @@ }, "devDependencies": { "@types/lodash": "*", - "@typescript-eslint/parser": "4.33.0" + "@typescript-eslint/parser": "5.0.0" } } diff --git a/packages/eslint-plugin/CHANGELOG.md b/packages/eslint-plugin/CHANGELOG.md index fb68903babc0..24164b8b9adb 100644 --- a/packages/eslint-plugin/CHANGELOG.md +++ b/packages/eslint-plugin/CHANGELOG.md @@ -3,6 +3,41 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.33.0...v5.0.0) (2021-10-11) + + +### Bug Fixes + +* **eslint-plugin:** [explicit-member-accessibility] report `TSAbstractPropertyDefinition` and `TSAbstractMethodDefinition` properly ([#3901](https://github.com/typescript-eslint/typescript-eslint/issues/3901)) ([82016f9](https://github.com/typescript-eslint/typescript-eslint/commit/82016f99b14825c9c60e1f7eb3b4efcc492bba86)) +* **eslint-plugin:** update new rules from master ([#3840](https://github.com/typescript-eslint/typescript-eslint/issues/3840)) ([d88a6b4](https://github.com/typescript-eslint/typescript-eslint/commit/d88a6b44eedcf9dd59569160570aa118851aa86b)) +* update new rules from master ([b34fb7e](https://github.com/typescript-eslint/typescript-eslint/commit/b34fb7eb3102ea603bb4aef0dbbf9885b3d47557)) +* **eslint-plugin:** crash in no-dupe-class-members (v5) ([#3813](https://github.com/typescript-eslint/typescript-eslint/issues/3813)) ([4b09644](https://github.com/typescript-eslint/typescript-eslint/commit/4b096442f731c0a60926ac0391a4f2c4208aa8d4)) + + +### Features + +* **ast-spec:** bring `Node` objects in line with ESTree ([#3771](https://github.com/typescript-eslint/typescript-eslint/issues/3771)) ([dd14064](https://github.com/typescript-eslint/typescript-eslint/commit/dd140643b457aa515cc21fcda2b3cd4acc2a1c5c)) +* **eslint-plugin:** remove `object` from `ban-types`' default types ([#3818](https://github.com/typescript-eslint/typescript-eslint/issues/3818)) ([ae3fa90](https://github.com/typescript-eslint/typescript-eslint/commit/ae3fa900d5b4e1f557a52ca58d35a7d098d9efaf)) +* **eslint-plugin:** removed value from abstract property nodes ([#3765](https://github.com/typescript-eslint/typescript-eslint/issues/3765)) ([5823524](https://github.com/typescript-eslint/typescript-eslint/commit/58235241714596b641a1e8b39c569e561e0039b4)), closes [#3748](https://github.com/typescript-eslint/typescript-eslint/issues/3748) +* **eslint-plugin:** update recommended configs ([#3809](https://github.com/typescript-eslint/typescript-eslint/issues/3809)) ([deeb7bb](https://github.com/typescript-eslint/typescript-eslint/commit/deeb7bb9334d301c6af56aefd37d318231af11ef)) +* align class property representation with ESTree ([#3806](https://github.com/typescript-eslint/typescript-eslint/issues/3806)) ([22fa5c0](https://github.com/typescript-eslint/typescript-eslint/commit/22fa5c0c4705ed2898f00b7cacc5dd642d859275)), closes [#3430](https://github.com/typescript-eslint/typescript-eslint/issues/3430) [#3077](https://github.com/typescript-eslint/typescript-eslint/issues/3077) +* remove `meta.docs.category` from rules ([#3800](https://github.com/typescript-eslint/typescript-eslint/issues/3800)) ([71c9370](https://github.com/typescript-eslint/typescript-eslint/commit/71c93706e55f5f92a1285102b93c6ab1950c6df4)) +* remove `TSParenthesizedType` ([#3340](https://github.com/typescript-eslint/typescript-eslint/issues/3340)) ([c8ee432](https://github.com/typescript-eslint/typescript-eslint/commit/c8ee43269faea4c04ec02eaa2b81a0aa6eec5d3e)), closes [#3136](https://github.com/typescript-eslint/typescript-eslint/issues/3136) +* support `PrivateIdentifier` ([#3808](https://github.com/typescript-eslint/typescript-eslint/issues/3808)) ([0eefe5e](https://github.com/typescript-eslint/typescript-eslint/commit/0eefe5e49d21af3f1e3e2d9a90c2e49929863ac2)), closes [#3430](https://github.com/typescript-eslint/typescript-eslint/issues/3430) [#2933](https://github.com/typescript-eslint/typescript-eslint/issues/2933) +* **eslint-plugin:** [comma-dangle] align schema with ESLint v8 ([#3768](https://github.com/typescript-eslint/typescript-eslint/issues/3768)) ([0acfafc](https://github.com/typescript-eslint/typescript-eslint/commit/0acfafcc655e28dcfc05a5caa567c0d0217ee7ad)) +* **eslint-plugin:** [member-ordering] add support for getters and setters ([#3611](https://github.com/typescript-eslint/typescript-eslint/issues/3611)) ([e264124](https://github.com/typescript-eslint/typescript-eslint/commit/e2641246571b69df36cde5cb7bce7c4fffc43f98)) +* **eslint-plugin:** remove `no-unused-vars-experimental` ([79ae03b](https://github.com/typescript-eslint/typescript-eslint/commit/79ae03b8adbae2b0a86276711a9c834af01bbb61)) +* support ESLint v8 ([#3737](https://github.com/typescript-eslint/typescript-eslint/issues/3737)) ([4ca62ae](https://github.com/typescript-eslint/typescript-eslint/commit/4ca62aee6681d706e762a8db727541ca204364f2)) + + +### BREAKING CHANGES + +* **eslint-plugin:** `ban-types` no longer reports `object` by default + + + + + # [4.33.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.32.0...v4.33.0) (2021-10-04) diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index ed1e439926d5..f49ea2c65daf 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin", - "version": "4.33.0", + "version": "5.0.0", "description": "TypeScript plugin for ESLint", "keywords": [ "eslint", @@ -44,8 +44,8 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/experimental-utils": "4.33.0", - "@typescript-eslint/scope-manager": "4.33.0", + "@typescript-eslint/experimental-utils": "5.0.0", + "@typescript-eslint/scope-manager": "5.0.0", "debug": "^4.3.1", "functional-red-black-tree": "^1.0.1", "ignore": "^5.1.8", diff --git a/packages/experimental-utils/CHANGELOG.md b/packages/experimental-utils/CHANGELOG.md index 4fc1e388ede2..d6c5611fcacb 100644 --- a/packages/experimental-utils/CHANGELOG.md +++ b/packages/experimental-utils/CHANGELOG.md @@ -3,6 +3,28 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.33.0...v5.0.0) (2021-10-11) + + +### Bug Fixes + +* **experimental-utils:** fix `isSetter`'s return type ([#3975](https://github.com/typescript-eslint/typescript-eslint/issues/3975)) ([d256856](https://github.com/typescript-eslint/typescript-eslint/commit/d2568561d0417fdfbdfd964ad942f9d00434af73)) + + +### Features + +* **ast-spec:** bring `Node` objects in line with ESTree ([#3771](https://github.com/typescript-eslint/typescript-eslint/issues/3771)) ([dd14064](https://github.com/typescript-eslint/typescript-eslint/commit/dd140643b457aa515cc21fcda2b3cd4acc2a1c5c)) +* align class property representation with ESTree ([#3806](https://github.com/typescript-eslint/typescript-eslint/issues/3806)) ([22fa5c0](https://github.com/typescript-eslint/typescript-eslint/commit/22fa5c0c4705ed2898f00b7cacc5dd642d859275)), closes [#3430](https://github.com/typescript-eslint/typescript-eslint/issues/3430) [#3077](https://github.com/typescript-eslint/typescript-eslint/issues/3077) +* remove `meta.docs.category` from rules ([#3800](https://github.com/typescript-eslint/typescript-eslint/issues/3800)) ([71c9370](https://github.com/typescript-eslint/typescript-eslint/commit/71c93706e55f5f92a1285102b93c6ab1950c6df4)) +* remove `TSParenthesizedType` ([#3340](https://github.com/typescript-eslint/typescript-eslint/issues/3340)) ([c8ee432](https://github.com/typescript-eslint/typescript-eslint/commit/c8ee43269faea4c04ec02eaa2b81a0aa6eec5d3e)), closes [#3136](https://github.com/typescript-eslint/typescript-eslint/issues/3136) +* support ESLint v8 ([#3737](https://github.com/typescript-eslint/typescript-eslint/issues/3737)) ([4ca62ae](https://github.com/typescript-eslint/typescript-eslint/commit/4ca62aee6681d706e762a8db727541ca204364f2)) +* **experimental-utils:** extract `isNodeOfTypes` out of `ast-utils`' `predicates` ([#3836](https://github.com/typescript-eslint/typescript-eslint/issues/3836)) ([0cc509b](https://github.com/typescript-eslint/typescript-eslint/commit/0cc509b61df248cfb4b42fe64ec800f3cac69c69)) +* **experimental-utils:** remove `getComments` from `ESLint` `SourceCode` types ([#3766](https://github.com/typescript-eslint/typescript-eslint/issues/3766)) ([165a507](https://github.com/typescript-eslint/typescript-eslint/commit/165a507970d8e4a0ed12abdd5f0d892f7de83ffe)) + + + + + # [4.33.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.32.0...v4.33.0) (2021-10-04) diff --git a/packages/experimental-utils/package.json b/packages/experimental-utils/package.json index ed9b0d3dc914..820da1ffc8db 100644 --- a/packages/experimental-utils/package.json +++ b/packages/experimental-utils/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/experimental-utils", - "version": "4.33.0", + "version": "5.0.0", "description": "(Experimental) Utilities for working with TypeScript + ESLint together", "keywords": [ "eslint", @@ -40,9 +40,9 @@ }, "dependencies": { "@types/json-schema": "^7.0.7", - "@typescript-eslint/scope-manager": "4.33.0", - "@typescript-eslint/types": "4.33.0", - "@typescript-eslint/typescript-estree": "4.33.0", + "@typescript-eslint/scope-manager": "5.0.0", + "@typescript-eslint/types": "5.0.0", + "@typescript-eslint/typescript-estree": "5.0.0", "eslint-scope": "^5.1.1", "eslint-utils": "^3.0.0" }, diff --git a/packages/parser/CHANGELOG.md b/packages/parser/CHANGELOG.md index 892b55f89f56..4328fce0b216 100644 --- a/packages/parser/CHANGELOG.md +++ b/packages/parser/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.33.0...v5.0.0) (2021-10-11) + + +### Features + +* support ESLint v8 ([#3737](https://github.com/typescript-eslint/typescript-eslint/issues/3737)) ([4ca62ae](https://github.com/typescript-eslint/typescript-eslint/commit/4ca62aee6681d706e762a8db727541ca204364f2)) + + + + + # [4.33.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.32.0...v4.33.0) (2021-10-04) **Note:** Version bump only for package @typescript-eslint/parser diff --git a/packages/parser/package.json b/packages/parser/package.json index 64caa07a14e9..efa2212665c1 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/parser", - "version": "4.33.0", + "version": "5.0.0", "description": "An ESLint custom parser which leverages TypeScript ESTree", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -44,14 +44,14 @@ "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" }, "dependencies": { - "@typescript-eslint/scope-manager": "4.33.0", - "@typescript-eslint/types": "4.33.0", - "@typescript-eslint/typescript-estree": "4.33.0", + "@typescript-eslint/scope-manager": "5.0.0", + "@typescript-eslint/types": "5.0.0", + "@typescript-eslint/typescript-estree": "5.0.0", "debug": "^4.3.1" }, "devDependencies": { "@types/glob": "*", - "@typescript-eslint/experimental-utils": "4.33.0", + "@typescript-eslint/experimental-utils": "5.0.0", "glob": "*", "typescript": "*" }, diff --git a/packages/scope-manager/CHANGELOG.md b/packages/scope-manager/CHANGELOG.md index 7d0ddf98816f..40ae08d39d9f 100644 --- a/packages/scope-manager/CHANGELOG.md +++ b/packages/scope-manager/CHANGELOG.md @@ -3,6 +3,19 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.33.0...v5.0.0) (2021-10-11) + + +### Features + +* align class property representation with ESTree ([#3806](https://github.com/typescript-eslint/typescript-eslint/issues/3806)) ([22fa5c0](https://github.com/typescript-eslint/typescript-eslint/commit/22fa5c0c4705ed2898f00b7cacc5dd642d859275)), closes [#3430](https://github.com/typescript-eslint/typescript-eslint/issues/3430) [#3077](https://github.com/typescript-eslint/typescript-eslint/issues/3077) +* support `PrivateIdentifier` ([#3808](https://github.com/typescript-eslint/typescript-eslint/issues/3808)) ([0eefe5e](https://github.com/typescript-eslint/typescript-eslint/commit/0eefe5e49d21af3f1e3e2d9a90c2e49929863ac2)), closes [#3430](https://github.com/typescript-eslint/typescript-eslint/issues/3430) [#2933](https://github.com/typescript-eslint/typescript-eslint/issues/2933) +* **eslint-plugin:** removed value from abstract property nodes ([#3765](https://github.com/typescript-eslint/typescript-eslint/issues/3765)) ([5823524](https://github.com/typescript-eslint/typescript-eslint/commit/58235241714596b641a1e8b39c569e561e0039b4)), closes [#3748](https://github.com/typescript-eslint/typescript-eslint/issues/3748) + + + + + # [4.33.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.32.0...v4.33.0) (2021-10-04) **Note:** Version bump only for package @typescript-eslint/scope-manager diff --git a/packages/scope-manager/package.json b/packages/scope-manager/package.json index ac2c2a335f9b..e534cc63c536 100644 --- a/packages/scope-manager/package.json +++ b/packages/scope-manager/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/scope-manager", - "version": "4.33.0", + "version": "5.0.0", "description": "TypeScript scope analyser for ESLint", "keywords": [ "eslint", @@ -39,12 +39,12 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/types": "4.33.0", - "@typescript-eslint/visitor-keys": "4.33.0" + "@typescript-eslint/types": "5.0.0", + "@typescript-eslint/visitor-keys": "5.0.0" }, "devDependencies": { "@types/glob": "*", - "@typescript-eslint/typescript-estree": "4.33.0", + "@typescript-eslint/typescript-estree": "5.0.0", "glob": "*", "jest-specific-snapshot": "*", "make-dir": "*", diff --git a/packages/shared-fixtures/CHANGELOG.md b/packages/shared-fixtures/CHANGELOG.md index b4e3999eac20..ee8c3d0abc6a 100644 --- a/packages/shared-fixtures/CHANGELOG.md +++ b/packages/shared-fixtures/CHANGELOG.md @@ -3,6 +3,23 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.33.0...v5.0.0) (2021-10-11) + + +### Bug Fixes + +* **typescript-estree:** change `source` of ExportNamedDeclaration to Literal from Expression ([#3763](https://github.com/typescript-eslint/typescript-eslint/issues/3763)) ([dc5a0f5](https://github.com/typescript-eslint/typescript-eslint/commit/dc5a0f5104b400f4422b8d67ecfc6cc7a32613a2)) + + +### Features + +* support `PrivateIdentifier` ([#3808](https://github.com/typescript-eslint/typescript-eslint/issues/3808)) ([0eefe5e](https://github.com/typescript-eslint/typescript-eslint/commit/0eefe5e49d21af3f1e3e2d9a90c2e49929863ac2)), closes [#3430](https://github.com/typescript-eslint/typescript-eslint/issues/3430) [#2933](https://github.com/typescript-eslint/typescript-eslint/issues/2933) +* **eslint-plugin:** removed value from abstract property nodes ([#3765](https://github.com/typescript-eslint/typescript-eslint/issues/3765)) ([5823524](https://github.com/typescript-eslint/typescript-eslint/commit/58235241714596b641a1e8b39c569e561e0039b4)), closes [#3748](https://github.com/typescript-eslint/typescript-eslint/issues/3748) + + + + + # [4.33.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.32.0...v4.33.0) (2021-10-04) **Note:** Version bump only for package @typescript-eslint/shared-fixtures diff --git a/packages/shared-fixtures/package.json b/packages/shared-fixtures/package.json index ecbb220c80f1..a93c026c4fb6 100644 --- a/packages/shared-fixtures/package.json +++ b/packages/shared-fixtures/package.json @@ -1,5 +1,5 @@ { "name": "@typescript-eslint/shared-fixtures", - "version": "4.33.0", + "version": "5.0.0", "private": true } diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index 215fa2e52936..9a266a4a5eb9 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.33.0...v5.0.0) (2021-10-11) + + +### Features + +* support `PrivateIdentifier` ([#3808](https://github.com/typescript-eslint/typescript-eslint/issues/3808)) ([0eefe5e](https://github.com/typescript-eslint/typescript-eslint/commit/0eefe5e49d21af3f1e3e2d9a90c2e49929863ac2)), closes [#3430](https://github.com/typescript-eslint/typescript-eslint/issues/3430) [#2933](https://github.com/typescript-eslint/typescript-eslint/issues/2933) + + + + + # [4.33.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.32.0...v4.33.0) (2021-10-04) **Note:** Version bump only for package @typescript-eslint/types diff --git a/packages/types/package.json b/packages/types/package.json index 4cb0ba110bda..0d0adb29f43c 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/types", - "version": "4.33.0", + "version": "5.0.0", "description": "Types for the TypeScript-ESTree AST spec", "keywords": [ "eslint", diff --git a/packages/typescript-estree/CHANGELOG.md b/packages/typescript-estree/CHANGELOG.md index f957fb3ba982..c5368d811729 100644 --- a/packages/typescript-estree/CHANGELOG.md +++ b/packages/typescript-estree/CHANGELOG.md @@ -3,6 +3,28 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.33.0...v5.0.0) (2021-10-11) + + +### Bug Fixes + +* **typescript-estree:** change `source` of ExportNamedDeclaration to Literal from Expression ([#3763](https://github.com/typescript-eslint/typescript-eslint/issues/3763)) ([dc5a0f5](https://github.com/typescript-eslint/typescript-eslint/commit/dc5a0f5104b400f4422b8d67ecfc6cc7a32613a2)) + + +### Features + +* **ast-spec:** bring `Node` objects in line with ESTree ([#3771](https://github.com/typescript-eslint/typescript-eslint/issues/3771)) ([dd14064](https://github.com/typescript-eslint/typescript-eslint/commit/dd140643b457aa515cc21fcda2b3cd4acc2a1c5c)) +* **eslint-plugin:** update recommended configs ([#3809](https://github.com/typescript-eslint/typescript-eslint/issues/3809)) ([deeb7bb](https://github.com/typescript-eslint/typescript-eslint/commit/deeb7bb9334d301c6af56aefd37d318231af11ef)) +* align class property representation with ESTree ([#3806](https://github.com/typescript-eslint/typescript-eslint/issues/3806)) ([22fa5c0](https://github.com/typescript-eslint/typescript-eslint/commit/22fa5c0c4705ed2898f00b7cacc5dd642d859275)), closes [#3430](https://github.com/typescript-eslint/typescript-eslint/issues/3430) [#3077](https://github.com/typescript-eslint/typescript-eslint/issues/3077) +* remove `TSParenthesizedType` ([#3340](https://github.com/typescript-eslint/typescript-eslint/issues/3340)) ([c8ee432](https://github.com/typescript-eslint/typescript-eslint/commit/c8ee43269faea4c04ec02eaa2b81a0aa6eec5d3e)), closes [#3136](https://github.com/typescript-eslint/typescript-eslint/issues/3136) +* support `PrivateIdentifier` ([#3808](https://github.com/typescript-eslint/typescript-eslint/issues/3808)) ([0eefe5e](https://github.com/typescript-eslint/typescript-eslint/commit/0eefe5e49d21af3f1e3e2d9a90c2e49929863ac2)), closes [#3430](https://github.com/typescript-eslint/typescript-eslint/issues/3430) [#2933](https://github.com/typescript-eslint/typescript-eslint/issues/2933) +* **eslint-plugin:** removed value from abstract property nodes ([#3765](https://github.com/typescript-eslint/typescript-eslint/issues/3765)) ([5823524](https://github.com/typescript-eslint/typescript-eslint/commit/58235241714596b641a1e8b39c569e561e0039b4)), closes [#3748](https://github.com/typescript-eslint/typescript-eslint/issues/3748) +* **typescript-estree:** remove legacy `useJSXTextNode` option ([#3109](https://github.com/typescript-eslint/typescript-eslint/issues/3109)) ([5b84b98](https://github.com/typescript-eslint/typescript-eslint/commit/5b84b98fb3cf68d944b7d4e970f39f4e88f0b2d5)) + + + + + # [4.33.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.32.0...v4.33.0) (2021-10-04) **Note:** Version bump only for package @typescript-eslint/typescript-estree diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index 2d70c3f50cd1..ee54a5dbd14f 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/typescript-estree", - "version": "4.33.0", + "version": "5.0.0", "description": "A parser that converts TypeScript source code into an ESTree compatible form", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -41,8 +41,8 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/types": "4.33.0", - "@typescript-eslint/visitor-keys": "4.33.0", + "@typescript-eslint/types": "5.0.0", + "@typescript-eslint/visitor-keys": "5.0.0", "debug": "^4.3.1", "globby": "^11.0.3", "is-glob": "^4.0.1", @@ -59,7 +59,7 @@ "@types/is-glob": "*", "@types/semver": "*", "@types/tmp": "*", - "@typescript-eslint/shared-fixtures": "4.33.0", + "@typescript-eslint/shared-fixtures": "5.0.0", "glob": "*", "jest-specific-snapshot": "*", "make-dir": "*", diff --git a/packages/visitor-keys/CHANGELOG.md b/packages/visitor-keys/CHANGELOG.md index 0376970754eb..6393289b2c82 100644 --- a/packages/visitor-keys/CHANGELOG.md +++ b/packages/visitor-keys/CHANGELOG.md @@ -3,6 +3,20 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.33.0...v5.0.0) (2021-10-11) + + +### Features + +* align class property representation with ESTree ([#3806](https://github.com/typescript-eslint/typescript-eslint/issues/3806)) ([22fa5c0](https://github.com/typescript-eslint/typescript-eslint/commit/22fa5c0c4705ed2898f00b7cacc5dd642d859275)), closes [#3430](https://github.com/typescript-eslint/typescript-eslint/issues/3430) [#3077](https://github.com/typescript-eslint/typescript-eslint/issues/3077) +* remove `TSParenthesizedType` ([#3340](https://github.com/typescript-eslint/typescript-eslint/issues/3340)) ([c8ee432](https://github.com/typescript-eslint/typescript-eslint/commit/c8ee43269faea4c04ec02eaa2b81a0aa6eec5d3e)), closes [#3136](https://github.com/typescript-eslint/typescript-eslint/issues/3136) +* support `PrivateIdentifier` ([#3808](https://github.com/typescript-eslint/typescript-eslint/issues/3808)) ([0eefe5e](https://github.com/typescript-eslint/typescript-eslint/commit/0eefe5e49d21af3f1e3e2d9a90c2e49929863ac2)), closes [#3430](https://github.com/typescript-eslint/typescript-eslint/issues/3430) [#2933](https://github.com/typescript-eslint/typescript-eslint/issues/2933) +* **eslint-plugin:** removed value from abstract property nodes ([#3765](https://github.com/typescript-eslint/typescript-eslint/issues/3765)) ([5823524](https://github.com/typescript-eslint/typescript-eslint/commit/58235241714596b641a1e8b39c569e561e0039b4)), closes [#3748](https://github.com/typescript-eslint/typescript-eslint/issues/3748) + + + + + # [4.33.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.32.0...v4.33.0) (2021-10-04) **Note:** Version bump only for package @typescript-eslint/visitor-keys diff --git a/packages/visitor-keys/package.json b/packages/visitor-keys/package.json index 5ea3a984b532..4ef726e3e3d7 100644 --- a/packages/visitor-keys/package.json +++ b/packages/visitor-keys/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/visitor-keys", - "version": "4.33.0", + "version": "5.0.0", "description": "Visitor keys used to help traverse the TypeScript-ESTree AST", "keywords": [ "eslint", @@ -38,7 +38,7 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/types": "4.33.0", + "@typescript-eslint/types": "5.0.0", "eslint-visitor-keys": "^3.0.0" }, "devDependencies": {