From 1f3c34426cea6d04df2393032e0728ade7390d3c Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Sun, 3 May 2020 22:19:55 -0700 Subject: [PATCH] chore: upgrade to prettier 2.0 (#1970) --- .github/workflows/ci.yml | 3 +- .prettierrc.json | 13 +- package.json | 3 +- .../rules/explicit-function-return-type.md | 12 +- .../rules/explicit-module-boundary-types.md | 16 +-- .../docs/rules/no-explicit-any.md | 4 +- .../docs/rules/no-floating-promises.md | 4 +- .../docs/rules/no-implied-eval.md | 10 +- .../eslint-plugin/docs/rules/no-this-alias.md | 2 +- packages/eslint-plugin/docs/rules/typedef.md | 8 +- packages/eslint-plugin/package.json | 2 - .../src/rules/consistent-type-assertions.ts | 1 - .../rules/explicit-member-accessibility.ts | 2 +- .../no-unnecessary-boolean-literal-compare.ts | 2 +- .../src/rules/no-unnecessary-qualifier.ts | 2 +- .../adjacent-overload-signatures.test.ts | 2 +- .../tests/rules/default-param-last.test.ts | 112 +++++++-------- .../explicit-function-return-type.test.ts | 58 ++++---- .../explicit-module-boundary-types.test.ts | 50 +++---- .../tests/rules/init-declarations.test.ts | 8 +- .../rules/method-signature-style.test.ts | 3 +- .../tests/rules/no-explicit-any.test.ts | 8 +- .../tests/rules/no-floating-promises.test.ts | 12 +- .../tests/rules/no-implied-eval.test.ts | 16 +-- .../tests/rules/no-inferrable-types.test.ts | 6 +- .../tests/rules/no-invalid-this.test.ts | 134 +++++++++--------- .../tests/rules/no-unused-vars.test.ts | 2 +- .../tests/rules/no-use-before-define.test.ts | 10 +- .../tests/rules/prefer-readonly.test.ts | 2 +- .../rules/promise-function-async.test.ts | 16 +-- .../tests/rules/require-await.test.ts | 24 ++-- .../eslint-plugin/tests/rules/typedef.test.ts | 10 +- .../tests/rules/unbound-method.test.ts | 2 +- .../tests/rules/unified-signatures.test.ts | 16 +-- packages/parser/src/analyze-scope.ts | 2 +- yarn.lock | 16 +-- 36 files changed, 301 insertions(+), 292 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3e2d0e9dd51..62502349d9f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -167,7 +167,8 @@ jobs: yarn check-clean-workspace-after-install - name: Run unit tests - run: yarn test + # the internal plugin is only run locally, so it doesn't have to support older versions + run: yarn test --ignore @typescript-eslint/eslint-plugin-internal env: CI: true diff --git a/.prettierrc.json b/.prettierrc.json index a20502b7f06..2fdcda48cf4 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,4 +1,15 @@ { + "arrowParens": "avoid", + "bracketSpacing": true, + "endOfLine": "lf", + "jsxBracketSameLine": false, + "jsxSingleQuote": false, + "printWidth": 80, + "proseWrap": "preserve", + "quoteProps": "as-needed", + "semi": true, "singleQuote": true, - "trailingComma": "all" + "tabWidth": 2, + "trailingComma": "all", + "useTabs": false } diff --git a/package.json b/package.json index d0ecaef0fa5..9f87c2c1d48 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,7 @@ "@commitlint/config-lerna-scopes": "^8.3.4", "@types/jest": "^25.1.0", "@types/node": "^12.12.7", + "@types/prettier": "^2.0.0", "all-contributors-cli": "^6.11.0", "cspell": "^4.0.43", "cz-conventional-changelog": "^3.0.2", @@ -73,7 +74,7 @@ "lerna": "^3.20.2", "lint-staged": "^9.4.3", "markdownlint-cli": "^0.22.0", - "prettier": "^1.19.1", + "prettier": "^2.0.5", "ts-jest": "^25.0.0", "ts-node": "^8.5.0", "tslint": "^6.1.0", diff --git a/packages/eslint-plugin/docs/rules/explicit-function-return-type.md b/packages/eslint-plugin/docs/rules/explicit-function-return-type.md index a0e4ebce5ea..5e60f29eac2 100644 --- a/packages/eslint-plugin/docs/rules/explicit-function-return-type.md +++ b/packages/eslint-plugin/docs/rules/explicit-function-return-type.md @@ -18,7 +18,7 @@ function test() { } // Should indicate that a number is returned -var fn = function() { +var fn = function () { return 1; }; @@ -42,7 +42,7 @@ function test(): void { } // A return value of type number -var fn = function(): number { +var fn = function (): number { return 1; }; @@ -119,7 +119,7 @@ Examples of **correct** code for this rule with `{ allowExpressions: true }`: ```ts node.addEventListener('click', () => {}); -node.addEventListener('click', function() {}); +node.addEventListener('click', function () {}); const foo = arr.map(i => i * i); ``` @@ -131,7 +131,7 @@ Examples of **incorrect** code for this rule with `{ allowTypedFunctionExpressio ```ts let arrowFn = () => 'test'; -let funcExpr = function() { +let funcExpr = function () { return 'test'; }; @@ -186,7 +186,7 @@ Examples of **incorrect** code for this rule with `{ allowHigherOrderFunctions: var arrowFn = () => () => {}; function fn() { - return function() {}; + return function () {}; } ``` @@ -196,7 +196,7 @@ Examples of **correct** code for this rule with `{ allowHigherOrderFunctions: tr var arrowFn = () => (): void => {}; function fn() { - return function(): void {}; + return function (): void {}; } ``` diff --git a/packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md b/packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md index 3c077a75c88..5a33f9e9a35 100644 --- a/packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md +++ b/packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md @@ -17,7 +17,7 @@ export function test() { } // Should indicate that a number is returned -export default function() { +export default function () { return 1; } @@ -44,7 +44,7 @@ function test() { } // A return value of type number -export var fn = function(): number { +export var fn = function (): number { return 1; }; @@ -129,7 +129,7 @@ Examples of **incorrect** code for this rule with `{ allowTypedFunctionExpressio ```ts export let arrowFn = () => 'test'; -export let funcExpr = function() { +export let funcExpr = function () { return 'test'; }; @@ -147,7 +147,7 @@ type FuncType = () => string; export let arrowFn: FuncType = () => 'test'; -export let funcExpr: FuncType = function() { +export let funcExpr: FuncType = function () { return 'test'; }; @@ -179,11 +179,11 @@ Examples of **incorrect** code for this rule with `{ allowHigherOrderFunctions: export var arrowFn = () => () => {}; export function fn() { - return function() {}; + return function () {}; } export function foo(outer) { - return function(inner): void {}; + return function (inner): void {}; } ``` @@ -193,11 +193,11 @@ Examples of **correct** code for this rule with `{ allowHigherOrderFunctions: tr export var arrowFn = () => (): void => {}; export function fn() { - return function(): void {}; + return function (): void {}; } export function foo(outer: string) { - return function(inner: string): void {}; + return function (inner: string): void {}; } ``` diff --git a/packages/eslint-plugin/docs/rules/no-explicit-any.md b/packages/eslint-plugin/docs/rules/no-explicit-any.md index c440d3bdc60..7aeb465874e 100644 --- a/packages/eslint-plugin/docs/rules/no-explicit-any.md +++ b/packages/eslint-plugin/docs/rules/no-explicit-any.md @@ -122,7 +122,7 @@ function foo4(...args: ReadonlyArray): void {} declare function bar(...args: any[]): void; const baz = (...args: any[]) => {}; -const qux = function(...args: any[]) {}; +const qux = function (...args: any[]) {}; type Quux = (...args: any[]) => void; type Quuz = new (...args: any[]) => void; @@ -151,7 +151,7 @@ function foo4(...args: ReadonlyArray): void {} declare function bar(...args: any[]): void; const baz = (...args: any[]) => {}; -const qux = function(...args: any[]) {}; +const qux = function (...args: any[]) {}; type Quux = (...args: any[]) => void; type Quuz = new (...args: any[]) => void; diff --git a/packages/eslint-plugin/docs/rules/no-floating-promises.md b/packages/eslint-plugin/docs/rules/no-floating-promises.md index 4ea2e6addc9..9ed1f23455a 100644 --- a/packages/eslint-plugin/docs/rules/no-floating-promises.md +++ b/packages/eslint-plugin/docs/rules/no-floating-promises.md @@ -83,11 +83,11 @@ This allows you to skip checking of async iife Examples of **correct** code for this rule with `{ ignoreIIFE: true }`: ```ts -await(async function() { +await(async function () { await res(1); })(); -(async function() { +(async function () { await res(1); })(); ``` diff --git a/packages/eslint-plugin/docs/rules/no-implied-eval.md b/packages/eslint-plugin/docs/rules/no-implied-eval.md index a16844a6d43..3753adf26d7 100644 --- a/packages/eslint-plugin/docs/rules/no-implied-eval.md +++ b/packages/eslint-plugin/docs/rules/no-implied-eval.md @@ -56,19 +56,19 @@ Examples of **correct** code for this rule: ```ts /* eslint @typescript-eslint/no-implied-eval: "error" */ -setTimeout(function() { +setTimeout(function () { alert('Hi!'); }, 100); -setInterval(function() { +setInterval(function () { alert('Hi!'); }, 100); -setImmediate(function() { +setImmediate(function () { alert('Hi!'); }); -execScript(function() { +execScript(function () { alert('Hi!'); }); @@ -76,7 +76,7 @@ const fn = () => {}; setTimeout(fn, 100); const foo = { - fn: function() {}, + fn: function () {}, }; setTimeout(foo.fn, 100); setTimeout(foo.fn.bind(this), 100); diff --git a/packages/eslint-plugin/docs/rules/no-this-alias.md b/packages/eslint-plugin/docs/rules/no-this-alias.md index b5d2afb542c..324929e52c2 100644 --- a/packages/eslint-plugin/docs/rules/no-this-alias.md +++ b/packages/eslint-plugin/docs/rules/no-this-alias.md @@ -14,7 +14,7 @@ Rationale from TSLint: > ```js > const self = this; > -> setTimeout(function() { +> setTimeout(function () { > self.doWork(); > }); > ``` diff --git a/packages/eslint-plugin/docs/rules/typedef.md b/packages/eslint-plugin/docs/rules/typedef.md index 07f4bb1eb3a..594f7b65e7d 100644 --- a/packages/eslint-plugin/docs/rules/typedef.md +++ b/packages/eslint-plugin/docs/rules/typedef.md @@ -164,7 +164,7 @@ function logsSize(size): void { console.log(size); } -const doublesSize = function(size): number { +const doublesSize = function (size): number { return size * 2; }; @@ -172,7 +172,7 @@ const divider = { curriesSize(size): number { return size; }, - dividesSize: function(size): number { + dividesSize: function (size): number { return size / 2; }, }; @@ -192,7 +192,7 @@ function logsSize(size: number): void { console.log(size); } -const doublesSize = function(size: number): number { +const doublesSize = function (size: number): number { return size * 2; }; @@ -200,7 +200,7 @@ const divider = { curriesSize(size: number): number { return size; }, - dividesSize: function(size: number): number { + dividesSize: function (size: number): number { return size / 2; }, }; diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index 6c359a6dd97..18f4a5dc8c5 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -47,9 +47,7 @@ "tsutils": "^3.17.1" }, "devDependencies": { - "@types/json-schema": "^7.0.3", "@types/marked": "^0.7.1", - "@types/prettier": "^1.18.2", "chalk": "^3.0.0", "marked": "^0.7.0", "prettier": "*", diff --git a/packages/eslint-plugin/src/rules/consistent-type-assertions.ts b/packages/eslint-plugin/src/rules/consistent-type-assertions.ts index 0620822f83c..2457bdb08a9 100644 --- a/packages/eslint-plugin/src/rules/consistent-type-assertions.ts +++ b/packages/eslint-plugin/src/rules/consistent-type-assertions.ts @@ -10,7 +10,6 @@ type MessageIds = | 'angle-bracket' | 'never' | 'unexpectedObjectTypeAssertion'; -// https://github.com/prettier/prettier/issues/4794 type OptUnion = | { assertionStyle: 'as' | 'angle-bracket'; diff --git a/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts b/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts index 7c49f0d6a31..23ac95814c0 100644 --- a/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts +++ b/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts @@ -166,7 +166,7 @@ export default util.createRule({ | TSESTree.ClassProperty | TSESTree.TSParameterProperty, ): TSESLint.ReportFixFunction { - return function(fixer: TSESLint.RuleFixer): TSESLint.RuleFix { + return function (fixer: TSESLint.RuleFixer): TSESLint.RuleFix { const tokens = sourceCode.getTokens(node); let rangeToRemove: TSESLint.AST.Range; for (let i = 0; i < tokens.length; i++) { 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 1cd03962ae4..ffcdd0e0732 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 @@ -106,7 +106,7 @@ export default util.createRule<[], MessageIds>({ if (comparison) { context.report({ - fix: function*(fixer) { + fix: function* (fixer) { yield fixer.removeRange(comparison.range); if (!comparison.forTruthy) { diff --git a/packages/eslint-plugin/src/rules/no-unnecessary-qualifier.ts b/packages/eslint-plugin/src/rules/no-unnecessary-qualifier.ts index a34533d2fc2..395bbfdc4f3 100644 --- a/packages/eslint-plugin/src/rules/no-unnecessary-qualifier.ts +++ b/packages/eslint-plugin/src/rules/no-unnecessary-qualifier.ts @@ -179,7 +179,7 @@ export default util.createRule({ TSQualifiedName(node: TSESTree.TSQualifiedName): void { visitNamespaceAccess(node, node.left, node.right); }, - 'MemberExpression[computed=false]': function( + 'MemberExpression[computed=false]': function ( node: TSESTree.MemberExpression, ): void { const property = node.property as TSESTree.Identifier; 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 8e844bb96be..55fea63fb11 100644 --- a/packages/eslint-plugin/tests/rules/adjacent-overload-signatures.test.ts +++ b/packages/eslint-plugin/tests/rules/adjacent-overload-signatures.test.ts @@ -221,7 +221,7 @@ class Test { } `, // examples from https://github.com/nzakas/eslint-plugin-typescript/issues/138 - 'export default function(foo: T) {}', + 'export default function (foo: T) {}', 'export default function named(foo: T) {}', ` interface Foo { diff --git a/packages/eslint-plugin/tests/rules/default-param-last.test.ts b/packages/eslint-plugin/tests/rules/default-param-last.test.ts index 76e23bbe8a7..aa0ffbc8743 100644 --- a/packages/eslint-plugin/tests/rules/default-param-last.test.ts +++ b/packages/eslint-plugin/tests/rules/default-param-last.test.ts @@ -19,17 +19,17 @@ ruleTester.run('default-param-last', rule, { 'function foo(a: number, b?: number, c = 1) {}', 'function foo(a: number, b = 1, ...c) {}', - 'const foo = function() {};', - 'const foo = function(a: number) {};', - 'const foo = function(a = 1) {};', - 'const foo = function(a?: number) {};', - 'const foo = function(a: number, b: number) {};', - 'const foo = function(a: number, b: number, c?: number) {};', - 'const foo = function(a: number, b = 1) {};', - 'const foo = function(a: number, b = 1, c = 1) {};', - 'const foo = function(a: number, b = 1, c?: number) {};', - 'const foo = function(a: number, b?: number, c = 1) {};', - 'const foo = function(a: number, b = 1, ...c) {};', + 'const foo = function () {};', + 'const foo = function (a: number) {};', + 'const foo = function (a = 1) {};', + 'const foo = function (a?: number) {};', + 'const foo = function (a: number, b: number) {};', + 'const foo = function (a: number, b: number, c?: number) {};', + 'const foo = function (a: number, b = 1) {};', + 'const foo = function (a: number, b = 1, c = 1) {};', + 'const foo = function (a: number, b = 1, c?: number) {};', + 'const foo = function (a: number, b?: number, c = 1) {};', + 'const foo = function (a: number, b = 1, ...c) {};', 'const foo = () => {};', 'const foo = (a: number) => {};', @@ -251,163 +251,163 @@ class Foo { ], }, { - code: 'const foo = function(a = 1, b: number) {};', + code: 'const foo = function (a = 1, b: number) {};', errors: [ { messageId: 'shouldBeLast', line: 1, - column: 22, - endColumn: 27, + column: 23, + endColumn: 28, }, ], }, { - code: 'const foo = function(a = 1, b = 2, c: number) {};', + code: 'const foo = function (a = 1, b = 2, c: number) {};', errors: [ { messageId: 'shouldBeLast', line: 1, - column: 22, - endColumn: 27, + column: 23, + endColumn: 28, }, { messageId: 'shouldBeLast', line: 1, - column: 29, - endColumn: 34, + column: 30, + endColumn: 35, }, ], }, { - code: 'const foo = function(a = 1, b: number, c = 2, d: number) {};', + code: 'const foo = function (a = 1, b: number, c = 2, d: number) {};', errors: [ { messageId: 'shouldBeLast', line: 1, - column: 22, - endColumn: 27, + column: 23, + endColumn: 28, }, { messageId: 'shouldBeLast', line: 1, - column: 40, - endColumn: 45, + column: 41, + endColumn: 46, }, ], }, { - code: 'const foo = function(a = 1, b: number, c = 2) {};', + code: 'const foo = function (a = 1, b: number, c = 2) {};', errors: [ { messageId: 'shouldBeLast', line: 1, - column: 22, - endColumn: 27, + column: 23, + endColumn: 28, }, ], }, { - code: 'const foo = function(a = 1, b: number, ...c) {};', + code: 'const foo = function (a = 1, b: number, ...c) {};', errors: [ { messageId: 'shouldBeLast', line: 1, - column: 22, - endColumn: 27, + column: 23, + endColumn: 28, }, ], }, { - code: 'const foo = function(a?: number, b: number) {};', + code: 'const foo = function (a?: number, b: number) {};', errors: [ { messageId: 'shouldBeLast', line: 1, - column: 22, - endColumn: 32, + column: 23, + endColumn: 33, }, ], }, { - code: 'const foo = function(a: number, b?: number, c: number) {};', + code: 'const foo = function (a: number, b?: number, c: number) {};', errors: [ { messageId: 'shouldBeLast', line: 1, - column: 33, - endColumn: 43, + column: 34, + endColumn: 44, }, ], }, { - code: 'const foo = function(a = 1, b?: number, c: number) {};', + code: 'const foo = function (a = 1, b?: number, c: number) {};', errors: [ { messageId: 'shouldBeLast', line: 1, - column: 22, - endColumn: 27, + column: 23, + endColumn: 28, }, { messageId: 'shouldBeLast', line: 1, - column: 29, - endColumn: 39, + column: 30, + endColumn: 40, }, ], }, { - code: 'const foo = function(a = 1, { b }) {};', + code: 'const foo = function (a = 1, { b }) {};', errors: [ { messageId: 'shouldBeLast', line: 1, - column: 22, - endColumn: 27, + column: 23, + endColumn: 28, }, ], }, { - code: 'const foo = function({ a } = {}, b) {};', + code: 'const foo = function ({ a } = {}, b) {};', errors: [ { messageId: 'shouldBeLast', line: 1, - column: 22, - endColumn: 32, + column: 23, + endColumn: 33, }, ], }, { - code: 'const foo = function({ a, b } = { a: 1, b: 2 }, c) {};', + code: 'const foo = function ({ a, b } = { a: 1, b: 2 }, c) {};', errors: [ { messageId: 'shouldBeLast', line: 1, - column: 22, - endColumn: 47, + column: 23, + endColumn: 48, }, ], }, { - code: 'const foo = function([a] = [], b) {};', + code: 'const foo = function ([a] = [], b) {};', errors: [ { messageId: 'shouldBeLast', line: 1, - column: 22, - endColumn: 30, + column: 23, + endColumn: 31, }, ], }, { - code: 'const foo = function([a, b] = [1, 2], c) {};', + code: 'const foo = function ([a, b] = [1, 2], c) {};', errors: [ { messageId: 'shouldBeLast', line: 1, - column: 22, - endColumn: 37, + column: 23, + endColumn: 38, }, ], }, diff --git a/packages/eslint-plugin/tests/rules/explicit-function-return-type.test.ts b/packages/eslint-plugin/tests/rules/explicit-function-return-type.test.ts index dd3e3815676..6ce8210822b 100644 --- a/packages/eslint-plugin/tests/rules/explicit-function-return-type.test.ts +++ b/packages/eslint-plugin/tests/rules/explicit-function-return-type.test.ts @@ -18,7 +18,7 @@ function test(): void { { filename: 'test.ts', code: ` -var fn = function(): number { +var fn = function (): number { return 1; }; `, @@ -56,7 +56,7 @@ class Test { }, { filename: 'test.ts', - code: 'fn(function() {});', + code: 'fn(function () {});', options: [ { allowExpressions: true, @@ -65,7 +65,7 @@ class Test { }, { filename: 'test.ts', - code: '[function() {}, () => {}];', + code: '[function () {}, () => {}];', options: [ { allowExpressions: true, @@ -74,7 +74,7 @@ class Test { }, { filename: 'test.ts', - code: '(function() {});', + code: '(function () {});', options: [ { allowExpressions: true, @@ -113,7 +113,7 @@ var arrowFn: Foo = () => 'test'; { filename: 'test.ts', code: ` -var funcExpr: Foo = function() { +var funcExpr: Foo = function () { return 'test'; }; `, @@ -193,7 +193,7 @@ const myObj = { { filename: 'test.ts', code: ` -() => function(): void {}; +() => function (): void {}; `, options: [{ allowHigherOrderFunctions: true }], }, @@ -210,7 +210,7 @@ const myObj = { filename: 'test.ts', code: ` () => { - return function(): void {}; + return function (): void {}; }; `, options: [{ allowHigherOrderFunctions: true }], @@ -228,7 +228,7 @@ function fn() { filename: 'test.ts', code: ` function fn() { - return function(): void {}; + return function (): void {}; } `, options: [{ allowHigherOrderFunctions: true }], @@ -324,7 +324,7 @@ foo({ }, }); foo({ - meth: function() { + meth: function () { return 1; }, }); @@ -410,7 +410,7 @@ function test() { { filename: 'test.ts', code: ` -var fn = function() { +var fn = function () { return 1; }; `, @@ -420,7 +420,7 @@ var fn = function() { line: 2, endLine: 2, column: 10, - endColumn: 20, + endColumn: 21, }, ], }, @@ -522,7 +522,7 @@ function test() { }, { filename: 'test.ts', - code: 'const foo = function() {};', + code: 'const foo = function () {};', options: [{ allowExpressions: true }], errors: [ { @@ -530,7 +530,7 @@ function test() { line: 1, endLine: 1, column: 13, - endColumn: 23, + endColumn: 24, }, ], }, @@ -550,7 +550,7 @@ function test() { }, { filename: 'test.ts', - code: 'export default function() {}', + code: 'export default function () {}', options: [{ allowExpressions: true }], errors: [ { @@ -558,7 +558,7 @@ function test() { line: 1, endLine: 1, column: 16, - endColumn: 26, + endColumn: 27, }, ], }, @@ -567,11 +567,11 @@ function test() { code: ` class Foo { public a = () => {}; - public b = function() {}; + public b = function () {}; public c = function test() {}; static d = () => {}; - static e = function() {}; + static e = function () {}; } `, options: [{ allowExpressions: true }], @@ -588,7 +588,7 @@ class Foo { line: 4, endLine: 4, column: 14, - endColumn: 24, + endColumn: 25, }, { messageId: 'missingReturnType', @@ -609,7 +609,7 @@ class Foo { line: 8, endLine: 8, column: 14, - endColumn: 24, + endColumn: 25, }, ], }, @@ -630,7 +630,7 @@ class Foo { { filename: 'test.ts', code: ` -var funcExpr = function() { +var funcExpr = function () { return 'test'; }; `, @@ -641,7 +641,7 @@ var funcExpr = function() { line: 2, endLine: 2, column: 16, - endColumn: 26, + endColumn: 27, }, ], }, @@ -714,7 +714,7 @@ const x: Foo = { }, { filename: 'test.ts', - code: '() => function() {};', + code: '() => function () {};', options: [{ allowHigherOrderFunctions: true }], errors: [ { @@ -722,7 +722,7 @@ const x: Foo = { line: 1, endLine: 1, column: 7, - endColumn: 17, + endColumn: 18, }, ], }, @@ -748,7 +748,7 @@ const x: Foo = { filename: 'test.ts', code: ` () => { - return function() {}; + return function () {}; }; `, options: [{ allowHigherOrderFunctions: true }], @@ -758,7 +758,7 @@ const x: Foo = { line: 3, endLine: 3, column: 10, - endColumn: 20, + endColumn: 21, }, ], }, @@ -784,7 +784,7 @@ function fn() { filename: 'test.ts', code: ` function fn() { - return function() {}; + return function () {}; } `, options: [{ allowHigherOrderFunctions: true }], @@ -794,7 +794,7 @@ function fn() { line: 3, endLine: 3, column: 10, - endColumn: 20, + endColumn: 21, }, ], }, @@ -955,7 +955,7 @@ foo({ }, }); foo({ - meth: function() { + meth: function () { return 1; }, }); @@ -983,7 +983,7 @@ foo({ line: 9, endLine: 9, column: 9, - endColumn: 19, + endColumn: 20, }, { messageId: 'missingReturnType', diff --git a/packages/eslint-plugin/tests/rules/explicit-module-boundary-types.test.ts b/packages/eslint-plugin/tests/rules/explicit-module-boundary-types.test.ts index 5d63e8e1036..4d20b7b9a3f 100644 --- a/packages/eslint-plugin/tests/rules/explicit-module-boundary-types.test.ts +++ b/packages/eslint-plugin/tests/rules/explicit-module-boundary-types.test.ts @@ -23,7 +23,7 @@ export function test(): void { }, { code: ` -export var fn = function(): number { +export var fn = function (): number { return 1; }; `, @@ -105,7 +105,7 @@ export var arrowFn: Foo = () => 'test'; }, { code: ` -export var funcExpr: Foo = function() { +export var funcExpr: Foo = function () { return 'test'; }; `, @@ -176,7 +176,7 @@ export default () => (): void => {}; }, { code: ` -export default () => function(): void {}; +export default () => function (): void {}; `, options: [{ allowHigherOrderFunctions: true }], }, @@ -191,7 +191,7 @@ export default () => { { code: ` export default () => { - return function(): void {}; + return function (): void {}; }; `, options: [{ allowHigherOrderFunctions: true }], @@ -207,7 +207,7 @@ export function fn() { { code: ` export function fn() { - return function(): void {}; + return function (): void {}; } `, options: [{ allowHigherOrderFunctions: true }], @@ -304,7 +304,7 @@ export class Test { { code: ` export function foo(outer: string) { - return function(inner: string): void {}; + return function (inner: string): void {}; } `, options: [ @@ -331,7 +331,7 @@ export class Test { { code: ` export const Foo: FC = () => ( -
{}} b={function(e) {}} c={function foo(e) {}}>
+
{}} b={function (e) {}} c={function foo(e) {}}>
); `, parserOptions: { @@ -341,7 +341,7 @@ export const Foo: FC = () => ( { code: ` export const Foo: JSX.Element = ( -
{}} b={function(e) {}} c={function foo(e) {}}>
+
{}} b={function (e) {}} c={function foo(e) {}}>
); `, parserOptions: { @@ -473,7 +473,7 @@ export function test() { }, { code: ` -export var fn = function() { +export var fn = function () { return 1; }; `, @@ -483,7 +483,7 @@ export var fn = function() { line: 2, endLine: 2, column: 17, - endColumn: 27, + endColumn: 28, }, ], }, @@ -560,11 +560,11 @@ export class Test { code: ` export class Foo { public a = () => {}; - public b = function() {}; + public b = function () {}; public c = function test() {}; static d = () => {}; - static e = function() {}; + static e = function () {}; } `, errors: [ @@ -580,7 +580,7 @@ export class Foo { line: 4, endLine: 4, column: 14, - endColumn: 24, + endColumn: 25, }, { messageId: 'missingReturnType', @@ -601,7 +601,7 @@ export class Foo { line: 8, endLine: 8, column: 14, - endColumn: 24, + endColumn: 25, }, ], }, @@ -639,7 +639,7 @@ export class Foo { }, { code: ` -export var funcExpr = function() { +export var funcExpr = function () { return 'test'; }; `, @@ -650,7 +650,7 @@ export var funcExpr = function() { line: 2, endLine: 2, column: 23, - endColumn: 33, + endColumn: 34, }, ], }, @@ -717,7 +717,7 @@ export const x: Foo = { ], }, { - code: 'export default () => function() {};', + code: 'export default () => function () {};', options: [{ allowHigherOrderFunctions: true }], errors: [ { @@ -725,7 +725,7 @@ export const x: Foo = { line: 1, endLine: 1, column: 22, - endColumn: 32, + endColumn: 33, }, ], }, @@ -749,7 +749,7 @@ export default () => { { code: ` export default () => { - return function() {}; + return function () {}; }; `, options: [{ allowHigherOrderFunctions: true }], @@ -759,7 +759,7 @@ export default () => { line: 3, endLine: 3, column: 10, - endColumn: 20, + endColumn: 21, }, ], }, @@ -783,7 +783,7 @@ export function fn() { { code: ` export function fn() { - return function() {}; + return function () {}; } `, options: [{ allowHigherOrderFunctions: true }], @@ -793,7 +793,7 @@ export function fn() { line: 3, endLine: 3, column: 10, - endColumn: 20, + endColumn: 21, }, ], }, @@ -985,7 +985,7 @@ export function fn(test): string { { code: ` export function foo(outer) { - return function(inner) {}; + return function (inner) {}; } `, options: [{ allowHigherOrderFunctions: true }], @@ -1221,7 +1221,7 @@ export default Foo; { code: ` class Foo { - bool = function(arg) { + bool = function (arg) { return arg; }; } @@ -1242,7 +1242,7 @@ export default Foo; { code: ` class Foo { - bool = function(arg) { + bool = function (arg) { return arg; }; } diff --git a/packages/eslint-plugin/tests/rules/init-declarations.test.ts b/packages/eslint-plugin/tests/rules/init-declarations.test.ts index 6f4c8f75ebb..1d5dc73655f 100644 --- a/packages/eslint-plugin/tests/rules/init-declarations.test.ts +++ b/packages/eslint-plugin/tests/rules/init-declarations.test.ts @@ -22,7 +22,7 @@ function foo() { var bar = []; } `, - 'var fn = function() {};', + 'var fn = function () {};', 'var foo = (bar = 2);', 'for (var i = 0; i < 1; i++) {}', ` @@ -245,7 +245,7 @@ function foo() { }, { code: ` -var bar: string = function(): string { +var bar: string = function (): string { return 'string'; }; `, @@ -253,7 +253,7 @@ var bar: string = function(): string { }, { code: ` -var bar: string = function(arg1: stirng): string { +var bar: string = function (arg1: stirng): string { return 'string'; }; `, @@ -645,7 +645,7 @@ function foo() { ], }, { - code: 'let arr: string = function() {};', + code: 'let arr: string = function () {};', options: ['never'], errors: [ { diff --git a/packages/eslint-plugin/tests/rules/method-signature-style.test.ts b/packages/eslint-plugin/tests/rules/method-signature-style.test.ts index 62383014082..3f125b33cdf 100644 --- a/packages/eslint-plugin/tests/rules/method-signature-style.test.ts +++ b/packages/eslint-plugin/tests/rules/method-signature-style.test.ts @@ -27,8 +27,7 @@ interface Test { ['f']: (a: T, b: T) => T; } `, - // TODO - requires prettier2 to format correctly - noFormat` + ` interface Test { 'f!': (/* b */ x: any /* c */) => void; } diff --git a/packages/eslint-plugin/tests/rules/no-explicit-any.test.ts b/packages/eslint-plugin/tests/rules/no-explicit-any.test.ts index 1a5b9c5778c..2694fdbf104 100644 --- a/packages/eslint-plugin/tests/rules/no-explicit-any.test.ts +++ b/packages/eslint-plugin/tests/rules/no-explicit-any.test.ts @@ -147,7 +147,7 @@ type obj = { options: [{ ignoreRestArgs: true }], }, { - code: 'const bar1 = function(...args: any[]) {};', + code: 'const bar1 = function (...args: any[]) {};', options: [{ ignoreRestArgs: true }], }, { @@ -159,7 +159,7 @@ type obj = { options: [{ ignoreRestArgs: true }], }, { - code: 'const bar2 = function(...args: readonly any[]) {};', + code: 'const bar2 = function (...args: readonly any[]) {};', options: [{ ignoreRestArgs: true }], }, { @@ -171,7 +171,7 @@ type obj = { options: [{ ignoreRestArgs: true }], }, { - code: 'const bar3 = function(...args: Array) {};', + code: 'const bar3 = function (...args: Array) {};', options: [{ ignoreRestArgs: true }], }, { @@ -183,7 +183,7 @@ type obj = { options: [{ ignoreRestArgs: true }], }, { - code: 'const bar4 = function(...args: ReadonlyArray) {};', + code: 'const bar4 = function (...args: ReadonlyArray) {};', options: [{ ignoreRestArgs: true }], }, { diff --git a/packages/eslint-plugin/tests/rules/no-floating-promises.test.ts b/packages/eslint-plugin/tests/rules/no-floating-promises.test.ts index f6601a0613a..e5c0ea5210f 100644 --- a/packages/eslint-plugin/tests/rules/no-floating-promises.test.ts +++ b/packages/eslint-plugin/tests/rules/no-floating-promises.test.ts @@ -368,7 +368,7 @@ async function test() { code: ` const foo = () => new Promise(res => { - (async function() { + (async function () { await res(1); })(); }); @@ -377,7 +377,7 @@ async function test() { }, { code: ` - (async function() { + (async function () { await res(1); })(); `, @@ -826,7 +826,7 @@ async function test() { code: ` const foo = () => new Promise(res => { - (async function() { + (async function () { await res(1); })(); }); @@ -840,7 +840,7 @@ async function test() { }, { code: ` - (async function() { + (async function () { await res(1); })(); `, @@ -853,7 +853,7 @@ async function test() { }, { code: ` - (async function() { + (async function () { Promise.resolve(); })(); `, @@ -867,7 +867,7 @@ async function test() { }, { code: ` - (async function() { + (async function () { const promiseIntersection: Promise & number; promiseIntersection; promiseIntersection.then(() => {}); diff --git a/packages/eslint-plugin/tests/rules/no-implied-eval.test.ts b/packages/eslint-plugin/tests/rules/no-implied-eval.test.ts index 521f838f06f..353a6300b45 100644 --- a/packages/eslint-plugin/tests/rules/no-implied-eval.test.ts +++ b/packages/eslint-plugin/tests/rules/no-implied-eval.test.ts @@ -18,7 +18,7 @@ ruleTester.run('no-implied-eval', rule, { 'foo.execScript(null);', 'foo.setTimeout(null);', 'foo();', - '(function() {})();', + '(function () {})();', 'setTimeout(() => {}, 0);', 'window.setTimeout(() => {}, 0);', @@ -45,7 +45,7 @@ setImmediate(foo); execScript(foo); `, ` -const foo = function() {}; +const foo = function () {}; setTimeout(foo, 0); setInterval(foo, 0); @@ -72,7 +72,7 @@ execScript(foo.fn); `, ` const foo = { - fn: function() {}, + fn: function () {}, }; setTimeout(foo.fn, 0); @@ -166,8 +166,8 @@ setImmediate(foo()); execScript(foo()); `, ` -const foo = function() { - return function() { +const foo = function () { + return function () { return ''; }; }; @@ -368,7 +368,7 @@ execScript(foo); }, { code: ` -const foo = function() { +const foo = function () { return 'x + 1'; }; @@ -402,7 +402,7 @@ execScript(foo()); }, { code: ` -const foo = function() { +const foo = function () { return () => 'x + 1'; }; @@ -436,7 +436,7 @@ execScript(foo()()); }, { code: ` -const fn = function() {}; +const fn = function () {}; setTimeout(fn + '', 0); setInterval(fn + '', 0); diff --git a/packages/eslint-plugin/tests/rules/no-inferrable-types.test.ts b/packages/eslint-plugin/tests/rules/no-inferrable-types.test.ts index b87e778d508..0f7bb141f1b 100644 --- a/packages/eslint-plugin/tests/rules/no-inferrable-types.test.ts +++ b/packages/eslint-plugin/tests/rules/no-inferrable-types.test.ts @@ -103,7 +103,7 @@ ruleTester.run('no-inferrable-types', rule, { ...validTestCases, "const fn = (a = 5, b = true, c = 'foo') => {};", - "const fn = function(a = 5, b = true, c = 'foo') {};", + "const fn = function (a = 5, b = true, c = 'foo') {};", "function fn(a = 5, b = true, c = 'foo') {}", 'function fn(a: number, b: boolean, c: string) {}', @@ -121,7 +121,7 @@ class Foo { `, 'const a: any = 5;', - "const fn = function(a: any = 5, b: any = true, c: any = 'foo') {};", + "const fn = function (a: any = 5, b: any = true, c: any = 'foo') {};", { code: @@ -135,7 +135,7 @@ class Foo { }, { code: - "const fn = function(a: number = 5, b: boolean = true, c: string = 'foo') {};", + "const fn = function (a: number = 5, b: boolean = true, c: string = 'foo') {};", options: [{ ignoreParameters: true }], }, { diff --git a/packages/eslint-plugin/tests/rules/no-invalid-this.test.ts b/packages/eslint-plugin/tests/rules/no-invalid-this.test.ts index 93701a2dc32..f3d339fe63e 100644 --- a/packages/eslint-plugin/tests/rules/no-invalid-this.test.ts +++ b/packages/eslint-plugin/tests/rules/no-invalid-this.test.ts @@ -18,7 +18,7 @@ ruleTester.run('no-invalid-this', rule, { valid: [ ` describe('foo', () => { - it('does something', function(this: Mocha.Context) { + it('does something', function (this: Mocha.Context) { this.timeout(100); // done }); @@ -38,7 +38,7 @@ function foo(this: prop) { } `, ` -z(function(x, this: context) { +z(function (x, this: context) { console.log(x, this); }); `, @@ -56,7 +56,7 @@ function foo() { // https://github.com/eslint/eslint/issues/6824 ` -var Ctor = function() { +var Ctor = function () { console.log(this); z(x => console.log(x, this)); }; @@ -113,7 +113,7 @@ class A { { code: ` var obj = { - foo: function() { + foo: function () { console.log(this); z(x => console.log(x, this)); }, @@ -135,7 +135,7 @@ var obj = { var obj = { foo: foo || - function() { + function () { console.log(this); z(x => console.log(x, this)); }, @@ -147,7 +147,7 @@ var obj = { var obj = { foo: hasNative ? foo - : function() { + : function () { console.log(this); z(x => console.log(x, this)); }, @@ -157,8 +157,8 @@ var obj = { { code: ` var obj = { - foo: (function() { - return function() { + foo: (function () { + return function () { console.log(this); z(x => console.log(x, this)); }; @@ -169,7 +169,7 @@ var obj = { { code: ` Object.defineProperty(obj, 'foo', { - value: function() { + value: function () { console.log(this); z(x => console.log(x, this)); }, @@ -180,7 +180,7 @@ Object.defineProperty(obj, 'foo', { code: ` Object.defineProperties(obj, { foo: { - value: function() { + value: function () { console.log(this); z(x => console.log(x, this)); }, @@ -192,7 +192,7 @@ Object.defineProperties(obj, { // Assigns to a property. { code: ` -obj.foo = function() { +obj.foo = function () { console.log(this); z(x => console.log(x, this)); }; @@ -202,7 +202,7 @@ obj.foo = function() { code: ` obj.foo = foo || - function() { + function () { console.log(this); z(x => console.log(x, this)); }; @@ -212,7 +212,7 @@ obj.foo = code: ` obj.foo = foo ? bar - : function() { + : function () { console.log(this); z(x => console.log(x, this)); }; @@ -220,8 +220,8 @@ obj.foo = foo }, { code: ` -obj.foo = (function() { - return function() { +obj.foo = (function () { + return function () { console.log(this); z(x => console.log(x, this)); }; @@ -231,7 +231,7 @@ obj.foo = (function() { { code: ` obj.foo = (() => - function() { + function () { console.log(this); z(x => console.log(x, this)); })(); @@ -240,20 +240,20 @@ obj.foo = (() => // Bind/Call/Apply ` -(function() { +(function () { console.log(this); z(x => console.log(x, this)); }.call(obj)); `, ` -var foo = function() { +var foo = function () { console.log(this); z(x => console.log(x, this)); }.bind(obj); `, ` Reflect.apply( - function() { + function () { console.log(this); z(x => console.log(x, this)); }, @@ -262,7 +262,7 @@ Reflect.apply( ); `, ` -(function() { +(function () { console.log(this); z(x => console.log(x, this)); }.apply(obj)); @@ -283,7 +283,7 @@ class A { ` Array.from( [], - function() { + function () { console.log(this); z(x => console.log(x, this)); }, @@ -292,49 +292,49 @@ Array.from( `, ` -foo.every(function() { +foo.every(function () { console.log(this); z(x => console.log(x, this)); }, obj); `, ` -foo.filter(function() { +foo.filter(function () { console.log(this); z(x => console.log(x, this)); }, obj); `, ` -foo.find(function() { +foo.find(function () { console.log(this); z(x => console.log(x, this)); }, obj); `, ` -foo.findIndex(function() { +foo.findIndex(function () { console.log(this); z(x => console.log(x, this)); }, obj); `, ` -foo.forEach(function() { +foo.forEach(function () { console.log(this); z(x => console.log(x, this)); }, obj); `, ` -foo.map(function() { +foo.map(function () { console.log(this); z(x => console.log(x, this)); }, obj); `, ` -foo.some(function() { +foo.some(function () { console.log(this); z(x => console.log(x, this)); }, obj); @@ -351,7 +351,7 @@ foo.some(function() { ` foo( - /* @this Obj */ function() { + /* @this Obj */ function () { console.log(this); z(x => console.log(x, this)); }, @@ -370,7 +370,7 @@ function foo() { `, ` -Ctor = function() { +Ctor = function () { console.log(this); z(x => console.log(x, this)); }; @@ -378,7 +378,7 @@ Ctor = function() { ` function foo( - Ctor = function() { + Ctor = function () { console.log(this); z(x => console.log(x, this)); }, @@ -387,7 +387,7 @@ function foo( ` [ - obj.method = function() { + obj.method = function () { console.log(this); z(x => console.log(x, this)); }, @@ -441,7 +441,7 @@ z(x => console.log(x, this)); // IIFE. { code: ` -(function() { +(function () { console.log(this); z(x => console.log(x, this)); })(); @@ -508,7 +508,7 @@ function Foo() { }, { code: ` -return function() { +return function () { console.log(this); z(x => console.log(x, this)); }; @@ -520,7 +520,7 @@ return function() { }, { code: ` -var foo = function() { +var foo = function () { console.log(this); z(x => console.log(x, this)); }.bar(obj); @@ -533,7 +533,7 @@ var foo = function() { { code: ` var obj = { - foo: function() { + foo: function () { function foo() { console.log(this); z(x => console.log(x, this)); @@ -563,8 +563,8 @@ var obj = { { code: ` var obj = { - foo: function() { - return function() { + foo: function () { + return function () { console.log(this); z(x => console.log(x, this)); }; @@ -577,9 +577,9 @@ var obj = { { code: ` var obj = { - foo: function() { + foo: function () { 'use strict'; - return function() { + return function () { console.log(this); z(x => console.log(x, this)); }; @@ -591,8 +591,8 @@ var obj = { }, { code: ` -obj.foo = function() { - return function() { +obj.foo = function () { + return function () { console.log(this); z(x => console.log(x, this)); }; @@ -603,9 +603,9 @@ obj.foo = function() { }, { code: ` -obj.foo = function() { +obj.foo = function () { 'use strict'; - return function() { + return function () { console.log(this); z(x => console.log(x, this)); }; @@ -618,7 +618,7 @@ obj.foo = function() { code: ` class A { foo() { - return function() { + return function () { console.log(this); z(x => console.log(x, this)); }; @@ -633,7 +633,7 @@ class A { { code: ` -obj.foo = (function() { +obj.foo = (function () { return () => { console.log(this); z(x => console.log(x, this)); @@ -657,7 +657,7 @@ obj.foo = (() => () => { { code: ` -var foo = function() { +var foo = function () { console.log(this); z(x => console.log(x, this)); }.bind(null); @@ -668,7 +668,7 @@ var foo = function() { { code: ` -(function() { +(function () { console.log(this); z(x => console.log(x, this)); }.call(undefined)); @@ -679,7 +679,7 @@ var foo = function() { { code: ` -(function() { +(function () { console.log(this); z(x => console.log(x, this)); }.apply(void 0)); @@ -691,7 +691,7 @@ var foo = function() { // Array methods. { code: ` -Array.from([], function() { +Array.from([], function () { console.log(this); z(x => console.log(x, this)); }); @@ -701,7 +701,7 @@ Array.from([], function() { }, { code: ` -foo.every(function() { +foo.every(function () { console.log(this); z(x => console.log(x, this)); }); @@ -711,7 +711,7 @@ foo.every(function() { }, { code: ` -foo.filter(function() { +foo.filter(function () { console.log(this); z(x => console.log(x, this)); }); @@ -721,7 +721,7 @@ foo.filter(function() { }, { code: ` -foo.find(function() { +foo.find(function () { console.log(this); z(x => console.log(x, this)); }); @@ -731,7 +731,7 @@ foo.find(function() { }, { code: ` -foo.findIndex(function() { +foo.findIndex(function () { console.log(this); z(x => console.log(x, this)); }); @@ -741,7 +741,7 @@ foo.findIndex(function() { }, { code: ` -foo.forEach(function() { +foo.forEach(function () { console.log(this); z(x => console.log(x, this)); }); @@ -751,7 +751,7 @@ foo.forEach(function() { }, { code: ` -foo.map(function() { +foo.map(function () { console.log(this); z(x => console.log(x, this)); }); @@ -761,7 +761,7 @@ foo.map(function() { }, { code: ` -foo.some(function() { +foo.some(function () { console.log(this); z(x => console.log(x, this)); }); @@ -772,7 +772,7 @@ foo.some(function() { { code: ` -foo.forEach(function() { +foo.forEach(function () { console.log(this); z(x => console.log(x, this)); }, null); @@ -795,7 +795,7 @@ foo.forEach(function() { }, { code: ` -/** @this Obj */ foo(function() { +/** @this Obj */ foo(function () { console.log(this); z(x => console.log(x, this)); }); @@ -806,7 +806,7 @@ foo.forEach(function() { { code: ` -var Ctor = function() { +var Ctor = function () { console.log(this); z(x => console.log(x, this)); }; @@ -817,7 +817,7 @@ var Ctor = function() { }, { code: ` -var func = function() { +var func = function () { console.log(this); z(x => console.log(x, this)); }; @@ -827,7 +827,7 @@ var func = function() { }, { code: ` -var func = function() { +var func = function () { console.log(this); z(x => console.log(x, this)); }; @@ -839,7 +839,7 @@ var func = function() { { code: ` -Ctor = function() { +Ctor = function () { console.log(this); z(x => console.log(x, this)); }; @@ -850,7 +850,7 @@ Ctor = function() { }, { code: ` -func = function() { +func = function () { console.log(this); z(x => console.log(x, this)); }; @@ -860,7 +860,7 @@ func = function() { }, { code: ` -func = function() { +func = function () { console.log(this); z(x => console.log(x, this)); }; @@ -873,7 +873,7 @@ func = function() { { code: ` function foo( - func = function() { + func = function () { console.log(this); z(x => console.log(x, this)); }, @@ -886,7 +886,7 @@ function foo( { code: ` [ - func = function() { + func = function () { console.log(this); z(x => console.log(x, this)); }, diff --git a/packages/eslint-plugin/tests/rules/no-unused-vars.test.ts b/packages/eslint-plugin/tests/rules/no-unused-vars.test.ts index f59cb588425..6b0d7f4148b 100644 --- a/packages/eslint-plugin/tests/rules/no-unused-vars.test.ts +++ b/packages/eslint-plugin/tests/rules/no-unused-vars.test.ts @@ -135,7 +135,7 @@ bar(); `, ` import { Foo } from 'foo'; -const bar = function() {}; +const bar = function () {}; bar(); `, ` diff --git a/packages/eslint-plugin/tests/rules/no-use-before-define.test.ts b/packages/eslint-plugin/tests/rules/no-use-before-define.test.ts index dbbfcd61f5a..aa09db0f29f 100644 --- a/packages/eslint-plugin/tests/rules/no-use-before-define.test.ts +++ b/packages/eslint-plugin/tests/rules/no-use-before-define.test.ts @@ -97,7 +97,7 @@ function foo() { } `, ` -var foo = function() { +var foo = function () { foo(); }; `, @@ -154,7 +154,7 @@ switch (foo) { code: ` a(); { - let a = function() {}; + let a = function () {}; } `, parserOptions, @@ -355,7 +355,7 @@ var a = 19; { code: ` a(); -var a = function() {}; +var a = function () {}; `, errors: [ { @@ -403,7 +403,7 @@ function a() { { code: ` a(); -var a = function() {}; +var a = function () {}; `, options: ['nofunc'], errors: [ @@ -644,7 +644,7 @@ if (true) { { code: ` a(); -var a = function() {}; +var a = function () {}; `, options: [{ functions: false, classes: false }], errors: [ diff --git a/packages/eslint-plugin/tests/rules/prefer-readonly.test.ts b/packages/eslint-plugin/tests/rules/prefer-readonly.test.ts index 43ecdb03fe8..c1602f01913 100644 --- a/packages/eslint-plugin/tests/rules/prefer-readonly.test.ts +++ b/packages/eslint-plugin/tests/rules/prefer-readonly.test.ts @@ -14,7 +14,7 @@ const ruleTester = new RuleTester({ ruleTester.run('prefer-readonly', rule, { valid: [ 'function ignore() {}', - 'const ignore = function() {};', + 'const ignore = function () {};', 'const ignore = () => {};', ` const container = { member: true }; diff --git a/packages/eslint-plugin/tests/rules/promise-function-async.test.ts b/packages/eslint-plugin/tests/rules/promise-function-async.test.ts index d4da6e3b66c..47b5b6221d6 100644 --- a/packages/eslint-plugin/tests/rules/promise-function-async.test.ts +++ b/packages/eslint-plugin/tests/rules/promise-function-async.test.ts @@ -24,12 +24,12 @@ function nonAsyncNonPromiseFunctionDeclaration(n: number) { } `, ` -const asyncPromiseFunctionExpressionA = async function(p: Promise) { +const asyncPromiseFunctionExpressionA = async function (p: Promise) { return p; }; `, ` -const asyncPromiseFunctionExpressionB = async function() { +const asyncPromiseFunctionExpressionB = async function () { return new Promise(); }; `, @@ -182,7 +182,7 @@ function returnsUnknown(): unknown { }, { code: ` -const nonAsyncPromiseFunctionExpressionA = function(p: Promise) { +const nonAsyncPromiseFunctionExpressionA = function (p: Promise) { return p; }; `, @@ -194,7 +194,7 @@ const nonAsyncPromiseFunctionExpressionA = function(p: Promise) { }, { code: ` -const nonAsyncPromiseFunctionExpressionB = function() { +const nonAsyncPromiseFunctionExpressionB = function () { return new Promise(); }; `, @@ -273,7 +273,7 @@ class Test { }, { code: ` -const nonAsyncPromiseFunctionExpression = function(p: Promise) { +const nonAsyncPromiseFunctionExpression = function (p: Promise) { return p; }; @@ -311,7 +311,7 @@ class Test { }, { code: ` -const nonAsyncPromiseFunctionExpression = function(p: Promise) { +const nonAsyncPromiseFunctionExpression = function (p: Promise) { return p; }; @@ -349,7 +349,7 @@ class Test { }, { code: ` -const nonAsyncPromiseFunctionExpression = function(p: Promise) { +const nonAsyncPromiseFunctionExpression = function (p: Promise) { return p; }; @@ -387,7 +387,7 @@ class Test { }, { code: ` -const nonAsyncPromiseFunctionExpression = function(p: Promise) { +const nonAsyncPromiseFunctionExpression = function (p: Promise) { return p; }; diff --git a/packages/eslint-plugin/tests/rules/require-await.test.ts b/packages/eslint-plugin/tests/rules/require-await.test.ts index 05c4bf739b9..add1855f36b 100644 --- a/packages/eslint-plugin/tests/rules/require-await.test.ts +++ b/packages/eslint-plugin/tests/rules/require-await.test.ts @@ -22,7 +22,7 @@ function numberOne(): number { `, // Non-async function expression ` -const numberOne = function(): number { +const numberOne = function (): number { return 1; }; `, @@ -57,7 +57,7 @@ async function numberOne(): Promise { `, // Async function expression with await ` -const numberOne = async function(): Promise { +const numberOne = async function (): Promise { return await 1; }; `, @@ -77,7 +77,7 @@ async function numberOne(): Promise { `, // Async function expression with promise return ` -const numberOne = async function(): Promise { +const numberOne = async function (): Promise { return Promise.resolve(1); }; `, @@ -100,17 +100,17 @@ async function getAsyncNumber(x: number): Promise { `, // Async function expression with async function return ` -const numberOne = async function(): Promise { +const numberOne = async function (): Promise { return getAsyncNumber(1); }; -const getAsyncNumber = async function(x: number): Promise { +const getAsyncNumber = async function (x: number): Promise { return Promise.resolve(x); }; `, // Async arrow function with async function return (concise-body) ` const numberOne = async (): Promise => getAsyncNumber(1); -const getAsyncNumber = async function(x: number): Promise { +const getAsyncNumber = async function (x: number): Promise { return Promise.resolve(x); }; `, @@ -119,7 +119,7 @@ const getAsyncNumber = async function(x: number): Promise { const numberOne = async (): Promise => { return getAsyncNumber(1); }; -const getAsyncNumber = async function(x: number): Promise { +const getAsyncNumber = async function (x: number): Promise { return Promise.resolve(x); }; `, @@ -161,7 +161,7 @@ async function* test1() { yield* asyncGenerator(); } `, - 'const foo: () => void = async function*() {};', + 'const foo: () => void = async function* () {};', ` async function* foo(): Promise { return new Promise(res => res(\`hello\`)); @@ -189,7 +189,7 @@ async function numberOne(): Promise { { // Async function expression with no await code: ` -const numberOne = async function(): Promise { +const numberOne = async function (): Promise { return 1; }; `, @@ -264,7 +264,7 @@ async function* foo() { }, { code: ` -const foo = async function*() { +const foo = async function* () { console.log('bar'); }; `, @@ -322,7 +322,7 @@ async function foo() { } `, ` -(async function() { +(async function () { await doSomething(); }); `, @@ -403,7 +403,7 @@ for await (let num of asyncIterable) { }, { code: ` - (async function() { + (async function () { doSomething(); }); `, diff --git a/packages/eslint-plugin/tests/rules/typedef.test.ts b/packages/eslint-plugin/tests/rules/typedef.test.ts index d6b37c811ed..e624670d206 100644 --- a/packages/eslint-plugin/tests/rules/typedef.test.ts +++ b/packages/eslint-plugin/tests/rules/typedef.test.ts @@ -378,7 +378,7 @@ ruleTester.run('typedef', rule, { }, // variable declaration ignore function { - code: 'const foo = function(): void {};', + code: 'const foo = function (): void {};', options: [ { variableDeclaration: true, @@ -405,7 +405,7 @@ ruleTester.run('typedef', rule, { ], }, { - code: 'const foo: () => void = function(): void {};', + code: 'const foo: () => void = function (): void {};', options: [ { variableDeclaration: true, @@ -417,7 +417,7 @@ ruleTester.run('typedef', rule, { code: ` class Foo { a = (): void => {}; - b = function(): void {}; + b = function (): void {}; } `, options: [ @@ -831,7 +831,7 @@ class Foo { ], }, { - code: 'const foo = function(): void {};', + code: 'const foo = function (): void {};', errors: [ { messageId: 'expectedTypedefNamed', @@ -864,7 +864,7 @@ class Foo { code: ` class Foo { a = (): void => {}; - b = function(): void {}; + b = function (): void {}; } `, errors: [ diff --git a/packages/eslint-plugin/tests/rules/unbound-method.test.ts b/packages/eslint-plugin/tests/rules/unbound-method.test.ts index 20caa1d8b45..12d6486e09f 100644 --- a/packages/eslint-plugin/tests/rules/unbound-method.test.ts +++ b/packages/eslint-plugin/tests/rules/unbound-method.test.ts @@ -373,7 +373,7 @@ instance.unbound = x; // THIS SHOULD NOT { code: ` class Foo { - unbound = function() {}; + unbound = function () {}; } const unbound = new Foo().unbound; `, diff --git a/packages/eslint-plugin/tests/rules/unified-signatures.test.ts b/packages/eslint-plugin/tests/rules/unified-signatures.test.ts index 3c109d67a03..ea259aea432 100644 --- a/packages/eslint-plugin/tests/rules/unified-signatures.test.ts +++ b/packages/eslint-plugin/tests/rules/unified-signatures.test.ts @@ -131,11 +131,11 @@ export interface Foo { `, ` declare module 'foo' { - export default function(foo: number): string[]; + export default function (foo: number): string[]; } `, ` -export default function(foo: number): string[]; +export default function (foo: number): string[]; `, // https://github.com/typescript-eslint/typescript-eslint/issues/740 ` @@ -682,28 +682,28 @@ export function foo(line: number, character?: number): number; { code: ` declare module 'foo' { - export default function(foo: number): string[]; - export default function(foo: number, bar?: string): string[]; + export default function (foo: number): string[]; + export default function (foo: number, bar?: string): string[]; } `, errors: [ { messageId: 'omittingSingleParameter', line: 4, - column: 40, + column: 41, }, ], }, { code: ` -export default function(foo: number): string[]; -export default function(foo: number, bar?: string): string[]; +export default function (foo: number): string[]; +export default function (foo: number, bar?: string): string[]; `, errors: [ { messageId: 'omittingSingleParameter', line: 3, - column: 38, + column: 39, }, ], }, diff --git a/packages/parser/src/analyze-scope.ts b/packages/parser/src/analyze-scope.ts index 4e680373d77..66a2167d41c 100644 --- a/packages/parser/src/analyze-scope.ts +++ b/packages/parser/src/analyze-scope.ts @@ -17,7 +17,7 @@ import { visitorKeys as childVisitorKeys } from '@typescript-eslint/typescript-e function overrideDefine( define: (node: TSESTree.Node, def: TSESLintScope.Definition) => void, ) { - return function( + return function ( this: TSESLintScope.Scope, node: TSESTree.Node, definition: TSESLintScope.Definition, diff --git a/yarn.lock b/yarn.lock index 04ba7af56f0..1be631b3cbe 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1486,10 +1486,10 @@ resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e" integrity sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA== -"@types/prettier@^1.18.2": - version "1.18.3" - resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-1.18.3.tgz#64ff53329ce16139f17c3db9d3e0487199972cd8" - integrity sha512-48rnerQdcZ26odp+HOvDGX8IcUkYOCuMc2BodWYTe956MqkHlOGAG4oFQ83cjZ0a4GAgj7mb4GUClxYd2Hlodg== +"@types/prettier@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.0.0.tgz#dc85454b953178cc6043df5208b9e949b54a3bc4" + integrity sha512-/rM+sWiuOZ5dvuVzV37sUuklsbg+JPOP8d+nNFlo2ZtfpzPiPvh1/gc8liWOLBqe+sR+ZM7guPaIcTt6UZTo7Q== "@types/semver@^6.2.0": version "6.2.0" @@ -6804,10 +6804,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@^1.19.1: - version "1.19.1" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" - integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== +prettier@*, prettier@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.5.tgz#d6d56282455243f2f92cc1716692c08aa31522d4" + integrity sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg== pretty-format@^25.1.0: version "25.1.0"