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

Implement Stylelint linting of CSS logical properties #4023

Merged

Conversation

kommunarr
Copy link
Collaborator

@kommunarr kommunarr commented Sep 10, 2023

Implement Stylelint linting of CSS logical properties

Pull Request Type

  • Feature Implementation

Related issue

See #3970 (comment)

Description

This change implements the Stylelint plugin stylelint-use-logical-spec with all rules enabled except for requiring float: inline-start and float: inline-end, which as of today is still an experimental feature in Chrome.

To prevent current issues blocking contributors going forward, this PR also enacts this rule throughout FreeTube. This mostly just changes all CSS properties with height and width to become block-size and inline-size respectively, which is only functionally relevant for different writing-modes (note that the default horizontal-tb is the only writing-mode currently supported by FreeTube, but that is subject to change in the future).

This PR enables Stylelint for npm run lint and npm run lint-fix, including minor modification of the other scripts to make space for this. This PR also runs Stylelint on pre-commit. This was never enabled beforehand due to concerns about which other rules should be needed. As a result, this PR removes the other plugins and rules, and they can be added back as necessary in their own tested PRs.

Screenshots

Screenshot_20230910_161625

Testing

  1. Add a non-logical property (e.g., padding-right: 55px) to a CSS file (e.g., App.vue).
  2. Save the file and try to commit the change.
  3. Encounter pre-commit hook notifying you of the issue with the non-logical property.
  4. Run npm run lint to see the same assessment as in 3.
  5. Run npm run lint-fix to see the issue automatically resolved by the linter.
  6. Commit the fixed change; you should encounter no issues.
  7. (Optional) run other slightly modified commands to ensure they work correctly (eslint-lint, eslint-lint-fix, lint-style-fix)

Desktop

  • OS: OpenSUSE Tumbleweed
  • OS Version: 2023xxxx
  • FreeTube version: 0.19.0

Additional context

Given that transform and float are still vulnerable to introducing directionality concerns, code contributors and reviewers must take special care to use these CSS horizontal directionality variables going forward. We currently only care about the x-dimension for right-to-left language support. Code contributors and reviewers must also take care to use logical properties inside style blocks and properties in .js and .vue files. Currently, the stylelint-use-logical-spec plugin is not capable of detecting these instances. We should probably add this note to the FreeTube Docs as well.

…y-one

After discussing this with the FreeTube team, it seems that we are still undecided on which rules we want to be active, including ones currently enabled. As a stopgap fix, we disabled Stylelint checking in our pre-commit Git hook and our recommended
> freetube@0.19.0 lint-fix
> run-p eslint-fix lint-style-fix command. With this change, we will be using Stylelint in our
> freetube@0.19.0 lint-fix
> run-p eslint-fix lint-style-fix command, while giving us the flexibility to add in additional desired plugins and rules as separate efforts.
This is not enforced by the plugin at this time.
…input when .stylelintignore files are changed
@FreeTubeBot FreeTubeBot enabled auto-merge (squash) September 10, 2023 23:04
@github-actions github-actions bot added PR: dependencies Pull requests that update a dependency file PR: waiting for review For PRs that are complete, tested, and ready for review labels Sep 10, 2023
.stylelintignore Outdated Show resolved Hide resolved
We want to avoid introducing directionality-specific properties that could muck up the video player.
@ChunkyProgrammer
Copy link
Member

This mostly has to do with changes that I added before this PR but I think these changes should be done here as we are enforcing stylelint now: (other than the following changes, the PR looks good to me)

index 3e6ccdf5..cae7d2d8 100644
--- a/package.json
+++ b/package.json
@@ -33,18 +33,14 @@
     "dev-runner": "node _scripts/dev-runner.js",
     "get-instances": "node _scripts/getInstances.js",
     "get-regions": "node _scripts/getRegions.mjs",
-    "lint-all": "run-p lint lint-json lint-style",
+    "lint-all": "run-p lint lint-json",
     "lint": "run-p eslint-lint lint-style",
     "lint-fix": "run-p eslint-lint-fix lint-style-fix",
     "eslint-lint": "eslint --ext .js,.vue ./",
     "eslint-lint-fix": "eslint --fix --ext .js,.vue ./",
     "lint-json": "eslint --ext .json ./",
-    "lint-style": "run-p lint-style:scss lint-style:css",
-    "lint-style:scss": "stylelint \"**/*.scss\"",
-    "lint-style:css": "stylelint \"**/*.css\"",
-    "lint-style-fix": "run-p lint-style-fix:scss lint-style-fix:css",
-    "lint-style-fix:scss": "stylelint --fix \"**/*.scss\"",
-    "lint-style-fix:css": "stylelint --fix \"**/*.css\"",
+    "lint-style": "stylelint \"**/*.{css,scss}\"",
+    "lint-style-fix": "stylelint --fix \"**/*.{css,scss}\"",
     "lint-yml": "eslint --ext .yml,.yaml ./",
     "pack": "run-p pack:main pack:renderer",
     "pack:main": "webpack --mode=production --node-env=production --config _scripts/webpack.main.config.js",

@FreeTubeBot FreeTubeBot merged commit 3db6f43 into FreeTubeApp:development Sep 14, 2023
5 checks passed
@github-actions github-actions bot removed the PR: waiting for review For PRs that are complete, tested, and ready for review label Sep 14, 2023
PikachuEXE added a commit to PikachuEXE/FreeTube that referenced this pull request Sep 14, 2023
* development:
  Implement Stylelint linting of CSS logical properties (FreeTubeApp#4023)
  Translated using Weblate (German)
  Translated using Weblate (French)
  Translated using Weblate (Arabic)
  Translated using Weblate (Chinese (Traditional))
  Translated using Weblate (Italian)
  Translated using Weblate (Portuguese (Brazil))

# Conflicts:
#	src/renderer/components/ft-prompt/ft-prompt.css
#	src/renderer/components/playlist-info/playlist-info.scss
#	src/renderer/scss-partials/_ft-list-item.scss
#	src/renderer/views/Playlist/Playlist.scss
#	src/renderer/views/UserPlaylists/UserPlaylists.css
@@ -66,6 +65,7 @@
"marked": "^8.0.0",
"path-browserify": "^1.0.1",
"process": "^0.11.10",
"stylelint-use-logical-spec": "^5.0.0",
Copy link
Member

Choose a reason for hiding this comment

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

Just realized that this was added as a Dependency and not a DevDependency

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Darn, you're right

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants