Skip to content

Commit

Permalink
Rewrite to ES6
Browse files Browse the repository at this point in the history
  • Loading branch information
wareczek committed Mar 25, 2017
1 parent 8e5db5a commit 112360f
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 79 deletions.
79 changes: 43 additions & 36 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
coverage
node_modules
npm-debug.log
10 changes: 3 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
19 changes: 19 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -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']);
22 changes: 11 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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\']');
Expand Down
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
28 changes: 14 additions & 14 deletions test.js
Original file line number Diff line number Diff line change
@@ -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');

Expand All @@ -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',
Expand All @@ -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',
Expand Down

0 comments on commit 112360f

Please sign in to comment.