Skip to content

Commit 5711d6d

Browse files
committed
enable linting
1 parent b7bb68f commit 5711d6d

File tree

4 files changed

+26
-19
lines changed

4 files changed

+26
-19
lines changed

.eslintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "eslint-config-hapi"
3+
}

bin/purdy.js

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
#!/usr/bin/env node
2+
'use strict';
23

3-
var Fs = require('fs');
4-
var Purdy = require('../');
4+
const Fs = require('fs');
5+
const Purdy = require('../');
56

67

7-
var internals = {};
8+
const internals = {};
89

910

10-
internals.stdin = function(stream, callback){
11+
internals.stdin = function (stream, callback){
1112

12-
var buf = '';
13+
let buf = '';
1314
stream.setEncoding('utf8');
1415

15-
stream.on('data', function(s){ buf += s });
16+
stream.on('data', (s) => {
1617

17-
stream.on('end', function(){
18+
buf += s;
19+
});
20+
21+
stream.on('end', () => {
1822

1923
callback(buf);
2024
}).resume();
@@ -24,7 +28,7 @@ internals.stdin = function(stream, callback){
2428
internals.parse = function (str, depth) {
2529

2630
try {
27-
Purdy(JSON.parse(str), { depth: depth });
31+
Purdy(JSON.parse(str), { depth });
2832
}
2933
catch (e) {
3034
Purdy(e);
@@ -35,17 +39,17 @@ internals.parse = function (str, depth) {
3539

3640
internals.main = function () {
3741

38-
var stream = process.stdin;
42+
let stream = process.stdin;
3943

4044
try {
41-
var depthIdx = process.argv.indexOf('--depth');
42-
var depth = 2;
45+
const depthIdx = process.argv.indexOf('--depth');
46+
let depth = 2;
4347
if (depthIdx !== -1) {
44-
var pair = process.argv.splice(depthIdx, 2);
48+
const pair = process.argv.splice(depthIdx, 2);
4549
depth = parseFloat(pair[1]);
4650

4751
if (String(depth) === 'NaN') {
48-
var e = new Error('Depth requires a numerical value');
52+
const e = new Error('Depth requires a numerical value');
4953
e.depth = pair[1];
5054
Purdy(e);
5155
process.exit(1);
@@ -55,10 +59,10 @@ internals.main = function () {
5559
stream = process.stdin;
5660
}
5761
else {
58-
var path = Fs.realpathSync(process.argv[2]);
62+
const path = Fs.realpathSync(process.argv[2]);
5963
stream = Fs.createReadStream(path);
6064
}
61-
internals.stdin(stream, function (str) {
65+
internals.stdin(stream, (str) => {
6266

6367
internals.parse(str, depth);
6468
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Pretty print objects in real purdy colors. Allows clearer visualization of objects than you get from most pretty printers due to colors. It will also print out the complete path to an object, something that's extremly useful for debugging. Purdy will also print out the path to access a variable using Hoek format making it useful on accessing values.",
55
"main": "lib/index.js",
66
"scripts": {
7-
"test": "lab -a code -t 100 -v -I Reflect"
7+
"test": "lab -a code -t 100 -v -I Reflect -L"
88
},
99
"homepage": "https://github.com/danielb2/purdy.js",
1010
"bugs": "https://github.com/danielb2/purdy.js/issues",

test/purdy.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ describe('Purdy', () => {
124124

125125
it('should print constructor name', (done) => {
126126

127-
const mises = function mises() {
127+
const mises = function mises () {
128128

129129
this.moop = 3;
130130
};
@@ -157,7 +157,7 @@ describe('Purdy', () => {
157157

158158
it('should print an anonymous function', (done) => {
159159

160-
const out = Purdy.stringify(function () {});
160+
const out = Purdy.stringify(() => {});
161161
const expected = '\u001b[36m[Function]\u001b[39m';
162162
expect(out).to.equal(expected);
163163
done();
@@ -178,7 +178,7 @@ describe('Purdy', () => {
178178

179179
it('should print properties for functions with name', (done) => {
180180

181-
const obj = function Liberty() {};
181+
const obj = function Liberty () {};
182182

183183
obj.property = 3;
184184

0 commit comments

Comments
 (0)