Skip to content

Commit

Permalink
让prettier正常工作
Browse files Browse the repository at this point in the history
  • Loading branch information
Eished committed Aug 10, 2022
1 parent a3942d8 commit 72af7f5
Show file tree
Hide file tree
Showing 7 changed files with 198 additions and 2 deletions.
72 changes: 72 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"editor.tabSize": 2,
"editor.wordWrap": "on",
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
"eslint.validate": ["javascript", "html", "vue", "typescript"],
"eslint.format.enable": true,
"eslint.options": {
"overrideConfig": {
"env": {
"browser": true,
"node": true,
"es2021": true
},
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": "latest",
"sourceType": "module"
},
"rules": {
"no-debugger": "off"
}
}
},
"editor.formatOnSave": true,
"html.format.indentHandlebars": true,
"html.format.preserveNewLines": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true,
"source.fixAll": true,
"source.fixAll.eslint": false
},
"emmet.includeLanguages": {
"vue": "html",
"javascript": "html"
},
"[vue]": {
"editor.defaultFormatter": "octref.vetur"
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
// vue backup
"vetur.format.defaultFormatterOptions": {
"prettier": {
"semi": true,
"printWidth": 120,
"singleQuote": false,
"trailingComma": "aways",
"arrowParens": "aways"
}
},
"vetur.format.defaultFormatter.js": "prettier-eslint",
"vetur.format.defaultFormatter.html": "js-beautify-html"
}
1 change: 1 addition & 0 deletions Typescript学习笔记.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ npm install @tsconfig/node16 --save-dev # 非必要

```bash
npm install eslint --save-dev
npm i prettier eslint-plugin-prettier eslint-config-prettier -D
npm install @typescript-eslint/parser @typescript-eslint/eslint-plugin --save-dev
```

Expand Down
103 changes: 103 additions & 0 deletions typescript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
"@typescript-eslint/eslint-plugin": "^5.33.0",
"@typescript-eslint/parser": "^5.33.0",
"eslint": "^8.21.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"nodemon": "^2.0.19",
"prettier": "^2.7.1",
"ts-node": "^10.9.1",
"typescript": "^4.7.4"
}
Expand Down
2 changes: 2 additions & 0 deletions typescript/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import './utilityType'

const world = 'world'

export function hello(who: string = world): string {
Expand Down
15 changes: 15 additions & 0 deletions typescript/src/utilityType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export const enum Direction {
up = 'up',
left = 'left',
right = 'right',
down = 'down',
}

type DirectionType = keyof typeof Direction

const directionToRotation: Record<DirectionType, string> = {
right: '-90',
left: '90',
up: '180',
down: '0',
}
4 changes: 2 additions & 2 deletions typescript/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"alwaysStrict": true, // 以严格模式检查每个模块,并在每个文件里加入 'use strict'

/* 额外的检查 */
"noUnusedLocals": true, // 有未使用的变量时,抛出错误
"noUnusedParameters": true, // 有未使用的参数时,抛出错误
"noUnusedLocals": false, // 有未使用的变量时,抛出错误
"noUnusedParameters": false, // 有未使用的参数时,抛出错误
"noImplicitReturns": true, // 并不是所有函数里的代码都有返回值时,抛出错误
"noFallthroughCasesInSwitch": true, // 报告 switch 语句的 fallthrough 错误。(即,不允许 switch 的 case 语句贯穿)

Expand Down

0 comments on commit 72af7f5

Please sign in to comment.