Skip to content
This repository has been archived by the owner on Jun 29, 2019. It is now read-only.

Commit

Permalink
Use prettier!
Browse files Browse the repository at this point in the history
  • Loading branch information
Heejin Lee committed May 13, 2018
1 parent 311ee62 commit 19697c0
Show file tree
Hide file tree
Showing 90 changed files with 1,291 additions and 1,002 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
app/renderer/
app/dist/
app/node_modules/
node_modules/
93 changes: 48 additions & 45 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,47 +1,50 @@
{
"extends": "recommended/node",
"rules": {
"comma-dangle": ["warn", "only-multiline"],
"no-unused-vars": "warn",
"camelcase": "off",
"object-shorthand": "off",
"guard-for-in": "warn",
"arrow-body-style": "off",
"consistent-return": "warn",
"no-throw-literal": "warn",
"quote-props": "off",
"new-cap": "off",
"default-case": "off",
"no-empty": "warn",
"curly": "off",
"padded-blocks": "off",
"no-use-before-define": "warn",
"no-param-reassign": ["error", {"props": false}],
"max-len": "off",
"no-underscore-dangle": "off",
"strict": "off",
"global-require": "off",
"no-restricted-syntax": "off",
"no-multi-spaces": "off",
"spaced-comment": "off",
"no-trailing-spaces": "off",
"key-spacing": "off",
"func-names": "off",
"no-empty-function": "off",
"no-console": "warn",
"import/no-extraneous-dependencies": "off",
"import/no-commonjs": "warn",
"import/no-nodejs-modules": "off"
},
"env": {
"jest": true
},
"plugins": [
"react"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
}
}
"extends": ["recommended/node", "plugin:prettier/recommended"],
"rules": {
"comma-dangle": ["warn", "only-multiline"],
"no-unused-vars": ["error", { "vars": "all", "args": "none", "ignoreRestSiblings": false }],
"camelcase": "off",
"object-shorthand": "off",
"guard-for-in": "warn",
"arrow-body-style": "off",
"consistent-return": "warn",
"no-throw-literal": "warn",
"quote-props": "off",
"new-cap": "off",
"default-case": "off",
"no-empty": "warn",
"curly": "off",
"padded-blocks": "off",
"no-use-before-define": "warn",
"no-param-reassign": ["error", { "props": false }],
"max-len": "off",
"no-underscore-dangle": "off",
"strict": "off",
"global-require": "off",
"no-restricted-syntax": "off",
"no-multi-spaces": "off",
"spaced-comment": "off",
"no-trailing-spaces": "off",
"key-spacing": "off",
"func-names": "off",
"no-empty-function": "off",
"no-console": "warn",
"import/no-extraneous-dependencies": "off",
"import/no-commonjs": "off",
"import/no-nodejs-modules": "off",
"no-sync": "off",
"eqeqeq": "off",
"require-yield": "off",
"class-methods-use-this": "off",
"prettier/prettier": "error"
},
"env": {
"jest": true
},
"plugins": ["react", "prettier"],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
}
}
}
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
app/renderer/
app/dist/
app/node_modules/
node_modules/
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"arrowParens": "always"
}
44 changes: 24 additions & 20 deletions @types/hain-plugin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ type bitfield = number;
* @see https://github.com/simonlast/node-persist
*/
declare namespace NodePersist {

interface InitOptions {
dir?: string;
stringify?: (toSerialize: any) => string;
Expand All @@ -26,11 +25,18 @@ declare namespace NodePersist {

initSync(options?: InitOptions): void;

getItem(key: string, callback?: (err: any, value: any) => any): Promise<any>;
getItem(
key: string,
callback?: (err: any, value: any) => any
): Promise<any>;

getItemSync(key: string): any;

setItem(key: string, value: any, callback?: (err: any) => any): Promise<any>;
setItem(
key: string,
value: any,
callback?: (err: any) => any
): Promise<any>;

setItemSync(key: string, value: any): void;

Expand Down Expand Up @@ -63,14 +69,12 @@ declare namespace NodePersist {
}

declare namespace hain {

/**
* These are the functions your plugin can/must implement
*
* @since v0.5
*/
export class Plugin {

/**
* (Optional)
* This function will be invoked on startup once. you can do any preparations here.
Expand Down Expand Up @@ -144,10 +148,10 @@ declare namespace hain {
}

export enum KeyBitfield {
CTRL = 1,
ALT = 2,
CTRL = 1,
ALT = 2,
SHIFT = 4,
META = 8,
META = 8
}

/**
Expand Down Expand Up @@ -396,9 +400,7 @@ declare namespace hain {
/**
* @since v0.5
*/
export interface PluginLocalStorage extends NodePersist.LocalStorage {

}
export interface PluginLocalStorage extends NodePersist.LocalStorage {}

/**
* @since v0.5
Expand Down Expand Up @@ -465,13 +467,13 @@ declare namespace hain {
* @example
* <pre>
* function search(query, res) {
* res.add({
* id: 'temp',
* title: 'Fetching...',
* desc: 'Please wait a second'
* });
* setTimeout(() => res.remove('temp'), 1000);
* }
* res.add({
* id: 'temp',
* title: 'Fetching...',
* desc: 'Please wait a second'
* });
* setTimeout(() => res.remove('temp'), 1000);
* }
* </pre>
*/
export interface ResponseObject {
Expand Down Expand Up @@ -526,14 +528,16 @@ declare namespace hain {
* @param key A unique ID which you can later use to remove or modify this addition
* @param callback The callback function, this will be called synchronously
*/
set(key: string, callback: (query: string) => IndexedResult | IndexedResult[]): void;
set(
key: string,
callback: (query: string) => IndexedResult | IndexedResult[]
): void;

/**
* Removes the set of results added with the given key
*
* @param key A unique ID which you can later use to remove or modify this addition
*/
remove(key: string): void;

}
}
29 changes: 11 additions & 18 deletions @types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
{
"include": [
"./@types/*.ts"
],
"exclude": [

],
"include": ["./@types/*.ts"],
"exclude": [],
"compilerOptions": {
"module": "es6",
"lib": [
"es7", "es2015.promise", "dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"module": "es6",
"lib": ["es7", "es2015.promise", "dom"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
// "baseUrl": "../",
"types": [],
"noEmit": false,
"outDir": "./",
"pretty": true,
"types": [],
"noEmit": false,
"outDir": "./",
"pretty": true,
"listEmittedFiles": true,
"alwaysStrict": true

"alwaysStrict": true
}
}
13 changes: 6 additions & 7 deletions app/main/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

((function startup() {
(function startup() {
if (require('electron-squirrel-startup')) return;

// workaround for fixing auto-launch cwd problem
Expand All @@ -24,9 +24,8 @@

const Server = require('./server');
const server = new Server();
server.launch()
.catch((e) => {
dialog.showErrorBox('Hain', `Unhandled Error: ${e.stack || e}`);
electronApp.quit();
});
})());
server.launch().catch((e) => {
dialog.showErrorBox('Hain', `Unhandled Error: ${e.stack || e}`);
electronApp.quit();
});
})();
10 changes: 4 additions & 6 deletions app/main/conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ const DEV_PLUGIN_REPO = path.resolve(`${HAIN_USER_PATH}/devplugins`);

const _apiVersionInfo = pkg._apiVersion;
const CURRENT_API_VERSION = _apiVersionInfo.currentVersion;
const COMPATIBLE_API_VERSIONS = [CURRENT_API_VERSION].concat(_apiVersionInfo.compatibleVersions);
const COMPATIBLE_API_VERSIONS = [CURRENT_API_VERSION].concat(
_apiVersionInfo.compatibleVersions
);

const PLUGIN_REPOS = [
INTERNAL_PLUGIN_REPO,
MAIN_PLUGIN_REPO,
DEV_PLUGIN_REPO
];
const PLUGIN_REPOS = [INTERNAL_PLUGIN_REPO, MAIN_PLUGIN_REPO, DEV_PLUGIN_REPO];

module.exports = {
HAIN_USER_PATH,
Expand Down
33 changes: 18 additions & 15 deletions app/main/plugins/hain-commands/__tests__/check-update.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,32 @@ const mock_got = require('got');
const checkForUpdate = require('../check-update');

describe('checkUpdate', () => {

pit('should return latest version and url', () => {
const latestVersion = '0.2.0';
const downloadUrl = 'download-0.2.0';

const githubAPIData = [{
tag_name: `v${latestVersion}`,
html_url: downloadUrl
}, {
tag_name: 'v0.1.0',
html_url: 'fake'
}];

mock_got.mockReturnValueOnce(Promise.resolve({
body: githubAPIData
}));

return checkForUpdate().then(res => {
const githubAPIData = [
{
tag_name: `v${latestVersion}`,
html_url: downloadUrl
},
{
tag_name: 'v0.1.0',
html_url: 'fake'
}
];

mock_got.mockReturnValueOnce(
Promise.resolve({
body: githubAPIData
})
);

return checkForUpdate().then((res) => {
expect(res).toEqual({
version: latestVersion,
url: downloadUrl
});
});
});

});
2 changes: 1 addition & 1 deletion app/main/plugins/hain-commands/check-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function checkForUpdate() {
Accept: 'application/vnd.github.v3+json'
},
json: true
}).then(res => {
}).then((res) => {
const latest = res.body[0];
const latestUrl = latest.html_url;
const latestVersion = latest.tag_name.substring(1);
Expand Down
Loading

0 comments on commit 19697c0

Please sign in to comment.