@switz/lint-config
v14.0.0
Published
Shared oxlint and oxfmt configs
Readme
switz's lint-config
Shared oxlint and oxfmt configs.
Installation
pnpm install -D oxlint oxfmt @switz/lint-configFor Tailwind support, also install the native oxlint plugin:
pnpm install -D oxlint-tailwindcssLinting
Create an oxlint.config.ts in your project root. oxlint picks it up automatically, and it imports the configs straight from the package, so nothing is copied or hardcoded to a node_modules path:
import { defineConfig } from 'oxlint';
import base from '@switz/lint-config/oxlint' with { type: 'json' };
export default defineConfig({
...base,
});Spread base rather than putting it in extends: oxlint doesn't inherit ignorePatterns (or env and settings) from extended configs, so the base ignore list would be lost.
For React, extend the react config:
import { defineConfig } from 'oxlint';
import base from '@switz/lint-config/oxlint' with { type: 'json' };
import react from '@switz/lint-config/oxlint/react' with { type: 'json' };
export default defineConfig({
...base,
extends: [react],
});For Tailwind, also extend the tailwind config and point it at your Tailwind CSS entry file (required; settings are not inherited from extended configs):
import { defineConfig } from 'oxlint';
import base from '@switz/lint-config/oxlint' with { type: 'json' };
import react from '@switz/lint-config/oxlint/react' with { type: 'json' };
import tailwind from '@switz/lint-config/oxlint/tailwind' with { type: 'json' };
export default defineConfig({
...base,
extends: [react, tailwind],
settings: {
tailwindcss: {
entryPoint: 'src/styles/globals.css',
},
},
});Then run:
oxlintoxlint's JSON extends only accepts file paths, not package names, so reference the files in node_modules directly. This breaks if your package manager hoists the package somewhere else (e.g. a monorepo root), and the base ignorePatterns are not inherited.
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"extends": [
"./node_modules/@switz/lint-config/oxlint.json",
"./node_modules/@switz/lint-config/oxlint.react.json"
],
"ignorePatterns": ["node_modules", "dist", "build", ".next"]
}Formatting
Create an oxfmt.config.ts in your project root. oxfmt picks it up automatically:
import config from '@switz/lint-config/oxfmt' with { type: 'json' };
export default config;To override an option, spread it: export default { ...config, printWidth: 80 };
Alternatively, skip the config file and pass the path directly: oxfmt -c node_modules/@switz/lint-config/.oxfmtrc.json. Symlinking .oxfmtrc.json does not work, because oxfmt ignores symlinked config files.
Add scripts to your package.json:
{
"scripts": {
"lint": "oxlint",
"fmt": "oxfmt",
"fmt:check": "oxfmt --check"
}
}The TypeScript configs above need oxlint >= 1.45 and oxfmt >= 0.38; older versions either fail to load them or silently ignore them and use defaults. They also require a Node version that can run .ts natively (22.18+). If your tsconfig.json type-checks these files, enable resolveJsonModule.
Tailwind
The Tailwind config uses oxlint-tailwindcss, a native oxlint plugin. It requires Tailwind CSS v4. Set settings.tailwindcss.entryPoint in your own config as shown above.
Migrating from @switz/eslint-config
This package replaces @switz/eslint-config, which is no longer maintained. Remove eslint, prettier and @switz/eslint-config, then follow the setup above. Known gaps vs. the old ESLint configs:
- React: oxlint covers ~20 of 80+
eslint-plugin-reactrules. Core rules likejsx-key,no-direct-mutation-state, hooks rules, andjsx-no-duplicate-propsare covered. Rules likeno-unstable-nested-components,no-array-index-key,jsx-handler-namesare not. - MDX: oxfmt formats
.mdxfiles, but does not lint embedded code blocks likeeslint-plugin-mdxdid. - TypeScript type-aware rules: oxlint's type-aware checking is in alpha (~73% coverage of
typescript-eslintrecommended rules).
License
MIT, have fun
