Skip to content

Commit aa59ced

Browse files
committed
Reintroduce eslint and fix some minor errors and unused require-d statements.
1 parent 50cd669 commit aa59ced

File tree

7 files changed

+37
-19
lines changed

7 files changed

+37
-19
lines changed

Diff for: .eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lib/algorithms/*.js
2+
!lib/algorithms/default.js

Diff for: .eslintrc

-8
This file was deleted.

Diff for: .eslintrc.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"env": {
3+
"node": true
4+
},
5+
"extends": "eslint:recommended",
6+
"rules": {
7+
"indent": [
8+
"error",
9+
2
10+
],
11+
"linebreak-style": [
12+
"error",
13+
"unix"
14+
],
15+
"quotes": [
16+
"error",
17+
"single"
18+
],
19+
"semi": [
20+
"error",
21+
"always"
22+
]
23+
}
24+
}

Diff for: lib/core.js

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

3-
var path = require('path');
43
var extend = require('xtend');
54
var defaultAlgorithm = require('./algorithms/default.js');
65

@@ -44,6 +43,7 @@ Slayer.prototype = {
4443
* @param i {Number}
4544
* @returns {Number}
4645
*/
46+
// eslint-disable-next-line no-unused-vars
4747
getItem: function getItem(item, originalItem, i){
4848
return item;
4949
},
@@ -70,7 +70,7 @@ Slayer.prototype = {
7070
* Configures the internal filters of a slayer instance
7171
*/
7272
configureFilters: function configureFilters(config){
73-
if (typeof config.minPeakHeight !== 'number' || config.minPeakHeight === NaN){
73+
if (typeof config.minPeakHeight !== 'number' || isNaN(config.minPeakHeight)){
7474
throw new TypeError('config.minPeakHeight should be a numeric value. Was: ' + String(config.minPeakHeight));
7575
}
7676

@@ -104,7 +104,7 @@ Slayer.prototype = {
104104
return this;
105105
}
106106

107-
throw new TypeError('.use() expects its first and only paramter to be a peak detection function.')
107+
throw new TypeError('.use() expects its first and only paramter to be a peak detection function.');
108108
},
109109
/**
110110
* Index accessor applied to each series item.

Diff for: lib/readers/array.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ var commons = require('./_common.js');
2727
function fromArray(data){
2828
var self = this;
2929

30-
return new Promise(function(resolve, reject) {
30+
return new Promise(function(resolve) {
3131
if (!Array.isArray(data)){
32-
throw new TypeError('The data argument should be an array of time series values.')
32+
throw new TypeError('The data argument should be an array of time series values.');
3333
}
3434

3535
var spikes = data
@@ -39,7 +39,7 @@ function fromArray(data){
3939
.map(commons.objectMapper.bind(self, data))
4040
.filter(commons.cleanEmptyElement.bind(null, self.config.transformedValueProperty));
4141

42-
resolve(spikes);
42+
resolve(spikes);
4343
});
4444
}
4545

Diff for: lib/readers/stream.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,10 @@ function createReadStream(options){
6161
var emittedCache = [];
6262
var currentOffset = 0;
6363
var SLIDING_WINDOW_SIZE = this.config.minPeakDistance * options.bufferingFactor;
64-
console.log(SLIDING_WINDOW_SIZE)
6564
var SLIDING_WINDOW_OVERLAP = SLIDING_WINDOW_SIZE * options.lookAheadFactor;
6665

6766
var findSpikes = function findSpikes(items, stream) {
68-
var spikes = items
67+
return items
6968
.map(self.getValueY.bind(self))
7069
.map(self.filterDataItem.bind(self))
7170
.map(self.algorithm.bind(self, self.config.minPeakDistance))
@@ -74,7 +73,7 @@ function createReadStream(options){
7473
.map(incrementOffset.bind(self, 'x', currentOffset))
7574
.filter(cleanEmitted.bind(self, 'x', emittedCache))
7675
.map(pushToStream, stream);
77-
}
76+
};
7877

7978
var flush = function flushBuffer(done) {
8079
findSpikes(buffer, this);

Diff for: package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"main": "index.js",
66
"scripts": {
77
"test": "nyc mocha --reporter dot 'test/**/*.js'",
8-
"eslint": "eslint ./lib/",
8+
"posttest": "npm run lint",
9+
"lint": "eslint index.js ./lib",
910
"benchmarks": "./bin/run-benchmarks.js"
1011
},
1112
"repository": {
@@ -35,7 +36,7 @@
3536
"devDependencies": {
3637
"benchmark": "^1.0.0",
3738
"chai": "^3.5.0",
38-
"eslint": "^0.5.0",
39+
"eslint": "^3.7.1",
3940
"mocha": "^3.1.0",
4041
"nyc": "^8.3.0",
4142
"sinon": "^1.9.1",

0 commit comments

Comments
 (0)