Skip to content

Commit

Permalink
Resolve issues relating to 4-spaces, add crowdin-cli (jestjs#3369)
Browse files Browse the repository at this point in the history
Adding additional settings to prettier.js to catch unformatted files in packages/*

Running 'yarn prettier'
  • Loading branch information
ericnakagawa authored and cpojer committed Apr 26, 2017
1 parent 82cbd76 commit 02879c4
Show file tree
Hide file tree
Showing 38 changed files with 301 additions and 272 deletions.
2 changes: 1 addition & 1 deletion examples/async/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function request(url) {
// This module is being mocked in __mocks__/request.js
http.get({path: url}, response => {
let data = '';
response.on('data', _data => data += _data);
response.on('data', _data => (data += _data));
response.on('end', () => resolve(data));
});
});
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/resolve/__tests__/resolve-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
let platform;

function testRequire(filename) {
return () => platform = require(filename);
return () => (platform = require(filename));
}

test('should explicitly resolve filename.<platform>.js', () => {
Expand Down
4 changes: 3 additions & 1 deletion packages/babel-jest/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ const getBabelRC = (filename, {useCache}) => {
// $FlowFixMe
const packageJsonFileContents = require(packageJsonFilePath);
if (packageJsonFileContents[BABEL_CONFIG_KEY]) {
cache[directory] = JSON.stringify(packageJsonFileContents[BABEL_CONFIG_KEY]);
cache[directory] = JSON.stringify(
packageJsonFileContents[BABEL_CONFIG_KEY],
);
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-jest-hoist/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const WHITELISTED_IDENTIFIERS = {
require: true,
undefined: true,
};
Object.keys(global).forEach(name => WHITELISTED_IDENTIFIERS[name] = true);
Object.keys(global).forEach(name => (WHITELISTED_IDENTIFIERS[name] = true));

const JEST_GLOBAL = {name: 'jest'};
const IDVisitor = {
Expand Down
3 changes: 2 additions & 1 deletion packages/eslint-plugin-jest/src/rules/no-disabled-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ module.exports = (context: EslintContext) => ({
}

if (
callee.type === 'MemberExpression' && isCallToTestSkipFunction(callee)
callee.type === 'MemberExpression' &&
isCallToTestSkipFunction(callee)
) {
context.report({
message: 'Unexpected disabled test.',
Expand Down
3 changes: 2 additions & 1 deletion packages/eslint-plugin-jest/src/rules/no-focused-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ module.exports = (context: EslintContext) => ({
}

if (
callee.type === 'MemberExpression' && isCallToTestOnlyFunction(callee)
callee.type === 'MemberExpression' &&
isCallToTestOnlyFunction(callee)
) {
context.report({
message: 'Unexpected focused test.',
Expand Down
6 changes: 3 additions & 3 deletions packages/jest-changed-files/src/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ function findChangedFiles(
const child = childProcess.spawn('git', args, {cwd});
let stdout = '';
let stderr = '';
child.stdout.on('data', data => stdout += data);
child.stderr.on('data', data => stderr += data);
child.stdout.on('data', data => (stdout += data));
child.stderr.on('data', data => (stderr += data));
child.on('error', e => reject(e));
child.on('close', code => {
if (code === 0) {
Expand All @@ -59,7 +59,7 @@ function isGitRepository(cwd: string): Promise<?string> {
let stdout = '';
const options = ['rev-parse', '--show-toplevel'];
const child = childProcess.spawn('git', options, {cwd});
child.stdout.on('data', data => stdout += data);
child.stdout.on('data', data => (stdout += data));
child.on('error', () => resolve(null));
child.on('close', code => resolve(code === 0 ? stdout.trim() : null));
} catch (e) {
Expand Down
6 changes: 3 additions & 3 deletions packages/jest-changed-files/src/hg.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ function findChangedFiles(cwd: string, options: Options): Promise<Array<Path>> {
const child = childProcess.spawn('hg', args, {cwd, env});
let stdout = '';
let stderr = '';
child.stdout.on('data', data => stdout += data);
child.stderr.on('data', data => stderr += data);
child.stdout.on('data', data => (stdout += data));
child.stderr.on('data', data => (stderr += data));
child.on('error', e => reject(e));
child.on('close', code => {
if (code === 0) {
Expand All @@ -62,7 +62,7 @@ function isHGRepository(cwd: string): Promise<?string> {
try {
let stdout = '';
const child = childProcess.spawn('hg', ['root'], {cwd, env});
child.stdout.on('data', data => stdout += data);
child.stdout.on('data', data => (stdout += data));
child.on('error', () => resolve(null));
child.on('close', code => resolve(code === 0 ? stdout.trim() : null));
} catch (e) {
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-cli/src/TestSequencer.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class TestSequencer {
cache[test.path] && cache[test.path][0] === FAIL;
const time = (cache, test) => cache[test.path] && cache[test.path][1];

tests.forEach(test => test.duration = time(this._getCache(test), test));
tests.forEach(test => (test.duration = time(this._getCache(test), test)));
return tests.sort((testA, testB) => {
const cacheA = this._getCache(testA);
const cacheB = this._getCache(testB);
Expand All @@ -87,7 +87,7 @@ class TestSequencer {

cacheResults(tests: Tests, results: AggregatedResult) {
const map = Object.create(null);
tests.forEach(test => map[test.path] = test);
tests.forEach(test => (map[test.path] = test));
results.testResults.forEach(testResult => {
if (testResult && map[testResult.testFilePath] && !testResult.skipped) {
const cache = this._getCache(map[testResult.testFilePath]);
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-cli/src/TestWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ module.exports = (
callback: WorkerCallback,
) => {
let parentExited = false;
const disconnectCallback = () => parentExited = true;
const disconnectCallback = () => (parentExited = true);
const removeListener = () =>
process.removeListener('disconnect', disconnectCallback);
process.on('disconnect', disconnectCallback);
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-cli/src/__tests__/TestRunner-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ let workerFarmMock;
jest.mock('worker-farm', () => {
const mock = jest.fn(
(options, worker) =>
workerFarmMock = jest.fn((data, callback) =>
(workerFarmMock = jest.fn((data, callback) =>
require(worker)(data, callback),
),
)),
);
mock.end = jest.fn();
return mock;
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-cli/src/runJest.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const TestSequencer = require('./TestSequencer');

const setConfig = (contexts, newConfig) =>
contexts.forEach(
context => context.config = Object.assign({}, context.config, newConfig),
context => (context.config = Object.assign({}, context.config, newConfig)),
);

const formatTestPathPattern = pattern => {
Expand Down
5 changes: 3 additions & 2 deletions packages/jest-config/src/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ const setupBabelJest = (config: InitialConfig) => {
{basedir},
);
if (
jsTransformer && jsTransformer.includes(NODE_MODULES + 'babel-jest')
jsTransformer &&
jsTransformer.includes(NODE_MODULES + 'babel-jest')
) {
babelJest = jsTransformer;
}
Expand Down Expand Up @@ -230,7 +231,7 @@ const normalizeArgv = (config: InitialConfig, argv: Object) => {
if (argv.collectCoverageOnlyFrom) {
const collectCoverageOnlyFrom = Object.create(null);
argv.collectCoverageOnlyFrom.forEach(
path => collectCoverageOnlyFrom[path] = true,
path => (collectCoverageOnlyFrom[path] = true),
);
config.collectCoverageOnlyFrom = collectCoverageOnlyFrom;
}
Expand Down
4 changes: 3 additions & 1 deletion packages/jest-config/src/vendor/jsonlint.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,9 @@ var jsonlint = (function() {

// handle parse error
_handle_error: if (
typeof action === 'undefined' || !action.length || !action[0]
typeof action === 'undefined' ||
!action.length ||
!action[0]
) {
if (!recovering) {
// Report error
Expand Down
3 changes: 2 additions & 1 deletion packages/jest-editor-support/src/parsers/BabylonParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ const parse = (file: string) => {
) {
searchNodes(element.expression.right.body, file);
} else if (
element.type === 'ReturnStatement' && element.argument.arguments
element.type === 'ReturnStatement' &&
element.argument.arguments
) {
element.argument.arguments
.filter(argument => isFunctionDeclaration(argument.type))
Expand Down
Loading

0 comments on commit 02879c4

Please sign in to comment.