Commit 32de690
feat: add options parameter with
Nursery rules specified in `.oxlintrc.json` were not being output by
`buildFromOxlintConfigFile`, preventing ESLint from disabling them.
Nursery rules are unstable and excluded by default by design, but users
need opt-in access when explicitly configuring them.
## Changes
**Type & API**
- Added `BuildFromOxlintConfigOptions` type with optional `withNursery:
boolean` flag
- Updated `buildFromOxlintConfig()` and `buildFromOxlintConfigFile()` to
accept optional `options` parameter (defaults to `{ withNursery: false
}`)
**Rule Filtering**
- Modified `scripts/constants.ts`: removed 'nursery' from
`ignoreCategories` to generate nursery rules
- Updated `RulesGenerator` and `ConfigGenerator`: filter nursery rules
when grouping by scope (but include when grouping by category)
- Updated `handleCategoriesScope()` and `handleRulesScope()` to filter
nursery rules unless `withNursery: true`
- Modified `src/configs.ts`: explicitly exclude nursery rules from `all`
and `flat/all` configs
**Generated Files**
- `rules-by-category.ts` and `configs-by-category.ts`: Include nursery
rules (in `nurseryRules` and `flat/nursery` config)
- `rules-by-scope.ts` and `configs-by-scope.ts`: Exclude nursery rules
(no nursery in scope-based groupings like `flat/eslint`, `flat/react`,
etc.)
**Testing**
- Added 6 tests verifying nursery rules behavior with/without
`withNursery` option
- Added 3 tests confirming nursery rules absent from `all`, `flat/all`,
and scope-based configs
## Usage
```typescript
// Default: nursery rules excluded (backward compatible)
buildFromOxlintConfig({
rules: { 'import/named': 'error' }
});
// => import/named NOT in output
// Opt-in: nursery rules included
buildFromOxlintConfig({
rules: { 'import/named': 'error' }
}, { withNursery: true });
// => { 'import/named': 'off' }
```
Fully backward compatible—existing behavior unchanged.
Fixes #412
<!-- START COPILOT CODING AGENT SUFFIX -->
<details>
<summary>Original prompt</summary>
>
> ----
>
> *This section details on the original issue you should resolve*
>
> <issue_title>Nursery rules are not output by
buildFromOxlintConfigFile</issue_title>
> <issue_description><details>
> <summary>.oxlintrc.json</summary>
>
> ```
> {
> "$schema": "./node_modules/oxlint/configuration_schema.json",
> "plugins": [],
> "rules": {
> "import/no-cycle": "error",
> "import/named": "error"
> }
> }
>
> ```
> </details>
>
>
> <details>
> <summary>Output from eslint-plugin-oxlint</summary>
>
> ```
> // output from oxlint.buildFromOxlintConfigFile('./.oxlintrc.json')
>
> [
> {
> name: 'oxlint/from-oxlint-config',
> rules: {
> 'for-direction': 'off',
> 'no-async-promise-executor': 'off',
> 'no-caller': 'off',
> 'no-class-assign': 'off',
> 'no-useless-backreference': 'off',
> 'no-compare-neg-zero': 'off',
> 'no-cond-assign': 'off',
> 'no-const-assign': 'off',
> 'no-constant-binary-expression': 'off',
> 'no-constant-condition': 'off',
> 'no-control-regex': 'off',
> 'no-debugger': 'off',
> 'no-delete-var': 'off',
> 'no-dupe-class-members': 'off',
> 'no-dupe-else-if': 'off',
> 'no-dupe-keys': 'off',
> 'no-duplicate-case': 'off',
> 'no-empty-character-class': 'off',
> 'no-empty-pattern': 'off',
> 'no-empty-static-block': 'off',
> 'no-eval': 'off',
> 'no-ex-assign': 'off',
> 'no-extra-boolean-cast': 'off',
> 'no-func-assign': 'off',
> 'no-global-assign': 'off',
> 'no-import-assign': 'off',
> 'no-invalid-regexp': 'off',
> 'no-irregular-whitespace': 'off',
> 'no-loss-of-precision': 'off',
> 'no-new-native-nonconstructor': 'off',
> 'no-nonoctal-decimal-escape': 'off',
> 'no-obj-calls': 'off',
> 'no-self-assign': 'off',
> 'no-setter-return': 'off',
> 'no-shadow-restricted-names': 'off',
> 'no-sparse-arrays': 'off',
> 'no-this-before-super': 'off',
> 'no-unsafe-finally': 'off',
> 'no-unsafe-negation': 'off',
> 'no-unsafe-optional-chaining': 'off',
> 'no-unused-labels': 'off',
> 'no-unused-private-class-members': 'off',
> 'no-useless-catch': 'off',
> 'no-useless-escape': 'off',
> 'no-useless-rename': 'off',
> 'no-with': 'off',
> 'require-yield': 'off',
> 'use-isnan': 'off',
> 'valid-typeof': 'off',
> 'import/no-cycle': 'off'
> }
> },
> {
> name: 'oxlint/vue-svelte-exceptions',
> ignores: [ '**/*.vue', '**/*.svelte' ],
> rules: { 'no-unused-vars': 'off' }
> }
> ]
> ```
> </details>
>
>
> When explicitly specifying a rule within the [Nursery
category](https://oxc.rs/docs/guide/usage/linter/rules.html#nursery-10)
(in the above example, `import/named`), the plugin doesn't return the
rule. This means it will not be turned off in the ESLint config.
>
> I would expect that any rules defined in the `.oxlintrc.json` file to
be output as 'off'. The example above sees that non-Nursery rules
(`import/no-cycle`) do this, but Nursery rules are not output.
> </issue_description>
>
> <agent_instructions>`buildFromOxlintConfig` and
`buildFromOxlintConfigFile` should have a second optional `options`
parameter for nursery rules.
> Do not ignore nursery rules in
https://github.com/oxc-project/eslint-plugin-oxlint/blob/main/scripts/constants.ts
> But do not implement them to the general config in `all` and
`flat/all` config:
>
https://github.com/oxc-project/eslint-plugin-oxlint/blob/ae96e4995816341987448e836acbda732ec561cb/src/configs.ts#L30-L37
> Create tests for:
> - nursery rules are not in the `all` and `flat/all` config
> - nursery rules are not outputted with default `buildFromOxlintConfig`
> - nursery rules are outputted with `options: withNursery=true` and
`buildFromOxlintConfig`</agent_instructions>
>
> ## Comments on the Issue (you are @copilot in this section)
>
> <comments>
> <comment_new><author>@Sysix</author><body>
> Nursery rules are rules which are still under development.
> Disabling the rule in ESLint will maybe not report warnings in oxlint
as expected.
> This was a design decision:
#255 (review)
and #256.
>
> ~~This decision was made when `buildFromOxlintConfigFile` was not
created.~~
> Happy to see this implement with a second optional options parameter
for `buildFromOxlintConfigFile`.</body></comment_new>
> </comments>
>
</details>
- Fixes #412
<!-- START COPILOT CODING AGENT TIPS -->
---
✨ Let Copilot coding agent [set things up for
you](https://github.com/oxc-project/eslint-plugin-oxlint/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: Sysix <[email protected]>
Co-authored-by: Sysix <[email protected]>withNursery to buildFromOxlintConfig function (#545)1 parent 02dcb2c commit 32de690
File tree
14 files changed
+175
-29
lines changed- scripts
- src
- build-from-oxlint-config
- generated
14 files changed
+175
-29
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
45 | 49 | | |
46 | 50 | | |
47 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | 4 | | |
8 | 5 | | |
9 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
48 | 52 | | |
49 | 53 | | |
50 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
| 2 | + | |
7 | 3 | | |
8 | 4 | | |
9 | 5 | | |
| |||
98 | 94 | | |
99 | 95 | | |
100 | 96 | | |
101 | | - | |
102 | 97 | | |
103 | 98 | | |
104 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
195 | 235 | | |
196 | 236 | | |
197 | 237 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | | - | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
26 | 33 | | |
27 | 34 | | |
28 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
2 | 6 | | |
3 | 7 | | |
4 | 8 | | |
| |||
25 | 29 | | |
26 | 30 | | |
27 | 31 | | |
28 | | - | |
| 32 | + | |
| 33 | + | |
29 | 34 | | |
30 | 35 | | |
31 | 36 | | |
| |||
47 | 52 | | |
48 | 53 | | |
49 | 54 | | |
50 | | - | |
| 55 | + | |
51 | 56 | | |
52 | 57 | | |
53 | 58 | | |
54 | 59 | | |
55 | | - | |
| 60 | + | |
56 | 61 | | |
57 | 62 | | |
58 | 63 | | |
| |||
72 | 77 | | |
73 | 78 | | |
74 | 79 | | |
75 | | - | |
| 80 | + | |
76 | 81 | | |
77 | 82 | | |
78 | 83 | | |
| |||
86 | 91 | | |
87 | 92 | | |
88 | 93 | | |
89 | | - | |
| 94 | + | |
| 95 | + | |
90 | 96 | | |
91 | 97 | | |
92 | 98 | | |
| |||
100 | 106 | | |
101 | 107 | | |
102 | 108 | | |
103 | | - | |
| 109 | + | |
104 | 110 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | | - | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
26 | | - | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
31 | | - | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| |||
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
20 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
21 | 26 | | |
22 | 27 | | |
23 | | - | |
| 28 | + | |
24 | 29 | | |
25 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
26 | 38 | | |
27 | 39 | | |
28 | 40 | | |
| |||
51 | 63 | | |
52 | 64 | | |
53 | 65 | | |
54 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
55 | 74 | | |
56 | 75 | | |
57 | 76 | | |
| |||
77 | 96 | | |
78 | 97 | | |
79 | 98 | | |
80 | | - | |
| 99 | + | |
| 100 | + | |
81 | 101 | | |
82 | 102 | | |
83 | | - | |
| 103 | + | |
84 | 104 | | |
85 | 105 | | |
86 | 106 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
3 | 7 | | |
4 | 8 | | |
5 | 9 | | |
| |||
0 commit comments