@samitouri / QOS-React-2 / commits / e830cea050

Lint vendor/fbtransform as well

Paul O’Shannessy committed Feb 19, 2015 at 15:23 UTC e830cea05096b07c5096b935d10ed0b839407071
9 files changed +41 -16
.eslintignore
+2
@@ -7,3 +7,5 @@ src/**/__tests__/**
7 # This should be enabled but that folder has too much in it that doesn't belong
8 src/test
9 test/the-files-to-test.generated.js
10 +# This is synced with a different file internally, don't want to lint it yet
11 +vendor/fbtransform/syntax.js
grunt/tasks/eslint.js
+9 -1
@@ -6,7 +6,15 @@ module.exports = function() {
6 var done = this.async();
7 grunt.util.spawn({
8 cmd: 'node_modules/.bin/eslint',
9 - args: ['src/', 'Gruntfile.js', 'grunt/', 'main.js', 'perf/', 'test/']
9 + args: [
10 + 'src/',
11 + 'Gruntfile.js',
12 + 'grunt/',
13 + 'main.js',
14 + 'perf/',
15 + 'test/',
16 + 'vendor/fbtransform'
17 + ]
18 }, function(err, result, code) {
19 if (err) {
20 grunt.log.error('Lint failed');
vendor/fbtransform/.eslintrc new
+9
@@ -0,0 +1,9 @@
1 +---
2 +globals:
3 + describe: true
4 + expect: true
5 + it: true
6 + jest: true
7 +
8 +rules:
9 + no-process-exit: 0
vendor/fbtransform/transforms/__tests__/react-displayName-test.js
+1 -1
@@ -8,7 +8,7 @@
8 *
9 * @emails react-core
10 */
11 -"use strict";
11 +'use strict';
12
13 require('mock-modules').autoMockOff();
14
vendor/fbtransform/transforms/__tests__/react-test.js
+9 -6
@@ -11,13 +11,12 @@
11
12 /*jshint evil:true, unused:false*/
13
14 -"use strict";
14 +'use strict';
15
16 require('mock-modules').autoMockOff();
17
18 describe('react jsx', function() {
19 var transformAll = require('../../syntax.js').transformAll;
20 - var xjs = require('../xjs.js');
20
21 var transform = function(code, options, excludes) {
22 return transformAll(
@@ -34,13 +33,15 @@ describe('react jsx', function() {
33 var z = 345678;
34
35 var expectObjectAssign = function(code) {
36 + /*eslint-disable no-unused-vars, no-eval*/
37 var Component = jest.genMockFunction();
38 var Child = jest.genMockFunction();
39 var objectAssignMock = jest.genMockFunction();
40 React.__spread = objectAssignMock;
41 eval(transform(code).code);
42 return expect(objectAssignMock);
43 - }
43 + /*eslint-enable*/
44 + };
45
46 var React = {
47 createElement: jest.genMockFunction()
@@ -338,7 +339,9 @@ describe('react jsx', function() {
339
340 it('should not throw for unknown hyphenated tags', function() {
341 var code = '<x-component />;';
341 - expect(function() {transform(code);}).not.toThrow();
342 + expect(function() {
343 + transform(code);
344 + }).not.toThrow();
345 });
346
347 it('calls assign with a new target object for spreads', function() {
@@ -368,13 +371,13 @@ describe('react jsx', function() {
371 it('passes the same value multiple times to React.__spread', function() {
372 expectObjectAssign(
373 '<Component x={1} y="2" {...z} {...z}><Child /></Component>'
371 - ).toBeCalledWith({x: 1, y: "2"}, z, z);
374 + ).toBeCalledWith({x: 1, y: '2'}, z, z);
375 });
376
377 it('evaluates sequences before passing them to React.__spread', function() {
378 expectObjectAssign(
379 '<Component x="1" {...(z = { y: 2 }, z)} z={3}>Text</Component>'
377 - ).toBeCalledWith({x: "1"}, {y: 2}, {z: 3});
380 + ).toBeCalledWith({x: '1'}, {y: 2}, {z: 3});
381 });
382
383 });
vendor/fbtransform/transforms/react.js
+1 -1
@@ -7,7 +7,7 @@
7 * of patent rights can be found in the PATENTS file in the same directory.
8 */
9 /*global exports:true*/
10 -"use strict";
10 +'use strict';
11
12 var Syntax = require('jstransform').Syntax;
13 var utils = require('jstransform/src/utils');
vendor/fbtransform/transforms/reactDisplayName.js
+5 -5
@@ -7,7 +7,7 @@
7 * of patent rights can be found in the PATENTS file in the same directory.
8 */
9 /*global exports:true*/
10 -"use strict";
10 +'use strict';
11
12 var Syntax = require('jstransform').Syntax;
13 var utils = require('jstransform/src/utils');
@@ -20,10 +20,10 @@ function addDisplayName(displayName, object, state) {
20 object.callee.object.name === 'React' &&
21 object.callee.property.type === Syntax.Identifier &&
22 object.callee.property.name === 'createClass' &&
23 - object['arguments'].length === 1 &&
24 - object['arguments'][0].type === Syntax.ObjectExpression) {
23 + object.arguments.length === 1 &&
24 + object.arguments[0].type === Syntax.ObjectExpression) {
25 // Verify that the displayName property isn't already set
26 - var properties = object['arguments'][0].properties;
26 + var properties = object.arguments[0].properties;
27 var safe = properties.every(function(property) {
28 var value = property.key.type === Syntax.Identifier ?
29 property.key.name :
@@ -32,7 +32,7 @@ function addDisplayName(displayName, object, state) {
32 });
33
34 if (safe) {
35 - utils.catchup(object['arguments'][0].range[0] + 1, state);
35 + utils.catchup(object.arguments[0].range[0] + 1, state);
36 utils.append('displayName: "' + displayName + '",', state);
37 }
38 }
vendor/fbtransform/transforms/xjs.js
+2 -2
@@ -7,7 +7,7 @@
7 * of patent rights can be found in the PATENTS file in the same directory.
8 */
9 /*global exports:true*/
10 -"use strict";
10 +'use strict';
11 var Syntax = require('jstransform').Syntax;
12 var utils = require('jstransform/src/utils');
13
@@ -49,7 +49,7 @@ function renderXJSLiteral(object, isLast, state, start, end) {
49 if (trimmedLine || isLastNonEmptyLine) {
50 utils.append(
51 JSON.stringify(trimmedLine) +
52 - (!isLastNonEmptyLine ? " + ' ' +" : ''),
52 + (!isLastNonEmptyLine ? ' + \' \' +' : ''),
53 state);
54
55 if (isLastNonEmptyLine) {
vendor/fbtransform/visitors.js
+3
@@ -1,4 +1,7 @@
1 /*global exports:true*/
2 +
3 +'use strict';
4 +
5 var es6ArrowFunctions = require('jstransform/visitors/es6-arrow-function-visitors');
6 var es6Classes = require('jstransform/visitors/es6-class-visitors');
7 var es6Destructuring = require('jstransform/visitors/es6-destructuring-visitors');