diff --git a/.oxfmtrc.json b/.oxfmtrc.json new file mode 100644 index 0000000000..949480d45e --- /dev/null +++ b/.oxfmtrc.json @@ -0,0 +1,6 @@ +{ + "printWidth": 80, + "trailingComma": "es5", + "sortPackageJson": false, + "ignorePatterns": [] +} diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index b02580b96e..0000000000 --- a/.prettierrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "printWidth": 80, - "trailingComma": "es5" -} diff --git a/app/editor/menus/code.tsx b/app/editor/menus/code.tsx index bd5a145cbc..c1106720f3 100644 --- a/app/editor/menus/code.tsx +++ b/app/editor/menus/code.tsx @@ -21,9 +21,7 @@ import { metaDisplay } from "@shared/utils/keyboard"; * @param ctx - the current selection context. * @returns an array of menu items. */ -export default function codeMenuItems( - ctx: SelectionContext -): MenuItem[] { +export default function codeMenuItems(ctx: SelectionContext): MenuItem[] { const { state, readOnly } = ctx; const node = state.selection instanceof NodeSelection diff --git a/app/editor/menus/image.tsx b/app/editor/menus/image.tsx index 3f567828cd..b48b0d39b7 100644 --- a/app/editor/menus/image.tsx +++ b/app/editor/menus/image.tsx @@ -24,9 +24,7 @@ import { t } from "i18next"; * @param ctx - the current selection context. * @returns an array of menu items. */ -export default function imageMenuItems( - ctx: SelectionContext -): MenuItem[] { +export default function imageMenuItems(ctx: SelectionContext): MenuItem[] { if (ctx.readOnly) { return []; } diff --git a/app/editor/menus/notice.tsx b/app/editor/menus/notice.tsx index d665de2eac..635e7e1644 100644 --- a/app/editor/menus/notice.tsx +++ b/app/editor/menus/notice.tsx @@ -15,9 +15,7 @@ import type { MenuItem, SelectionContext } from "@shared/editor/types"; * @param ctx - the current selection context. * @returns an array of menu items. */ -export default function noticeMenuItems( - ctx: SelectionContext -): MenuItem[] { +export default function noticeMenuItems(ctx: SelectionContext): MenuItem[] { const node = ctx.selection.$from.node(-1); const currentStyle = node?.attrs.style as NoticeTypes; diff --git a/lint-staged.config.mjs b/lint-staged.config.mjs index a414ff6ef4..b6b0f7912d 100644 --- a/lint-staged.config.mjs +++ b/lint-staged.config.mjs @@ -5,10 +5,10 @@ const oxlint = (files) => `bash -c 'out=$(oxlint ${files.join(" ")} --fix --type-aware 2>&1); rc=$?; printf "%s\\n" "$out"; if [ $rc -ne 0 ] && ! printf "%s" "$out" | grep -q "No files found to lint"; then exit $rc; fi'`; export default { - // Run prettier first for formatting, then oxlint for linting, and translation updates on changes to JS and + // Run oxfmt first for formatting, then oxlint for linting, and translation updates on changes to JS and // TypeScript files "**/*.[tj]s?(x)": [ - (f) => `prettier --write ${f.join(" ")}`, + (f) => `oxfmt ${f.join(" ")}`, (f) => (f.length > 20 ? `yarn lint --fix` : oxlint(f)), () => `yarn build:i18n`, () => "git add shared/i18n/locales/en_US/translation.json", diff --git a/package.json b/package.json index 208c65898a..05265d025d 100644 --- a/package.json +++ b/package.json @@ -15,8 +15,8 @@ "dev:watch": "NODE_ENV=development yarn concurrently -n backend,frontend \"yarn dev:backend\" \"yarn vite:dev\"", "lint": "oxlint --type-aware app server shared plugins", "lint:changed": "git diff --name-only --diff-filter=ACMRTUXB | grep -E '\\.(js|jsx|ts|tsx)$' | xargs -r oxlint", - "format": "prettier --write .", - "format:check": "prettier --check .", + "format": "oxfmt app server shared plugins", + "format:check": "oxfmt --check app server shared plugins", "prepare": "husky install", "postinstall": "yarn patch-package", "install-local-ssl": "node ./server/scripts/install-local-ssl.js", @@ -366,10 +366,10 @@ "lint-staged": "^16.4.0", "msw": "^2.14.2", "nodemon": "^3.1.14", + "oxfmt": "0.55.0", "oxlint": "1.70.0", "oxlint-tsgolint": "0.23.0", "postinstall-postinstall": "^2.1.0", - "prettier": "^3.8.3", "react-refresh": "^0.18.0", "rimraf": "^6.1.3", "rollup-plugin-webpack-stats": "2.1.11", diff --git a/shared/editor/lib/buildSelectionContext.ts b/shared/editor/lib/buildSelectionContext.ts index b9c49e8b75..ee2e9374e2 100644 --- a/shared/editor/lib/buildSelectionContext.ts +++ b/shared/editor/lib/buildSelectionContext.ts @@ -4,11 +4,7 @@ import { CellSelection } from "prosemirror-tables"; import { isInCode } from "../queries/isInCode"; import { isInList } from "../queries/isInList"; import { isInNotice } from "../queries/isInNotice"; -import { - getColumnIndex, - getRowIndex, - isTableSelected, -} from "../queries/table"; +import { getColumnIndex, getRowIndex, isTableSelected } from "../queries/table"; import { isMobile as isMobileDevice, isTouchDevice } from "../../utils/browser"; import type { SelectionContext } from "../types"; @@ -44,9 +40,7 @@ export function buildSelectionContext( isTableCell: selection instanceof CellSelection, isTableSelected: isTableSelected(state), selectedNodeType: - selection instanceof NodeSelection - ? selection.node.type.name - : undefined, + selection instanceof NodeSelection ? selection.node.type.name : undefined, colIndex: getColumnIndex(state), rowIndex: getRowIndex(state), }; diff --git a/shared/editor/rules/mark.ts b/shared/editor/rules/mark.ts index 964d3dc4aa..619a2b6bd1 100644 --- a/shared/editor/rules/mark.ts +++ b/shared/editor/rules/mark.ts @@ -61,10 +61,7 @@ export default function (options: { delim: string; mark: string }) { // Walk through delimiter list and replace text tokens with tags // - function postProcess( - state: StateInline, - delimiters: Delimiter[] - ) { + function postProcess(state: StateInline, delimiters: Delimiter[]) { let i = 0, j, startDelim, diff --git a/shared/utils/ProsemirrorHelper.ts b/shared/utils/ProsemirrorHelper.ts index 9ace5ee68c..133acd6622 100644 --- a/shared/utils/ProsemirrorHelper.ts +++ b/shared/utils/ProsemirrorHelper.ts @@ -313,9 +313,7 @@ export class ProsemirrorHelper { return []; } - return ( - node.attrs.marks as { type?: string; attrs?: { id?: string } }[] - ) + return (node.attrs.marks as { type?: string; attrs?: { id?: string } }[]) .filter( (mark): mark is { type: "comment"; attrs: { id: string } } => mark?.type === "comment" && !!mark?.attrs?.id diff --git a/yarn.lock b/yarn.lock index 31aaac607c..31e434c1a4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3930,6 +3930,139 @@ __metadata: languageName: node linkType: hard +"@oxfmt/binding-android-arm-eabi@npm:0.55.0": + version: 0.55.0 + resolution: "@oxfmt/binding-android-arm-eabi@npm:0.55.0" + conditions: os=android & cpu=arm + languageName: node + linkType: hard + +"@oxfmt/binding-android-arm64@npm:0.55.0": + version: 0.55.0 + resolution: "@oxfmt/binding-android-arm64@npm:0.55.0" + conditions: os=android & cpu=arm64 + languageName: node + linkType: hard + +"@oxfmt/binding-darwin-arm64@npm:0.55.0": + version: 0.55.0 + resolution: "@oxfmt/binding-darwin-arm64@npm:0.55.0" + conditions: os=darwin & cpu=arm64 + languageName: node + linkType: hard + +"@oxfmt/binding-darwin-x64@npm:0.55.0": + version: 0.55.0 + resolution: "@oxfmt/binding-darwin-x64@npm:0.55.0" + conditions: os=darwin & cpu=x64 + languageName: node + linkType: hard + +"@oxfmt/binding-freebsd-x64@npm:0.55.0": + version: 0.55.0 + resolution: "@oxfmt/binding-freebsd-x64@npm:0.55.0" + conditions: os=freebsd & cpu=x64 + languageName: node + linkType: hard + +"@oxfmt/binding-linux-arm-gnueabihf@npm:0.55.0": + version: 0.55.0 + resolution: "@oxfmt/binding-linux-arm-gnueabihf@npm:0.55.0" + conditions: os=linux & cpu=arm + languageName: node + linkType: hard + +"@oxfmt/binding-linux-arm-musleabihf@npm:0.55.0": + version: 0.55.0 + resolution: "@oxfmt/binding-linux-arm-musleabihf@npm:0.55.0" + conditions: os=linux & cpu=arm + languageName: node + linkType: hard + +"@oxfmt/binding-linux-arm64-gnu@npm:0.55.0": + version: 0.55.0 + resolution: "@oxfmt/binding-linux-arm64-gnu@npm:0.55.0" + conditions: os=linux & cpu=arm64 & libc=glibc + languageName: node + linkType: hard + +"@oxfmt/binding-linux-arm64-musl@npm:0.55.0": + version: 0.55.0 + resolution: "@oxfmt/binding-linux-arm64-musl@npm:0.55.0" + conditions: os=linux & cpu=arm64 & libc=musl + languageName: node + linkType: hard + +"@oxfmt/binding-linux-ppc64-gnu@npm:0.55.0": + version: 0.55.0 + resolution: "@oxfmt/binding-linux-ppc64-gnu@npm:0.55.0" + conditions: os=linux & cpu=ppc64 & libc=glibc + languageName: node + linkType: hard + +"@oxfmt/binding-linux-riscv64-gnu@npm:0.55.0": + version: 0.55.0 + resolution: "@oxfmt/binding-linux-riscv64-gnu@npm:0.55.0" + conditions: os=linux & cpu=riscv64 & libc=glibc + languageName: node + linkType: hard + +"@oxfmt/binding-linux-riscv64-musl@npm:0.55.0": + version: 0.55.0 + resolution: "@oxfmt/binding-linux-riscv64-musl@npm:0.55.0" + conditions: os=linux & cpu=riscv64 & libc=musl + languageName: node + linkType: hard + +"@oxfmt/binding-linux-s390x-gnu@npm:0.55.0": + version: 0.55.0 + resolution: "@oxfmt/binding-linux-s390x-gnu@npm:0.55.0" + conditions: os=linux & cpu=s390x & libc=glibc + languageName: node + linkType: hard + +"@oxfmt/binding-linux-x64-gnu@npm:0.55.0": + version: 0.55.0 + resolution: "@oxfmt/binding-linux-x64-gnu@npm:0.55.0" + conditions: os=linux & cpu=x64 & libc=glibc + languageName: node + linkType: hard + +"@oxfmt/binding-linux-x64-musl@npm:0.55.0": + version: 0.55.0 + resolution: "@oxfmt/binding-linux-x64-musl@npm:0.55.0" + conditions: os=linux & cpu=x64 & libc=musl + languageName: node + linkType: hard + +"@oxfmt/binding-openharmony-arm64@npm:0.55.0": + version: 0.55.0 + resolution: "@oxfmt/binding-openharmony-arm64@npm:0.55.0" + conditions: os=openharmony & cpu=arm64 + languageName: node + linkType: hard + +"@oxfmt/binding-win32-arm64-msvc@npm:0.55.0": + version: 0.55.0 + resolution: "@oxfmt/binding-win32-arm64-msvc@npm:0.55.0" + conditions: os=win32 & cpu=arm64 + languageName: node + linkType: hard + +"@oxfmt/binding-win32-ia32-msvc@npm:0.55.0": + version: 0.55.0 + resolution: "@oxfmt/binding-win32-ia32-msvc@npm:0.55.0" + conditions: os=win32 & cpu=ia32 + languageName: node + linkType: hard + +"@oxfmt/binding-win32-x64-msvc@npm:0.55.0": + version: 0.55.0 + resolution: "@oxfmt/binding-win32-x64-msvc@npm:0.55.0" + conditions: os=win32 & cpu=x64 + languageName: node + linkType: hard + "@oxlint-tsgolint/darwin-arm64@npm:0.23.0": version: 0.23.0 resolution: "@oxlint-tsgolint/darwin-arm64@npm:0.23.0" @@ -15234,6 +15367,7 @@ __metadata: nodemon: "npm:^3.1.14" octokit: "npm:^5.0.5" outline-icons: "npm:^4.3.0" + oxfmt: "npm:0.55.0" oxlint: "npm:1.70.0" oxlint-tsgolint: "npm:0.23.0" oy-vey: "npm:^0.12.1" @@ -15249,7 +15383,6 @@ __metadata: png-chunks-extract: "npm:^1.0.0" polished: "npm:^4.3.1" postinstall-postinstall: "npm:^2.1.0" - prettier: "npm:^3.8.3" prosemirror-changeset: "npm:2.4.1" prosemirror-codemark: "npm:^0.4.2" prosemirror-commands: "npm:^1.7.1" @@ -15432,6 +15565,83 @@ __metadata: languageName: node linkType: hard +"oxfmt@npm:0.55.0": + version: 0.55.0 + resolution: "oxfmt@npm:0.55.0" + dependencies: + "@oxfmt/binding-android-arm-eabi": "npm:0.55.0" + "@oxfmt/binding-android-arm64": "npm:0.55.0" + "@oxfmt/binding-darwin-arm64": "npm:0.55.0" + "@oxfmt/binding-darwin-x64": "npm:0.55.0" + "@oxfmt/binding-freebsd-x64": "npm:0.55.0" + "@oxfmt/binding-linux-arm-gnueabihf": "npm:0.55.0" + "@oxfmt/binding-linux-arm-musleabihf": "npm:0.55.0" + "@oxfmt/binding-linux-arm64-gnu": "npm:0.55.0" + "@oxfmt/binding-linux-arm64-musl": "npm:0.55.0" + "@oxfmt/binding-linux-ppc64-gnu": "npm:0.55.0" + "@oxfmt/binding-linux-riscv64-gnu": "npm:0.55.0" + "@oxfmt/binding-linux-riscv64-musl": "npm:0.55.0" + "@oxfmt/binding-linux-s390x-gnu": "npm:0.55.0" + "@oxfmt/binding-linux-x64-gnu": "npm:0.55.0" + "@oxfmt/binding-linux-x64-musl": "npm:0.55.0" + "@oxfmt/binding-openharmony-arm64": "npm:0.55.0" + "@oxfmt/binding-win32-arm64-msvc": "npm:0.55.0" + "@oxfmt/binding-win32-ia32-msvc": "npm:0.55.0" + "@oxfmt/binding-win32-x64-msvc": "npm:0.55.0" + tinypool: "npm:2.1.0" + peerDependencies: + svelte: ^5.0.0 + vite-plus: "*" + dependenciesMeta: + "@oxfmt/binding-android-arm-eabi": + optional: true + "@oxfmt/binding-android-arm64": + optional: true + "@oxfmt/binding-darwin-arm64": + optional: true + "@oxfmt/binding-darwin-x64": + optional: true + "@oxfmt/binding-freebsd-x64": + optional: true + "@oxfmt/binding-linux-arm-gnueabihf": + optional: true + "@oxfmt/binding-linux-arm-musleabihf": + optional: true + "@oxfmt/binding-linux-arm64-gnu": + optional: true + "@oxfmt/binding-linux-arm64-musl": + optional: true + "@oxfmt/binding-linux-ppc64-gnu": + optional: true + "@oxfmt/binding-linux-riscv64-gnu": + optional: true + "@oxfmt/binding-linux-riscv64-musl": + optional: true + "@oxfmt/binding-linux-s390x-gnu": + optional: true + "@oxfmt/binding-linux-x64-gnu": + optional: true + "@oxfmt/binding-linux-x64-musl": + optional: true + "@oxfmt/binding-openharmony-arm64": + optional: true + "@oxfmt/binding-win32-arm64-msvc": + optional: true + "@oxfmt/binding-win32-ia32-msvc": + optional: true + "@oxfmt/binding-win32-x64-msvc": + optional: true + peerDependenciesMeta: + svelte: + optional: true + vite-plus: + optional: true + bin: + oxfmt: bin/oxfmt + checksum: 10c0/8052adf41f426d34e08ba464efeb388d8864ee00c263719d7aa5d72c96e436e8a24cd83597904387a5764e87ea2bd57e7e7f26772d6347b7181bb3bf2ab8f5bb + languageName: node + linkType: hard + "oxlint-tsgolint@npm:0.23.0": version: 0.23.0 resolution: "oxlint-tsgolint@npm:0.23.0" @@ -16210,15 +16420,6 @@ __metadata: languageName: node linkType: hard -"prettier@npm:^3.8.3": - version: 3.8.3 - resolution: "prettier@npm:3.8.3" - bin: - prettier: bin/prettier.cjs - checksum: 10c0/754816fd7593eb80f6376d7476d463e832c38a12f32775a82683adb6e35b772b1f484d65f19401507b983a8c8a7cd5a4a9f12006bd56491e8f35503473f77473 - languageName: node - linkType: hard - "pretty-bytes@npm:^5.3.0": version: 5.6.0 resolution: "pretty-bytes@npm:5.6.0" @@ -19014,6 +19215,13 @@ __metadata: languageName: node linkType: hard +"tinypool@npm:2.1.0": + version: 2.1.0 + resolution: "tinypool@npm:2.1.0" + checksum: 10c0/9fb1c760558c6264e0f4cfde96a63b12450b43f1730fbe6274aa24ddbdf488745c08924d0dea7a1303b47d555416a6415f2113898c69b6ecf731e75ac95238a5 + languageName: node + linkType: hard + "tinyrainbow@npm:^3.1.0": version: 3.1.0 resolution: "tinyrainbow@npm:3.1.0"