Skip to content

Commit 49869e7

Browse files
authored
Migrate repository to Oxfmt and Oxlint (#1272)
* migrate to oxfmt and oxlint * fix oxfmt codegen hook * run oxlint in CI
1 parent d663057 commit 49869e7

35 files changed

Lines changed: 286 additions & 178 deletions

File tree

‎.github/workflows/test.yaml‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,20 @@ jobs:
3333
run: bun install --frozen-lockfile
3434
- name: Format
3535
run: bun run format:check
36+
lint:
37+
runs-on: ubuntu-latest
38+
name: Lint
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v4
42+
- name: Setup bun
43+
uses: oven-sh/setup-bun@v2
44+
with:
45+
bun-version-file: 'package.json'
46+
- name: Install dependencies
47+
run: bun install --frozen-lockfile
48+
- name: Lint
49+
run: bun run lint
3650
typecheck:
3751
runs-on: ubuntu-latest
3852
name: Typecheck

‎.oxfmtrc.json‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"printWidth": 100,
4+
"singleQuote": true,
5+
"tabWidth": 4,
6+
"sortPackageJson": false,
7+
"ignorePatterns": [
8+
".DS_Store",
9+
"node_modules/",
10+
"dist/",
11+
"*.log",
12+
".cache",
13+
".idea/",
14+
"CHANGELOG.md",
15+
"docs",
16+
"*.MD",
17+
"*.md",
18+
"*.html",
19+
"**/*.raw.js",
20+
"integrations/runkit/src/webframe.ts",
21+
"packages/cli/src/generated-commands.ts"
22+
]
23+
}

‎.oxlintrc.json‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"plugins": ["typescript", "unicorn", "oxc"],
4+
"categories": {
5+
"correctness": "error"
6+
},
7+
"ignorePatterns": ["packages/cli/src/generated-commands.ts"],
8+
"rules": {
9+
"eslint/no-unused-vars": [
10+
"error",
11+
{
12+
"args": "none",
13+
"caughtErrors": "none"
14+
}
15+
]
16+
},
17+
"overrides": [
18+
{
19+
"files": ["**/*.raw.js"],
20+
"rules": {
21+
"eslint/no-constant-condition": "off",
22+
"eslint/no-unassigned-vars": "off",
23+
"eslint/no-unused-expressions": "off",
24+
"eslint/no-unused-vars": "off",
25+
"oxc/number-arg-out-of-range": "off",
26+
"unicorn/no-thenable": "off"
27+
}
28+
},
29+
{
30+
"files": [
31+
"integrations/marketo/webframe/src/webframe.ts",
32+
"integrations/runkit/webframe/src/webframe.ts"
33+
],
34+
"rules": {
35+
"eslint/no-unused-vars": "off"
36+
}
37+
},
38+
{
39+
"files": ["scripts/generate-commands.ts"],
40+
"rules": {
41+
"eslint/no-useless-escape": "off"
42+
}
43+
},
44+
{
45+
"files": ["packages/cli/postinstall.js"],
46+
"rules": {
47+
"eslint/no-unused-expressions": "off"
48+
}
49+
},
50+
{
51+
"files": ["integrations/bucket/src/schema.ts"],
52+
"rules": {
53+
"unicorn/no-useless-spread": "off"
54+
}
55+
}
56+
],
57+
"env": {
58+
"builtin": true
59+
}
60+
}

‎.prettierignore‎

Lines changed: 0 additions & 31 deletions
This file was deleted.

‎.prettierrc.json‎

Lines changed: 0 additions & 5 deletions
This file was deleted.

‎bun.lock‎

Lines changed: 90 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎integrations/amplitude/.eslintrc.json‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎integrations/amplitude/package.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"@gitbook/tsconfig": "workspace:*"
1212
},
1313
"scripts": {
14-
"lint": "eslint ./src/**/*.ts",
1514
"typecheck": "tsc --noEmit",
1615
"publish-integrations-staging": "gitbook publish .",
1716
"publish-integrations": "gitbook publish ."

‎integrations/cognito/src/index.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,10 @@ const configBlock = createComponent<
194194
* Get the published content (site or space) related urls.
195195
*/
196196
async function getPublishedContentUrls(context: CognitoRuntimeContext) {
197-
const organizationId = context.environment.installation?.target?.organization!;
197+
const organizationId = context.environment.installation?.target?.organization;
198+
if (!organizationId) {
199+
throw new Error('No organization ID found');
200+
}
198201
const siteInstallation = assertInstallation(context.environment);
199202
const publishedContentData = await context.api.orgs.getSiteById(
200203
organizationId,
@@ -298,7 +301,7 @@ const handleFetchEvent: FetchEventCallback<CognitoRuntimeContext> = async (reque
298301
: undefined;
299302
const jwtToken = await jwt.sign(
300303
{
301-
...(decodedCognitoToken.payload ?? {}),
304+
...decodedCognitoToken.payload,
302305
exp: Math.max(minimumExp, upstreamTokenExp ?? 0),
303306
},
304307
privateKey,

‎integrations/formspree/src/index.tsx‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,18 @@ const formspreeBlock = createComponent<
2828
return element;
2929
}
3030

31-
const success = await handleSubmit(
32-
(context.environment.spaceInstallation?.configuration as FormspreeConfiguration)
33-
.formspree_id,
34-
{
35-
email: element.state.email,
36-
name: element.state.name,
37-
message: element.state.message,
38-
},
39-
);
31+
const configuration = context.environment.spaceInstallation?.configuration as
32+
| FormspreeConfiguration
33+
| undefined;
34+
if (!configuration?.formspree_id) {
35+
return element;
36+
}
37+
38+
const success = await handleSubmit(configuration.formspree_id, {
39+
email: element.state.email,
40+
name: element.state.name,
41+
message: element.state.message,
42+
});
4043

4144
if (!success) {
4245
return element;

0 commit comments

Comments
 (0)