-
Notifications
You must be signed in to change notification settings - Fork 533
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 of force nested rules to remove duplication #323
Refactor of force nested rules to remove duplication #323
Conversation
…ass-lint into feature/refactor-force-rules
…ass-lint into feature/refactor-force-rules
Maybe we consider pulling in underscore.string so we don't need to maintain string manipulation functions on our own. Thoughts?
|
Sure makes sense. I'll pull it in and replace the capitalise helper function. |
Ok, by requiring the |
Is there any particular reason you went with Underscore over Lodash? Just curious. I guess @Snugug would be the one to ask. I like that Lodash will let us have per-method dependencies so that the footprint of our tool is as small as possible. |
The library is called underscore.string but is not underscore
|
Sorry, thanks for clarifying. But I think my argument still holds. I see that |
I agree, I was looking through and we're pulling in a lot of functions in that dependency that we don't need or use. Being able to pull in only the functions we require as a dependency would be favourable over a whole library. |
Completely open on the which library front and happy to pull in individual functions with |
Individual functions would be better than the whole library each time I would say. |
Done! |
I don't mean to be too picky here, as which library we use isn't an important area to devote our time, IMO. But to clarify what I meant about Lodash function-specific dependency: There is a separate NPM module for each of Lodash's functions, so the project itself only depends on the functions within Lodash that you use. So we'd change If you look carefully at the dependencies of many npm packages, you'll see fewer instances of dependency on Lodash and more on specific Lodash functions. Just wanted to clarify. No need to spend time changing things. |
Don't worry @benthemonkey I knew what you meant 😉 |
Thanks for clarifying (and sticking with me 😛) @benthemonkey I see a clear advantage now so happy to go with your approach if everyone's in agreement. |
Update me! |
Refactor of force nested rules to remove duplication
…e-rules Refactor of force nested rules to remove duplication
PR removes a lot of duplicated functionality from the three force nested rules (
force-pseudo-nesting
,force-element-nesting
andforce-attribute-nesting
).It's decreased the amount of code in each rule by 50% through the creation of 2 new helper functions (
isNestable
andconstructSelector
) and a slight refactor of the rule code.It adds 2 other helper functions (capitalize
andcamelCaseToHyphens
) to assist with improving the formatting of the warning messages from these three rules.Update: 2 string helper functions to improve the formatting of warning messages have been removed and replaced with underscore.string library.
DCO 1.1 Signed-off-by: Ben Griffith gt11687@gmail.com