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

Add and fix test cases for emptyLineBeforeUnspecified #90

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
205 changes: 199 additions & 6 deletions rules/properties-order/tests/empty-line-before-unspecified.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,57 @@ testRule(rule, {
}
`,
},
{
description: '6',
code: `
a {
height: 20px;
/* other props */
Copy link
Contributor

@njbraun njbraun Jul 26, 2019

Choose a reason for hiding this comment

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

Are you suggesting this should pass with emptyLineBeforeUnspecified: 'always', set? I was under the impression this should fail. Anything that isn't a 'height' or 'width' css property should classify as "unspecified" and therefore should have an empty line before it w/ the above config.

That being said, if something isn't a standard css property (e.g. a comment, or the start of a new css selector block), that creates kind of a natural separation.

Let me know what you are thinking.

Copy link
Owner Author

Choose a reason for hiding this comment

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

We ignore requirement if there is a comment before. Take a look at these tests for emptyLineBefore:

{
description: '7',
code: `
a {
display: none;
/* comment */
position: absolute;
}
`,
},

{
description: '9',
code: `
a {
/* comment */
display: none;
/* comment */
position: absolute;
}
`,
},

They are both accepted when emptyLineBefore: "always" is set for position.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Word “unspecified” in properties-order rule always mean properties which are not specified in a config.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for clarifying, I should have a PR up soon for this then.

font-style: italic;
}
`,
},
{
description: '7',
code: `
a {
height: 20px;

/* other props */
font-style: italic;
}
`,
},
{
description: '8',
code: `
a {
height: 20px;
width: 20px;

b {
font-style: italic;
}
}
`,
},
{
description: '9',
code: `
a {
height: 20px;
width: 20px;
b {
font-style: italic;
}
}
`,
},
],

reject: [
{
description: '6',
description: '10',
code: `
a {
height: 20px;
Expand All @@ -86,7 +132,7 @@ testRule(rule, {
message: messages.expectedEmptyLineBefore('font-style'),
},
{
description: '7',
description: '11',
code: `
a {
height: 20px;
Expand All @@ -105,7 +151,7 @@ testRule(rule, {
message: messages.expectedEmptyLineBefore('font-style'),
},
{
description: '8',
description: '12',
code: `
a {
height: 20px;
Expand All @@ -121,24 +167,171 @@ testRule(rule, {
`,
message: messages.expectedEmptyLineBefore('font-style'),
},
],
});

testRule(rule, {
ruleName,
config: [
['height', 'width'],
{
description: '9',
unspecified: 'bottom',
emptyLineBeforeUnspecified: 'never',
},
],
fix: true,

accept: [
{
description: '13',
code: `
a {
height: 20px;

width: 20px;
font-style: italic;
}
`,
},
{
description: '14',
code: `
a {
height: 20px;
width: 20px;
font-style: italic;
}
`,
},
{
description: '15',
code: `
a {
height: 20px;
font-style: italic;
}
`,
},
{
description: '16',
code: `
a {
font-style: italic;
}
`,
},
{
description: '17',
code: `
a {
}
`,
},
{
description: '18',
code: `
a {
height: 20px;
/* other props */
font-style: italic;
}
`,
fixed: `
},
{
description: '19',
code: `
a {
height: 20px;

/* other props */
font-style: italic;
}
`,
message: messages.expectedEmptyLineBefore('undefined'),
},
{
description: '20',
code: `
a {
height: 20px;
width: 20px;

b {
font-style: italic;
}
}
`,
},
{
description: '21',
code: `
a {
height: 20px;
width: 20px;
b {
font-style: italic;
}
}
`,
},
],

reject: [
{
description: '22',
code: `
a {
height: 20px;

width: 20px;

font-style: italic;
}
`,
fixed: `
a {
height: 20px;

width: 20px;
font-style: italic;
}
`,
message: messages.rejectedEmptyLineBefore('font-style'),
},
{
description: '23',
code: `
a {
height: 20px;
width: 20px;

font-style: italic;
}
`,
fixed: `
a {
height: 20px;
width: 20px;
font-style: italic;
}
`,
message: messages.rejectedEmptyLineBefore('font-style'),
},
{
description: '24',
code: `
a {
height: 20px;

font-style: italic;
}
`,
fixed: `
a {
height: 20px;
font-style: italic;
}
`,
message: messages.rejectedEmptyLineBefore('font-style'),
},
],
});