Skip to content

Commit cf46c8d

Browse files
committed
Configure oxfmt formatter and simplify git hooks
1 parent 66d69bc commit cf46c8d

File tree

147 files changed

+17852
-21804
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+17852
-21804
lines changed

.changeset/config.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
{
22
"$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json",
3-
"changelog": [
4-
"@changesets/changelog-github",
5-
{ "repo": "ydb-platform/ydb-js-sdk" }
6-
],
3+
"changelog": ["@changesets/changelog-github", { "repo": "ydb-platform/ydb-js-sdk" }],
74
"commit": false,
85
"fixed": [],
96
"linked": [],

.prettierrc.json renamed to .oxfmtrc.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
2-
"printWidth": 80,
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"printWidth": 100,
34
"tabWidth": 4,
45
"useTabs": true,
56
"semi": false,
@@ -9,9 +10,11 @@
910
"bracketSameLine": false,
1011
"arrowParens": "always",
1112
"endOfLine": "lf",
13+
"sortPackageJson": false,
14+
"ignorePatterns": [],
1215
"overrides": [
1316
{
14-
"files": "*.{md,yml,yaml}",
17+
"files": ["*.md", "*.yml", "*.yaml"],
1518
"options": {
1619
"tabWidth": 2,
1720
"useTabs": false

.oxlintrc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"unicorn/require-post-message-target-origin": "off",
1313
"yoda": "deny",
1414
"vitest/consistent-test-it": ["error", { "fn": "test" }],
15-
"vitest/max-nested-describe": ["error", 0],
15+
"vitest/max-nested-describe": ["error", { "max": 0 }],
1616
"vitest/valid-expect": [
1717
"error",
1818
{
@@ -21,7 +21,7 @@
2121
}
2222
]
2323
},
24-
"plugins": ["node", "import", "vitest", "promise", "typescript"],
24+
"plugins": ["node", "import", "vitest", "promise", "typescript", "oxc"],
2525
"ignorePatterns": ["**/node_modules/**", "**/dist/**"],
2626
"categories": {
2727
"correctness": "error",

.vscode/extensions.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
{
2-
"recommendations": [
3-
"oxc.oxc-vscode",
4-
"vitest.explorer",
5-
"prettier.prettier-vscode"
6-
]
2+
"recommendations": ["oxc.oxc-vscode", "vitest.explorer"]
73
}

docs/.vitepress/config.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { defineConfig } from 'vitepress'
22

33
const base = process.env.DOCS_BASE || '/'
4-
const sitemapHostname =
5-
process.env.SITE_HOSTNAME || 'https://ydb-platform.github.io/ydb-js-sdk'
4+
const sitemapHostname = process.env.SITE_HOSTNAME || 'https://ydb-platform.github.io/ydb-js-sdk'
65

76
// https://vitepress.dev/reference/site-config
87
export default defineConfig({

docs/advanced/retries.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ See implementation: `packages/retry/src/index.ts` and `packages/query/src/query.
2525
## Marking single calls as idempotent
2626

2727
```ts
28-
await sql`UPDATE counters SET v = v + 1 WHERE id = ${id}`
29-
.idempotent(true)
30-
.timeout(3000)
28+
await sql`UPDATE counters SET v = v + 1 WHERE id = ${id}`.idempotent(true).timeout(3000)
3129
```
3230

3331
Inside `sql.begin`/`sql.transaction`, the per-call idempotency flag is ignored; configure idempotency at the transaction level and make your business logic idempotent (e.g., via idempotency keys).

docs/guide/core.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ This guide helps you connect to YDB from JavaScript/TypeScript and run your firs
1616
```ts
1717
import { Driver } from '@ydbjs/core'
1818

19-
const driver = new Driver(
20-
process.env['YDB_CONNECTION_STRING'] || 'grpc://localhost:2136/local'
21-
)
19+
const driver = new Driver(process.env['YDB_CONNECTION_STRING'] || 'grpc://localhost:2136/local')
2220
await driver.ready()
2321

2422
// use the driver with Query/Topic or low-level clients
@@ -53,7 +51,10 @@ import { StaticCredentialsProvider } from '@ydbjs/auth/static'
5351
const authEndpoint = 'grpcs://ydb.example.com:2135' // AuthService endpoint
5452
const driver = new Driver('grpcs://ydb.example.com:2135/your-db', {
5553
credentialsProvider: new StaticCredentialsProvider(
56-
{ username: process.env.YDB_USER!, password: process.env.YDB_PASSWORD! },
54+
{
55+
username: process.env.YDB_USER!,
56+
password: process.env.YDB_PASSWORD!,
57+
},
5758
authEndpoint
5859
),
5960
})
@@ -223,10 +224,7 @@ Example:
223224
class MyCredentialsProvider extends CredentialsProvider {
224225
#token: string | null = null
225226

226-
async getToken(
227-
force = false,
228-
signal: AbortSignal = AbortSignal.timeout(10_000)
229-
) {
227+
async getToken(force = false, signal: AbortSignal = AbortSignal.timeout(10_000)) {
230228
if (!force && this.#token) return this.#token
231229
const abort = AbortSignal.any([signal, AbortSignal.timeout(15_000)])
232230
const res = await fetch(this.#endpoint, {

docs/guide/query/index.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,7 @@ await sql`PRAGMA TablePathPrefix(${sql.unsafe('/Root/dev')});`
102102
```ts
103103
import { StatsMode } from '@ydbjs/api/query'
104104

105-
const q = sql`SELECT * FROM heavy_table`
106-
.idempotent(true)
107-
.withStats(StatsMode.FULL)
105+
const q = sql`SELECT * FROM heavy_table`.idempotent(true).withStats(StatsMode.FULL)
108106

109107
q.on('retry', (ctx) => console.log('retry attempt', ctx.attempt, ctx.error))
110108
q.on('stats', (s) => console.log('cpu(us)=', s.queryPhaseStats?.cpuTimeUs))

docs/guide/query/value.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,8 @@ const userType = new Struct({
7777

7878
// List<Struct<...>> with values
7979
const users = new List(
80-
new Struct(
81-
{ id: 1, name: new Optional(null, new TextType()) },
82-
userType.type
83-
),
84-
new Struct(
85-
{ id: 2, name: new Optional('Bob', new TextType()) },
86-
userType.type
87-
)
80+
new Struct({ id: 1, name: new Optional(null, new TextType()) }, userType.type),
81+
new Struct({ id: 2, name: new Optional('Bob', new TextType()) }, userType.type)
8882
)
8983

9084
await sql`INSERT INTO users SELECT * FROM AS_TABLE(${users})`

docs/guide/topic/index.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,7 @@ await writer.flush()
112112

113113
```ts
114114
await using reader = t.createReader({
115-
topic: [
116-
{ path: '/Root/topic-a', partitionIds: [0n, 1n] },
117-
{ path: '/Root/topic-b' },
118-
],
115+
topic: [{ path: '/Root/topic-a', partitionIds: [0n, 1n] }, { path: '/Root/topic-b' }],
119116
consumer: 'svc-a',
120117
})
121118

@@ -135,12 +132,7 @@ await using reader = t.createReader({
135132
return { readOffset: committed }
136133
},
137134
onPartitionSessionStop: async (session, committed) => {
138-
console.log(
139-
'partition closed',
140-
session.partitionSessionId,
141-
'committed',
142-
committed
143-
)
135+
console.log('partition closed', session.partitionSessionId, 'committed', committed)
144136
},
145137
onCommittedOffset: (session, committed) => {
146138
// observe commits (useful with fire-and-forget commit())

0 commit comments

Comments
 (0)