Files
huachuang/nl-ui/nl-ui-admin-vben/yudao-ui-admin-vben/internal/lint-configs/oxfmt-config/src/index.ts
2026-07-08 15:08:41 +08:00

136 lines
3.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { defineConfig as defineOxfmtConfig } from 'oxfmt';
type OxfmtConfig = Parameters<typeof defineOxfmtConfig>[0];
/**
* oxfmt 配置文件,详见下方链接
* https://oxc.rs/docs/guide/usage/formatter/config-file-reference.html
*/
const oxfmtConfig: OxfmtConfig = defineOxfmtConfig({
/**
* 单行长度 oxfmt适配 prettier 的 80
* Default100
*/
printWidth: 80,
/**
* 缩进宽度
* Default2
*/
tabWidth: 2,
/**
* Markdown、MDX、YAML 文件格式化包裹
* type: always | never | preserve
* Default: preserve
*/
proseWrap: 'never',
/**
* 结尾添加分号
* Defaulttrue
*/
semi: true,
/**
* 使用单引号
* Defaultfalse
*/
singleQuote: true,
/**
* 对象属性添加引号
* Defaultas-needed
*/
quoteProps: 'as-needed',
/**
* 将多行元素的 > 放在最后一行的末尾,而不是单独放在下一行
* Defaultfalse
*/
bracketSameLine: false,
/**
* 对象字面量的大括号间添加空格
* Defaulttrue
*/
bracketSpacing: true,
/**
* 箭头函数参数总是使用括号
* type: always | avoid
* Defaultalways
*/
arrowParens: 'always',
/**
* 配置 package.json 排序,但是 oxfmt 不支持 pnpm-workspace
* 现使用 eslint 搭配 eslint-plugin-pnpm eslint-plugin-yml 支持 package.json 和 pnpm-workspace.yaml 但排序风格不太一致
* Defaulttrue
*/
sortPackageJson: false,
/**
* 配置 import 排序,现在 使用 eslint-plugin-perfectionist但是 oxfmt 不支持 export 等
* 并且 customGroups 不支持 ts-equals-import
* Defaultfalse
*/
sortImports: false,
/**
* 多行结构中的后置逗号
* Defaultall
*/
trailingComma: 'all',
/**
* 行尾换行符
* type: lf | crlf | cr
* Default: lf
*/
endOfLine: 'lf',
/**
* 在文件最后插入一个换行
* Defaulttrue
*/
insertFinalNewline: true,
/**
* 控制格式化文件中例如CSS-in-JS 或 JS-in-Vue 等
* Defaultauto
*/
embeddedLanguageFormatting: 'auto',
/**
* Vue/HTML/Angular/Handlebars 的空白敏感度oxfmt 现会格式化 <template>
* type: css | strict | ignore
* Defaultcss
*/
htmlWhitespaceSensitivity: 'css',
/**
* 暂时关闭,改动较多,后续可以考虑开启,支持 vue 但与现有的 eslint-plugin-better-tailwindcss 格式化会冲突
* eslint-plugin-better-tailwindcss配置在 oxlint在 vue文 件暂时不生效ts等正常
* Default关闭
*/
// sortTailwindcss: {
// functions: ['clsx', 'cn', 'cva', 'tw'],
// stylesheet: './internal/tailwind-config/src/theme.css',
// preserveWhitespace: true,
// },
overrides: [
{
files: [
'*.json',
'*.json5',
'*.jsonc',
'*.code-workspace',
'**/*.json',
'**/*.json5',
'**/*.jsonc',
'**/*.code-workspace',
],
options: {
trailingComma: 'none',
quoteProps: 'preserve',
singleQuote: false,
},
},
],
});
function defineConfig(config: OxfmtConfig = {}): OxfmtConfig {
return defineOxfmtConfig({
...oxfmtConfig,
...config,
});
}
export { defineConfig, oxfmtConfig };
export type { OxfmtConfig };