Skip to content

Commit c47c90d

Browse files
Linting
1 parent 001fb8b commit c47c90d

File tree

7 files changed

+136
-128
lines changed

7 files changed

+136
-128
lines changed

packages/splitio-engine/es6/index.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const parser = require('./parser');
22

33
function Split(baseInfo, evaluator, segments) {
44
if (!(this instanceof Split)) {
5-
return new Split(baseInfo, evaluator, segments);
5+
return new Split(baseInfo, evaluator, segments);
66
}
77

88
this.baseInfo = baseInfo;
@@ -15,32 +15,38 @@ Split.parse = function parse(splitFlatStructure, storage) {
1515
let {evaluator, segments} = parser(conditions, storage);
1616

1717
return new Split(baseInfo, evaluator, segments);
18-
}
18+
};
1919

2020
Split.prototype.getKey = function getKey() {
2121
return this.baseInfo.name;
2222
};
2323

2424
Split.prototype.getSegments = function getSegments() {
2525
return this.segments;
26-
}
26+
};
2727

2828
Split.prototype.getTreatment = function getTreatment(key, attributes) {
29-
if (this.baseInfo.killed) {
30-
return this.baseInfo.defaultTreatment;
29+
let {
30+
killed,
31+
seed,
32+
defaultTreatment
33+
} = this.baseInfo;
34+
35+
if (killed) {
36+
return defaultTreatment;
37+
} else {
38+
let treatment = this.evaluator(key, seed, attributes);
39+
40+
return treatment !== undefined ? treatment : defaultTreatment;
3141
}
32-
33-
let treatment = this.evaluator(key, this.baseInfo.seed, attributes);
34-
35-
return treatment !== undefined ? treatment : this.baseInfo.defaultTreatment;
36-
}
42+
};
3743

3844
Split.prototype.isTreatment = function isTreatment(key, treatment) {
3945
return this.getTreatment(key) === treatment;
40-
}
46+
};
4147

4248
Split.prototype.isGarbage = function isGarbage() {
4349
return this.baseInfo.status === 'ARCHIVED';
44-
}
50+
};
4551

4652
module.exports = Split;

packages/splitio-engine/es6/matchers/types.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ module.exports = {
3939
return this.enum.GREATER_THAN_OR_EQUAL_TO;
4040
case 'LESS_THAN_OR_EQUAL_TO':
4141
return this.enum.LESS_THAN_OR_EQUAL_TO;
42-
case 'BETWEEN': Symbol()
42+
case 'BETWEEN':
4343
return this.enum.BETWEEN;
4444
default:
4545
throw new Error('Invalid matcher type provided');

packages/splitio-engine/es6/parser/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ function parse(conditions /*: Iterable<Object> */, storage /*: Storage */) /*: P
4545
for (let condition of conditions) {
4646
let {
4747
matcherGroup: {
48-
combiner,
4948
matchers
5049
},
5150
partitions

packages/splitio-engine/es6/transforms/matchers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function transform(matchers /*: Array<object> */) /*: Array<MatcherDTO> */ {
6262
userDefinedSegmentMatcherData: segmentObject /*: segmentObject */,
6363
whitelistMatcherData: whitelistObject /*: whiteListObject */,
6464
unaryNumericMatcherData: unaryNumericObject /*: unaryNumericObject */,
65-
betweenMatcherData: betweenObject /*: betweenObject */,
65+
betweenMatcherData: betweenObject /*: betweenObject */
6666
} = matcher;
6767

6868
let attribute = keySelector && keySelector.attribute;

packages/splitio-engine/test/es6/parser/index.spec.js

Lines changed: 111 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -103,31 +103,31 @@ tape('PARSER / if user is in segment ["u1", "u2", "u3", "u4"] then split 100%:on
103103

104104
tape('PARSER / if user.account is in list ["v1", "v2", "v3"] then split 100:on', assert => {
105105

106-
let {evaluator, segments} = parser([{
107-
"matcherGroup": {
108-
"combiner": "AND",
109-
"matchers": [{
110-
"keySelector": {
111-
"trafficType": "user",
112-
"attribute": "account"
106+
let {evaluator} = parser([{
107+
matcherGroup: {
108+
combiner: 'AND',
109+
matchers: [{
110+
keySelector: {
111+
trafficType: 'user',
112+
attribute: 'account'
113113
},
114-
"matcherType": "WHITELIST",
115-
"negate": false,
116-
"userDefinedSegmentMatcherData": null,
117-
"whitelistMatcherData": {
118-
"whitelist": [
119-
"v1",
120-
"v2",
121-
"v3"
114+
matcherType: 'WHITELIST',
115+
negate: false,
116+
userDefinedSegmentMatcherData: null,
117+
whitelistMatcherData: {
118+
whitelist: [
119+
'v1',
120+
'v2',
121+
'v3'
122122
]
123123
},
124-
"unaryNumericMatcherData": null,
125-
"betweenMatcherData": null
124+
unaryNumericMatcherData: null,
125+
betweenMatcherData: null
126126
}]
127127
},
128-
"partitions": [{
129-
"treatment": "on",
130-
"size": 100
128+
partitions: [{
129+
treatment: 'on',
130+
size: 100
131131
}]
132132
}]);
133133

@@ -147,26 +147,26 @@ tape('PARSER / if user.account is in list ["v1", "v2", "v3"] then split 100:on',
147147

148148
tape('PARSER / if user.account is in segment all then split 100:on', assert => {
149149

150-
let {evaluator, segments} = parser([{
151-
"matcherGroup": {
152-
"combiner": "AND",
153-
"matchers": [{
154-
"keySelector": {
155-
"trafficType": "user",
156-
"attribute": "account"
150+
let {evaluator} = parser([{
151+
matcherGroup: {
152+
combiner: 'AND',
153+
matchers: [{
154+
keySelector: {
155+
trafficType: 'user',
156+
attribute: 'account'
157157
},
158-
"matcherType": "ALL_KEYS",
159-
"negate": false,
160-
"userDefinedSegmentMatcherData": null,
161-
"whitelistMatcherData": null,
162-
"unaryNumericMatcherData": null,
163-
"betweenMatcherData": null,
164-
"unaryStringMatcherData": null
158+
matcherType: 'ALL_KEYS',
159+
negate: false,
160+
userDefinedSegmentMatcherData: null,
161+
whitelistMatcherData: null,
162+
unaryNumericMatcherData: null,
163+
betweenMatcherData: null,
164+
unaryStringMatcherData: null
165165
}]
166166
},
167-
"partitions": [{
168-
"treatment": "on",
169-
"size": 100
167+
partitions: [{
168+
treatment: 'on',
169+
size: 100
170170
}]
171171
}]);
172172

@@ -176,37 +176,37 @@ tape('PARSER / if user.account is in segment all then split 100:on', assert => {
176176

177177
assert.true(
178178
evaluator('test@split.io', 31) === undefined,
179-
"missing attribute account but using segment all evaluates to on"
179+
'missing attribute should evaluates to undefined'
180180
);
181181

182182
assert.end();
183183
});
184184

185185
tape('PARSER / if user.attr is between 10 and 20 then split 100:on', assert => {
186186

187-
let {evaluator, segments} = parser([{
188-
"matcherGroup": {
189-
"combiner": "AND",
190-
"matchers": [{
191-
"keySelector": {
192-
"trafficType": "user",
193-
"attribute": "attr"
187+
let {evaluator} = parser([{
188+
matcherGroup: {
189+
combiner: 'AND',
190+
matchers: [{
191+
keySelector: {
192+
trafficType: 'user',
193+
attribute: 'attr'
194194
},
195-
"matcherType": "BETWEEN",
196-
"negate": false,
197-
"userDefinedSegmentMatcherData": null,
198-
"whitelistMatcherData": null,
199-
"unaryNumericMatcherData": null,
200-
"betweenMatcherData": {
201-
"dataType": "NUMBER",
202-
"start": 10,
203-
"end": 20
195+
matcherType: 'BETWEEN',
196+
negate: false,
197+
userDefinedSegmentMatcherData: null,
198+
whitelistMatcherData: null,
199+
unaryNumericMatcherData: null,
200+
betweenMatcherData: {
201+
dataType: 'NUMBER',
202+
start: 10,
203+
end: 20
204204
}
205205
}]
206206
},
207-
"partitions": [{
208-
"treatment": "on",
209-
"size": 100
207+
partitions: [{
208+
treatment: 'on',
209+
size: 100
210210
}]
211211
}]);
212212

@@ -228,28 +228,28 @@ tape('PARSER / if user.attr is between 10 and 20 then split 100:on', assert => {
228228

229229
tape('PARSER / if user.attr <= datetime 1458240947021 then split 100:on', assert => {
230230

231-
let {evaluator, segments} = parser([{
232-
"matcherGroup": {
233-
"combiner": "AND",
234-
"matchers": [{
235-
"keySelector": {
236-
"trafficType": "user",
237-
"attribute": "attr"
231+
let {evaluator} = parser([{
232+
matcherGroup: {
233+
combiner: 'AND',
234+
matchers: [{
235+
keySelector: {
236+
trafficType: 'user',
237+
attribute: 'attr'
238238
},
239-
"matcherType": "LESS_THAN_OR_EQUAL_TO",
240-
"negate": false,
241-
"userDefinedSegmentMatcherData": null,
242-
"whitelistMatcherData": null,
243-
"unaryNumericMatcherData": {
244-
"dataType": "DATETIME",
245-
"value": 1458240947021
239+
matcherType: 'LESS_THAN_OR_EQUAL_TO',
240+
negate: false,
241+
userDefinedSegmentMatcherData: null,
242+
whitelistMatcherData: null,
243+
unaryNumericMatcherData: {
244+
dataType: 'DATETIME',
245+
value: 1458240947021
246246
},
247-
"betweenMatcherData": null
247+
betweenMatcherData: null
248248
}]
249249
},
250-
"partitions": [{
251-
"treatment": "on",
252-
"size": 100
250+
partitions: [{
251+
treatment: 'on',
252+
size: 100
253253
}]
254254
}]);
255255

@@ -275,28 +275,28 @@ tape('PARSER / if user.attr <= datetime 1458240947021 then split 100:on', assert
275275

276276
tape('PARSER / if user.attr >= datetime 1458240947021 then split 100:on', assert => {
277277

278-
let {evaluator, segments} = parser([{
279-
"matcherGroup": {
280-
"combiner": "AND",
281-
"matchers": [{
282-
"keySelector": {
283-
"trafficType": "user",
284-
"attribute": "attr"
278+
let {evaluator} = parser([{
279+
matcherGroup: {
280+
combiner: 'AND',
281+
matchers: [{
282+
keySelector: {
283+
trafficType: 'user',
284+
attribute: 'attr'
285285
},
286-
"matcherType": "GREATER_THAN_OR_EQUAL_TO",
287-
"negate": false,
288-
"userDefinedSegmentMatcherData": null,
289-
"whitelistMatcherData": null,
290-
"unaryNumericMatcherData": {
291-
"dataType": "DATETIME",
292-
"value": 1458240947021
286+
matcherType: 'GREATER_THAN_OR_EQUAL_TO',
287+
negate: false,
288+
userDefinedSegmentMatcherData: null,
289+
whitelistMatcherData: null,
290+
unaryNumericMatcherData: {
291+
dataType: 'DATETIME',
292+
value: 1458240947021
293293
},
294-
"betweenMatcherData": null
294+
betweenMatcherData: null
295295
}]
296296
},
297-
"partitions": [{
298-
"treatment": "on",
299-
"size": 100
297+
partitions: [{
298+
treatment: 'on',
299+
size: 100
300300
}]
301301
}]);
302302

@@ -322,28 +322,28 @@ tape('PARSER / if user.attr >= datetime 1458240947021 then split 100:on', assert
322322

323323
tape('PARSER / if user.attr = datetime 1458240947021 then split 100:on', assert => {
324324

325-
let {evaluator, segments} = parser([{
326-
"matcherGroup": {
327-
"combiner": "AND",
328-
"matchers": [{
329-
"keySelector": {
330-
"trafficType": "user",
331-
"attribute": "attr"
325+
let {evaluator} = parser([{
326+
matcherGroup: {
327+
combiner: 'AND',
328+
matchers: [{
329+
keySelector: {
330+
trafficType: 'user',
331+
attribute: 'attr'
332332
},
333-
"matcherType": "EQUAL_TO",
334-
"negate": false,
335-
"userDefinedSegmentMatcherData": null,
336-
"whitelistMatcherData": null,
337-
"unaryNumericMatcherData": {
338-
"dataType": "DATETIME",
339-
"value": 1458240947021
333+
matcherType: 'EQUAL_TO',
334+
negate: false,
335+
userDefinedSegmentMatcherData: null,
336+
whitelistMatcherData: null,
337+
unaryNumericMatcherData: {
338+
dataType: 'DATETIME',
339+
value: 1458240947021
340340
},
341-
"betweenMatcherData": null
341+
betweenMatcherData: null
342342
}]
343343
},
344-
"partitions": [{
345-
"treatment": "on",
346-
"size": 100
344+
partitions: [{
345+
treatment: 'on',
346+
size: 100
347347
}]
348348
}]);
349349

packages/splitio-utils/es6/settings/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function defaults(custom /*: Settings */) /*: Settings */ {
3838
featuresRefreshRate: 30, // 30 sec
3939
segmentsRefreshRate: 60, // 60 sec
4040
metricsRefreshRate: 60, // 60 sec
41-
impressionsRefreshRate: 60, // 60 sec
41+
impressionsRefreshRate: 60 // 60 sec
4242
}
4343
};
4444

scripts/lint.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,8 @@
1616

1717
# Verify our code is good enough for machines at least.
1818

19-
eslint packages/*/es6/**/*.js \
19+
20+
eslint packages/*/es6/*.js \
21+
packages/*/es6/**/*.js \
22+
packages/*/test/es6/*.js \
2023
packages/*/test/es6/**/*.js

0 commit comments

Comments
 (0)