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

chore: prevent importing theme components with relative paths #7674

Merged
merged 2 commits into from
Jun 24, 2022

Conversation

slorber
Copy link
Collaborator

@slorber slorber commented Jun 24, 2022

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

ESLint should detect when using relative component imports between theme components

Also, we want to ensure consistent naming/usage of CSS module files

Test Plan

CI

Test links

Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/

Related issues/PRs

@slorber slorber added the pr: maintenance This PR does not produce any behavior differences to end users when upgrading. label Jun 24, 2022
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jun 24, 2022

.docusaurus-mt-lg {
/* Docusaurus-specific utility class */
:global(.docusaurus-mt-lg) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really liking this solitary utility class 🤪 maybe we should just duplicate the rule everywhere 🤷‍♂️

@@ -16,7 +16,7 @@ import {
import BlogLayout from '@theme/BlogLayout';
import TagsListByLetter from '@theme/TagsListByLetter';
import type {Props} from '@theme/BlogTagsListPage';
import SearchMetadata from '../SearchMetadata';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now catched with error

/Users/sebastienlorber/Desktop/projects/docusaurus/packages/docusaurus-theme-classic/src/theme/BlogTagsListPage/index.tsx
19:1 error '../SearchMetadata' import is restricted from being used by a pattern no-restricted-imports

@netlify
Copy link

netlify bot commented Jun 24, 2022

[V2]

Name Link
🔨 Latest commit c26c3cf
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/62b5c602f5a6bd0009171a6e
😎 Deploy Preview https://deploy-preview-7674--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions
Copy link

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 70 🟢 100 🟢 100 🟢 100 🟢 90 Report
/docs/installation 🟢 91 🟢 100 🟢 100 🟢 100 🟢 90 Report

@Josh-Cena Josh-Cena changed the title chore: ESLint should prevent bad them relative imports chore: prevent importing theme components with relative paths Jun 24, 2022
@github-actions
Copy link

Size Change: +52 B (0%)

Total Size: 802 kB

Filename Size Change
website/build/assets/js/main.********.js 604 kB +31 B (0%)
ℹ️ View Unchanged
Filename Size Change
website/.docusaurus/globalData.json 52.6 kB 0 B
website/build/assets/css/styles.********.css 107 kB +4 B (0%)
website/build/index.html 38.9 kB +17 B (0%)

compressed-size-action

Copy link
Collaborator

@Josh-Cena Josh-Cena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wanted to do the same 👍

@slorber slorber merged commit 90a8ca3 into main Jun 24, 2022
@slorber slorber deleted the slorber/theme-prevent-relative-imports branch June 24, 2022 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: maintenance This PR does not produce any behavior differences to end users when upgrading.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants