Skip to content

feat: support ! negation patterns in ignore matching#590

Merged
chenjiahan merged 1 commit intomainfrom
fix/go-negation-ignore-20260402
Apr 3, 2026
Merged

feat: support ! negation patterns in ignore matching#590
chenjiahan merged 1 commit intomainfrom
fix/go-negation-ignore-20260402

Conversation

@fansenze
Copy link
Copy Markdown
Contributor

@fansenze fansenze commented Apr 2, 2026

Summary

  • Align isFileIgnored with ESLint v10 semantics: evaluate ignore patterns sequentially where later patterns override earlier ones
  • A ! prefix negates (re-includes) a file that was previously matched by an earlier ignore pattern
  • Merge all global ignore entries before evaluating, so ! negation works across separate global ignore entries
  • Update docs: ! is now supported (was previously marked as unsupported)

Examples:

// Re-include specific file inside ignored directory
{ ignores: ['build/**/*', '!build/test.js'] }

// Cross-entry negation also works
{ ignores: ['build/**/*'] },
{ ignores: ['!build/test.js'] },

// Entry-level ignores
{ files: ['**/*.ts'], ignores: ['vendor/**/*', '!vendor/keep/**/*'], rules: {...} }

Known difference from ESLint v10:
{ ignores: ['dir/**', '!dir/keep.ts'] } — In ESLint v10, dir/** blocks directory traversal so ! cannot re-include during eslint .. In rslint, files from tsconfig Programs bypass directory traversal, so ! re-includes at the file matching level. This is a file discovery architecture difference (to be addressed in the files-driven-lint PR), not an ignore matching logic issue. Using dir/**/* instead of dir/** produces identical behavior in both tools.

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 2, 2026

Deploying rslint with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4af9a2c
Status: ✅  Deploy successful!
Preview URL: https://46d5e54f.rslint.pages.dev
Branch Preview URL: https://fix-go-negation-ignore-20260.rslint.pages.dev

View logs

Copy link
Copy Markdown
Contributor

@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 implements support for ! negation patterns in ignore configurations, aligning with ESLint v10 semantics. The changes include sequential pattern evaluation where later patterns override earlier ones, cross-entry global ignore merging, and comprehensive new tests. Documentation has also been updated to clarify the usage of negation with different glob patterns. Feedback suggests refactoring the path matching logic in isFileIgnored to reduce code duplication by using a closure.

Comment thread internal/config/config.go Outdated
@fansenze fansenze force-pushed the fix/go-negation-ignore-20260402 branch 2 times, most recently from dae5d34 to d5373f6 Compare April 2, 2026 10:56
@fansenze fansenze changed the title fix: support ! negation patterns in ignore matching feat: support ! negation patterns in ignore matching Apr 2, 2026
Align isFileIgnored with ESLint v10 semantics: evaluate ignore patterns
sequentially where later patterns override earlier ones. A `!` prefix
negates (re-includes) a file that was previously matched by an earlier
ignore pattern. Global ignore entries are merged before evaluating, so
negation works across separate entries.
@fansenze fansenze force-pushed the fix/go-negation-ignore-20260402 branch from d5373f6 to 4af9a2c Compare April 2, 2026 10:59
@chenjiahan chenjiahan merged commit 3cb366f into main Apr 3, 2026
19 of 21 checks passed
@chenjiahan chenjiahan deleted the fix/go-negation-ignore-20260402 branch April 3, 2026 02:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants