Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Stripping of newlines in comments when preceded by carriage returns #145

Copy link
Copy link
Closed
@brettz9

Description

@brettz9
Issue body actions

Hi,

Our users for eslint-plugin-jsdoc have reported problems with Vue in passing on preserving newlines within the ESLint AST comments property when carriage returns are also present (preceding them).

I've confirmed that @babel/eslint-parser does not strip the newlines when interpreting the text within the user's <script> tag, but when supplying the text to vue-eslint-parser, though the carriage returns our preserved, the newlines are stripped, producing comment AST like the following, causing our plugin to report errors when there should be none:

[
  {
    type: 'Block',
    value: '*\r       * @description TESTSTETSTST\r       * @param {string} arg - lorem\r       * @return {string} - someDescription\r       ',
    // ...
  }
]

However, I see that in the likes of templateBody AST, at least, instead of newlines being missing, the newlines are present (and the carriage returns are not added), as perhaps is expected. But for comments, there is the above problem.

Code to reproduce (in a type: "module" package):

import {parseForESLint} from 'vue-eslint-parser';

const parsed = parseForESLint(`\r
  <template>\r
    <div>HELLO WORLD</div>\r
  </template>\r
\r
  <script>\r
  export default {\r
    computed: {\r
      /**\r
       * @description TESTSTETSTST\r
       * @param {string} arg - lorem\r
       * @return {string} - someDescription\r
       */\r
      isForTestingLint (arg) {\r
        return arg;\r
      },\r
    },\r
  };\r
  </script>\r
`, {
  parser: "@babel/eslint-parser"
})

console.log('parsed', parsed.ast.comments);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.