Skip to content

Commit

Permalink
feat(consistent-selector-style): Enabled support for partial style
Browse files Browse the repository at this point in the history
  • Loading branch information
marekdedic committed Dec 14, 2024
1 parent c4f6de7 commit 8174f91
Show file tree
Hide file tree
Showing 11 changed files with 249 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export default createRule('consistent-selector-style', {
items: {
enum: ['class', 'id', 'type']
},
minItems: 3, // TODO: Allow fewer items
maxItems: 3,
uniqueItems: true
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"options": [{ "style": ["type", "id"] }]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<a class="link">Click me!</a>

<a class="link">Click me two!</a>

<a>Click me three!</a>

<b class="bold">Text 1</b>

<b class="bold">Text 2</b>

<b data-key="val">Text 3</b>

<style>
.link {
color: red;
}
.bold {
color: red;
}
.link:active {
color: red;
}
.link + .bold {
color: red;
}
.bold[data-key="val"] {
color: red;
}
.bold::before {
color: red;
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<a id="link">Click me!</a>

<a>Click me too!</a>

<b id="bold">Text 1</b>

<b data-key="val">Text 2</b>

<style>
#link {
color: red;
}
#bold {
color: red;
}
#link:active {
color: red;
}
#link + #bold {
color: red;
}
#bold[data-key="val"] {
color: red;
}
#bold::before {
color: red;
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<a>Click me!</a>

<b>Text 1</b>

<style lang="scss">
a {
color: red;
}
b {
color: red;
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<a>Click me!</a>

<a>Click me two!</a>

<b>Text 1</b>

<b>Text 2</b>

<b data-key="val">Text 2</b>

<style>
a {
color: red;
}
b {
color: red;
}
a:active {
color: red;
}
a + b {
color: red;
}
b[data-key="val"] {
color: red;
}
b::before {
color: red;
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"options": [{ "style": ["type"] }]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<a class="link">Click me!</a>

<a class="link">Click me two!</a>

<a>Click me three!</a>

<a class="unique">Click me three!</a>

<b class="bold">Text 1</b>

<b class="bold">Text 2</b>

<b data-key="val">Text 3</b>

<style>
.link {
color: red;
}
.bold {
color: red;
}
.link:active {
color: red;
}
.link + .bold {
color: red;
}
.bold[data-key="val"] {
color: red;
}
.bold::before {
color: red;
}
.unique {
color: red;
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<a id="link">Click me!</a>

<a>Click me too!</a>

<b id="bold">Text 1</b>

<b data-key="val">Text 2</b>

<style>
#link {
color: red;
}
#bold {
color: red;
}
#link:active {
color: red;
}
#link + #bold {
color: red;
}
#bold[data-key="val"] {
color: red;
}
#bold::before {
color: red;
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<a>Click me!</a>

<b>Text 1</b>

<style lang="scss">
a {
color: red;
}
b {
color: red;
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<a>Click me!</a>

<a>Click me two!</a>

<b>Text 1</b>

<b>Text 2</b>

<b data-key="val">Text 2</b>

<style>
a {
color: red;
}
b {
color: red;
}
a:active {
color: red;
}
a + b {
color: red;
}
b[data-key="val"] {
color: red;
}
b::before {
color: red;
}
</style>

0 comments on commit 8174f91

Please sign in to comment.