Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

ESLint comment blocks will not work yet #5

Closed
JamesHenry opened this issue Jan 14, 2016 · 6 comments
Closed

ESLint comment blocks will not work yet #5

JamesHenry opened this issue Jan 14, 2016 · 6 comments

Comments

@JamesHenry
Copy link
Member

(Note: I am using ESLint via eslint-loader for webpack)
ESLint: 1.9.0
eslint-loader: 1.1.1
typescript-eslint-parser: 0.1.0-alpha-1

I have a codebase which was being transpiled with babel and being linted by eslint using the babel-parser.

After migrating the code to TypeScript and replacing the babel-parser with the typescript-eslint-parser, I have noticed that eslint comment blocks are no longer being respected.

Other than the parser option, no other changes were made to the .eslintrc during the migration.

For example:

/* global d3 */
console.log( d3 )

...used to produce no error or warning, but now shows:
error "d3" is not defined no-undef

The same is true for eslint-disable and eslint-enable comments:

/* eslint-disable no-alert */
alert( 'Hello, World!' )
/* eslint-enable no-alert */

Before introducing typescript-eslint-parser: no feedback from eslint
After introducing typescript-eslint-parser: warning Unexpected alert no-alert

@nzakas
Copy link
Member

nzakas commented Jan 15, 2016

This is expected right now because we are not yet including comments in the AST. I'll leave this open to track.

@nzakas nzakas added bug and removed triage labels Jan 15, 2016
@mitermayer
Copy link

@nzakas are you working on this issue or would accept PR on it ?

I believe you already have started on it since this area is commented out

     if (extra.attachComment || extra.comment) {
            // acornOptions.onComment = function() {
            //     var comment = convertAcornCommentToEsprimaComment.apply(this, arguments);
            //     extra.comments.push(comment);
            //
            //     if (extra.attachComment) {
            //         commentAttachment.addComment(comment);
            //     }
            // };
        }

@nzakas
Copy link
Member

nzakas commented Jul 12, 2016

There's already an open PR that has some of the work done. Take a look.

@JamesHenry
Copy link
Member Author

JamesHenry commented Sep 8, 2016

Update on this issue:

It was decided that ESLint would be taking responsibility for attributing comment nodes. This project, and any other ESLint parsers, will only be responsible for identifying and converting the comment nodes for ESLint to then attach.

Here is the relevant issue in ESLint: eslint/eslint#6724

I will leave this issue open until that work is complete so that it serves a reference for anyone else experiencing the issue

@JamesHenry JamesHenry changed the title eslint comment blocks are not being respected in typescript-eslint-parser Blocked: ESLint comment blocks will not work yet Sep 8, 2016
@JamesHenry JamesHenry changed the title Blocked: ESLint comment blocks will not work yet ESLint comment blocks will not work yet Jan 10, 2017
@JamesHenry
Copy link
Member Author

ESLint 4.0.0-alpha.0 has been released and I can confirm that ESLint comments are working with TypeScript!!!

🎉

It can be installed using eslint@next, see this post for more details http://eslint.org/blog/2017/04/eslint-v4.0.0-alpha.0-released

@JamesHenry
Copy link
Member Author

4.0.0 is now the stable version of ESLint and I am delighted to be able to close this issue 😄

https://github.com/eslint/eslint/releases/tag/v4.0.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants