From b75dc61a4603a2414923616d18d2e38db7b26bfe Mon Sep 17 00:00:00 2001 From: Ovidiu Viorel Iepure Date: Wed, 9 Nov 2016 09:18:25 -0800 Subject: [PATCH] Fix lint warnings in JSTransformer Summary: Fix lint warnings throughout JSTransformer. Reviewed By: bestander Differential Revision: D4148161 fbshipit-source-id: ac73a9e3919b1c66fef0e447083b44039900f963 --- .../JSTransformer/__tests__/Transformer-test.js | 7 ++++--- .../worker/__tests__/constant-folding-test.js | 14 +++++++------- .../worker/__tests__/extract-dependencies-test.js | 8 ++++---- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/react-packager/src/JSTransformer/__tests__/Transformer-test.js b/react-packager/src/JSTransformer/__tests__/Transformer-test.js index c801bd7f..4689d7fb 100644 --- a/react-packager/src/JSTransformer/__tests__/Transformer-test.js +++ b/react-packager/src/JSTransformer/__tests__/Transformer-test.js @@ -39,12 +39,13 @@ describe('Transformer', function() { workerFarm.mockClear(); workerFarm.mockImpl((opts, path, methods) => { const api = workers = {}; - methods.forEach(method => api[method] = jest.fn()); + methods.forEach(method => {api[method] = jest.fn();}); return api; }); }); - it('passes transform module path, file path, source code, and options to the worker farm when transforming', () => { + it('passes transform module path, file path, source code,' + + ' and options to the worker farm when transforming', () => { const transformOptions = {arbitrary: 'options'}; const code = 'arbitrary(code)'; new Transformer(options).transformFile(fileName, code, transformOptions, transformCacheKey); @@ -64,7 +65,7 @@ describe('Transformer', function() { var snippet = 'snippet'; workers.transformAndExtractDependencies.mockImpl( - function(transformPath, filename, code, options, transformCacheKey, callback) { + function(transformPath, filename, code, opts, transfCacheKey, callback) { var babelError = new SyntaxError(message); babelError.type = 'SyntaxError'; babelError.description = message; diff --git a/react-packager/src/JSTransformer/worker/__tests__/constant-folding-test.js b/react-packager/src/JSTransformer/worker/__tests__/constant-folding-test.js index c717e6d0..b1899fca 100644 --- a/react-packager/src/JSTransformer/worker/__tests__/constant-folding-test.js +++ b/react-packager/src/JSTransformer/worker/__tests__/constant-folding-test.js @@ -40,7 +40,7 @@ describe('constant expressions', () => { f() ? g() : h() );`; expect(normalize(constantFolding('arbitrary.js', parse(code)))) - .toEqual(`a(true,true,2,true,{},{a:1},c,f()?g():h());`); + .toEqual('a(true,true,2,true,{},{a:1},c,f()?g():h());'); }); it('can optimize ternary expressions with constant conditions', () => { @@ -50,7 +50,7 @@ describe('constant expressions', () => { ? ('production' != 'production' ? 'a' : 'A') : 'i';`; expect(normalize(constantFolding('arbitrary.js', parse(code)))) - .toEqual(`var a=1;var b='A';`); + .toEqual('var a=1;var b=\'A\';'); }); it('can optimize logical operator expressions with constant conditions', () => { @@ -59,7 +59,7 @@ describe('constant expressions', () => { var b = 'android' == 'android' && 'production' != 'production' || null || "A";`; expect(normalize(constantFolding('arbitrary.js', parse(code)))) - .toEqual(`var a=true;var b="A";`); + .toEqual('var a=true;var b="A";'); }); it('can optimize logical operators with partly constant operands', () => { @@ -71,7 +71,7 @@ describe('constant expressions', () => { var e = !1 && z(); `; expect(normalize(constantFolding('arbitrary.js', parse(code)))) - .toEqual(`var a="truthy";var b=z();var c=null;var d=z();var e=false;`); + .toEqual('var a="truthy";var b=z();var c=null;var d=z();var e=false;'); }); it('can remode an if statement with a falsy constant test', () => { @@ -81,7 +81,7 @@ describe('constant expressions', () => { } `; expect(normalize(constantFolding('arbitrary.js', parse(code)))) - .toEqual(``); + .toEqual(''); }); it('can optimize if-else-branches with constant conditions', () => { @@ -97,7 +97,7 @@ describe('constant expressions', () => { } `; expect(normalize(constantFolding('arbitrary.js', parse(code)))) - .toEqual(`{var a=3;var b=a+4;}`); + .toEqual('{var a=3;var b=a+4;}'); }); it('can optimize nested if-else constructs', () => { @@ -117,6 +117,6 @@ describe('constant expressions', () => { } `; expect(normalize(constantFolding('arbitrary.js', parse(code)))) - .toEqual(`{{require('c');}}`); + .toEqual('{{require(\'c\');}}'); }); }); diff --git a/react-packager/src/JSTransformer/worker/__tests__/extract-dependencies-test.js b/react-packager/src/JSTransformer/worker/__tests__/extract-dependencies-test.js index 1d78e73a..998ee7da 100644 --- a/react-packager/src/JSTransformer/worker/__tests__/extract-dependencies-test.js +++ b/react-packager/src/JSTransformer/worker/__tests__/extract-dependencies-test.js @@ -78,7 +78,7 @@ describe('Dependency extraction:', () => { }); it('does not extract calls to function with names that start with "require"', () => { - const code = `arbitraryrequire('foo');`; + const code = 'arbitraryrequire(\'foo\');'; const {dependencies, dependencyOffsets} = extractDependencies(code); expect(dependencies).toEqual([]); @@ -86,7 +86,7 @@ describe('Dependency extraction:', () => { }); it('does not extract calls to require with non-static arguments', () => { - const code = `require('foo/' + bar)`; + const code = 'require(\'foo/\' + bar)'; const {dependencies, dependencyOffsets} = extractDependencies(code); expect(dependencies).toEqual([]); @@ -95,7 +95,7 @@ describe('Dependency extraction:', () => { it('does not get confused by previous states', () => { // yes, this was a bug - const code = `require("a");/* a comment */ var a = /[a]/.test('a');`; + const code = 'require("a");/* a comment */ var a = /[a]/.test(\'a\');'; const {dependencies, dependencyOffsets} = extractDependencies(code); expect(dependencies).toEqual(['a']); @@ -103,7 +103,7 @@ describe('Dependency extraction:', () => { }); it('can handle regular expressions', () => { - const code = `require('a'); /["']/.test('foo'); require("b");`; + const code = 'require(\'a\'); /["\']/.test(\'foo\'); require("b");'; const {dependencies, dependencyOffsets} = extractDependencies(code); expect(dependencies).toEqual(['a', 'b']);