Skip to content

Commit 1001e0c

Browse files
committed
chore: bump eslint*
1 parent 588ad09 commit 1001e0c

21 files changed

+1357
-1283
lines changed

.eslintrc

+1-22
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,3 @@
11
{
2-
"extends": ["standard"],
3-
"plugins": ["standard"],
4-
"rules": {
5-
"semi": [2, "always"],
6-
"space-before-function-paren": [2, "never"],
7-
"max-len": [2, 80, 2],
8-
"camelcase": [2, { "properties": "always" }],
9-
"linebreak-style": [2, "unix"],
10-
"new-cap": [2, { "newIsCap": true, "capIsNew": true }],
11-
"arrow-body-style": [2, "as-needed"],
12-
"arrow-parens": [2, "as-needed"],
13-
"prefer-arrow-callback": 0,
14-
"prefer-template": 0,
15-
16-
"no-var": 2,
17-
"no-undef": 2,
18-
"no-param-reassign": 2,
19-
"comma-dangle": [2, "always-multiline"]
20-
},
21-
"env": {
22-
"node": true
23-
}
2+
"extends": "plugin:bpmn-io/recommended"
243
}

bin/diffpatch

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env node
22

3+
/* eslint-env node */
4+
35
import { DiffPatcher } from '../lib/index.js';
46
import ConsoleFormatter from '../lib/formatters/console.js';
57

lib/contexts/context.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default class Context {
3232
child.root = this.root || this;
3333
child.options = child.options || this.options;
3434
if (!this.children) {
35-
this.children = [child];
35+
this.children = [ child ];
3636
this.nextAfterChildren = this.next || null;
3737
this.next = child;
3838
} else {

lib/filters/arrays.js

+22-6
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ function matchItems(array1, array2, index1, index2, context) {
4545
}
4646
let objectHash = context.objectHash;
4747
if (!objectHash) {
48+
4849
// no way to match objects was provided, try match by position
4950
return context.matchByPosition && index1 === index2;
5051
}
@@ -123,6 +124,7 @@ export const diffFilter = function arraysDiffFilter(context) {
123124
context.push(child, index);
124125
commonHead++;
125126
}
127+
126128
// separate common tail
127129
while (
128130
commonTail + commonHead < len1 &&
@@ -144,31 +146,35 @@ export const diffFilter = function arraysDiffFilter(context) {
144146
let result;
145147
if (commonHead + commonTail === len1) {
146148
if (len1 === len2) {
149+
147150
// arrays are identical
148151
context.setResult(undefined).exit();
149152
return;
150153
}
154+
151155
// trivial case, a block (1 or more consecutive items) was added
152156
result = result || {
153157
_t: 'a',
154158
};
155159
for (index = commonHead; index < len2 - commonTail; index++) {
156-
result[index] = [array2[index]];
160+
result[index] = [ array2[index] ];
157161
}
158162
context.setResult(result).exit();
159163
return;
160164
}
161165
if (commonHead + commonTail === len2) {
166+
162167
// trivial case, a block (1 or more consecutive items) was removed
163168
result = result || {
164169
_t: 'a',
165170
};
166171
for (index = commonHead; index < len1 - commonTail; index++) {
167-
result[`_${index}`] = [array1[index], 0, 0];
172+
result[`_${index}`] = [ array1[index], 0, 0 ];
168173
}
169174
context.setResult(result).exit();
170175
return;
171176
}
177+
172178
// reset hash cache
173179
delete matchContext.hashCache1;
174180
delete matchContext.hashCache2;
@@ -183,8 +189,9 @@ export const diffFilter = function arraysDiffFilter(context) {
183189
};
184190
for (index = commonHead; index < len1 - commonTail; index++) {
185191
if (arrayIndexOf(seq.indices1, index - commonHead) < 0) {
192+
186193
// removed
187-
result[`_${index}`] = [array1[index], 0, 0];
194+
result[`_${index}`] = [ array1[index], 0, 0 ];
188195
removedItems.push(index);
189196
}
190197
}
@@ -210,6 +217,7 @@ export const diffFilter = function arraysDiffFilter(context) {
210217
for (index = commonHead; index < len2 - commonTail; index++) {
211218
let indexOnArray2 = arrayIndexOf(seq.indices2, index - commonHead);
212219
if (indexOnArray2 < 0) {
220+
213221
// added, try to match with a removed item and register as position move
214222
let isMove = false;
215223
if (detectMove && removedItemsLength > 0) {
@@ -228,9 +236,11 @@ export const diffFilter = function arraysDiffFilter(context) {
228236
matchContext
229237
)
230238
) {
239+
231240
// store position move as: [originalValue, newPosition, ARRAY_MOVE]
232241
result[`_${index1}`].splice(1, 2, index, ARRAY_MOVE);
233242
if (!includeValueOnMove) {
243+
234244
// don't include moved value on diff, to save bytes
235245
result[`_${index1}`][0] = '';
236246
}
@@ -248,10 +258,12 @@ export const diffFilter = function arraysDiffFilter(context) {
248258
}
249259
}
250260
if (!isMove) {
261+
251262
// added
252-
result[index] = [array2[index]];
263+
result[index] = [ array2[index] ];
253264
}
254265
} else {
266+
255267
// match, do inner diff
256268
index1 = seq.indices1[indexOnArray2] + commonHead;
257269
index2 = seq.indices2[indexOnArray2] + commonHead;
@@ -293,23 +305,26 @@ export const patchFilter = function nestedPatchFilter(context) {
293305
for (index in delta) {
294306
if (index !== '_t') {
295307
if (index[0] === '_') {
308+
296309
// removed item from original array
297310
if (delta[index][2] === 0 || delta[index][2] === ARRAY_MOVE) {
298311
toRemove.push(parseInt(index.slice(1), 10));
299312
} else {
300313
throw new Error(
301-
`only removal or move can be applied at original array indices,` +
314+
'only removal or move can be applied at original array indices,' +
302315
` invalid diff type: ${delta[index][2]}`
303316
);
304317
}
305318
} else {
306319
if (delta[index].length === 1) {
320+
307321
// added item at new array
308322
toInsert.push({
309323
index: parseInt(index, 10),
310324
value: delta[index][0],
311325
});
312326
} else {
327+
313328
// modified item at new array
314329
toModify.push({
315330
index: parseInt(index, 10),
@@ -327,6 +342,7 @@ export const patchFilter = function nestedPatchFilter(context) {
327342
let indexDiff = delta[`_${index1}`];
328343
let removedValue = array.splice(index1, 1)[0];
329344
if (indexDiff[2] === ARRAY_MOVE) {
345+
330346
// reinsert later
331347
toInsert.push({
332348
index: indexDiff[1],
@@ -366,7 +382,7 @@ export const patchFilter = function nestedPatchFilter(context) {
366382
patchFilter.filterName = 'arrays';
367383

368384
export const collectChildrenPatchFilter = function collectChildrenPatchFilter(
369-
context
385+
context
370386
) {
371387
if (!context || !context.children) {
372388
return;

lib/filters/dates.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ export const diffFilter = function datesDiffFilter(context) {
22
if (context.left instanceof Date) {
33
if (context.right instanceof Date) {
44
if (context.left.getTime() !== context.right.getTime()) {
5-
context.setResult([context.left, context.right]);
5+
context.setResult([ context.left, context.right ]);
66
} else {
77
context.setResult(undefined);
88
}
99
} else {
10-
context.setResult([context.left, context.right]);
10+
context.setResult([ context.left, context.right ]);
1111
}
1212
context.exit();
1313
} else if (context.right instanceof Date) {
14-
context.setResult([context.left, context.right]).exit();
14+
context.setResult([ context.left, context.right ]).exit();
1515
}
1616
};
1717
diffFilter.filterName = 'dates';

lib/filters/lcs.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ const lengthMatrix = function(array1, array2, match, context) {
1616
let x, y;
1717

1818
// initialize empty matrix of len1+1 x len2+1
19-
let matrix = [len1 + 1];
19+
let matrix = [ len1 + 1 ];
2020
for (x = 0; x < len1 + 1; x++) {
21-
matrix[x] = [len2 + 1];
21+
matrix[x] = [ len2 + 1 ];
2222
for (y = 0; y < len2 + 1; y++) {
2323
matrix[x][y] = 0;
2424
}
2525
}
2626
matrix.match = match;
27+
2728
// save sequence lengths for each coordinate
2829
for (x = 1; x < len1 + 1; x++) {
2930
for (y = 1; y < len2 + 1; y++) {

lib/filters/nested.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export const patchFilter = function nestedPatchFilter(context) {
8181
patchFilter.filterName = 'objects';
8282

8383
export const collectChildrenPatchFilter = function collectChildrenPatchFilter(
84-
context
84+
context
8585
) {
8686
if (!context || !context.children) {
8787
return;

lib/filters/texts.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ let getDiffMatchPatch = function(required) {
1212
let instance;
1313
/* eslint-disable camelcase, new-cap */
1414
if (typeof diff_match_patch !== 'undefined') {
15+
1516
// already loaded, probably a browser
1617
instance =
1718
typeof diff_match_patch === 'function'
@@ -66,19 +67,21 @@ export const diffFilter = function textsDiffFilter(context) {
6667
context.options.textDiff.minLength) ||
6768
DEFAULT_MIN_LENGTH;
6869
if (context.left.length < minLength || context.right.length < minLength) {
69-
context.setResult([context.left, context.right]).exit();
70+
context.setResult([ context.left, context.right ]).exit();
7071
return;
7172
}
73+
7274
// large text, try to use a text-diff algorithm
7375
let diffMatchPatch = getDiffMatchPatch();
7476
if (!diffMatchPatch) {
77+
7578
// diff-match-patch library not available,
7679
// fallback to regular string replace
77-
context.setResult([context.left, context.right]).exit();
80+
context.setResult([ context.left, context.right ]).exit();
7881
return;
7982
}
8083
let diff = diffMatchPatch.diff;
81-
context.setResult([diff(context.left, context.right), 0, TEXT_DIFF]).exit();
84+
context.setResult([ diff(context.left, context.right), 0, TEXT_DIFF ]).exit();
8285
};
8386
diffFilter.filterName = 'texts';
8487

@@ -127,6 +130,7 @@ const textDeltaReverse = function(delta) {
127130
} else if (lineStart === '+') {
128131
lines[i] = '-' + lines[i].slice(1);
129132
if (lines[i - 1].slice(0, 1) === '+') {
133+
130134
// swap lines to keep default order (-+)
131135
lineTmp = lines[i];
132136
lines[i] = lines[i - 1];
@@ -148,6 +152,6 @@ export const reverseFilter = function textsReverseFilter(context) {
148152
}
149153

150154
// text-diff, use a text-diff algorithm
151-
context.setResult([textDeltaReverse(context.delta[0]), 0, TEXT_DIFF]).exit();
155+
context.setResult([ textDeltaReverse(context.delta[0]), 0, TEXT_DIFF ]).exit();
152156
};
153157
reverseFilter.filterName = 'texts';

lib/filters/trivial.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ export const diffFilter = function trivialMatchesDiffFilter(context) {
1414
if (typeof context.right === 'function') {
1515
throw new Error('functions are not supported');
1616
}
17-
context.setResult([context.right]).exit();
17+
context.setResult([ context.right ]).exit();
1818
return;
1919
}
2020
if (typeof context.right === 'undefined') {
21-
context.setResult([context.left, 0, 0]).exit();
21+
context.setResult([ context.left, 0, 0 ]).exit();
2222
return;
2323
}
2424
if (
@@ -30,11 +30,11 @@ export const diffFilter = function trivialMatchesDiffFilter(context) {
3030
context.leftType = context.left === null ? 'null' : typeof context.left;
3131
context.rightType = context.right === null ? 'null' : typeof context.right;
3232
if (context.leftType !== context.rightType) {
33-
context.setResult([context.left, context.right]).exit();
33+
context.setResult([ context.left, context.right ]).exit();
3434
return;
3535
}
3636
if (context.leftType === 'boolean' || context.leftType === 'number') {
37-
context.setResult([context.left, context.right]).exit();
37+
context.setResult([ context.left, context.right ]).exit();
3838
return;
3939
}
4040
if (context.leftType === 'object') {
@@ -44,17 +44,17 @@ export const diffFilter = function trivialMatchesDiffFilter(context) {
4444
context.rightIsArray = isArray(context.right);
4545
}
4646
if (context.leftIsArray !== context.rightIsArray) {
47-
context.setResult([context.left, context.right]).exit();
47+
context.setResult([ context.left, context.right ]).exit();
4848
return;
4949
}
5050

5151
if (context.left instanceof RegExp) {
5252
if (context.right instanceof RegExp) {
5353
context
54-
.setResult([context.left.toString(), context.right.toString()])
54+
.setResult([ context.left.toString(), context.right.toString() ])
5555
.exit();
5656
} else {
57-
context.setResult([context.left, context.right]).exit();
57+
context.setResult([ context.left, context.right ]).exit();
5858
}
5959
}
6060
};
@@ -100,15 +100,15 @@ export const reverseFilter = function trivialReferseFilter(context) {
100100
return;
101101
}
102102
if (context.delta.length === 1) {
103-
context.setResult([context.delta[0], 0, 0]).exit();
103+
context.setResult([ context.delta[0], 0, 0 ]).exit();
104104
return;
105105
}
106106
if (context.delta.length === 2) {
107-
context.setResult([context.delta[1], context.delta[0]]).exit();
107+
context.setResult([ context.delta[1], context.delta[0] ]).exit();
108108
return;
109109
}
110110
if (context.delta.length === 3 && context.delta[2] === 0) {
111-
context.setResult([context.delta[0]]).exit();
111+
context.setResult([ context.delta[0] ]).exit();
112112
}
113113
};
114114
reverseFilter.filterName = 'trivial';

lib/formatters/annotated.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default class AnnotatedFormatter extends BaseFormatter {
3838
for (let i = 0, l = lines.length; i < l; i++) {
3939
const line = lines[i];
4040
context.out(
41-
`<li><div class="jsondiffpatch-textdiff-location">` +
41+
'<li><div class="jsondiffpatch-textdiff-location">' +
4242
`<span class="jsondiffpatch-textdiff-line-number">${
4343
line.location.line
4444
}</span><span class="jsondiffpatch-textdiff-char">${
@@ -113,6 +113,7 @@ export default class AnnotatedFormatter extends BaseFormatter {
113113
format_movedestination() {}
114114

115115
format_node(context, delta, left) {
116+
116117
// recurse
117118
this.formatDeltaChildren(context, delta, left);
118119
}
@@ -156,7 +157,7 @@ const deltaAnnotations = {
156157
},
157158
moved(delta, left, key, leftKey) {
158159
return (
159-
`move from <span title="(position to remove at original state)">` +
160+
'move from <span title="(position to remove at original state)">' +
160161
`index ${leftKey}</span> to <span title="(position to insert at final` +
161162
` state)">index ${delta[1]}</span>`
162163
);
@@ -170,7 +171,7 @@ const deltaAnnotations = {
170171
: ` at property ${wrapPropertyName(leftKey)}`;
171172
return (
172173
`text diff${location}, format is <a href="https://code.google.com/` +
173-
`p/google-diff-match-patch/wiki/Unidiff">a variation of Unidiff</a>`
174+
'p/google-diff-match-patch/wiki/Unidiff">a variation of Unidiff</a>'
174175
);
175176
},
176177
};
@@ -183,6 +184,7 @@ const formatAnyChange = function(context, delta) {
183184
annotator.apply(annotator, Array.prototype.slice.call(arguments, 1));
184185
let json = JSON.stringify(delta, null, 2);
185186
if (deltaType === 'textdiff') {
187+
186188
// split text diffs lines
187189
json = json.split('\\n').join('\\n"+\n "');
188190
}

0 commit comments

Comments
 (0)