Skip to content

Commit

Permalink
format: 使用prettier作为格式化工具
Browse files Browse the repository at this point in the history
添加全局格式化命令script:format
添加vscode自动格式化设置
  • Loading branch information
neko-para committed Apr 25, 2023
1 parent 83b373e commit 63d27ab
Show file tree
Hide file tree
Showing 162 changed files with 6,020 additions and 5,414 deletions.
112 changes: 56 additions & 56 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
const path = require("path");

module.exports = {
root: true,
env: {
browser: true,
es2021: true,
node: true,
"vue/setup-compiler-macros": true,
},
parserOptions: {
ecmaVersion: 12,
sourceType: "module",
project: [
path.join(__dirname, "packages/renderer/tsconfig.json"),
path.join(__dirname, "packages/main/tsconfig.json"),
],
},
plugins: ["vue", "@typescript-eslint"],
extends: [
"eslint:recommended",
"plugin:vue/vue3-recommended",
"plugin:vue/vue3-essential",
"standard-with-typescript",
"@vue/eslint-config-typescript",
],
rules: {
"vue/max-len": [
"error",
{
code: 120,
template: 120,
},
],
"no-undef": "off", // 让ts检查undefined
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/strict-boolean-expressions": "off",
"vue/multi-word-component-names": "off",
"vue/max-attributes-per-line": [
"error",
{
singleline: {
max: 3,
},
multiline: {
max: 1,
},
},
],
"@typescript-eslint/promise-function-async": "off",
"@typescript-eslint/naming-convention": "off",
"camelcase": "off",
"vue/prop-name-casing": "off",
"space-before-function-paren": "off",
},
};
const path = require('path')

module.exports = {
root: true,
env: {
browser: true,
es2021: true,
node: true,
'vue/setup-compiler-macros': true,
},
parserOptions: {
ecmaVersion: 12,
sourceType: 'module',
project: [
path.join(__dirname, 'packages/renderer/tsconfig.json'),
path.join(__dirname, 'packages/main/tsconfig.json'),
],
},
plugins: ['vue', '@typescript-eslint'],
extends: [
'eslint:recommended',
'plugin:vue/vue3-recommended',
'plugin:vue/vue3-essential',
'standard-with-typescript',
'@vue/eslint-config-typescript',
],
rules: {
'vue/max-len': [
'error',
{
code: 120,
template: 120,
},
],
'no-undef': 'off', // 让ts检查undefined
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/strict-boolean-expressions': 'off',
'vue/multi-word-component-names': 'off',
'vue/max-attributes-per-line': [
'error',
{
singleline: {
max: 3,
},
multiline: {
max: 1,
},
},
],
'@typescript-eslint/promise-function-async': 'off',
'@typescript-eslint/naming-convention': 'off',
camelcase: 'off',
'vue/prop-name-casing': 'off',
'space-before-function-paren': 'off',
},
}
6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
packages/common/ArknightsGameData/**
*.md
*.yml
*.yaml
*.json
*.html
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"trailingComma": "es5",
"semi": false,
"singleQuote": true,
"arrowParens": "avoid",
"vueIndentScriptAndStyle": false,
"printWidth": 80
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@
"packages/renderer/src/i18n"
],
"i18n-ally.keystyle": "nested",
"[javascript][typescript][vue][css][less]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
24 changes: 12 additions & 12 deletions forge.config.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
const info = require('./package.json');
const info = require('./package.json')

module.exports = {
packagerConfig: {
icon: 'packages/common/resources/icon',
appBundleId: 'com.maa.maa-x',
productName: 'MaaX',
ignore: (filepath) => {
ignore: filepath => {
if (filepath.length === 0) {
return false;
return false
}
if (/^\/dist/.test(filepath)) {
return false;
return false
}
if (/^\/package.json/.test(filepath)) {
return false;
return false
}
if (/^\/node_modules/.test(filepath)) {
return false;
return false
}
return true;
return true
},
// asar: true,
},
Expand Down Expand Up @@ -64,9 +64,9 @@ module.exports = {
config: {
repository: {
owner: 'MaaAssistantArknights',
name: 'MaaX'
name: 'MaaX',
},
}
}
]
};
},
},
],
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"make": "electron-forge make",
"start": "electron-forge start",
"package": "electron-forge package",
"publish": "electron-forge publish"
"publish": "electron-forge publish",
"format": "npx prettier -w ."
},
"engines": {
"node": ">=18.12.0"
Expand Down
9 changes: 6 additions & 3 deletions packages/@types/api/service.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
interface ApiServiceProvider {
get: <T>(url: string, config?: import('axios').AxiosRequestConfig) => Promise<T | Error>
}
interface ApiServiceProvider {
get: <T>(
url: string,
config?: import('axios').AxiosRequestConfig
) => Promise<T | Error>
}
5 changes: 1 addition & 4 deletions packages/@types/componentManager/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
type ComponentType =
| 'Maa Core'
| 'Maa App'
| 'Android Platform Tools'
type ComponentType = 'Maa Core' | 'Maa App' | 'Android Platform Tools'

type ComponentStatus =
| 'not-installed'
Expand Down
2 changes: 1 addition & 1 deletion packages/@types/coreLoader/ipc.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
enum TouchMode {
minitouch = 'minitouch',
maatouch = 'maatouch',
adb = 'adb'
adb = 'adb',
}

interface InitCoreParam {
Expand Down
6 changes: 3 additions & 3 deletions packages/@types/deviceDetector/adapterBase.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ interface EmulatorAdapter {
getAdbDevices: () => Promise<Device[]>

/**
* @description Get all emulators
* @returns {Promise<Emulator[]>}
*/
* @description Get all emulators
* @returns {Promise<Emulator[]>}
*/
getEmulators: () => Promise<Emulator[]>
}

Expand Down
2 changes: 1 addition & 1 deletion packages/@types/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { MessageApiInjection } from 'naive-ui/lib/message/src/MessageProvider'
import type { DialogApiInjection } from 'naive-ui/lib/dialog/src/DialogProvider'
export { }
export {}

declare global {
interface Window {
Expand Down
4 changes: 1 addition & 3 deletions packages/@types/i18n/boolean.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
type BooleanDisplayOption =
| 'Right/Wrong'
| 'Yes/No'
type BooleanDisplayOption = 'Right/Wrong' | 'Yes/No'
10 changes: 8 additions & 2 deletions packages/@types/ipc/ipc-events.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,16 @@ type IpcRendererHandleEvent =

interface IpcMainEvent<T> {
name: IpcMainHandleEvent
listener: (event: import('electron').IpcMainInvokeEvent, ...args: any[]) => Promise<T> | T | undefined
listener: (
event: import('electron').IpcMainInvokeEvent,
...args: any[]
) => Promise<T> | T | undefined
}

interface IpcRendererEvent<T> {
name: IpcRendererHandleEvent
listener: (event: import('electron').IpcRendererEvent, ...args: any[]) => Promise<T> | T | undefined
listener: (
event: import('electron').IpcRendererEvent,
...args: any[]
) => Promise<T> | T | undefined
}
8 changes: 4 additions & 4 deletions packages/@types/module.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
interface Module {
readonly version: string
readonly name: string
}
interface Module {
readonly version: string
readonly name: string
}
2 changes: 1 addition & 1 deletion packages/@types/store/store.device.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ interface Device {
/**
* @props 模拟器命令行参数
* @description 启动参数, 比如蓝叠启动指定实例的 "--instance" "114514"
*/
*/
commandLine?: string
}

Expand Down
6 changes: 3 additions & 3 deletions packages/@types/store/store.task.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ type TaskName =
| 'copilot'
| 'idle'

type CoreTaskName =
type CoreTaskName =
| 'Emulator'
| 'StartUp'
| 'Fight'
| 'Recruit'
|'Infrast'
| 'Infrast'
| 'Visit'
| 'Mall'
| 'Award'
Expand Down Expand Up @@ -110,7 +110,7 @@ interface TaskGroup {
id: number
/**
* @props 任务组内的任务列表
*/
*/
tasks: Task[]
}

Expand Down
Loading

0 comments on commit 63d27ab

Please sign in to comment.