-
-
Notifications
You must be signed in to change notification settings - Fork 938
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
Update postcss-less to 1.0 #2702
Conversation
@jwilsson It's fantastic to see this WIP! I'll label as |
@@ -53,6 +53,10 @@ const rule = function (actual) { | |||
} | |||
|
|||
root.walk(node => { | |||
if (node.mixin) { |
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'm not 100% satisfied with this current solution here and below, but we can't use isStandardSyntaxRule
here since it checks for --custom-property-set: {}
, thus failing other tests which uses that.
While working on this, though, I found myself thinking of a isLessRule
util. Would that be of interest or is it too specific since it's a non-standard syntax thing? I was thinking that the isLessRule
util would consist of the Less-specific checks from isStandardSyntaxRule
and that isStandardSyntaxRule
could make use of isLessRule
instead.
Using a isLessRule
here in no-extra-semicolons
would also catch Less &:extend(.foo)
rules which aren't currently ignored (&:extend(.foo)
can of course be caught and ignored without it too, but a util would be a better fit IMO).
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.
Would that be of interest or is it too specific since it's a non-standard syntax thing?
Too specific I'm afraid. Rules make use of the isStandardSyntax*
utils to make sure only whitelisted constructs are dealt with within the rule. There are too many non-standard syntaxes to add special cases to individual rules, even if it's to explicitly ignore a piece of non-standard syntax. There are a lot of rules to maintain and having this consistent behaviour has benefited us thus far.
As such, I suggest we structure that conditional in terms of known construct and standard syntax utils i.e.:
if (
node.type === "rule"
&& !isCustomPropertySet(node)
&& !isStandardSyntaxRule(node)
) {
return
}
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.
Gotcha! That's what I figured, but I thought I'd ask :)
@@ -555,6 +555,6 @@ testRule(rule, { | |||
code: "a { .mixin();\ncolor: red;; }", | |||
message: messages.rejected, | |||
line: 2, | |||
column: 10, | |||
column: 11, |
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 actually believe that the old column here was incorrect, 11
makes more sense when checking it in my editor for example (the editor is reporting 11
as the first semicolon after red
).
I'm happy to be proved wrong though!
All tests should pass as of the latest commit, just waiting for a new release of |
@@ -555,6 +555,6 @@ testRule(rule, { | |||
code: "a { .mixin();\ncolor: red;; }", | |||
message: messages.rejected, | |||
line: 2, | |||
column: 10, | |||
column: 12, |
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.
This should be even more correct, 12
corresponds to the last of the two semicolons.
This should be ready for review. The new |
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.
@jwilsson Big thanks again for picking up this Less update and putting in the legwork.
I've made two requests to tweak how the conditionals in the no-extra-semicolon
rule are structured. Other than that, this looks great!
Would you like me to add you to the stylelint org? That way any future Less-related updates you might do can happen on a branch here.
@@ -53,6 +53,10 @@ const rule = function (actual) { | |||
} | |||
|
|||
root.walk(node => { | |||
if (node.mixin) { |
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.
Would that be of interest or is it too specific since it's a non-standard syntax thing?
Too specific I'm afraid. Rules make use of the isStandardSyntax*
utils to make sure only whitelisted constructs are dealt with within the rule. There are too many non-standard syntaxes to add special cases to individual rules, even if it's to explicitly ignore a piece of non-standard syntax. There are a lot of rules to maintain and having this consistent behaviour has benefited us thus far.
As such, I suggest we structure that conditional in terms of known construct and standard syntax utils i.e.:
if (
node.type === "rule"
&& !isCustomPropertySet(node)
&& !isStandardSyntaxRule(node)
) {
return
}
@@ -87,6 +91,15 @@ const rule = function (actual) { | |||
const rawAfterNode = node.raws.after | |||
|
|||
if (rawAfterNode && rawAfterNode.trim().length !== 0) { | |||
/** |
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 above, let's check if the last node is a standard rule or a custom property set:
if (
node.last
&& node.last.type === "rule"
&& !isCustomPropertySet(node.last)
&& !isStandardSyntaxRule(node.last)
) {
return
}
Sure, happy to help out! |
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 for making the changes.
LGTM.
I've restarted the node 8.x tests... it's been temperamental.
I've added you to the org. Welcome onboard :)
Welcome @jwilsson 😄 |
Tests are now green. LGTM. |
* Add stylelint semantic versioning policy * Fix whitespace and empty lines * Add changelog entry * Remove stylelint-config=standard reference * Tweak major release optional options verbiage * Update changelog * Props ESLint * Fix false negatives with ignore: ["descendant"] in selector-no-type (#2200) * Update CHANGELOG.md * Fix handling of shared-line comments (#2262) * Fix handling of shared-line comments Introduces a number of utilities and adjusts the following rules: at-rule-empty-line-before, custom-property-empty-line-before, declaration-empty-line-before, rule-nested-empty-line-before, rule-non-nested-empty-line-before Closes #2237; closes #2239; closes #2240. * Fixes based on feedback * Use getPreviousNonSharedLineCommentNode more * Use more new helpers in comment-empty-line-before * Add ignore: ["child"] option to selector-no-type (#2217) * Add ignore: ["child"] option to selector-no-type * Correct logic for ignore: ["child"] option * Include line and column in reject tests with multiple type selectors * Update CHANGELOG.md * Report every selector resolved selector in selector-max-compound-selectors (#2350) * Update CHANGELOG.md * Add new shorthand data (#2354) * Add new shorthand data * Add mask shorthand * Use defined list of properties in shorthand-property-no-redundant-values * Improve declaration-block-no-shorthand-property-overrides speed a little bit * Check prefixed properties agains prefixed properties in declaration-block-no-shorthand-property-overrides * Improve declaration-block-no-redundant-longhand-properties speed a little bit * Ignore prefixes case in declaration-block-no-shorthand-property-overrides * Check prefixed properties agains prefixed properties in declaration-block-no-redundant-longhand-properties * Add `grid-gap` to shorthand-property-no-redundant-values * Explain properties set for shorthand-property-no-redundant-values * Revert unnecessary changes * Add “mask” to declaration-block-no-redundant-longhand-properties readme * Update CHANGELOG.md * Update changelog * Remove deprecated rules (#2422) * Remove deprecated rules * Include `rule-empty-line-before` in system tests * *-empty-line-before rules consider line as empty if it contains whitespace only (#2440) * Update CHANGELOG.md * Remove deprecated options (#2433) * Update CHANGELOG.md * report-needless-disables now exits with non-zero code (#2341) * Update CHANGELOG.md * Remove leftover files (#2442) * Remove leftover file * One more * And one more * Ignoring improvements (#2464) * WIP ignoring improvements * Remove standaloneIgnored property of result * Add disableDefaultIgnores * Add documentation tweaks * Add parseStylelintIgnore tests * Non-absolutized ignore file paths * Restire gitignore syntax * Remove parseStylelintIgnore * Update CHANGELOG.md * Check all linear-gradients in a value list (#2496) Closes #2481 * Update CHANGELOG.md * Update CHANGELOG.md * Respect line case for `ignorePattern` (#2683) Closes #2647 * Update CHANGELOG.md * Update decls * Fix remark warning * Update snapshots * Add missing message to reject test * Fix tests for *-empty-line-before rules (#2688) * Fix tests for *-empty-line-before rules * Test addition and tweak * Update to PostCSS@6 (#2561) * Update to PostCSS@6 * Fix PostCSS@6 closing-brace test (#2689) * Account for PostCSS@6's support for at-apply * Remove only * Fix postcssPlugin tests (#2690) * Fix defaultSeverity.test.js test * Fix ignoreDisables test * Check ownSemiColon * Fixed: remove hacks related to custom property set. * Remove deprecated rules (#2693) Closes #2521 * Update CHANGELOG.md * Update CHANGELOG.md * Add VISION.md (#2704) * Add releases.md (#2705) * Add releases.md Closes #2700 * Add dry-release step * Use HTTPS for links * Change ignore options for selector-max-type (#2701) * Fix false negatives with ignore descendant * Add ignore child Closes #2699 * Update CHANGELOG.md * Update README.md to account for VISION.md (#2727) * Update README.md to account for VISION.md * Fix lint warnings in CHANGELOG * Update postcss-less to 1.0 (#2702) * Update postcss-less to 1.0.2 * Update isStandardSyntaxRule for postcss-less 1.0 * Pass custom postcss stringifier when creating result * Correct no-extra-semicolons Less test position * Ignore Less mixins in no-extra-semicolons * Update postcss-less to 1.1.0 * Correct no-extra-semicolons Less test position again * Utilize isStandardSyntaxRule when checking for Less rules in no-extra-semicolons * Case sensitive white/blacklists and ignore* options (#2709) Closes #2660 * Update CHANGELOG.md * docs: Add "New Release Issue Template" to releases.md (#2728) * Exit with non-zero code on postcss warnings (#2713) * Enhancement: exit with non zero code on postcss warnings. * Account for parseErrors in stringformatqer * Guard against no parseErrors * Update CHANGELOG.md * Refactor: simplify ignore logic. (#2732) * Update changelog * Bump 8.0.0 changes to top * Correctly place changelog items * Add introduction * Add codefence for website * Use relative path * Include VISION in package for website * Add link to VISION doc for website * Changelog amends * Update releases.md (#2738) * Update eslint and config (#2737) * Order requires * Use eqeqeq eslint rule * Update eslint * Disable no-useless-escape just for this repo * Enable no-useless-escape rule * Use tilde * Fix enable comment * Add reject test for unescaped regex
Superseeds #2637.
This is still a WIP, two issues in
no-extra-semicolons
remains.The big thing however, which isn't reflected by the tests are stringifying of the new
Import
node type in a couple of rules (string-quotes
for example) and the use ofnode.positionBy()
inutils/report
. It would fail with the sameTypeError: this[node.type] is not a function
errors since theRoot
node there wasn't frompostcss-less
but frompostcss
. I found those issues while runningstylelint
via the CLI. However, I have a fix for that pending in shellscape/postcss-less#82. So as soon as that is merged and a new version is tagged there we should be good to go (after I've fixedno-extra-semicolons
too of course).The current changes I've made are just minor ones, passing the current syntax's stringifier to
toResult
when checking the file's newlines and updatingisStandardSyntaxRule
to use new property names for Less mixins/extends.