Lint vendor/fbtransform as well

This commit is contained in:
Paul O’Shannessy 2015-02-19 15:23:29 -08:00
parent 02d225f26e
commit e830cea050
9 changed files with 41 additions and 16 deletions

View File

@ -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

View File

@ -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');

9
vendor/fbtransform/.eslintrc vendored Normal file
View File

@ -0,0 +1,9 @@
---
globals:
describe: true
expect: true
it: true
jest: true
rules:
no-process-exit: 0

View File

@ -8,7 +8,7 @@
*
* @emails react-core
*/
"use strict";
'use strict';
require('mock-modules').autoMockOff();

View File

@ -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(
@ -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()
@ -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() {
@ -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});
});
});

View File

@ -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');

View File

@ -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');
@ -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 :
@ -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);
}
}

View File

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

View File

@ -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');