Skip to content

Commit

Permalink
Upgrade to prettier 1.6 (#4426)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB authored and cpojer committed Sep 5, 2017
1 parent 1517391 commit 0cb03f6
Show file tree
Hide file tree
Showing 39 changed files with 225 additions and 241 deletions.
5 changes: 1 addition & 4 deletions examples/react-native/__tests__/intro.test.js
Expand Up @@ -51,10 +51,7 @@ it('renders the ListView component', () => {
.create(
<ListView
dataSource={dataSource}
renderRow={rowData =>
<Text>
{rowData}
</Text>}
renderRow={rowData => <Text>{rowData}</Text>}
/>
)
.toJSON();
Expand Down
4 changes: 1 addition & 3 deletions examples/snapshot/Clock.react.js
Expand Up @@ -25,9 +25,7 @@ export default class Clock extends React.Component {

render() {
return (
<p>
{this.state.seconds} seconds have ellapsed since the UNIX epoch.
</p>
<p>{this.state.seconds} seconds have ellapsed since the UNIX epoch.</p>
);
}
}
6 changes: 1 addition & 5 deletions examples/snapshot/__tests__/link.react.test.js
Expand Up @@ -21,11 +21,7 @@ it('renders as an anchor when no page is set', () => {

it('properly escapes quotes', () => {
const tree = renderer
.create(
<Link>
{"\"Facebook\" \\'is \\ 'awesome'"}
</Link>
)
.create(<Link>{"\"Facebook\" \\'is \\ 'awesome'"}</Link>)
.toJSON();
expect(tree).toMatchSnapshot();
});
Expand Down
6 changes: 5 additions & 1 deletion integration_tests/__tests__/env.test.js
Expand Up @@ -11,7 +11,11 @@

const runJest = require('../runJest');

const getLog = result => result.stdout.toString().split('\n')[1].trim();
const getLog = result =>
result.stdout
.toString()
.split('\n')[1]
.trim();

describe('Environment override', () => {
it('uses jsdom when specified', () => {
Expand Down
28 changes: 21 additions & 7 deletions integration_tests/__tests__/jest_changed_files.test.js
Expand Up @@ -148,7 +148,9 @@ test('gets changed files for git', async () => {

let {changedFiles: files} = await getChangedFilesForRoots(roots, {});
expect(
Array.from(files).map(filePath => path.basename(filePath)).sort(),
Array.from(files)
.map(filePath => path.basename(filePath))
.sort(),
).toEqual(['file1.txt', 'file2.txt', 'file3.txt']);

run(`${GIT} add .`, DIR);
Expand All @@ -161,7 +163,9 @@ test('gets changed files for git', async () => {
lastCommit: true,
}));
expect(
Array.from(files).map(filePath => path.basename(filePath)).sort(),
Array.from(files)
.map(filePath => path.basename(filePath))
.sort(),
).toEqual(['file1.txt', 'file2.txt', 'file3.txt']);

writeFiles(DIR, {
Expand All @@ -170,7 +174,9 @@ test('gets changed files for git', async () => {

({changedFiles: files} = await getChangedFilesForRoots(roots, {}));
expect(
Array.from(files).map(filePath => path.basename(filePath)).sort(),
Array.from(files)
.map(filePath => path.basename(filePath))
.sort(),
).toEqual(['file1.txt']);
});

Expand Down Expand Up @@ -198,7 +204,9 @@ test('gets changed files for hg', async () => {

let {changedFiles: files} = await getChangedFilesForRoots(roots, {});
expect(
Array.from(files).map(filePath => path.basename(filePath)).sort(),
Array.from(files)
.map(filePath => path.basename(filePath))
.sort(),
).toEqual(['file1.txt', 'file2.txt', 'file3.txt']);

run(`${HG} add .`, DIR);
Expand All @@ -211,7 +219,9 @@ test('gets changed files for hg', async () => {
lastCommit: true,
}));
expect(
Array.from(files).map(filePath => path.basename(filePath)).sort(),
Array.from(files)
.map(filePath => path.basename(filePath))
.sort(),
).toEqual(['file1.txt', 'file2.txt', 'file3.txt']);

writeFiles(DIR, {
Expand All @@ -220,7 +230,9 @@ test('gets changed files for hg', async () => {

({changedFiles: files} = await getChangedFilesForRoots(roots, {}));
expect(
Array.from(files).map(filePath => path.basename(filePath)).sort(),
Array.from(files)
.map(filePath => path.basename(filePath))
.sort(),
).toEqual(['file1.txt']);

run(`${HG} commit -m "test2"`, DIR);
Expand All @@ -234,6 +246,8 @@ test('gets changed files for hg', async () => {
}));
// Returns files from current uncommited state + the last commit
expect(
Array.from(files).map(filePath => path.basename(filePath)).sort(),
Array.from(files)
.map(filePath => path.basename(filePath))
.sort(),
).toEqual(['file1.txt', 'file4.txt']);
});
11 changes: 9 additions & 2 deletions integration_tests/__tests__/list_tests.test.js
Expand Up @@ -27,7 +27,10 @@ describe('--listTests flag', () => {

expect(status).toBe(0);
expect(
normalizePaths(stdout).split('\n').sort().join('\n'),
normalizePaths(stdout)
.split('\n')
.sort()
.join('\n'),
).toMatchSnapshot();
});

Expand All @@ -37,7 +40,11 @@ describe('--listTests flag', () => {
expect(status).toBe(0);
expect(() => JSON.parse(stdout)).not.toThrow();
expect(
JSON.stringify(JSON.parse(stdout).map(normalizePaths).sort()),
JSON.stringify(
JSON.parse(stdout)
.map(normalizePaths)
.sort(),
),
).toMatchSnapshot();
});
});
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -25,14 +25,14 @@
"debug": "^2.6.8",
"enzyme": "^2.8.2",
"eslint": "^4.2.0",
"eslint-config-prettier": "^2.3.0",
"eslint-config-prettier": "^2.4.0",
"eslint-plugin-babel": "^4.1.1",
"eslint-plugin-flowtype": "^2.35.0",
"eslint-plugin-import": "^2.6.0",
"eslint-plugin-jest": "^21.0.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-markdown": "^1.0.0-beta.6",
"eslint-plugin-prettier": "^2.1.2",
"eslint-plugin-prettier": "^2.2.0",
"eslint-plugin-react": "^7.1.0",
"eslint-plugin-relay": "0.0.8",
"eslint-plugin-unicorn": "^2.1.2",
Expand All @@ -55,7 +55,7 @@
"mkdirp": "^0.5.1",
"mocha": "^3.4.2",
"mock-fs": "^4.4.1",
"prettier": "^1.5.2",
"prettier": "^1.6.1",
"progress": "^1.1.8",
"react": "^15.4.2",
"react-addons-test-utils": "15.4.2",
Expand Down
Expand Up @@ -43,9 +43,12 @@ const initialize = ({

// Jest tests snapshotSerializers in order preceding built-in serializers.
// Therefore, add in reverse because the last added is the first tested.
config.snapshotSerializers.concat().reverse().forEach(path => {
addSerializer(localRequire(path));
});
config.snapshotSerializers
.concat()
.reverse()
.forEach(path => {
addSerializer(localRequire(path));
});

const {expand, updateSnapshot} = globalConfig;
const snapshotState = new SnapshotState(testPath, {expand, updateSnapshot});
Expand Down
Expand Up @@ -201,7 +201,10 @@ describe('Watch mode flows', () => {
stdin.emit(KEYS.P);
expect(pipe.write.mock.calls.join('\n')).toMatchSnapshot();

['p'].map(toHex).concat(KEYS.ENTER).forEach(key => stdin.emit(key));
['p']
.map(toHex)
.concat(KEYS.ENTER)
.forEach(key => stdin.emit(key));

pipe.write.mockReset();
stdin.emit(KEYS.P);
Expand All @@ -223,7 +226,10 @@ describe('Watch mode flows', () => {
stdin.emit(KEYS.T);
expect(pipe.write.mock.calls.join('\n')).toMatchSnapshot();

['t'].map(toHex).concat(KEYS.ENTER).forEach(key => stdin.emit(key));
['t']
.map(toHex)
.concat(KEYS.ENTER)
.forEach(key => stdin.emit(key));

pipe.write.mockReset();
stdin.emit(KEYS.T);
Expand Down
4 changes: 3 additions & 1 deletion packages/jest-cli/src/reporters/coverage_reporter.js
Expand Up @@ -202,7 +202,9 @@ class CoverageReporter extends BaseReporter {
}
};

return Promise.all(instrumentation).then(cleanup).catch(cleanup);
return Promise.all(instrumentation)
.then(cleanup)
.catch(cleanup);
}

_checkThreshold(globalConfig: GlobalConfig, map: CoverageMap) {
Expand Down
4 changes: 3 additions & 1 deletion packages/jest-config/src/reporter_validation_errors.js
Expand Up @@ -55,7 +55,9 @@ function createArrayReporterError(
` ${chalk.bold.green(getType(value))}\n` +
` Reporter configuration:\n` +
` ${chalk.bold.green(
JSON.stringify(arrayReporter, null, 2).split('\n').join('\n '),
JSON.stringify(arrayReporter, null, 2)
.split('\n')
.join('\n '),
)}`;

return new ValidationError(ERROR, errorMessage, DOCUMENTATION_NOTE);
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-diff/src/diff_strings.js
Expand Up @@ -238,8 +238,8 @@ const formatHunks = (
const oldLinesCount = (a.match(/\n/g) || []).length;

return {
diff: structuredPatch('', '', a, b, '', '', options).hunks
.map((hunk: Hunk) => {
diff: structuredPatch('', '', a, b, '', '', options)
.hunks.map((hunk: Hunk) => {
// Hunk properties are one-based but index args are zero-based.
const getOriginal =
getter && getter(hunk.oldStart - 1, hunk.newStart - 1);
Expand Down
5 changes: 4 additions & 1 deletion packages/jest-editor-support/src/Runner.js
Expand Up @@ -56,7 +56,10 @@ module.exports = class Runner extends EventEmitter {
this.debugprocess.stdout.on('data', (data: Buffer) => {
// Make jest save to a file, otherwise we get chunked data
// and it can be hard to put it back together.
const stringValue = data.toString().replace(/\n$/, '').trim();
const stringValue = data
.toString()
.replace(/\n$/, '')
.trim();
if (stringValue.startsWith('Test results written to')) {
readFile(this.outputPath, 'utf8', (err, data) => {
if (err) {
Expand Down
5 changes: 4 additions & 1 deletion packages/jest-haste-map/src/crawlers/node.js
Expand Up @@ -99,7 +99,10 @@ function findNative(
child.stdout.on('data', data => (stdout += data));

child.stdout.on('close', () => {
const lines = stdout.trim().split('\n').filter(x => !ignore(x));
const lines = stdout
.trim()
.split('\n')
.filter(x => !ignore(x));
const result = [];
let count = lines.length;
if (!count) {
Expand Down
9 changes: 6 additions & 3 deletions packages/jest-jasmine2/src/setup_jest_globals.js
Expand Up @@ -93,9 +93,12 @@ module.exports = ({
}: SetupOptions) => {
// Jest tests snapshotSerializers in order preceding built-in serializers.
// Therefore, add in reverse because the last added is the first tested.
config.snapshotSerializers.concat().reverse().forEach(path => {
addSerializer(localRequire(path));
});
config.snapshotSerializers
.concat()
.reverse()
.forEach(path => {
addSerializer(localRequire(path));
});
patchJasmine();
const {expand, updateSnapshot} = globalConfig;
const snapshotState = new SnapshotState(testPath, {expand, updateSnapshot});
Expand Down
5 changes: 4 additions & 1 deletion packages/jest-message-util/src/index.js
Expand Up @@ -78,7 +78,10 @@ const formatExecError = (
message = separated.message;
}

message = message.split(/\n/).map(line => MESSAGE_INDENT + line).join('\n');
message = message
.split(/\n/)
.map(line => MESSAGE_INDENT + line)
.join('\n');
stack =
stack && !options.noStackTrace
? '\n' + formatStackTrace(stack, config, options, testPath)
Expand Down
10 changes: 8 additions & 2 deletions packages/jest-runtime/src/script_transformer.js
Expand Up @@ -365,7 +365,10 @@ const stripShebang = content => {
* could get corrupted, out-of-sync, etc.
*/
function writeCodeCacheFile(cachePath: Path, code: string) {
const checksum = crypto.createHash('md5').update(code).digest('hex');
const checksum = crypto
.createHash('md5')
.update(code)
.digest('hex');
writeCacheFile(cachePath, checksum + '\n' + code);
}

Expand All @@ -381,7 +384,10 @@ function readCodeCacheFile(cachePath: Path): ?string {
return null;
}
const code = content.substr(33);
const checksum = crypto.createHash('md5').update(code).digest('hex');
const checksum = crypto
.createHash('md5')
.update(code)
.digest('hex');
if (checksum === content.substr(0, 32)) {
return code;
}
Expand Down
5 changes: 4 additions & 1 deletion packages/jest-snapshot/src/__tests__/plugins.test.js
Expand Up @@ -19,7 +19,10 @@ const testPath = names => {

// Jest tests snapshotSerializers in order preceding built-in serializers.
// Therefore, add in reverse because the last added is the first tested.
added.concat().reverse().forEach(serializer => addSerializer(serializer));
added
.concat()
.reverse()
.forEach(serializer => addSerializer(serializer));

const next = getSerializers();
expect(next.length).toBe(added.length + prev.length);
Expand Down
5 changes: 4 additions & 1 deletion packages/jest-util/src/get_console_output.js
Expand Up @@ -19,7 +19,10 @@ module.exports = (root: string, verbose: boolean, buffer: ConsoleBuffer) => {

return buffer.reduce((output, {type, message, origin}) => {
origin = path.relative(root, origin);
message = message.split(/\n/).map(line => CONSOLE_INDENT + line).join('\n');
message = message
.split(/\n/)
.map(line => CONSOLE_INDENT + line)
.join('\n');

let typeMessage = 'console.' + type;
if (type === 'warn') {
Expand Down
4 changes: 3 additions & 1 deletion packages/pretty-format/src/plugins/react_element.js
Expand Up @@ -55,7 +55,9 @@ export const serialize = (
: printElement(
getType(element),
printProps(
Object.keys(element.props).filter(key => key !== 'children').sort(),
Object.keys(element.props)
.filter(key => key !== 'children')
.sort(),
element.props,
config,
indentation + config.indent,
Expand Down
5 changes: 4 additions & 1 deletion scripts/build.js
Expand Up @@ -56,7 +56,10 @@ const adjustToTerminalWidth = str => {
if (lastString.length < WIDTH) {
lastString += Array(WIDTH - lastString.length).join(chalk.dim('.'));
}
return strs.slice(0, -1).concat(lastString).join('\n');
return strs
.slice(0, -1)
.concat(lastString)
.join('\n');
};

function getPackageName(file) {
Expand Down

0 comments on commit 0cb03f6

Please sign in to comment.