-
Notifications
You must be signed in to change notification settings - Fork 889
Implement a "react" option for the no-unused-variable rule #725
Conversation
Rebased against |
@jkillian @adidahiya just rebased this |
Ideally, it would be nicer to just accept one option named 'react' and not worry about prefixes. Especially since React 0.14 moved addons to their own npm packages (and hopefully bower packages?). Are there any other legit use cases other than 'react' and 'react/addons'? |
Not sure, hence why I coded a bit more defensively here... but on reflection it's much simpler to have the modules I'll push up another commit that makes that change... then we can choose between the two (and then squash commits) |
* use it as npm test * waits for jsx react commit: palantir/tslint#725
* not fully waiting for PR merge to master: palantir/tslint#725
I'd prefer only supporting |
Why not support both? I assume using |
Sorry, I should've been more clear -- I would like the rule option to be named |
Oh gotchya. I was thinking have the option be named |
hi folks. I just found this discussion as I saw the same thing in my project. I also have |
@Jazzik Can you post an example of your code? I believe as long as it's not private, you shouldn't get that error. Something like this shouldn't give a lint error:
|
@jkillian oh right, I had it as private 😊 |
* use it as npm test * waits for jsx react commit: palantir/tslint#725
* not fully waiting for PR merge to master: palantir/tslint#725
@jkillian @adidahiya pushed up a second commit with a single |
@adidahiya @jkillian - any thoughts on this? Only reason for me pushing is that we've got a whole load of |
@@ -16,8 +16,13 @@ | |||
import * as Lint from "../lint"; | |||
import * as ts from "typescript"; | |||
|
|||
const OPTION_REACT = "react"; | |||
const OPTION_REACT_MODULES = ["react", "react/addons"]; | |||
const OPTION_REACT_NAMESPACE_IMPORT_NAME = "React"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can these two consts not start with OPTION_
? I think that should be reserved only for actual options which are provided to the rule
// a) seen another usage of React and/or | ||
// b) seen a JSX identifier | ||
// | ||
// otherwise a usage error will be reported |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change this to "... a variable usage failure will ..."
"error" is ambiguous in JS, so we should stick to the "failure" terminology.
@adidahiya - all points addressed in most recent push. Apologies, a number of the whitespace changes crept in because my editor automatically runs |
Implement a "react" option for the no-unused-variable rule
Addresses #698
With such a valid option, the following is not an error:
Thoughts/comments?