-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Remove SourceCode#getComments()
#14744
Comments
I'm not opposed to removing it but since we already locked down and announced the changes coming in v8.0.0, it seems like we should wait until v9.0.0 and maybe just add a deprecation warning in v8.0.0? |
Then we probably should fix it, since it will be broken with Espree 8. |
Agreed, sorry, that's what I meant to imply. |
Prepared a quick fix: #14748 |
I added this to v9.0.0 project.
That would be throwing an error in RuleTester? It already throws on any access to start/end properties, so that might be good enough, though not all code paths in |
Throwing an error in RuleTester sounds good. |
Prepared #14769 to throw an error in RuleTester if The remaining task is to completely remove |
Reopening since it isn't completed (there's still a task to remove the method in v9.0.0). |
Weird. No idea what could have caused it to close. Nice catch. |
The version of ESLint you are using.
ESLint 7.29.0 with Espree 8.0.0-beta.1
The problem you want to solve.
This test is failing:
eslint/tests/lib/source-code/source-code.js
Lines 909 to 968 in f113cdd
because
sourceCode.getComments(node)
usesstart
andend
properties of nodes and tokens:eslint/lib/source-code/source-code.js
Lines 351 to 357 in f113cdd
and after the change in eslint/js#461,
Program.start
is no longer0
butbody[0].start
:https://github.com/eslint/espree/blob/e08c9d78745fcee03136b57f46d09e11cad70861/lib/espree.js#L171
Your take on the correct solution to problem.
Remove
SourceCode#getComments()
?It was deprecated in ESLint v4.0.0 (735d02d):
In ESLint v7.0.0,
RuleTester
was updated to throw on any access tostart
andend
properties. Consequently, rules that usesourceCode.getComments()
should have already noticed errors (e.g., #13293) and switched to other methods.Are you willing to submit a pull request to implement this change?
Yes
The text was updated successfully, but these errors were encountered: