feat(eslint-plugin): squiggle the offending identifier in invalid-query errors#504
Conversation
🦋 Changeset detectedLatest commit: 1136c7b The changes in this PR will be included in the next version bump. This PR includes changesets to release 17 packages
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. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthrough
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
⚪️ generate() performance
⚪️ check-sql lint-rule overhead
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/rules/check-sql.utils.ts`:
- Around line 758-768: The nearest-match lookup in check-sql.utils.ts is using
the mapped fragment start instead of the translated Postgres error offset, which
can highlight the wrong repeated token. Update the anchor passed to
findNearestMatchIndex in the errorToken handling path to use the translated
error.position value from the builder-sourcemap flow, and keep the existing
getSourceLocation logic intact. Add a regression test around the relevant
check-sql rule helper to cover repeated identifiers in the same fragment and
verify the squiggle lands on the actual error occurrence.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 77f2e864-7664-47c7-895b-b367b4253d78
📒 Files selected for processing (4)
.changeset/precise-invalid-query-position.mdpackages/eslint-plugin/src/rules/check-sql.utils.tspackages/eslint-plugin/src/rules/check-sql/check-sql.plugins.test.tspackages/plugins/kysely/src/plugin.integration.test.ts
Greptile SummaryThis PR improves the diagnostic precision of SafeQL's invalid-query errors by extracting the specific offending identifier from Postgres error messages and narrowing the squiggle to that token, rather than underlining the whole query or embedded
Confidence Score: 5/5Safe to merge — the change is purely additive, all new patterns fall back to the existing full-range highlight when no token is matched or found. Every new code path has an explicit fallback to the prior behavior, so a bad regex match or a missing token simply leaves the squiggle where it was before. The new extractErrorToken patterns cover the most common Postgres identifier-error families. The fragment-restriction logic in getQueryErrorPosition is arithmetically verified by the test assertions, which pin exact column ranges against a live database. No existing behavior is removed. No files require special attention. Important Files Changed
|
e49efce to
35d607e
Compare
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
35d607e to
3116165
Compare
…ry errors Postgres names the bad identifier in many error messages (unknown column — quoted or qualified-unquoted — table, relation, type, function). Extract it and locate it in the source so the report lands on that token instead of the whole query. The search is confined to the failing fragment, so a token that also appears earlier in a builder chain (e.g. a column named in a `.innerJoin`) isn't matched ahead of the occurrence that actually failed. This is most visible for Kysely builder chains, whose sourcemap spans the entire embedded `sql` fragment, so the error previously underlined the whole fragment.
3116165 to
1136c7b
Compare
Summary by CodeRabbit
invalidQuerylocations.