mirror of
https://github.com/Mibew/simple-icons.git
synced 2025-04-04 03:57:07 +03:00
Fix error in 'collinear-segments' lint (#4604)
This commit is contained in:
parent
9c9188ec90
commit
c7734830f0
File diff suppressed because one or more lines are too long
@ -335,39 +335,39 @@ module.exports = {
|
|||||||
cmd = seg[0],
|
cmd = seg[0],
|
||||||
nextCmd = s + 1 < segments.length ? segments[s + 1][0] : null;
|
nextCmd = s + 1 < segments.length ? segments[s + 1][0] : null;
|
||||||
|
|
||||||
if ('LM'.includes(cmd)) {
|
if ('LM'.includes(cmd)) {
|
||||||
currAbsCoord[0] = seg[1];
|
currAbsCoord[0] = seg[1];
|
||||||
currAbsCoord[1] = seg[2];
|
currAbsCoord[1] = seg[2];
|
||||||
} else if ('lm'.includes(cmd)) {
|
} else if ('lm'.includes(cmd)) {
|
||||||
currAbsCoord[0] = (!currAbsCoord[0] ? 0 : currAbsCoord[0]) + seg[1];
|
currAbsCoord[0] = (!currAbsCoord[0] ? 0 : currAbsCoord[0]) + seg[1];
|
||||||
currAbsCoord[1] = (!currAbsCoord[1] ? 0 : currAbsCoord[1]) + seg[2];
|
currAbsCoord[1] = (!currAbsCoord[1] ? 0 : currAbsCoord[1]) + seg[2];
|
||||||
} else if (cmd === 'H') {
|
} else if (cmd === 'H') {
|
||||||
currAbsCoord[0] = seg[1];
|
currAbsCoord[0] = seg[1];
|
||||||
} else if (cmd === 'h') {
|
} else if (cmd === 'h') {
|
||||||
currAbsCoord[0] = (!currAbsCoord[0] ? 0 : currAbsCoord[0]) + seg[1];
|
currAbsCoord[0] = (!currAbsCoord[0] ? 0 : currAbsCoord[0]) + seg[1];
|
||||||
} else if (cmd === 'V') {
|
} else if (cmd === 'V') {
|
||||||
currAbsCoord[1] = seg[1];
|
currAbsCoord[1] = seg[1];
|
||||||
} else if (cmd === 'v') {
|
} else if (cmd === 'v') {
|
||||||
currAbsCoord[1] = (!currAbsCoord[1] ? 0 : currAbsCoord[1]) + seg[1];
|
currAbsCoord[1] = (!currAbsCoord[1] ? 0 : currAbsCoord[1]) + seg[1];
|
||||||
} else if (cmd === 'C') {
|
} else if (cmd === 'C') {
|
||||||
currAbsCoord[0] = seg[5];
|
currAbsCoord[0] = seg[5];
|
||||||
currAbsCoord[1] = seg[6];
|
currAbsCoord[1] = seg[6];
|
||||||
} else if (cmd === 'c') {
|
} else if (cmd === 'c') {
|
||||||
currAbsCoord[0] = (!currAbsCoord[0] ? 0 : currAbsCoord[0]) + seg[5];
|
currAbsCoord[0] = (!currAbsCoord[0] ? 0 : currAbsCoord[0]) + seg[5];
|
||||||
currAbsCoord[1] = (!currAbsCoord[1] ? 0 : currAbsCoord[1]) + seg[6];
|
currAbsCoord[1] = (!currAbsCoord[1] ? 0 : currAbsCoord[1]) + seg[6];
|
||||||
} else if (cmd === 'Q') {
|
} else if (cmd === 'Q') {
|
||||||
currAbsCoord[0] = seg[3];
|
currAbsCoord[0] = seg[3];
|
||||||
currAbsCoord[1] = seg[4];
|
currAbsCoord[1] = seg[4];
|
||||||
} else if (cmd === 'q') {
|
} else if (cmd === 'q') {
|
||||||
currAbsCoord[0] = (!currAbsCoord[0] ? 0 : currAbsCoord[0]) + seg[3];
|
currAbsCoord[0] = (!currAbsCoord[0] ? 0 : currAbsCoord[0]) + seg[3];
|
||||||
currAbsCoord[1] = (!currAbsCoord[1] ? 0 : currAbsCoord[1]) + seg[4];
|
currAbsCoord[1] = (!currAbsCoord[1] ? 0 : currAbsCoord[1]) + seg[4];
|
||||||
} else if (zCommands.includes(cmd)) {
|
} else if (zCommands.includes(cmd)) {
|
||||||
// Overlapping in Z should be handled in another rule
|
// Overlapping in Z should be handled in another rule
|
||||||
currAbsCoord = [undefined, undefined];
|
currAbsCoord = [undefined, undefined];
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`"${cmd}" command not handled`)
|
throw new Error(`"${cmd}" command not handled`)
|
||||||
}
|
}
|
||||||
|
|
||||||
_nextInStraightLine = straightLineCommands.includes(nextCmd);
|
_nextInStraightLine = straightLineCommands.includes(nextCmd);
|
||||||
let _exitingStraightLine = (_inStraightLine && !_nextInStraightLine);
|
let _exitingStraightLine = (_inStraightLine && !_nextInStraightLine);
|
||||||
_inStraightLine = straightLineCommands.includes(cmd);
|
_inStraightLine = straightLineCommands.includes(cmd);
|
||||||
@ -376,14 +376,11 @@ module.exports = {
|
|||||||
currLine.push([currAbsCoord[0], currAbsCoord[1]]);
|
currLine.push([currAbsCoord[0], currAbsCoord[1]]);
|
||||||
} else {
|
} else {
|
||||||
if (_exitingStraightLine) {
|
if (_exitingStraightLine) {
|
||||||
if (!zCommands.includes(cmd)) {
|
if (straightLineCommands.includes(cmd)) {
|
||||||
currLine.push([currAbsCoord[0], currAbsCoord[1]]);
|
currLine.push([currAbsCoord[0], currAbsCoord[1]]);
|
||||||
}
|
}
|
||||||
// Get collinear coordinates
|
// Get collinear coordinates
|
||||||
for (let p = 0; p < currLine.length; p++) {
|
for (let p = 1; p < currLine.length - 1; p++) {
|
||||||
if (p === 0 || p === currLine.length - 1) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
let _collinearCoord = collinear(currLine[p - 1][0],
|
let _collinearCoord = collinear(currLine[p - 1][0],
|
||||||
currLine[p - 1][1],
|
currLine[p - 1][1],
|
||||||
currLine[p][0],
|
currLine[p][0],
|
||||||
|
Loading…
Reference in New Issue
Block a user