Skip to content

Commit

Permalink
chore: update prettier to 2.3 (#11397)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed May 11, 2021
1 parent c28e485 commit 0a902e1
Show file tree
Hide file tree
Showing 95 changed files with 765 additions and 835 deletions.
5 changes: 0 additions & 5 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ enableGlobalCache: true

nodeLinker: node-modules

packageExtensions:
"@docusaurus/plugin-pwa@*":
peerDependencies:
"@babel/core": "^7.0.0"

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
Expand Down
5 changes: 2 additions & 3 deletions docs/ManualMocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,8 @@ describe('listFilesInDirectorySync', () => {

test('includes all files in the directory in the summary', () => {
const FileSummarizer = require('../FileSummarizer');
const fileSummary = FileSummarizer.summarizeFilesInDirectorySync(
'/path/to',
);
const fileSummary =
FileSummarizer.summarizeFilesInDirectorySync('/path/to');

expect(fileSummary.length).toBe(2);
});
Expand Down
21 changes: 11 additions & 10 deletions e2e/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ export const linkJestPackage = (packageName: string, cwd: Config.Path) => {
fs.symlinkSync(packagePath, destination, 'junction');
};

export const makeTemplate = (
str: string,
): ((values?: Array<unknown>) => string) => (values = []) =>
str.replace(/\$(\d+)/g, (_match, number) => {
if (!Array.isArray(values)) {
throw new Error('Array of values must be passed to the template.');
}
return values[number - 1];
});
export const makeTemplate =
(str: string): ((values?: Array<unknown>) => string) =>
(values = []) =>
str.replace(/\$(\d+)/g, (_match, number) => {
if (!Array.isArray(values)) {
throw new Error('Array of values must be passed to the template.');
}
return values[number - 1];
});

export const cleanup = (directory: string) => rimraf.sync(directory);

Expand Down Expand Up @@ -251,7 +251,8 @@ export const extractSortedSummary = (stdout: string) => {
export const extractSummaries = (
stdout: string,
): Array<{rest: string; summary: string}> => {
const regex = /Test Suites:.*\nTests.*\nSnapshots.*\nTime.*(\nRan all test suites)*.*\n*$/gm;
const regex =
/Test Suites:.*\nTests.*\nSnapshots.*\nTime.*(\nRan all test suites)*.*\n*$/gm;

let match = regex.exec(stdout);
const matches: Array<RegExpExecArray> = [];
Expand Down
8 changes: 3 additions & 5 deletions e2e/__tests__/jestChangedFiles.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,9 @@ testIfHg('gets changed files for hg', async () => {

run(`${HG} init`, DIR);

const roots = [
'',
'nested-dir',
'nested-dir/second-nested-dir',
].map(filename => path.resolve(DIR, filename));
const roots = ['', 'nested-dir', 'nested-dir/second-nested-dir'].map(
filename => path.resolve(DIR, filename),
);

let {changedFiles: files} = await getChangedFilesForRoots(roots, {});
expect(
Expand Down
6 changes: 4 additions & 2 deletions e2e/__tests__/toMatchSnapshot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ test('handles invalid property matchers', () => {

test('handles property matchers with hint', () => {
const filename = 'handle-property-matchers-with-hint.test.js';
const template = makeTemplate(`test('handles property matchers with hint', () => {
const template =
makeTemplate(`test('handles property matchers with hint', () => {
expect({createdAt: $1}).toMatchSnapshot({createdAt: expect.any(Date)}, 'descriptive hint');
});
`);
Expand Down Expand Up @@ -263,7 +264,8 @@ test('handles property matchers with hint', () => {

test('handles property matchers with deep properties', () => {
const filename = 'handle-property-matchers-with-name.test.js';
const template = makeTemplate(`test('handles property matchers with deep properties', () => {
const template =
makeTemplate(`test('handles property matchers with deep properties', () => {
expect({ user: { createdAt: $1, name: $2 }}).toMatchSnapshot({ user: { createdAt: expect.any(Date), name: $2 }});
});
`);
Expand Down
9 changes: 6 additions & 3 deletions e2e/__tests__/toThrowErrorMatchingSnapshot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ afterAll(() => cleanup(TESTS_DIR));

test('works fine when function throws error', () => {
const filename = 'works-fine-when-function-throws-error.test.js';
const template = makeTemplate(`test('works fine when function throws error', () => {
const template =
makeTemplate(`test('works fine when function throws error', () => {
expect(() => { throw new Error('apple'); })
.toThrowErrorMatchingSnapshot();
});
Expand All @@ -35,7 +36,8 @@ test('works fine when function throws error', () => {

test(`throws the error if tested function didn't throw error`, () => {
const filename = 'throws-if-tested-function-did-not-throw.test.js';
const template = makeTemplate(`test('throws the error if tested function did not throw error', () => {
const template =
makeTemplate(`test('throws the error if tested function did not throw error', () => {
expect(() => {}).toThrowErrorMatchingSnapshot();
});
`);
Expand Down Expand Up @@ -83,7 +85,8 @@ test('cannot be used with .not', () => {

test('should support rejecting promises', () => {
const filename = 'should-support-rejecting-promises.test.js';
const template = makeTemplate(`test('should support rejecting promises', () => {
const template =
makeTemplate(`test('should support rejecting promises', () => {
return expect(Promise.reject(new Error('octopus'))).rejects.toThrowErrorMatchingSnapshot();
});
`);
Expand Down
3 changes: 1 addition & 2 deletions e2e/browser-resolver/fake-pkg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
"browser": {
"./nope.js": "./main.js"
},
"dependencies": {
}
"dependencies": {}
}
6 changes: 3 additions & 3 deletions e2e/call-done-twice/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"jest": {
"testEnvironment": "node"
}
"jest": {
"testEnvironment": "node"
}
}
4 changes: 3 additions & 1 deletion e2e/coverage-without-transform/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"jest": {
"collectCoverageFrom": ["*.js"],
"collectCoverageFrom": [
"*.js"
],
"transform": {},
"testEnvironment": "node"
}
Expand Down
3 changes: 1 addition & 2 deletions e2e/global-setup-node-modules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"jest": {
"testEnvironment": "node",
"globalSetup": "<rootDir>/setup.js",
"transformIgnorePatterns": [
]
"transformIgnorePatterns": []
}
}
5 changes: 4 additions & 1 deletion e2e/module-name-mapper-correct-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"jest": {
"moduleNameMapper": {
"\\.(css|less)$": "./__mocks__/styleMock.js",
"\\.(sass)$": ["./__mocks__/nonExistentMock.js", "./__mocks__/styleMock.js"]
"\\.(sass)$": [
"./__mocks__/nonExistentMock.js",
"./__mocks__/styleMock.js"
]
}
}
}
5 changes: 4 additions & 1 deletion e2e/module-name-mapper-wrong-array-config/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"jest": {
"moduleNameMapper": {
"\\.(css|less)$": ["no-such-module", "no-such-module-2"]
"\\.(css|less)$": [
"no-such-module",
"no-such-module-2"
]
}
}
}
4 changes: 3 additions & 1 deletion e2e/native-esm-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"name": "native-esm-typescript",
"version": "1.0.0",
"jest": {
"extensionsToTreatAsEsm": [".ts"],
"extensionsToTreatAsEsm": [
".ts"
],
"testEnvironment": "node"
}
}
1 change: 0 additions & 1 deletion e2e/require-main-after-create-require/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
"testEnvironment": "node"
}
}

2 changes: 1 addition & 1 deletion e2e/transform/transform-environment/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"esModuleInterop": true,
"module": "commonjs",
"module": "commonjs"
}
}
44 changes: 21 additions & 23 deletions e2e/transform/transform-runner/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,27 @@ export default class BaseTestRunner {
(promise, test) =>
mutex(() =>
promise
.then(
async (): Promise<TestResult> => {
await onStart(test);
return {
...createEmptyTestResult(),
numPassingTests: 1,
testFilePath: test.path,
testResults: [
{
ancestorTitles: [],
duration: 2,
failureDetails: [],
failureMessages: [],
fullName: 'sample test',
location: null,
numPassingAsserts: 1,
status: 'passed',
title: 'sample test',
},
],
};
},
)
.then(async (): Promise<TestResult> => {
await onStart(test);
return {
...createEmptyTestResult(),
numPassingTests: 1,
testFilePath: test.path,
testResults: [
{
ancestorTitles: [],
duration: 2,
failureDetails: [],
failureMessages: [],
fullName: 'sample test',
location: null,
numPassingAsserts: 1,
status: 'passed',
title: 'sample test',
},
],
};
})
.then(result => onResult(test, result))
.catch(err => onFailure(test, err)),
),
Expand Down
2 changes: 1 addition & 1 deletion e2e/transform/transform-runner/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"esModuleInterop": true,
"module": "commonjs",
"module": "commonjs"
}
}
2 changes: 1 addition & 1 deletion e2e/transform/transform-testrunner/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"esModuleInterop": true,
"module": "commonjs",
"module": "commonjs"
}
}
4 changes: 3 additions & 1 deletion e2e/watch-plugins/cjs/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"jest": {
"watchPlugins": ["./my-watch-plugin.cjs"]
"watchPlugins": [
"./my-watch-plugin.cjs"
]
}
}
4 changes: 3 additions & 1 deletion e2e/watch-plugins/js-type-module/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"type": "module",
"jest": {
"watchPlugins": ["./my-watch-plugin.js"]
"watchPlugins": [
"./my-watch-plugin.js"
]
}
}
4 changes: 3 additions & 1 deletion e2e/watch-plugins/js/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"jest": {
"watchPlugins": ["./my-watch-plugin.js"]
"watchPlugins": [
"./my-watch-plugin.js"
]
}
}
4 changes: 3 additions & 1 deletion e2e/watch-plugins/mjs/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"jest": {
"watchPlugins": ["./my-watch-plugin.mjs"]
"watchPlugins": [
"./my-watch-plugin.mjs"
]
}
}
5 changes: 2 additions & 3 deletions examples/manual-mocks/__tests__/file_summarizer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ describe('listFilesInDirectorySync', () => {

it('includes all files in the directory in the summary', () => {
const FileSummarizer = require('../FileSummarizer');
const fileSummary = FileSummarizer.summarizeFilesInDirectorySync(
'/path/to',
);
const fileSummary =
FileSummarizer.summarizeFilesInDirectorySync('/path/to');

expect(fileSummary.length).toBe(2);
});
Expand Down
4 changes: 1 addition & 3 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"version": "27.0.0-next.9",
"npmClient": "yarn",
"packages": [
"packages/*"
]
"packages": ["packages/*"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,23 @@ jest.mock('./App', () => () => <div>Hello world</div>);
var _jsxFileName = "/root/project/src/file.js";
_getJestObj().mock("./App", () => () =>
/*#__PURE__*/ _jsxDEV(
"div",
{
children: "Hello world",
},
void 0,
false,
{
fileName: _jsxFileName,
lineNumber: 1,
columnNumber: 32,
},
this
)
_getJestObj().mock(
"./App",
() => () =>
/*#__PURE__*/ _jsxDEV(
"div",
{
children: "Hello world",
},
void 0,
false,
{
fileName: _jsxFileName,
lineNumber: 1,
columnNumber: 32,
},
this
)
);
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
Expand Down
5 changes: 2 additions & 3 deletions packages/babel-plugin-jest-hoist/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,8 @@ export default (): PluginObj<{
return this.jestObjGetterIdentifier;
}

this.jestObjGetterIdentifier = program.scope.generateUidIdentifier(
'getJestObj',
);
this.jestObjGetterIdentifier =
program.scope.generateUidIdentifier('getJestObj');

program.unshiftContainer('body', [
createJestObjectGetter({
Expand Down
Loading

0 comments on commit 0a902e1

Please sign in to comment.