-
Notifications
You must be signed in to change notification settings - Fork 577
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(boilerplate): add midway-ts-strict-boilerplate
- use `TypeScript ESlint` instead of `TSlint` - enable more strict lint rules - use ng filename style, `file.{controller|service|model}.ts` - no use of Prettier cause of the ugly breakBeforeElse style and the team won't add options for other style refs: - [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint) - [TSLint will be deprecated](palantir/tslint#4534) - [Eslint: Migrating to v6.0.0](https://eslint.org/docs/user-guide/migrating-to-6.0.0#package-loading-simplification)
- Loading branch information
1 parent
a9114d3
commit 8ee325c
Showing
28 changed files
with
583 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
packages/midway-init/boilerplate/midway-ts-strict-boilerplate/boilerplate/.editorconfig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# http://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
max_line_length = off | ||
trim_trailing_whitespace = false | ||
|
||
[Makefile] | ||
indent_style = tab |
6 changes: 6 additions & 0 deletions
6
packages/midway-init/boilerplate/midway-ts-strict-boilerplate/boilerplate/.eslintrc.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
extends: '@waiting/eslint-config' | ||
|
||
# https://eslint.org/docs/rules/ | ||
# https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin | ||
#rules: | ||
|
34 changes: 34 additions & 0 deletions
34
...ages/midway-init/boilerplate/midway-ts-strict-boilerplate/boilerplate/.vscode/launch.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
// 使用 IntelliSense 了解相关属性。 | ||
// 悬停以查看现有属性的描述。 | ||
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Midway Debug", | ||
"type": "node", | ||
"autoAttachChildProcesses": true, | ||
"console": "integratedTerminal", | ||
"env": { | ||
"NODE_ENV": "local" | ||
}, | ||
"port": 9229, | ||
"preLaunchTask": "TypeScript compile", | ||
"protocol": "auto", | ||
"request": "launch", | ||
"restart": true, | ||
"runtimeArgs": [ | ||
"run", | ||
"debug", | ||
"--", | ||
"--inspect-brk" | ||
], | ||
"runtimeExecutable": "npm", | ||
"skipFiles": [ | ||
// "${workspaceFolder}/node_modules/**/*.js", | ||
"${workspaceFolder}/node_modules/rxjs/**/*.js", | ||
"<node_internals>/**/*.js" | ||
] | ||
} | ||
] | ||
} |
81 changes: 81 additions & 0 deletions
81
...es/midway-init/boilerplate/midway-ts-strict-boilerplate/boilerplate/.vscode/settings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
{ | ||
"editor.tabSize": 2, | ||
"editor.wordWrap": "on", | ||
"eslint.autoFixOnSave": true, | ||
"eslint.validate": [ | ||
"javascript", | ||
"javascriptreact", | ||
"html", | ||
{ | ||
"language": "typescript", | ||
"autoFix": true | ||
}, | ||
"typescriptreact" | ||
], | ||
"files.insertFinalNewline": true, | ||
"files.eol": "\n", | ||
"files.exclude": { | ||
"USE_GITIGNORE": true, | ||
"**/*.js": { | ||
"when": "$(basename).ts" | ||
}, | ||
"**/*.map": true, | ||
"**/*.swp": true, | ||
"**/.git": true, | ||
"**/.DS_Store": true, | ||
".build": true, | ||
".dockerignore": true, | ||
".eslint*": true, | ||
".editorconfig": true, | ||
".git": true, | ||
".gitignore": true, | ||
".githooks": true, | ||
".npmignore": true, | ||
".nyc_output": true, | ||
".sourcemaps": true, | ||
".travis.yml": true, | ||
".vscode": true, | ||
"appveyor.yml": true, | ||
"commitlint.config.js": true, | ||
"coverage": true, | ||
"dist": true, | ||
"logs": true, | ||
"node_modules*": true, | ||
"out": true, | ||
"package-lock.json": true, | ||
"platforms": true, | ||
"rollup.config.js": true, | ||
"run": true, | ||
"tslint.json": true | ||
}, | ||
"files.watcherExclude": { | ||
"**/.classpath": true, | ||
"**/.factorypath": true, | ||
"**/.git/objects/**": true, | ||
"**/.project": true, | ||
"**/.settings": true, | ||
"**/node_modules/**": true, | ||
"**/node_modules*/**": true, | ||
"coverage/**": true, | ||
"dist/**": true | ||
}, | ||
"files.trimTrailingWhitespace": true, | ||
"search.exclude": { | ||
"**/node_modules": true, | ||
".vscode/**": true, | ||
".build/**": true, | ||
"dist/": true, | ||
"out/**": true, | ||
"i18n/**": true | ||
}, | ||
"[markdown]": { | ||
"files.trimTrailingWhitespace": false | ||
}, | ||
"telemetry.enableTelemetry": false, | ||
"typescript.format.enable": true, | ||
"typescript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": false, | ||
"typescript.format.insertSpaceAfterTypeAssertion": true, | ||
"typescript.format.insertSpaceBeforeAndAfterBinaryOperators": true, | ||
"typescript.updateImportsOnFileMove.enabled": "always", | ||
"git.ignoreLimitWarning": true | ||
} |
50 changes: 50 additions & 0 deletions
50
packages/midway-init/boilerplate/midway-ts-strict-boilerplate/boilerplate/.vscode/tasks.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
// 有关 tasks.json 格式的文档,请参见 | ||
// https://go.microsoft.com/fwlink/?LinkId=733558 | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "TypeScript compile", | ||
"command": "tsc", | ||
"args": [ | ||
"-p", | ||
"." | ||
], | ||
"problemMatcher": [ | ||
"$tsc" | ||
], | ||
"type": "shell" | ||
}, | ||
{ | ||
"label": "watch", | ||
"command": "tsc", | ||
"args": [ | ||
"-w", | ||
"-p", | ||
"." | ||
], | ||
"isBackground": true, | ||
"problemMatcher": [ | ||
"$tsc-watch" | ||
], | ||
"type": "shell" | ||
}, | ||
{ | ||
// Ctrl+Shift+B | ||
"type": "npm", | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
}, | ||
"presentation": { | ||
"reveal": "silent" | ||
}, | ||
"problemMatcher": [ | ||
"$eslint-stylish", | ||
"$tsc", | ||
"$tslint5" | ||
], | ||
"script": "build" | ||
} | ||
] | ||
} |
33 changes: 33 additions & 0 deletions
33
...ages/midway-init/boilerplate/midway-ts-strict-boilerplate/boilerplate/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# {{name}} | ||
|
||
{{description}} | ||
|
||
## QuickStart | ||
|
||
<!-- add docs here for user --> | ||
|
||
see [midway docs][midway] for more detail. | ||
|
||
### Development | ||
|
||
```bash | ||
$ npm i | ||
$ npm run dev | ||
$ open http://localhost:7001/ | ||
``` | ||
|
||
### Deploy | ||
|
||
```bash | ||
$ npm start | ||
$ npm stop | ||
``` | ||
|
||
### npm scripts | ||
|
||
- Use `npm run lint` to check code style. | ||
- Use `npm test` to run unit test. | ||
- Use `npm run autod` to auto detect dependencies upgrade, see [autod](https://www.npmjs.com/package/autod) for more detail. | ||
|
||
|
||
[midway]: https://midwayjs.org |
39 changes: 39 additions & 0 deletions
39
...idway-init/boilerplate/midway-ts-strict-boilerplate/boilerplate/README.zh-CN.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# {{name}} | ||
|
||
{{description}} | ||
|
||
## 快速入门 | ||
|
||
<!-- 在此次添加使用文档 --> | ||
|
||
如需进一步了解,参见 [midway 文档][midway]。 | ||
|
||
### 本地开发 | ||
|
||
```bash | ||
$ npm i | ||
$ npm run dev | ||
$ open http://localhost:7001/ | ||
``` | ||
|
||
### 部署 | ||
|
||
```bash | ||
$ npm start | ||
$ npm stop | ||
``` | ||
|
||
### 单元测试 | ||
|
||
- [midway-bin] 内置了 [mocha], [thunk-mocha], [power-assert], [istanbul] 等框架,让你可以专注于写单元测试,无需理会配套工具。 | ||
- 断言库非常推荐使用 [power-assert]。 | ||
- 具体参见 [midway 文档 - 单元测试](https://eggjs.org/zh-cn/core/unittest)。 | ||
|
||
### 内置指令 | ||
|
||
- 使用 `npm run lint` 来做代码风格检查。 | ||
- 使用 `npm test` 来执行单元测试。 | ||
- 使用 `npm run autod` 来自动检测依赖更新,详细参见 [autod](https://www.npmjs.com/package/autod) 。 | ||
|
||
|
||
[midway]: https://midwayjs.org |
12 changes: 12 additions & 0 deletions
12
packages/midway-init/boilerplate/midway-ts-strict-boilerplate/boilerplate/_.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
logs/ | ||
npm-debug.log | ||
yarn-error.log | ||
node_modules/ | ||
package-lock.json | ||
yarn.lock | ||
coverage/ | ||
.idea/ | ||
run/ | ||
.DS_Store | ||
*.sw* | ||
*.un~ |
51 changes: 51 additions & 0 deletions
51
packages/midway-init/boilerplate/midway-ts-strict-boilerplate/boilerplate/_package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
"name": "{{name}}", | ||
"version": "1.0.0", | ||
"description": "{{description}}", | ||
"private": true, | ||
"dependencies": { | ||
"midway": "^1.0.0", | ||
"egg-scripts": "^2.10.0" | ||
}, | ||
"devDependencies": { | ||
"@types/mocha": "^5.2.5", | ||
"@types/node": "^10.5.5", | ||
"@typescript-eslint/eslint-plugin": "^1.11.0", | ||
"@typescript-eslint/eslint-plugin-tslint": "^1.11.0", | ||
"@typescript-eslint/parser": "^1.11.0", | ||
"@waiting/eslint-config": "^1.0.0", | ||
"cross-env": "^5.2.0", | ||
"egg-ci": "^1.8.0", | ||
"eslint": "^6.0.0", | ||
"eslint-plugin-import": "^2.18.0", | ||
"midway-bin": "1", | ||
"midway-mock": "1", | ||
"tslib": "^1.8.1", | ||
"ts-node": "^8.0.2", | ||
"typescript": "^3.2.0" | ||
}, | ||
"engines": { | ||
"node": ">=8.9.0" | ||
}, | ||
"scripts": { | ||
"start": "egg-scripts start --daemon --title=egg-server-{{name}} --framework=midway", | ||
"stop": "egg-scripts stop --title=egg-server-{{name}}", | ||
"start_build": "npm run build && cross-env NODE_ENV=development midway-bin dev", | ||
"dev": "cross-env NODE_ENV=local midway-bin dev --ts", | ||
"debug": "cross-env NODE_ENV=local midway-bin debug --ts", | ||
"test": "npm run lint && midway-bin test --ts", | ||
"cov": "midway-bin cov --ts", | ||
"lint": "eslint --fix src/**/*.{ts,js} test/**/*.{ts,js}", | ||
"ci": "npm run cov", | ||
"build": "midway-bin build -c" | ||
}, | ||
"ci": { | ||
"version": "8, 10" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "" | ||
}, | ||
"author": "{{author}}", | ||
"license": "MIT" | ||
} |
32 changes: 32 additions & 0 deletions
32
packages/midway-init/boilerplate/midway-ts-strict-boilerplate/boilerplate/procfile.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// you can use this file to deploy by pandora | ||
// please use 'npm i pandora --save' first | ||
|
||
'use strict'; | ||
|
||
module.exports = pandora => { | ||
|
||
/** | ||
* default is fork mode | ||
*/ | ||
pandora | ||
.fork('{{name}}', require.resolve('midway/server')); | ||
|
||
/** | ||
* you can use cluster mode to start application | ||
*/ | ||
// pandora | ||
// .cluster('./cluster.js'); | ||
|
||
/** | ||
* you can create another process here | ||
*/ | ||
// pandora | ||
// .process('background') | ||
// .argv(['--expose-gc']); | ||
|
||
/** | ||
* more features please visit our document. | ||
* https://github.com/midwayjs/pandora/ | ||
*/ | ||
|
||
}; |
18 changes: 18 additions & 0 deletions
18
...init/boilerplate/midway-ts-strict-boilerplate/boilerplate/src/app/home/home.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Context, config, controller, get, provide } from 'midway' | ||
|
||
|
||
@provide() | ||
@controller('/') | ||
export class HomeController { | ||
|
||
constructor( | ||
@config() private readonly welcomeMsg: string, | ||
) {} | ||
|
||
@get('/') | ||
public index(ctx: Context): void { | ||
ctx.body = this.welcomeMsg | ||
} | ||
|
||
} | ||
|
1 change: 1 addition & 0 deletions
1
...t/boilerplate/midway-ts-strict-boilerplate/boilerplate/src/app/public/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
## public static file directory! |
Binary file added
BIN
+1.31 KB
...boilerplate/midway-ts-strict-boilerplate/boilerplate/src/app/public/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.