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

refactor: remove sub-eslintrc, fix more lint errors #7530

Merged
merged 1 commit into from
May 30, 2022
Merged

Conversation

Josh-Cena
Copy link
Collaborator

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

Little refactors, fix more errors.

I also included the type-aware configs as commented-out lines, so it can be more easily enabled in the future.

Test Plan

Test links

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

Related issues/PRs

@Josh-Cena Josh-Cena added the pr: internal This PR does not touch production code, or is not meaningful enough to be in the changelog. label May 30, 2022
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label May 30, 2022
@netlify
Copy link

netlify bot commented May 30, 2022

[V2]

Name Link
🔨 Latest commit 7b7dfbc
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/6294664158d6c50009aeeafe
😎 Deploy Preview https://deploy-preview-7530--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
/ 🟠 65 🟢 100 🟢 100 🟢 100 🟢 90 Report
/docs/installation 🟠 84 🟢 99 🟢 100 🟢 100 🟢 90 Report

@github-actions
Copy link

Size Change: -1 B (0%)

Total Size: 797 kB

ℹ️ View Unchanged
Filename Size Change
website/.docusaurus/globalData.json 52.5 kB 0 B
website/build/assets/css/styles.********.css 106 kB 0 B
website/build/assets/js/main.********.js 600 kB -1 B (0%)
website/build/index.html 38.9 kB 0 B

compressed-size-action

@Josh-Cena Josh-Cena merged commit 9023b77 into main May 30, 2022
@Josh-Cena Josh-Cena deleted the jc/fix-lint branch May 30, 2022 06:49
Comment on lines +33 to +40
// A very implicit API: we allow users to hand-write the toc variable. It will
// get overwritten in most cases, but until we find a better way, better keep
// supporting this
it('does not overwrite TOC var if no TOC', async () => {
const result = await processFixture('no-heading-with-toc-export');
expect(result).toMatchSnapshot();
});

Copy link
Collaborator

Choose a reason for hiding this comment

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

@Josh-Cena I don't understand why this behavior was implemented.

As far as I understand:

Manually exported toc will be overriden by remark toc if there are headings:

## heading

export const toc = [{}]

Manually exported toc won't be overriden by remark toc if there's no heading

export const toc = [{}]

Why would we want 2 different behaviors here?

I'd like to get rid of one and always let the user override the toc with an explicit export.

Asking for #9684

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@slorber: It was implemented to support hand-writing TOC in very edge cases, such as importing partials, using exclusively JSX headings, and such. I think I implemented it this way, because if a user both has hand-written and existing TOC, it is more likely that they should be merged, but I'm okay with always-overriding behavior too. I just thought this is the least surprising for the time being.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks @Josh-Cena

After my refactor the logic is much easier to understand, and now feels a bit awkward to me.

CleanShot 2024-01-19 at 01 15 57@2x

I'll probably update this behavior and a few other things in another PR, for now I kept the existing behavior although 2 things surprised me:

  • exporting the toc after the last import (instead of always at the end)
  • overriding user explicit toc only if any heading is found

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

exporting the toc after the last import (instead of always at the end)

This has always been the case, which surprised me too because it's extra work.

overriding user explicit toc only if any heading is found

Which to me is a slight improvement over always overriding explicit TOC, although I agree always respecting explicit TOC is probably the most reasonable.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks, I'll do those 2 changes in upcoming PRs.

I guess the toc override can be considered as a breaking change and should better be planned for v4? Or do you think it's fine for v3? I'm not sure since we never really documented this behavior anywhere so it might as well be a bugfix to make the behavior consistent.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it has always remained an implementation detail, and while we did recommend using export toc = [...toc1, ...toc2] for the "barrel of partials" case before, this use case will keep working. I don't think anyone will expect their explicit TOC to be overridden.

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: internal This PR does not touch production code, or is not meaningful enough to be in the changelog.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants