Lint the expressions package
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {Array, BooleanData, ExpressionData, Kind} from "../data";
|
||||
import {BooleanData, ExpressionData, Kind} from "../data";
|
||||
import {equals} from "../result";
|
||||
import {FunctionDefinition} from "./info";
|
||||
|
||||
@@ -19,7 +19,7 @@ export const contains: FunctionDefinition = {
|
||||
return new BooleanData(ls.toLowerCase().includes(rs.toLowerCase()));
|
||||
}
|
||||
} else if (left.kind === Kind.Array) {
|
||||
const la = left as Array;
|
||||
const la = left;
|
||||
if (la.values().length === 0) {
|
||||
return new BooleanData(false);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ export const format: FunctionDefinition = {
|
||||
|
||||
while (index < fs.length) {
|
||||
const lbrace = fs.indexOf("{", index);
|
||||
let rbrace = fs.indexOf("}", index);
|
||||
const rbrace = fs.indexOf("}", index);
|
||||
|
||||
// Left brace
|
||||
if (lbrace >= 0 && (rbrace < 0 || rbrace > lbrace)) {
|
||||
@@ -81,7 +81,7 @@ function safeCharAt(string: string, index: number): string {
|
||||
function readArgIndex(string: string, startIndex: number): ArgIndex {
|
||||
// Count the number of digits
|
||||
let length = 0;
|
||||
while (true) {
|
||||
for (;;) {
|
||||
const nextChar = safeCharAt(string, startIndex + length);
|
||||
if (nextChar >= "0" && nextChar <= "9") {
|
||||
length++;
|
||||
@@ -112,9 +112,3 @@ interface ArgIndex {
|
||||
result: number;
|
||||
endIndex: number;
|
||||
}
|
||||
|
||||
interface FormatSpecifiers {
|
||||
success: boolean;
|
||||
result: string;
|
||||
rbrace: number;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ export const fromjson: FunctionDefinition = {
|
||||
}
|
||||
|
||||
try {
|
||||
return JSON.parse(is, reviver);
|
||||
return JSON.parse(is, reviver) as ExpressionData;
|
||||
} catch (e) {
|
||||
throw new ExpressionEvaluationError("Error parsing JSON when evaluating fromJson", {cause: e});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Array, ExpressionData, Kind, StringData} from "../data";
|
||||
import {ExpressionData, Kind, StringData} from "../data";
|
||||
import {FunctionDefinition} from "./info";
|
||||
|
||||
export const join: FunctionDefinition = {
|
||||
@@ -23,7 +23,7 @@ export const join: FunctionDefinition = {
|
||||
|
||||
// Convert items to strings
|
||||
return new StringData(
|
||||
(args[0] as Array)
|
||||
args[0]
|
||||
.values()
|
||||
.map(item => item.coerceString())
|
||||
.join(separator)
|
||||
|
||||
Reference in New Issue
Block a user