Skip to content
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

Merged
merged 5 commits into from
May 18, 2020
Merged

Conversation

tesseralis
Copy link
Contributor

@tesseralis tesseralis commented May 16, 2020

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.

@tesseralis tesseralis requested review from a team as code owners May 16, 2020 00:18
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label May 16, 2020
Comment on lines +82 to +90
{
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" }],
},
},
Copy link
Contributor

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.

Copy link
Contributor

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

Copy link
Contributor Author

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!

Copy link
Contributor

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

Copy link
Contributor Author

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.

@pieh pieh removed the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label May 18, 2020
Copy link
Contributor

@pieh pieh left a 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)

@tesseralis tesseralis added the bot: merge on green Gatsbot will merge these PRs automatically when all tests passes label May 18, 2020
@gatsbybot gatsbybot merged commit 96a8abb into master May 18, 2020
@delete-merged-branch delete-merged-branch bot deleted the eslint-www branch May 18, 2020 23:53
@fk
Copy link
Contributor

fk commented May 19, 2020

💜 ❤️ 🧡 💛 💚 💙

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: merge on green Gatsbot will merge these PRs automatically when all tests passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants