Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
node_modules
.vscode
dist
dist.new
*.tsbuildinfo
Expand Down
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm lint-staged
112 changes: 112 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
"plugins": ["import"],
"jsPlugins": [
"./eslint/eslint-plugin-drizzle-internal/index.js"
],
"rules": {
"typescript/consistent-type-imports": [
"error",
{
"disallowTypeAnnotations": true,
"fixStyle": "separate-type-imports"
}
],
"typescript/no-import-type-side-effects": "error",
"import/no-cycle": "error",
"import/no-self-import": "error",
"import/no-empty-named-blocks": "error",
"import/no-duplicates": "error",
"import/extensions": [
"error",
"always",
{
"ignorePackages": true
}
],
"typescript/no-explicit-any": "off",
"typescript/no-non-null-assertion": "off",
"typescript/no-namespace": "off",
"no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}
],
"ban-types": [
"error",
{
"extendDefaults": true,
"types": {
"{}": false
}
}
],
"typescript/no-this-alias": "off",
"typescript/no-var-requires": "off",
"unicorn/prefer-node-protocol": "off",
"unicorn/prefer-top-level-await": "off",
"unicorn/catch-error-name": "off",
"unicorn/no-null": "off",
"unicorn/numeric-separators-style": "off",
"unicorn/explicit-length-check": "off",
"unicorn/filename-case": "off",
"unicorn/no-array-reduce": "off",
"unicorn/no-nested-ternary": "off",
"unicorn/no-useless-undefined": [
"error",
{
"checkArguments": false
}
],
"unicorn/no-this-assignment": "off",
"unicorn/empty-brace-spaces": "off",
"unicorn/no-thenable": "off",
"unicorn/consistent-function-scoping": "off",
"unicorn/prefer-type-error": "off",
"eqeqeq": "error",
"unicorn/no-instanceof-builtins": "error",
"unicorn/prefer-string-replace-all": "off",
"unicorn/no-process-exit": "off",
"typescript/ban-ts-comment": "off",
"typescript/no-empty-interface": "off",
"typescript/no-unsafe-declaration-merging": "off",
"no-inner-declarations": "off",
"drizzle-internal/no-instanceof": "error",
"drizzle-internal/require-entity-kind": "error"
},
"overrides": [
{
"files": ["**/tests/**/*.ts", "**/type-tests/**/*.ts", "**/typeperf-test/**/*.ts"],
"rules": {
"import/extensions": "off",
"drizzle-internal/no-instanceof": "off"
}
},
{
"files": ["**/type-tests/**/*.ts", "**/integration-tests/tests/**/*.ts"],
"rules": {
"no-unused-expressions": "off"
}
},
{
"files": ["eslint-plugin-drizzle/**/*"],
"rules": {
"import/extensions": "off"
}
}
],
"ignorePatterns": [
"node_modules",
"dist",
"dist-dts",
"examples",
"**/*.js",
"**/*.mjs",
"**/*.cjs",
"**/playground",
"integration-tests/tests/prisma/*/client",
"integration-tests/tests/prisma/*/drizzle",
"drizzle-kit/*"
]
}
17 changes: 17 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"typescript.tsdk": "node_modules/typescript/lib",
"editor.defaultFormatter": "dprint.dprint",
"[javascript]": {
"editor.defaultFormatter": "dprint.dprint"
},
"[typescript]": {
"editor.defaultFormatter": "dprint.dprint"
},
"[json]": {
"editor.defaultFormatter": "dprint.dprint"
},
"[markdown]": {
"editor.defaultFormatter": "dprint.dprint"
},
"dprint.path": "node_modules/.bin/dprint"
}
4 changes: 1 addition & 3 deletions attw-fork/src/createPackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,7 @@ export async function resolveTypesPackageForPackage(
],
options,
);
} catch {
null;
}
} catch {}

return undefined;
}
Expand Down
4 changes: 1 addition & 3 deletions attw-fork/src/internal/esm/cjsNamespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ export function getCjsModuleNamespace(fs: Package, file: URL, seen = new Set<str
const reexported = getCjsModuleNamespace(fs, url, seen);
for (const name of reexported) exports.add(name);
}
} catch {
null;
}
} catch {}
}

return exports;
Expand Down
4 changes: 1 addition & 3 deletions attw-fork/src/internal/getEntrypointInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ function getProxyDirectories(rootDir: string, fs: Package) {
const proxyDir = '.' + file.slice(rootDir.length, file.lastIndexOf('/'));
proxyDirectories.push(proxyDir);
}
} catch {
null;
}
} catch {}
}
}

Expand Down
54 changes: 27 additions & 27 deletions clean.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import { existsSync, lstatSync, readdirSync, rmSync } from 'node:fs';
import { join } from 'node:path';
// import { existsSync, lstatSync, readdirSync, rmSync } from 'node:fs';
// import { join } from 'node:path';

const printTree = (path: string, indentation: number) => {
for (const it of readdirSync(path)) {
if (it === 'node_modules') continue;
if (it === '.git') continue;
if (it === '.github') continue;
if (it === '.turbo') continue;
if (it === 'dist') continue;
// const printTree = (path: string, indentation: number) => {
// for (const it of readdirSync(path)) {
// if (it === 'node_modules') continue;
// if (it === '.git') continue;
// if (it === '.github') continue;
// if (it === '.turbo') continue;
// if (it === 'dist') continue;

const full = join(path, it);
const stat = existsSync(full) ? lstatSync(full) : undefined;
if (!stat) continue;
// const full = join(path, it);
// const stat = existsSync(full) ? lstatSync(full) : undefined;
// if (!stat) continue;

if (stat.isDirectory()) {
printTree(full, indentation + 1);
} else {
if (
full.endsWith('.js')
&& existsSync(full.replace('.js', '.js.map'))
&& existsSync(full.replace('.js', '.ts'))
) {
console.log(full);
rmSync(full);
rmSync(full.replace('.js', '.js.map'));
}
}
}
};
// if (stat.isDirectory()) {
// printTree(full, indentation + 1);
// } else {
// if (
// full.endsWith('.js')
// && existsSync(full.replace('.js', '.js.map'))
// && existsSync(full.replace('.js', '.ts'))
// ) {
// console.log(full);
// rmSync(full);
// rmSync(full.replace('.js', '.js.map'));
// }
// }
// }
// };

// I've accidentally ran tsc which generated .d.ts files for all ts files in repo
// printTree(".");
2 changes: 1 addition & 1 deletion drizzle-arktype/src/column.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { CONSTANTS } from './constants.ts';

export const literalSchema = type.string.or(type.number).or(type.boolean).or(type.null);
export const jsonSchema = literalSchema.or(type.unknown.as<any>().array()).or(type.object.as<Record<string, any>>());
export const bufferSchema = type.unknown.narrow((value) => value instanceof Buffer).as<Buffer>().describe( // eslint-disable-line no-instanceof/no-instanceof
export const bufferSchema = type.unknown.narrow((value) => value instanceof Buffer).as<Buffer>().describe( // oxlint-disable-line drizzle-internal/no-instanceof
'a Buffer instance',
);

Expand Down
2 changes: 1 addition & 1 deletion drizzle-arktype/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import tsconfigPaths from 'vite-tsconfig-paths';
import { defineConfig } from 'vitest/config';
import { defineConfig } from 'vitest/config.js';

export default defineConfig({
test: {
Expand Down
5 changes: 0 additions & 5 deletions drizzle-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@
"@types/semver": "^7.5.5",
"@types/uuid": "^9.0.8",
"@types/ws": "^8.5.10",
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"@vercel/postgres": "^0.8.0",
"ava": "^5.1.0",
"better-sqlite3": "^11.9.1",
Expand All @@ -89,9 +87,6 @@
"drizzle-orm": "workspace:./drizzle-orm/dist",
"env-paths": "^3.0.0",
"esbuild-node-externals": "^1.9.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"gel": "^2.0.0",
"get-port": "^6.1.2",
"glob": "^8.1.0",
Expand Down
2 changes: 1 addition & 1 deletion drizzle-kit/src/dialects/mssql/introspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ ORDER BY lower(name)
reference_table_id: number;
reference_column_id: number;
};

const fkCostraintQuery = await db.query<ForeignKeyRow>(`
SELECT
fk.name as name,
Expand Down
4 changes: 2 additions & 2 deletions drizzle-kit/tests/mssql/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export const diffIntrospect = async (
const filePath = `tests/mssql/tmp/${testName}.ts`;

writeFileSync(filePath, file.file);
await tsc(file.file)
await tsc(file.file);

const typeCheckResult = await $`pnpm exec tsc --noEmit --skipLibCheck ${filePath}`.nothrow();
if (typeCheckResult.exitCode !== 0) {
Expand Down Expand Up @@ -279,7 +279,7 @@ export const diffDefault = async <T extends MsSqlColumnBuilder>(

if (existsSync(path)) rmSync(path);
writeFileSync(path, file.file);
await tsc(file.file)
await tsc(file.file);

const response = await prepareFromSchemaFiles([path]);
const { schema: sch, errors: e2 } = fromDrizzleSchema(response, 'camelCase');
Expand Down
2 changes: 1 addition & 1 deletion drizzle-kit/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default defineConfig({
},
testTimeout: 100000,
hookTimeout: 100000,
maxConcurrency:1,
maxConcurrency: 1,
fileParallelism: false,
},
plugins: [tsconfigPaths()],
Expand Down
10 changes: 5 additions & 5 deletions drizzle-orm/src/_relations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,20 +474,20 @@ export function extractTablesRelationalConfig<
const relations: Record<string, Relation> = value.config(
configHelpers(value.table),
);
let primaryKey: AnyColumn[] | undefined;
// let primaryKey: AnyColumn[] | undefined;

for (const [relationName, relation] of Object.entries(relations)) {
if (tableName) {
const tableConfig = tablesConfig[tableName]!;
tableConfig.relations[relationName] = relation;
if (primaryKey) {
tableConfig.primaryKey.push(...primaryKey);
}
// if (primaryKey) {
// tableConfig.primaryKey.push(...primaryKey);
// }
} else {
if (!(dbName in relationsBuffer)) {
relationsBuffer[dbName] = {
relations: {},
primaryKey,
// primaryKey,
};
}
relationsBuffer[dbName]!.relations[relationName] = relation;
Expand Down
2 changes: 1 addition & 1 deletion drizzle-orm/src/aws-data-api/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function toValueParam(value: any, typings?: QueryTypingsValue): { value:
response.value = { doubleValue: value };
} else if (typeof value === 'boolean') {
response.value = { booleanValue: value };
} else if (value instanceof Date) { // eslint-disable-line no-instanceof/no-instanceof
} else if (value instanceof Date) { // oxlint-disable-line drizzle-internal/no-instanceof
// TODO: check if this clause is needed? Seems like date value always comes as string
response.value = { stringValue: value.toISOString().replace('T', ' ').replace('Z', '') };
} else {
Expand Down
2 changes: 1 addition & 1 deletion drizzle-orm/src/aws-data-api/pg/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export function drizzle<
): AwsDataApiPgDatabase<TSchema, TRelations> & {
$client: TClient;
} {
// eslint-disable-next-line no-instanceof/no-instanceof
// oxlint-disable-next-line drizzle-internal/no-instanceof
if (params[0] instanceof RDSDataClient || params[0].constructor.name !== 'Object') {
return construct(params[0] as TClient, params[1] as DrizzleAwsDataApiPgConfig<TSchema, TRelations>) as any;
}
Expand Down
2 changes: 1 addition & 1 deletion drizzle-orm/src/cockroach-core/columns/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export class CockroachArrayBuilder<
length: number | undefined;
}
> {
static override readonly [entityKind] = 'CockroachArrayBuilder';
static override readonly [entityKind]: string = 'CockroachArrayBuilder';

constructor(
name: string,
Expand Down
2 changes: 1 addition & 1 deletion drizzle-orm/src/cockroach-core/query-builders/count.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class CockroachCountBuilder<
private sql: SQL<number>;
private token?: NeonAuthToken;

static override readonly [entityKind] = 'CockroachCountBuilder';
static override readonly [entityKind]: string = 'CockroachCountBuilder';
[Symbol.toStringTag] = 'CockroachCountBuilder';

private session: TSession;
Expand Down
2 changes: 1 addition & 1 deletion drizzle-orm/src/cockroach-core/query-builders/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import {
getTableLikeName,
haveSameKeys,
type NeonAuthToken,
orderSelectedFields,
type ValueOrArray,
} from '~/utils.ts';
import { orderSelectedFields } from '~/utils.ts';
import { ViewBaseConfig } from '~/view-common.ts';
import type {
AnyCockroachSelect,
Expand Down
4 changes: 2 additions & 2 deletions drizzle-orm/src/cockroach/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export class NodeCockroachSession<
transaction: (tx: NodeCockroachTransaction<TFullSchema, TSchema>) => Promise<T>,
config?: CockroachTransactionConfig | undefined,
): Promise<T> {
const session = this.client instanceof Pool // eslint-disable-line no-instanceof/no-instanceof
const session = this.client instanceof Pool // oxlint-disable-line drizzle-internal/no-instanceof
? new NodeCockroachSession(await this.client.connect(), this.dialect, this.schema, this.options)
: this;
const tx = new NodeCockroachTransaction<TFullSchema, TSchema>(this.dialect, session, this.schema);
Expand All @@ -241,7 +241,7 @@ export class NodeCockroachSession<
await tx.execute(sql`rollback`);
throw error;
} finally {
if (this.client instanceof Pool) { // eslint-disable-line no-instanceof/no-instanceof
if (this.client instanceof Pool) { // oxlint-disable-line drizzle-internal/no-instanceof
(session.client as PoolClient).release();
}
}
Expand Down
Loading
Loading