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

Add style linter to pre-commit, and run #1764

Closed
wants to merge 2 commits into from

Conversation

gabalafou
Copy link
Collaborator

No description provided.

@gabalafou
Copy link
Collaborator Author

Note: this did not pick up the bug fixed in #1761. Why? A selector of the form html .something (newline) html .something is not invalid. I'm not exactly sure what kind of linter rule one would write to pick up that kind of bug.

@gabalafou
Copy link
Collaborator Author

Should this PR be separated? One commit that adds stylelint, another that runs the linter?

Copy link
Collaborator Author

@gabalafou gabalafou left a comment

Choose a reason for hiding this comment

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

Finished self reviewing. May need to make a couple changes before this can be safely merged.

// Thickness of the underline for links
// the default will be either:
// - 1px
// - 0.0625rem if it's thicker than 1px because the user has changed the text
// size in their browser
$link-underline-thickness: unquote("max(1px, .0625rem)") !default;
$link-underline-thickness: string.unquote("max(1px, .0625rem)") !default;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

is string.unquote even necessary here? I don't understand what it's doing

Copy link
Collaborator

@trallard trallard Apr 29, 2024

Choose a reason for hiding this comment

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

Yes, the unquote is necessary when compiling this will result in max(1px, .0625rem) which is a valid identifier.

Comment on lines +11 to +12
user-select: text; /* Safari fallback only */ /* Chrome/Safari */ /* Firefox */
user-select: none; /* IE10+ */
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This might need some modification

Copy link
Collaborator

Choose a reason for hiding this comment

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

Think it should be user-select: text; right? Unless I am missing something https://developer.mozilla.org/en-US/docs/Web/CSS/user-select#browser_compatibility

@include icon-navbar-hover;
@include focus-indicator;
}

// Hide the navbar header items on mobile because they're in the sidebar
// stylelint-disable-next-line no-duplicate-selectors
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Didn't feel easy and safe to move these rules so I left the duplicate selector

@@ -163,6 +166,7 @@
*/

// Hide the header items on mobile
// stylelint-disable-next-line no-duplicate-selectors
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Didn't feel easy and safe to move these rules so I left the duplicate selector

Comment on lines +35 to +39
--pst-font-family-base-system: -apple-system, blinkmacsystemfont, segoe ui,
"Helvetica Neue", arial, sans-serif, apple color emoji, segoe ui emoji,
segoe ui symbol;
--pst-font-family-monospace-system: "SFMono-Regular", menlo, consolas, monaco,
liberation mono, lucida console, monospace;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No idea why the linter wanted to lower case all of the unquoted font names 🤷‍♂️

Copy link
Collaborator

Choose a reason for hiding this comment

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

Does it work with all lowercase?
This seems like a hard rule of making all nonn-quoted strings a valid identifier, but I am not sure this applies to Fonts.

Copy link
Collaborator

@Carreau Carreau left a comment

Choose a reason for hiding this comment

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

Not an expert, but looks good to me.

I'm astonished the pseudo selector : vs :: worked !

@gabalafou
Copy link
Collaborator Author

I'm astonished the pseudo selector : vs :: worked !

The linter is being pedantic (as linters do). Browsers accept both :before (older standard)) and ::before (newer standard). See note on MDN ::before article.

@trallard trallard added the kind: maintenance Improving maintainability and reducing technical debt label Apr 18, 2024
Copy link
Collaborator

@trallard trallard left a comment

Choose a reason for hiding this comment

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

Thanks @gabalafou left a couple of comments. I agree it might be worth splitting this in 1) adding the linter 2) run the linter as we have a whole lot of changes here

Comment on lines +11 to +12
user-select: text; /* Safari fallback only */ /* Chrome/Safari */ /* Firefox */
user-select: none; /* IE10+ */
Copy link
Collaborator

Choose a reason for hiding this comment

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

Think it should be user-select: text; right? Unless I am missing something https://developer.mozilla.org/en-US/docs/Web/CSS/user-select#browser_compatibility

Comment on lines +293 to +296
img:not(.only-dark, .dark-light) {
filter: brightness(0.8) contrast(1.2);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

For another time, this would need revisiting with all the a11y work in flight

Comment on lines +35 to +39
--pst-font-family-base-system: -apple-system, blinkmacsystemfont, segoe ui,
"Helvetica Neue", arial, sans-serif, apple color emoji, segoe ui emoji,
segoe ui symbol;
--pst-font-family-monospace-system: "SFMono-Regular", menlo, consolas, monaco,
liberation mono, lucida console, monospace;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does it work with all lowercase?
This seems like a hard rule of making all nonn-quoted strings a valid identifier, but I am not sure this applies to Fonts.

@jarrodmillman
Copy link
Collaborator

jarrodmillman commented May 1, 2024

@gabalafou Before merging this, it would be great if you could rebase and then add a third commit adding the commit corresponding to "fix errors emitted by style linter" to
https://github.com/pydata/pydata-sphinx-theme/blob/main/.git-blame-ignore-revs

We will need to enable and use "Create a merge commit". Otherwise the commit in .git-blame-ignore-revs will be wrong.

@gabalafou
Copy link
Collaborator Author

@jarrodmillman will do, thanks for the tip!

@drammock
Copy link
Collaborator

drammock commented May 1, 2024

@gabalafou Before merging this, it would be great if you could rebase and then add a third commit adding the commit corresponding to "fix errors emitted by style linter" to https://github.com/pydata/pydata-sphinx-theme/blob/main/.git-blame-ignore-revs

We will need to enable and use "Create a merge commit". Otherwise the commit in .git-blame-ignore-revs will be wrong.

@jarrodmillman since we typically squash-merge, I would suggest this workflow instead:

  1. (rebase and) merge this one edit: with just the addition of the linter, not the fixes, as suggested in Add style linter to pre-commit, and run  #1764 (comment)
  2. do another PR that fixes the linter-discovered errors, and merge it
  3. do a third PR that adds the hash of (2) to .git-blame-ignore-revs

The advantage is that whoever does the merging doesn't need to have the repo-admin permissions to change our merge strategy, and doesn't need to remember to change it back afterwards.

@gabalafou gabalafou mentioned this pull request May 17, 2024
@gabalafou
Copy link
Collaborator Author

This work is picked up in #1823.

@gabalafou gabalafou closed this May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: maintenance Improving maintainability and reducing technical debt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants