From d3e5c39804e095551b819122e9b3cd3f0bd0c498 Mon Sep 17 00:00:00 2001 From: Armano Date: Thu, 11 Feb 2021 07:10:52 +0100 Subject: [PATCH 1/2] chore: bump prettier from 2.1.1 to 2.2.1 --- package.json | 2 +- .../src/rules/indent-new-do-not-use/index.ts | 12 +++---- .../rules/naming-convention-utils/format.ts | 7 ++-- packages/eslint-plugin/src/rules/semi.ts | 4 +-- packages/eslint-plugin/src/util/index.ts | 4 +-- .../tests/rules/naming-convention.test.ts | 7 ++-- .../experimental-utils/src/ts-eslint/Rule.ts | 34 ++++++------------- yarn.lock | 10 +++--- 8 files changed, 31 insertions(+), 49 deletions(-) diff --git a/package.json b/package.json index 98af4e2b5b41..6f79930b0a91 100644 --- a/package.json +++ b/package.json @@ -101,7 +101,7 @@ "lint-staged": "^10.2.13", "make-dir": "^3.1.0", "markdownlint-cli": "^0.23.2", - "prettier": "^2.1.1", + "prettier": "^2.2.1", "rimraf": "^3.0.2", "ts-jest": "^26.3.0", "ts-node": "^9.0.0", 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 05c35c7a295a..7b6bf6d35b99 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 @@ -1570,9 +1570,9 @@ export default createRule({ * 2. Don't set any offsets against the first token of the node. * 3. Call `ignoreNode` on the node sometime after exiting it and before validating offsets. */ - const offsetListeners = Object.keys(baseOffsetListeners).reduce< - TSESLint.RuleListener - >( + const offsetListeners = Object.keys( + baseOffsetListeners, + ).reduce( /* * Offset listener calls are deferred until traversal is finished, and are called as * part of the final `Program:exit` listener. This is necessary because a node might @@ -1590,9 +1590,9 @@ export default createRule({ * ignored nodes are known. */ (acc, key) => { - const listener = baseOffsetListeners[key] as TSESLint.RuleFunction< - TSESTree.Node - >; + const listener = baseOffsetListeners[ + key + ] as TSESLint.RuleFunction; // eslint-disable-next-line @typescript-eslint/explicit-function-return-type acc[key] = node => listenerCallQueue.push({ listener, node }); diff --git a/packages/eslint-plugin/src/rules/naming-convention-utils/format.ts b/packages/eslint-plugin/src/rules/naming-convention-utils/format.ts index 2640aee6ecd4..26e96993f5aa 100644 --- a/packages/eslint-plugin/src/rules/naming-convention-utils/format.ts +++ b/packages/eslint-plugin/src/rules/naming-convention-utils/format.ts @@ -96,10 +96,9 @@ function validateUnderscores(name: string): boolean { return !wasUnderscore; } -const PredefinedFormatToCheckFunction: Readonly boolean ->> = { +const PredefinedFormatToCheckFunction: Readonly< + Record boolean> +> = { [PredefinedFormats.PascalCase]: isPascalCase, [PredefinedFormats.StrictPascalCase]: isStrictPascalCase, [PredefinedFormats.camelCase]: isCamelCase, diff --git a/packages/eslint-plugin/src/rules/semi.ts b/packages/eslint-plugin/src/rules/semi.ts index e73fd4b51dec..9c18d0e36712 100644 --- a/packages/eslint-plugin/src/rules/semi.ts +++ b/packages/eslint-plugin/src/rules/semi.ts @@ -36,9 +36,7 @@ export default util.createRule({ ], create(context) { const rules = baseRule.create(context); - const checkForSemicolon = rules.ExpressionStatement as TSESLint.RuleFunction< - TSESTree.Node - >; + const checkForSemicolon = rules.ExpressionStatement as TSESLint.RuleFunction; /* The following nodes are handled by the member-delimiter-style rule diff --git a/packages/eslint-plugin/src/util/index.ts b/packages/eslint-plugin/src/util/index.ts index 86e0ec233fd4..810398a093f0 100644 --- a/packages/eslint-plugin/src/util/index.ts +++ b/packages/eslint-plugin/src/util/index.ts @@ -18,9 +18,9 @@ const { isObjectNotArray, getParserServices, } = ESLintUtils; -type InferMessageIdsTypeFromRule = ESLintUtils.InferMessageIdsTypeFromRule< +type InferMessageIdsTypeFromRule< T ->; +> = ESLintUtils.InferMessageIdsTypeFromRule; type InferOptionsTypeFromRule = ESLintUtils.InferOptionsTypeFromRule; export { diff --git a/packages/eslint-plugin/tests/rules/naming-convention.test.ts b/packages/eslint-plugin/tests/rules/naming-convention.test.ts index 93173074ae94..ab5cfdd749e1 100644 --- a/packages/eslint-plugin/tests/rules/naming-convention.test.ts +++ b/packages/eslint-plugin/tests/rules/naming-convention.test.ts @@ -18,10 +18,9 @@ const parserOptions = { project: './tsconfig.json', }; -const formatTestNames: Readonly ->> = { +const formatTestNames: Readonly< + Record> +> = { camelCase: { valid: ['strictCamelCase', 'lower', 'camelCaseUNSTRICT'], invalid: ['snake_case', 'UPPER_CASE', 'UPPER', 'StrictPascalCase'], diff --git a/packages/experimental-utils/src/ts-eslint/Rule.ts b/packages/experimental-utils/src/ts-eslint/Rule.ts index 8ced374dd700..d74af833121e 100644 --- a/packages/experimental-utils/src/ts-eslint/Rule.ts +++ b/packages/experimental-utils/src/ts-eslint/Rule.ts @@ -115,9 +115,9 @@ interface RuleFixer { type ReportFixFunction = ( fixer: RuleFixer, ) => null | RuleFix | RuleFix[] | IterableIterator; -type ReportSuggestionArray = ReportDescriptorBase< - TMessageIds ->[]; +type ReportSuggestionArray< + TMessageIds extends string +> = ReportDescriptorBase[]; interface ReportDescriptorBase { /** @@ -328,29 +328,21 @@ interface RuleListener { TryStatement?: RuleFunction; TSAbstractClassProperty?: RuleFunction; TSAbstractKeyword?: RuleFunction; - TSAbstractMethodDefinition?: RuleFunction< - TSESTree.TSAbstractMethodDefinition - >; + TSAbstractMethodDefinition?: RuleFunction; TSAnyKeyword?: RuleFunction; TSArrayType?: RuleFunction; TSAsExpression?: RuleFunction; TSAsyncKeyword?: RuleFunction; TSBigIntKeyword?: RuleFunction; TSBooleanKeyword?: RuleFunction; - TSCallSignatureDeclaration?: RuleFunction< - TSESTree.TSCallSignatureDeclaration - >; + TSCallSignatureDeclaration?: RuleFunction; TSClassImplements?: RuleFunction; TSConditionalType?: RuleFunction; TSConstructorType?: RuleFunction; - TSConstructSignatureDeclaration?: RuleFunction< - TSESTree.TSConstructSignatureDeclaration - >; + TSConstructSignatureDeclaration?: RuleFunction; TSDeclareKeyword?: RuleFunction; TSDeclareFunction?: RuleFunction; - TSEmptyBodyFunctionExpression?: RuleFunction< - TSESTree.TSEmptyBodyFunctionExpression - >; + TSEmptyBodyFunctionExpression?: RuleFunction; TSEnumDeclaration?: RuleFunction; TSEnumMember?: RuleFunction; TSExportAssignment?: RuleFunction; @@ -371,9 +363,7 @@ interface RuleListener { TSMethodSignature?: RuleFunction; TSModuleBlock?: RuleFunction; TSModuleDeclaration?: RuleFunction; - TSNamespaceExportDeclaration?: RuleFunction< - TSESTree.TSNamespaceExportDeclaration - >; + TSNamespaceExportDeclaration?: RuleFunction; TSNeverKeyword?: RuleFunction; TSNonNullExpression?: RuleFunction; TSNullKeyword?: RuleFunction; @@ -400,12 +390,8 @@ interface RuleListener { TSTypeLiteral?: RuleFunction; TSTypeOperator?: RuleFunction; TSTypeParameter?: RuleFunction; - TSTypeParameterDeclaration?: RuleFunction< - TSESTree.TSTypeParameterDeclaration - >; - TSTypeParameterInstantiation?: RuleFunction< - TSESTree.TSTypeParameterInstantiation - >; + TSTypeParameterDeclaration?: RuleFunction; + TSTypeParameterInstantiation?: RuleFunction; TSTypePredicate?: RuleFunction; TSTypeQuery?: RuleFunction; TSTypeReference?: RuleFunction; diff --git a/yarn.lock b/yarn.lock index d657b1aba7f8..c4bfcfe6a01f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2816,7 +2816,7 @@ commander@^2.12.1: resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== -commander@^6.0.0, commander@^6.2.0: +commander@^6.2.0: version "6.2.1" resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.1.tgz#0792eb682dfbc325999bb2b84fddddba110ac73c" integrity sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA== @@ -7157,10 +7157,10 @@ prelude-ls@~1.1.2: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ= -prettier@*, prettier@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.1.1.tgz#d9485dd5e499daa6cb547023b87a6cf51bee37d6" - integrity sha512-9bY+5ZWCfqj3ghYBLxApy2zf6m+NJo5GzmLTpr9FsApsfjriNnS2dahWReHMi7qNPhhHl9SYHJs2cHZLgexNIw== +prettier@*, prettier@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.2.1.tgz#795a1a78dd52f073da0cd42b21f9c91381923ff5" + integrity sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q== pretty-format@^25.2.1, pretty-format@^25.5.0: version "25.5.0" From 6d40785d720c2b3fbed8a429f6cef3bc0bae5561 Mon Sep 17 00:00:00 2001 From: Armano Date: Thu, 11 Feb 2021 07:34:58 +0100 Subject: [PATCH 2/2] test(eslint-plugin): disable formatting some of tests --- .../eslint-plugin/tests/rules/naming-convention.test.ts | 9 +++------ .../eslint-plugin/tests/rules/no-empty-function.test.ts | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/eslint-plugin/tests/rules/naming-convention.test.ts b/packages/eslint-plugin/tests/rules/naming-convention.test.ts index ab5cfdd749e1..f4ed42e3c3e3 100644 --- a/packages/eslint-plugin/tests/rules/naming-convention.test.ts +++ b/packages/eslint-plugin/tests/rules/naming-convention.test.ts @@ -1131,13 +1131,11 @@ ruleTester.run('naming-convention', rule, { { const camelCaseVar = 1; function camelCaseFunction() {} - declare function camelCaseDeclaredFunction() { - }; + declare function camelCaseDeclaredFunction() {}; } const PascalCaseVar = 1; function PascalCaseFunction() {} - declare function PascalCaseDeclaredFunction() { - }; + declare function PascalCaseDeclaredFunction() {}; `, options: [ { selector: 'default', format: ['camelCase'] }, @@ -1990,8 +1988,7 @@ ruleTester.run('naming-convention', rule, { code: ` const PascalCaseVar = 1; function PascalCaseFunction() {} - declare function PascalCaseDeclaredFunction() { - }; + declare function PascalCaseDeclaredFunction() {}; `, options: [ { selector: 'default', format: ['snake_case'] }, diff --git a/packages/eslint-plugin/tests/rules/no-empty-function.test.ts b/packages/eslint-plugin/tests/rules/no-empty-function.test.ts index b840643f01a9..d9f37deaaf1c 100644 --- a/packages/eslint-plugin/tests/rules/no-empty-function.test.ts +++ b/packages/eslint-plugin/tests/rules/no-empty-function.test.ts @@ -1,5 +1,5 @@ import rule from '../../src/rules/no-empty-function'; -import { RuleTester } from '../RuleTester'; +import { noFormat, RuleTester } from '../RuleTester'; const ruleTester = new RuleTester({ parser: '@typescript-eslint/parser', @@ -159,7 +159,7 @@ function foo() {} ], }, { - code: ` + code: noFormat` @decorator() function foo() {} `,