Autoformatted all ts and json files

This commit is contained in:
digeff 2016-02-17 10:28:01 -08:00
Родитель 719dd68983
Коммит b031edc774
17 изменённых файлов: 253 добавлений и 252 удалений

24
.vscode/launch.json поставляемый
Просмотреть файл

@ -1,16 +1,16 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceRoot}"
],
"sourceMaps": true,
"outDir": "${workspaceRoot}/out",
"version": "0.2.0",
"configurations": [
{
"name": "Launch Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceRoot}"
],
"sourceMaps": true,
"outDir": "${workspaceRoot}/out",
"preLaunchTask": "build"
},
{

18
.vscode/settings.json поставляемый
Просмотреть файл

@ -1,12 +1,12 @@
// Place your settings in this file to overwrite default and user settings.
{
"javascript.validate.enable": false,
"files.trimTrailingWhitespace": true,
"eslint.enable": false,
"editor.insertSpaces": true,
"editor.tabSize": 4,
"files.exclude": {
"**/node_modules": true,
"**/out": true
}
"javascript.validate.enable": false,
"files.trimTrailingWhitespace": true,
"eslint.enable": false,
"editor.insertSpaces": true,
"editor.tabSize": 4,
"files.exclude": {
"**/node_modules": true,
"**/out": true
}
}

2
.vscode/tasks.json поставляемый
Просмотреть файл

@ -3,7 +3,7 @@
"command": "gulp",
"isShellCommand": true,
"tasks": [
{
{
"taskName": "watch",
"args": [],
"isBuildCommand": true,

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

@ -17,44 +17,44 @@ var outPath = 'out';
var sources = [
srcPath,
].map(function (tsFolder) { return tsFolder + '/**/*.ts'; })
].map(function(tsFolder) { return tsFolder + '/**/*.ts'; })
.concat(['test/*.ts']);
// TODO: The file property should point to the generated source (this implementation adds an extra folder to the path)
// We should also make sure that we always generate urls in all the path properties (We shouldn't have \\s. This seems to
// be an issue on Windows platforms)
gulp.task('build', function () {
gulp.task('build', function() {
var tsProject = ts.createProject('tsconfig.json');
return tsProject.src()
.pipe(sourcemaps.init())
.pipe(ts(tsProject))
.pipe(sourcemaps.write('.', {
includeContent: false,
sourceRoot: function (file) {
sourceRoot: function(file) {
return path.relative(path.dirname(file.path), __dirname + '/src');
}
}))
.pipe(gulp.dest(outPath));
});
gulp.task('watch', ['build'], function (cb) {
gulp.task('watch', ['build'], function(cb) {
log('Watching build sources...');
return gulp.watch(sources, ['build']);
});
gulp.task('default', function (callback) {
gulp.task('default', function(callback) {
runSequence("clean", "build", "tslint", callback);
});
var lintSources = [
srcPath,
].map(function (tsFolder) { return tsFolder + '/**/*.ts'; });
].map(function(tsFolder) { return tsFolder + '/**/*.ts'; });
lintSources = lintSources.concat([
'!src/typings/**'
]);
var tslint = require('gulp-tslint');
gulp.task('tslint', function () {
gulp.task('tslint', function() {
return gulp.src(lintSources, { base: '.' })
.pipe(tslint())
.pipe(tslint.report('verbose'));
@ -67,11 +67,11 @@ function test() {
gulp.task('build-test', ['build'], test);
gulp.task('test', test);
gulp.task('watch-build-test', ['build', 'build-test'], function () {
gulp.task('watch-build-test', ['build', 'build-test'], function() {
return gulp.watch(sources, ['build', 'build-test']);
});
gulp.task("clean", function () {
gulp.task("clean", function() {
var del = require("del");
return del([outPath + "/**"], { force: true });
});

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

@ -1,7 +1,7 @@
'use strict';
var opn = require('./index.js');
module.exports = function (target, opts, cb) {
module.exports = function(target, opts, cb) {
if (process.env.REACT_DEBUGGER) {
if (opts.app) {
console.log("Debugger for React Native is configured. Skipping launch of " + opts.app);
@ -9,5 +9,5 @@ module.exports = function (target, opts, cb) {
return;
}
return opn(target, opts, cb);
return opn(target, opts, cb);
};

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

@ -104,7 +104,9 @@
"compile": "node ./node_modules/vscode/bin/compile -watch -p ./",
"vscode:prepublish": "gulp"
},
"extensionDependencies": ["andreweinand.node-debug"],
"extensionDependencies": [
"andreweinand.node-debug"
],
"dependencies": {
"q": "^1.4.1",
"ws": "^1.0.1"

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

@ -46,7 +46,7 @@ export class IOSDebugModeManager {
const failureString = `Unable to find plist file to ${actionText} debugging`;
return pu.retryAsync(() =>
this.tryOneAttemptToFindPListFile(), // Operation to retry until succesful
this.tryOneAttemptToFindPListFile(), // Operation to retry until succesful
(file: string) =>
file !== null, // Condition to check if the operation was succesful, and this logic is done
IOSDebugModeManager.MAX_RETRIES,

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

@ -25,11 +25,11 @@ export class PlistBuddy {
// Attempt to set the value, and if it fails due to the key not existing attempt to create the key
return this.invokePlistBuddy(`Set ${property} ${value}`, plistFile).fail(() =>
this.invokePlistBuddy(`Add ${property} string ${value}`, plistFile)
).then(() => {});
).then(() => { });
}
public deletePlistProperty(plistFile: string, property: string): Q.Promise<void> {
return this.invokePlistBuddy(`Delete ${property}`, plistFile).then(() => {});
return this.invokePlistBuddy(`Delete ${property}`, plistFile).then(() => { });
}
public readPlistProperty(plistFile: string, property: string): Q.Promise<string> {

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

@ -21,22 +21,22 @@ export class SimulatorPlist {
return Q.all<any>([
new PlistBuddy().getBundleId(this.projectRoot), // Find the name of the application
new Node.ChildProcess().exec("xcrun simctl getenv booted HOME").outcome]) // Find the path of the simulator we are running
.spread((bundleId: string, pathBuffer: Buffer) => {
const pathBefore = path.join(pathBuffer.toString().trim(), "Containers", "Data", "Application");
const pathAfter = path.join("Library", "Preferences", `${bundleId}.plist`);
.spread((bundleId: string, pathBuffer: Buffer) => {
const pathBefore = path.join(pathBuffer.toString().trim(), "Containers", "Data", "Application");
const pathAfter = path.join("Library", "Preferences", `${bundleId}.plist`);
// Look through $SIMULATOR_HOME/Containers/Data/Application/*/Library/Preferences to find $BUNDLEID.plist
return Q.nfcall(fs.readdir, pathBefore).then((apps: string[]) => {
const mockableFS = new Node.FileSystem();
const plistCandidates = apps.map((app: string) => path.join(pathBefore, app, pathAfter)).filter(mockableFS.existsSync);
if (plistCandidates.length === 0) {
throw new Error(`Unable to find plist file for ${bundleId}`);
} else if (plistCandidates.length > 1) {
Log.logMessage("Warning: Multiple plist candidates found. Application may not be in debug mode");
}
// Look through $SIMULATOR_HOME/Containers/Data/Application/*/Library/Preferences to find $BUNDLEID.plist
return Q.nfcall(fs.readdir, pathBefore).then((apps: string[]) => {
const mockableFS = new Node.FileSystem();
const plistCandidates = apps.map((app: string) => path.join(pathBefore, app, pathAfter)).filter(mockableFS.existsSync);
if (plistCandidates.length === 0) {
throw new Error(`Unable to find plist file for ${bundleId}`);
} else if (plistCandidates.length > 1) {
Log.logMessage("Warning: Multiple plist candidates found. Application may not be in debug mode");
}
return plistCandidates[0];
return plistCandidates[0];
});
});
});
}
}

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

@ -57,7 +57,7 @@ export class FileSystem {
*/
public exists(filename: string): Q.Promise<boolean> {
return Q.nfcall(fs.stat, filename)
.then(function(){
.then(function() {
return Q.resolve(true);
})
.catch(function(err) {
@ -147,14 +147,14 @@ export class FileSystem {
return Q.nfcall<void>(fs.mkdir, target);
}
})
.then(() => {
return Q.nfcall<string[]>(fs.readdir, source);
})
.then(contents => {
Q.all(contents.map((childPath: string): Q.Promise<void> => {
return this.copyRecursive(path.join(source, childPath), path.join(target, childPath));
}));
});
.then(() => {
return Q.nfcall<string[]>(fs.readdir, source);
})
.then(contents => {
Q.all(contents.map((childPath: string): Q.Promise<void> => {
return this.copyRecursive(path.join(source, childPath), path.join(target, childPath));
}));
});
} else {
return this.copyFile(source, target);
}

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

@ -42,10 +42,10 @@ export class Package {
public setMainFile(value: string): Q.Promise<void> {
return this.parsePackageInformation()
.then(packageInformation => {
packageInformation.main = value;
return new Node.FileSystem().writeFile(this.informationJsonFilePath(), JSON.stringify(<Object>packageInformation));
});
.then(packageInformation => {
packageInformation.main = value;
return new Node.FileSystem().writeFile(this.informationJsonFilePath(), JSON.stringify(<Object>packageInformation));
});
}
private informationJsonFilePath(): string {

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

@ -40,20 +40,20 @@ export class Packager {
this.isRunning().done(running => {
if (!running) {
return this.monkeyPatchOpnForRNPackager()
.then(() => {
let args = ["--port", Packager.PORT];
let childEnvForDebugging = Object.assign({}, process.env, { REACT_DEBUGGER: "echo A debugger is not needed: " });
.then(() => {
let args = ["--port", Packager.PORT];
let childEnvForDebugging = Object.assign({}, process.env, { REACT_DEBUGGER: "echo A debugger is not needed: " });
Log.logMessage("Starting Packager", outputChannel);
// The packager will continue running while we debug the application, so we can"t
// wait for this command to finish
Log.logMessage("Starting Packager", outputChannel);
// The packager will continue running while we debug the application, so we can"t
// wait for this command to finish
let spawnOptions = { env: childEnvForDebugging };
let spawnOptions = { env: childEnvForDebugging };
new CommandExecutor(this.projectPath).spawnReactCommand("start", args, spawnOptions, outputChannel).then((packagerProcess) => {
this.packagerProcess = packagerProcess;
});
}).done();
new CommandExecutor(this.projectPath).spawnReactCommand("start", args, spawnOptions, outputChannel).then((packagerProcess) => {
this.packagerProcess = packagerProcess;
});
}).done();
}
});
@ -132,7 +132,7 @@ export class Packager {
? Q.resolve(path)
: Q.reject<string>("opn package location not found"))));
} catch (err) {
console.error ("The package \'opn\' was not found." + err);
console.error("The package \'opn\' was not found." + err);
}
}
@ -142,20 +142,20 @@ export class Packager {
// Finds the 'opn' package
return this.findOpnPackage()
.then((opnIndexFilePath) => {
destnFilePath = opnIndexFilePath;
// Read the package's "package.json"
opnPackage = new Package(path.resolve(path.dirname(destnFilePath)));
return opnPackage.parsePackageInformation();
}).then((packageJson) => {
if (packageJson.main !== Packager.JS_INJECTOR_FILENAME) {
// Copy over the patched 'opn' main file
return new Node.FileSystem().copyFile(Packager.JS_INJECTOR_FILEPATH, path.resolve(path.dirname(destnFilePath), Packager.JS_INJECTOR_FILENAME))
.then(() => {
// Write/over-write the "main" attribute with the new file
return opnPackage.setMainFile(Packager.JS_INJECTOR_FILENAME);
});
}
});
.then((opnIndexFilePath) => {
destnFilePath = opnIndexFilePath;
// Read the package's "package.json"
opnPackage = new Package(path.resolve(path.dirname(destnFilePath)));
return opnPackage.parsePackageInformation();
}).then((packageJson) => {
if (packageJson.main !== Packager.JS_INJECTOR_FILENAME) {
// Copy over the patched 'opn' main file
return new Node.FileSystem().copyFile(Packager.JS_INJECTOR_FILEPATH, path.resolve(path.dirname(destnFilePath), Packager.JS_INJECTOR_FILENAME))
.then(() => {
// Write/over-write the "main" attribute with the new file
return opnPackage.setMainFile(Packager.JS_INJECTOR_FILENAME);
});
}
});
}
}

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

@ -44,7 +44,7 @@ export class CommandPaletteHandler {
public runIos(): void {
// Set the Debugging setting to disabled
new IOSDebugModeManager(this.workspaceRoot).setSimulatorJSDebuggingModeSetting(/*enable=*/ false)
.catch(() => {}) // If setting the debugging mode fails, we ignore the error and we run the run ios command anyways
.catch(() => { }) // If setting the debugging mode fails, we ignore the error and we run the run ios command anyways
.done(() => this.executeCommandInContext(() => this.executeReactNativeRunCommand("run-ios")));
}

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

@ -33,7 +33,7 @@ export function activate(context: vscode.ExtensionContext): void {
const nodeDebugPath = vscode.extensions.getExtension("andreweinand.node-debug").extensionPath;
const fsUtil = new FileSystem();
fsUtil.writeFile(path.resolve(__dirname, "../", "debugger", "nodeDebugLocation.json"), JSON.stringify({nodeDebugPath})).done();
fsUtil.writeFile(path.resolve(__dirname, "../", "debugger", "nodeDebugLocation.json"), JSON.stringify({ nodeDebugPath })).done();
}
/**
@ -74,10 +74,10 @@ function setupReactNativeIntellisense(): void {
}
TsConfigHelper.allowJs(true)
.then(function() {
return TsConfigHelper.addExcludePaths(["node_modules"]);
})
.done();
.then(function() {
return TsConfigHelper.addExcludePaths(["node_modules"]);
})
.done();
const reactTypingsSource = path.resolve(__dirname, "..", "..", "ReactTypings");
const reactTypingsDest = path.resolve(vscode.workspace.rootPath, ".vscode", "typings");

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

@ -21,17 +21,17 @@ export class TsConfigHelper {
let fileSystem = new FileSystem();
return fileSystem.exists(tsConfigPath)
.then(function(exists: boolean): Q.Promise<void> {
if (!exists) {
return fileSystem.writeFile(tsConfigPath, "{}");
}
})
.then(function(): Q.Promise<string> {
return fileSystem.readFile(tsConfigPath, "utf-8");
})
.then(function(jsonContents: string): Q.Promise<any> {
return JSON.parse(jsonContents);
});
.then(function(exists: boolean): Q.Promise<void> {
if (!exists) {
return fileSystem.writeFile(tsConfigPath, "{}");
}
})
.then(function(): Q.Promise<string> {
return fileSystem.readFile(tsConfigPath, "utf-8");
})
.then(function(jsonContents: string): Q.Promise<any> {
return JSON.parse(jsonContents);
});
}
/**
@ -48,18 +48,18 @@ export class TsConfigHelper {
*/
public static allowJs(enabled: boolean): Q.Promise<void> {
return TsConfigHelper.readConfigJson()
.then(function(tsConfigJson: any): Q.Promise<void> {
tsConfigJson.compilerOptions = tsConfigJson.compilerOptions || {};
.then(function(tsConfigJson: any): Q.Promise<void> {
tsConfigJson.compilerOptions = tsConfigJson.compilerOptions || {};
// Return if the setting is already correctly set.
if (tsConfigJson.compilerOptions.allowJs === enabled) {
return Q.resolve<void>(void 0);
}
// Return if the setting is already correctly set.
if (tsConfigJson.compilerOptions.allowJs === enabled) {
return Q.resolve<void>(void 0);
}
tsConfigJson.compilerOptions.allowJs = enabled;
tsConfigJson.compilerOptions.allowJs = enabled;
return TsConfigHelper.writeConfigJson(tsConfigJson);
});
return TsConfigHelper.writeConfigJson(tsConfigJson);
});
}
/**
@ -67,22 +67,22 @@ export class TsConfigHelper {
*/
public static addExcludePaths(excludePaths: string[]): Q.Promise<void> {
return TsConfigHelper.readConfigJson()
.then(function(tsConfigJson: any) {
let currentExcludes: string[] = tsConfigJson.exclude || [];
let isDirty: boolean = false;
.then(function(tsConfigJson: any) {
let currentExcludes: string[] = tsConfigJson.exclude || [];
let isDirty: boolean = false;
excludePaths.forEach(function(exclude: string){
if (currentExcludes.indexOf(exclude) < 0) {
currentExcludes.push(exclude);
isDirty = true;
excludePaths.forEach(function(exclude: string) {
if (currentExcludes.indexOf(exclude) < 0) {
currentExcludes.push(exclude);
isDirty = true;
}
});
if (isDirty) {
tsConfigJson.exclude = currentExcludes;
return TsConfigHelper.writeConfigJson(tsConfigJson);
}
});
if (isDirty) {
tsConfigJson.exclude = currentExcludes;
return TsConfigHelper.writeConfigJson(tsConfigJson);
}
});
}
}

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

@ -1,11 +1,11 @@
{
"name": "SampleApplication",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start"
},
"dependencies": {
"react-native": "^0.19.0"
}
}
"name": "SampleApplication",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start"
},
"dependencies": {
"react-native": "^0.19.0"
}
}

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

@ -1,112 +1,111 @@
{
"rules": {
"align": [
true,
"parameters",
"statements"
],
"ban": false,
"class-name": true,
"comment-format": [
true,
"check-space"
],
"curly": false,
"forin": true,
"indent": [
true,
"spaces"
],
"jsdoc-format": true,
"label-position": true,
"label-undefined": true,
"max-line-length": [
false,
140
],
"member-access": true,
"member-ordering": [
true,
"variables-before-functions",
"public-before-private"
],
"no-any": false,
"no-arg": true,
"no-bitwise": true,
"no-conditional-assignment": true,
"no-console": [
true,
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-construct": true,
"no-debugger": true,
"no-duplicate-key": true,
"no-duplicate-variable": true,
"no-empty": false,
"no-eval": true,
"no-inferrable-types": false,
"no-internal-module": false,
"no-keyword-named-variables": true,
"no-require-imports": false,
"no-shadowed-variable": true,
"no-string-literal": true,
"no-switch-case-fall-through": false,
"no-trailing-whitespace": true,
"no-unreachable": true,
"no-unused-expression": true,
"no-unused-variable": true,
"no-use-before-declare": true,
"no-var-keyword": true,
"no-var-requires": true,
"object-literal-sort-keys": true,
"one-line": [
true,
"check-open-brace",
"check-catch",
"check-else",
"check-whitespace"
],
"quotemark": [
true,
"double"
],
"radix": true,
"semicolon": true,
"switch-default": true,
"trailing-comma": [
true,
{
"multiline": "always",
"singleline": "never"
}
],
"triple-equals": [
true,
"allow-null-check"
],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"variable-name": false,
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
]
}
}
"rules": {
"align": [
true,
"parameters",
"statements"
],
"ban": false,
"class-name": true,
"comment-format": [
true,
"check-space"
],
"curly": false,
"forin": true,
"indent": [
true,
"spaces"
],
"jsdoc-format": true,
"label-position": true,
"label-undefined": true,
"max-line-length": [
false,
140
],
"member-access": true,
"member-ordering": [
true,
"variables-before-functions",
"public-before-private"
],
"no-any": false,
"no-arg": true,
"no-bitwise": true,
"no-conditional-assignment": true,
"no-console": [
true,
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-construct": true,
"no-debugger": true,
"no-duplicate-key": true,
"no-duplicate-variable": true,
"no-empty": false,
"no-eval": true,
"no-inferrable-types": false,
"no-internal-module": false,
"no-keyword-named-variables": true,
"no-require-imports": false,
"no-shadowed-variable": true,
"no-string-literal": true,
"no-switch-case-fall-through": false,
"no-trailing-whitespace": true,
"no-unreachable": true,
"no-unused-expression": true,
"no-unused-variable": true,
"no-use-before-declare": true,
"no-var-keyword": true,
"no-var-requires": true,
"object-literal-sort-keys": true,
"one-line": [
true,
"check-open-brace",
"check-catch",
"check-else",
"check-whitespace"
],
"quotemark": [
true,
"double"
],
"radix": true,
"semicolon": true,
"switch-default": true,
"trailing-comma": [
true,
{
"multiline": "always",
"singleline": "never"
}
],
"triple-equals": [
true,
"allow-null-check"
],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"variable-name": false,
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
]
}
}