Skip to content

Commit 0ed03a5

Browse files
committed
lints
1 parent 1d3bc51 commit 0ed03a5

4 files changed

Lines changed: 64 additions & 62 deletions

File tree

crates/bindings-typescript/src/lib/schema.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,12 @@ export class ModuleContext {
188188
value: module.rowLevelSecurity,
189189
}
190190
);
191-
push(module.explicitNames && { tag: 'ExplicitNames', value: module.explicitNames });
191+
push(
192+
module.explicitNames && {
193+
tag: 'ExplicitNames',
194+
value: module.explicitNames,
195+
}
196+
);
192197
return { sections };
193198
}
194199

@@ -250,9 +255,9 @@ export class ModuleContext {
250255

251256
#registerCompoundTypeRecursively<
252257
T extends
253-
| SumBuilder<VariantsObj>
254-
| ProductBuilder<ElementsObj>
255-
| RowBuilder<RowObj>,
258+
| SumBuilder<VariantsObj>
259+
| ProductBuilder<ElementsObj>
260+
| RowBuilder<RowObj>,
256261
>(typeBuilder: T): RefBuilder<Infer<T>, InferSpacetimeTypeOfTypeBuilder<T>> {
257262
const ty = typeBuilder.algebraicType;
258263
// NB! You must ensure that all TypeBuilder passed into this function
@@ -275,13 +280,13 @@ export class ModuleContext {
275280
const newTy =
276281
typeBuilder instanceof RowBuilder || typeBuilder instanceof ProductBuilder
277282
? ({
278-
tag: 'Product',
279-
value: { elements: [] },
280-
} as AlgebraicTypeVariants.Product)
283+
tag: 'Product',
284+
value: { elements: [] },
285+
} as AlgebraicTypeVariants.Product)
281286
: ({
282-
tag: 'Sum',
283-
value: { variants: [] },
284-
} as AlgebraicTypeVariants.Sum);
287+
tag: 'Sum',
288+
value: { variants: [] },
289+
} as AlgebraicTypeVariants.Sum);
285290

286291
r = new RefBuilder(this.#moduleDef.typespace.types.length);
287292
this.#moduleDef.typespace.types.push(newTy);

crates/bindings-typescript/src/lib/table.ts

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,26 @@ type HasInvalidColumn<Row extends RowObj> =
4444
// this checks if Row exactly equals RowObj - if it does, we can't
4545
// do type-system-level checking, so just let it pass
4646
(<G>() => G extends Row ? 1 : 2) extends <G>() => G extends RowObj ? 1 : 2
47-
? false
48-
: {
49-
[K in keyof Row]: Row[K] extends ColumnBuilder<any, any, infer M>
50-
? ValidateColumnMetadata<M> extends InvalidColumnMetadata<any>
51-
? true
52-
: false
53-
: false;
54-
}[keyof Row] extends false
55-
? false
56-
: true;
47+
? false
48+
: {
49+
[K in keyof Row]: Row[K] extends ColumnBuilder<any, any, infer M>
50+
? ValidateColumnMetadata<M> extends InvalidColumnMetadata<any>
51+
? true
52+
: false
53+
: false;
54+
}[keyof Row] extends false
55+
? false
56+
: true;
5757

5858
/**
5959
* Extract the names of columns that have invalid metadata.
6060
*/
6161
type InvalidColumnNames<Row extends RowObj> = {
6262
[K in keyof Row]: Row[K] extends ColumnBuilder<any, any, infer M>
63-
? ValidateColumnMetadata<M> extends InvalidColumnMetadata<any>
64-
? K & string
65-
: never
66-
: never;
63+
? ValidateColumnMetadata<M> extends InvalidColumnMetadata<any>
64+
? K & string
65+
: never
66+
: never;
6767
}[keyof Row];
6868

6969
/**
@@ -90,8 +90,8 @@ export type CoerceColumn<
9090
Col extends TypeBuilder<any, any> | ColumnBuilder<any, any, any>,
9191
> =
9292
Col extends TypeBuilder<infer T, infer U>
93-
? ColumnBuilder<T, U, ColumnMetadata<any>>
94-
: Col;
93+
? ColumnBuilder<T, U, ColumnMetadata<any>>
94+
: Col;
9595

9696
/**
9797
* Coerces a RowObj where TypeBuilders are replaced with ColumnBuilders
@@ -128,10 +128,10 @@ export type TableIndexes<TableDef extends UntypedTableDef> = {
128128
K,
129129
TableDef['columns'][K]['columnMetadata']
130130
> extends never
131-
? never
132-
: K]: ColumnIndex<K, TableDef['columns'][K]['columnMetadata']>;
131+
? never
132+
: K]: ColumnIndex<K, TableDef['columns'][K]['columnMetadata']>;
133133
} & {
134-
[I in TableDef['indexes'][number]as I['accessor'] & {}]: TableIndexFromDef<
134+
[I in TableDef['indexes'][number] as I['accessor'] & {}]: TableIndexFromDef<
135135
TableDef,
136136
I
137137
>;
@@ -144,21 +144,21 @@ type TableIndexFromDef<
144144
NormalizeIndexColumns<TableDef, I> extends infer Cols extends ReadonlyArray<
145145
keyof TableDef['columns'] & string
146146
>
147-
? {
148-
name: I['accessor'];
149-
unique: AllUnique<TableDef, Cols>;
150-
algorithm: Lowercase<I['algorithm']>;
151-
columns: Cols;
152-
}
153-
: never;
147+
? {
148+
name: I['accessor'];
149+
unique: AllUnique<TableDef, Cols>;
150+
algorithm: Lowercase<I['algorithm']>;
151+
columns: Cols;
152+
}
153+
: never;
154154

155155
type NormalizeIndexColumns<
156156
TableDef extends UntypedTableDef,
157157
I extends IndexOpts<keyof TableDef['columns'] & string>,
158158
> =
159159
IndexColumns<I> extends ReadonlyArray<keyof TableDef['columns'] & string>
160-
? IndexColumns<I>
161-
: never;
160+
? IndexColumns<I>
161+
: never;
162162

163163
/**
164164
* Options for configuring a database table.
@@ -176,10 +176,10 @@ export type TableOpts<Row extends RowObj> = {
176176
scheduled?: () =>
177177
| ReducerExport<any, { [k: string]: RowBuilder<RowObj> }>
178178
| ProcedureExport<
179-
any,
180-
{ [k: string]: RowBuilder<RowObj> },
181-
ReturnType<typeof t.unit>
182-
>;
179+
any,
180+
{ [k: string]: RowBuilder<RowObj> },
181+
ReturnType<typeof t.unit>
182+
>;
183183
event?: boolean;
184184
};
185185

@@ -214,7 +214,7 @@ export type Table<TableDef extends UntypedTableDef> = Prettify<
214214

215215
export type ReadonlyTable<TableDef extends UntypedTableDef> = Prettify<
216216
ReadonlyTableMethods<TableDef> &
217-
ReadonlyIndexes<TableDef, TableIndexes<TableDef>>
217+
ReadonlyIndexes<TableDef, TableIndexes<TableDef>>
218218
>;
219219

220220
export interface ReadonlyTableMethods<TableDef extends UntypedTableDef> {
@@ -292,10 +292,10 @@ export function table<Row extends RowObj, const Opts extends TableOpts<Row>>(
292292
// See the JSDoc above for details on how to fix this error.
293293
..._: HasInvalidColumn<Row> extends true
294294
? [
295-
error: ERROR_default_cannot_be_combined_with_primaryKey_unique_or_autoInc<
296-
InvalidColumnNames<Row>
297-
>,
298-
]
295+
error: ERROR_default_cannot_be_combined_with_primaryKey_unique_or_autoInc<
296+
InvalidColumnNames<Row>
297+
>,
298+
]
299299
: []
300300
): TableSchema<CoerceRow<Row>, OptsIndices<Opts>> {
301301
const {

crates/schema/tests/ensure_same_schema.rs

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ fn ensure_same_schema_rust_csharp_benchmarks() {
100100

101101
#[test]
102102
#[serial]
103-
fn test_all_schema_names() {
103+
fn test_case_converted_names() {
104104
let module_def: ModuleDef = get_normalized_schema("module-test");
105105

106106
// println!("Types {:?}", module_def.types().collect::<Vec<_>>());
@@ -110,9 +110,10 @@ fn test_all_schema_names() {
110110
// Test Tables
111111
let table_names = [
112112
// Accessor is CamelCase in modules.
113-
"test_a_table",
113+
"test_a_table",
114114
// Uses explicit canonical name
115-
"Person"];
115+
"Person",
116+
];
116117
for name in table_names {
117118
assert!(
118119
TableDef::lookup(&module_def, &Identifier::for_test(name)).is_some(),
@@ -122,8 +123,7 @@ fn test_all_schema_names() {
122123
}
123124

124125
// Test Reducers
125-
let reducer_names = [
126-
];
126+
let reducer_names = [];
127127
for name in reducer_names {
128128
assert!(
129129
ReducerDef::lookup(&module_def, &ReducerName::for_test(name)).is_some(),
@@ -204,9 +204,7 @@ fn test_all_schema_names() {
204204
// }
205205

206206
// Test Constraints
207-
let constraint_names = [
208-
"Person_id_key",
209-
];
207+
let constraint_names = ["Person_id_key"];
210208
for constraint_name in constraint_names {
211209
assert!(
212210
ConstraintDef::lookup(&module_def, &RawIdentifier::new(constraint_name)).is_some(),
@@ -216,9 +214,7 @@ fn test_all_schema_names() {
216214
}
217215

218216
// Test Sequences
219-
let sequence_names = [
220-
"Person_id_seq",
221-
];
217+
let sequence_names = ["Person_id_seq"];
222218
for sequence_name in sequence_names {
223219
assert!(
224220
SequenceDef::lookup(&module_def, &RawIdentifier::new(sequence_name)).is_some(),
@@ -236,9 +232,7 @@ fn test_all_schema_names() {
236232
);
237233

238234
// Test Columns (using composite key: table_name, column_name)
239-
let column_names = [
240-
("Person", "id"),
241-
];
235+
let column_names = [("Person", "id")];
242236
for (table_name, col_name) in column_names {
243237
assert!(
244238
ColumnDef::lookup(
@@ -269,5 +263,4 @@ fn test_all_schema_names() {
269263
// view_name,
270264
// col_name
271265
// );
272-
273266
}

modules/module-test/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ license-file = "LICENSE"
99
test-add-column = []
1010
test-remove-table = []
1111

12+
13+
[lints.rust]
14+
non_snake_case = "allow"
15+
1216
[lib]
1317
crate-type = ["cdylib"]
1418
# Benching off, because of https://bheisler.github.io/criterion.rs/book/faq.html#cargo-bench-gives-unrecognized-option-errors-for-valid-command-line-options

0 commit comments

Comments
 (0)