babel / babel-eslint

:tokyo_tower: A wrapper for Babel's parser used for ESLint (renamed to @babel/eslint-parser)

Home Page:https://github.com/babel/babel/tree/main/eslint/babel-eslint-parser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Upgrading to 11.0.0-beta.0 from 8.2.6 causes another linter plugin to start failing

kaiyoma opened this issue · comments

We have a linter plugin (written/published internally) that checks for unnecessary blank lines in our source files. For the purposes of this issue, it's relevant that this plugin prohibits blank lines before the import statements at the top of a file, except when the first line is a comment. In that case, a blank line between the comment and the first import statement is acceptable.

This plugin is passing, but if I upgrade to the latest beta version of babel-eslint, it starts failing, saying that blank lines are not allowed above import blocks. I haven't dug into this, but I'm guessing that somehow the (first line) comments are disappearing. Does babel-eslint somehow modify the files being linted?

It’s hard to tell without looking at the rule source code or knowing what exactly the error is. One thing that comes to mind: comment attachment was removed in babel-eslint v11 (ESLint core hasn’t used comment attachment since v4). Are you relying on leadingComments for either the Program or first ImportDeclaration nodes by any chance?

Edit: comment attachment was actually removed in ESLint v4, so it hasn't been supported since v3.

Yes, we are using leadingComments in the code for our plugin.

Okay, this is working as intended then. Please see https://eslint.org/docs/user-guide/migrating-to-4.0.0#-ast-nodes-no-longer-have-comment-properties for how to upgrade the plugin.

commented

Ok closed as intended change