Skip to content

Commit 6256ae0

Browse files
committed
feat: shareable oxlint config
1 parent deda60f commit 6256ae0

File tree

19 files changed

+643
-28
lines changed

19 files changed

+643
-28
lines changed

.changeset/beige-rats-lie.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@rnx-kit/oxlint-config": major
3+
---
4+
5+
Shareable oxlint configurations

.yarnrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,5 @@ catalog:
7575
eslint: ^9.0.0
7676
jest: ^29.2.1
7777
oxfmt: ^0.35.0
78+
oxlint: ^1.50.0
7879
typescript: ^5.0.0

packages/eslint-plugin/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"test": "rnx-kit-scripts test"
4444
},
4545
"dependencies": {
46-
"@react-native/eslint-plugin": "^0.76.0",
46+
"@react-native/eslint-plugin": "^0.84.0",
4747
"enhanced-resolve": "^5.8.3",
4848
"eslint-plugin-react": "^7.35.2",
4949
"eslint-plugin-react-hooks": "^5.2.0",
@@ -58,7 +58,8 @@
5858
"@types/estree": "*",
5959
"@types/node": "^24.0.0",
6060
"@typescript-eslint/parser": "^8.0.0",
61-
"@typescript-eslint/types": "^8.0.0"
61+
"@typescript-eslint/types": "^8.0.0",
62+
"eslint": "^9.0.0"
6263
},
6364
"peerDependencies": {
6465
"eslint": ">=8.57.0"

packages/oxlint-config/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!-- We recommend an empty change log entry for a new package: `yarn change --empty` -->
2+
3+
# @rnx-kit/oxlint-config
4+
5+
[![Build](https://github.com/microsoft/rnx-kit/actions/workflows/build.yml/badge.svg)](https://github.com/microsoft/rnx-kit/actions/workflows/build.yml)
6+
[![npm version](https://img.shields.io/npm/v/@rnx-kit/oxlint-config)](https://www.npmjs.com/package/@rnx-kit/oxlint-config)
7+
8+
9+
10+
This is a sample folder to use as base for generating new packages for
11+
`rnx-kit`.
12+
13+
## Motivation
14+
15+
We want new packages to follow an existing set of patterns and guidelines; via
16+
this package, we can enforce easily allow new folders to stick to at least a
17+
common starting point.
18+
19+
## Installation
20+
21+
```sh
22+
yarn add @rnx-kit/oxlint-config --dev
23+
```
24+
25+
or if you're using npm
26+
27+
```sh
28+
npm add --save-dev @rnx-kit/oxlint-config
29+
```
30+
31+
## Usage
32+
33+
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
"name": "@rnx-kit/oxlint-config",
3+
"version": "0.0.1",
4+
"description": "Shareable oxlint configs",
5+
"homepage": "https://github.com/microsoft/rnx-kit/tree/main/packages/oxlint-config#readme",
6+
"license": "MIT",
7+
"author": {
8+
"name": "Microsoft Open Source",
9+
"email": "microsoftopensource@users.noreply.github.com"
10+
},
11+
"repository": {
12+
"type": "git",
13+
"url": "https://github.com/microsoft/rnx-kit",
14+
"directory": "packages/oxlint-config"
15+
},
16+
"files": [
17+
"src"
18+
],
19+
"type": "module",
20+
"main": "recommended.ts",
21+
"exports": {
22+
".": {
23+
"default": "./src/configs/recommended.ts"
24+
},
25+
"./eslint-recommended": {
26+
"default": "./src/configs/eslint-recommended.ts"
27+
},
28+
"./private": {
29+
"default": "./private.ts"
30+
},
31+
"./recommended": {
32+
"default": "./src/configs/recommended.ts"
33+
},
34+
"./sdl-common": {
35+
"default": "./src/configs/sdl-common.ts"
36+
},
37+
"./sdl-node": {
38+
"default": "./src/configs/sdl-node.ts"
39+
},
40+
"./sdl-react": {
41+
"default": "./src/configs/sdl-react.ts"
42+
},
43+
"./strict": {
44+
"default": "./src/configs/strict.ts"
45+
},
46+
"./typescript-recommended": {
47+
"default": "./src/configs/typescript-recommended.ts"
48+
},
49+
"./typescript-stylistic": {
50+
"default": "./src/configs/typescript-stylistic.ts"
51+
},
52+
"./package.json": "./package.json"
53+
},
54+
"scripts": {
55+
"build": "rnx-kit-scripts build",
56+
"format": "rnx-kit-scripts format"
57+
},
58+
"dependencies": {
59+
"@microsoft/eslint-plugin-sdl": "^1.0.0",
60+
"@react-native/eslint-plugin": "^0.84.0",
61+
"@rnx-kit/eslint-plugin": "^0.9.6"
62+
},
63+
"devDependencies": {
64+
"@rnx-kit/scripts": "*",
65+
"@rnx-kit/tsconfig": "*",
66+
"eslint": "^9.0.0",
67+
"oxlint": "^1.50.0"
68+
},
69+
"peerDependencies": {
70+
"eslint": "^9.0.0",
71+
"oxlint": "^1.50.0"
72+
},
73+
"peerDependenciesMeta": {
74+
"eslint": {
75+
"optional": true
76+
}
77+
},
78+
"engines": {
79+
"node": ">=22.11"
80+
}
81+
}

packages/oxlint-config/private.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { defineConfig } from "oxlint";
2+
import sdlCommon from "./src/configs/sdl-common.ts";
3+
import sdlNode from "./src/configs/sdl-node.ts";
4+
import sdlReact from "./src/configs/sdl-react.ts";
5+
import strict from "./src/configs/strict.ts";
6+
import stylistic from "./src/configs/typescript-stylistic.ts";
7+
8+
export default defineConfig({
9+
extends: [sdlCommon, sdlNode, sdlReact, strict, stylistic],
10+
rules: {
11+
"@rnx-kit/no-foreach-with-captured-variables": "error",
12+
},
13+
overrides: [
14+
{
15+
files: ["**/types.ts"],
16+
rules: {
17+
"@rnx-kit/type-definitions-only": "error",
18+
},
19+
},
20+
],
21+
});
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { defineConfig } from "oxlint";
2+
3+
export default defineConfig({
4+
categories: {
5+
correctness: "error",
6+
},
7+
plugins: ["eslint", "unicorn"],
8+
rules: {
9+
"no-case-declarations": "error", // eslint/pedantic
10+
"no-empty": "error", // eslint/restriction
11+
"no-empty-file": "off", // unicorn/correctness
12+
"no-empty-function": "error", // eslint/restriction
13+
"no-fallthrough": "error", // eslint/pedantic
14+
"no-new-func": "error", // eslint/style
15+
"no-prototype-builtins": "error", // eslint/pedantic
16+
"no-redeclare": "error", // eslint/pedantic
17+
"no-regex-spaces": "error", // eslint/restriction
18+
"no-unexpected-multiline": "error", // eslint/suspicious
19+
"no-unused-vars": [
20+
"error",
21+
{
22+
args: "all",
23+
argsIgnorePattern: "^_",
24+
caughtErrors: "all",
25+
caughtErrorsIgnorePattern: "^_",
26+
destructuredArrayIgnorePattern: "^_",
27+
varsIgnorePattern: "^_",
28+
ignoreRestSiblings: true,
29+
},
30+
],
31+
"no-unneeded-ternary": "warn", // eslint/suspicious
32+
},
33+
});
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { defineConfig } from "oxlint";
2+
import eslint from "./eslint-recommended.ts";
3+
import typescript from "./typescript-recommended.ts";
4+
5+
export default defineConfig({
6+
extends: [eslint, typescript],
7+
// https://oxc.rs/docs/guide/usage/linter/config.html#enable-groups-of-rules-with-categories
8+
categories: {
9+
correctness: "error",
10+
},
11+
// https://oxc.rs/docs/guide/usage/linter/plugins.html#supported-plugins
12+
plugins: ["node", "oxc", "react"],
13+
// https://oxc.rs/docs/guide/usage/linter/config.html#configure-js-plugins-experimental
14+
jsPlugins: [
15+
{
16+
name: "@react-native",
17+
specifier: import.meta.resolve("@react-native/eslint-plugin"),
18+
},
19+
{
20+
name: "@rnx-kit",
21+
specifier: import.meta.resolve("@rnx-kit/eslint-plugin"),
22+
},
23+
],
24+
// https://oxc.rs/docs/guide/usage/linter/rules.html
25+
rules: {
26+
"@react-native/platform-colors": "error",
27+
"@rnx-kit/no-const-enum": "warn",
28+
"@rnx-kit/no-export-all": "warn",
29+
"@rnx-kit/no-foreach-with-captured-variables": "warn",
30+
"no-unused-expressions": "off", // Catches valid expressions like template literals
31+
"typescript/consistent-type-imports": [
32+
"error", // typescript/style
33+
{ disallowTypeAnnotations: false },
34+
],
35+
},
36+
});
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { defineConfig } from "oxlint";
2+
3+
// https://github.com/microsoft/eslint-plugin-sdl/blob/main/config/common.js
4+
export default defineConfig({
5+
jsPlugins: [
6+
{
7+
name: "@microsoft/sdl",
8+
specifier: import.meta.resolve("@microsoft/eslint-plugin-sdl"),
9+
},
10+
],
11+
rules: {
12+
"@microsoft/sdl/no-cookies": "error",
13+
"@microsoft/sdl/no-document-domain": "error",
14+
"@microsoft/sdl/no-document-write": "error",
15+
"@microsoft/sdl/no-html-method": "error",
16+
"@microsoft/sdl/no-inner-html": "error",
17+
"@microsoft/sdl/no-insecure-url": "error",
18+
"@microsoft/sdl/no-msapp-exec-unsafe": "error",
19+
"@microsoft/sdl/no-postmessage-star-origin": "error",
20+
"@microsoft/sdl/no-winjs-html-unsafe": "error",
21+
},
22+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { defineConfig } from "oxlint";
2+
3+
// https://github.com/microsoft/eslint-plugin-sdl/blob/main/config/node.js
4+
export default defineConfig({
5+
plugins: ["typescript"],
6+
jsPlugins: [
7+
{
8+
name: "@microsoft/sdl",
9+
specifier: import.meta.resolve("@microsoft/eslint-plugin-sdl"),
10+
},
11+
],
12+
rules: {
13+
"@microsoft/sdl/no-unsafe-alloc": "error",
14+
"typescript/no-deprecated": "error",
15+
},
16+
});

0 commit comments

Comments
 (0)