Skip to content

Commit

Permalink
add selector to message of css-unused-selector warning (sveltejs#5253)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachiah authored and taylorzane committed Dec 17, 2020
1 parent 212bc8d commit 308d121
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/compiler/compile/css/Stylesheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ export default class Stylesheet {
child.warn_on_unused_selector((selector: Selector) => {
component.warn(selector.node, {
code: `css-unused-selector`,
message: `Unused CSS selector`
message: `Unused CSS selector "${this.source.slice(selector.node.start, selector.node.end)}"`
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/css/samples/empty-class/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export default {
warnings: [{
filename: "SvelteComponent.svelte",
code: `css-unused-selector`,
message: "Unused CSS selector",
message: 'Unused CSS selector ".x"',
start: {
line: 4,
column: 1,
Expand Down
2 changes: 1 addition & 1 deletion test/css/samples/global-with-unused-descendant/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default {
3: color: red;
4: }
`,
message: 'Unused CSS selector',
message: 'Unused CSS selector ":global(.foo) .bar"',
pos: 9,
start: {
character: 9,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default {
warnings: [{
code: `css-unused-selector`,
message: 'Unused CSS selector',
message: 'Unused CSS selector "div > p"',
start: {
line: 8,
column: 1,
Expand Down
4 changes: 2 additions & 2 deletions test/css/samples/unused-selector-leading/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export default {
{
filename: "SvelteComponent.svelte",
code: `css-unused-selector`,
message: "Unused CSS selector",
message: 'Unused CSS selector ".foo"',
start: {
line: 4,
column: 1,
Expand All @@ -27,7 +27,7 @@ export default {
{
filename: "SvelteComponent.svelte",
code: `css-unused-selector`,
message: "Unused CSS selector",
message: 'Unused CSS selector ".baz"',
start: {
line: 4,
column: 13,
Expand Down
20 changes: 10 additions & 10 deletions test/css/samples/unused-selector-string-concat/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export default {
warnings: [
{
code: 'css-unused-selector',
message: 'Unused CSS selector',
message: 'Unused CSS selector ".fooaa"',
frame:
` 9: <style>
10: .foo {color: red;}
Expand All @@ -16,7 +16,7 @@ export default {
},
{
code: 'css-unused-selector',
message: 'Unused CSS selector',
message: 'Unused CSS selector ".foobb"',
frame:
`10: .foo {color: red;}
11: .fooaa {color: red;}
Expand All @@ -30,7 +30,7 @@ export default {
},
{
code: 'css-unused-selector',
message: 'Unused CSS selector',
message: 'Unused CSS selector ".foodd"',
frame:
`12: .foobb {color: red;}
13: .foocc {color: red;}
Expand All @@ -44,7 +44,7 @@ export default {
},
{
code: 'css-unused-selector',
message: 'Unused CSS selector',
message: 'Unused CSS selector ".bbbar"',
frame:
`18: .dd {color: red;}
19: .aabar {color: red;}
Expand All @@ -58,7 +58,7 @@ export default {
},
{
code: 'css-unused-selector',
message: 'Unused CSS selector',
message: 'Unused CSS selector ".ccbar"',
frame:
`19: .aabar {color: red;}
20: .bbbar {color: red;}
Expand All @@ -72,7 +72,7 @@ export default {
},
{
code: 'css-unused-selector',
message: 'Unused CSS selector',
message: 'Unused CSS selector ".ddbar"',
frame:
`20: .bbbar {color: red;}
21: .ccbar {color: red;}
Expand All @@ -86,7 +86,7 @@ export default {
},
{
code: 'css-unused-selector',
message: 'Unused CSS selector',
message: 'Unused CSS selector ".fooaabar"',
frame:
`21: .ccbar {color: red;}
22: .ddbar {color: red;}
Expand All @@ -100,7 +100,7 @@ export default {
},
{
code: 'css-unused-selector',
message: 'Unused CSS selector',
message: 'Unused CSS selector ".foobbbar"',
frame:
`22: .ddbar {color: red;}
23: .fooaabar {color: red;}
Expand All @@ -114,7 +114,7 @@ export default {
},
{
code: 'css-unused-selector',
message: 'Unused CSS selector',
message: 'Unused CSS selector ".fooccbar"',
frame:
`23: .fooaabar {color: red;}
24: .foobbbar {color: red;}
Expand All @@ -128,7 +128,7 @@ export default {
},
{
code: 'css-unused-selector',
message: 'Unused CSS selector',
message: 'Unused CSS selector ".unused"',
frame:
`26: .fooddbar {color: red;}
27: .baz {color: red;}
Expand Down
2 changes: 1 addition & 1 deletion test/css/samples/unused-selector-ternary-concat/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default {
14: .unused {color: blue;}
^
15: </style>`,
message: 'Unused CSS selector',
message: 'Unused CSS selector ".unused"',
pos: 198,
start: {
character: 198,
Expand Down
4 changes: 2 additions & 2 deletions test/css/samples/unused-selector-ternary-nested/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export default {
warnings: [
{
code: 'css-unused-selector',
message: 'Unused CSS selector',
message: 'Unused CSS selector ".hover.unused"',
frame: `
13: .thing.active {color: blue;}
14: .hover { color: blue; }
Expand All @@ -16,7 +16,7 @@ export default {
},
{
code: 'css-unused-selector',
message: 'Unused CSS selector',
message: 'Unused CSS selector ".unused"',
frame: `
15: .hover.unused { color: blue; }
16:
Expand Down
2 changes: 1 addition & 1 deletion test/css/samples/unused-selector-ternary/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
warnings: [{
filename: "SvelteComponent.svelte",
code: `css-unused-selector`,
message: "Unused CSS selector",
message: 'Unused CSS selector ".maybeactive"',
start: {
line: 16,
column: 1,
Expand Down
2 changes: 1 addition & 1 deletion test/css/samples/unused-selector/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export default {
warnings: [{
filename: "SvelteComponent.svelte",
code: `css-unused-selector`,
message: "Unused CSS selector",
message: 'Unused CSS selector ".bar"',
start: {
line: 8,
column: 1,
Expand Down

0 comments on commit 308d121

Please sign in to comment.