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

Refactor @content arguments specs #1543

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<===> none_passed/input.scss
<===> args/none_passed/input.scss
// It's an error to pass no arguments to a content block that requires them.
@mixin mixin {
@content;
}

@include mixin using ($arg1, $arg2) {}

<===> none_passed/error
<===> args/none_passed/error
Error: Missing argument $arg1.
,
3 | @content;
Expand All @@ -19,7 +19,7 @@ Error: Missing argument $arg1.
input.scss 3:3 mixin()
input.scss 6:1 root stylesheet

<===> none_passed/error-libsass
<===> args/none_passed/error-libsass
Error: Mixin @content is missing argument $arg1.
on line 2:3 of test.scss, in mixin `mixin`
from line 5:10 of test.scss
Expand All @@ -29,15 +29,15 @@ Error: Mixin @content is missing argument $arg1.

<===>
================================================================================
<===> none_expected/input.scss
<===> args/none_expected/input.scss
// It's an error to pass argments to a content block that doesn't take them.
@mixin mixin {
@content(value);
}

@include mixin {}

<===> none_expected/error
<===> args/none_expected/error
Error: Only 0 arguments allowed, but 1 was passed.
,
3 | @content(value);
Expand All @@ -50,7 +50,7 @@ Error: Only 0 arguments allowed, but 1 was passed.
input.scss 3:3 mixin()
input.scss 6:1 root stylesheet

<===> none_expected/error-libsass
<===> args/none_expected/error-libsass
Error: wrong number of arguments (1 for 0) for `@content'
on line 2:3 of test.scss, in mixin `@content`
from line 2:3 of test.scss, in mixin `mixin`
Expand All @@ -61,15 +61,15 @@ Error: wrong number of arguments (1 for 0) for `@content'

<===>
================================================================================
<===> named/input.scss
<===> args/named/input.scss
// It's an error to pass a named argument that doesn't exist.
@mixin mixin {
@content($invalid: value);
}

@include mixin using ($valid: value) {}

<===> named/error
<===> args/named/error
Error: No argument named $invalid.
,
3 | @content($invalid: value);
Expand All @@ -82,7 +82,7 @@ Error: No argument named $invalid.
input.scss 3:3 mixin()
input.scss 6:1 root stylesheet

<===> named/error-libsass
<===> args/named/error-libsass
Error: Mixin @content has no parameter named $invalid
on line 2:12 of test.scss, in mixin `@content`
from line 2:3 of test.scss, in mixin `mixin`
Expand All @@ -93,15 +93,15 @@ Error: Mixin @content has no parameter named $invalid

<===>
================================================================================
<===> too_few/input.scss
<===> args/too_few/input.scss
// It's an error to pass fewer positional arguments than are required.
@mixin mixin {
@content(1);
}

@include mixin using ($arg1, $arg2) {}

<===> too_few/error
<===> args/too_few/error
Error: Missing argument $arg2.
,
3 | @content(1);
Expand All @@ -114,7 +114,7 @@ Error: Missing argument $arg2.
input.scss 3:3 mixin()
input.scss 6:1 root stylesheet

<===> too_few/error-libsass
<===> args/too_few/error-libsass
Error: Mixin @content is missing argument $arg2.
on line 2:3 of test.scss, in mixin `mixin`
from line 5:10 of test.scss
Expand All @@ -124,15 +124,15 @@ Error: Mixin @content is missing argument $arg2.

<===>
================================================================================
<===> too_many/input.scss
<===> args/too_many/input.scss
// It's an error to pass more positional arguments than are required.
@mixin mixin {
@content(1, 2, 3);
}

@include mixin using ($arg1, $arg2) {}

<===> too_many/error
<===> args/too_many/error
Error: Only 2 arguments allowed, but 3 were passed.
,
3 | @content(1, 2, 3);
Expand All @@ -145,11 +145,131 @@ Error: Only 2 arguments allowed, but 3 were passed.
input.scss 3:3 mixin()
input.scss 6:1 root stylesheet

<===> too_many/error-libsass
<===> args/too_many/error-libsass
Error: wrong number of arguments (3 for 2) for `@content'
on line 2:3 of test.scss, in mixin `@content`
from line 2:3 of test.scss, in mixin `mixin`
from line 5:10 of test.scss
>> @content(1, 2, 3);

--^

<===>
================================================================================
<===> syntax/arglist/invalid/input.scss
@mixin mixin {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
@mixin mixin {
@mixin a {

Super nitty, but these specs were written before the style guide was locked in, so they don't follow DO use single-letter names for irrelevant placeholders. Since you're touching them anyway, it's probably worth updating them to fully follow the style guide.

@content;
}

@include mixin() using ($arg1: ) {}

<===> syntax/arglist/invalid/error
Error: Expected expression.
,
5 | @include mixin() using ($arg1: ) {}
| ^
'
input.scss 5:32 root stylesheet

<===> syntax/arglist/invalid/error-libsass
Error: Invalid CSS after "...) using ($arg1:": expected expression (e.g. 1px, bold), was ") {}"
on line 5:32 of test.scss
>> @include mixin() using ($arg1: ) {}

-------------------------------^

<===>
================================================================================
<===> syntax/arglist/missing/input.scss
@mixin mixin {
@content;
}

@include mixin using {}

<===> syntax/arglist/missing/error
Error: expected "(".
,
5 | @include mixin using {}
| ^
'
input.scss 5:22 root stylesheet

<===> syntax/arglist/missing/error-libsass
Error: Invalid CSS after "...ude mixin using": expected "(", was "{}"
on line 5:16 of test.scss
>> @include mixin using {}

---------------^

<===>
================================================================================
<===> syntax/arglist/missing_parens/input.scss
@mixin mixin {
@content;
}

@include mixin using $arg1 {}

<===> syntax/arglist/missing_parens/error
Error: expected "(".
,
5 | @include mixin using $arg1 {}
| ^
'
input.scss 5:22 root stylesheet

<===> syntax/arglist/missing_parens/error-libsass
Error: Invalid CSS after "...ude mixin using": expected "(", was "$arg1 {}"
on line 5:16 of test.scss
>> @include mixin using $arg1 {}

---------------^

<===>
================================================================================
<===> syntax/missing_using/input.scss
@mixin mixin {
@content;
}

@include mixin() () {}

<===> syntax/missing_using/error
Error: expected ";".
,
5 | @include mixin() () {}
| ^
'
input.scss 5:18 root stylesheet

<===> syntax/missing_using/error-libsass
Error: Invalid CSS after "@include mixin()": expected ";", was "() {}"
on line 5:16 of test.scss
>> @include mixin() () {}

---------------^

<===>
================================================================================
<===> syntax/missing_block/input.scss
@mixin mixin {
@content;
}

@include mixin using ();

<===> syntax/missing_block/error
Error: expected "{".
,
5 | @include mixin using ();
| ^
'
input.scss 5:24 root stylesheet

<===> syntax/missing_block/error-libsass
Error: Invalid CSS after "... mixin using ()": expected "{", was ";"
on line 5:23 of test.scss
>> @include mixin using ();

----------------------^
105 changes: 105 additions & 0 deletions spec/directives/mixin/content/arguments/none.hrx
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<===> no_parens/no_using/input.scss
@mixin mixin {
@content;
}

a {
@include mixin {
x: y;
}
}

<===> no_parens/no_using/output.css
a {
x: y;
}
Comment on lines +1 to +15
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems strange to have a spec under content/arguments that calls a mixin without passing any arguments to its content block.


<===>
================================================================================
<===> no_parens/empty_using/input.scss
@mixin mixin {
@content;
}

a {
@include mixin using () {
x: y;
}
}

<===> no_parens/empty_using/output.css
a {
x: y;
}

<===>
================================================================================
<===> no_parens/default_using/input.scss
@mixin mixin {
@content;
}

a {
@include mixin using ($arg: value) {
arg: $arg;
}
}

<===> no_parens/default_using/output.css
a {
arg: value;
}

<===>
================================================================================
<===> with_parens/no_using/input.scss
@mixin mixin {
@content();
}

a {
@include mixin {
x: y;
}
}

<===> with_parens/no_using/output.css
a {
x: y;
}

<===>
================================================================================
<===> with_parens/empty_using/input.scss
@mixin mixin {
@content();
}

a {
@include mixin using () {
x: y;
}
}

<===> with_parens/empty_using/output.css
a {
x: y;
}

<===>
================================================================================
<===> with_parens/default_using/input.scss
@mixin mixin {
@content();
}

a {
@include mixin using ($arg: value) {
arg: $arg;
}
}

<===> with_parens/default_using/output.css
a {
arg: value;
}
Loading