You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add options parameter with withNursery to buildFromOxlintConfig function (#545)
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] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Sysix <3897725+Sysix@users.noreply.github.com>
Co-authored-by: Sysix <sysix@sysix-coding.de>
0 commit comments