Skip to content

feat!: export JS config with defineConfig() for oxlint >= 1.51.0#2

Open
fengmk2 wants to merge 1 commit intomasterfrom
fix/oxlint-1.51-compat
Open

feat!: export JS config with defineConfig() for oxlint >= 1.51.0#2
fengmk2 wants to merge 1 commit intomasterfrom
fix/oxlint-1.51-compat

Conversation

@fengmk2
Copy link
Copy Markdown
Member

@fengmk2 fengmk2 commented Mar 6, 2026

Breaking Change

oxlint >= 1.51.0 (bundled in vite-plus 0.1.1) no longer supports string paths in extends. Config objects wrapped with defineConfig() are now required.

What changed

  • Added index.mjs that exports the config as a JS object using defineConfig() from oxlint
  • Updated package.json exports to point to index.mjs as the default entry
  • Added oxlint >= 1.51.0 as an optional peer dependency
  • Bumped version to 2.0.0
  • .oxlintrc.json is still available for direct CLI use

Usage

// vite.config.ts
import { defineConfig } from 'vite-plus';
import oxlintConfig from '@eggjs/oxlint-config';

export default defineConfig({
  lint: {
    extends: [oxlintConfig],
  },
});
// oxlint.config.mjs
import { defineConfig } from 'oxlint';
import eggConfig from '@eggjs/oxlint-config';

export default defineConfig({
  extends: [eggConfig],
});

Summary by CodeRabbit

  • New Features

    • Added ES module configuration format support alongside the legacy JSON configuration.
  • Documentation

    • Simplified README with focused description and expanded usage instructions including code examples for modern TypeScript and ESM module setups.
  • Chores

    • Version bumped to 2.0.0.
    • Updated minimum oxlint dependency requirement to 1.51.0.

BREAKING CHANGE: The default export is now a JS config object wrapped
with defineConfig() from oxlint. This is required by oxlint >= 1.51.0
which no longer supports string paths in extends.

Usage in vite.config.ts:
  import oxlintConfig from '@eggjs/oxlint-config';
  lint: { extends: [oxlintConfig] }

The .oxlintrc.json is still available for direct CLI use.
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a breaking change to the @eggjs/oxlint-config package, adapting it to the new configuration requirements of oxlint version 1.51.0 and above. The update shifts from string-based paths for extends in .oxlintrc.json to requiring config objects wrapped with defineConfig(). This change modernizes the configuration export, making it more robust and compatible with contemporary tooling like vite-plus.

Highlights

  • New Configuration Export: Introduced a new JavaScript module (index.mjs) to export the oxlint configuration using defineConfig(), aligning with oxlint >= 1.51.0 requirements.
  • Package Entry Point Update: Updated package.json to specify index.mjs as the primary entry point and to support module exports.
  • Optional Peer Dependency: Added oxlint >= 1.51.0 as an optional peer dependency, reflecting the new configuration approach.
  • Version Bump: Bumped the package version to 2.0.0, indicating a breaking change due to the new configuration format.
  • Documentation Update: Revised the README.md to provide updated usage examples for vite-plus and oxlint.config.mjs, while also noting the continued availability of the legacy JSON config.
Changelog
  • README.md
    • Removed old badge links and updated the project description.
    • Updated installation instructions to use --save-dev.
    • Replaced the old JSON usage example with new sections for vite-plus (vite.config.ts) and oxlint.config.mjs usage.
    • Added a section for "Legacy JSON config (v1)" explaining how to use the .oxlintrc.json directly.
    • Removed the "Contributors" section.
  • index.mjs
    • Added a new module file that exports the oxlint configuration object wrapped in defineConfig().
    • Defined env, categories, plugins, and a comprehensive set of rules for various linters (eslint, import, promise, unicorn, oxc, typescript, jsdoc).
  • package-lock.json
    • Added a new package-lock.json file, reflecting the updated dependencies and version bump to 2.0.0.
    • Included various @oxlint/binding-* optional dependencies for different platforms.
  • package.json
    • Updated the package version from 1.0.0 to 2.0.0.
    • Added exports and main fields to point to the new index.mjs file.
    • Included index.mjs in the files array for publishing.
    • Added oxlint: ">=1.51.0" as an optional peer dependency.
    • Updated devDependencies.oxlint from ^1.11.0 to ^1.51.0.
Activity
  • No specific activity (comments, reviews, progress updates) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 6, 2026

📝 Walkthrough

Walkthrough

A new oxlint configuration module (index.mjs) is introduced and exported via package.json, with the package version bumped to 2.0.0. README documentation is streamlined by removing badges and adding concrete configuration code examples for modern JavaScript/TypeScript setups.

Changes

Cohort / File(s) Summary
Configuration Module
index.mjs
New file exporting oxlint configuration via defineConfig() with environment settings (node: true), all categories set to error, multiple plugins (import, typescript, unicorn, jsdoc, node, promise, oxc), and extensive rule customizations across eslint, import, promise, unicorn, oxc, typescript, and jsdoc.
Package Manifest
package.json
Version updated to 2.0.0. Added exports field mapping "." to "./index.mjs" and "./.oxlintrc.json" to itself. Added main field pointing to "./index.mjs", files array including "index.mjs", and peerDependencies with optional oxlint >= 1.51.0. Updated oxlint devDependency to ^1.51.0.
Documentation
README.md
Removed all badge images and metadata lines. Simplified description to single sentence. Expanded usage section with concrete code snippets for vite-plus TypeScript configuration, oxlint.config.mjs ESM setup, and legacy JSON configuration reference.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A config takes shape in modules so neat,
With oxlint rules dancing to rhythmic beat,
Badges are gone, the docs shine anew,
Version two hops—a hop-hurrah for you! 🎉

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: exporting a JS config with defineConfig() for oxlint >= 1.51.0, which is the primary objective of this breaking change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/oxlint-1.51-compat

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a breaking change to export the oxlint configuration as a JavaScript object using defineConfig(), to support oxlint >= 1.51.0. The changes are well-structured, including a new index.mjs entry point, corresponding updates to package.json, and revised documentation in README.md. My review includes a couple of minor suggestions for the new index.mjs configuration file to improve its clarity and maintainability.

'no-empty-function': 'error',
'max-depth': ['error', 6],
'max-lines-per-function': 'allow',
'no-lonely-if': 'error',
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The no-lonely-if rule is also provided by the unicorn plugin as unicorn/no-lonely-if (which you've enabled on line 115). The unicorn version is an enhanced version with autofix capabilities. To avoid redundancy, it's recommended to remove this core ESLint rule and rely solely on the unicorn version.

'unicorn/prefer-number-properties': 'error',
'unicorn/prefer-array-some': 'error',
'unicorn/prefer-string-slice': 'error',
// "unicorn/no-null": "error",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This commented-out rule appears to be a leftover. The unicorn/no-null rule is already configured as 'allow' on line 99. To improve code clarity and avoid confusion, this redundant line should be removed.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
index.mjs (1)

3-150: Avoid maintaining the same config in two places.

index.mjs now duplicates the full payload from .oxlintrc.json. That makes future rule changes easy to miss in one entry point and silently diverge behavior between the JS export and the legacy JSON export.

Suggested direction

Author one canonical config and generate the legacy artifact from it during publish. For example, keep index.mjs as the source of truth and add a small release script that writes .oxlintrc.json from the same object before publish.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@index.mjs` around lines 3 - 150, index.mjs duplicates the full rule payload
from .oxlintrc.json, causing drift; instead make a single source of truth and
generate the legacy JSON during release. Keep the exported config object used by
defineConfig (the default export in index.mjs) as the canonical config, remove
the duplicated .oxlintrc.json from manual maintenance, and add a small
release/build script (e.g., a publish script or prepack step) that imports/reads
the same exported config and writes it to .oxlintrc.json before publishing;
ensure the script serializes the same object shape (rules, plugins, categories,
ignorePatterns) so both consumers get identical configs.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@index.mjs`:
- Line 26: Several inline comment headers like "// eslint" are failing the
capitalized-comments rule; update each section header comment (e.g., the comment
text "// eslint" and the other comment headers at the noted locations) to start
with an uppercase letter (for example change "// eslint" to "// ESLint") so they
are capitalized; locate these comment lines in index.mjs and edit their initial
letter to be uppercase for each occurrence.

In `@package.json`:
- Around line 36-42: The package currently marks the peerDependency "oxlint" as
optional while the package's runtime (index.mjs) does a direct import of oxlint,
which will cause MODULE_NOT_FOUND for JS consumers; update package.json by
removing the "optional": true entry under "peerDependenciesMeta" for "oxlint"
(or otherwise ensure "oxlint" is a required peerDependency) so that installing
this package will require oxlint to be installed, and keep README notes about
JSON-only usage if you still want to support consumers that avoid the JS API.

---

Nitpick comments:
In `@index.mjs`:
- Around line 3-150: index.mjs duplicates the full rule payload from
.oxlintrc.json, causing drift; instead make a single source of truth and
generate the legacy JSON during release. Keep the exported config object used by
defineConfig (the default export in index.mjs) as the canonical config, remove
the duplicated .oxlintrc.json from manual maintenance, and add a small
release/build script (e.g., a publish script or prepack step) that imports/reads
the same exported config and writes it to .oxlintrc.json before publishing;
ensure the script serializes the same object shape (rules, plugins, categories,
ignorePatterns) so both consumers get identical configs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f9267ed9-c171-4f55-aa59-abc6b8c51ca7

📥 Commits

Reviewing files that changed from the base of the PR and between f7718b9 and 6eae92f.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • README.md
  • index.mjs
  • package.json

'oxc',
],
rules: {
// eslint
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Capitalize these section headers to unblock CI.

These comments currently trip capitalized-comments, so both workflows stay red until they are uppercased.

Proposed fix
-    // eslint
+    // ESLint
...
-    // maybe warn
+    // Maybe warn
...
-    // import
+    // Import
...
-    // promise
+    // Promise
...
-    // unicorn
+    // Unicorn
...
-    // oxc
+    // Oxc
...
-    // typescript
+    // TypeScript
...
-    // jsdoc
+    // JSDoc

Also applies to: 54-54, 73-73, 88-88, 97-97, 123-123, 130-130, 146-146

🧰 Tools
🪛 GitHub Actions: Node.js CI

[error] 26-26: eslint(capitalized-comments): Comments should not begin with a lowercase letter. Help: Change the first letter of the comment to uppercase.

🪛 GitHub Actions: Publish Any Commit

[error] 26-26: ESLint: Comments should not begin with a lowercase letter (capitalized-comments)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@index.mjs` at line 26, Several inline comment headers like "// eslint" are
failing the capitalized-comments rule; update each section header comment (e.g.,
the comment text "// eslint" and the other comment headers at the noted
locations) to start with an uppercase letter (for example change "// eslint" to
"// ESLint") so they are capitalized; locate these comment lines in index.mjs
and edit their initial letter to be uppercase for each occurrence.

Comment on lines +36 to +42
"peerDependencies": {
"oxlint": ">=1.51.0"
},
"peerDependenciesMeta": {
"oxlint": {
"optional": true
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find and display package.json
if [ -f "package.json" ]; then
  echo "=== package.json content ==="
  cat -n package.json
else
  echo "package.json not found"
fi

Repository: eggjs/oxlint-config

Length of output: 1358


🏁 Script executed:

#!/bin/bash
# Check index.mjs
if [ -f "index.mjs" ]; then
  echo "=== index.mjs content ==="
  cat -n index.mjs
else
  echo "index.mjs not found"
fi

Repository: eggjs/oxlint-config

Length of output: 5865


🏁 Script executed:

#!/bin/bash
# Check .oxlintrc.json and README
echo "=== .oxlintrc.json content ==="
if [ -f ".oxlintrc.json" ]; then
  cat .oxlintrc.json
else
  echo ".oxlintrc.json not found"
fi

echo ""
echo "=== README.md (first 50 lines) ==="
if [ -f "README.md" ]; then
  head -50 README.md
else
  echo "README.md not found"
fi

Repository: eggjs/oxlint-config

Length of output: 5701


Don't mark oxlint optional when the main export imports it.

index.mjs line 1 has a hard runtime import from oxlint, and the primary README examples show consuming via import oxlintConfig from '@eggjs/oxlint-config'. With the peer marked optional, oxlint won't be installed by default, causing MODULE_NOT_FOUND for users following the documented JS import pattern.

Proposed fix
   "peerDependencies": {
     "oxlint": ">=1.51.0"
   },
-  "peerDependenciesMeta": {
-    "oxlint": {
-      "optional": true
-    }
-  },
   "devDependencies": {
     "oxlint": "^1.51.0"
   }

If you want to keep supporting JSON-only consumers via the .oxlintrc.json export without requiring oxlint, document that the legacy JSON config is an alternative for projects that don't need the JS API.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` around lines 36 - 42, The package currently marks the
peerDependency "oxlint" as optional while the package's runtime (index.mjs) does
a direct import of oxlint, which will cause MODULE_NOT_FOUND for JS consumers;
update package.json by removing the "optional": true entry under
"peerDependenciesMeta" for "oxlint" (or otherwise ensure "oxlint" is a required
peerDependency) so that installing this package will require oxlint to be
installed, and keep README notes about JSON-only usage if you still want to
support consumers that avoid the JS API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant