-
-
Notifications
You must be signed in to change notification settings - Fork 136
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
[Snippets] Added 20 new JavaScript snippets across multiple categories #229
Conversation
|
||
```js | ||
function combineArrays(array1, array2) { | ||
return array1.concat(array2); |
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.
This snippet does not quite align with QuickSnip guidelines, as is simply a wrapper for a standard library of JS
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.
I'll remove this one if requested by a reviewer with write access
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.
@ACR1209 i right, this doesn't align at all with quicksnip guidelines, Please read them it's something that's written in them
```js | ||
function addClass(element, className) { | ||
if (element && className) { | ||
element.classList.add(className); |
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.
The classList.add()
method already does the intended functionality you're presenting
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.
typing element.classList.add() is longer than addClass() which is why I'm including it this way
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.
I get it! 💯
This is the same as my response on .remove()
, so we could just keep the thread there if you'll like as is an interesting boundary to comment on 😀
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.
Snippet shouldn't wrap around an std functionality, even if the function name is 10x longer, Also valid for the .remove()
one too
```js | ||
function removeClass(element, className) { | ||
if (element && className) { | ||
element.classList.remove(className); |
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.
The classList.remove()
method already does the intended functionality you're presenting
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.
typing element.classList.remove() is longer than removeClass() which is why I'm including it this way
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.
I understand your point 💯
But at the end of the day, is a difference of 4 characters and removes the option of multi argument class removal. Plus adds a bit more bloat to the code base.
This was common with IE10 as it did throw errors
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.
Same as for add-a-css-class-to-an-element
.
--- | ||
|
||
```js | ||
localStorage.clear(); |
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.
This is simply a usage of a language standard function
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.
I included this considering that C:\xampp\htdocs\quicksnip\snippets\javascript\basics\hello-world.md is essentially also just a standard language function
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.
Yeah, you're definitely right on that, hello worlds are a kinda of the exception to the rule I think.
But for the rest of snippets we do consider the contributing guidelines "Does the standard library of my language provide an easy way of doing this ?" boundary
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.
If requested by a reviewer with write access, I will remove this
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.
ACR is right, Btw I've noticed you are not taking feedback from the community Even when it's backed by the guidelines, The community has an important role into the reviewing process, please take them a bit more into account.
Hello world, is infact a specific snippet, and it should be (in most cases) the only one of it's "type", so no, as per the guidelines, this doesn't qualify as a snippet
I think the validation snippets would be better placed under the regex category |
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.
Thanks for the contribution, please take a look at my feedbacks bellow.
I've noticed some other issues:
- all of the stuff in the
validation
category doesn't really belong here, and fits more the scope of theregex
language. - You've created lots of snippets that just wrap over something an std function, your argument of length of call isn't really something we take into account.
Please take into account feedback of the community, and avoid responding "Waiting for a write access reviewer to confirm". Yes we have the "final" say in what to do or not do, but when the feedback is backed by the guidelines take it into account
|
||
```js | ||
function combineArrays(array1, array2) { | ||
return array1.concat(array2); |
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.
@ACR1209 i right, this doesn't align at all with quicksnip guidelines, Please read them it's something that's written in them
```js | ||
function addClass(element, className) { | ||
if (element && className) { | ||
element.classList.add(className); |
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.
Snippet shouldn't wrap around an std functionality, even if the function name is 10x longer, Also valid for the .remove()
one too
```js | ||
function removeClass(element, className) { | ||
if (element && className) { | ||
element.classList.remove(className); |
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.
Same as for add-a-css-class-to-an-element
.
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.
Same as add-a-css-class-to-an-element
--- | ||
|
||
```js | ||
localStorage.clear(); |
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.
ACR is right, Btw I've noticed you are not taking feedback from the community Even when it's backed by the guidelines, The community has an important role into the reviewing process, please take them a bit more into account.
Hello world, is infact a specific snippet, and it should be (in most cases) the only one of it's "type", so no, as per the guidelines, this doesn't qualify as a snippet
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.
Same as for the others, it just wraps over an std function, it adds a little bit of functionnality over it... But this functionnality isn't the main goal of the snippet, so in it's current state it's not valid
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.
Already exists as merge-objects-deeply
Closed, will make a different pr at a later date. |
Description
Added 20 new code snippets for JavaScript across 6 categories.
Validation
Color Manipulation
Local Storage
DOM Manipulation
Array Manipulation
Object Manipulation
Type of Change
Checklist
Related Issues
None
Additional Context
I tried to cram a lot into this one because I want to help out a lot. I will probably make something for different languages soon though, so be on the look out.