mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
lint: Changeset.js opcode eqeqeq checks
This commit is contained in:
parent
d91f2b5b07
commit
98a0e76a20
1 changed files with 38 additions and 38 deletions
|
@ -308,20 +308,20 @@ exports.smartOpAssembler = () => {
|
||||||
if (!op.opcode) return;
|
if (!op.opcode) return;
|
||||||
if (!op.chars) return;
|
if (!op.chars) return;
|
||||||
|
|
||||||
if (op.opcode == '-') {
|
if (op.opcode === '-') {
|
||||||
if (lastOpcode == '=') {
|
if (lastOpcode === '=') {
|
||||||
flushKeeps();
|
flushKeeps();
|
||||||
}
|
}
|
||||||
minusAssem.append(op);
|
minusAssem.append(op);
|
||||||
lengthChange -= op.chars;
|
lengthChange -= op.chars;
|
||||||
} else if (op.opcode == '+') {
|
} else if (op.opcode === '+') {
|
||||||
if (lastOpcode == '=') {
|
if (lastOpcode === '=') {
|
||||||
flushKeeps();
|
flushKeeps();
|
||||||
}
|
}
|
||||||
plusAssem.append(op);
|
plusAssem.append(op);
|
||||||
lengthChange += op.chars;
|
lengthChange += op.chars;
|
||||||
} else if (op.opcode == '=') {
|
} else if (op.opcode === '=') {
|
||||||
if (lastOpcode != '=') {
|
if (lastOpcode !== '=') {
|
||||||
flushPlusMinus();
|
flushPlusMinus();
|
||||||
}
|
}
|
||||||
keepAssem.append(op);
|
keepAssem.append(op);
|
||||||
|
@ -394,7 +394,7 @@ exports.mergingOpAssembler = () => {
|
||||||
|
|
||||||
const flush = (isEndDocument) => {
|
const flush = (isEndDocument) => {
|
||||||
if (bufOp.opcode) {
|
if (bufOp.opcode) {
|
||||||
if (isEndDocument && bufOp.opcode == '=' && !bufOp.attribs) {
|
if (isEndDocument && bufOp.opcode === '=' && !bufOp.attribs) {
|
||||||
// final merged keep, leave it implicit
|
// final merged keep, leave it implicit
|
||||||
} else {
|
} else {
|
||||||
assem.append(bufOp);
|
assem.append(bufOp);
|
||||||
|
@ -411,7 +411,7 @@ exports.mergingOpAssembler = () => {
|
||||||
|
|
||||||
const append = (op) => {
|
const append = (op) => {
|
||||||
if (op.chars > 0) {
|
if (op.chars > 0) {
|
||||||
if (bufOp.opcode == op.opcode && bufOp.attribs == op.attribs) {
|
if (bufOp.opcode === op.opcode && bufOp.attribs === op.attribs) {
|
||||||
if (op.lines > 0) {
|
if (op.lines > 0) {
|
||||||
// bufOp and additional chars are all mergeable into a multi-line op
|
// bufOp and additional chars are all mergeable into a multi-line op
|
||||||
bufOp.chars += bufOpAdditionalCharsAfterNewline + op.chars;
|
bufOp.chars += bufOpAdditionalCharsAfterNewline + op.chars;
|
||||||
|
@ -844,7 +844,7 @@ exports.unpack = (cs) => {
|
||||||
exports.error(`Not a exports: ${cs}`);
|
exports.error(`Not a exports: ${cs}`);
|
||||||
}
|
}
|
||||||
const oldLen = exports.parseNum(headerMatch[1]);
|
const oldLen = exports.parseNum(headerMatch[1]);
|
||||||
const changeSign = (headerMatch[2] == '>') ? 1 : -1;
|
const changeSign = (headerMatch[2] === '>') ? 1 : -1;
|
||||||
const changeMag = exports.parseNum(headerMatch[3]);
|
const changeMag = exports.parseNum(headerMatch[3]);
|
||||||
const newLen = oldLen + changeSign * changeMag;
|
const newLen = oldLen + changeSign * changeMag;
|
||||||
const opsStart = headerMatch[0].length;
|
const opsStart = headerMatch[0].length;
|
||||||
|
@ -1019,7 +1019,7 @@ exports._slicerZipperFunc = (attOp, csOp, opOut, pool) => {
|
||||||
// attribution string or the earlier of two exportss being composed.
|
// attribution string or the earlier of two exportss being composed.
|
||||||
// pool can be null if definitely not needed.
|
// pool can be null if definitely not needed.
|
||||||
// print(csOp.toSource()+" "+attOp.toSource()+" "+opOut.toSource());
|
// print(csOp.toSource()+" "+attOp.toSource()+" "+opOut.toSource());
|
||||||
if (attOp.opcode == '-') {
|
if (attOp.opcode === '-') {
|
||||||
exports.copyOp(attOp, opOut);
|
exports.copyOp(attOp, opOut);
|
||||||
attOp.opcode = '';
|
attOp.opcode = '';
|
||||||
} else if (!attOp.opcode) {
|
} else if (!attOp.opcode) {
|
||||||
|
@ -1045,7 +1045,7 @@ exports._slicerZipperFunc = (attOp, csOp, opOut, pool) => {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// delete and keep going
|
// delete and keep going
|
||||||
if (attOp.opcode == '=') {
|
if (attOp.opcode === '=') {
|
||||||
opOut.opcode = '-';
|
opOut.opcode = '-';
|
||||||
opOut.chars = attOp.chars;
|
opOut.chars = attOp.chars;
|
||||||
opOut.lines = attOp.lines;
|
opOut.lines = attOp.lines;
|
||||||
|
@ -1071,7 +1071,7 @@ exports._slicerZipperFunc = (attOp, csOp, opOut, pool) => {
|
||||||
opOut.opcode = attOp.opcode;
|
opOut.opcode = attOp.opcode;
|
||||||
opOut.chars = csOp.chars;
|
opOut.chars = csOp.chars;
|
||||||
opOut.lines = csOp.lines;
|
opOut.lines = csOp.lines;
|
||||||
opOut.attribs = exports.composeAttributes(attOp.attribs, csOp.attribs, attOp.opcode == '=', pool);
|
opOut.attribs = exports.composeAttributes(attOp.attribs, csOp.attribs, attOp.opcode === '=', pool);
|
||||||
csOp.opcode = '';
|
csOp.opcode = '';
|
||||||
attOp.chars -= csOp.chars;
|
attOp.chars -= csOp.chars;
|
||||||
attOp.lines -= csOp.lines;
|
attOp.lines -= csOp.lines;
|
||||||
|
@ -1171,12 +1171,12 @@ exports.mutateAttributionLines = (cs, lines, pool) => {
|
||||||
// print("csOp: "+csOp.toSource());
|
// print("csOp: "+csOp.toSource());
|
||||||
if ((!csOp.opcode) && (!attOp.opcode) && (!lineAssem) && (!(lineIter && lineIter.hasNext()))) {
|
if ((!csOp.opcode) && (!attOp.opcode) && (!lineAssem) && (!(lineIter && lineIter.hasNext()))) {
|
||||||
break; // done
|
break; // done
|
||||||
} else if (csOp.opcode == '=' && csOp.lines > 0 && (!csOp.attribs) && (!attOp.opcode) && (!lineAssem) && (!(lineIter && lineIter.hasNext()))) {
|
} else if (csOp.opcode === '=' && csOp.lines > 0 && (!csOp.attribs) && (!attOp.opcode) && (!lineAssem) && (!(lineIter && lineIter.hasNext()))) {
|
||||||
// skip multiple lines; this is what makes small changes not order of the document size
|
// skip multiple lines; this is what makes small changes not order of the document size
|
||||||
mut.skipLines(csOp.lines);
|
mut.skipLines(csOp.lines);
|
||||||
// print("skipped: "+csOp.lines);
|
// print("skipped: "+csOp.lines);
|
||||||
csOp.opcode = '';
|
csOp.opcode = '';
|
||||||
} else if (csOp.opcode == '+') {
|
} else if (csOp.opcode === '+') {
|
||||||
if (csOp.lines > 1) {
|
if (csOp.lines > 1) {
|
||||||
const firstLineLen = csBank.indexOf('\n', csBankIndex) + 1 - csBankIndex;
|
const firstLineLen = csBank.indexOf('\n', csBankIndex) + 1 - csBankIndex;
|
||||||
exports.copyOp(csOp, opOut);
|
exports.copyOp(csOp, opOut);
|
||||||
|
@ -1296,12 +1296,12 @@ exports.compose = (cs1, cs2, pool) => {
|
||||||
// debugBuilder.append(' / ');
|
// debugBuilder.append(' / ');
|
||||||
const op1code = op1.opcode;
|
const op1code = op1.opcode;
|
||||||
const op2code = op2.opcode;
|
const op2code = op2.opcode;
|
||||||
if (op1code == '+' && op2code == '-') {
|
if (op1code === '+' && op2code === '-') {
|
||||||
bankIter1.skip(Math.min(op1.chars, op2.chars));
|
bankIter1.skip(Math.min(op1.chars, op2.chars));
|
||||||
}
|
}
|
||||||
exports._slicerZipperFunc(op1, op2, opOut, pool);
|
exports._slicerZipperFunc(op1, op2, opOut, pool);
|
||||||
if (opOut.opcode == '+') {
|
if (opOut.opcode === '+') {
|
||||||
if (op2code == '+') {
|
if (op2code === '+') {
|
||||||
bankAssem.append(bankIter2.take(opOut.chars));
|
bankAssem.append(bankIter2.take(opOut.chars));
|
||||||
} else {
|
} else {
|
||||||
bankAssem.append(bankIter1.take(opOut.chars));
|
bankAssem.append(bankIter1.take(opOut.chars));
|
||||||
|
@ -1396,7 +1396,7 @@ exports.toSplices = (cs) => {
|
||||||
let inSplice = false;
|
let inSplice = false;
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
const op = iter.next();
|
const op = iter.next();
|
||||||
if (op.opcode == '=') {
|
if (op.opcode === '=') {
|
||||||
oldPos += op.chars;
|
oldPos += op.chars;
|
||||||
inSplice = false;
|
inSplice = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1404,10 +1404,10 @@ exports.toSplices = (cs) => {
|
||||||
splices.push([oldPos, oldPos, '']);
|
splices.push([oldPos, oldPos, '']);
|
||||||
inSplice = true;
|
inSplice = true;
|
||||||
}
|
}
|
||||||
if (op.opcode == '-') {
|
if (op.opcode === '-') {
|
||||||
oldPos += op.chars;
|
oldPos += op.chars;
|
||||||
splices[splices.length - 1][1] += op.chars;
|
splices[splices.length - 1][1] += op.chars;
|
||||||
} else if (op.opcode == '+') {
|
} else if (op.opcode === '+') {
|
||||||
splices[splices.length - 1][2] += charIter.take(op.chars);
|
splices[splices.length - 1][2] += charIter.take(op.chars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1663,7 +1663,7 @@ exports.prepareForWire = (cs, pool) => {
|
||||||
*/
|
*/
|
||||||
exports.isIdentity = (cs) => {
|
exports.isIdentity = (cs) => {
|
||||||
const unpacked = exports.unpack(cs);
|
const unpacked = exports.unpack(cs);
|
||||||
return unpacked.ops == '' && unpacked.oldLen == unpacked.newLen;
|
return unpacked.ops === '' && unpacked.oldLen == unpacked.newLen;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1755,7 +1755,7 @@ exports.makeAttribsString = (opcode, attribs, pool) => {
|
||||||
const result = [];
|
const result = [];
|
||||||
for (let i = 0; i < attribs.length; i++) {
|
for (let i = 0; i < attribs.length; i++) {
|
||||||
const pair = attribs[i];
|
const pair = attribs[i];
|
||||||
if (opcode == '=' || (opcode == '+' && pair[1])) {
|
if (opcode === '=' || (opcode === '+' && pair[1])) {
|
||||||
result.push(`*${exports.numToString(pool.putAttrib(pair))}`);
|
result.push(`*${exports.numToString(pool.putAttrib(pair))}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1927,7 +1927,7 @@ exports.inverse = (cs, lines, alines, pool) => {
|
||||||
const attribValues = [];
|
const attribValues = [];
|
||||||
while (csIter.hasNext()) {
|
while (csIter.hasNext()) {
|
||||||
const csOp = csIter.next();
|
const csOp = csIter.next();
|
||||||
if (csOp.opcode == '=') {
|
if (csOp.opcode === '=') {
|
||||||
if (csOp.attribs) {
|
if (csOp.attribs) {
|
||||||
attribKeys.length = 0;
|
attribKeys.length = 0;
|
||||||
attribValues.length = 0;
|
attribValues.length = 0;
|
||||||
|
@ -1954,9 +1954,9 @@ exports.inverse = (cs, lines, alines, pool) => {
|
||||||
skip(csOp.chars, csOp.lines);
|
skip(csOp.chars, csOp.lines);
|
||||||
builder.keep(csOp.chars, csOp.lines);
|
builder.keep(csOp.chars, csOp.lines);
|
||||||
}
|
}
|
||||||
} else if (csOp.opcode == '+') {
|
} else if (csOp.opcode === '+') {
|
||||||
builder.remove(csOp.chars, csOp.lines);
|
builder.remove(csOp.chars, csOp.lines);
|
||||||
} else if (csOp.opcode == '-') {
|
} else if (csOp.opcode === '-') {
|
||||||
var textBank = nextText(csOp.chars);
|
var textBank = nextText(csOp.chars);
|
||||||
var textBankIndex = 0;
|
var textBankIndex = 0;
|
||||||
consumeAttribRuns(csOp.chars, (len, attribs, endsLine) => {
|
consumeAttribRuns(csOp.chars, (len, attribs, endsLine) => {
|
||||||
|
@ -1986,11 +1986,11 @@ exports.follow = (cs1, cs2, reverseInsertOrder, pool) => {
|
||||||
const hasInsertFirst = exports.attributeTester(['insertorder', 'first'], pool);
|
const hasInsertFirst = exports.attributeTester(['insertorder', 'first'], pool);
|
||||||
|
|
||||||
const newOps = exports.applyZip(unpacked1.ops, 0, unpacked2.ops, 0, (op1, op2, opOut) => {
|
const newOps = exports.applyZip(unpacked1.ops, 0, unpacked2.ops, 0, (op1, op2, opOut) => {
|
||||||
if (op1.opcode == '+' || op2.opcode == '+') {
|
if (op1.opcode === '+' || op2.opcode === '+') {
|
||||||
let whichToDo;
|
let whichToDo;
|
||||||
if (op2.opcode != '+') {
|
if (op2.opcode !== '+') {
|
||||||
whichToDo = 1;
|
whichToDo = 1;
|
||||||
} else if (op1.opcode != '+') {
|
} else if (op1.opcode !== '+') {
|
||||||
whichToDo = 2;
|
whichToDo = 2;
|
||||||
} else {
|
} else {
|
||||||
// both +
|
// both +
|
||||||
|
@ -2029,7 +2029,7 @@ exports.follow = (cs1, cs2, reverseInsertOrder, pool) => {
|
||||||
exports.copyOp(op2, opOut);
|
exports.copyOp(op2, opOut);
|
||||||
op2.opcode = '';
|
op2.opcode = '';
|
||||||
}
|
}
|
||||||
} else if (op1.opcode == '-') {
|
} else if (op1.opcode === '-') {
|
||||||
if (!op2.opcode) {
|
if (!op2.opcode) {
|
||||||
op1.opcode = '';
|
op1.opcode = '';
|
||||||
} else if (op1.chars <= op2.chars) {
|
} else if (op1.chars <= op2.chars) {
|
||||||
|
@ -2044,7 +2044,7 @@ exports.follow = (cs1, cs2, reverseInsertOrder, pool) => {
|
||||||
op1.lines -= op2.lines;
|
op1.lines -= op2.lines;
|
||||||
op2.opcode = '';
|
op2.opcode = '';
|
||||||
}
|
}
|
||||||
} else if (op2.opcode == '-') {
|
} else if (op2.opcode === '-') {
|
||||||
exports.copyOp(op2, opOut);
|
exports.copyOp(op2, opOut);
|
||||||
if (!op1.opcode) {
|
if (!op1.opcode) {
|
||||||
op2.opcode = '';
|
op2.opcode = '';
|
||||||
|
@ -2162,12 +2162,12 @@ exports.composeWithDeletions = (cs1, cs2, pool) => {
|
||||||
const newOps = exports.applyZip(unpacked1.ops, 0, unpacked2.ops, 0, (op1, op2, opOut) => {
|
const newOps = exports.applyZip(unpacked1.ops, 0, unpacked2.ops, 0, (op1, op2, opOut) => {
|
||||||
const op1code = op1.opcode;
|
const op1code = op1.opcode;
|
||||||
const op2code = op2.opcode;
|
const op2code = op2.opcode;
|
||||||
if (op1code == '+' && op2code == '-') {
|
if (op1code === '+' && op2code === '-') {
|
||||||
bankIter1.skip(Math.min(op1.chars, op2.chars));
|
bankIter1.skip(Math.min(op1.chars, op2.chars));
|
||||||
}
|
}
|
||||||
exports._slicerZipperFuncWithDeletions(op1, op2, opOut, pool);
|
exports._slicerZipperFuncWithDeletions(op1, op2, opOut, pool);
|
||||||
if (opOut.opcode == '+') {
|
if (opOut.opcode === '+') {
|
||||||
if (op2code == '+') {
|
if (op2code === '+') {
|
||||||
bankAssem.append(bankIter2.take(opOut.chars));
|
bankAssem.append(bankIter2.take(opOut.chars));
|
||||||
} else {
|
} else {
|
||||||
bankAssem.append(bankIter1.take(opOut.chars));
|
bankAssem.append(bankIter1.take(opOut.chars));
|
||||||
|
@ -2185,7 +2185,7 @@ exports._slicerZipperFuncWithDeletions = (attOp, csOp, opOut, pool) => {
|
||||||
// attribution string or the earlier of two exportss being composed.
|
// attribution string or the earlier of two exportss being composed.
|
||||||
// pool can be null if definitely not needed.
|
// pool can be null if definitely not needed.
|
||||||
// print(csOp.toSource()+" "+attOp.toSource()+" "+opOut.toSource());
|
// print(csOp.toSource()+" "+attOp.toSource()+" "+opOut.toSource());
|
||||||
if (attOp.opcode == '-') {
|
if (attOp.opcode === '-') {
|
||||||
exports.copyOp(attOp, opOut);
|
exports.copyOp(attOp, opOut);
|
||||||
attOp.opcode = '';
|
attOp.opcode = '';
|
||||||
} else if (!attOp.opcode) {
|
} else if (!attOp.opcode) {
|
||||||
|
@ -2197,7 +2197,7 @@ exports._slicerZipperFuncWithDeletions = (attOp, csOp, opOut, pool) => {
|
||||||
{
|
{
|
||||||
if (csOp.chars <= attOp.chars) {
|
if (csOp.chars <= attOp.chars) {
|
||||||
// delete or delete part
|
// delete or delete part
|
||||||
if (attOp.opcode == '=') {
|
if (attOp.opcode === '=') {
|
||||||
opOut.opcode = '-';
|
opOut.opcode = '-';
|
||||||
opOut.chars = csOp.chars;
|
opOut.chars = csOp.chars;
|
||||||
opOut.lines = csOp.lines;
|
opOut.lines = csOp.lines;
|
||||||
|
@ -2211,7 +2211,7 @@ exports._slicerZipperFuncWithDeletions = (attOp, csOp, opOut, pool) => {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// delete and keep going
|
// delete and keep going
|
||||||
if (attOp.opcode == '=') {
|
if (attOp.opcode === '=') {
|
||||||
opOut.opcode = '-';
|
opOut.opcode = '-';
|
||||||
opOut.chars = attOp.chars;
|
opOut.chars = attOp.chars;
|
||||||
opOut.lines = attOp.lines;
|
opOut.lines = attOp.lines;
|
||||||
|
@ -2237,7 +2237,7 @@ exports._slicerZipperFuncWithDeletions = (attOp, csOp, opOut, pool) => {
|
||||||
opOut.opcode = attOp.opcode;
|
opOut.opcode = attOp.opcode;
|
||||||
opOut.chars = csOp.chars;
|
opOut.chars = csOp.chars;
|
||||||
opOut.lines = csOp.lines;
|
opOut.lines = csOp.lines;
|
||||||
opOut.attribs = exports.composeAttributes(attOp.attribs, csOp.attribs, attOp.opcode == '=', pool);
|
opOut.attribs = exports.composeAttributes(attOp.attribs, csOp.attribs, attOp.opcode === '=', pool);
|
||||||
csOp.opcode = '';
|
csOp.opcode = '';
|
||||||
attOp.chars -= csOp.chars;
|
attOp.chars -= csOp.chars;
|
||||||
attOp.lines -= csOp.lines;
|
attOp.lines -= csOp.lines;
|
||||||
|
@ -2249,7 +2249,7 @@ exports._slicerZipperFuncWithDeletions = (attOp, csOp, opOut, pool) => {
|
||||||
opOut.opcode = attOp.opcode;
|
opOut.opcode = attOp.opcode;
|
||||||
opOut.chars = attOp.chars;
|
opOut.chars = attOp.chars;
|
||||||
opOut.lines = attOp.lines;
|
opOut.lines = attOp.lines;
|
||||||
opOut.attribs = exports.composeAttributes(attOp.attribs, csOp.attribs, attOp.opcode == '=', pool);
|
opOut.attribs = exports.composeAttributes(attOp.attribs, csOp.attribs, attOp.opcode === '=', pool);
|
||||||
attOp.opcode = '';
|
attOp.opcode = '';
|
||||||
csOp.chars -= attOp.chars;
|
csOp.chars -= attOp.chars;
|
||||||
csOp.lines -= attOp.lines;
|
csOp.lines -= attOp.lines;
|
||||||
|
|
Loading…
Reference in a new issue