Remove `SourceCode#getComments()`
See original GitHub issueThe 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:
because sourceCode.getComments(node)
uses start
and end
properties of nodes and tokens:
and after the change in https://github.com/eslint/espree/pull/461, Program.start
is no longer 0
but body[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 (https://github.com/eslint/eslint/commit/735d02d570f4a2d3c663f0f4c6a6d4e4223aeb32):
Please note that the following methods have been deprecated and will be removed in a future version of ESLint:
getComments()
- replaced bygetCommentsBefore()
,getCommentsAfter()
, andgetCommentsInside()
In ESLint v7.0.0, RuleTester
was updated to throw on any access to start
and end
properties. Consequently, rules that use sourceCode.getComments()
should have already noticed errors (e.g., https://github.com/eslint/eslint/issues/13293) and switched to other methods.
Are you willing to submit a pull request to implement this change?
Yes
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (9 by maintainers)
Top GitHub Comments
Throwing an error in RuleTester sounds good.
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?