Skip to content

feat: Add and use SourceCode#getLoc/getRange#18703

Merged
mdjermanovic merged 5 commits intomainfrom
issue18695
Jul 24, 2024
Merged

feat: Add and use SourceCode#getLoc/getRange#18703
mdjermanovic merged 5 commits intomainfrom
issue18695

Conversation

@nzakas
Copy link
Copy Markdown
Member

@nzakas nzakas commented Jul 19, 2024

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[x] Add something to the core
[ ] Other, please explain:

What changes did you make? (Give an overview)

  • Added SourceCode#getRange() and SourceCode.getLoc()
  • Refactored Linter, applyDisableDirectives() to use the new methods instead of pulling from the node/token
  • Updated tests

Refs #18695
Depends on eslint/rewrite#89

Is there anything you'd like reviewers to focus on?

@eslint-github-bot eslint-github-bot Bot added the feature This change adds a new feature to ESLint label Jul 19, 2024
@github-actions github-actions Bot added the core Relates to ESLint's core APIs and features label Jul 19, 2024
@netlify
Copy link
Copy Markdown

netlify Bot commented Jul 19, 2024

Deploy Preview for docs-eslint canceled.

Name Link
🔨 Latest commit 7ce8fe8
🔍 Latest deploy log https://app.netlify.com/sites/docs-eslint/deploys/669ea0b62080450008a69bc5

Copy link
Copy Markdown
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

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

Few more places that should also be updated, I believe, because they're using .loc or .range of nodes:

return descriptor.node.loc;

return this.insertTextAfterRange(nodeOrToken.range, text);

return this.insertTextBeforeRange(nodeOrToken.range, text);

return this.replaceTextRange(nodeOrToken.range, text);

return this.removeRange(nodeOrToken.range);

@nzakas
Copy link
Copy Markdown
Member Author

nzakas commented Jul 19, 2024

Thanks!

@nzakas nzakas marked this pull request as ready for review July 22, 2024 17:54
@nzakas nzakas requested a review from a team as a code owner July 22, 2024 17:54
@mdjermanovic mdjermanovic added the accepted There is consensus among the team that this change meets the criteria for inclusion label Jul 22, 2024
Copy link
Copy Markdown
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@mdjermanovic mdjermanovic merged commit 13d0bd3 into main Jul 24, 2024
@mdjermanovic mdjermanovic deleted the issue18695 branch July 24, 2024 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accepted There is consensus among the team that this change meets the criteria for inclusion core Relates to ESLint's core APIs and features feature This change adds a new feature to ESLint

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants