Describe the bug
This is a followup for https://github.com/thepracticaldev/dev.to/pull/2432
The *.jsx files inside app/javascript
still have a lot of bad practices according to eslint. That's why when you edit these files, eslint will throw you about 650 errors during the husky hook before commit.
To Reproduce
Steps to reproduce the behavior:
Go into app/javascript
and run eslint . --ext .jsx
Expected behavior
There shouldn't be any eslint errors.
Screenshots
I will start working on these errors after I refactored the issues codeclimate reported in https://github.com/thepracticaldev/dev.to/pull/2432
Thanks for reporting this and starting to refactor @venarius!
@venarius, still interested in helping out on this? It would be a great way to ease yourself into the codebase. Also, there are some a11y wins in here if we get this all cleaned up.
@jessleenyc, there are also regular JS files that have eslint errors. Should I create a separate ticket for those?
@nickytonline sure, I think that makes sense!
Hi @nickytonline, wanted to check in and see if this is still active? I can start working through these JSX files if so. Thanks!
@daningenthron please go ahead if you wish to work on a set of file. A recommendation: to make reviews easier and also curb the possibility of introducing bugs, is not to tackle too many files at the same time.
Thanks for your effort!
@rhymes Good points.
@daningenthron Would you like me to help? Would be a pleasure. :)
Hi @ruffle1986 that would be great! I globbed the JSX files and it looks like there are ~60 files affected. I think we can use the issue page to track where we're working, then submit individual PRs for individual directories (or subsets) to keep the review process lean. Definitely open to suggestions to improve the process.
Just to throw a dart at the map, I'll get started in /app/javascript/onboarding/components.
@daningenthron I'm going to ask you a huge favor, can you put the list here with all files or folders in a checkable list? Or you can just dump the list in a gist file and then I'll edit it out to add who's working on what.
I think having a centralized list with all the various PRs and users it's going to be hugely helpful for the effort
Thanks!
@daningenthron @rhymes Here's the list of the files with eslint issues:
@daningenthron @rhymes Alright. I'm gonna fix the files in the /app/javascript/article-form
folder and open a PR.
Is that ok with you?
@ruffle1986 :v: I would like to work on /app/javascript/listings/
if nobody is taking it. Thanks
@hoangvvo That would be great. Thank you, man! 馃嵒
@ruffle1986 Hi! I would like to work on app/javascript/src/components/
if it's free :)
I can't remember who is working on app/javascript/listings/elements/categories.jsx, but I made a small refactor where I destructure the array to make it clearer what the pieces are. See https://github.com/thepracticaldev/dev.to/pull/4257/files#diff-7783bfe5c15d16a3b1fd6a657339ff56R7. One of us will need to update depending on who gets merged first.
I can't remember who is working on app/javascript/listings/elements/categories.jsx, but I made a small refactor where I destructure the array to make it clearer what the pieces are. See https://github.com/thepracticaldev/dev.to/pull/4257/files#diff-7783bfe5c15d16a3b1fd6a657339ff56R7. One of us will need to update depending on who gets merged first.
I was working on it.
Hey, guys! I'm still waiting for answers in my PR for the article-form. Meanwhile I started working on /app/javascript/chat/
.
@hoangvvo @emimuresan Did you run the git pre-commit hooks when you committed your changes? It runs prettier and does changes according to the prettier config. For instance, There was a generic function to create a component for me but prettier simply just removed that and copy-and-pasted the same code three times. Now, this is what the code climate is complaining about in my case.
@rhymes Should I commit changes with the --no-verify
git flag in order to prevent Prettier from modifying my files? You can find these and other questions in my PR (#4217 ). If you have some free time, could you please answer those? Thank you in advance.
@ruffle1986 yep, i did not bypass the hooks, in my case i had no issues.
@ruffle1986
Should I commit changes with the --no-verify git flag in order to prevent Prettier from modifying my files?
what happens if you commit it with Prettier running?
You can find these and other questions in my PR (#4217 ). If you have some free time, could you please answer those? Thank you in advance.
I'll take a look, usually we don't review PRs that have the WIP
tag, it's a signal that it is indeed a work in progress and not ready for review. I'll check it promptly
@rhymes
what happens if you commit it with Prettier running?
It changes a lot of lines that are not related to issue I'm about to solve. It seems that these files were committed with the --no-verify tag in order to prevent Prettier from doing this previously. Is it ok with you that the PR includes these changes done by Prettier? I thought that it would a bit more difficult for the reviewers to focus on the eslint fixes only.
'll take a look, usually we don't review PRs that have the WIP tag, it's a signal that it is indeed a work in progress and not ready for review. I'll check it promptly
Sorry, my bad. Removed the WIP prefix.
@ruffle1986 maybe it can be done in a following PRs? so we don't drag those changes forever with the --no-verify
flag
@rhymes I'm gonna fix the files in the app/javascript/article-form/elements/moreConfig.jsx folder and open a PR.
4350 - PR
@rhymes @nickytonline can i take this /app/javascript/onboarding/components/EmailListTermsConditionsForm.jsx ?
@RakChamp25 It has been already taken by @daningenthron.
Here's his PR: https://github.com/thepracticaldev/dev.to/pull/4240/files#diff-6ef1acdc1504cf90b5ef7203ca78e590
Please check the list of files with lint issues and pick one that is not taken by anyone: https://github.com/thepracticaldev/dev.to/issues/2470#issuecomment-537845194
I am gonna fix this app/javascript/shared/components/tags.jsx
@rhymes PR link
@rhymes
I'll pick up
/app/javascript/sidebar-widget/SidebarWidget.jsx
/app/javascript/sidebar-widget/sidebarUser.jsx
/app/javascript/packs/sidebarWidget.jsx
@ruffle1986
Mind if I take a swing at /app/javascript/packs/articleForm.jsx ?
@kaoskater08 Not at all. Thanks! 馃嵒
@ruffle1986 I'll take /app/javascript/packs/Onboarding.jsx too....I just realized they are in the same folder 馃槃.
@ruffle1986 You need some help on /app/javascript/chat/
?
@netochaves That's very kind of you but I'm fine. I'm already done with the eslint issues. Now I'm fixing the failing snapshot tests. Sorry for the delay. :( Cheers 馃嵒
Hey Guys,
/app/javascript/githubRepos/githubRepos.jsx
is free to take ;)
Cheers 馃嵒
I'll take it @ruffle1986
@netochaves That's very kind of you but I'm fine. I'm already done with the eslint issues. Now I'm fixing the failing snapshot tests. Sorry for the delay. :( Cheers
No problem @ruffle1986. Great work on this issue btw
I'll take /app/javascript/listings/elements/title.jsx
too.
@ruffle1986 #4240 is still open, but I believe it has been addressed now by #4254. Do you see anything left in the original list that needs linting?
@daningenthron Nope, we're good. 馃嵒
@ruffle1986 /app/javascript/githubRepos/githubRepos.jsx
was fixed in #4496 too.
I've already done the eslint fixes for the chat in #4302
Waiting for review...
/app/javascript/shared/components/tags.jsx
is still there to be fixed. @RakChamp25 took it but he messed up something with the PR. @RakChamp25, would you like to give it another shot or it's free to steal?
I can take /app/javascript/shared/components/tags.jsx
if that's ok to @RakChamp25
yeah, I will give a chance to @ruffle1986 and take a chance to shot on /app/javascript/shared/components/tags.jsx
. Then I will check what you gonna update on that.
I am very curious what else you gonna update and learn on that, let see 馃槂
Hey guys, I saw that we still have some eslint erros on app/javascript/chat/userDetails.jsx
and /app/javascript/chat/content.jsx
I'll work on these files, if that's ok.
Sure @netochaves, thank you!
Hello, I solved some eslint errors on the files below. But I don't know if these errors were solved by someone else?
Hi @frkozbk, you're right, some files have been solved by other PRs. Some are still in need of fixing.
I'm updating the list here, feel free to claim whatever you prefer, I'll keep this list updated!
@rhymes Then I want to take these files.
/app/javascript/articles/Feed.jsx
/app/javascript/articles/LoadingArticle.jsx
/app/javascript/chat/article.jsx
/app/javascript/chat/channelDetails.jsx
/app/javascript/chat/channels.jsx
/app/javascript/onboarding/components/IntroSlide.jsx
/app/javascript/packs/homePage.jsx
/app/javascript/podcasts/PodcastFeed.jsx
/app/javascript/sidebar-widget/SidebarWidget.jsx
Should I send then in one pr or should I split them into different pr?
If you could split them in separate PRs that would be great. Much easier to check and get through. Thank you!
Can I help? I resolved this one #6491
I'm so sorry @frkozbk, I didn't notice this is in your list!
I'd really like to hop in on this. Where should I start?
I'd really like to hop in on this. Where should I start?
@twhite96, I ran eslint on the project and here are some issues that need addressing. Feel free to tackle whatever you like.
app/javascript/article-form/actions.js
23:5 error 'previewShowing' is assigned a value but never used no-unused-vars
24:5 error 'helpShowing' is assigned a value but never used no-unused-vars
25:5 error 'previewResponse' is assigned a value but never used no-unused-vars
26:5 error 'helpHTML' is assigned a value but never used no-unused-vars
27:5 error 'imageManagementShowing' is assigned a value but never used no-unused-vars
28:5 error 'moreConfigShowing' is assigned a value but never used no-unused-vars
29:5 error 'errors' is assigned a value but never used no-unused-vars
app/javascript/contentDisplayPolicy/hideBlockedContent.js
5:16 error 'userData' is not defined no-undef
5:28 error Expected exception block, space or tab after '//' in comment spaced-comment
app/javascript/article-form/elements/imageManagement.jsx
111:17 error 'err' is defined but never used. Allowed unused args must match /^_/u no-unused-vars
app/javascript/chat/channels.jsx
19:9 error 'newMessagesIndicator' is never reassigned. Use 'const' instead prefer-const
56:25 error Empty components are self-closing react/self-closing-comp
56:31 error Unknown property 'class' found, use 'className' instead react/no-unknown-property
56:122 error `{channel.channel_name}` must be placed on a new line react/jsx-one-expression-per-line
app/javascript/chat/chat.jsx
274:11 error Use object destructuring prefer-destructuring
623:9 error Expected property shorthand object-shorthand
640:15 error Unexpected string concatenation prefer-template
648:15 error Unexpected string concatenation prefer-template
1053:18 warning Unexpected unnamed function func-names
1165:11 error Expected indentation of 8 space characters but found 10 react/jsx-indent
app/javascript/chat/content.jsx
8:5 error Prop type `object` is forbidden react/forbid-prop-types
8:5 error propType "resource" is not required, but has no corresponding defaultProps declaration react/require-default-props
9:5 error 'activeChannelId' PropType is defined but prop is never used react/no-unused-prop-types
9:5 error propType "activeChannelId" is not required, but has no corresponding defaultProps declaration react/require-default-props
10:5 error 'pusherKey' PropType is defined but prop is never used react/no-unused-prop-types
10:5 error propType "pusherKey" is not required, but has no corresponding defaultProps declaration react/require-default-props
11:5 error propType "fullscreen" is not required, but has no corresponding defaultProps declaration react/require-default-props
15:10 error Must use destructuring props assignment react/destructuring-assignment
18:28 error Must use destructuring props assignment react/destructuring-assignment
18:161 error `path` must be placed on a new line react/jsx-one-expression-per-line
18:222 error A space is required before closing bracket react/jsx-tag-spacing
18:224 error `path` must be placed on a new line react/jsx-one-expression-per-line
18:337 error A space is required before closing bracket react/jsx-tag-spacing
18:457 error `path` must be placed on a new line react/jsx-one-expression-per-line
18:518 error A space is required before closing bracket react/jsx-tag-spacing
18:520 error `path` must be placed on a new line react/jsx-one-expression-per-line
18:638 error A space is required before closing bracket react/jsx-tag-spacing
20:7 error Visible, non-interactive elements with click handlers must have at least one keyboard listener jsx-a11y/click-events-have-key-events
20:7 error Static HTML elements with event handlers require a role jsx-a11y/no-static-element-interactions
23:18 error Must use destructuring props assignment react/destructuring-assignment
23:29 error 'onTriggerContent' is missing in props validation react/prop-types
25:9 error Missing an explicit type attribute for button react/button-has-type
29:114 error `path` must be placed on a new line react/jsx-one-expression-per-line
29:169 error A space is required before closing bracket react/jsx-tag-spacing
29:171 error `path` must be placed on a new line react/jsx-one-expression-per-line
29:329 error A space is required before closing bracket react/jsx-tag-spacing
31:9 error Missing an explicit type attribute for button react/button-has-type
38:10 error 'display' was used before it was defined no-use-before-define
44:10 error Expected to return a value at the end of function 'display' consistent-return
60:31 error Must use destructuring props assignment react/destructuring-assignment
app/javascript/chat/videoContent.jsx
6:10 error Must use destructuring props assignment react/destructuring-assignment
6:21 error 'videoPath' is missing in props validation react/prop-types
9:28 error Must use destructuring props assignment react/destructuring-assignment
9:39 error 'fullscreen' is missing in props validation react/prop-types
9:161 error `path` must be placed on a new line react/jsx-one-expression-per-line
9:222 error A space is required before closing bracket react/jsx-tag-spacing
9:224 error `path` must be placed on a new line react/jsx-one-expression-per-line
9:337 error A space is required before closing bracket react/jsx-tag-spacing
9:457 error `path` must be placed on a new line react/jsx-one-expression-per-line
9:518 error A space is required before closing bracket react/jsx-tag-spacing
9:520 error `path` must be placed on a new line react/jsx-one-expression-per-line
9:638 error A space is required before closing bracket react/jsx-tag-spacing
11:7 error Visible, non-interactive elements with click handlers must have at least one keyboard listener jsx-a11y/click-events-have-key-events
11:7 error Static HTML elements with event handlers require a role jsx-a11y/no-static-element-interactions
14:18 error Must use destructuring props assignment react/destructuring-assignment
14:29 error 'onTriggerVideoContent' is missing in props validation react/prop-types
16:9 error Missing an explicit type attribute for button react/button-has-type
20:114 error `path` must be placed on a new line react/jsx-one-expression-per-line
20:169 error A space is required before closing bracket react/jsx-tag-spacing
20:171 error `path` must be placed on a new line react/jsx-one-expression-per-line
20:329 error A space is required before closing bracket react/jsx-tag-spacing
22:9 error Missing an explicit type attribute for button react/button-has-type
29:9 error <iframe> elements must have a unique title property jsx-a11y/iframe-has-title
29:22 error Must use destructuring props assignment react/destructuring-assignment
29:33 error 'videoPath' is missing in props validation react/prop-types
app/javascript/listings/dashboard/rowElements/location.jsx
5:51 error `銉籤 must be placed on a new line react/jsx-one-expression-per-line
5:52 error `{location}` must be placed on a new line react/jsx-one-expression-per-line
app/javascript/packs/homePageFeed.jsx
95:15 error Value must be omitted for boolean attributes react/jsx-boolean-value
app/javascript/packs/videoChat.jsx
1:1 error Expected 1 empty line after require statement not followed by another require import/newline-after-import
7:67 error Expected exception block, space or tab after '//' in comment spaced-comment
10:29 error 'participantConnected' was used before it was defined no-use-before-define
11:35 error 'participantConnected' was used before it was defined no-use-before-define
13:38 error 'participantDisconnected' was used before it was defined no-use-before-define
14:29 error 'error' is defined but never used. Allowed unused args must match /^_/u no-unused-vars
14:64 error 'participantDisconnected' was used before it was defined no-use-before-define
15:24 warning Unexpected unnamed function func-names
17:47 warning Unexpected unnamed function func-names
32:31 warning Unexpected unnamed function func-names
34:47 warning Unexpected unnamed function func-names
63:19 error Unexpected string concatenation prefer-template
64:19 error Unexpected string concatenation prefer-template
64:19 error Multiline support is limited to browsers supporting ES5 only no-multi-str
65:63 error Multiline support is limited to browsers supporting ES5 only no-multi-str
70:46 error 'trackSubscribed' was used before it was defined no-use-before-define
71:39 error 'trackUnsubscribed' was used before it was defined no-use-before-define
73:44 error 'trackDisabled' was used before it was defined no-use-before-define
74:43 error 'trackEnabled' was used before it was defined no-use-before-define
78:7 error 'trackSubscribed' was used before it was defined no-use-before-define
app/javascript/podcasts/TodaysPodcasts.jsx
6:10 error Unknown property 'class' found, use 'className' instead react/no-unknown-property
7:11 error Unknown property 'class' found, use 'className' instead react/no-unknown-property
app/javascript/shared/components/tags.jsx
401:11 warning Dangerous property 'dangerouslySetInnerHTML' found react/no-danger
app/javascript/src/utils/getUnopenedChannels.jsx
45:49 error Unexpected string concatenation prefer-template
45:53 error 'userData' is not defined no-undef
50:54 error Unexpected string concatenation prefer-template
@nickytonline okay. Was interviewing there for a bit. Will spin this up in Docker and work on it.
We've fixed all the linting issues in JSX files.
Most helpful comment
@daningenthron @rhymes Here's the list of the files with eslint issues: