lint: add editorconfig and eslint to enforce

This commit is contained in:
Douglas Christopher Wilson
2017-11-22 23:54:40 -05:00
parent b0f8f33d4a
commit d66e8036f7
6 changed files with 25 additions and 0 deletions

11
.editorconfig Normal file
View File

@@ -0,0 +1,11 @@
# http://editorconfig.org
root = true
[*]
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
[{*.js,*.json,*.yml}]
indent_size = 2
indent_style = space

2
.eslintignore Normal file
View File

@@ -0,0 +1,2 @@
coverage
node_modules

6
.eslintrc.yml Normal file
View File

@@ -0,0 +1,6 @@
root: true
rules:
eol-last: error
indent: [error, 2, { SwitchCase: 1 }]
no-trailing-spaces: error

View File

@@ -21,6 +21,7 @@ before_install:
# Setup Node.js version-specific dependencies
- "test $TRAVIS_NODE_VERSION != '0.8' || npm rm --save-dev istanbul"
- "test $(echo $TRAVIS_NODE_VERSION | cut -d. -f1) -ge 4 || npm rm --save-dev $(grep -E '\"eslint\\S*\"' package.json | cut -d'\"' -f2)"
# Update Node.js modules
- "test ! -d node_modules || npm prune"
@@ -29,5 +30,6 @@ script:
# Run test script, depending on istanbul install
- "test ! -z $(npm -ps ls istanbul) || npm test"
- "test -z $(npm -ps ls istanbul) || npm run-script test-ci"
- "test -z $(npm -ps ls eslint) || npm run-script lint"
after_script:
- "test -e ./coverage/lcov.info && npm install coveralls@2 && cat ./coverage/lcov.info | coveralls"

View File

@@ -17,6 +17,7 @@ install:
- ps: Install-Product node $env:nodejs_version
- npm config set shrinkwrap false
- if "%nodejs_version%" equ "0.8" npm rm --save-dev istanbul
- for /f tokens^=2^ delims^=^" %%m in ('findstr /r /c:"eslint[^ ]" package.json') do call npm rm --save-dev %%m
- if exist node_modules npm prune
- if exist node_modules npm rebuild
- npm install

View File

@@ -16,6 +16,8 @@
},
"devDependencies": {
"after": "0.8.2",
"eslint": "3.19.0",
"eslint-plugin-markdown": "1.0.0-beta.6",
"istanbul": "0.4.5",
"mocha": "2.5.3",
"supertest": "1.1.0"
@@ -30,6 +32,7 @@
"node": ">= 0.8.0"
},
"scripts": {
"lint": "eslint --plugin markdown --ext js,md .",
"test": "mocha --reporter spec --bail --check-leaks test/",
"test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/"