oxlint-config
@rnx-kit/oxlint-config is a set of configurations that can be used as is, or
extended in your own oxlint config.
Install
yarn add @rnx-kit/oxlint-config --dev
or if you're using npm:
npm add --save-dev @rnx-kit/oxlint-config
Usage
Several configurations are exported by this package. For instance, to use the
recommended
configuration, you can re-export it in your config like so:
export { default } from "@rnx-kit/oxlint-config";
Alternatively, if you want to add customizations:
import recommended from "@rnx-kit/oxlint-config";
import { defineConfig } from "oxlint";
export default defineConfig({
extends: [recommended],
plugins: ["import"],
rules: {
"import/no-default-export": "error",
"no-unneeded-ternary": "error",
},
});
Recommended Configurations
@rnx-kit/oxlint-config/recommended(or@rnx-kit/oxlint-configfor short) enables:correctnessrules foreslint,import,node,oxc,react,typescript,unicorn- All the equivalent rules found in (where possible):
- It also includes and enables the following rules:
@react-native/platform-colors(as JS plugin)
@rnx-kit/oxlint-config/strictextends@rnx-kit/oxlint-config/recommendedwith rules that enables better tree shaking:@rnx-kit/no-const-enum(as JS plugin)@rnx-kit/no-export-all(as JS plugin)@rnx-kit/no-foreach-with-captured-variables(as JS plugin)import/no-default-exportno-unneeded-ternary
@rnx-kit/oxlint-config/types-onlyenables rules for types only modules
Additionally, we also export the following configurations to ease the migration from ESLint:
eslint:recommended@typescript-eslint/recommended@microsoft/sdl/common@microsoft/sdl/node@microsoft/sdl/react
Supported Rules
- ✓: Enabled with
@rnx-kit/oxlint-config/recommended - 🔧: Fixable with
--fix
| ✓ | 🔧 | Rule | Description |
|---|---|---|---|
| ✓ | @rnx-kit/no-const-enum | disallow const enum (why is it bad?) | |
| ✓ | 🔧 | @rnx-kit/no-export-all | disallow export * (why is it bad?) |
| ✓ | @rnx-kit/no-foreach-with-captured-variables | disallow forEach with outside variables; JavaScript is not efficient when it comes to using variables defined outside of its scope, and repeatedly calling that function can lead to performance issues. By using a for...of loop, you can avoid these performance pitfalls and also it is easier to debug. | |
@rnx-kit/type-definitions-only | disallow anything but type definitions; useful for types only files or packages |