@lobehub/oxlint-config
v3.0.1
Published
Oxlint configuration for LobeHub projects
Maintainers
Keywords
Readme
Oxlint configuration for LobeHub projects
Features
- The
@lobehub/eslint-configrule set, converted to Oxlint and kept in sync by a generator - No
typescriptoreslintinstall: the JS plugins it needs are bundled with stubs for both - Native Oxlint rules for JavaScript, TypeScript, React, Next.js, import, unicorn and jsx-a11y
- Bundled JS plugins: ESLint's
no-restricted-importsandno-restricted-syntax(eslint-core),@eslint-react,perfectionist,simple-import-sort,react-native,react/jsx-sort-props,@stylexjs - Optional type-aware rules through
oxlint-tsgolint - About 4x faster than ESLint on a 12,000-file codebase (6.7s vs 30s)
Installation
pnpm add -D @lobehub/oxlint-config oxlintUsage
Create oxlint.config.ts in your project root. Oxlint loads TypeScript config files on Node.js 22.18 or later.
import { defineConfig } from '@lobehub/oxlint-config';
export default defineConfig({
react: 'next',
next: true,
});Then run:
npx oxlint
npx oxlint --fixOverrides
Every argument after the options is an Oxlint override, appended after the built-in ones:
import { defineConfig } from '@lobehub/oxlint-config';
export default defineConfig(
{ react: true },
{
files: ['**/*.test.ts'],
rules: { 'no-console': 'off' },
},
);Overrides that use your own JS plugins list them in jsPlugins. To use a bundled plugin in an override, name it by its key ('eslint-core', 'eslint-react', 'perfectionist', 'react-js', 'react-native', 'simple-import-sort', 'stylex'); never point at the plugin's npm package, which registers it a second time.
ESLint core rules
Oxlint has no no-restricted-syntax, and its native no-restricted-imports also reports import(). The bundled eslint-core plugin runs ESLint's own versions of both:
export default defineConfig(
{},
{
files: ['src/**/*.{ts,tsx}'],
jsPlugins: ['eslint-core'],
rules: {
'eslint-core/no-restricted-imports': [
'error',
{ paths: [{ name: 'heavy-lib', message: 'Load it with import().' }] },
],
'eslint-core/no-restricted-syntax': [
'error',
{ selector: 'WithStatement', message: 'No with.' },
],
},
},
);Oxlint loads each plugin file once, so a plugin cannot be registered twice under different names. For a second, independently configured copy of a rule, re-export it from a local plugin:
// lint/guard.mjs
import core from '@lobehub/oxlint-config/plugins/eslint-core';
export default {
meta: { name: 'guard' },
rules: { 'no-legacy': core.rules['no-restricted-imports'] },
};Options Reference
| Option | Type | Default | Description |
| --------------- | -------------------------------------------------- | ------- | ------------------------------------------------------------------- |
| typescript | boolean \| 'strict' | true | TypeScript rules; 'strict' uses the strict rule set |
| typeChecked | boolean | false | Type-aware rules; install oxlint-tsgolint |
| react | boolean \| 'next' \| 'remix' \| 'vite' \| 'expo' | false | React rules; a framework value adjusts only-export-components |
| reactCompiler | boolean | false | Raise the React Compiler rules from warn to error |
| reactNative | boolean | false | React Native rules |
| next | boolean | false | Next.js rules |
| a11y | boolean | false | jsx-a11y rules; requires react |
| sortImports | boolean | true | Sort imports and exports with simple-import-sort |
| sortKeys | boolean | true | Sort interface members, enum members and JSX props |
| stylex | boolean | false | StyleX rules for stylex.create styles (@stylexjs/eslint-plugin) |
| ignores | string[] | [] | Extra ignore globs; a pattern without a slash matches at the root |
Differences from @lobehub/eslint-config
- Not ported: the
regexp,ymlandmdxoptions,parserOptionsandtsconfigPath. - Comment rules: only
no-unlimited-disableandno-duplicate-disableare kept. Oxlint'sreportUnusedDisableDirectiveswarns about unused disable comments. - Unused imports: reported by Oxlint's
no-unused-vars. There is no separate autofix rule. - React Compiler rules: Oxlint's own implementations. They also check components wrapped in
memo(), whicheslint-plugin-react-hooksskips, so expect more warnings. - Adjusted for Oxlint behavior:
no-useless-assignmentis off until oxc-project/oxc#28603 is fixed;unicorn/no-immediate-mutationiswarn, because Oxlint also flagsnew Map(source)followed by.set();no-unsafe-optional-chainingis off in test files.
- Type-aware
@eslint-reactrules (no-implicit-*,no-leaked-conditional-rendering,no-unused-props) are off. They need the TypeScript API.
Requirements
- Node.js >= 20.19 (
oxlint.config.tsneeds Node.js >= 22.18) - Oxlint >= 1.90.0 < 2
oxlint-tsgolintwhentypeCheckedis on
License
MIT © LobeHub
