Provide parser error when :global appears without selector in CSS

pull/4936/head
Cameron Messinides 5 years ago
parent a4dadf82be
commit d2628bad9f

@ -54,6 +54,13 @@ export default function read_style(parser: Parser, start: number, attributes: No
}, node.start); }, node.start);
} }
if (node.type === 'PseudoClassSelector' && node.name === 'global' && node.children === null) {
parser.error({
code: `css-global-without-selector`,
message: `:global() must contain a selector, cannot be used on its own`
}, node.loc.start.offset);
}
if (node.loc) { if (node.loc) {
node.start = node.loc.start.offset; node.start = node.loc.start.offset;
node.end = node.loc.end.offset; node.end = node.loc.end.offset;

@ -0,0 +1,10 @@
{
"code": "css-global-without-selector",
"message": ":global() must contain a selector, cannot be used on its own",
"start": {
"line": 2,
"column": 1,
"character": 9
},
"pos": 9
}
Loading…
Cancel
Save