Skip to content
This repository has been archived by the owner on May 31, 2019. It is now read-only.

Ignore comment annotation doesn't work for one-line functions #7

Open
yang opened this issue May 18, 2015 · 4 comments
Open

Ignore comment annotation doesn't work for one-line functions #7

yang opened this issue May 18, 2015 · 4 comments

Comments

@yang
Copy link

yang commented May 18, 2015

$ cat ./go.coffee
'use strict'
x = 0
###coffeelint-variable-scope-ignore###
-> x = 1

$ ./node_modules/.bin/coffeelint ./go.coffee
  ✗ ./go.coffee
     ✗ #2-4: Outer scope variable overwrite. x.

✗ Lint! » 1 error and 0 warnings in 1 file
@AsaAyers
Copy link

CoffeeLint comes with a mechanism to do this. I'm not sure why this rule is providing a custom mechanism that no other rule provides. The method below doesn't rely on scopes, it disables between any two lines.

'use strict'
x = 0
# coffeelint: disable=variable_scope
-> x = 1
# coffeelint: enable=variable_scope

@yang
Copy link
Author

yang commented May 18, 2015

I had tried that before but it sadly doesn't work for this rule:

$ cat go.coffee
'use strict'
x = 0
# coffeelint: disable=variable_scope
-> x = 1
# coffeelint: enable=variable_scope
->
  # coffeelint: disable=variable_scope
  x = 1
  # coffeelint: enable=variable_scope

$ ./node_modules/.bin/coffeelint ./go.coffee
  ✗ ./go.coffee
     ✗ #2-4: Outer scope variable overwrite. x.
     ✗ #2-8: Outer scope variable overwrite. x.

✗ Lint! » 2 errors and 0 warnings in 1 file

On Sunday, May 17, 2015, Asa Ayers notifications@github.com wrote:

CoffeeLint comes with a mechanism to do this. I'm not sure why this rule
is providing a custom mechanism that no other rule provides. The method
below doesn't rely on scopes, it disables between any two lines.

'use strict'
x = 0

coffeelint: disable=variable_scope

-> x = 1

coffeelint: enable=variable_scope


Reply to this email directly or view it on GitHub
#7 (comment)
.

@AsaAyers
Copy link

oh, this rule isn't warning you around where the error is produced (line 4) above. It's wrapping the error all the way from where the variable was defined. This seems awkward but to use the built in capability to disable a rule you need to use:

$ cat go.coffee
'use strict'
# coffeelint: disable=variable_scope
x = 0 # Now this will suppress all errors that start on this line.
# coffeelint: enable=variable_scope
-> x = 1
->
  x = 1

CoffeeLint filters based on the first line, which is known for all errors/warnings. implementation

I have no control over this project, I'm the maintainer of CoffeeLint. I Sometimes subscribe to rules I don't use just to see what others are doing with CoffeeLint.

@yang
Copy link
Author

yang commented May 18, 2015

Got it. I believe that, usability-wise, the most common use case is to
selectively control whether a particular mutation is kosher (rather than
blanketing a variable altogether). But anyway this is an adequate
workaround for now for my particular code base, thank you!

On Monday, May 18, 2015, Asa Ayers notifications@github.com wrote:

oh, this rule isn't warning you around where the error is produced (line
4) above. It's wrapping the error all the way from where the variable was
defined. This seems awkward but to use the built in capability to disable a
rule you need to use:

$ cat go.coffee
'use strict'

coffeelint: disable=variable_scope

x = 0 # Now this will suppress all errors that start on this line.

coffeelint: enable=variable_scope

-> x = 1
->
x = 1

CoffeeLint filters based on the first line, which is known for all
errors/warnings. implementation
https://github.com/clutchski/coffeelint/blob/master/src/coffeelint.coffee#L293-L315

I have no control over this project, I'm the maintainer of CoffeeLint. I
Sometimes subscribe to rules I don't use just to see what others are doing
with CoffeeLint.


Reply to this email directly or view it on GitHub
#7 (comment)
.

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

No branches or pull requests

2 participants