Skip to content

Commit

Permalink
Revert D5409825: [RN] Convert easy files to Prettier
Browse files Browse the repository at this point in the history
Differential Revision: D5409825

fbshipit-source-id: f797a40b58bc6bcc6ae53ed820a10ab49d3f10f5
  • Loading branch information
elicwhite authored and facebook-github-bot committed Jul 13, 2017
1 parent bfece1d commit aafccdf
Show file tree
Hide file tree
Showing 27 changed files with 122 additions and 166 deletions.
22 changes: 9 additions & 13 deletions babel-preset/configs/hmr.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @format
*/
'use strict';

Expand All @@ -18,8 +16,8 @@ var transformPath = require.resolve(hmrTransform);

module.exports = function(options, filename) {
var transform = filename
? './' + path.relative(path.dirname(filename), transformPath) // packager can't handle absolute paths
: hmrTransform;
? './' + path.relative(path.dirname(filename), transformPath) // packager can't handle absolute paths
: hmrTransform;

// Fix the module path to use '/' on Windows.
if (path.sep === '\\') {
Expand All @@ -31,15 +29,13 @@ module.exports = function(options, filename) {
[
'react-transform',
{
transforms: [
{
transform: transform,
imports: ['react'],
locals: ['module'],
},
],
transforms: [{
transform: transform,
imports: ['react'],
locals: ['module'],
}]
},
],
]),
]
])
};
};
4 changes: 1 addition & 3 deletions babel-preset/configs/internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @format
*/
'use strict';

Expand All @@ -15,4 +13,4 @@ var resolvePlugins = require('../lib/resolvePlugins');
module.exports = function(options) {
// For future internal pipeline usage
return null;
};
}
12 changes: 4 additions & 8 deletions babel-preset/configs/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @format
*/
'use strict';

Expand All @@ -27,10 +25,7 @@ var base = {
'transform-es2015-computed-properties',
'check-es2015-constants',
'transform-es2015-destructuring',
[
'transform-es2015-modules-commonjs',
{strict: false, allowTopLevelThis: true},
],
['transform-es2015-modules-commonjs', { strict: false, allowTopLevelThis: true }],
'transform-es2015-parameters',
'transform-es2015-shorthand-properties',
'transform-es2015-spread',
Expand All @@ -42,17 +37,18 @@ var base = {
'transform-react-display-name',
'transform-react-jsx',
'transform-regenerator',
['transform-es2015-for-of', {loose: true}],
['transform-es2015-for-of', { loose: true }],
require('../transforms/transform-regenerator-runtime-insertion'),
require('../transforms/transform-symbol-member'),
]),
};

var devTools = Object.assign({}, base);
devTools.plugins = devTools.plugins.concat(
resolvePlugins(['transform-react-jsx-source']),
resolvePlugins(['transform-react-jsx-source'])
);


module.exports = function(options) {
var withDevTools = options.withDevTools;
if (withDevTools == null) {
Expand Down
2 changes: 0 additions & 2 deletions babel-preset/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @format
*/
'use strict';

Expand Down
2 changes: 0 additions & 2 deletions babel-preset/lib/resolvePlugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @format
*/
'use strict';

Expand Down
4 changes: 1 addition & 3 deletions babel-preset/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @format
*/
'use strict';

Expand All @@ -28,7 +26,7 @@ module.exports = {
'babel-plugin-transform-es2015-shorthand-properties': require('babel-plugin-transform-es2015-shorthand-properties'),
'babel-plugin-transform-es2015-spread': require('babel-plugin-transform-es2015-spread'),
'babel-plugin-transform-es2015-template-literals': require('babel-plugin-transform-es2015-template-literals'),
'babel-plugin-transform-es2015-literals': require('babel-plugin-transform-es2015-literals'),
'babel-plugin-transform-es2015-literals' : require('babel-plugin-transform-es2015-literals'),
'babel-plugin-transform-flow-strip-types': require('babel-plugin-transform-flow-strip-types'),
'babel-plugin-transform-object-assign': require('babel-plugin-transform-object-assign'),
'babel-plugin-transform-object-rest-spread': require('babel-plugin-transform-object-rest-spread'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
* @format
*/

'use strict';
Expand Down Expand Up @@ -100,9 +98,9 @@ module.exports = function() {
t.identifier('regeneratorRuntime'),
t.callExpression(t.identifier('require'), [
t.stringLiteral(NAME),
]),
),
]),
])
)
])
);
}
},
Expand Down
20 changes: 10 additions & 10 deletions babel-preset/transforms/transform-symbol-member.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/**
* Copyright 2004-present Facebook. All Rights Reserved.
*
* @format
*/

'use strict';
Expand Down Expand Up @@ -36,12 +34,16 @@ module.exports = function symbolMember(babel) {
t.conditionalExpression(
t.binaryExpression(
'===',
t.unaryExpression('typeof', t.identifier('Symbol'), true),
t.stringLiteral('function'),
t.unaryExpression(
'typeof',
t.identifier('Symbol'),
true
),
t.stringLiteral('function')
),
node,
t.stringLiteral(`@@${node.property.name}`),
),
t.stringLiteral(`@@${node.property.name}`)
)
);

// We should stop to avoid infinite recursion, since Babel
Expand All @@ -55,10 +57,8 @@ module.exports = function symbolMember(babel) {
function isAppropriateMember(path) {
let node = path.node;

return (
path.parentPath.type !== 'AssignmentExpression' &&
return path.parentPath.type !== 'AssignmentExpression' &&
node.object.type === 'Identifier' &&
node.object.name === 'Symbol' &&
node.property.type === 'Identifier'
);
node.property.type === 'Identifier';
}
39 changes: 18 additions & 21 deletions bots/code-analysis-bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @format
*/
'use strict';

Expand All @@ -19,9 +17,7 @@ if (!process.env.CI_REPO) {
process.exit(1);
}
if (!process.env.GITHUB_TOKEN) {
console.error(
'Missing GITHUB_TOKEN. Example: 5fd88b964fa214c4be2b144dc5af5d486a2f8c1e',
);
console.error('Missing GITHUB_TOKEN. Example: 5fd88b964fa214c4be2b144dc5af5d486a2f8c1e');
process.exit(1);
}
if (!process.env.PULL_REQUEST_NUMBER) {
Expand Down Expand Up @@ -96,7 +92,7 @@ var converters = {
});
});
});
},
}
};

function getShaFromPullRequest(user, repo, number, callback) {
Expand Down Expand Up @@ -124,6 +120,7 @@ function getFilesFromCommit(user, repo, sha, callback) {
});
}


/**
* Sadly we can't just give the line number to github, we have to give the
* line number relative to the patch file which is super annoying. This
Expand All @@ -135,7 +132,7 @@ function getLineMapFromPatch(patchString) {
var fileLineIndex = 0;
var lineMap = {};

patchString.split('\n').forEach(line => {
patchString.split('\n').forEach((line) => {
if (line.match(/^@@/)) {
fileLineIndex = line.match(/\+([0-9]+)/)[1] - 1;
return;
Expand Down Expand Up @@ -184,27 +181,27 @@ function main(messages, user, repo, number) {
return;
}

getShaFromPullRequest(user, repo, number, sha => {
getFilesFromCommit(user, repo, sha, files => {
files.filter(file => messages[file.filename]).forEach(file => {
// github api sometimes does not return a patch on large commits
if (!file.patch) {
return;
}
var lineMap = getLineMapFromPatch(file.patch);
messages[file.filename].forEach(message => {
sendComment(user, repo, number, sha, file.filename, lineMap, message);
getShaFromPullRequest(user, repo, number, (sha) => {
getFilesFromCommit(user, repo, sha, (files) => {
files
.filter((file) => messages[file.filename])
.forEach((file) => {
// github api sometimes does not return a patch on large commits
if (!file.patch) {
return;
}
var lineMap = getLineMapFromPatch(file.patch);
messages[file.filename].forEach((message) => {
sendComment(user, repo, number, sha, file.filename, lineMap, message);
});
});
});
});
});
}

var content = '';
process.stdin.resume();
process.stdin.on('data', function(buf) {
content += buf.toString();
});
process.stdin.on('data', function(buf) { content += buf.toString(); });
process.stdin.on('end', function() {
var messages = {};

Expand Down
2 changes: 0 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @format
*/
'use strict';

Expand Down
4 changes: 1 addition & 3 deletions jest/mockComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @format
*/
'use strict';

Expand All @@ -19,7 +17,7 @@ module.exports = moduleName => {
const name = RealComponent.displayName || RealComponent.name;

return React.createElement(
name.replace(/^(RCT|RK)/, ''),
name.replace(/^(RCT|RK)/,''),
this.props,
this.props.children,
);
Expand Down
18 changes: 11 additions & 7 deletions jest/preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @format
* @flow
*/

/* eslint-env node */
Expand All @@ -17,18 +17,22 @@ const babel = require('babel-core');
const babelRegisterOnly = require('metro-bundler/src/babelRegisterOnly');
const createCacheKeyFunction = require('fbjs-scripts/jest/createCacheKeyFunction');

const nodeFiles = RegExp(['/local-cli/', '/metro-bundler/'].join('|'));
const nodeFiles = RegExp([
'/local-cli/',
'/metro-bundler/',
].join('|'));
const nodeOptions = babelRegisterOnly.config([nodeFiles]);

babelRegisterOnly([]);

const transformer = require('metro-bundler/src/transformer.js');
module.exports = {
process(src, file) {
if (nodeFiles.test(file)) {
// node specific transforms only
return babel.transform(src, Object.assign({filename: file}, nodeOptions))
.code;
process(src/*: string*/, file/*: string*/) {
if (nodeFiles.test(file)) { // node specific transforms only
return babel.transform(
src,
Object.assign({filename: file}, nodeOptions)
).code;
}

return transformer.transform({
Expand Down
Loading

0 comments on commit aafccdf

Please sign in to comment.