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

Fix isStandardSyntaxAtRule.test.js that use callbacks #4957

Merged
merged 2 commits into from Oct 4, 2020
Merged

Fix isStandardSyntaxAtRule.test.js that use callbacks #4957

merged 2 commits into from Oct 4, 2020

Conversation

ybiquitous
Copy link
Member

Which issue, if any, is this issue related to?

This is a part of #4881.

Is there anything in the PR that needs further explanation?

It seems postcss-sass does not support @mixin, so maybe the following test case is incorrect:

it('ignore `@content` inside mixins newline', () => {
const sass = '@mixin mixin()\n @content';
sassAtRules(sass, (atRule) => {
if (atRule.name === 'mixin') {
return;
}
expect(isStandardSyntaxAtRule(atRule)).toBeFalsy();
});
});

In this PR, I've marked the case above as skipped.

const scss = require('postcss-scss');
const postcssLess = require('postcss-less');
const postcssSass = require('postcss-sass');
const postcssScss = require('postcss-scss');
Copy link
Member Author

Choose a reason for hiding this comment

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

[note] I've renamed the variables not to hide local variables with the same name, e.g.

const sass = '@mixin mixin()\n  @content';
const scss = '@mixin mixin() { @content; };';

lessAtRules(less, (atRule) => {
expect(isStandardSyntaxAtRule(atRule)).toBeFalsy();
});
const rules = lessAtRules('@my-variable: 10px; .top { margin-top: @my-variable; }');
Copy link
Member Author

Choose a reason for hiding this comment

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

[note] I think the one-line is easier to read here such as '@detached-ruleset: { background: red; }; .top { @detached-ruleset(); }'.

it('ignore `@content` inside mixins newline', () => {
const sass = '@mixin mixin()\n @content';
// eslint-disable-next-line jest/no-disabled-tests -- TODO: `postcss-sass` parser does not support `@mixin`.
it.skip('ignore `@content` inside mixins newline', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

[note] This skip does not affect on the coverage:


image

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Has anybody left an issue on postcss-sass about this? Maybe we can submit a fix upstream as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

I found a PR to add the support of @mixin at-rule, but it seems WIP (and too old). 😢

AleshaOleg/postcss-sass#56

@ybiquitous ybiquitous marked this pull request as ready for review September 25, 2020 16:39
Copy link
Member

@mattxwang mattxwang left a comment

Choose a reason for hiding this comment

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

LGTM 💯

it('ignore `@content` inside mixins newline', () => {
const sass = '@mixin mixin()\n @content';
// eslint-disable-next-line jest/no-disabled-tests -- TODO: `postcss-sass` parser does not support `@mixin`.
it.skip('ignore `@content` inside mixins newline', () => {
Copy link
Member

Choose a reason for hiding this comment

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

Has anybody left an issue on postcss-sass about this? Maybe we can submit a fix upstream as well.

@hudochenkov hudochenkov merged commit 9246466 into stylelint:master Oct 4, 2020
@ybiquitous ybiquitous deleted the fix-isStandardSyntaxAtRule.test.js branch October 4, 2020 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants