feat(eslint-plugin): Resolve globs relative to the project root instead of /app#8942
feat(eslint-plugin): Resolve globs relative to the project root instead of /app#8942Ephem wants to merge 4 commits into
Conversation
🦋 Changeset detectedLatest commit: cc25b29 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Repository UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe ChangesProject-relative glob matching for require-auth-protection
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Comment |
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/electron
@clerk/electron-passkeys
@clerk/eslint-plugin
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/eslint-plugin/src/next/__tests__/file-info.test.ts`:
- Around line 39-56: Add a new test case to cover the edge case where a file is
within the project root but the folder name starts with `..` (e.g.,
`/proj/..internal/actions.ts`). The test should verify that getRelativeFolder
correctly returns the project-relative folder path (`..internal`) rather than
null, ensuring that the function distinguishes between paths that are truly
outside the root versus paths with unusual but valid folder names that contain
`..` as part of the directory name.
In `@packages/eslint-plugin/src/next/lib/file-info.ts`:
- Around line 33-35: The condition in the file-info.ts file that checks
`rel.startsWith('..')` is too broad and incorrectly rejects valid in-root paths
that happen to start with two dots (like `..internal/foo.ts`). Modify the check
to specifically detect actual parent directory traversal by checking for `..`
followed by a path separator (forward slash `/` or backslash `\`) instead of
just checking if the relative path starts with `..`.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Repository UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 4517c2c6-7ec5-441a-a137-ba9cae90d5f5
📒 Files selected for processing (7)
.changeset/eslint-plugin-project-relative-paths.mdpackages/eslint-plugin/README.mdpackages/eslint-plugin/src/next/__tests__/file-info.test.tspackages/eslint-plugin/src/next/__tests__/require-auth-protection.suggestions.test.tspackages/eslint-plugin/src/next/__tests__/require-auth-protection.test.tspackages/eslint-plugin/src/next/lib/file-info.tspackages/eslint-plugin/src/next/require-auth-protection.ts
Description
The previous glob pattern behavior was that they resolved from
app/, and not from the project root, this had two downsides:public: ['src/app/sign-in/**']would failapp/and we still want to protect themThis PR makes a breaking change (but in a minor pre-stable version) to always anchor to the project root instead, and changes the default pattern in the Readme to
protected: ['**']to include Server Functions. The reason it's breaking is that you now have to specifysrc/if that's what your project is using.The PR also expands the Readme with some more details and specifics, including on public first patterns and monorepo setups.
The rule still only checks
page.jsx,route.jsetc if the file is inside of ansrc/app/orapp/folder.I also included some extra validation for the path patterns provided via the config.
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit
protected/publicglob patterns.rootDir, including separate vs single top-level ESLint configs.protected/publicglob matching now behaves as project-root-relative (with notes forsrc/applayouts).protected/public/mixedScopeLayoutspatterns and App Router file classification.