Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint vendor/fbtransform as well #3206

Merged
merged 1 commit into from
Feb 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ src/**/__tests__/**
# This should be enabled but that folder has too much in it that doesn't belong
src/test
test/the-files-to-test.generated.js
# This is synced with a different file internally, don't want to lint it yet
vendor/fbtransform/syntax.js
10 changes: 9 additions & 1 deletion grunt/tasks/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ module.exports = function() {
var done = this.async();
grunt.util.spawn({
cmd: 'node_modules/.bin/eslint',
args: ['src/', 'Gruntfile.js', 'grunt/', 'main.js', 'perf/', 'test/']
args: [
'src/',
'Gruntfile.js',
'grunt/',
'main.js',
'perf/',
'test/',
'vendor/fbtransform'
]
}, function(err, result, code) {
if (err) {
grunt.log.error('Lint failed');
Expand Down
9 changes: 9 additions & 0 deletions vendor/fbtransform/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
globals:
describe: true
expect: true
it: true
jest: true

rules:
no-process-exit: 0
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*
* @emails react-core
*/
"use strict";
'use strict';

require('mock-modules').autoMockOff();

Expand Down
15 changes: 9 additions & 6 deletions vendor/fbtransform/transforms/__tests__/react-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@

/*jshint evil:true, unused:false*/

"use strict";
'use strict';

require('mock-modules').autoMockOff();

describe('react jsx', function() {
var transformAll = require('../../syntax.js').transformAll;
var xjs = require('../xjs.js');

var transform = function(code, options, excludes) {
return transformAll(
Expand All @@ -34,13 +33,15 @@ describe('react jsx', function() {
var z = 345678;

var expectObjectAssign = function(code) {
/*eslint-disable no-unused-vars, no-eval*/
var Component = jest.genMockFunction();
var Child = jest.genMockFunction();
var objectAssignMock = jest.genMockFunction();
React.__spread = objectAssignMock;
eval(transform(code).code);
return expect(objectAssignMock);
}
/*eslint-enable*/
};

var React = {
createElement: jest.genMockFunction()
Expand Down Expand Up @@ -338,7 +339,9 @@ describe('react jsx', function() {

it('should not throw for unknown hyphenated tags', function() {
var code = '<x-component />;';
expect(function() {transform(code);}).not.toThrow();
expect(function() {
transform(code);
}).not.toThrow();
});

it('calls assign with a new target object for spreads', function() {
Expand Down Expand Up @@ -368,13 +371,13 @@ describe('react jsx', function() {
it('passes the same value multiple times to React.__spread', function() {
expectObjectAssign(
'<Component x={1} y="2" {...z} {...z}><Child /></Component>'
).toBeCalledWith({x: 1, y: "2"}, z, z);
).toBeCalledWith({x: 1, y: '2'}, z, z);
});

it('evaluates sequences before passing them to React.__spread', function() {
expectObjectAssign(
'<Component x="1" {...(z = { y: 2 }, z)} z={3}>Text</Component>'
).toBeCalledWith({x: "1"}, {y: 2}, {z: 3});
).toBeCalledWith({x: '1'}, {y: 2}, {z: 3});
});

});
2 changes: 1 addition & 1 deletion vendor/fbtransform/transforms/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
/*global exports:true*/
"use strict";
'use strict';

var Syntax = require('jstransform').Syntax;
var utils = require('jstransform/src/utils');
Expand Down
10 changes: 5 additions & 5 deletions vendor/fbtransform/transforms/reactDisplayName.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
/*global exports:true*/
"use strict";
'use strict';

var Syntax = require('jstransform').Syntax;
var utils = require('jstransform/src/utils');
Expand All @@ -20,10 +20,10 @@ function addDisplayName(displayName, object, state) {
object.callee.object.name === 'React' &&
object.callee.property.type === Syntax.Identifier &&
object.callee.property.name === 'createClass' &&
object['arguments'].length === 1 &&
object['arguments'][0].type === Syntax.ObjectExpression) {
object.arguments.length === 1 &&
object.arguments[0].type === Syntax.ObjectExpression) {
// Verify that the displayName property isn't already set
var properties = object['arguments'][0].properties;
var properties = object.arguments[0].properties;
var safe = properties.every(function(property) {
var value = property.key.type === Syntax.Identifier ?
property.key.name :
Expand All @@ -32,7 +32,7 @@ function addDisplayName(displayName, object, state) {
});

if (safe) {
utils.catchup(object['arguments'][0].range[0] + 1, state);
utils.catchup(object.arguments[0].range[0] + 1, state);
utils.append('displayName: "' + displayName + '",', state);
}
}
Expand Down
4 changes: 2 additions & 2 deletions vendor/fbtransform/transforms/xjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
/*global exports:true*/
"use strict";
'use strict';
var Syntax = require('jstransform').Syntax;
var utils = require('jstransform/src/utils');

Expand Down Expand Up @@ -49,7 +49,7 @@ function renderXJSLiteral(object, isLast, state, start, end) {
if (trimmedLine || isLastNonEmptyLine) {
utils.append(
JSON.stringify(trimmedLine) +
(!isLastNonEmptyLine ? " + ' ' +" : ''),
(!isLastNonEmptyLine ? ' + \' \' +' : ''),
state);

if (isLastNonEmptyLine) {
Expand Down
3 changes: 3 additions & 0 deletions vendor/fbtransform/visitors.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/*global exports:true*/

'use strict';

var es6ArrowFunctions = require('jstransform/visitors/es6-arrow-function-visitors');
var es6Classes = require('jstransform/visitors/es6-class-visitors');
var es6Destructuring = require('jstransform/visitors/es6-destructuring-visitors');
Expand Down