10000 fix: crash with template expression in no-trailing-spaces by yeonjuan · Pull Request #337 · yeonjuan/html-eslint · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: crash with template expression in no-trailing-spaces #337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 7, 2025

Conversation

@yeonjuan yeonjuan requested a review from Copilot May 7, 2025 15:41
Copy link
Contributor
@Copilot 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

This PR fixes a crash in the no-trailing-spaces rule when using template expressions by correcting location calculations and improving error reporting.

  • Updated tests to include explicit line, column, and endColumn properties for error objects.
  • Modified the check function to accept an offset object (with range, line, and column properties) for precise location adjustments.
  • Adjusted the fixer logic to remove trailing spaces based on computed indices.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/eslint-plugin/tests/rules/no-trailing-spaces.test.js Updated test cases to validate accurate error locations in both plain and tagged templates.
packages/eslint-plugin/lib/rules/no-trailing-spaces.js Refactored the check function’s offset handling and updated the fixer to remove trailing spaces correctly.
Comments suppressed due to low confidence (1)

packages/eslint-plugin/lib/rules/no-trailing-spaces.js:86

  • The variable 'end' is used in the fixer function but is not defined. Define 'end' (e.g., by setting const end = sourceCode.getIndexFromLoc(loc.end)) before using it in fixer.removeRange to ensure the correct removal range.
return fixer.removeRange([start, end]);

@yeonjuan yeonjuan merged commit 53db1d4 into main May 7, 2025
5 checks passed
@yeonjuan yeonjuan deleted the fix-no-trailing-spaces-crash branch May 7, 2025 16:24
Copy link
codecov bot commented May 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.54%. Comparing base (390a69b) to head (59d225b).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #337      +/-   ##
==========================================
- Coverage   98.54%   98.54%   -0.01%     
==========================================
  Files          76       76              
  Lines        2332     2331       -1     
  Branches      640      641       +1     
==========================================
- Hits         2298     2297       -1     
  Misses         34       34              
Flag Coverage Δ
unittest 98.54% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ages/eslint-plugin/lib/rules/no-trailing-spaces.js 92.68% <100.00%> (-0.18%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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
0