Conversation
|
Great suggestion. @publicJorn what do you think? I like that this is an all-in-one solution, like Biome, but it seems to support scss as well. This alone is a great reason to ditch our current lint/format chain IMO. I think the oxc ecosystem has a better attitude towards non-standard-but-widespread-usage stuff as well as the push for vanilla & native. I see there are some experimental settings enabled, some pre 1.0.0 releases being used, and some installed package versions aren't pinned. I'm not comfortable with merging any of those things into our production template, so before accepting we need to weigh these options. Would removing those settings be a reason not to go forward with this? Or worded differently: what do these experimental/prerelease features bring to the table? Also, it seems you accidentally included changes from your other PR? |
- Replace Biome with Oxlint (type-aware) for linting - Replace Prettier with Oxfmt for formatting (including SCSS) - Update lefthook pre-commit hooks - Update VSCode settings for Oxc extension - Remove Base UI dependencies and revert to original form components - Update README with Oxc setup instructions
2b4cf97 to
fcc223a
Compare
- Removed glob pattern from the Oxlint job in lefthook.yml to streamline pre-commit hook execution.
vercel/next.js#85451 also the |
I'm not convinced that others taking a risk is a good reason for us to follow, there's a reason it's a draft PR 😉. Looking at their website, the entire formatter is still in alpha. They do claim that "Oxfmt currently passes approximately 95% of Prettier's JavaScript and TypeScript test suite.", which sounds reasonably acceptable to me since this PR proves our codebase fits within that percentage. Although I'd like Jorn's input as well.
Hmm, I've read the docs and there is no mention of that being necessary... https://oxc.rs/docs/guide/usage/formatter/editors.html#vs-code |
apparently the oxlint only works with json :D
|
I've now played around with oxfmt and oxlint and it is quite good. Works great out-of-the-box and runs wihtout problem on this template and several of my personal projects. The following is not pertinent to whether we want to use this in our template, but I thought it was worth a mention. Only problem is that custom plugins do not yet support in-editor diagnostincs. Not a big deal, but it does mean that the plugin I just wrote (😉) to require readonly types will only error when checked through the CLI. View readonly-plugin.tsimport { defineRule, type Plugin, type Visitor } from "oxlint";
const isMutableType = (node: Parameters<NonNullable<Visitor[string]>>[0]) => {
switch (node.type) {
case "TSTypeLiteral": {
if (
node.parent.type === "TSTypeReference" &&
node.parent.typeName.type === "Identifier" &&
node.parent.typeName.name.startsWith("Readonly")
) {
return false;
}
return node.members.some(
(member) => member.type === "TSPropertySignature" && member.readonly !== true,
);
}
case "TSTypeOperator": {
if (node.operator === "readonly") {
return false;
}
return isMutableType(node.typeAnnotation);
}
case "TSArrayType": {
return true;
}
case "TSUnionType":
case "TSIntersectionType": {
if (
node.parent.type === "TSTypeReference" &&
node.parent.typeName.type === "Identifier" &&
node.parent.typeName.name.startsWith("Readonly")
) {
return false;
}
return node.types.some(isMutableType);
}
default: {
return false;
}
}
};
const rule = defineRule({
createOnce(context) {
return {
TSTypeAliasDeclaration(node) {
const typeNode = node.typeAnnotation;
if (isMutableType(typeNode)) {
context.report({
node,
message: `Type alias "${node.id.name}" must be readonly`,
});
}
},
};
},
});
const plugin: Plugin = {
meta: {
name: "readonly-plugin",
},
rules: {
readonly: rule,
},
};
export default plugin;This one will do the following: // BAD!
type ButtonProps = {
type: Whatever;
};
// GOOD!
type ButtonProps = {
readonly type: Whatever;
};
// GOOD!
type ButtonProps = Readonly<{
type: Whatever;
}>;
// BAD!
type CoolArray = number[];
// GOOD!
type ButtonProps = readonly number[];
// GOOD!
type ButtonProps = ReadonlyArray<number>;While absolutely not an issue for applying this in our workflow, I'd like to propose we do run this rule to prevent mutating code at the typescript level. |
This will be supported in the tsgolint type-aware linting. tsgolint its one of the last 14 rules that are to be implemented! That is if this rule complies with your idea of the readonly params. This is the rule typescript-eslint edit: |
Hmm, not exactly... but it seems like that would solve the same issues, just in a different way. I'd like to propose we use that plugin for our projects (when it's implemented), but let's see what everyone thinks. |
The lsp support for custom plugins is coming in Q1 oxc-project/oxc#14826, there is currently a draft pr open to implement the LSP |
|
Don't have time to really dive into this now. I like the idea of unifying the linting/formatting system. But updating just because its hip and new I don't find necessary. Most important points:
If those 3 boxes tick, and you guys are enthousiastic: go ahead. |
Cli for both tools will fix matched files by default (they can be changed to only check with the
Not sure what is reasonable maturity in your opinion. Oxlint is past v1.0.0 and is used by some big parties, such as shopify, and funnily enough also hey-api.
|
|
I re-read all comments. In my opinion we should freeze this PR until the oxfmt is on version 1. Again: we don't really have a problem with our current biome setup afaik. The combo with prettier is fast enough and it works great in the editor. That said, if oxfmt is released I do see benefit in unifying the linting stack. |
🔧 Migrate from Biome to Oxlint + Oxfmt
Summary
This PR replaces Biome (lint + format) and Prettier with Oxlint (type-aware linting) and Oxfmt (formatting), streamlining our tooling to the Oxc ecosystem.
Why Oxlint + Oxfmt?
What Changed
Removed:
@biomejs/biomeprettierprettier-plugin-css-orderbiome.json.prettierrcAdded:
oxlint– Type-aware lintingoxfmt– Formatting (JS, TS, JSON, SCSS, HTML, Markdown, etc.).oxlintrc.jsonc– Linter configuration with categories and rules.oxfmtrc.jsonc– Formatter configuration (ported from Prettier).vscode/settings.json– Editor integration for Oxc extensionsLefthook Pre-commit
Updated to run:
oxlint --type-awareon all staged filesoxfmt --checkon all staged filesConfiguration Parity
The new setup mirrors our previous Biome rules:
eslint/no-console: erroreslint/no-unused-vars: warncorrectness,suspiciousnode_modules,*.d.ts,*.gen.tsIt does introduce a sane print width of 100 (default for oxfmt)
Related