Run oxfmt across repo, add format script and ignore config

Format all non-generated files with oxfmt via `vp fmt`. Add
.oxfmtignore to skip bindings/ and wasm-pack output. Add npm
format script and update DEVELOPMENT.md docs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Gregory Schier
2026-03-13 09:52:11 -07:00
parent a9cccb21b8
commit 5919fae739
664 changed files with 13631 additions and 13482 deletions

View File

@@ -1,62 +1,62 @@
import MimeType from 'whatwg-mimetype';
import type { EditorProps } from '../components/core/Editor/Editor';
import MimeType from "whatwg-mimetype";
import type { EditorProps } from "../components/core/Editor/Editor";
export function languageFromContentType(
contentType: string | null,
content: string | null = null,
): EditorProps['language'] {
const justContentType = contentType?.split(';')[0] ?? contentType ?? '';
if (justContentType.includes('json')) {
return 'json';
): EditorProps["language"] {
const justContentType = contentType?.split(";")[0] ?? contentType ?? "";
if (justContentType.includes("json")) {
return "json";
}
if (justContentType.includes('xml')) {
return 'xml';
if (justContentType.includes("xml")) {
return "xml";
}
if (justContentType.includes('html')) {
if (justContentType.includes("html")) {
const detected = languageFromContent(content);
if (detected === 'xml') {
if (detected === "xml") {
// If it's detected as XML, but is already HTML, don't change it
return 'html';
return "html";
}
return detected;
}
if (justContentType.includes('javascript')) {
if (justContentType.includes("javascript")) {
// Sometimes `application/javascript` returns JSON, so try detecting that
return languageFromContent(content, 'javascript');
return languageFromContent(content, "javascript");
}
if (justContentType.includes('markdown')) {
return 'markdown';
if (justContentType.includes("markdown")) {
return "markdown";
}
return languageFromContent(content, 'text');
return languageFromContent(content, "text");
}
export function languageFromContent(
content: string | null,
fallback?: EditorProps['language'],
): EditorProps['language'] {
if (content == null) return 'text';
fallback?: EditorProps["language"],
): EditorProps["language"] {
if (content == null) return "text";
const firstBytes = content.slice(0, 20).trim();
if (firstBytes.startsWith('{') || firstBytes.startsWith('[')) {
return 'json';
if (firstBytes.startsWith("{") || firstBytes.startsWith("[")) {
return "json";
}
if (
firstBytes.toLowerCase().startsWith('<!doctype') ||
firstBytes.toLowerCase().startsWith('<html')
firstBytes.toLowerCase().startsWith("<!doctype") ||
firstBytes.toLowerCase().startsWith("<html")
) {
return 'html';
return "html";
}
if (firstBytes.startsWith('<')) {
return 'xml';
if (firstBytes.startsWith("<")) {
return "xml";
}
return fallback;
}
export function isJSON(content: string | null | undefined): boolean {
if (typeof content !== 'string') return false;
if (typeof content !== "string") return false;
try {
JSON.parse(content);
@@ -73,20 +73,20 @@ export function isProbablyTextContentType(contentType: string | null): boolean {
const normalized = mimeType.toLowerCase();
// Check if it starts with "text/"
if (normalized.startsWith('text/')) {
if (normalized.startsWith("text/")) {
return true;
}
// Common text mimetypes and suffixes
return [
'application/json',
'application/xml',
'application/javascript',
'application/yaml',
'+json',
'+xml',
'+yaml',
'+text',
"application/json",
"application/xml",
"application/javascript",
"application/yaml",
"+json",
"+xml",
"+yaml",
"+text",
].some((textType) => normalized === textType || normalized.endsWith(textType));
}
@@ -94,6 +94,6 @@ export function getMimeTypeFromContentType(contentType: string): MimeType {
try {
return new MimeType(contentType);
} catch {
return new MimeType('text/plain');
return new MimeType("text/plain");
}
}