-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor #27
Refactor #27
Conversation
Current coverage is
|
Personally, I'm all for exposing a module's method to be used as a lib 👍 But to be honest, I would have rather just So, I'm really unsure whether to refactor it exactly this way, and I tend towards declining it. |
@ta2edchimp thanks for sharing your concerns.
Me too, the proposed code is pseudo-functional/pseudo-object-orieneted, if I may say so. All the computation is purely functional. It does not depends on the
In fact, its similar to var config = binUtils.getConfig(process.argv[2])
var currentRules = binUtils.getCurrentRules(config)
var pluginRules = binUtils.getPluginRules(config) The only reason to wrap the above stated computation in The only drawback I see in the proposed approach is var ruleFinder = new RuleFinder(specifiedFile)
var newRules = ruleFinder.getNewRules() If any changes takes place between those two statement, for example, But it would be a rare scenario. var config = binUtils.getConfig(process.argv[2])
var currentRules = binUtils.getCurrentRules(config)
var pluginRules = binUtils.getPluginRules(config) However we could stick to pure functional and always |
Well I actually think of this approach to not take changes into account as a real advantage! Well, could we at least think of letting the module expose a factory function to return the desired tl;dr, sth like this (shortened heavily): function getRuleFinder(specifiedFile) {
// the private stuff ...
return {
// prop shorthand notation only for demo purposes
getCurrentRules() {
return currentRules
},
getPluginRules() {
return pluginRules
},
getAllAvailableRules() {
return allRules
},
getNewRules() {
return newRules
}
}
}
module.exports = getRuleFinder I also think about whether something like What do you think? PS: Sorry if I may sound a bit ranting at times, it is absolutely not intended, but as not being a native speaker, it's just hard sometimes to express exactly what I mean 😜 |
Me neither, for
👍 Totally, I am bad with, naming things.
How about? module.exports = function(specifiedFile) {
return new RuleFinder(specifiedFile)
} |
I'd be fine with that! Just for the sake of completeness, I'd do module.exports = function getRuleFinder(specifiedFile) {
return new RuleFinder(specifiedFile)
} or |
@ta2edchimp could you take another look? |
Will have a thorough look tomorrow (only on the phone atm), but looks good to me as far as I can tell now, and will probably going to merge, when @kentcdodds has nothing to add 😃 |
Some things that we have to consider prior to merging:
Had to track this here to not forget until tomorrow as I'm almost 😴 |
for encapsulation and state BREAKING CHANGE: the API has changed from findNewRules(currentRules, pluginRules) to getRuleFinder('path/to/eslint-config').getUnusedRules()
@ta2edchimp Thanks for pointing out.
Please have look, and let me know, if any changes required. Thanks!! |
LGTM |
LGTM too. 👍 |
The binary interface has not been changed. However if one would prefer to
require
the module, below exposed APIs are available.getCurrentRules // get all the current rules instead of referring the extended files or documentation
getPluginRules // get all the plugin rules instead of referring the extended files or documentation
getAllAvailableRules // get all the availale rules instead of referring eslint and pluging packages or documentation
getNewRules
I look forward to your concerns. 🐰 Happy Easter! 🐰