-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
maintenance(www): Get eslint to work on www again #24133
Conversation
{ | ||
files: ["www/**/*"], | ||
rules: { | ||
// We need to import React to use the Fragment shorthand (`<>`). | ||
// When we use theme-ui's JSX pragma, it lists React as an unused var | ||
// even though it's still needed. | ||
"no-unused-vars": ["error", { varsIgnorePattern: "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.
Could we instead of ignoring React
use <React.Fragment>
instead of shorthand (at least in files that use jsx pragma)? Not a blocker for this PR, just food for thought.
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.
For reference for other folks checking this out - this is workaround for emotion-js/emotion#1549 / jsx-eslint/eslint-plugin-react#2156
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 can make an issue for it and assign it to the community!
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.
When I ran this locally on www/src
(after commenting out this override) I got 7 errors:
yarn eslint --ext .js,.jsx,.ts,.tsx www/src
yarn run v1.21.0
$ /mnt/d/dev/gatsby-mbp/node_modules/.bin/eslint --ext .js,.jsx,.ts,.tsx www/src
/mnt/d/dev/gatsby-mbp/www/src/components/docs-markdown-page.js
3:8 error 'React' is defined but never used no-unused-vars
/mnt/d/dev/gatsby-mbp/www/src/components/guidelines/nav-item.js
3:8 error 'React' is defined but never used no-unused-vars
/mnt/d/dev/gatsby-mbp/www/src/components/layout.js
3:8 error 'React' is defined but never used no-unused-vars
/mnt/d/dev/gatsby-mbp/www/src/components/showcase-details.js
3:8 error 'React' is defined but never used no-unused-vars
/mnt/d/dev/gatsby-mbp/www/src/pages/plugins.js
3:8 error 'React' is defined but never used no-unused-vars
/mnt/d/dev/gatsby-mbp/www/src/templates/template-docs-markdown.js
3:8 error 'React' is defined but never used no-unused-vars
/mnt/d/dev/gatsby-mbp/www/src/views/creators/index.js
3:8 error 'React' is defined but never used no-unused-vars
✖ 7 problems (7 errors, 0 warnings)
(some of them don't even use <>
fragments)
I don't have strong opinion on ignoring this rule vs forcing to use long-hand (<React.Fragment>
) - I do however see having to use longer form annoying (on top of devs not being aware of this problem being confused by those eslint errors) so I'd rather track eslint-plugin-react
issue and remove the override once it's fixed upstream
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.
Sure, that's fine as well.
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.
Looks great!
Would be nice to not have to ignore React
for no-unused-vars
rule, but having linting (and (auto)formatting) enabled for most of things is better than current state, so we should get this in as-is (IMO)
💜 ❤️ 🧡 💛 💚 💙 |
Description
Re-enable code formatting on
www
through eslint/prettier.Linting on
www
hasn't been working since #20246. This re-enables linting/formatting on the site and fixes some of the formatting errors that have accumulated since then.