Skip to content

Commit 112360f

Browse files
committed
Rewrite to ES6
1 parent 8e5db5a commit 112360f

7 files changed

+102
-79
lines changed

.eslintrc.json

+43-36
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,61 @@
11
{
22
"extends": "eslint:recommended",
3+
"ecmaVersion": 2015,
34
"env": {
5+
"es6": true,
46
"mocha": true,
57
"node": true
68
},
79
"rules": {
8-
"array-bracket-spacing": 2,
9-
"brace-style": 2,
10-
"camelcase": 2,
11-
"comma-dangle": 0,
12-
"comma-spacing": 2,
13-
"comma-style": 2,
14-
"computed-property-spacing": 2,
15-
"curly": 2,
16-
"dot-location": [2, "property"],
17-
"dot-notation": 2,
18-
"eol-last": 2,
19-
"eqeqeq": 2,
20-
"guard-for-in": 2,
21-
"indent": [2, 4, {
10+
"array-bracket-spacing": "error",
11+
"arrow-body-style": ["error", "always"],
12+
"arrow-parens": "error",
13+
"brace-style": "error",
14+
"camelcase": "error",
15+
"comma-dangle": "off",
16+
"comma-spacing": "error",
17+
"comma-style": "error",
18+
"computed-property-spacing": "error",
19+
"curly": "error",
20+
"dot-location": ["error", "property"],
21+
"dot-notation": "error",
22+
"eol-last": "error",
23+
"eqeqeq": "error",
24+
"guard-for-in": "error",
25+
"indent": ["error", 4, {
2226
"SwitchCase": 1,
2327
"VariableDeclarator": 0
2428
}],
25-
"key-spacing": 2,
26-
"keyword-spacing": [2, {
29+
"key-spacing": "error",
30+
"keyword-spacing": ["error", {
2731
"after": true,
2832
"before": true
2933
}],
30-
"newline-after-var": 2,
31-
"no-caller": 2,
32-
"no-console": 0,
33-
"no-else-return": 2,
34-
"no-eval": 2,
35-
"no-extend-native": 2,
36-
"no-lonely-if": 2,
37-
"no-loop-func": 2,
38-
"no-multi-spaces": 2,
39-
"no-trailing-spaces": 2,
40-
"one-var": [2, "never"],
41-
"quotes": [2, "single", "avoid-escape"],
42-
"semi": 2,
43-
"space-before-blocks": 2,
44-
"space-before-function-paren": 2,
45-
"space-in-parens": 2,
46-
"space-unary-ops": [2, {
34+
"no-bitwise": "error",
35+
"no-caller": "error",
36+
"no-console": "off",
37+
"no-const-assign": "error",
38+
"no-else-return": "error",
39+
"no-eval": "error",
40+
"no-extend-native": "error",
41+
"no-lonely-if": "error",
42+
"no-loop-func": "error",
43+
"no-multi-spaces": "error",
44+
"no-trailing-spaces": "error",
45+
"no-var": "error",
46+
"prefer-const": "error",
47+
"quotes": ["error", "single", "avoid-escape"],
48+
"semi": "error",
49+
"space-before-blocks": "error",
50+
"space-before-function-paren": "error",
51+
"space-in-parens": "error",
52+
"space-infix-ops": "error",
53+
"space-unary-ops": ["error", {
4754
"nonwords": false,
4855
"words": true
4956
}],
50-
"strict": [2, "global"],
51-
"vars-on-top": 2,
52-
"yoda": 2
57+
"strict": ["error", "global"],
58+
"template-curly-spacing": ["error", "always"],
59+
"yoda": "error"
5360
}
5461
}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.DS_Store
2+
coverage
23
node_modules
34
npm-debug.log

.travis.yml

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
sudo: false
2-
31
language: node_js
42
node_js:
5-
- "0.10"
6-
- "0.12"
7-
- "iojs-v1"
8-
- "iojs-v2"
9-
- "iojs-v3"
103
- "4"
114
- "5"
5+
- "6"
6+
- "7"
127

138
before_script:
149
- node --version
1510
- npm --version
11+
- npm install -g gulp
1612

1713
script:
1814
- npm test

gulpfile.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'use strict';
2+
3+
const gulp = require('gulp');
4+
const eslint = require('gulp-eslint');
5+
const mocha = require('gulp-mocha');
6+
7+
gulp.task('lint', () => {
8+
return gulp.src(['./*.js'])
9+
.pipe(eslint())
10+
.pipe(eslint.format())
11+
.pipe(eslint.failAfterError());
12+
});
13+
14+
gulp.task('test', ['lint'], () => {
15+
return gulp.src(['./test.js'])
16+
.pipe(mocha());
17+
});
18+
19+
gulp.task('default', ['test']);

index.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
'use strict';
22

3-
var util = require('util');
3+
const util = require('util');
44

55
module.exports = {
6-
report: function (errors) {
7-
var lastFile = '';
6+
report: function report (results) {
7+
let lastFile = '';
88

99
console.log('##teamcity[testSuiteStarted name=\'lesshint\']');
1010

11-
errors.forEach(function (err) {
12-
var errFile = err.fullPath.replace('./', '');
11+
results.forEach((result) => {
12+
const errFile = result.fullPath.replace(process.env.PWD + '/', '');
1313

1414
if (lastFile !== errFile) {
1515
if (lastFile) {
@@ -24,16 +24,16 @@ module.exports = {
2424
util.format(
2525
'##teamcity[testFailed name=\'%s\' message=\'line %d, col %d, %s (%s) %s\']',
2626
lastFile,
27-
err.line,
28-
err.column,
29-
err.severity === 'error' ? 'Error' : 'Warning',
30-
err.linter,
31-
err.message.replace('\'', '|\'')
27+
result.line,
28+
result.column,
29+
result.severity === 'error' ? 'Error' : 'Warning',
30+
result.linter,
31+
result.message.replace('\'', '|\'')
3232
)
3333
);
3434
});
3535

36-
if (errors.length) {
36+
if (results.length) {
3737
console.log(util.format('##teamcity[testFinished name=\'%s\']', lastFile));
3838
} else {
3939
console.log('##teamcity[testStarted name=\'lesshint\']');

package.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
{
22
"name": "lesshint-reporter-teamcity",
3-
"version": "1.0.3",
3+
"version": "1.1.0",
44
"description": "TeamCity reporter for lesshint.",
55
"main": "index.js",
66
"repository": {
77
"type": "git",
8-
"url": "https://github.com/lesshint/reporter-teamcity"
8+
"url": "git+https://github.com/lesshint/reporter-teamcity.git"
99
},
1010
"keywords": [
1111
"reporter",
1212
"lesshint",
1313
"teamcity"
1414
],
15+
"devDependencies": {
16+
"chai": "^3.5.0",
17+
"gulp": "^3.9.0",
18+
"gulp-eslint": "^3.0.1",
19+
"gulp-mocha": "^4.1.0",
20+
"proxyquire": "^1.7.10",
21+
"sinon": "^2.0.0"
22+
},
1523
"scripts": {
16-
"pretest": "eslint *.js",
17-
"test": "mocha"
24+
"test": "gulp"
1825
},
1926
"license": "MIT",
2027
"bugs": {
2128
"url": "https://github.com/lesshint/reporter-teamcity/issues"
22-
},
23-
"devDependencies": {
24-
"chai": "^3.5.0",
25-
"eslint": "^2.2.0",
26-
"mocha": "^2.4.5",
27-
"rewire": "^2.5.1",
28-
"sinon": "^1.17.3"
2929
}
3030
}

test.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
'use strict';
22

3-
var expect = require('chai').expect;
4-
var rewire = require('rewire');
5-
var sinon = require('sinon');
6-
var util = require('util');
3+
const proxyquire = require('proxyquire');
4+
const expect = require('chai').expect;
5+
const sinon = require('sinon');
6+
const util = require('util');
77

8-
describe('reporter:teamcity', function () {
9-
var reporter = rewire('./index.js');
8+
const reporter = proxyquire('./index', {util: util});
109

11-
beforeEach(function () {
10+
describe('reporter:teamcity', () => {
11+
beforeEach(() => {
1212
sinon.stub(process.stdout, 'write');
1313
});
1414

15-
afterEach(function () {
15+
afterEach(() => {
1616
if (process.stdout.write.restore) {
1717
process.stdout.write.restore();
1818
}
1919
});
2020

21-
it('should not print anything when not passed any errors', function () {
22-
var errors = [];
21+
it('should not print anything when not passed any errors', () => {
22+
const errors = [];
2323

2424
sinon.spy(console, 'log');
2525

@@ -34,8 +34,8 @@ describe('reporter:teamcity', function () {
3434
console.log.restore();
3535
});
3636

37-
it('print error for 1 file', function () {
38-
var errors = [{
37+
it('print error for 1 file', () => {
38+
const errors = [{
3939
column: 5,
4040
file: 'file.less',
4141
fullPath: 'path/to/file.less',
@@ -62,8 +62,8 @@ describe('reporter:teamcity', function () {
6262
console.log.restore();
6363
});
6464

65-
it('print errors for 2 files', function () {
66-
var errors = [{
65+
it('print errors for 2 files', () => {
66+
const errors = [{
6767
column: 5,
6868
file: 'file.less',
6969
fullPath: 'path/to/file.less',

0 commit comments

Comments
 (0)