Skip to content

fix: support ignorePatterns in both rule options or config file#8

Merged
ntnyq merged 1 commit into
mainfrom
fix/ignore-patterns
Mar 12, 2026
Merged

fix: support ignorePatterns in both rule options or config file#8
ntnyq merged 1 commit into
mainfrom
fix/ignore-patterns

Conversation

@ntnyq
Copy link
Copy Markdown
Owner

@ntnyq ntnyq commented Mar 12, 2026

fixes: #7

Summary by CodeRabbit

  • New Features

    • Enabled oxfmt code formatting with support for ignorePatterns to exclude files from formatting.
  • Chores

    • Updated dependencies: oxfmt (0.35.0 → 0.39.0), eslint-config, TypeScript, and pnpm.
    • Updated autofix workflow action version.
    • Configuration updates for ESLint and code formatting tooling.

Copilot AI review requested due to automatic review settings March 12, 2026 09:56
@gemini-code-assist
Copy link
Copy Markdown

Important

Installation incomplete: to start using Gemini Code Assist, please ask the organization owner(s) to visit the Gemini Code Assist Admin Console and sign the Terms of Services.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 12, 2026

📝 Walkthrough

Walkthrough

This PR implements ignorePatterns support for the oxfmt ESLint plugin, enabling it to respect ignore patterns defined in .oxfmtrc configuration files. A helper function in the worker determines which files should be skipped during formatting, and configuration updates align tooling versions and settings.

Changes

Cohort / File(s) Summary
Workflow & Action Updates
.github/workflows/autofix.yml
Added pnpm run format step and upgraded autofix action from v1.3.2 to v1.3.3.
Configuration Files
.oxfmtrc.jsonc, .vscode/settings.json, tsdown.config.ts
Reordered ignorePatterns and fixture paths in oxfmt config; renamed TypeScript experimental setting key; renamed tsdown dependency filter property from onlyAllowBundle to onlyBundle.
ESLint & Package Configuration
eslint.config.mjs, package.json
Simplified ESLint config with oxfmt enabled; removed separate plugin wiring; updated pnpm, oxfmt, load-oxfmt-config, and other dev dependencies to latest versions.
Core ignorePatterns Implementation
workers/oxfmt.mjs
Added shouldIgnoreFile() helper to check if files match ignorePatterns using cross-platform path normalization; integrated pattern matching into worker flow to skip formatting for ignored files.
Test Coverage & Fixtures
tests/eslint-plugin.test.ts, tests/rules/oxfmt.test.ts, tests/fixtures/use-config/...
Expanded test suite with fixtures for ignorePatterns validation; added tests verifying ignorePatterns from .oxfmtrc are respected when useConfig is true; added tests ensuring rule-level ignorePatterns take precedence; included fixture files in ignored and src directories.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A hop and a skip through patterns ignored,
Files neatly sorted, their fate now explored,
No more conflicting what oxfmt should do,
ESLint and oxfmt now perfectly true!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Several changes appear out of scope: dependency updates (oxfmt, eslint-config versions), tsdown config rename, and eslint config refactoring are not directly related to ignorePatterns support. Clarify whether dependency updates and config refactoring changes are necessary for ignorePatterns support or should be separated into a distinct PR.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The PR successfully implements the fix for issue #7 by adding ignorePatterns support that prevents ESLint from reporting oxfmt violations for ignored files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The pull request title clearly summarizes the main change: adding support for ignorePatterns in both rule options and config files, which directly addresses the core objective of the PR.

✏️ 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/ignore-patterns

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.

@ntnyq ntnyq changed the title fix: support ignorePatterns in both rule config or config file fix: support ignorePatterns in both rule config or options file Mar 12, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Mar 12, 2026

Open in StackBlitz

npm i https://pkg.pr.new/eslint-plugin-oxfmt@8

commit: 88cd80f

@ntnyq ntnyq changed the title fix: support ignorePatterns in both rule config or options file fix: support ignorePatterns in both rule options or config file Mar 12, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds support for honoring ignorePatterns when the formatter is run through the oxfmt/oxfmt ESLint rule, aligning ESLint behavior with oxfmt --check and addressing issue #7.

Changes:

  • Implement ignorePatterns handling in the oxfmt worker (supports both rule options and config-loaded patterns).
  • Add/extend tests and fixtures to verify ignore behavior with useConfig: true and rule-level precedence.
  • Update tooling/dependencies (tsdown config option, package bumps) and CI autofix workflow.

Reviewed changes

Copilot reviewed 14 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
workers/oxfmt.mjs Adds shouldIgnoreFile() and early-return behavior to skip formatting for ignored files.
tsdown.config.ts Updates tsdown dependency bundling config key (onlyBundle).
tests/rules/oxfmt.test.ts Adds rule-tester cases covering ignored vs non-ignored files and multiple ignore patterns.
tests/rules/__snapshots__/oxfmt.test.ts.snap Updates snapshots for the new invalid test case.
tests/eslint-plugin.test.ts Adds integration tests verifying .oxfmtrc ignorePatterns and rule-level precedence.
tests/__snapshots__/eslint-plugin.test.ts.snap Adds snapshots for the new integration tests.
tests/fixtures/use-config/src/unformatted.js Fixture for “should be formatted” when useConfig loads ignorePatterns.
tests/fixtures/use-config/ignored/unformatted.js Fixture for “should be ignored” via .oxfmtrc ignorePatterns.
tests/fixtures/use-config/.oxfmtrc.jsonc Adds ignorePatterns config used by the new integration tests.
tests/fixtures/base/ts.ts Adds a base fixture used by the updated linting integration test.
package.json Bumps dependencies (notably load-oxfmt-config, oxfmt, tsdown) and pnpm version.
pnpm-lock.yaml Lockfile updates to reflect dependency/tooling bumps.
eslint.config.mjs Simplifies repo ESLint config and enables oxfmt in @ntnyq/eslint-config.
.vscode/settings.json Updates the tsgo setting key.
.oxfmtrc.jsonc Adjusts ignorePatterns and JSONC formatting (commas/trailing commas).
.github/workflows/autofix.yml Runs pnpm run format in autofix workflow and bumps autofix-ci/action.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread workers/oxfmt.mjs
shouldIgnoreFile(
filename,
cwd,
ignorePatterns || baseOptions.ignorePatterns,
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

ignorePatterns || baseOptions.ignorePatterns treats an explicitly provided empty array (ignorePatterns: []) as falsy and will fall back to the config-file ignorePatterns. This makes it impossible to intentionally disable ignore patterns from config via rule options. Use nullish coalescing (ignorePatterns ?? baseOptions.ignorePatterns) (or an explicit check for undefined) so an empty array is respected as an override.

Suggested change
ignorePatterns || baseOptions.ignorePatterns,
ignorePatterns ?? baseOptions.ignorePatterns,

Copilot uses AI. Check for mistakes.
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.

🧹 Nitpick comments (1)
tests/eslint-plugin.test.ts (1)

61-63: Consider adding explicit assertions for expected file count.

Both tests rely on glob finding the expected fixture files but don't verify the count. Adding a simple assertion like expect(files.length).toBe(2) would catch issues if fixture files are accidentally removed or renamed, making test failures more obvious.

💡 Optional: Add file count assertion
     const results = await eslint.lintFiles(files)
 
+    expect(files.length).toBe(2)
     results.forEach((result, idx) => {
       expect(result.messages).toMatchSnapshot(files[idx])
     })

Also applies to: 96-98

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

In `@tests/eslint-plugin.test.ts` around lines 61 - 63, Add an explicit assertion
that the number of fixture files found matches the expected count before
iterating results; e.g., in tests/eslint-plugin.test.ts where
results.forEach((result, idx) =>
expect(result.messages).toMatchSnapshot(files[idx])), add a check like
expect(files.length).toBe(<expectedCount>) (and the analogous assertion in the
second test block that also iterates results) so the tests fail clearly if
fixture files are removed or renamed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/eslint-plugin.test.ts`:
- Around line 61-63: Add an explicit assertion that the number of fixture files
found matches the expected count before iterating results; e.g., in
tests/eslint-plugin.test.ts where results.forEach((result, idx) =>
expect(result.messages).toMatchSnapshot(files[idx])), add a check like
expect(files.length).toBe(<expectedCount>) (and the analogous assertion in the
second test block that also iterates results) so the tests fail clearly if
fixture files are removed or renamed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2dcddd7a-c75d-4839-9f16-10cdc12f50a0

📥 Commits

Reviewing files that changed from the base of the PR and between a2bbc6d and 1b7e887.

⛔ Files ignored due to path filters (3)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • tests/__snapshots__/eslint-plugin.test.ts.snap is excluded by !**/*.snap
  • tests/rules/__snapshots__/oxfmt.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (13)
  • .github/workflows/autofix.yml
  • .oxfmtrc.jsonc
  • .vscode/settings.json
  • eslint.config.mjs
  • package.json
  • tests/eslint-plugin.test.ts
  • tests/fixtures/base/ts.ts
  • tests/fixtures/use-config/.oxfmtrc.jsonc
  • tests/fixtures/use-config/ignored/unformatted.js
  • tests/fixtures/use-config/src/unformatted.js
  • tests/rules/oxfmt.test.ts
  • tsdown.config.ts
  • workers/oxfmt.mjs

@ntnyq ntnyq merged commit 6758552 into main Mar 12, 2026
19 checks passed
@ntnyq ntnyq deleted the fix/ignore-patterns branch March 27, 2026 08:41
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.

.oxfmtrc.json ignorePatterns not applied?

2 participants