Skip to content

Commit eff0a57

Browse files
Copilotmrjf
andauthored
Fix all CI lint errors: add benchmarks/ to biome ignore, fix formatting, TS4111 conflicts, noAssignInExpressions, noForEach, noNonNullAssertion
- Add benchmarks/** to biome.json ignore (benchmarks need console.log) - Auto-format all source files with biome format --write - Apply safe biome lint fixes (import sorting, useImportType, noUselessElse, etc.) - Fix noAssignInExpressions in string_ops.ts and string_ops_extended.ts (restructure while loops to avoid assignment in condition) - Fix noForEach in string_ops.ts (use for...of instead) - Fix noNonNullAssertion in test files (use ?? 0 instead of !) - Add biome-ignore comments for useLiteralKeys where bracket access is required by TypeScript's noPropertyAccessFromIndexSignature (TS4111) Agent-Logs-Url: https://github.com/githubnext/tsessebe/sessions/1df0cfcf-bce4-4db6-ad4b-cc73af955b11 Co-authored-by: mrjf <180956+mrjf@users.noreply.github.com>
1 parent b171f71 commit eff0a57

35 files changed

Lines changed: 673 additions & 410 deletions

biome.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77
},
88
"files": {
99
"ignoreUnknown": false,
10-
"ignore": ["dist/**", "node_modules/**", "*.d.ts", "playground/**/*.js", "playground/serve.ts"]
10+
"ignore": [
11+
"dist/**",
12+
"node_modules/**",
13+
"*.d.ts",
14+
"playground/**/*.js",
15+
"playground/serve.ts",
16+
"benchmarks/**"
17+
]
1118
},
1219
"formatter": {
1320
"enabled": true,

src/core/api_types.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
* @module
2424
*/
2525

26-
import { Dtype } from "./dtype.ts";
2726
import type { DtypeName } from "../types.ts";
27+
import { Dtype } from "./dtype.ts";
2828

2929
// ─── internal helper ──────────────────────────────────────────────────────────
3030

@@ -95,13 +95,19 @@ export function isListLike(val: unknown): boolean {
9595
return false;
9696
}
9797
// Has Symbol.iterator and is not a plain number/boolean/bigint/symbol
98-
if (typeof val === "number" || typeof val === "boolean" || typeof val === "bigint" || typeof val === "symbol") {
98+
if (
99+
typeof val === "number" ||
100+
typeof val === "boolean" ||
101+
typeof val === "bigint" ||
102+
typeof val === "symbol"
103+
) {
99104
return false;
100105
}
101106
if (typeof val === "object" || typeof val === "function") {
102107
if (Symbol.iterator in (val as object)) {
103108
return true;
104109
}
110+
// biome-ignore lint/complexity/useLiteralKeys: TS4111 index signature requires bracket access
105111
const len = (val as Record<string, unknown>)["length"];
106112
if (typeof len === "number" && len >= 0 && Number.isInteger(len)) {
107113
return true;
@@ -134,6 +140,7 @@ export function isArrayLike(val: unknown): boolean {
134140
if (typeof val !== "object" && typeof val !== "function") {
135141
return false;
136142
}
143+
// biome-ignore lint/complexity/useLiteralKeys: TS4111 index signature requires bracket access
137144
const len = (val as Record<string, unknown>)["length"];
138145
return typeof len === "number" && len >= 0 && Number.isInteger(len);
139146
}
@@ -192,6 +199,7 @@ export function isIterator(val: unknown): boolean {
192199
if (typeof val !== "object" && typeof val !== "function") {
193200
return false;
194201
}
202+
// biome-ignore lint/complexity/useLiteralKeys: TS4111 index signature requires bracket access
195203
return typeof (val as Record<string, unknown>)["next"] === "function";
196204
}
197205

src/core/attrs.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,9 @@ export function setAttr(obj: object, key: string, value: unknown): void {
227227
*/
228228
export function deleteAttr(obj: object, key: string): void {
229229
const existing = registry.get(obj);
230-
if (existing === undefined) return;
230+
if (existing === undefined) {
231+
return;
232+
}
231233
const { [key]: _removed, ...rest } = existing;
232234
if (Object.keys(rest).length === 0) {
233235
registry.delete(obj);

src/core/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ export { CategoricalAccessor } from "./cat_accessor.ts";
1515
export type { CatSeriesLike } from "./cat_accessor.ts";
1616
export { MultiIndex } from "./multi_index.ts";
1717
export type { MultiIndexOptions } from "./multi_index.ts";
18-
export { insertColumn, popColumn, reorderColumns, moveColumn, dataFrameFromPairs } from "./insert_pop.ts";
18+
export {
19+
insertColumn,
20+
popColumn,
21+
reorderColumns,
22+
moveColumn,
23+
dataFrameFromPairs,
24+
} from "./insert_pop.ts";
1925
export type { PopResult } from "./insert_pop.ts";
2026
export { toDictOriented, fromDictOriented } from "./to_from_dict.ts";
2127
export type {

src/core/insert_pop.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*/
2828

2929
import type { Label, Scalar } from "../types.ts";
30-
import { Index } from "./base-index.ts";
30+
import type { Index } from "./base-index.ts";
3131
import { DataFrame } from "./frame.ts";
3232
import { Series } from "./series.ts";
3333

src/core/pipe_apply.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,7 @@ import type { Label, Scalar } from "../types.ts";
4545
export function pipe<A>(value: A): A;
4646
export function pipe<A, B>(value: A, fn1: (a: A) => B): B;
4747
export function pipe<A, B, C>(value: A, fn1: (a: A) => B, fn2: (b: B) => C): C;
48-
export function pipe<A, B, C, D>(
49-
value: A,
50-
fn1: (a: A) => B,
51-
fn2: (b: B) => C,
52-
fn3: (c: C) => D,
53-
): D;
48+
export function pipe<A, B, C, D>(value: A, fn1: (a: A) => B, fn2: (b: B) => C, fn3: (c: C) => D): D;
5449
export function pipe<A, B, C, D, E>(
5550
value: A,
5651
fn1: (a: A) => B,
@@ -119,7 +114,11 @@ export function seriesApply(
119114
for (let i = 0; i < n; i++) {
120115
out[i] = fn(series.iat(i), series.index.at(i), i);
121116
}
122-
return new Series({ data: out, index: series.index, ...(series.name !== null ? { name: series.name } : {}) });
117+
return new Series({
118+
data: out,
119+
index: series.index,
120+
...(series.name !== null ? { name: series.name } : {}),
121+
});
123122
}
124123

125124
/**
@@ -141,7 +140,11 @@ export function seriesTransform(
141140
for (let i = 0; i < n; i++) {
142141
out[i] = fn(series.iat(i));
143142
}
144-
return new Series({ data: out, index: series.index, ...(series.name !== null ? { name: series.name } : {}) });
143+
return new Series({
144+
data: out,
145+
index: series.index,
146+
...(series.name !== null ? { name: series.name } : {}),
147+
});
145148
}
146149

147150
// ─── DataFrame apply ──────────────────────────────────────────────────────────
@@ -272,7 +275,11 @@ export function dataFrameTransform(
272275
*/
273276
export function dataFrameTransformRows(
274277
df: DataFrame,
275-
fn: (row: Readonly<Record<string, Scalar>>, rowLabel: Label, position: number) => Readonly<Record<string, Scalar>>,
278+
fn: (
279+
row: Readonly<Record<string, Scalar>>,
280+
rowLabel: Label,
281+
position: number,
282+
) => Readonly<Record<string, Scalar>>,
276283
): DataFrame {
277284
const colNames = df.columns.values as readonly string[];
278285
const rowLabels = df.index.values as readonly Label[];
@@ -290,7 +297,9 @@ export function dataFrameTransformRows(
290297
const rowOut = fn(rowIn, rowLabels[i] as Label, i);
291298
for (const c of colNames) {
292299
const colArr = colArrays.get(c);
293-
if (colArr === undefined) continue;
300+
if (colArr === undefined) {
301+
continue;
302+
}
294303
// use the transformed value if present, else keep original
295304
colArr[i] = c in rowOut ? (rowOut[c] as Scalar) : rowIn[c];
296305
}

src/core/to_from_dict.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,20 @@
2525
import type { Label, Scalar } from "../types.ts";
2626
import { Index } from "./base-index.ts";
2727
import { DataFrame } from "./frame.ts";
28-
import { Series } from "./series.ts";
28+
import type { Series } from "./series.ts";
2929

3030
// ─── public types ──────────────────────────────────────────────────────────────
3131

3232
/** Orient values supported by {@link toDictOriented}. */
33-
export type ToDictOrient = "dict" | "columns" | "list" | "series" | "split" | "tight" | "records" | "index";
33+
export type ToDictOrient =
34+
| "dict"
35+
| "columns"
36+
| "list"
37+
| "series"
38+
| "split"
39+
| "tight"
40+
| "records"
41+
| "index";
3442

3543
/** Orient values supported by {@link fromDictOriented}. */
3644
export type FromDictOrient = "columns" | "index" | "split" | "tight";
@@ -78,13 +86,19 @@ function isDefaultRange(labels: readonly Label[]): boolean {
7886
* @param df Source DataFrame.
7987
* @param orient Output structure. Defaults to `"dict"`.
8088
*/
81-
export function toDictOriented(df: DataFrame, orient: "dict" | "columns"): Record<string, Record<string, Scalar>>;
89+
export function toDictOriented(
90+
df: DataFrame,
91+
orient: "dict" | "columns",
92+
): Record<string, Record<string, Scalar>>;
8293
export function toDictOriented(df: DataFrame, orient: "list"): Record<string, Scalar[]>;
8394
export function toDictOriented(df: DataFrame, orient: "series"): Record<string, Series<Scalar>>;
8495
export function toDictOriented(df: DataFrame, orient: "split"): DictSplit;
8596
export function toDictOriented(df: DataFrame, orient: "tight"): DictTight;
8697
export function toDictOriented(df: DataFrame, orient: "records"): Record<string, Scalar>[];
87-
export function toDictOriented(df: DataFrame, orient: "index"): Record<string, Record<string, Scalar>>;
98+
export function toDictOriented(
99+
df: DataFrame,
100+
orient: "index",
101+
): Record<string, Record<string, Scalar>>;
88102
export function toDictOriented(
89103
df: DataFrame,
90104
orient: ToDictOrient = "dict",
@@ -201,10 +215,7 @@ export function fromDictOriented(
201215
orient: "index",
202216
): DataFrame;
203217
export function fromDictOriented(data: SplitInput, orient: "split" | "tight"): DataFrame;
204-
export function fromDictOriented(
205-
data: unknown,
206-
orient: FromDictOrient = "columns",
207-
): DataFrame {
218+
export function fromDictOriented(data: unknown, orient: FromDictOrient = "columns"): DataFrame {
208219
switch (orient) {
209220
case "columns": {
210221
const colsData = data as Record<string, readonly Scalar[]>;

src/index.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,22 @@ export type { ClipOptions, RoundOptions, DataFrameElemOptions } from "./stats/in
115115
export { valueCounts, dataFrameValueCounts } from "./stats/index.ts";
116116
export type { ValueCountsOptions, DataFrameValueCountsOptions } from "./stats/index.ts";
117117

118-
export { insertColumn, popColumn, reorderColumns, moveColumn, dataFrameFromPairs } from "./core/index.ts";
118+
export {
119+
insertColumn,
120+
popColumn,
121+
reorderColumns,
122+
moveColumn,
123+
dataFrameFromPairs,
124+
} from "./core/index.ts";
119125
export type { PopResult } from "./core/index.ts";
120126
export { toDictOriented, fromDictOriented } from "./core/index.ts";
121-
export type { ToDictOrient, FromDictOrient, DictSplit, DictTight, SplitInput } from "./core/index.ts";
127+
export type {
128+
ToDictOrient,
129+
FromDictOrient,
130+
DictSplit,
131+
DictTight,
132+
SplitInput,
133+
} from "./core/index.ts";
122134
export { wideToLong } from "./reshape/index.ts";
123135
export type { WideToLongOptions } from "./reshape/index.ts";
124136
export { cut, qcut } from "./stats/index.ts";
@@ -132,7 +144,16 @@ export type {
132144
SeriesWhereOptions,
133145
DataFrameWhereOptions,
134146
} from "./stats/index.ts";
135-
export { isna, notna, isnull, notnull, fillna, dropna, countna, countValid } from "./stats/index.ts";
147+
export {
148+
isna,
149+
notna,
150+
isnull,
151+
notnull,
152+
fillna,
153+
dropna,
154+
countna,
155+
countValid,
156+
} from "./stats/index.ts";
136157
export type { IsnaInput, FillnaOptions, DropnaOptions } from "./stats/index.ts";
137158
export {
138159
getAttrs,

src/reshape/wide_to_long.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838
* @module
3939
*/
4040

41-
import type { Label, Scalar } from "../types.ts";
42-
import { Index } from "../core/base-index.ts";
41+
import type { Index } from "../core/base-index.ts";
4342
import { DataFrame } from "../core/frame.ts";
4443
import { RangeIndex } from "../core/range-index.ts";
44+
import type { Label, Scalar } from "../types.ts";
4545

4646
// ─── public types ──────────────────────────────────────────────────────────────
4747

@@ -100,7 +100,7 @@ function collectSuffixes(
100100
// Sort numerically when both look like integers, otherwise lexicographically.
101101
const na = Number(a);
102102
const nb = Number(b);
103-
if (!Number.isNaN(na) && !Number.isNaN(nb)) {
103+
if (!(Number.isNaN(na) || Number.isNaN(nb))) {
104104
return na - nb;
105105
}
106106
return a < b ? -1 : a > b ? 1 : 0;
@@ -193,7 +193,8 @@ export function wideToLong(
193193
const arr = stubArrays[stub];
194194
if (arr !== undefined) {
195195
const wideCol = df.get(wideColName);
196-
const val: Scalar = wideCol !== undefined ? ((wideCol.values[row] ?? null) as Scalar) : null;
196+
const val: Scalar =
197+
wideCol !== undefined ? ((wideCol.values[row] ?? null) as Scalar) : null;
197198
arr.push(val);
198199
}
199200
}

0 commit comments

Comments
 (0)