From c793778eab1389c30eb34023a2204202efc2a3a9 Mon Sep 17 00:00:00 2001 From: e-cloud Date: Thu, 14 Jul 2016 17:08:47 +0800 Subject: [PATCH] chore: update code management facilities 1. add eslint support 2. add some restrictions on git commit 3. add conventional-changelog for future auto changelog generation 4. update ignores 5. add editor config --- .editorconfig | 29 +++++++++++++++++++++++++++++ .eslintrc | 12 ++++++++++++ .gitattributes | 21 +++++++++++++++++++++ .gitignore | 10 ++++++++++ .npmignore | 14 ++++++++++++++ package.json | 36 ++++++++++++++++++++++++++++++++++-- 6 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 .editorconfig create mode 100644 .eslintrc create mode 100644 .gitattributes create mode 100644 .npmignore diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..3361fd1 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,29 @@ +# http://editorconfig.org +root = true + +[*] +indent_style = space +end_of_line = lf +indent_size = 2 +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.js] +quote_type = single +curly_bracket_next_line = true +indent_brace_style = Allman +spaces_around_operators = true +spaces_around_brackets = inside +continuation_indent_size = 2 + +[*.html] +# indent_size = 4 + +[*{.yml,.yaml,.json}] +indent_style = space +indent_size = 2 + +[.eslintrc] +indent_style = space +indent_size = 2 diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..8f5156b --- /dev/null +++ b/.eslintrc @@ -0,0 +1,12 @@ +{ + "extends": "airbnb-base", + "rules": { + "comma-dangle": 1, + "indent": 2, + "object-shorthand": 0, + "func-names": 0, + "max-len": [1, 120, 2], + "no-use-before-define": 1, + "no-param-reassign": [2, { "props": false }] + } +} diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..70d5e00 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,21 @@ +# Automatically normalize line endings for all text-based files +# http://git-scm.com/docs/gitattributes#_end_of_line_conversion +* text=auto + +# For the following file types, normalize line endings to LF on +# checkin and prevent conversion to CRLF when they are checked out +# (this is required in order to prevent newline related issues like, +# for example, after the build script is run) +.* text eol=lf +*.css text eol=lf +*.html text eol=lf +*.js text eol=lf +*.json text eol=lf +*.md text eol=lf +*.sh text eol=lf +*.txt text eol=lf +*.xml text eol=lf + +# Exclude the `.htaccess` file from GitHub's language statistics +# https://github.com/github/linguist#using-gitattributes +dist/.htaccess linguist-vendored diff --git a/.gitignore b/.gitignore index 12925cd..ccfb9e6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,17 @@ +# Logs +logs *.log* +npm-debug.log* + +# Runtime data +pids +*.pid +*.seed + build node_modules .bob/ test/streams/test-* .idea +.vscode .DS_Store diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..2708937 --- /dev/null +++ b/.npmignore @@ -0,0 +1,14 @@ +# Created by .ignore support plugin +**/.* +node_modules +bower_components +test +tests +support +benchmarks +examples +sample +lib-cov +coverage.html +Makefile +coverage diff --git a/package.json b/package.json index 320be24..b640f11 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "node": ">=0.8" }, "scripts": { - "pretest": "jshint lib/ test/", + "pretest": "echo 'no lint yet'", "test": "vows" }, "directories": { @@ -34,11 +34,43 @@ "semver": "~4.3.3" }, "devDependencies": { - "jshint": "^2.9.2", + "conventional-changelog": "^1.1.0", + "eslint": "^3.0.0", + "eslint-config-airbnb-base": "^4.0.0", + "eslint-plugin-import": "^1.5.0", + "ghooks": "^1.2.1", "sandboxed-module": "0.1.3", + "validate-commit-msg": "^2.6.1", "vows": "0.7.0" }, "browser": { "os": false + }, + "config": { + "validate-commit-msg": { + "types": [ + "feat", + "fix", + "docs", + "style", + "refactor", + "example", + "perf", + "test", + "chore", + "revert" + ], + "warnOnFail": false, + "maxSubjectLength": 72, + "subjectPattern": ".+", + "subjectPatternErrorMsg": "subject does not match subject pattern!", + "helpMessage": "\n# allowed type: feat, fix, docs, style, refactor, example, perf, test, chore, revert\n# subject no more than 50 chars\n# a body line no more than 72 chars" + }, + "ghooks": { + "//": { + "pre-commit": "check code style" + }, + "commit-msg": "validate-commit-msg" + } } }