Fix lint errors

Reviewed By: davidaurelio

Differential Revision: D2628366

fb-gh-sync-id: 8d849e2deb038842475e66ef641fa1d4f7b78d8f
This commit is contained in:
Christoph Pojer 2015-11-09 13:32:47 -08:00 committed by facebook-github-bot-7
parent b4fb6c2f61
commit 8c59866b69
9 changed files with 190 additions and 192 deletions

View File

@ -22,7 +22,7 @@ class DeprecatedAssetMap {
fileWatcher,
ignoreFilePath,
helpers,
activity
activity,
}) {
if (roots == null || roots.length === 0) {
this._disabled = true;
@ -85,9 +85,9 @@ class DeprecatedAssetMap {
}
_processAsset(file) {
let ext = this._helpers.extname(file);
const ext = this._helpers.extname(file);
if (this._assetExts.indexOf(ext) !== -1) {
let name = assetName(file, ext);
const name = assetName(file, ext);
if (this._map[name] != null) {
debug('Conflcting assets', name);
}

View File

@ -25,12 +25,12 @@ class HasteMap {
this._map = Object.create(null);
let promises = this._fastfs.findFilesByExt('js', {
ignore: (file) => this._helpers.isNodeModulesDir(file)
ignore: (file) => this._helpers.isNodeModulesDir(file),
}).map(file => this._processHasteModule(file));
promises = promises.concat(
this._fastfs.findFilesByName('package.json', {
ignore: (file) => this._helpers.isNodeModulesDir(file)
ignore: (file) => this._helpers.isNodeModulesDir(file),
}).map(file => this._processHastePackage(file))
);
@ -41,9 +41,9 @@ class HasteMap {
return Promise.resolve().then(() => {
/*eslint no-labels: 0 */
if (type === 'delete' || type === 'change') {
loop: for (let name in this._map) {
loop: for (const name in this._map) {
const modulesMap = this._map[name];
for (let platform in modulesMap) {
for (const platform in modulesMap) {
const module = modulesMap[platform];
if (module.path === absPath) {
delete modulesMap[platform];
@ -53,7 +53,7 @@ class HasteMap {
}
if (type === 'delete') {
return;
return null;
}
}

View File

@ -48,7 +48,7 @@ describe('DependencyGraph', function() {
on: function() {
return this;
},
isWatchman: () => Promise.resolve(false)
isWatchman: () => Promise.resolve(false),
};
defaults = {
@ -78,14 +78,14 @@ describe('DependencyGraph', function() {
'/**',
' * @providesModule index',
' */',
'require("a")'
'require("a")',
].join('\n'),
'a.js': [
'/**',
' * @providesModule a',
' */',
].join('\n'),
}
},
});
var dgraph = new DependencyGraph({
@ -104,7 +104,7 @@ describe('DependencyGraph', function() {
isJSON: false,
isPolyfill: false,
resolution: undefined,
resolveDependency: undefined
resolveDependency: undefined,
},
{
id: 'a',
@ -115,7 +115,7 @@ describe('DependencyGraph', function() {
isJSON: false,
isPolyfill: false,
resolution: undefined,
resolveDependency: undefined
resolveDependency: undefined,
},
]);
});
@ -129,7 +129,7 @@ describe('DependencyGraph', function() {
'/**',
' * @providesModule index',
' */',
'require("a")'
'require("a")',
].join('\n'),
'a.js': [
'/**',
@ -141,7 +141,7 @@ describe('DependencyGraph', function() {
' * @providesModule a',
' */',
].join('\n'),
}
},
});
var dgraph = new DependencyGraph({
@ -180,18 +180,18 @@ describe('DependencyGraph', function() {
fs.__setMockFilesystem({
'root': {
'package.json': JSON.stringify({
name: 'package'
name: 'package',
}),
'index.js': [
'/**',
' * @providesModule index',
' */',
'require("./a.json")',
'require("./b")'
'require("./b")',
].join('\n'),
'a.json': JSON.stringify({}),
'b.json': JSON.stringify({}),
}
},
});
var dgraph = new DependencyGraph({
@ -240,7 +240,7 @@ describe('DependencyGraph', function() {
fs.__setMockFilesystem({
'root': {
'package.json': JSON.stringify({
name: 'package'
name: 'package',
}),
'index.js': [
'/**',
@ -248,7 +248,7 @@ describe('DependencyGraph', function() {
' */',
'require("./package.json")',
].join('\n'),
}
},
});
var dgraph = new DependencyGraph({
@ -290,12 +290,12 @@ describe('DependencyGraph', function() {
'/**',
' * @providesModule index',
' */',
'require("image!a")'
'require("image!a")',
].join('\n'),
'imgs': {
'a.png': ''
'a.png': '',
},
},
}
});
var dgraph = new DependencyGraph({
@ -338,15 +338,15 @@ describe('DependencyGraph', function() {
'/**',
' * @providesModule index',
' */',
'require("./imgs/a.png")'
'require("./imgs/a.png")',
].join('\n'),
'imgs': {
'a.png': ''
'a.png': '',
},
'package.json': JSON.stringify({
name: 'rootPackage'
name: 'rootPackage',
}),
}
},
});
var dgraph = new DependencyGraph({
@ -399,9 +399,9 @@ describe('DependencyGraph', function() {
'c@2x.png': '',
},
'package.json': JSON.stringify({
name: 'rootPackage'
name: 'rootPackage',
}),
}
},
});
var dgraph = new DependencyGraph({
@ -478,9 +478,9 @@ describe('DependencyGraph', function() {
'c@2x.ios.png': '',
},
'package.json': JSON.stringify({
name: 'rootPackage'
name: 'rootPackage',
}),
}
},
});
var dgraph = new DependencyGraph({
@ -551,12 +551,12 @@ describe('DependencyGraph', function() {
'require("image!a")',
].join('\n'),
'imgs': {
'a.png': ''
'a.png': '',
},
'package.json': JSON.stringify({
name: 'rootPackage'
name: 'rootPackage',
}),
}
},
});
var dgraph = new DependencyGraph({
@ -617,7 +617,7 @@ describe('DependencyGraph', function() {
' */',
'require("index")',
].join('\n'),
}
},
});
var dgraph = new DependencyGraph({
@ -664,11 +664,11 @@ describe('DependencyGraph', function() {
'aPackage': {
'package.json': JSON.stringify({
name: 'aPackage',
main: 'main.js'
main: 'main.js',
}),
'main.js': 'lol'
}
}
'main.js': 'lol',
},
},
});
var dgraph = new DependencyGraph({
@ -715,11 +715,11 @@ describe('DependencyGraph', function() {
'aPackage': {
'package.json': JSON.stringify({
name: 'aPackage',
main: 'main.js'
main: 'main.js',
}),
'main.js': 'lol'
}
}
'main.js': 'lol',
},
},
});
var dgraph = new DependencyGraph({
@ -767,18 +767,18 @@ describe('DependencyGraph', function() {
'sha.js': {
'package.json': JSON.stringify({
name: 'sha.js',
main: 'main.js'
main: 'main.js',
}),
'main.js': 'lol'
'main.js': 'lol',
},
'x.y.z': {
'package.json': JSON.stringify({
name: 'x.y.z',
main: 'main.js'
main: 'main.js',
}),
'main.js': 'lol'
}
}
'main.js': 'lol',
},
},
});
var dgraph = new DependencyGraph({
@ -832,8 +832,8 @@ describe('DependencyGraph', function() {
name: 'aPackage',
}),
'index.js': 'lol',
}
}
},
},
});
var dgraph = new DependencyGraph({
@ -881,8 +881,8 @@ describe('DependencyGraph', function() {
' * @providesModule EpicModule',
' */',
].join('\n'),
}
}
},
},
});
var dgraph = new DependencyGraph({
@ -929,8 +929,8 @@ describe('DependencyGraph', function() {
lib: {
'index.js': 'lol',
},
}
}
},
},
});
var dgraph = new DependencyGraph({
@ -975,7 +975,7 @@ describe('DependencyGraph', function() {
lib: {
'index.js': 'lol',
},
}
},
});
var dgraph = new DependencyGraph({
@ -1024,7 +1024,7 @@ describe('DependencyGraph', function() {
'index.js': 'lol',
'main.js': 'lol',
},
}
},
});
var dgraph = new DependencyGraph({
@ -1069,9 +1069,9 @@ describe('DependencyGraph', function() {
].join('\n'),
'aPackage': {
'package.json': 'lol',
'main.js': 'lol'
}
}
'main.js': 'lol',
},
},
});
var dgraph = new DependencyGraph({
@ -1109,7 +1109,7 @@ describe('DependencyGraph', function() {
' * @providesModule index',
' */',
].join('\n'),
}
},
});
const _exit = process.exit;
@ -1140,8 +1140,8 @@ describe('DependencyGraph', function() {
' * @providesModule index',
' */',
'require("lolomg")',
].join('\n')
}
].join('\n'),
},
});
var dgraph = new DependencyGraph({
@ -1161,7 +1161,7 @@ describe('DependencyGraph', function() {
isPolyfill: false,
resolution: undefined,
resolveDependency: undefined,
}
},
]);
});
});
@ -1179,14 +1179,14 @@ describe('DependencyGraph', function() {
'aPackage': {
'package.json': JSON.stringify({
name: 'aPackage',
main: 'main.js'
main: 'main.js',
}),
'main.js': 'lol',
'subdir': {
'lolynot.js': 'lolynot'
}
}
}
'lolynot.js': 'lolynot',
},
},
},
});
var dgraph = new DependencyGraph({
@ -1228,12 +1228,12 @@ describe('DependencyGraph', function() {
'symlinkedPackage': {
'package.json': JSON.stringify({
name: 'aPackage',
main: 'main.js'
main: 'main.js',
}),
'main.js': 'lol',
'subdir': {
'lolynot.js': 'lolynot'
}
'lolynot.js': 'lolynot',
},
},
'root': {
'index.js': [
@ -1243,7 +1243,7 @@ describe('DependencyGraph', function() {
'require("aPackage/subdir/lolynot")',
].join('\n'),
'aPackage': { SYMLINK: '/symlinkedPackage' },
}
},
});
var dgraph = new DependencyGraph({
@ -1292,15 +1292,15 @@ describe('DependencyGraph', function() {
'aPackage': {
'package.json': JSON.stringify({
name: 'aPackage',
main: 'main.js'
main: 'main.js',
}),
'main.js': 'require("./subdir/lolynot")',
'subdir': {
'lolynot.js': 'require("../other")'
'lolynot.js': 'require("../other")',
},
'other.js': 'some code',
},
},
'other.js': 'some code'
}
}
});
var dgraph = new DependencyGraph({
@ -1376,8 +1376,8 @@ describe('DependencyGraph', function() {
}),
'main.js': 'some other code',
'client.js': 'some code',
}
}
},
},
});
var dgraph = new DependencyGraph({
@ -1431,8 +1431,8 @@ describe('DependencyGraph', function() {
}),
'main.js': 'some other code',
'client.js': 'some code',
}
}
},
},
});
var dgraph = new DependencyGraph({
@ -1486,8 +1486,8 @@ describe('DependencyGraph', function() {
}),
'main.js': 'some other code',
'client.js': 'some code',
}
}
},
},
});
var dgraph = new DependencyGraph({
@ -1541,8 +1541,8 @@ describe('DependencyGraph', function() {
}),
'main.js': 'some other code',
'client.js': 'some code',
}
}
},
},
});
var dgraph = new DependencyGraph({
@ -1611,8 +1611,8 @@ describe('DependencyGraph', function() {
},
'hello.js': 'hello',
'bye.js': 'bye',
}
}
},
},
});
var dgraph = new DependencyGraph({
@ -1697,7 +1697,7 @@ describe('DependencyGraph', function() {
name: 'aPackage',
browser: {
'node-package': 'browser-package',
}
},
}),
'index.js': 'require("node-package")',
'node-package': {
@ -1712,8 +1712,8 @@ describe('DependencyGraph', function() {
}),
'index.js': 'some browser code',
},
}
}
},
},
});
var dgraph = new DependencyGraph({
@ -1782,7 +1782,7 @@ describe('DependencyGraph', function() {
}),
'main.js': 'bar 1 module',
},
}
},
},
'bar': {
'package.json': JSON.stringify({
@ -1792,7 +1792,7 @@ describe('DependencyGraph', function() {
'main.js': 'bar 2 module',
},
},
}
},
});
var dgraph = new DependencyGraph({
@ -1867,12 +1867,12 @@ describe('DependencyGraph', function() {
'bar': {
'package.json': JSON.stringify({
name: 'bar',
main: 'main'
main: 'main',
}),
'main.ios.js': '',
},
},
}
},
});
var dgraph = new DependencyGraph({
@ -1943,7 +1943,7 @@ describe('DependencyGraph', function() {
'main.js': 'bar 1 module',
'lol.js': '',
},
}
},
},
'bar': {
'package.json': JSON.stringify({
@ -1953,7 +1953,7 @@ describe('DependencyGraph', function() {
'main.js': 'bar 2 module',
},
},
}
},
});
var dgraph = new DependencyGraph({
@ -2031,14 +2031,14 @@ describe('DependencyGraph', function() {
name: 'bar',
main: 'main.js',
browser: {
'./lol': './wow'
}
'./lol': './wow',
},
}),
'main.js': 'bar 1 module',
'lol.js': '',
'wow.js': '',
},
}
},
},
'bar': {
'package.json': JSON.stringify({
@ -2048,7 +2048,7 @@ describe('DependencyGraph', function() {
'main2.js': 'bar 2 module',
},
},
}
},
});
var dgraph = new DependencyGraph({
@ -2132,7 +2132,7 @@ describe('DependencyGraph', function() {
},
'node_modules': {},
},
}
},
});
var dgraph = new DependencyGraph({
@ -2220,7 +2220,7 @@ describe('DependencyGraph', function() {
}),
'main.js': 'log()',
},
}
},
},
'ember': {
'package.json': JSON.stringify({
@ -2235,7 +2235,7 @@ describe('DependencyGraph', function() {
].join('\n'),
},
},
}
},
});
var dgraph = new DependencyGraph({
@ -2302,7 +2302,7 @@ describe('DependencyGraph', function() {
].join('\n'),
},
},
}
},
});
var dgraph = new DependencyGraph({
@ -2357,7 +2357,7 @@ describe('DependencyGraph', function() {
'main.js': 'foo module',
},
},
}
},
});
var dgraph = new DependencyGraph({
@ -2395,12 +2395,12 @@ describe('DependencyGraph', function() {
'sha.js': {
'package.json': JSON.stringify({
name: 'sha.js',
main: 'main.js'
main: 'main.js',
}),
'main.js': 'lol'
}
}
}
'main.js': 'lol',
},
},
},
});
var dgraph = new DependencyGraph({
@ -2459,7 +2459,7 @@ describe('DependencyGraph', function() {
* @providesModule a
*/
`,
}
},
});
var dgraph = new DependencyGraph({
@ -2518,7 +2518,7 @@ describe('DependencyGraph', function() {
* @providesModule a
*/
`,
}
},
});
var dgraph = new DependencyGraph({
@ -2565,7 +2565,7 @@ describe('DependencyGraph', function() {
'a.ios.js': '',
'a.android.js': '',
'a.js': '',
}
},
});
var dgraph = new DependencyGraph({
@ -2625,7 +2625,7 @@ describe('DependencyGraph', function() {
'main.js': 'require("./package.json")',
},
},
}
},
});
var dgraph = new DependencyGraph({
@ -2684,7 +2684,7 @@ describe('DependencyGraph', function() {
describe('file watch updating', function() {
var triggerFileChange;
var mockStat = {
isDirectory: () => false
isDirectory: () => false,
};
beforeEach(function() {
@ -2713,22 +2713,22 @@ describe('DependencyGraph', function() {
' * @providesModule index',
' */',
'require("aPackage")',
'require("foo")'
'require("foo")',
].join('\n'),
'foo': [
'/**',
' * @providesModule foo',
' */',
'require("aPackage")'
'require("aPackage")',
].join('\n'),
'aPackage': {
'package.json': JSON.stringify({
name: 'aPackage',
main: 'main.js'
main: 'main.js',
}),
'main.js': 'main',
}
}
},
},
});
var dgraph = new DependencyGraph({
@ -2776,22 +2776,22 @@ describe('DependencyGraph', function() {
' * @providesModule index',
' */',
'require("aPackage")',
'require("foo")'
'require("foo")',
].join('\n'),
'foo.js': [
'/**',
' * @providesModule foo',
' */',
'require("aPackage")'
'require("aPackage")',
].join('\n'),
'aPackage': {
'package.json': JSON.stringify({
name: 'aPackage',
main: 'main.js'
main: 'main.js',
}),
'main.js': 'main',
}
}
},
},
});
var dgraph = new DependencyGraph({
@ -2839,22 +2839,22 @@ describe('DependencyGraph', function() {
' * @providesModule index',
' */',
'require("aPackage")',
'require("foo")'
'require("foo")',
].join('\n'),
'foo.js': [
'/**',
' * @providesModule foo',
' */',
'require("aPackage")'
'require("aPackage")',
].join('\n'),
'aPackage': {
'package.json': JSON.stringify({
name: 'aPackage',
main: 'main.js'
main: 'main.js',
}),
'main.js': 'main',
}
}
},
},
});
var dgraph = new DependencyGraph({
@ -2901,22 +2901,22 @@ describe('DependencyGraph', function() {
' * @providesModule index',
' */',
'require("aPackage")',
'require("foo")'
'require("foo")',
].join('\n'),
'foo.js': [
'/**',
' * @providesModule foo',
' */',
'require("aPackage")'
'require("aPackage")',
].join('\n'),
'aPackage': {
'package.json': JSON.stringify({
name: 'aPackage',
main: 'main.js'
main: 'main.js',
}),
'main.js': 'main',
}
}
},
},
});
var dgraph = new DependencyGraph({
@ -2928,7 +2928,7 @@ describe('DependencyGraph', function() {
'/**',
' * @providesModule bar',
' */',
'require("foo")'
'require("foo")',
].join('\n');
triggerFileChange('add', 'bar.js', root, mockStat);
@ -2993,7 +2993,7 @@ describe('DependencyGraph', function() {
'/**',
' * @providesModule index',
' */',
'require("image!foo")'
'require("image!foo")',
].join('\n'),
},
});
@ -3018,7 +3018,7 @@ describe('DependencyGraph', function() {
isPolyfill: false,
resolution: undefined,
resolveDependency: undefined,
}
},
]);
filesystem.root['foo.png'] = '';
@ -3062,10 +3062,10 @@ describe('DependencyGraph', function() {
'/**',
' * @providesModule index',
' */',
'require("./foo.png")'
'require("./foo.png")',
].join('\n'),
'package.json': JSON.stringify({
name: 'aPackage'
name: 'aPackage',
}),
},
});
@ -3088,7 +3088,7 @@ describe('DependencyGraph', function() {
isPolyfill: false,
resolution: undefined,
resolveDependency: undefined,
}
},
]);
filesystem.root['foo.png'] = '';
@ -3133,22 +3133,22 @@ describe('DependencyGraph', function() {
' * @providesModule index',
' */',
'require("aPackage")',
'require("foo")'
'require("foo")',
].join('\n'),
'foo.js': [
'/**',
' * @providesModule foo',
' */',
'require("aPackage")'
'require("aPackage")',
].join('\n'),
'aPackage': {
'package.json': JSON.stringify({
name: 'aPackage',
main: 'main.js'
main: 'main.js',
}),
'main.js': 'main',
}
}
},
},
});
var dgraph = new DependencyGraph({
@ -3166,7 +3166,7 @@ describe('DependencyGraph', function() {
'/**',
' * @providesModule bar',
' */',
'require("foo")'
'require("foo")',
].join('\n');
triggerFileChange('add', 'bar.js', root, mockStat);
@ -3223,22 +3223,22 @@ describe('DependencyGraph', function() {
' * @providesModule index',
' */',
'require("aPackage")',
'require("foo")'
'require("foo")',
].join('\n'),
'foo.js': [
'/**',
' * @providesModule foo',
' */',
'require("aPackage")'
'require("aPackage")',
].join('\n'),
'aPackage': {
'package.json': JSON.stringify({
name: 'aPackage',
main: 'main.js'
main: 'main.js',
}),
'main.js': 'main',
}
}
},
},
});
var dgraph = new DependencyGraph({
...defaults,
@ -3246,7 +3246,7 @@ describe('DependencyGraph', function() {
});
return getOrderedDependenciesAsJSON(dgraph, '/root/index.js').then(function() {
triggerFileChange('change', 'aPackage', '/root', {
isDirectory: function(){ return true; }
isDirectory: () => true,
});
return getOrderedDependenciesAsJSON(dgraph, '/root/index.js').then(function(deps) {
expect(deps)
@ -3302,11 +3302,11 @@ describe('DependencyGraph', function() {
'aPackage': {
'package.json': JSON.stringify({
name: 'aPackage',
main: 'main.js'
main: 'main.js',
}),
'main.js': 'main',
}
}
},
},
});
var dgraph = new DependencyGraph({
@ -3366,12 +3366,12 @@ describe('DependencyGraph', function() {
'aPackage': {
'package.json': JSON.stringify({
name: 'aPackage',
main: 'main.js'
main: 'main.js',
}),
'main.js': 'main',
'browser.js': 'browser',
}
}
},
},
});
var dgraph = new DependencyGraph({
@ -3429,12 +3429,12 @@ describe('DependencyGraph', function() {
'aPackage': {
'package.json': JSON.stringify({
name: 'aPackage',
main: 'main.js'
main: 'main.js',
}),
'main.js': 'main',
'browser.js': 'browser',
}
}
},
},
});
var dgraph = new DependencyGraph({
@ -3492,10 +3492,10 @@ describe('DependencyGraph', function() {
}),
'main.js': 'bar 1 module',
},
}
},
},
}
},
},
});
var dgraph = new DependencyGraph({
@ -3593,7 +3593,7 @@ describe('DependencyGraph', function() {
'browser.js': 'foo module',
},
},
}
},
});
var dgraph = new DependencyGraph({
@ -3648,14 +3648,14 @@ describe('DependencyGraph', function() {
'/**',
' * @providesModule index',
' */',
'System.import("a")'
'System.import("a")',
].join('\n'),
'a.js': [
'/**',
' * @providesModule a',
' */',
].join('\n'),
}
},
});
var dgraph = new DependencyGraph({
@ -3667,7 +3667,7 @@ describe('DependencyGraph', function() {
.then(response => response.finalize())
.then(({ asyncDependencies }) => {
expect(asyncDependencies).toEqual([
['/root/a.js']
['/root/a.js'],
]);
});
});

View File

@ -145,7 +145,7 @@ class Module {
*/
const blockCommentRe = /\/\*(.|\n)*?\*\//g;
const lineCommentRe = /\/\/.+(\n|$)/g;
function extractRequires(code /*: string*/) /*: Array<string>*/ {
function extractRequires(code) {
var deps = {
sync: [],
async: [],

View File

@ -51,7 +51,7 @@ describe('Module', () => {
fs.__setMockFilesystem({
'root': {
'index.js': 'System.import("dep1")',
}
},
});
return expectAsyncDependenciesToEqual([['dep1']]);
@ -61,7 +61,7 @@ describe('Module', () => {
fs.__setMockFilesystem({
'root': {
'index.js': 'System.import(\'dep1\')',
}
},
});
return expectAsyncDependenciesToEqual([['dep1']]);
@ -74,7 +74,7 @@ describe('Module', () => {
'System.import("dep1")',
'System.import("dep2")',
].join('\n'),
}
},
});
return expectAsyncDependenciesToEqual([
@ -87,7 +87,7 @@ describe('Module', () => {
fs.__setMockFilesystem({
'root': {
'index.js': 'System.import(\n"dep1"\n)',
}
},
});
return expectAsyncDependenciesToEqual([['dep1']]);

View File

@ -142,7 +142,7 @@ class Fastfs extends EventEmitter {
}
matches(dir, pattern) {
let dirFile = this._getFile(dir);
const dirFile = this._getFile(dir);
if (!dirFile.isDir) {
throw new Error(`Expected file ${dirFile.path} to be a directory`);
}
@ -154,7 +154,7 @@ class Fastfs extends EventEmitter {
_getRoot(filePath) {
for (let i = 0; i < this._roots.length; i++) {
let possibleRoot = this._roots[i];
const possibleRoot = this._roots[i];
if (isDescendant(possibleRoot.path, filePath)) {
return possibleRoot;
}
@ -264,7 +264,7 @@ class File {
/*eslint consistent-this:0*/
let file = this;
for (let i = 0; i < parts.length; i++) {
let fileName = parts[i];
const fileName = parts[i];
if (!fileName) {
continue;
}

View File

@ -8,8 +8,6 @@
*/
'use strict';
const path = require('path');
const SUPPORTED_PLATFORM_EXTS = ['android', 'ios', 'web'];
const re = new RegExp(