Introduce oxlint, and fix lint warnings

This commit is contained in:
James Babcock committed 2026-09-29 11:54:22 -07:00
1 parent cb6dddd120
commit 06146c2b08
89 files changed
+818 -469

No files matched your search

+1 -2
View File
@@ -96,8 +96,7 @@ export function createCalculatorAppWindow(options: InProcessAppOptions): InProce
},
];
let app: InProcessWindow;
app = createInProcessWindow({
const app = createInProcessWindow({
appId: "calculator",
windowId: CALCULATOR_WINDOW_ID,
title: "Calculator",
+1 -1
View File
@@ -24,7 +24,7 @@ import {
findDigits,
highlightedMatch,
} from "./digit-search";
import { type MathWorkload, longRunOffer as makeLongRunOffer, type LongRunOffer } from "./workload";
import { type MathWorkload } from "./workload";
import {
binomial,
factorizationText,
+1 -1
View File
@@ -322,7 +322,7 @@ export function digitalRoot(value: number): number {
export function isPalindrome(value: number): boolean {
const text = String(Math.abs(value));
return text === [...text].reverse().join("");
return text === text.split("").reverse().join("");
}
export function isPerfect(value: number): boolean {
+2 -2
View File
@@ -123,7 +123,7 @@ export class Polynomial {
*/
dividingByRoot(root: MathNumber): Polynomial {
if (this.degree < 1) return this;
const quotient: MathNumber[] = new Array(this.degree).fill(integer(0));
const quotient: MathNumber[] = Array.from({ length: this.degree }, () => integer(0));
let carry: MathNumber = integer(0);
for (let power = this.degree; power >= 1; power--) {
const coefficient = add(this.at(power), carry);
@@ -235,7 +235,7 @@ function addAt(value: MathNumber, power: number, coefficients: MathNumber[]): vo
function convolve(lhs: MathNumber[], rhs: MathNumber[]): MathNumber[] {
if (lhs.length === 0 || rhs.length === 0) return [integer(0)];
const result: MathNumber[] = new Array(lhs.length + rhs.length - 1).fill(integer(0));
const result: MathNumber[] = Array.from({ length: lhs.length + rhs.length - 1 }, () => integer(0));
for (let i = 0; i < lhs.length; i++) {
if (isZero(lhs[i]!)) continue;
for (let j = 0; j < rhs.length; j++) {
-1
View File
@@ -19,7 +19,6 @@ import {
multiplyExpr,
negate,
num,
numberValue,
relation as relationExpr,
spokenRelation,
subtractExpr,
@@ -29,12 +29,12 @@ import {
numberEquals,
rational,
reciprocal,
isZero,
} from "./math-number";
import { simplify } from "./simplifier";
import { differentiate, integrateNumeric } from "./derivative";
import { evaluateValue } from "./evaluator";
import { Polynomial } from "./polynomial";
import { isZero } from "./math-number";
/** Indefinite integral with respect to `variable`, without the constant. */
export function integrate(expression: MathExpression, variable: string): MathExpression | null {
+2 -7
View File
@@ -103,8 +103,7 @@ function render(expression: MathExpression, parentPrecedence: number): string {
return wrap(`1/${inner}`, parentPrecedence > PRECEDENCE.product);
}
const body =
`${render(expression.base, PRECEDENCE.power + 1)}` +
`^${render(expression.exponent, PRECEDENCE.power + 1)}`;
`${render(expression.base, PRECEDENCE.power + 1)}^${render(expression.exponent, PRECEDENCE.power + 1)}`;
return wrap(body, parentPrecedence > PRECEDENCE.power);
}
@@ -116,11 +115,7 @@ function render(expression: MathExpression, parentPrecedence: number): string {
}
case "relation":
return (
`${render(expression.lhs, PRECEDENCE.relation)} ` +
`${expression.relation} ` +
`${render(expression.rhs, PRECEDENCE.relation)}`
);
return `${render(expression.lhs, PRECEDENCE.relation)} ${expression.relation} ${render(expression.rhs, PRECEDENCE.relation)}`;
}
}
+10 -10
View File
@@ -26,14 +26,14 @@ export type SolutionFamily = {
baseExpression: MathExpression | null;
};
export function familyValues(family: SolutionFamily, lower: number, upper: number): number[] {
if (family.period <= 0) {
return family.base >= lower && family.base <= upper ? [family.base] : [];
export function familyValues(solutionFamily: SolutionFamily, lower: number, upper: number): number[] {
if (solutionFamily.period <= 0) {
return solutionFamily.base >= lower && solutionFamily.base <= upper ? [solutionFamily.base] : [];
}
const results: number[] = [];
let n = Math.floor((lower - family.base) / family.period);
let n = Math.floor((lower - solutionFamily.base) / solutionFamily.period);
for (;;) {
const value = family.base + n * family.period;
const value = solutionFamily.base + n * solutionFamily.period;
if (value > upper) break;
if (value >= lower) results.push(value);
n += 1;
@@ -42,14 +42,14 @@ export function familyValues(family: SolutionFamily, lower: number, upper: numbe
return results;
}
export function familyText(family: SolutionFamily): string {
const baseText = family.baseExpression
? plain(family.baseExpression)
: describeNumber(fromDecimal(family.base));
export function familyText(solutionFamily: SolutionFamily): string {
const baseText = solutionFamily.baseExpression
? plain(solutionFamily.baseExpression)
: describeNumber(fromDecimal(solutionFamily.base));
// The separator is load-bearing: "2*pi" run straight into the index reads
// as "2*pin", a different and nonsensical expression to anyone scanning it
// on the lens.
const periodText = describePi(family.period);
const periodText = describePi(solutionFamily.period);
return `${baseText} + ${periodText}·n`;
}