Fix lint warnings in JSTransformer

Summary: Fix lint warnings throughout JSTransformer.

Reviewed By: bestander

Differential Revision: D4148161

fbshipit-source-id: ac73a9e3919b1c66fef0e447083b44039900f963
This commit is contained in:
Ovidiu Viorel Iepure 2016-11-09 09:18:25 -08:00 коммит произвёл Facebook Github Bot
Родитель 39798ae368
Коммит 8e803643ec
3 изменённых файлов: 15 добавлений и 14 удалений

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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