Shared oxlint config layers, the UXF oxlint rules and a reference oxfmt config for UXF frontend projects.
Preview, not yet a replacement for @uxf/eslint-config. This is step 1 of
docs/proposals/oxc-toolchain-migration.md in the fe-monorepo. The layers carry:
@uxf/eslint-config names explicitly and oxlint implements natively, with the same options and
severities (a rule that is WARNING there, i.e. off in CI, is warn here),correctness rules of every plugin a layer enables,uxf plugin (below), which ports the no-restricted-syntax selectors verbatim,compat/compat and n/no-deprecated-api from eslint-plugin-compat and eslint-plugin-n through jsPlugins,
with the settings of @uxf/eslint-config (below).Not here yet, each a later step of the proposal: the presets @uxf/eslint-config spreads (js and
typescript-eslint recommended, react recommended, jsx-a11y strict), eslint-plugin-tailwindcss and
react/destructuring-assignment through jsPlugins, boolean naming, restricted paths, the type-aware rules
(oxlint-tsgolint). Until then a project that switches loses those checks.
yarn add -D @uxf/oxc-config @uxf/browserslist-config oxlint
oxlint and @uxf/browserslist-config are peer dependencies (yarn dependencies:fix installs them in a project with
@uxf/scripts). eslint-plugin-compat and eslint-plugin-n are dependencies of this package; they declare eslint
as a peer, so npm installs ESLint along and Yarn 1 warns about it, but oxlint does not need it to run them.
A project inherits exactly one layer. extends takes a path relative to the config file, not a package name:
// .oxlintrc.json
{
"extends": ["./node_modules/@uxf/oxc-config/oxlintrc/next.json"],
"rules": {
"no-console": "off",
},
}Rules set in the project config override the inherited ones, including the uxf/* rules.
These are oxlint's rules for extends, verified with oxlint 1.93:
plugins, jsPlugins, rules and overrides are inherited and merge, so a layer only lists what it adds. A
layer cannot remove what it inherits, which is why react and email share react-core instead of email being
"react minus jsx-a11y".env, globals and settings are not inherited. oxlint reads them only from the config file it loads, i.e. the
project's. base therefore sets its globals in an overrides entry for all files, which is inherited: browser,
Node.js and Jest globals in every layer, as in @uxf/eslint-config. A project's own env adds to them and cannot
remove them. Without env.node, Buffer would not be a known global and n/no-deprecated-api would miss
new Buffer(). settings cannot go into overrides, so compat/compat gets its settings from the plugin itself
(below).oxlint --print-config does not list inherited jsPlugins, although they run.oxlint looks for a .oxlintrc.json in every directory and merges a parent config into the child ones. In a project
with web/, backoffice/ and e2e/, either give each directory its own config and put none in the root, or run
oxlint with --disable-nested-config.
uxf pluginplugins/uxf.mjs, loaded by base through jsPlugins. The rules are the three no-restricted-syntax entries of
@uxf/eslint-config, with the same selectors and messages, split into separate rules so that a project can turn one
off by name.
All three are warn. The plugin uses the ESLint rule API, so it loads into ESLint too.
react (and so next) runs compat/compat as an error: a web API (URLPattern, requestIdleCallback, ClipboardItem
…) or an ES built-in on a global (Intl.Segmenter) that a supported browser lacks. plugins/compat.mjs loads
eslint-plugin-compat under its own name, so the rule and its disable comments stay compat/compat, and gives it the
settings of @uxf/eslint-config:
A key in the project's settings replaces the default, so a project that sets its own polyfills repeats
"CookieStore". A green lint is no proof of support: the plugin's API data is frozen at about the end of 2024
(Promise.try, URL.parse, Iterator.from pass), instance methods (arr.toSorted()) are not checked, and only an if
counts as a feature check (a ternary or ?. is still reported).
base runs n/no-deprecated-api as an error: url.parse, new Buffer(), fs.exists and other deprecated Node.js
APIs. Node.js is kept on the latest LTS, so the version-range rules of eslint-plugin-n are not enabled.
Both plugins run in oxlint's JS runtime: on the 2,000 files of the fe-monorepo each adds 1.1–1.3 s.
oxfmtrc.json is a reference, copied into the project root as .oxfmtrc.json, not extended: oxfmt has no
extends and ignores keys it does not know, so an extends key does nothing. It keeps the Prettier settings of UXF
projects and adds:
sortImports in the order @uxf/eslint-config's import/order uses (external, internal, parent, sibling, index,
one block without blank lines), which replaces npm run eslint:fix-imports,sortTailwindcss with the cn, cx and cxa helpers, like prettier-plugin-tailwindcss,sortPackageJson: false, because oxfmt sorts package.json keys by default.Keep it a JSON file: the code style importer of the JetBrains plugin "Oxc" reads only JSON. In a project whose Tailwind
config is not tailwind.config.js in the root, set sortTailwindcss.config.