Skip to content

Commit

Permalink
Run eslint --fix
Browse files Browse the repository at this point in the history
Summary:
CI is currently failing because of a lint issue, this fixes it and a bunch of other warnings that are auto-fixable.

**Test plan**
Quick manual test, cosmetic changes only.
Closes facebook/react-native#16229

Differential Revision: D6009748

Pulled By: TheSavior

fbshipit-source-id: cabd44fed99dd90bd0b35626492719c139c89f34
  • Loading branch information
janicduplessis authored and facebook-github-bot committed Oct 10, 2017
1 parent 1729976 commit 96e5efa
Show file tree
Hide file tree
Showing 22 changed files with 283 additions and 283 deletions.
2 changes: 1 addition & 1 deletion bundle/saveAssets.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function saveAssets(
const src = asset.files[idx];
const dest = path.join(assetsDest, getAssetDestPath(asset, scale));
filesToCopy[src] = dest;
})
});
});

return copyAll(filesToCopy);
Expand Down
4 changes: 2 additions & 2 deletions core/windows/generateGUID.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ const s4 = () => {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
};

module.exports = function generateGUID() {
return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
s4() + '-' + s4() + s4() + s4();
}
};
10 changes: 5 additions & 5 deletions core/windows/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ const generateGUID = require('./generateGUID');

const relativeProjectPath = (fullProjPath) => {
const windowsPath = fullProjPath
.substring(fullProjPath.lastIndexOf("node_modules") - 1, fullProjPath.length)
.substring(fullProjPath.lastIndexOf('node_modules') - 1, fullProjPath.length)
.replace(/\//g, '\\');

return '..' + windowsPath;
}
};

const getProjectName = (fullProjPath) => {
return fullProjPath.split('/').slice(-1)[0].replace(/\.csproj/i, '');
}
};

/**
* Gets windows project config by analyzing given folder and taking some
Expand All @@ -41,7 +41,7 @@ exports.projectConfig = function projectConfigWindows(folder, userConfig) {

// expects solutions to be named the same as project folders
const solutionPath = path.join(folder, csSolution);
const windowsAppFolder = csSolution.substring(0, csSolution.lastIndexOf(".sln"));
const windowsAppFolder = csSolution.substring(0, csSolution.lastIndexOf('.sln'));
const src = userConfig.sourceDir || windowsAppFolder;
const sourceDir = path.join(folder, src);
const mainPage = path.join(sourceDir, 'MainPage.cs');
Expand Down Expand Up @@ -70,7 +70,7 @@ exports.dependencyConfig = function dependencyConfigWindows(folder, userConfig)
}

// expects solutions to be named the same as project folders
const windowsAppFolder = csSolution.substring(0, csSolution.lastIndexOf(".sln"));
const windowsAppFolder = csSolution.substring(0, csSolution.lastIndexOf('.sln'));
const src = userConfig.sourceDir || windowsAppFolder;

if (!src) {
Expand Down
14 changes: 7 additions & 7 deletions eject/eject.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,28 @@ function eject() {
let appConfig = null;
try {
appConfig = require(path.resolve('app.json'));
} catch(e) {
} catch (e) {
console.error(
`Eject requires an \`app.json\` config file to be located at ` +
'Eject requires an `app.json` config file to be located at ' +
`${path.resolve('app.json')}, and it must at least specify a \`name\` for the project ` +
`name, and a \`displayName\` for the app's home screen label.`
'name, and a `displayName` for the app\'s home screen label.'
);
process.exit(1);
}

const appName = appConfig.name;
if (!appName) {
console.error(
`App \`name\` must be defined in the \`app.json\` config file to define the project name. `+
`It must not contain any spaces or dashes.`
'App `name` must be defined in the `app.json` config file to define the project name. ' +
'It must not contain any spaces or dashes.'
);
process.exit(1);
}
const displayName = appConfig.displayName;
if (!displayName) {
console.error(
`App \`displayName\` must be defined in the \`app.json\` config file, to define the label ` +
`of the app on the home screen.`
'App `displayName` must be defined in the `app.json` config file, to define the label ' +
'of the app on the home screen.'
);
process.exit(1);
}
Expand Down
2 changes: 1 addition & 1 deletion generator/copyProjectTemplateAndReplace.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function copyProjectTemplateAndReplace(srcPath, destPath, newProjectName, option
* behavior of automatically renaming .gitignore to .npmignore.
*/
function dotFilePath(path) {
if (!path) return path;
if (!path) {return path;}
return path
.replace('_gitignore', '.gitignore')
.replace('_gitattributes', '.gitattributes')
Expand Down
36 changes: 18 additions & 18 deletions generator/promptSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function create() {
var echo = opts.echo;
var masked = 'echo' in opts;

var fd = (process.platform === 'win32') ?
var fd = (process.platform === 'win32') ?
process.stdin.fd :
fs.openSync('/dev/tty', 'rs');

Expand All @@ -51,15 +51,15 @@ function create() {
str = str + buf.toString();
str = str.replace(/\0/g, '');
insert = str.length;
process.stdout.write('\u001b[2K\u001b[0G'+ ask + str);
process.stdout.write('\u001b[' + (insert+ask.length+1) + 'G');
process.stdout.write('\u001b[2K\u001b[0G' + ask + str);
process.stdout.write('\u001b[' + (insert + ask.length + 1) + 'G');
buf = new Buffer(3);
}
continue; // any other 3 character sequence is ignored
}

// if it is not a control character seq, assume only one character is read
character = buf[read-1];
character = buf[read - 1];

// catch a ^C and return null
if (character == 3){
Expand All @@ -77,42 +77,42 @@ function create() {
}

if (character == 127 || (process.platform == 'win32' && character == 8)) { //backspace
if (!insert) continue;
str = str.slice(0, insert-1) + str.slice(insert);
if (!insert) {continue;}
str = str.slice(0, insert - 1) + str.slice(insert);
insert--;
process.stdout.write('\u001b[2D');
} else {
if ((character < 32 ) || (character > 126))
continue;
{continue;}
str = str.slice(0, insert) + String.fromCharCode(character) + str.slice(insert);
insert++;
};
}

if (masked) {
process.stdout.write('\u001b[2K\u001b[0G' + ask + Array(str.length+1).join(echo));
process.stdout.write('\u001b[2K\u001b[0G' + ask + Array(str.length + 1).join(echo));
} else {
process.stdout.write('\u001b[s');
if (insert == str.length) {
process.stdout.write('\u001b[2K\u001b[0G'+ ask + str);
process.stdout.write('\u001b[2K\u001b[0G' + ask + str);
} else {
if (ask) {
process.stdout.write('\u001b[2K\u001b[0G'+ ask + str);
process.stdout.write('\u001b[2K\u001b[0G' + ask + str);
} else {
process.stdout.write('\u001b[2K\u001b[0G'+ str + '\u001b[' + (str.length - insert) + 'D');
process.stdout.write('\u001b[2K\u001b[0G' + str + '\u001b[' + (str.length - insert) + 'D');
}
}
process.stdout.write('\u001b[u');
process.stdout.write('\u001b[1C');
}

}
process.stdout.write('\n')

process.stdout.write('\n');

process.stdin.setRawMode(wasRaw);

return str || value || '';
};
};
}
}

module.exports = create;
module.exports = create;
4 changes: 2 additions & 2 deletions link/__tests__/android/isInstalled.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const projectConfig = {

describe('android::isInstalled', () => {
it('should return true when project is already in build.gradle', () => {
expect(isInstalled(projectConfig, 'test')).toBeTruthy()
expect(isInstalled(projectConfig, 'test2')).toBeTruthy()
expect(isInstalled(projectConfig, 'test')).toBeTruthy();
expect(isInstalled(projectConfig, 'test2')).toBeTruthy();
});

it('should return false when project is not in build.gradle', () =>
Expand Down
2 changes: 1 addition & 1 deletion link/__tests__/ios/writePlist.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jest.mock('fs');
let plistPath = null;
jest.mock('../../ios/getPlistPath', () => () => plistPath);

const { readFileSync } = require.requireActual('fs')
const { readFileSync } = require.requireActual('fs');
const fs = require('fs');

const xcode = require('xcode');
Expand Down
2 changes: 1 addition & 1 deletion link/android/patches/makeBuildPatch.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = function makeBuildPatch(name) {
const installPattern = new RegExp(
`\\s{4}(compile)(\\(|\\s)(project)\\(\\\':${name}\\\'\\)(\\)|\\s)`
)
);

return {
installPattern,
Expand Down
2 changes: 1 addition & 1 deletion link/commandStub.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = (cb) => cb();
module.exports = (cb) => cb();
6 changes: 3 additions & 3 deletions link/ios/unlinkAssets.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ module.exports = function unlinkAssetsIOS(files, projectConfig) {
if (!plist) {
return log.error(
'ERRPLIST',
`Could not locate Info.plist file. Check if your project has 'INFOPLIST_FILE' set properly`
'Could not locate Info.plist file. Check if your project has \'INFOPLIST_FILE\' set properly'
);
}

if (!project.pbxGroupByName('Resources')) {
return log.error(
'ERRGROUP',
`Group 'Resources' does not exist in your Xcode project. There is nothing to unlink.`
'Group \'Resources\' does not exist in your Xcode project. There is nothing to unlink.'
);
}

Expand All @@ -39,7 +39,7 @@ module.exports = function unlinkAssetsIOS(files, projectConfig) {
)
)
.map(file => file.basename);
}
};

removeResourceFile(assets.image);

Expand Down
2 changes: 1 addition & 1 deletion link/promisify.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = (func) => new Promise((resolve, reject) =>
func((err, res) => err ? reject(err) : resolve(res))
);
);
2 changes: 1 addition & 1 deletion link/unlink.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function unlink(args, config) {
);
throw err;
});
};
}

module.exports = {
func: unlink,
Expand Down
2 changes: 1 addition & 1 deletion link/windows/patches/applyPatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = function applyPatch(file, patch, flip = false) {
fs.writeFileSync(file, fs
.readFileSync(file, 'utf8')
.replace(patch.pattern, match => {
return flip ? `${patch.patch}${match}` : `${match}${patch.patch}`
return flip ? `${patch.patch}${match}` : `${match}${patch.patch}`;
})
);
};
2 changes: 1 addition & 1 deletion link/windows/patches/revokePatch.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const fs = require('fs');

module.exports = function revokePatch(file, patch) {
const unpatch = patch.unpatch || patch.patch
const unpatch = patch.unpatch || patch.patch;
fs.writeFileSync(file, fs
.readFileSync(file, 'utf8')
.replace(unpatch, '')
Expand Down
4 changes: 2 additions & 2 deletions runAndroid/adb.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function parseDevicesResult(result: string): Array<string> {
const devices = [];
const lines = result.trim().split(/\r?\n/);

for (let i=0; i < lines.length; i++) {
for (let i = 0; i < lines.length; i++) {
let words = lines[i].split(/[ ,\t]+/).filter((w) => w !== '');

if (words[1] === 'device') {
Expand All @@ -49,4 +49,4 @@ function getDevices(): Array<string> {
module.exports = {
parseDevicesResult: parseDevicesResult,
getDevices: getDevices
};
};
Loading

0 comments on commit 96e5efa

Please sign in to comment.