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

Update guard-define-call rule for eslint 9 compat #143

Merged
merged 5 commits into from
Feb 20, 2025

Conversation

gracepark
Copy link
Contributor

@gracepark gracepark commented Feb 18, 2025

I was running into some compatibility issues with ESLint 9 for the guard-define-call rule:

ESLint: 9.20.1

TypeError: context.getAncestors is not a function
Occurred while linting
Rule: "wc/guard-define-call"

Tested out the rule update: https://eslint.org/blog/2023/09/preparing-custom-rules-eslint-v9/#context.getancestors() and this looks to fix the issue.

@@ -27,7 +27,7 @@ const rule: Rule.RuleModule = {

create(context): Rule.RuleListener {
const definedCustomElements = new Set<string>();

const sourceCode = context.sourceCode ?? context.getSourceCode();
Copy link
Owner

@43081j 43081j Feb 19, 2025

Choose a reason for hiding this comment

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

context.sourceCode was introduced in 9.x iirc, so we may not need to do this

pretty sure we have other places where we depend on >=9 too (though happy to be proven wrong!)

@43081j
Copy link
Owner

43081j commented Feb 19, 2025

left 2 comments but the overall question here is what our effective support is currently

i assumed we already required >=8 basically, maybe even >=9. if we can figure that out, it'll decide if we can simplify your code or not (to just assume those methods exist)

@gracepark
Copy link
Contributor Author

Ok @43081j that makes sense. I tested this out on our end, and it looks to be working as expected. Thanks!

Copy link
Owner

@43081j 43081j left a comment

Choose a reason for hiding this comment

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

i double checked and this does seem right 👍

we use context.sourceCode throughout the repo, so we are already depending on >=8.4 (as per package.json too)

and source.getAncestors existed since around then too

@43081j 43081j merged commit e96d723 into 43081j:master Feb 20, 2025
3 checks passed
@gracepark gracepark deleted the eslint-9-guard-define-call-update branch February 20, 2025 16:57
@gracepark
Copy link
Contributor Author

@43081j - thanks! Do you know when the next release will happen?

@43081j
Copy link
Owner

43081j commented Feb 20, 2025

https://github.com/43081j/eslint-plugin-wc/releases/tag/2.2.1

could you try it out @gracepark and let me know if all is good?

@gracepark
Copy link
Contributor Author

It works for me, thank you so much @43081j!

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.

2 participants