Skip to content
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

feat: add sourceCode property to the rule context #17107

Merged
merged 5 commits into from May 3, 2023

Conversation

snitin315
Copy link
Contributor

Prerequisites checklist

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

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

What changes did you make? (Give an overview)

Refers #16999

This PR creates context.sourceCode and deprecates context.getSourceCode().

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

Did I miss any references?

I intentionally didn't update custom-rules-deprecated.md

@eslint-github-bot eslint-github-bot bot added the feature This change adds a new feature to ESLint label Apr 22, 2023
@netlify
Copy link

netlify bot commented Apr 22, 2023

Deploy Preview for docs-eslint ready!

Name Link
🔨 Latest commit 2dde715
🔍 Latest deploy log https://app.netlify.com/sites/docs-eslint/deploys/64521f9923a5970008194ce6
😎 Deploy Preview https://deploy-preview-17107--docs-eslint.netlify.app/extend/custom-rules
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@snitin315 snitin315 marked this pull request as ready for review April 22, 2023 15:32
@snitin315 snitin315 requested a review from a team as a code owner April 22, 2023 15:32
@snitin315 snitin315 mentioned this pull request Apr 22, 2023
39 tasks
@snitin315 snitin315 added the accepted There is consensus among the team that this change meets the criteria for inclusion label Apr 29, 2023
docs/src/extend/custom-rules.md Outdated Show resolved Hide resolved
lib/linter/linter.js Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

The changes LGTM, but maybe we should add a test to ensure that context.getSourceCode() returns context.sourceCode. Currently, getSourceCode() is being heavily tested indirectly by dependencies that rely on its functionality, but if eventually these dependencies switch to use sourceCode instead, then getSourceCode() would remain uncovered.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestions I've updated the test cases to use assert.strictEqual(context.getSourceCode(), context.sourceCode);

@snitin315 snitin315 changed the title feat: add sourceCode to the rule context feat: add sourceCode property to the rule context Apr 29, 2023
Copy link
Member

@fasttime fasttime left a comment

Choose a reason for hiding this comment

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

LGTM. Leaving open for others to review.

@mdjermanovic
Copy link
Member

There are merge conflicts now.

@snitin315
Copy link
Contributor Author

@mdjermanovic I've rebased & resolved the conflicts.

docs/src/extend/custom-rules.md Outdated Show resolved Hide resolved
docs/src/extend/custom-rules.md Outdated Show resolved Hide resolved
Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

LGTM pending @mdjermanovic's latest suggestions.

Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
Copy link
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!

@aladdin-add aladdin-add restored the feat/context-sourceCode branch June 14, 2023 05:54
aladdin-add pushed a commit to aladdin-add/eslint that referenced this pull request Jun 15, 2023
aladdin-add pushed a commit to aladdin-add/eslint that referenced this pull request Jun 15, 2023
aladdin-add added a commit to aladdin-add/eslint that referenced this pull request Jun 15, 2023
aladdin-add added a commit to aladdin-add/eslint that referenced this pull request Jun 15, 2023
aladdin-add added a commit to aladdin-add/eslint that referenced this pull request Jun 15, 2023
aladdin-add added a commit to aladdin-add/eslint that referenced this pull request Jun 15, 2023
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Oct 31, 2023
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Oct 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion feature This change adds a new feature to ESLint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants