-
Notifications
You must be signed in to change notification settings - Fork 9
chore: update stylelint to v16 #84
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
|
|
||
| TEST_FILES=$(find "${SCRIPT_DIR}/../tests/stylelint" -type f -name '*.scss' | sort) | ||
|
|
||
| TEST_DID_FAIL=0 | ||
|
|
||
| for TEST_FILE in $TEST_FILES; do | ||
| OUTPUT=$("${SCRIPT_DIR}/../node_modules/.bin/stylelint" "${TEST_FILE}" 2>&1) | ||
| EXIT_CODE=$? | ||
|
|
||
| if [[ "${TEST_FILE}" == *.pass.scss ]] && [ "${EXIT_CODE}" -ne 0 ]; then | ||
| echo "ERROR: Expected ${TEST_FILE} to pass linting, but it failed linting with:\n${OUTPUT}" | ||
| TEST_DID_FAIL=1 | ||
| elif [[ "${TEST_FILE}" == *.fail.scss ]] && [ "${EXIT_CODE}" -eq 0 ]; then | ||
| echo "ERROR: Expected ${TEST_FILE} to fail linting, but the file passed linting" | ||
| TEST_DID_FAIL=1 | ||
| fi | ||
| done | ||
|
|
||
| NUM_FILES=$(echo "$TEST_FILES" | wc -l | tr -d '[:space:]') | ||
|
|
||
| if [ "${TEST_DID_FAIL}" -eq 0 ]; then | ||
| echo "All stylelint tests passed across $NUM_FILES test file(s)." | ||
| else | ||
| exit 1 | ||
| fi |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 know there is a desire for more flexibility with empty lines, and I've been thinking a lot about #82.
While I understand this perspective, I have some concerns about removing this constraint entirely and allowing arbitrary spacing based on personal preference. Without any constraints, we might see inconsistent spacing patterns like this example:
Regarding the other PR's concerns about our blank line principles: while I recognize that the current rules may feel restrictive, I don't believe they actually violate our stated principle. The principle states "Related statements that accomplish a single task should be grouped together without blank lines. Use one blank line to separate unrelated statements."
I'd argue that allowing arbitrary spacing between property declarations would violate this principle. While
colorandbackground-colormay seem unrelated as individual properties, they're logically grouped because they all relate to the parent selector and together form the complete specification for that element. Many properties are closely related (such asdisplay: flex; flex-direction: row;), and removing this rule would rely solely on convention and code review to prevent their separation.As a potential middle ground that addresses both concerns, I'd suggest this rule set as a step toward more permissive formatting:
This approach would enforce separation of nested blocks (better aligning with our blank line principles) while improving readability. If a set properties is excessively long they can easily be separated visually and with explanation by code comments. I believe these rules should be auto-fixable, allowing older codebases to be updated automatically, though this should be validated.
With these proposed rules, the formatting would look like this:
Uh oh!
There was an error while loading. Please reload this page.
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.
It was actually my intention with this PR to keep the result as close to our existing standards as possible, to avoid any linting/standards discussions for the upgrade PR if we could.
In the PR description above, I noted:
so unfortunately both of these rules are among the ones that were not re-implemented in the
@stylelisticrepo and the proposed config just results in "rule not found" errors.I don't disagree with the need for some kind of constraints on blank lines, and at first glance I like the results of the proposed config! We'll just need to implement those two rules ourselves as a plugin in a subsequent PR.
Sorry, I should've called that out more clearly, especially since there was an open issue about the blank line standards 😁
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.
As discussed separately, many stylistic rules were moved to stylistic... but the ones I commented on you are saying were not available are not in the deprecated list and thus not moved. They still exist in stylelint code and documentation as far as I can tell.
May need an audit of those rules you thought were moved/deprecated to be double sure. Thanks
Uh oh!
There was an error while loading. Please reload this page.
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.
Good catch! Sorry about that—The vibes were good but reality was bad, if you know what I mean ;)
Me, the human, has re-checked the config file and rules and made a few changes:
function-calc-no-invalidis removed without replacement.)@stylistic, I added the@stylistic/name prefix where the existing rule was rather than grouping@stylisticrules together so that it's easier to see what rules were removed and which were just renamedextends: stylelint-config-standardstatement so that we continue to benefit from the default ruleset. This necessitated disabling some new-since-v14+ rules that were enabled by default and throwing errors. We can evaluate what those settings should be in another PRoverridessection. Now, rules that need to be disabled for SCSS syntax support are only disabled for SCSS files.I re-ran this updated config against our larger internal projects and verified that linting standards are enforced as before.
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.
Thanks, the adjustments are much easier to understand now as a straight upgrade!