diff --git a/package.json b/package.json index bc10ee8c87cc..03bfdf5de3c3 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "mocha": "^6.0.2", "mock-fs": "^4.4.1", "opencollective": "^1.0.3", - "prettier": "^1.16.1", + "prettier": "^1.18.2", "prettylint": "^1.0.0", "progress": "^2.0.0", "promise": "^8.0.2", @@ -114,6 +114,12 @@ "singleQuote": true, "trailingComma": "all", "overrides": [ + { + "files": "**/*.md", + "options": { + "printWidth": 500 + } + }, { "excludeFiles": [ "e2e/__tests__/**/*", diff --git a/packages/jest-circus/src/eventHandler.ts b/packages/jest-circus/src/eventHandler.ts index 1accee9c36a0..bcbd151709e1 100644 --- a/packages/jest-circus/src/eventHandler.ts +++ b/packages/jest-circus/src/eventHandler.ts @@ -44,9 +44,7 @@ const eventHandler: Circus.EventHandler = (event, state): void => { if (!describeBlockHasTests(currentDescribeBlock)) { currentDescribeBlock.hooks.forEach(hook => { - hook.asyncError.message = `Invalid: ${ - hook.type - }() may not be used in a describe block containing no tests.`; + hook.asyncError.message = `Invalid: ${hook.type}() may not be used in a describe block containing no tests.`; state.unhandledErrors.push(hook.asyncError); }); } diff --git a/packages/jest-diff/src/joinAlignedDiffs.ts b/packages/jest-diff/src/joinAlignedDiffs.ts index e4c7746ec351..186f3c393e0b 100644 --- a/packages/jest-diff/src/joinAlignedDiffs.ts +++ b/packages/jest-diff/src/joinAlignedDiffs.ts @@ -189,20 +189,18 @@ export const joinAlignedDiffsNoExpand = ( // return joined lines with diff formatting. export const joinAlignedDiffsExpand = (diffs: Array) => diffs - .map( - (diff: Diff, i: number, diffs: Array): string => { - const line = diff[1]; + .map((diff: Diff, i: number, diffs: Array): string => { + const line = diff[1]; - switch (diff[0]) { - case DIFF_DELETE: - return printDeleteLine(line); + switch (diff[0]) { + case DIFF_DELETE: + return printDeleteLine(line); - case DIFF_INSERT: - return printInsertLine(line); + case DIFF_INSERT: + return printInsertLine(line); - default: - return printCommonLine(line, i === 0 || i === diffs.length - 1); - } - }, - ) + default: + return printCommonLine(line, i === 0 || i === diffs.length - 1); + } + }) .join('\n'); diff --git a/packages/jest-haste-map/src/types.ts b/packages/jest-haste-map/src/types.ts index 291d5473ba98..9f776911a225 100644 --- a/packages/jest-haste-map/src/types.ts +++ b/packages/jest-haste-map/src/types.ts @@ -52,7 +52,7 @@ export type FileMetaData = [ /* size */ number, /* visited */ 0 | 1, /* dependencies */ string, - /* sha1 */ string | null | undefined + /* sha1 */ string | null | undefined, ]; export type MockData = Map; diff --git a/packages/jest-mock/src/index.ts b/packages/jest-mock/src/index.ts index ba06769d893b..7647b81c379a 100644 --- a/packages/jest-mock/src/index.ts +++ b/packages/jest-mock/src/index.ts @@ -81,11 +81,11 @@ type MockFunctionConfig = { // see https://github.com/Microsoft/TypeScript/issues/25215 type NonFunctionPropertyNames = { - [K in keyof T]: T[K] extends (...args: Array) => any ? never : K + [K in keyof T]: T[K] extends (...args: Array) => any ? never : K; }[keyof T] & string; type FunctionPropertyNames = { - [K in keyof T]: T[K] extends (...args: Array) => any ? K : never + [K in keyof T]: T[K] extends (...args: Array) => any ? K : never; }[keyof T] & string; diff --git a/packages/jest-snapshot/src/snapshot_resolver.ts b/packages/jest-snapshot/src/snapshot_resolver.ts index 2903dc820d0e..116043596f91 100644 --- a/packages/jest-snapshot/src/snapshot_resolver.ts +++ b/packages/jest-snapshot/src/snapshot_resolver.ts @@ -109,9 +109,7 @@ function verifyConsistentTransformations(custom: SnapshotResolver) { if (resolvedTestPath !== custom.testPathForConsistencyCheck) { throw new Error( chalk.bold( - `Custom snapshot resolver functions must transform paths consistently, i.e. expects resolveTestPath(resolveSnapshotPath('${ - custom.testPathForConsistencyCheck - }')) === ${resolvedTestPath}`, + `Custom snapshot resolver functions must transform paths consistently, i.e. expects resolveTestPath(resolveSnapshotPath('${custom.testPathForConsistencyCheck}')) === ${resolvedTestPath}`, ), ); } diff --git a/packages/jest-util/src/__tests__/deepCyclicCopy.test.ts b/packages/jest-util/src/__tests__/deepCyclicCopy.test.ts index 41bb93570f17..73ea0f451da0 100644 --- a/packages/jest-util/src/__tests__/deepCyclicCopy.test.ts +++ b/packages/jest-util/src/__tests__/deepCyclicCopy.test.ts @@ -85,14 +85,14 @@ it('uses the blacklist to avoid copying properties on the first level', () => { it('does not keep the prototype by default when top level is object', () => { // @ts-ignore - const sourceObject = new function() {}(); + const sourceObject = new (function() {})(); // @ts-ignore - sourceObject.nestedObject = new function() {}(); + sourceObject.nestedObject = new (function() {})(); // @ts-ignore - sourceObject.nestedArray = new function() { + sourceObject.nestedArray = new (function() { // @ts-ignore this.length = 0; - }(); + })(); const spy = jest .spyOn(Array, 'isArray') @@ -125,10 +125,10 @@ it('does not keep the prototype by default when top level is array', () => { const spy = jest.spyOn(Array, 'isArray').mockImplementation(() => true); // @ts-ignore - const sourceArray = new function() { + const sourceArray = new (function() { // @ts-ignore this.length = 0; - }(); + })(); const copy = deepCyclicCopy(sourceArray); expect(Object.getPrototypeOf(copy)).not.toBe( @@ -143,10 +143,10 @@ it('does not keep the prototype of arrays when keepPrototype = false', () => { const spy = jest.spyOn(Array, 'isArray').mockImplementation(() => true); // @ts-ignore - const sourceArray = new function() { + const sourceArray = new (function() { // @ts-ignore this.length = 0; - }(); + })(); const copy = deepCyclicCopy(sourceArray, {keepPrototype: false}); expect(Object.getPrototypeOf(copy)).not.toBe( @@ -161,10 +161,10 @@ it('keeps the prototype of arrays when keepPrototype = true', () => { const spy = jest.spyOn(Array, 'isArray').mockImplementation(() => true); // @ts-ignore - const sourceArray = new function() { + const sourceArray = new (function() { // @ts-ignore this.length = 0; - }(); + })(); const copy = deepCyclicCopy(sourceArray, {keepPrototype: true}); expect(Object.getPrototypeOf(copy)).toBe(Object.getPrototypeOf(sourceArray)); @@ -174,14 +174,14 @@ it('keeps the prototype of arrays when keepPrototype = true', () => { it('does not keep the prototype for objects when keepPrototype = false', () => { // @ts-ignore - const sourceobject = new function() {}(); + const sourceobject = new (function() {})(); // @ts-ignore - sourceobject.nestedObject = new function() {}(); + sourceobject.nestedObject = new (function() {})(); // @ts-ignore - sourceobject.nestedArray = new function() { + sourceobject.nestedArray = new (function() { // @ts-ignore this.length = 0; - }(); + })(); const spy = jest .spyOn(Array, 'isArray') @@ -211,14 +211,14 @@ it('does not keep the prototype for objects when keepPrototype = false', () => { it('keeps the prototype for objects when keepPrototype = true', () => { // @ts-ignore - const sourceObject = new function() {}(); + const sourceObject = new (function() {})(); // @ts-ignore - sourceObject.nestedObject = new function() {}(); + sourceObject.nestedObject = new (function() {})(); // @ts-ignore - sourceObject.nestedArray = new function() { + sourceObject.nestedArray = new (function() { // @ts-ignore this.length = 0; - }(); + })(); const spy = jest .spyOn(Array, 'isArray') diff --git a/packages/jest-worker/src/types.ts b/packages/jest-worker/src/types.ts index 8c4979a5f7da..dc5bafc23835 100644 --- a/packages/jest-worker/src/types.ts +++ b/packages/jest-worker/src/types.ts @@ -101,19 +101,19 @@ export type ChildMessageInitialize = [ boolean, // processed string, // file Array | undefined, // setupArgs - MessagePort | undefined // MessagePort + MessagePort | undefined, // MessagePort ]; export type ChildMessageCall = [ typeof CHILD_MESSAGE_CALL, // type boolean, // processed string, // method - Array // args + Array, // args ]; export type ChildMessageEnd = [ typeof CHILD_MESSAGE_END, // type - boolean // processed + boolean, // processed ]; export type ChildMessage = @@ -125,7 +125,7 @@ export type ChildMessage = export type ParentMessageOk = [ typeof PARENT_MESSAGE_OK, // type - unknown // result + unknown, // result ]; export type ParentMessageError = [ @@ -133,7 +133,7 @@ export type ParentMessageError = [ string, // constructor string, // message string, // stack - unknown // extra + unknown, // extra ]; export type ParentMessage = ParentMessageOk | ParentMessageError; diff --git a/packages/pretty-format/README.md b/packages/pretty-format/README.md index 22a67afa4364..4981d42f9535 100755 --- a/packages/pretty-format/README.md +++ b/packages/pretty-format/README.md @@ -252,9 +252,7 @@ function serializeItems(items, config, indentation, depth, refs, printer) { config.spacingOuter + items .map( - item => - indentationItems + - printer(item, config, indentationItems, depth, refs), // callback + item => indentationItems + printer(item, config, indentationItems, depth, refs), // callback ) .join(SEPARATOR + config.spacingInner) + (config.min ? '' : SEPARATOR) + // following the last item @@ -269,12 +267,7 @@ const plugin = { }, serialize(array, config, indentation, depth, refs, printer) { const name = array.constructor.name; - return ++depth > config.maxDepth - ? '[' + name + ']' - : (config.min ? '' : name + ' ') + - '[' + - serializeItems(array, config, indentation, depth, refs, printer) + - ']'; + return ++depth > config.maxDepth ? '[' + name + ']' : (config.min ? '' : name + ' ') + '[' + serializeItems(array, config, indentation, depth, refs, printer) + ']'; }, }; ``` diff --git a/website/pages/en/versions.js b/website/pages/en/versions.js index 0eebc838301b..adec13ab457f 100644 --- a/website/pages/en/versions.js +++ b/website/pages/en/versions.js @@ -34,9 +34,7 @@ class Versions extends React.Component { {latestVersion} Documentation @@ -59,9 +57,7 @@ class Versions extends React.Component { master Documentation @@ -85,9 +81,7 @@ class Versions extends React.Component { {version} Documentation diff --git a/yarn.lock b/yarn.lock index ace1f049f6c0..911b881d96d5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10501,10 +10501,10 @@ prettier-linter-helpers@^1.0.0: dependencies: fast-diff "^1.1.2" -prettier@^1.13.4, prettier@^1.16.1: - version "1.16.4" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.16.4.tgz#73e37e73e018ad2db9c76742e2647e21790c9717" - integrity sha512-ZzWuos7TI5CKUeQAtFd6Zhm2s6EpAD/ZLApIhsF9pRvRtM1RFo61dM/4MSRUA0SuLugA/zgrZD8m0BaY46Og7g== +prettier@^1.13.4, prettier@^1.18.2: + version "1.18.2" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.18.2.tgz#6823e7c5900017b4bd3acf46fe9ac4b4d7bda9ea" + integrity sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw== pretty-format@24.0.0-alpha.6: version "24.0.0-alpha.6"