-
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
feat(gatsby): Add eslint rules to warn against bad patterns in pageTemplates (for Fast Refresh) #28689
Conversation
…se won't work with fast refresh
…n middle, not in the end)
…re-named-page-templates
…ed lowercase components
…re-named-page-templates
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 think it's fine to go? Please do go through the comments. Most things are improvements rather than problems. Some things are only problems if you say they are :)
...tests/development-runtime/cypress/integration/eslint-rules/limited-exports-page-templates.js
Show resolved
Hide resolved
packages/gatsby/src/utils/eslint-rules/limited-exports-page-templates.ts
Outdated
Show resolved
Hide resolved
packages/gatsby/src/utils/eslint-rules/limited-exports-page-templates.ts
Show resolved
Hide resolved
packages/gatsby/src/utils/eslint-rules/limited-exports-page-templates.ts
Outdated
Show resolved
Hide resolved
packages/gatsby/src/utils/eslint-rules/limited-exports-page-templates.ts
Outdated
Show resolved
Hide resolved
packages/gatsby/src/utils/eslint-rules/limited-exports-page-templates.ts
Outdated
Show resolved
Hide resolved
packages/gatsby/src/utils/eslint-rules/limited-exports-page-templates.ts
Show resolved
Hide resolved
packages/gatsby/src/utils/eslint-rules/limited-exports-page-templates.ts
Outdated
Show resolved
Hide resolved
packages/gatsby/src/utils/eslint-rules/no-anonymous-exports-page-templates.ts
Show resolved
Hide resolved
…t config (#28911) * feat(gatsby): add required eslint rules even if user has custom eslint config * handle case when extends is single string, add some tests * some extra existance checking * more exact checks for existance of eslint-loader rule * let's see if slash fixes win32 + env var for rules * another try * don't use slash after all Co-authored-by: LekoArts <lekoarts@gmail.com>
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.
Two cases are nits so I'd say merge with or without them applied.
Description
This adds new ESLint rules to our default configuration that enforce two things in page templates (so
src/pages/*
and pages created withcreatePage
):query
as a named exportAdditionally we also re-enabled the
pascalCase
rule (as it doesn't seem to trip up<Styled.p>
from theme-ui anymore.This all happens for Fast Refresh as it requires these code patterns to work correctly and without a full hard reload.
This PR will also include #28911
Old comment about Babel Plugin
This adds babel plugin to `develop` stage when fast-refresh is enabled that checks wether page template is hot reloadable with fast-refresh: - page template (default export) need to be named component (and it need to start with uppercase actually) - page template must not have additional exports (other than page query)Messages in Console:
TODO:
gatsby-plugin-eslint
. We don't "merge" eslint options and don't haverequiredRules
,defaultRules
kind of deal in same way we have for babelRelated Issues
[ch19773]
[ch22489]
[ch22491]