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

Class body has invalid range that breaks brace-style rule #152

Closed
soda0289 opened this issue Jan 31, 2017 · 2 comments
Closed

Class body has invalid range that breaks brace-style rule #152

soda0289 opened this issue Jan 31, 2017 · 2 comments
Labels

Comments

@soda0289
Copy link
Member

I noticed on the newer version of eslint (3.14) that the brace style rule fails on exported classes. The opening brace variable used in the rule is incorrect since it is pointing to the identifier 'hello'. I believe the class body node's range is wrong and is still including the identifier. Have not tested on typescript 2.0.3. Will try and submit pr with fix.

What version of TypeScript are you using?
2.1.3

What version of typescript-eslint-parser are you using?
ts-2.1

What code were you trying to parse?

export class hello {

    hello () {

    }
}

What did you expect to happen?
Should parse correctly with brace-style 1tbs

What happened?
Failed with error:
2:14 error Statement inside of curly braces should be on next line brace-style

@soda0289 soda0289 changed the title Class body has invalid range that brakes brace-style rule Class body has invalid range that breaks brace-style rule Feb 1, 2017
@soda0289
Copy link
Member Author

soda0289 commented Feb 1, 2017

This also effects typescript 2.0.3 with master. Will submit pull request with fix.

@JamesHenry
Copy link
Member

Thanks so much for your efforts, @soda0289! I've been so swamped in January but things are set to improve from next week.

soda0289 added a commit to soda0289/typescript-eslint-parser that referenced this issue Feb 1, 2017
The range of a class body should be from the opening brace to the
closing brace. To find the opening brace the ast converter parses over
modifiers of the class declaration and assumes it is the last token
after the last node modifier. This assumption is not always true when the
class is exported. This commit ensures we only skip over modifiers
which are after the class name or heritage clause.
soda0289 added a commit to soda0289/typescript-eslint-parser that referenced this issue Feb 1, 2017
The range of a class body should be from the opening brace to the
closing brace. To find the opening brace the ast converter parses over
modifiers of the class declaration and assumes it is the last token
after the last node modifier. This assumption is not always true when the
class is exported. This commit ensures we only skip over modifiers
which are after the class name or heritage clause.
@nzakas nzakas closed this as completed in e5f378f Feb 5, 2017
soda0289 added a commit to soda0289/typescript-eslint-parser that referenced this issue Feb 7, 2017
…) (eslint#153)

The range of a class body should be from the opening brace to the
closing brace. To find the opening brace the ast converter parses over
modifiers of the class declaration and assumes it is the last token
after the last node modifier. This assumption is not always true when the
class is exported. This commit ensures we only skip over modifiers
which are after the class name or heritage clause.
soda0289 added a commit to soda0289/typescript-eslint-parser that referenced this issue Feb 7, 2017
…slint#152)

When a class with a generic definition is exported we must take the
type parameters into account when finding the opening brace. This
continues the fix of pull request eslint#153 and handles the case of exporting
a class with generics. We now find the last type parameter and use the
succeeding token as the opening brace.
soda0289 added a commit to soda0289/typescript-eslint-parser that referenced this issue Feb 7, 2017
…slint#152)

When a class with a generic definition is exported we must take the
type parameters into account when finding the opening brace. This
continues the fix of pull request eslint#153 and handles the case of exporting
a class with generics. We now find the last type parameter and use the
succeeding token as the opening brace.
soda0289 added a commit to soda0289/typescript-eslint-parser that referenced this issue Feb 7, 2017
…nt#152)

When a class with a generic definition is exported we must take the
type parameters into account when finding the opening brace. This
continues the fix of pull request eslint#153 and handles the case of exporting
a class with generics. We now find the last type parameter and use the
succeeding token as the opening brace.
soda0289 added a commit to soda0289/typescript-eslint-parser that referenced this issue Feb 7, 2017
…nt#152)

When a class with a generic definition is exported we must take the
type parameters into account when finding the opening brace. This
continues the fix of pull request eslint#153 and handles the case of exporting
a class with generics. We now find the last type parameter and use the
succeeding token as the opening brace.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants