From d8e296d792bde091c98c8539400f96fc47418486 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jan 2022 00:52:38 -0800 Subject: [PATCH 1/6] chore: bump webpack from 5.65.0 to 5.66.0 (#4455) Bumps [webpack](https://github.com/webpack/webpack) from 5.65.0 to 5.66.0. - [Release notes](https://github.com/webpack/webpack/releases) - [Commits](https://github.com/webpack/webpack/compare/v5.65.0...v5.66.0) --- updated-dependencies: - dependency-name: webpack 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 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/yarn.lock b/yarn.lock index 9019ac2a0fd9..e39d75eb9ab6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7939,10 +7939,10 @@ got@^9.6.0: to-readable-stream "^1.0.0" url-parse-lax "^3.0.0" -graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.2, graceful-fs@^4.2.3, graceful-fs@^4.2.4, graceful-fs@^4.2.6: - version "4.2.8" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.8.tgz#e412b8d33f5e006593cbd3cee6df9f2cebbe802a" - integrity sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg== +graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.2, graceful-fs@^4.2.3, graceful-fs@^4.2.4, graceful-fs@^4.2.6, graceful-fs@^4.2.9: + version "4.2.9" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.9.tgz#041b05df45755e587a24942279b9d113146e1c96" + integrity sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ== gray-matter@^4.0.3: version "4.0.3" @@ -15021,9 +15021,9 @@ webpack-sources@^3.2.2: integrity sha512-cp5qdmHnu5T8wRg2G3vZZHoJPN14aqQ89SyQ11NpGH5zEMDCclt49rzo+MaRazk7/UeILhAI+/sEtcM+7Fr0nw== webpack@^5.61.0, webpack@^5.64.0: - version "5.65.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.65.0.tgz#ed2891d9145ba1f0d318e4ea4f89c3fa18e6f9be" - integrity sha512-Q5or2o6EKs7+oKmJo7LaqZaMOlDWQse9Tm5l1WAfU/ujLGN5Pb0SqGeVkN/4bpPmEqEP5RnVhiqsOtWtUVwGRw== + version "5.66.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.66.0.tgz#789bf36287f407fc92b3e2d6f978ddff1bfc2dbb" + integrity sha512-NJNtGT7IKpGzdW7Iwpn/09OXz9inIkeIQ/ibY6B+MdV1x6+uReqz/5z1L89ezWnpPDWpXF0TY5PCYKQdWVn8Vg== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.50" @@ -15039,7 +15039,7 @@ webpack@^5.61.0, webpack@^5.64.0: eslint-scope "5.1.1" events "^3.2.0" glob-to-regexp "^0.4.1" - graceful-fs "^4.2.4" + graceful-fs "^4.2.9" json-parse-better-errors "^1.0.2" loader-runner "^4.2.0" mime-types "^2.1.27" From 04cb5d869411159d7eb53b952e2bef208f88e112 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jan 2022 00:52:52 -0800 Subject: [PATCH 2/6] chore: bump ts-jest from 27.1.2 to 27.1.3 (#4457) Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 27.1.2 to 27.1.3. - [Release notes](https://github.com/kulshekhar/ts-jest/releases) - [Changelog](https://github.com/kulshekhar/ts-jest/blob/main/CHANGELOG.md) - [Commits](https://github.com/kulshekhar/ts-jest/compare/v27.1.2...v27.1.3) --- updated-dependencies: - dependency-name: ts-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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index e39d75eb9ab6..d5f04e304cf0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14300,9 +14300,9 @@ ts-essentials@^2.0.3: integrity sha512-3IVX4nI6B5cc31/GFFE+i8ey/N2eA0CZDbo6n0yrz0zDX8ZJ8djmU1p+XRz7G3is0F3bB3pu2pAroFdAWQKU3w== ts-jest@^27.0.5: - version "27.1.2" - resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-27.1.2.tgz#5991d6eb3fd8e1a8d4b8f6de3ec0a3cc567f3151" - integrity sha512-eSOiJOWq6Hhs6Khzk5wKC5sgWIXgXqOCiIl1+3lfnearu58Hj4QpE5tUhQcA3xtZrELbcvAGCsd6HB8OsaVaTA== + version "27.1.3" + resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-27.1.3.tgz#1f723e7e74027c4da92c0ffbd73287e8af2b2957" + integrity sha512-6Nlura7s6uM9BVUAoqLH7JHyMXjz8gluryjpPXxr3IxZdAXnU6FhjvVLHFtfd1vsE1p8zD1OJfskkc0jhTSnkA== dependencies: bs-logger "0.x" fast-json-stable-stringify "2.x" From ba3d3a3b580cbd015b7968ffb762a24b17fa6ad6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jan 2022 00:52:59 -0800 Subject: [PATCH 3/6] chore: bump eslint-plugin-jest from 25.3.4 to 25.7.0 (#4456) Bumps [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) from 25.3.4 to 25.7.0. - [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/v25.3.4...v25.7.0) --- 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 d5f04e304cf0..6d1fad15160b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6872,9 +6872,9 @@ eslint-plugin-import@^2.25.2: tsconfig-paths "^3.12.0" eslint-plugin-jest@^25.0.5: - version "25.3.4" - resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-25.3.4.tgz#2031dfe495be1463330f8b80096ddc91f8e6387f" - integrity sha512-CCnwG71wvabmwq/qkz0HWIqBHQxw6pXB1uqt24dxqJ9WB34pVg49bL1sjXphlJHgTMWGhBjN1PicdyxDxrfP5A== + version "25.7.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-25.7.0.tgz#ff4ac97520b53a96187bad9c9814e7d00de09a6a" + integrity sha512-PWLUEXeeF7C9QGKqvdSbzLOiLTx+bno7/HC9eefePfEb257QFHg7ye3dh80AZVkaa/RQsBB1Q/ORQvg2X7F0NQ== dependencies: "@typescript-eslint/experimental-utils" "^5.0.0" From e56f1e5d52fcbf3caae43034872e0b3181871689 Mon Sep 17 00:00:00 2001 From: Yosuke Ota Date: Mon, 17 Jan 2022 17:56:46 +0900 Subject: [PATCH 4/6] fix(eslint-plugin): [no-invalid-this] crash when used with eslint 8.7.0 (#4448) * fix(eslint-plugin): [no-invalid-this] crash when used with eslint 8.7.0 * revert eslint version --- .../src/rules/no-invalid-this.ts | 8 ++++---- .../eslint-plugin/typings/eslint-rules.d.ts | 20 +++++++++++++------ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/packages/eslint-plugin/src/rules/no-invalid-this.ts b/packages/eslint-plugin/src/rules/no-invalid-this.ts index 5884cc61dfa0..0ea8692e64a8 100644 --- a/packages/eslint-plugin/src/rules/no-invalid-this.ts +++ b/packages/eslint-plugin/src/rules/no-invalid-this.ts @@ -64,12 +64,12 @@ export default createRule({ ), ); // baseRule's work - rules.FunctionDeclaration(node); + rules.FunctionDeclaration?.(node); }, 'FunctionDeclaration:exit'(node: TSESTree.FunctionDeclaration): void { thisIsValidStack.pop(); // baseRule's work - rules['FunctionDeclaration:exit'](node); + rules['FunctionDeclaration:exit']?.(node); }, FunctionExpression(node: TSESTree.FunctionExpression): void { thisIsValidStack.push( @@ -79,12 +79,12 @@ export default createRule({ ), ); // baseRule's work - rules.FunctionExpression(node); + rules.FunctionExpression?.(node); }, 'FunctionExpression:exit'(node: TSESTree.FunctionExpression): void { thisIsValidStack.pop(); // baseRule's work - rules['FunctionExpression:exit'](node); + rules['FunctionExpression:exit']?.(node); }, ThisExpression(node: TSESTree.ThisExpression): void { const thisIsValidHere = thisIsValidStack[thisIsValidStack.length - 1]; diff --git a/packages/eslint-plugin/typings/eslint-rules.d.ts b/packages/eslint-plugin/typings/eslint-rules.d.ts index a279276e91b0..fc2491d67c85 100644 --- a/packages/eslint-plugin/typings/eslint-rules.d.ts +++ b/packages/eslint-plugin/typings/eslint-rules.d.ts @@ -701,12 +701,20 @@ declare module 'eslint/lib/rules/no-invalid-this' { }?, ], { - Program(node: TSESTree.Program): void; - 'Program:exit'(node: TSESTree.Program): void; - FunctionDeclaration(node: TSESTree.FunctionDeclaration): void; - 'FunctionDeclaration:exit'(node: TSESTree.FunctionDeclaration): void; - FunctionExpression(node: TSESTree.FunctionExpression): void; - 'FunctionExpression:exit'(node: TSESTree.FunctionExpression): void; + // for ESLint < v8.7.0 + Program?: (node: TSESTree.Program) => void; + 'Program:exit'?: (node: TSESTree.Program) => void; + FunctionDeclaration?: (node: TSESTree.FunctionDeclaration) => void; + 'FunctionDeclaration:exit'?: (node: TSESTree.FunctionDeclaration) => void; + FunctionExpression?: (node: TSESTree.FunctionExpression) => void; + 'FunctionExpression:exit'?: (node: TSESTree.FunctionExpression) => void; + + // for ESLint >= v8.7.0 + // We don't use it and we don't have the CodePath types, so comment out it. + // onCodePathStart?: (codePath: unknown, node: TSESTree.Node) => void + // onCodePathEnd?: (codePath: unknown, node: TSESTree.Node) => void + + // Common ThisExpression(node: TSESTree.ThisExpression): void; } >; From 3061ea9f83f3208ce092cb4e8d96a087a0c273e3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jan 2022 00:57:01 -0800 Subject: [PATCH 5/6] chore: bump @babel/types from 7.16.7 to 7.16.8 (#4454) Bumps [@babel/types](https://github.com/babel/babel/tree/HEAD/packages/babel-types) from 7.16.7 to 7.16.8. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.16.8/packages/babel-types) --- updated-dependencies: - dependency-name: "@babel/types" 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 6d1fad15160b..e27212405071 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1309,9 +1309,9 @@ globals "^11.1.0" "@babel/types@*", "@babel/types@^7.0.0", "@babel/types@^7.12.7", "@babel/types@^7.15.6", "@babel/types@^7.16.0", "@babel/types@^7.16.7", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4": - version "7.16.7" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.16.7.tgz#4ed19d51f840ed4bd5645be6ce40775fecf03159" - integrity sha512-E8HuV7FO9qLpx6OtoGfUQ2cjIYnbFwvZWYBS+87EwtdMvmUPJSwykpovFB+8insbpF0uJcpr8KMUi64XZntZcg== + version "7.16.8" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.16.8.tgz#0ba5da91dd71e0a4e7781a30f22770831062e3c1" + integrity sha512-smN2DQc5s4M7fntyjGtyIPbRJv6wW4rU/94fmYJ7PKQuZkC0qGMHXJbg6sNGt12JmVr4k5YaptI/XtiLJBnmIg== dependencies: "@babel/helper-validator-identifier" "^7.16.7" to-fast-properties "^2.0.0" From ef3147cf73767ddece91ce57f6028a83ce074b60 Mon Sep 17 00:00:00 2001 From: Rebecca Stevens Date: Mon, 17 Jan 2022 21:59:04 +1300 Subject: [PATCH 6/6] fix(type-utils): check IndexSignature internals when checking isTypeReadonly (#4417) * fix(type-utils): make isTypeReadonly's options param optional fix #4410 * test(type-utils): add basic tests for isTypeReadonly * test(type-utils): add test for IndexSignature internals * fix(type-utils): check IndexSignature internals when checking isTypeReadonly fix #3714 * perf(type-utils): don't test IndexSignature key for readonlyness as it will always be readonly Co-authored-by: Josh Goldberg --- packages/type-utils/src/isTypeReadonly.ts | 56 +++++++++++++------ .../type-utils/tests/isTypeReadonly.test.ts | 28 ++++++++++ 2 files changed, 68 insertions(+), 16 deletions(-) diff --git a/packages/type-utils/src/isTypeReadonly.ts b/packages/type-utils/src/isTypeReadonly.ts index d5d05e94a0e8..632108cd6b3a 100644 --- a/packages/type-utils/src/isTypeReadonly.ts +++ b/packages/type-utils/src/isTypeReadonly.ts @@ -107,9 +107,16 @@ function isTypeReadonlyObject( function checkIndexSignature(kind: ts.IndexKind): Readonlyness { const indexInfo = checker.getIndexInfoOfType(type, kind); if (indexInfo) { - return indexInfo.isReadonly - ? Readonlyness.Readonly - : Readonlyness.Mutable; + if (!indexInfo.isReadonly) { + return Readonlyness.Mutable; + } + + return isTypeReadonlyRecurser( + checker, + indexInfo.type, + options, + seenTypes, + ); } return Readonlyness.UnknownType; @@ -119,20 +126,37 @@ function isTypeReadonlyObject( if (properties.length) { // ensure the properties are marked as readonly for (const property of properties) { - if ( - !( - isPropertyReadonlyInType(type, property.getEscapedName(), checker) || - (options.treatMethodsAsReadonly && - property.valueDeclaration !== undefined && - hasSymbol(property.valueDeclaration) && - isSymbolFlagSet( - property.valueDeclaration.symbol, - ts.SymbolFlags.Method, - )) - ) - ) { - return Readonlyness.Mutable; + if (options.treatMethodsAsReadonly) { + if ( + property.valueDeclaration !== undefined && + hasSymbol(property.valueDeclaration) && + isSymbolFlagSet( + property.valueDeclaration.symbol, + ts.SymbolFlags.Method, + ) + ) { + continue; + } + + const declarations = property.getDeclarations(); + const lastDeclaration = + declarations !== undefined && declarations.length > 0 + ? declarations[declarations.length - 1] + : undefined; + if ( + lastDeclaration !== undefined && + hasSymbol(lastDeclaration) && + isSymbolFlagSet(lastDeclaration.symbol, ts.SymbolFlags.Method) + ) { + continue; + } + } + + if (isPropertyReadonlyInType(type, property.getEscapedName(), checker)) { + continue; } + + return Readonlyness.Mutable; } // all properties were readonly diff --git a/packages/type-utils/tests/isTypeReadonly.test.ts b/packages/type-utils/tests/isTypeReadonly.test.ts index 5afc3b6e59ca..d63ecf422d93 100644 --- a/packages/type-utils/tests/isTypeReadonly.test.ts +++ b/packages/type-utils/tests/isTypeReadonly.test.ts @@ -109,6 +109,34 @@ describe('isTypeReadonly', () => { ])('handles non fully readonly sets and maps', runTests); }); }); + + describe('IndexSignature', () => { + describe('is readonly', () => { + const runTests = runTestIsReadonly; + + it.each([ + ['type Test = { readonly [key: string]: string };'], + [ + 'type Test = { readonly [key: string]: { readonly foo: readonly string[]; }; };', + ], + ])( + 'handles readonly PropertySignature inside a readonly IndexSignature', + runTests, + ); + }); + + describe('is not readonly', () => { + const runTests = runTestIsNotReadonly; + + it.each([ + ['type Test = { [key: string]: string };'], + ['type Test = { readonly [key: string]: { foo: string[]; }; };'], + ])( + 'handles mutable PropertySignature inside a readonly IndexSignature', + runTests, + ); + }); + }); }); describe('treatMethodsAsReadonly', () => {