Reduce lint errors
This commit is contained in:
+13
-13
@@ -36,7 +36,7 @@ export function applyQuery<T>(parsedQuery: ParsedQuery, records: T[]): T[] {
|
||||
recordLoop:
|
||||
for (const record of records) {
|
||||
const recordAny: any = record;
|
||||
for (let { op, prop, value } of parsedQuery.filter) {
|
||||
for (const { op, prop, value } of parsedQuery.filter) {
|
||||
switch (op) {
|
||||
case "=": {
|
||||
const recordPropVal = recordAny[prop];
|
||||
@@ -123,8 +123,8 @@ export function applyQuery<T>(parsedQuery: ParsedQuery, records: T[]): T[] {
|
||||
}
|
||||
if (parsedQuery.select) {
|
||||
resultRecords = resultRecords.map((rec) => {
|
||||
let newRec: any = {};
|
||||
for (let k of parsedQuery.select!) {
|
||||
const newRec: any = {};
|
||||
for (const k of parsedQuery.select!) {
|
||||
newRec[k] = rec[k];
|
||||
}
|
||||
return newRec;
|
||||
@@ -139,27 +139,27 @@ export function removeQueries(pt: ParseTree) {
|
||||
if (t.type !== "CommentBlock") {
|
||||
return false;
|
||||
}
|
||||
let text = t.children![0].text!;
|
||||
let match = directiveStartRegex.exec(text);
|
||||
const text = t.children![0].text!;
|
||||
const match = directiveStartRegex.exec(text);
|
||||
if (!match) {
|
||||
return false;
|
||||
}
|
||||
let directiveType = match[1];
|
||||
let parentChildren = t.parent!.children!;
|
||||
let index = parentChildren.indexOf(t);
|
||||
let nodesToReplace: ParseTree[] = [];
|
||||
const directiveType = match[1];
|
||||
const parentChildren = t.parent!.children!;
|
||||
const index = parentChildren.indexOf(t);
|
||||
const nodesToReplace: ParseTree[] = [];
|
||||
for (let i = index + 1; i < parentChildren.length; i++) {
|
||||
let n = parentChildren[i];
|
||||
const n = parentChildren[i];
|
||||
if (n.type === "CommentBlock") {
|
||||
let text = n.children![0].text!;
|
||||
let match = directiveEndRegex.exec(text);
|
||||
const text = n.children![0].text!;
|
||||
const match = directiveEndRegex.exec(text);
|
||||
if (match && match[1] === directiveType) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
nodesToReplace.push(n);
|
||||
}
|
||||
let renderedText = nodesToReplace.map(renderToText).join("");
|
||||
const renderedText = nodesToReplace.map(renderToText).join("");
|
||||
parentChildren.splice(index + 1, nodesToReplace.length, {
|
||||
text: new Array(renderedText.length + 1).join(" "),
|
||||
});
|
||||
|
||||
+11
-11
@@ -12,7 +12,7 @@ export function addParentPointers(tree: ParseTree) {
|
||||
if (!tree.children) {
|
||||
return;
|
||||
}
|
||||
for (let child of tree.children) {
|
||||
for (const child of tree.children) {
|
||||
if (child.parent) {
|
||||
// Already added parent pointers before
|
||||
return;
|
||||
@@ -27,7 +27,7 @@ export function removeParentPointers(tree: ParseTree) {
|
||||
if (!tree.children) {
|
||||
return;
|
||||
}
|
||||
for (let child of tree.children) {
|
||||
for (const child of tree.children) {
|
||||
removeParentPointers(child);
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ export function collectNodesMatching(
|
||||
}
|
||||
let results: ParseTree[] = [];
|
||||
if (tree.children) {
|
||||
for (let child of tree.children) {
|
||||
for (const child of tree.children) {
|
||||
results = [...results, ...collectNodesMatching(child, matchFn)];
|
||||
}
|
||||
}
|
||||
@@ -75,11 +75,11 @@ export function replaceNodesMatching(
|
||||
substituteFn: (tree: ParseTree) => ParseTree | null | undefined,
|
||||
) {
|
||||
if (tree.children) {
|
||||
let children = tree.children.slice();
|
||||
for (let child of children) {
|
||||
let subst = substituteFn(child);
|
||||
const children = tree.children.slice();
|
||||
for (const child of children) {
|
||||
const subst = substituteFn(child);
|
||||
if (subst !== undefined) {
|
||||
let pos = tree.children.indexOf(child);
|
||||
const pos = tree.children.indexOf(child);
|
||||
if (subst) {
|
||||
tree.children.splice(pos, 1, subst);
|
||||
} else {
|
||||
@@ -124,8 +124,8 @@ export function nodeAtPos(tree: ParseTree, pos: number): ParseTree | null {
|
||||
if (!tree.children) {
|
||||
return tree;
|
||||
}
|
||||
for (let child of tree.children) {
|
||||
let n = nodeAtPos(child, pos);
|
||||
for (const child of tree.children) {
|
||||
const n = nodeAtPos(child, pos);
|
||||
if (n && n.text !== undefined) {
|
||||
// Got a text node, let's return its parent
|
||||
return tree;
|
||||
@@ -139,11 +139,11 @@ export function nodeAtPos(tree: ParseTree, pos: number): ParseTree | null {
|
||||
|
||||
// Turn ParseTree back into text
|
||||
export function renderToText(tree: ParseTree): string {
|
||||
let pieces: string[] = [];
|
||||
const pieces: string[] = [];
|
||||
if (tree.text !== undefined) {
|
||||
return tree.text;
|
||||
}
|
||||
for (let child of tree.children!) {
|
||||
for (const child of tree.children!) {
|
||||
pieces.push(renderToText(child));
|
||||
}
|
||||
return pieces.join("");
|
||||
|
||||
Reference in New Issue
Block a user