diff --git a/.eslintrc.json b/.eslintrc.json index d0f89ad..3a42734 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,54 +1,61 @@ { "extends": "eslint:recommended", + "ecmaVersion": 2015, "env": { + "es6": true, "mocha": true, "node": true }, "rules": { - "array-bracket-spacing": 2, - "brace-style": 2, - "camelcase": 2, - "comma-dangle": 0, - "comma-spacing": 2, - "comma-style": 2, - "computed-property-spacing": 2, - "curly": 2, - "dot-location": [2, "property"], - "dot-notation": 2, - "eol-last": 2, - "eqeqeq": 2, - "guard-for-in": 2, - "indent": [2, 4, { + "array-bracket-spacing": "error", + "arrow-body-style": ["error", "always"], + "arrow-parens": "error", + "brace-style": "error", + "camelcase": "error", + "comma-dangle": "off", + "comma-spacing": "error", + "comma-style": "error", + "computed-property-spacing": "error", + "curly": "error", + "dot-location": ["error", "property"], + "dot-notation": "error", + "eol-last": "error", + "eqeqeq": "error", + "guard-for-in": "error", + "indent": ["error", 4, { "SwitchCase": 1, "VariableDeclarator": 0 }], - "key-spacing": 2, - "keyword-spacing": [2, { + "key-spacing": "error", + "keyword-spacing": ["error", { "after": true, "before": true }], - "newline-after-var": 2, - "no-caller": 2, - "no-console": 0, - "no-else-return": 2, - "no-eval": 2, - "no-extend-native": 2, - "no-lonely-if": 2, - "no-loop-func": 2, - "no-multi-spaces": 2, - "no-trailing-spaces": 2, - "one-var": [2, "never"], - "quotes": [2, "single", "avoid-escape"], - "semi": 2, - "space-before-blocks": 2, - "space-before-function-paren": 2, - "space-in-parens": 2, - "space-unary-ops": [2, { + "no-bitwise": "error", + "no-caller": "error", + "no-console": "off", + "no-const-assign": "error", + "no-else-return": "error", + "no-eval": "error", + "no-extend-native": "error", + "no-lonely-if": "error", + "no-loop-func": "error", + "no-multi-spaces": "error", + "no-trailing-spaces": "error", + "no-var": "error", + "prefer-const": "error", + "quotes": ["error", "single", "avoid-escape"], + "semi": "error", + "space-before-blocks": "error", + "space-before-function-paren": "error", + "space-in-parens": "error", + "space-infix-ops": "error", + "space-unary-ops": ["error", { "nonwords": false, "words": true }], - "strict": [2, "global"], - "vars-on-top": 2, - "yoda": 2 + "strict": ["error", "global"], + "template-curly-spacing": ["error", "always"], + "yoda": "error" } } diff --git a/.gitignore b/.gitignore index 7595163..2f61f1f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .DS_Store +coverage node_modules npm-debug.log diff --git a/.travis.yml b/.travis.yml index 82521a7..1087954 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,14 @@ -sudo: false - language: node_js node_js: - - "0.10" - - "0.12" - - "iojs-v1" - - "iojs-v2" - - "iojs-v3" - "4" - "5" + - "6" + - "7" before_script: - node --version - npm --version + - npm install -g gulp script: - npm test diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..e0a3399 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,19 @@ +'use strict'; + +const gulp = require('gulp'); +const eslint = require('gulp-eslint'); +const mocha = require('gulp-mocha'); + +gulp.task('lint', () => { + return gulp.src(['./*.js']) + .pipe(eslint()) + .pipe(eslint.format()) + .pipe(eslint.failAfterError()); +}); + +gulp.task('test', ['lint'], () => { + return gulp.src(['./test.js']) + .pipe(mocha()); +}); + +gulp.task('default', ['test']); diff --git a/index.js b/index.js index da40b90..d648b1d 100644 --- a/index.js +++ b/index.js @@ -1,15 +1,15 @@ 'use strict'; -var util = require('util'); +const util = require('util'); module.exports = { - report: function (errors) { - var lastFile = ''; + report: function report (results) { + let lastFile = ''; console.log('##teamcity[testSuiteStarted name=\'lesshint\']'); - errors.forEach(function (err) { - var errFile = err.fullPath.replace('./', ''); + results.forEach((result) => { + const errFile = result.fullPath.replace(process.env.PWD + '/', ''); if (lastFile !== errFile) { if (lastFile) { @@ -24,16 +24,16 @@ module.exports = { util.format( '##teamcity[testFailed name=\'%s\' message=\'line %d, col %d, %s (%s) %s\']', lastFile, - err.line, - err.column, - err.severity === 'error' ? 'Error' : 'Warning', - err.linter, - err.message.replace('\'', '|\'') + result.line, + result.column, + result.severity === 'error' ? 'Error' : 'Warning', + result.linter, + result.message.replace('\'', '|\'') ) ); }); - if (errors.length) { + if (results.length) { console.log(util.format('##teamcity[testFinished name=\'%s\']', lastFile)); } else { console.log('##teamcity[testStarted name=\'lesshint\']'); diff --git a/package.json b/package.json index a00df4b..8c55134 100644 --- a/package.json +++ b/package.json @@ -1,30 +1,30 @@ { "name": "lesshint-reporter-teamcity", - "version": "1.0.3", + "version": "1.1.0", "description": "TeamCity reporter for lesshint.", "main": "index.js", "repository": { "type": "git", - "url": "https://github.com/lesshint/reporter-teamcity" + "url": "git+https://github.com/lesshint/reporter-teamcity.git" }, "keywords": [ "reporter", "lesshint", "teamcity" ], + "devDependencies": { + "chai": "^3.5.0", + "gulp": "^3.9.0", + "gulp-eslint": "^3.0.1", + "gulp-mocha": "^4.1.0", + "proxyquire": "^1.7.10", + "sinon": "^2.0.0" + }, "scripts": { - "pretest": "eslint *.js", - "test": "mocha" + "test": "gulp" }, "license": "MIT", "bugs": { "url": "https://github.com/lesshint/reporter-teamcity/issues" - }, - "devDependencies": { - "chai": "^3.5.0", - "eslint": "^2.2.0", - "mocha": "^2.4.5", - "rewire": "^2.5.1", - "sinon": "^1.17.3" } } diff --git a/test.js b/test.js index 8b4ebbb..30d6815 100644 --- a/test.js +++ b/test.js @@ -1,25 +1,25 @@ 'use strict'; -var expect = require('chai').expect; -var rewire = require('rewire'); -var sinon = require('sinon'); -var util = require('util'); +const proxyquire = require('proxyquire'); +const expect = require('chai').expect; +const sinon = require('sinon'); +const util = require('util'); -describe('reporter:teamcity', function () { - var reporter = rewire('./index.js'); +const reporter = proxyquire('./index', {util: util}); - beforeEach(function () { +describe('reporter:teamcity', () => { + beforeEach(() => { sinon.stub(process.stdout, 'write'); }); - afterEach(function () { + afterEach(() => { if (process.stdout.write.restore) { process.stdout.write.restore(); } }); - it('should not print anything when not passed any errors', function () { - var errors = []; + it('should not print anything when not passed any errors', () => { + const errors = []; sinon.spy(console, 'log'); @@ -34,8 +34,8 @@ describe('reporter:teamcity', function () { console.log.restore(); }); - it('print error for 1 file', function () { - var errors = [{ + it('print error for 1 file', () => { + const errors = [{ column: 5, file: 'file.less', fullPath: 'path/to/file.less', @@ -62,8 +62,8 @@ describe('reporter:teamcity', function () { console.log.restore(); }); - it('print errors for 2 files', function () { - var errors = [{ + it('print errors for 2 files', () => { + const errors = [{ column: 5, file: 'file.less', fullPath: 'path/to/file.less',