Skip to content

Commit

Permalink
style: fix by prettier (#354)
Browse files Browse the repository at this point in the history
* feat: add prettier

* feat: add prettier to CI

* chore: keep scripts same style

* feat: add prettier as deps

* feat: use @ice/spec

* style: fix by prettier
  • Loading branch information
alvinhui authored Jul 28, 2020
1 parent eee88af commit f536ba9
Show file tree
Hide file tree
Showing 272 changed files with 2,602 additions and 2,813 deletions.
10 changes: 5 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
const { eslint, tslint, deepmerge } = require('@ice/spec');

const commonRules = {
'react/jsx-filename-extension': [1, { 'extensions': ['.js', '.jsx', '.tsx'] }],
'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx', '.tsx'] }],
'react/jsx-no-target-blank': [0],
'prefer-object-spread': 0,
'max-classes-per-file': 0,
'class-methods-use-this': 0
'class-methods-use-this': 0,
};

const jsRules = deepmerge(eslint, {
env: {
jest: true
jest: true,
},
rules: {
...commonRules,
Expand All @@ -19,7 +19,7 @@ const jsRules = deepmerge(eslint, {

const tsRules = deepmerge(tslint, {
env: {
jest: true
jest: true,
},
rules: {
...commonRules,
Expand All @@ -31,7 +31,7 @@ const tsRules = deepmerge(tslint, {
'@typescript-eslint/no-non-null-assertion': 0,
'@typescript-eslint/explicit-function-return-type': 0,
'@typescript-eslint/explicit-member-accessibility': 0,
'@typescript-eslint/no-parameter-properties': 0
'@typescript-eslint/no-parameter-properties': 0,
},
});

Expand Down
8 changes: 4 additions & 4 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const { prettier, deepmerge } = require('@ice/spec');

module.exports = deepmerge(prettier, {
"tabWidth": 2,
"useTabs": false,
"jsxSingleQuote": true,
"printWidth": 120,
tabWidth: 2,
useTabs: false,
jsxSingleQuote: true,
printWidth: 120,
});
12 changes: 4 additions & 8 deletions extensions/iceworks-app/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/build/**/*.js"
],
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
"outFiles": ["${workspaceFolder}/build/**/*.js"],
"preLaunchTask": "npm: webpack"
},
}
]
}
}
2 changes: 1 addition & 1 deletion extensions/iceworks-app/.vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
}
}
]
}
}
2 changes: 1 addition & 1 deletion extensions/iceworks-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -420,4 +420,4 @@
"url": "https://github.com/ice-lab/iceworks/issues",
"email": "[email protected]"
}
}
}
2 changes: 1 addition & 1 deletion extensions/iceworks-app/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
"iceworksApp.command.nodeDependencies.upgrade.title": "Upgrade Dependency",
"iceworksApp.configuration.properties.iceworks.packageManager.description": "Iceworks npm package manager.",
"iceworksApp.configuration.properties.iceworks.npmRegistry.description": "Iceworks npm registry."
}
}
2 changes: 1 addition & 1 deletion extensions/iceworks-app/package.nls.zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
"iceworksApp.command.nodeDependencies.upgrade.title": "升级依赖",
"iceworksApp.configuration.properties.iceworks.packageManager.description": "Iceworks npm 包管理工具",
"iceworksApp.configuration.properties.iceworks.npmRegistry.description": "Iceworks npm 镜像源"
}
}
2 changes: 1 addition & 1 deletion extensions/iceworks-app/src/commands/executeCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ export default function executeCommand(terminalMapping: ITerminalMap, script: vs

terminal.show();
terminal.sendText(command);
}
}
2 changes: 1 addition & 1 deletion extensions/iceworks-app/src/commands/stopCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ export default function stopCommand(terminalMapping: ITerminalMap, scriptId: str
currentTerminal.dispose();
terminalMapping.delete(scriptId);
}
}
}
13 changes: 2 additions & 11 deletions extensions/iceworks-app/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
import { NodeDepTypes } from './types';

export const entryFileSuffix = [
'.jsx',
'.js',
'.tsx',
'.rml',
'.vue'
];
export const entryFileSuffix = ['.jsx', '.js', '.tsx', '.rml', '.vue'];

export const nodeDepTypes: NodeDepTypes[] = [
'dependencies',
'devDependencies'
];
export const nodeDepTypes: NodeDepTypes[] = ['dependencies', 'devDependencies'];

export const showExtensionsQuickPickCommandId = 'iceworksApp.showExtensionsQuickPick';

Expand Down
22 changes: 15 additions & 7 deletions extensions/iceworks-app/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,24 @@ export async function activate(context: vscode.ExtensionContext) {
subscriptions.push(extensionsStatusBar);
// init webview
function activeWebview() {
const webviewPanel: vscode.WebviewPanel = window.createWebviewPanel('iceworks',
i18n.format('extension.iceworksApp.extension.title'), ViewColumn.One, {
const webviewPanel: vscode.WebviewPanel = window.createWebviewPanel(
'iceworks',
i18n.format('extension.iceworksApp.extension.title'),
ViewColumn.One,
{
enableScripts: true,
retainContextWhenHidden: true,
});
}
);
webviewPanel.webview.html = getHtmlForWebview(extensionPath);
connectService(webviewPanel, context, { services, logger });
}

subscriptions.push(vscode.commands.registerCommand('iceworksApp.configHelper.start', function () {
activeWebview();
}));
subscriptions.push(
vscode.commands.registerCommand('iceworksApp.configHelper.start', function () {
activeWebview();
})
);

if (!rootPath) {
vscode.window.showInformationMessage(i18n.format('extension.iceworksApp.extebsion.emptyWorkplace'));
Expand Down Expand Up @@ -79,6 +85,8 @@ export async function activate(context: vscode.ExtensionContext) {
// DEF publish command in editor title
vscode.commands.executeCommand('setContext', 'iceworks:isAliInternal', isAliInternal);
if (isAliInternal) {
context.subscriptions.push(vscode.commands.registerCommand('iceworksApp.DefPublish', () => showDefPublishEnvQuickPick(terminals, rootPath)));
context.subscriptions.push(
vscode.commands.registerCommand('iceworksApp.DefPublish', () => showDefPublishEnvQuickPick(terminals, rootPath))
);
}
}
2 changes: 1 addition & 1 deletion extensions/iceworks-app/src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ i18n.registry('en', enUSTextMap);
// 设置使用的语言
i18n.setLocal(vscode.env.language);

export default i18n;
export default i18n;
8 changes: 6 additions & 2 deletions extensions/iceworks-app/src/inputBoxs/showDepsInputBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ import { NodeDepTypes, ITerminalMap } from '../types';
import executeCommand from '../commands/executeCommand';
import i18n from '../i18n';

export default async function showDepsInputBox(terminals: ITerminalMap, nodeDependenciesInstance: any, depType: NodeDepTypes) {
export default async function showDepsInputBox(
terminals: ITerminalMap,
nodeDependenciesInstance: any,
depType: NodeDepTypes
) {
const result = await vscode.window.showInputBox({
placeHolder: i18n.format('extension.iceworksApp.showDepsInputBox.materialImport.placeHolder'),
prompt: i18n.format('extension.iceworksApp.showDepsInputBox.materialImport.prompt',{depType})
prompt: i18n.format('extension.iceworksApp.showDepsInputBox.materialImport.prompt', { depType }),
});
if (!result) {
return;
Expand Down
38 changes: 19 additions & 19 deletions extensions/iceworks-app/src/locales/en-US.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"extension.iceworksApp.showExtensionsQuickPick.projectCreater.label": "Iceworks Create Application",
"extension.iceworksApp.showExtensionsQuickPick.projectCreater.detail": "Create a Universal Application(React/Rax/Vue, etc) quickly.",
"extension.iceworksApp.showExtensionsQuickPick.pageBuilder.label": "Iceworks Generate Page",
"extension.iceworksApp.showExtensionsQuickPick.pageBuilder.detail": "Build Page UI by low-code way.",
"extension.iceworksApp.showExtensionsQuickPick.generateComponent.label": "Iceworks Create Component",
"extension.iceworksApp.showExtensionsQuickPick.generateComponent.detail": "Build Component UI by low-code way.",
"extension.iceworksApp.showExtensionsQuickPick.materialImport.label": "Iceworks Import Component",
"extension.iceworksApp.showExtensionsQuickPick.materialImport.detail": "Add Component to the Application in a visual way.",
"extension.iceworksApp.showDepsInputBox.materialImport.placeHolder": "for example: lodash react@latest.",
"extension.iceworksApp.showDepsInputBox.materialImport.prompt": "Please enter the name of the dependency to be addded to <%= depType %>. Multiple dependencies should be spilted by Spaces.",
"extension.iceworksApp.showDefPublishEnvQuickPick.DEFEnvOptions.daily.label": "Daily",
"extension.iceworksApp.showDefPublishEnvQuickPick.DEFEnvOptions.daily.detail": "Release to daily environment.",
"extension.iceworksApp.showDefPublishEnvQuickPick.DEFEnvOptions.prod.label": "Production",
"extension.iceworksApp.showDefPublishEnvQuickPick.DEFEnvOptions.prod.detail": "Release to production environment.",
"extension.iceworksApp.showDepsQuickPick.quickPickItem.detail": "Install <%= label %>",
"extension.iceworksApp.openEntryFile.ErrorMessage": "Cannot find entry",
"extension.iceworksApp.extension.title": "Iceworks Settings",
"extension.iceworksApp.extebsion.emptyWorkplace": "Current workspace is empty, please open or create an application."
}
"extension.iceworksApp.showExtensionsQuickPick.projectCreater.label": "Iceworks Create Application",
"extension.iceworksApp.showExtensionsQuickPick.projectCreater.detail": "Create a Universal Application(React/Rax/Vue, etc) quickly.",
"extension.iceworksApp.showExtensionsQuickPick.pageBuilder.label": "Iceworks Generate Page",
"extension.iceworksApp.showExtensionsQuickPick.pageBuilder.detail": "Build Page UI by low-code way.",
"extension.iceworksApp.showExtensionsQuickPick.generateComponent.label": "Iceworks Create Component",
"extension.iceworksApp.showExtensionsQuickPick.generateComponent.detail": "Build Component UI by low-code way.",
"extension.iceworksApp.showExtensionsQuickPick.materialImport.label": "Iceworks Import Component",
"extension.iceworksApp.showExtensionsQuickPick.materialImport.detail": "Add Component to the Application in a visual way.",
"extension.iceworksApp.showDepsInputBox.materialImport.placeHolder": "for example: lodash react@latest.",
"extension.iceworksApp.showDepsInputBox.materialImport.prompt": "Please enter the name of the dependency to be addded to <%= depType %>. Multiple dependencies should be spilted by Spaces.",
"extension.iceworksApp.showDefPublishEnvQuickPick.DEFEnvOptions.daily.label": "Daily",
"extension.iceworksApp.showDefPublishEnvQuickPick.DEFEnvOptions.daily.detail": "Release to daily environment.",
"extension.iceworksApp.showDefPublishEnvQuickPick.DEFEnvOptions.prod.label": "Production",
"extension.iceworksApp.showDefPublishEnvQuickPick.DEFEnvOptions.prod.detail": "Release to production environment.",
"extension.iceworksApp.showDepsQuickPick.quickPickItem.detail": "Install <%= label %>",
"extension.iceworksApp.openEntryFile.ErrorMessage": "Cannot find entry",
"extension.iceworksApp.extension.title": "Iceworks Settings",
"extension.iceworksApp.extebsion.emptyWorkplace": "Current workspace is empty, please open or create an application."
}
36 changes: 18 additions & 18 deletions extensions/iceworks-app/src/locales/zh-CN.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"extension.iceworksApp.showExtensionsQuickPick.projectCreater.label": "Iceworks 创建应用",
"extension.iceworksApp.showExtensionsQuickPick.projectCreater.detail": "快速创建多端应用(例如:React/Rax/Vue...)",
"extension.iceworksApp.showExtensionsQuickPick.pageBuilder.label": "Iceworks 生成页面",
"extension.iceworksApp.showExtensionsQuickPick.pageBuilder.detail": "使用低代码的方式生成网页视图",
"extension.iceworksApp.showExtensionsQuickPick.generateComponent.label": "Iceworks 生成组件",
"extension.iceworksApp.showExtensionsQuickPick.generateComponent.detail": "使用低代码的方式生成前端组件",
"extension.iceworksApp.showExtensionsQuickPick.materialImport.label": "Iceworks 使用物料",
"extension.iceworksApp.showExtensionsQuickPick.materialImport.detail": "使用可视化的方式添加物料到应用中",
"extension.iceworksApp.showDepsInputBox.materialImport.placeHolder": "例如: lodash react@latest",
"extension.iceworksApp.showDepsInputBox.materialImport.prompt": "请输入需要添加到 <%= depType %> 的依赖名称, 支持通过空格添加多个依赖",
"extension.iceworksApp.showDefPublishEnvQuickPick.DEFEnvOptions.daily.label": "日常环境",
"extension.iceworksApp.showDefPublishEnvQuickPick.DEFEnvOptions.daily.detail": "发布到日常环境",
"extension.iceworksApp.showDefPublishEnvQuickPick.DEFEnvOptions.prod.label": "生产环境",
"extension.iceworksApp.showDefPublishEnvQuickPick.DEFEnvOptions.prod.detail": "发布到生产环境",
"extension.iceworksApp.showDepsQuickPick.quickPickItem.detail": "安装 <%= label %>",
"extension.iceworksApp.openEntryFile.ErrorMessage": "没有找到入口",
"extension.iceworksApp.extension.title": "设置 - Iceworks",
"extension.iceworksApp.extebsion.emptyWorkplace": "当前工作区为空,请打开应用或新建应用。"
"extension.iceworksApp.showExtensionsQuickPick.projectCreater.label": "Iceworks 创建应用",
"extension.iceworksApp.showExtensionsQuickPick.projectCreater.detail": "快速创建多端应用(例如:React/Rax/Vue...)",
"extension.iceworksApp.showExtensionsQuickPick.pageBuilder.label": "Iceworks 生成页面",
"extension.iceworksApp.showExtensionsQuickPick.pageBuilder.detail": "使用低代码的方式生成网页视图",
"extension.iceworksApp.showExtensionsQuickPick.generateComponent.label": "Iceworks 生成组件",
"extension.iceworksApp.showExtensionsQuickPick.generateComponent.detail": "使用低代码的方式生成前端组件",
"extension.iceworksApp.showExtensionsQuickPick.materialImport.label": "Iceworks 使用物料",
"extension.iceworksApp.showExtensionsQuickPick.materialImport.detail": "使用可视化的方式添加物料到应用中",
"extension.iceworksApp.showDepsInputBox.materialImport.placeHolder": "例如: lodash react@latest",
"extension.iceworksApp.showDepsInputBox.materialImport.prompt": "请输入需要添加到 <%= depType %> 的依赖名称, 支持通过空格添加多个依赖",
"extension.iceworksApp.showDefPublishEnvQuickPick.DEFEnvOptions.daily.label": "日常环境",
"extension.iceworksApp.showDefPublishEnvQuickPick.DEFEnvOptions.daily.detail": "发布到日常环境",
"extension.iceworksApp.showDefPublishEnvQuickPick.DEFEnvOptions.prod.label": "生产环境",
"extension.iceworksApp.showDefPublishEnvQuickPick.DEFEnvOptions.prod.detail": "发布到生产环境",
"extension.iceworksApp.showDepsQuickPick.quickPickItem.detail": "安装 <%= label %>",
"extension.iceworksApp.openEntryFile.ErrorMessage": "没有找到入口",
"extension.iceworksApp.extension.title": "设置 - Iceworks",
"extension.iceworksApp.extebsion.emptyWorkplace": "当前工作区为空,请打开应用或新建应用。"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,30 @@ import i18n from '../i18n';
const { window } = vscode;

export default function showDefPublishEnvQuickPick(terminalMapping: ITerminalMap, rootPath: string) {

const DEFEnvOptions = [
{ label: i18n.format('extension.iceworksApp.showDefPublishEnvQuickPick.DEFEnvOptions.daily.label'),
detail: i18n.format('extension.iceworksApp.showDefPublishEnvQuickPick.DEFEnvOptions.daily.detail'), command: 'def p -d' },
{ label: i18n.format('extension.iceworksApp.showDefPublishEnvQuickPick.DEFEnvOptions.prod.label'),
detail: i18n.format('extension.iceworksApp.showDefPublishEnvQuickPick.DEFEnvOptions.prod.detail'), command: 'def p -o' },
]

{
label: i18n.format('extension.iceworksApp.showDefPublishEnvQuickPick.DEFEnvOptions.daily.label'),
detail: i18n.format('extension.iceworksApp.showDefPublishEnvQuickPick.DEFEnvOptions.daily.detail'),
command: 'def p -d',
},
{
label: i18n.format('extension.iceworksApp.showDefPublishEnvQuickPick.DEFEnvOptions.prod.label'),
detail: i18n.format('extension.iceworksApp.showDefPublishEnvQuickPick.DEFEnvOptions.prod.detail'),
command: 'def p -o',
},
];

const quickPick = window.createQuickPick();
quickPick.items = DEFEnvOptions.map((options) => ({ label: options.label, detail: options.detail }));
quickPick.onDidChangeSelection(selection => {
quickPick.onDidChangeSelection((selection) => {
if (selection[0]) {
const env = DEFEnvOptions.find(option => option.label === selection[0].label)!;
const env = DEFEnvOptions.find((option) => option.label === selection[0].label)!;
const command: vscode.Command = {
title: 'Publish',
command: 'iceworksApp.DefPublish',
arguments: [rootPath, env.command]
}
executeCommand(terminalMapping, command, `DefPublish-${env.label}`)
arguments: [rootPath, env.command],
};
executeCommand(terminalMapping, command, `DefPublish-${env.label}`);
quickPick.dispose();
}
});
Expand Down
12 changes: 7 additions & 5 deletions extensions/iceworks-app/src/quickPicks/showDepsQuickPick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import i18n from '../i18n';

export default function showDepsQuickPick(terminals: ITerminalMap, nodeDependenciesInstance: any) {
const quickPick = vscode.window.createQuickPick();
quickPick.items = nodeDepTypes.map(label => ({ label, detail: i18n.format('extension.iceworksApp.showDepsQuickPick.quickPickItem.detail',{label}) }));
quickPick.onDidChangeSelection(selection => {
quickPick.items = nodeDepTypes.map((label) => ({
label,
detail: i18n.format('extension.iceworksApp.showDepsQuickPick.quickPickItem.detail', { label }),
}));
quickPick.onDidChangeSelection((selection) => {
if (selection[0]) {
showDepsInputBox(terminals, nodeDependenciesInstance, selection[0].label as NodeDepTypes)
.catch(console.error);
showDepsInputBox(terminals, nodeDependenciesInstance, selection[0].label as NodeDepTypes).catch(console.error);
}
});
quickPick.onDidHide(() => quickPick.dispose());
quickPick.show();
};
}
36 changes: 22 additions & 14 deletions extensions/iceworks-app/src/quickPicks/showExtensionsQuickPick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,32 @@ const { window, commands } = vscode;

export default function showExtensionsQuickPick() {
const extensionOptions = [
{ label: i18n.format('extension.iceworksApp.showExtensionsQuickPick.projectCreater.label'),
detail: i18n.format('extension.iceworksApp.showExtensionsQuickPick.projectCreater.detail'),
command: 'iceworks-project-creator.start', },
{ label: i18n.format('extension.iceworksApp.showExtensionsQuickPick.pageBuilder.label'),
detail: i18n.format('extension.iceworksApp.showExtensionsQuickPick.pageBuilder.detail'),
command: 'iceworks-page-builder.create', },
{ label: i18n.format('extension.iceworksApp.showExtensionsQuickPick.generateComponent.label'),
detail: i18n.format('extension.iceworksApp.showExtensionsQuickPick.generateComponent.detail'),
command: 'iceworks-component-builder.generate' },
{ label: i18n.format('extension.iceworksApp.showExtensionsQuickPick.materialImport.label'),
{
label: i18n.format('extension.iceworksApp.showExtensionsQuickPick.projectCreater.label'),
detail: i18n.format('extension.iceworksApp.showExtensionsQuickPick.projectCreater.detail'),
command: 'iceworks-project-creator.start',
},
{
label: i18n.format('extension.iceworksApp.showExtensionsQuickPick.pageBuilder.label'),
detail: i18n.format('extension.iceworksApp.showExtensionsQuickPick.pageBuilder.detail'),
command: 'iceworks-page-builder.create',
},
{
label: i18n.format('extension.iceworksApp.showExtensionsQuickPick.generateComponent.label'),
detail: i18n.format('extension.iceworksApp.showExtensionsQuickPick.generateComponent.detail'),
command: 'iceworks-component-builder.generate',
},
{
label: i18n.format('extension.iceworksApp.showExtensionsQuickPick.materialImport.label'),
detail: i18n.format('extension.iceworksApp.showExtensionsQuickPick.materialImport.detail'),
command: 'iceworks-material-import.start' },
]
command: 'iceworks-material-import.start',
},
];
const quickPick = window.createQuickPick();
quickPick.items = extensionOptions.map((options) => ({ label: options.label, detail: options.detail }));
quickPick.onDidChangeSelection(selection => {
quickPick.onDidChangeSelection((selection) => {
if (selection[0]) {
const currentExtension = extensionOptions.find(option => option.label === selection[0].label)!;
const currentExtension = extensionOptions.find((option) => option.label === selection[0].label)!;
commands.executeCommand(currentExtension.command);
quickPick.dispose();
}
Expand Down
2 changes: 1 addition & 1 deletion extensions/iceworks-app/src/services.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as common from '@iceworks/common-service';
import * as material from '@iceworks/material-service';

export default { common, material };
export default { common, material };
Loading

0 comments on commit f536ba9

Please sign in to comment.