Skip to content

Commit

Permalink
chore: 添加“commitizen => husky => lint-staged => prettier”工具链
Browse files Browse the repository at this point in the history
TODO: 目前 madge 只能检测 JS 循环依赖,因此需要先执行 `npm run build_cjs` 再执行 `npm run
check_circular_dependencies`,期待以后能够直接对 TS 文件做检测
  • Loading branch information
aicest committed Mar 7, 2018
1 parent 6ab9eb9 commit eb254ab
Show file tree
Hide file tree
Showing 7 changed files with 1,660 additions and 55 deletions.
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[*]
charset = utf-8
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
6 changes: 6 additions & 0 deletions .huskyrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"hooks": {
"pre-commit": "lint-staged",
"pre-push": "npm test"
}
}
4 changes: 4 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"*.{js,json,md}": ["prettier --write", "git add"],
"*.ts": ["prettier --write", "tslint --fix", "git add"]
}
13 changes: 13 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"arrowParens": "always",
"semi": false,
"singleQuote": true,
"overrides": [
{
"files": "{tslint.json,package.json}",
"options": {
"printWidth": 1e3
}
}
]
}
19 changes: 13 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"lint": "tslint ./src/**/*.ts ./mock/**/*.ts ./test/*.ts ./test/apis/**/*.ts ./test/mock/**/*.ts ./test/utils/**/*.ts",
"publish_sdk": "npm run build_all && npm run copy_files && npm publish ./dist/cjs",
"publish_all": "npm run publish_sdk && ts-node --type-check ./tools/tasks/publish.ts && cp -r ./dist/mock-cjs/** ./.tmp/mock && cp -r ./dist/socket/** ./.tmp/socket && npm publish .tmp/mock/ && npm publish .tmp/socket/",
"test": "npm run lint && npm run cover",
"test": "npm run lint && npm run build_cjs && npm run check_circular_dependencies && npm run cover",
"version": "ts-node tools/tasks/version.ts && git add .",
"watch": "export TZ=\"EST+5\"; npm run watch_test & ts-node ./tools/tasks/test.ts $!",
"watch_cjs": "tsc src/index.ts -m commonjs --outDir dist/cjs --sourcemap --inlineSources --target ES5 -d --diagnostics --pretty --experimentalDecorators --strict --noUnusedLocals --noUnusedParameters --suppressImplicitAnyIndexErrors --moduleResolution node --skipLibCheck -w --lib es5,es2015.iterable,es2015.collection,es2015.promise,es2015.core,dom",
Expand All @@ -29,17 +29,18 @@
"type": "git",
"url": "git+ssh://[email protected]/teambition/teambition-sdk.git"
},
"keywords": [
"teambition",
"sdk",
"teambition-sdk"
],
"keywords": ["teambition", "sdk", "teambition-sdk"],
"author": "[email protected]",
"license": "MIT",
"bugs": {
"url": "https://github.com/teambition/teambition-sdk/issues"
},
"homepage": "https://github.com/teambition/teambition-sdk#readme",
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
},
"peerDependencies": {
"reactivedb": "~0.9.13",
"rrule": "2.2.0",
Expand All @@ -55,16 +56,21 @@
"@types/sinon": "^4.0.0",
"@types/sinon-chai": "^2.7.29",
"chai": "^4.1.2",
"commitizen": "^2.9.6",
"coveralls": "^3.0.0",
"cz-conventional-changelog": "^2.1.0",
"engine.io-client": "^3.1.0",
"fetch-mock": "^5.12.2",
"google-closure-compiler-js": "^20180101.0.0",
"husky": "^0.15.0-rc.8",
"isomorphic-fetch": "^2.2.1",
"jsonrpc-lite": "^1.3.0",
"lint-staged": "^7.0.0",
"madge": "^1.6.0",
"moment": "^2.18.1",
"node-watch": "^0.5.5",
"nyc": "^11.2.1",
"prettier": "^1.11.1",
"reactivedb": "~0.9.13",
"rollup": "^0.54.0",
"rollup-plugin-alias": "^1.3.1",
Expand All @@ -80,6 +86,7 @@
"ts-node": "^4.0.0",
"tslib": "^1.7.1",
"tslint": "^5.7.0",
"tslint-config-prettier": "^1.9.0",
"tslint-eslint-rules": "^4.1.1",
"typescript": "^2.6.2"
}
Expand Down
38 changes: 15 additions & 23 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"extends": ["tslint-eslint-rules"],
"extends": ["tslint-eslint-rules", "tslint-config-prettier"],
"rules": {
"curly": true,
"eofline": true,
"align": [true, "parameters"],
"class-name": true,
"indent": [true, 2],
"indent": [true, "spaces", 2],
"max-line-length": [true, 150],
"no-consecutive-blank-lines": true,
"no-trailing-whitespace": true,
Expand All @@ -20,31 +20,23 @@
"no-require-imports": false,
"no-shadowed-variable": true,
"object-curly-spacing": true,
"one-line": [true,
"check-else",
"check-whitespace",
"check-open-brace"],
"one-line": [true, "check-else", "check-whitespace", "check-open-brace"],
"prefer-const": true,
"quotemark": [true,
"single",
"avoid-escape",
"jsx-single"],
"quotemark": [true, "single", "avoid-escape", "jsx-single"],
"semicolon": [true, "never"],
"ter-prefer-arrow-callback": true,
"typedef-whitespace": [true, {
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"use-isnan": true,
"whitespace": [true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"],
"whitespace": [true, "check-branch", "check-decl", "check-operator", "check-separator", "check-type"],
"comment-format": [true, "check-space", "check-lowercase"]
}
}
Loading

0 comments on commit eb254ab

Please sign in to comment.