-
-
Notifications
You must be signed in to change notification settings - Fork 75
Type annotations being caught by space-infix-ops rule #4
Comments
Rules are going to behave strangely with TypeScript for a while; it's too early to start getting into making all the rules work (or making any changes to allow that). In any event, there's nothing the parser could do to fix this, it would have to be some option in ESLint. Once the parsing is working correctly and the AST is filled out completely, we can circle back and look at what (if anything) can be done for failing rules. |
Ok, that makes sense. Are there any resources you can point me at to get up to speed more quickly with how the AST is built, terminology etc? I am super keen to help ESLint be a viable option for Angular 2 development, in particular, as I think we will be seeing a whole new wave of devs/teams embracing TypeScript, but I currently have no experience with linters/ASTs and would appreciate any ProTips! |
SpiderMonkey Parser API |
Many thanks, @ilyavolodin! |
Thanks @nzakas, that's super useful! |
👍 |
Hi, Is this issue have any update? |
@Pleasurazy the issue is closed. This project is still experimental and is expected to have a lot of errors at this point. As such, we are not accepting bug reports at this time. |
As this parseris now at 1.0.0 are we free to submit bug reports such as this? Can this be reopened? |
@AdamWillden it is not a bug in this project (i.e. it is not problem with the parsing or the generated AST), so this will not be reopened. The rule in ESLint core will need to be extended to take typeAnnotation nodes into account, as mentioned here #77 (comment) |
@JamesHenry thanks for linking the two. Makes sense! |
(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
The following code shows how a variable,
foo
, can be explicitly annotated with typestring
let foo: string = 'bar'
Currently this causes the
space-infix-ops
rule to error (if enabled).Re-writing to:
let foo : string = 'bar'
...does fix the eslint error, and is technically not a TypeScript error (example).
However, I would argue that the vast majority of people write their annotations using the first form, and that is certainly what comes through in all the documentation and examples from Microsoft.
It would therefore not be the intention of users who have enabled the
space-infix-ops
rule to receive an error forlet foo: string = 'bar'
The text was updated successfully, but these errors were encountered: