Skip to content

Commit

Permalink
chore: upgrade to prettier 2.0 (#1970)
Browse files Browse the repository at this point in the history
  • Loading branch information
bradzacher committed May 4, 2020
1 parent b18bc35 commit 1f3c344
Show file tree
Hide file tree
Showing 36 changed files with 301 additions and 292 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Expand Up @@ -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

Expand Down
13 changes: 12 additions & 1 deletion .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
}
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
Expand Up @@ -18,7 +18,7 @@ function test() {
}

// Should indicate that a number is returned
var fn = function() {
var fn = function () {
return 1;
};

Expand All @@ -42,7 +42,7 @@ function test(): void {
}

// A return value of type number
var fn = function(): number {
var fn = function (): number {
return 1;
};

Expand Down Expand Up @@ -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);
```
Expand All @@ -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';
};

Expand Down Expand Up @@ -186,7 +186,7 @@ Examples of **incorrect** code for this rule with `{ allowHigherOrderFunctions:
var arrowFn = () => () => {};

function fn() {
return function() {};
return function () {};
}
```

Expand All @@ -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 {};
}
```

Expand Down
Expand Up @@ -17,7 +17,7 @@ export function test() {
}

// Should indicate that a number is returned
export default function() {
export default function () {
return 1;
}

Expand All @@ -44,7 +44,7 @@ function test() {
}

// A return value of type number
export var fn = function(): number {
export var fn = function (): number {
return 1;
};

Expand Down Expand Up @@ -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';
};

Expand All @@ -147,7 +147,7 @@ type FuncType = () => string;

export let arrowFn: FuncType = () => 'test';

export let funcExpr: FuncType = function() {
export let funcExpr: FuncType = function () {
return 'test';
};

Expand Down Expand Up @@ -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 {};
}
```

Expand All @@ -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 {};
}
```

Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin/docs/rules/no-explicit-any.md
Expand Up @@ -122,7 +122,7 @@ function foo4(...args: ReadonlyArray<any>): 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;
Expand Down Expand Up @@ -151,7 +151,7 @@ function foo4(...args: ReadonlyArray<any>): 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;
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin/docs/rules/no-floating-promises.md
Expand Up @@ -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);
})();
```
Expand Down
10 changes: 5 additions & 5 deletions packages/eslint-plugin/docs/rules/no-implied-eval.md
Expand Up @@ -56,27 +56,27 @@ 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!');
});

const fn = () => {};
setTimeout(fn, 100);

const foo = {
fn: function() {},
fn: function () {},
};
setTimeout(foo.fn, 100);
setTimeout(foo.fn.bind(this), 100);
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/docs/rules/no-this-alias.md
Expand Up @@ -14,7 +14,7 @@ Rationale from TSLint:
> ```js
> const self = this;
>
> setTimeout(function() {
> setTimeout(function () {
> self.doWork();
> });
> ```
Expand Down
8 changes: 4 additions & 4 deletions packages/eslint-plugin/docs/rules/typedef.md
Expand Up @@ -164,15 +164,15 @@ function logsSize(size): void {
console.log(size);
}

const doublesSize = function(size): number {
const doublesSize = function (size): number {
return size * 2;
};

const divider = {
curriesSize(size): number {
return size;
},
dividesSize: function(size): number {
dividesSize: function (size): number {
return size / 2;
},
};
Expand All @@ -192,15 +192,15 @@ function logsSize(size: number): void {
console.log(size);
}

const doublesSize = function(size: number): number {
const doublesSize = function (size: number): number {
return size * 2;
};

const divider = {
curriesSize(size: number): number {
return size;
},
dividesSize: function(size: number): number {
dividesSize: function (size: number): number {
return size / 2;
},
};
Expand Down
2 changes: 0 additions & 2 deletions packages/eslint-plugin/package.json
Expand Up @@ -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": "*",
Expand Down
Expand Up @@ -10,7 +10,6 @@ type MessageIds =
| 'angle-bracket'
| 'never'
| 'unexpectedObjectTypeAssertion';
// https://github.com/prettier/prettier/issues/4794
type OptUnion =
| {
assertionStyle: 'as' | 'angle-bracket';
Expand Down
Expand Up @@ -166,7 +166,7 @@ export default util.createRule<Options, MessageIds>({
| 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++) {
Expand Down
Expand Up @@ -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) {
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -221,7 +221,7 @@ class Test {
}
`,
// examples from https://github.com/nzakas/eslint-plugin-typescript/issues/138
'export default function<T>(foo: T) {}',
'export default function <T>(foo: T) {}',
'export default function named<T>(foo: T) {}',
`
interface Foo {
Expand Down

0 comments on commit 1f3c344

Please sign in to comment.