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
Add methods that return information compatible with ESLint v9 #142
Comments
@eslint-community/core-team What do you think about it? @nzakas If these are added, do you think they should be introduced on the ESLint blog? |
@ota-meshi I'm not sure it's worth adding such methods. If people are going to need to update their rules, why would they update to use new |
I agree we should not add methods that are already in ESLint core |
For example, |
For example, I want to create a util function like the following. function getSourceCode(context) {
const sourceCode = context.sourceCode ?? context.getSourceCode()
return new Proxy(sourceCode, {
get(_target, name) {
if (sourceCode[name]) {
return sourceCode[name]
}
if (name === 'getScope') {
return node => {
// Emulate `getScope` using `sourceCode.scopeManager`.
}
}
if (name === 'getDeclaredVariables') {
return node => context.getDeclaredVariables(node)
}
// ...
}
})
} |
You can certainly create a utility function inside the plugin to do that if you'd like. I'm just not sure how many other plugins will also need to support ESLint v7. And keep in mind that proxies are much slower than other objects, so you definitely don't want that in your hot path. (We tested in this in ESLint core and found a 25% performance hit.) |
@ota-meshi In the blogpost @nzakas created, it's mentioned that all the necessary methods are already in ESLint for 6 years, so ESLint v7 should support all of them, no? |
I see 😃. I implement them inside the plugin where it is needed. |
ESLint v9 changes some context API.
eslint/eslint.org#471
So eslint plugin developers will need some workarounds if they want to support lower versions.
I would like to add a method to
eslint-utils
that can hide this workaround.For example:
The text was updated successfully, but these errors were encountered: