pull/11327/head
Rich Harris 2 years ago
parent 0d8effa0d6
commit 3c457644fe

@ -1,51 +1,47 @@
## invalid_css_declaration
## css_empty_declaration
> Declaration cannot be empty
## invalid_css_empty_declaration
## css_expected_identifier
> Declaration cannot be empty
> Expected a valid CSS identifier
## invalid_css_global_block_combinator
## css_global_block_invalid_combinator
> A :global {...} block cannot follow a %name% combinator
## invalid_css_global_block_declaration
## css_global_block_invalid_declaration
> A :global {...} block can only contain rules, not declarations
## invalid_css_global_block_list
## css_global_block_invalid_list
> A :global {...} block cannot be part of a selector list with more than one item
## invalid_css_global_block_modifier
## css_global_block_invalid_modifier
> A :global {...} block cannot modify an existing selector
## invalid_css_global_placement
## css_global_invalid_placement
> :global(...) can be at the start or end of a selector sequence, but not in the middle
## invalid_css_global_selector
## css_global_invalid_selector
> :global(...) must contain exactly one selector
## invalid_css_global_selector_list
## css_global_invalid_selector_list
> :global(...) must not contain type or universal selectors when used in a compound selector
## invalid_css_identifier
## css_nesting_selector_invalid_placement
> Expected a valid CSS identifier
> Nesting selectors can only be used inside a rule
## invalid_css_selector
## css_selector_invalid
> Invalid selector
## invalid_css_type_selector_placement
## css_type_selector_invalid_placement
> :global(...) must not be followed with a type selector
## invalid_nesting_selector
> Nesting selectors can only be used inside a rule

@ -57,441 +57,432 @@ function e(node, code, message) {
}
/**
* Declaration cannot be empty
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function invalid_css_declaration(node) {
e(node, "invalid_css_declaration", "Declaration cannot be empty");
}
/**
* Declaration cannot be empty
* Invalid compiler option: %details%
* @param {null | number | NodeLike} node
* @param {string} details
* @returns {never}
*/
export function invalid_css_empty_declaration(node) {
e(node, "invalid_css_empty_declaration", "Declaration cannot be empty");
export function options_invalid_value(node, details) {
e(node, "options_invalid_value", `Invalid compiler option: ${details}`);
}
/**
* A :global {...} block cannot follow a %name% combinator
* Invalid compiler option: %details%
* @param {null | number | NodeLike} node
* @param {string} name
* @param {string} details
* @returns {never}
*/
export function invalid_css_global_block_combinator(node, name) {
e(node, "invalid_css_global_block_combinator", `A :global {...} block cannot follow a ${name} combinator`);
export function options_removed(node, details) {
e(node, "options_removed", `Invalid compiler option: ${details}`);
}
/**
* A :global {...} block can only contain rules, not declarations
* Unrecognised compiler option %keypath%
* @param {null | number | NodeLike} node
* @param {string} keypath
* @returns {never}
*/
export function invalid_css_global_block_declaration(node) {
e(node, "invalid_css_global_block_declaration", "A :global {...} block can only contain rules, not declarations");
export function options_unrecognised(node, keypath) {
e(node, "options_unrecognised", `Unrecognised compiler option ${keypath}`);
}
/**
* A :global {...} block cannot be part of a selector list with more than one item
* `$bindable()` can only be used inside a `$props()` declaration
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function invalid_css_global_block_list(node) {
e(node, "invalid_css_global_block_list", "A :global {...} block cannot be part of a selector list with more than one item");
export function bindable_invalid_location(node) {
e(node, "bindable_invalid_location", "`$bindable()` can only be used inside a `$props()` declaration");
}
/**
* A :global {...} block cannot modify an existing selector
* Cannot assign to %thing%
* @param {null | number | NodeLike} node
* @param {string} thing
* @returns {never}
*/
export function invalid_css_global_block_modifier(node) {
e(node, "invalid_css_global_block_modifier", "A :global {...} block cannot modify an existing selector");
export function constant_assignment(node, thing) {
e(node, "constant_assignment", `Cannot assign to ${thing}`);
}
/**
* :global(...) can be at the start or end of a selector sequence, but not in the middle
* Cannot bind to %thing%
* @param {null | number | NodeLike} node
* @param {string} thing
* @returns {never}
*/
export function invalid_css_global_placement(node) {
e(node, "invalid_css_global_placement", ":global(...) can be at the start or end of a selector sequence, but not in the middle");
export function constant_binding(node, thing) {
e(node, "constant_binding", `Cannot bind to ${thing}`);
}
/**
* :global(...) must contain exactly one selector
* `%name%` has already been declared
* @param {null | number | NodeLike} node
* @param {string} name
* @returns {never}
*/
export function invalid_css_global_selector(node) {
e(node, "invalid_css_global_selector", ":global(...) must contain exactly one selector");
export function declaration_duplicate(node, name) {
e(node, "declaration_duplicate", `\`${name}\` has already been declared`);
}
/**
* :global(...) must not contain type or universal selectors when used in a compound selector
* Cannot declare same variable name which is imported inside `<script context="module">`
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function invalid_css_global_selector_list(node) {
e(node, "invalid_css_global_selector_list", ":global(...) must not contain type or universal selectors when used in a compound selector");
export function declaration_duplicate_module_import(node) {
e(node, "declaration_duplicate_module_import", "Cannot declare same variable name which is imported inside `<script context=\"module\">`");
}
/**
* Expected a valid CSS identifier
* Cannot export derived state from a module. To expose the current derived value, export a function returning its value
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function invalid_css_identifier(node) {
e(node, "invalid_css_identifier", "Expected a valid CSS identifier");
export function derived_invalid_export(node) {
e(node, "derived_invalid_export", "Cannot export derived state from a module. To expose the current derived value, export a function returning its value");
}
/**
* Invalid selector
* The $ name is reserved, and cannot be used for variables and imports
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function invalid_css_selector(node) {
e(node, "invalid_css_selector", "Invalid selector");
export function dollar_binding_invalid(node) {
e(node, "dollar_binding_invalid", "The $ name is reserved, and cannot be used for variables and imports");
}
/**
* :global(...) must not be followed with a type selector
* The $ prefix is reserved, and cannot be used for variables and imports
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function invalid_css_type_selector_placement(node) {
e(node, "invalid_css_type_selector_placement", ":global(...) must not be followed with a type selector");
export function dollar_prefix_invalid(node) {
e(node, "dollar_prefix_invalid", "The $ prefix is reserved, and cannot be used for variables and imports");
}
/**
* Nesting selectors can only be used inside a rule
* Cannot reassign or bind to each block argument in runes mode. Use the array and index variables instead (e.g. `array[i] = value` instead of `entry = value`)
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function invalid_nesting_selector(node) {
e(node, "invalid_nesting_selector", "Nesting selectors can only be used inside a rule");
export function each_item_invalid_assignment(node) {
e(node, "each_item_invalid_assignment", "Cannot reassign or bind to each block argument in runes mode. Use the array and index variables instead (e.g. `array[i] = value` instead of `entry = value`)");
}
/**
* Invalid compiler option: %details%
* `$effect()` can only be used as an expression statement
* @param {null | number | NodeLike} node
* @param {string} details
* @returns {never}
*/
export function options_invalid_value(node, details) {
e(node, "options_invalid_value", `Invalid compiler option: ${details}`);
export function effect_invalid_placement(node) {
e(node, "effect_invalid_placement", "`$effect()` can only be used as an expression statement");
}
/**
* Invalid compiler option: %details%
* `%name%` is an illegal variable name. To reference a global variable called `%name%`, use `globalThis.%name%`
* @param {null | number | NodeLike} node
* @param {string} details
* @param {string} name
* @returns {never}
*/
export function options_removed(node, details) {
e(node, "options_removed", `Invalid compiler option: ${details}`);
export function global_reference_invalid(node, name) {
e(node, "global_reference_invalid", `\`${name}\` is an illegal variable name. To reference a global variable called \`${name}\`, use \`globalThis.${name}\``);
}
/**
* Unrecognised compiler option %keypath%
* `$host()` can only be used inside custom element component instances
* @param {null | number | NodeLike} node
* @param {string} keypath
* @returns {never}
*/
export function options_unrecognised(node, keypath) {
e(node, "options_unrecognised", `Unrecognised compiler option ${keypath}`);
export function host_invalid_placement(node) {
e(node, "host_invalid_placement", "`$host()` can only be used inside custom element component instances");
}
/**
* `%name%` has already been declared
* Cannot use `export let` in runes mode use $props instead
* @param {null | number | NodeLike} node
* @param {string} name
* @returns {never}
*/
export function declaration_duplicate(node, name) {
e(node, "declaration_duplicate", `\`${name}\` has already been declared`);
export function legacy_export_invalid(node) {
e(node, "legacy_export_invalid", "Cannot use `export let` in runes mode — use $props instead");
}
/**
* Cannot declare same variable name which is imported inside `<script context="module">`
* Cannot use `$$props` in runes mode
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function declaration_duplicate_module_import(node) {
e(node, "declaration_duplicate_module_import", "Cannot declare same variable name which is imported inside `<script context=\"module\">`");
export function legacy_props_invalid(node) {
e(node, "legacy_props_invalid", "Cannot use `$$props` in runes mode");
}
/**
* The $ name is reserved, and cannot be used for variables and imports
* `$:` is not allowed in runes mode, use `$derived` or `$effect` instead
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function dollar_binding_invalid(node) {
e(node, "dollar_binding_invalid", "The $ name is reserved, and cannot be used for variables and imports");
export function legacy_reactive_statement_invalid(node) {
e(node, "legacy_reactive_statement_invalid", "`$:` is not allowed in runes mode, use `$derived` or `$effect` instead");
}
/**
* The $ prefix is reserved, and cannot be used for variables and imports
* Cannot use `$$restProps` in runes mode
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function dollar_prefix_invalid(node) {
e(node, "dollar_prefix_invalid", "The $ prefix is reserved, and cannot be used for variables and imports");
export function legacy_rest_props_invalid(node) {
e(node, "legacy_rest_props_invalid", "Cannot use `$$restProps` in runes mode");
}
/**
* `%name%` is an illegal variable name. To reference a global variable called `%name%`, use `globalThis.%name%`
* A component cannot have a default export
* @param {null | number | NodeLike} node
* @param {string} name
* @returns {never}
*/
export function global_reference_invalid(node, name) {
e(node, "global_reference_invalid", `\`${name}\` is an illegal variable name. To reference a global variable called \`${name}\`, use \`globalThis.${name}\``);
export function module_illegal_default_export(node) {
e(node, "module_illegal_default_export", "A component cannot have a default export");
}
/**
* A component cannot have a default export
* Cannot use `$props()` more than once
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function module_illegal_default_export(node) {
e(node, "module_illegal_default_export", "A component cannot have a default export");
export function props_duplicate(node) {
e(node, "props_duplicate", "Cannot use `$props()` more than once");
}
/**
* Cyclical dependency detected: %cycle%
* `$props()` can only be used with an object destructuring pattern
* @param {null | number | NodeLike} node
* @param {string} cycle
* @returns {never}
*/
export function reactive_declaration_cycle(node, cycle) {
e(node, "reactive_declaration_cycle", `Cyclical dependency detected: ${cycle}`);
export function props_invalid_identifier(node) {
e(node, "props_invalid_identifier", "`$props()` can only be used with an object destructuring pattern");
}
/**
* Cannot subscribe to stores that are not declared at the top level of the component
* `$props()` assignment must not contain nested properties or computed keys
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function store_invalid_scoped_subscription(node) {
e(node, "store_invalid_scoped_subscription", "Cannot subscribe to stores that are not declared at the top level of the component");
export function props_invalid_pattern(node) {
e(node, "props_invalid_pattern", "`$props()` assignment must not contain nested properties or computed keys");
}
/**
* Cannot reference store value inside `<script context="module">`
* `$props()` can only be used at the top level of components as a variable declaration initializer
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function store_invalid_subscription(node) {
e(node, "store_invalid_subscription", "Cannot reference store value inside `<script context=\"module\">`");
export function props_invalid_placement(node) {
e(node, "props_invalid_placement", "`$props()` can only be used at the top level of components as a variable declaration initializer");
}
/**
* `$bindable()` can only be used inside a `$props()` declaration
* Cyclical dependency detected: %cycle%
* @param {null | number | NodeLike} node
* @param {string} cycle
* @returns {never}
*/
export function bindable_invalid_location(node) {
e(node, "bindable_invalid_location", "`$bindable()` can only be used inside a `$props()` declaration");
export function reactive_declaration_cycle(node, cycle) {
e(node, "reactive_declaration_cycle", `Cyclical dependency detected: ${cycle}`);
}
/**
* Cannot assign to %thing%
* `%rune%` cannot be called with arguments
* @param {null | number | NodeLike} node
* @param {string} thing
* @param {string} rune
* @returns {never}
*/
export function constant_assignment(node, thing) {
e(node, "constant_assignment", `Cannot assign to ${thing}`);
export function rune_invalid_arguments(node, rune) {
e(node, "rune_invalid_arguments", `\`${rune}\` cannot be called with arguments`);
}
/**
* Cannot bind to %thing%
* `%rune%` must be called with %args%
* @param {null | number | NodeLike} node
* @param {string} thing
* @param {string} rune
* @param {string} args
* @returns {never}
*/
export function constant_binding(node, thing) {
e(node, "constant_binding", `Cannot bind to ${thing}`);
export function rune_invalid_arguments_length(node, rune, args) {
e(node, "rune_invalid_arguments_length", `\`${rune}\` must be called with ${args}`);
}
/**
* Cannot export derived state from a module. To expose the current derived value, export a function returning its value
* Cannot use %rune% rune in non-runes mode
* @param {null | number | NodeLike} node
* @param {string} rune
* @returns {never}
*/
export function derived_invalid_export(node) {
e(node, "derived_invalid_export", "Cannot export derived state from a module. To expose the current derived value, export a function returning its value");
export function rune_invalid_usage(node, rune) {
e(node, "rune_invalid_usage", `Cannot use ${rune} rune in non-runes mode`);
}
/**
* Cannot reassign or bind to each block argument in runes mode. Use the array and index variables instead (e.g. `array[i] = value` instead of `entry = value`)
* %name% cannot be used in runes mode
* @param {null | number | NodeLike} node
* @param {string} name
* @returns {never}
*/
export function each_item_invalid_assignment(node) {
e(node, "each_item_invalid_assignment", "Cannot reassign or bind to each block argument in runes mode. Use the array and index variables instead (e.g. `array[i] = value` instead of `entry = value`)");
export function runes_mode_invalid_import(node, name) {
e(node, "runes_mode_invalid_import", `${name} cannot be used in runes mode`);
}
/**
* `$effect()` can only be used as an expression statement
* Cannot reassign or bind to snippet parameter
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function effect_invalid_placement(node) {
e(node, "effect_invalid_placement", "`$effect()` can only be used as an expression statement");
export function snippet_parameter_assignment(node) {
e(node, "snippet_parameter_assignment", "Cannot reassign or bind to snippet parameter");
}
/**
* `$host()` can only be used inside custom element component instances
* Cannot export state from a module if it is reassigned. Either export a function returning the state value or only mutate the state value's properties
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function host_invalid_placement(node) {
e(node, "host_invalid_placement", "`$host()` can only be used inside custom element component instances");
export function state_invalid_export(node) {
e(node, "state_invalid_export", "Cannot export state from a module if it is reassigned. Either export a function returning the state value or only mutate the state value's properties");
}
/**
* Cannot use `export let` in runes mode use $props instead
* `%rune%(...)` can only be used as a variable declaration initializer or a class field
* @param {null | number | NodeLike} node
* @param {string} rune
* @returns {never}
*/
export function legacy_export_invalid(node) {
e(node, "legacy_export_invalid", "Cannot use `export let` in runes mode — use $props instead");
export function state_invalid_placement(node, rune) {
e(node, "state_invalid_placement", `\`${rune}(...)\` can only be used as a variable declaration initializer or a class field`);
}
/**
* Cannot use `$$props` in runes mode
* Cannot subscribe to stores that are not declared at the top level of the component
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function legacy_props_invalid(node) {
e(node, "legacy_props_invalid", "Cannot use `$$props` in runes mode");
export function store_invalid_scoped_subscription(node) {
e(node, "store_invalid_scoped_subscription", "Cannot subscribe to stores that are not declared at the top level of the component");
}
/**
* `$:` is not allowed in runes mode, use `$derived` or `$effect` instead
* Cannot reference store value inside `<script context="module">`
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function legacy_reactive_statement_invalid(node) {
e(node, "legacy_reactive_statement_invalid", "`$:` is not allowed in runes mode, use `$derived` or `$effect` instead");
export function store_invalid_subscription(node) {
e(node, "store_invalid_subscription", "Cannot reference store value inside `<script context=\"module\">`");
}
/**
* Cannot use `$$restProps` in runes mode
* Declaration cannot be empty
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function legacy_rest_props_invalid(node) {
e(node, "legacy_rest_props_invalid", "Cannot use `$$restProps` in runes mode");
export function css_empty_declaration(node) {
e(node, "css_empty_declaration", "Declaration cannot be empty");
}
/**
* Cannot use `$props()` more than once
* A :global {...} block cannot follow a %name% combinator
* @param {null | number | NodeLike} node
* @param {string} name
* @returns {never}
*/
export function props_duplicate(node) {
e(node, "props_duplicate", "Cannot use `$props()` more than once");
export function css_global_block_invalid_combinator(node, name) {
e(node, "css_global_block_invalid_combinator", `A :global {...} block cannot follow a ${name} combinator`);
}
/**
* `$props()` can only be used with an object destructuring pattern
* A :global {...} block can only contain rules, not declarations
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function props_invalid_identifier(node) {
e(node, "props_invalid_identifier", "`$props()` can only be used with an object destructuring pattern");
export function css_global_block_invalid_declaration(node) {
e(node, "css_global_block_invalid_declaration", "A :global {...} block can only contain rules, not declarations");
}
/**
* `$props()` assignment must not contain nested properties or computed keys
* A :global {...} block cannot be part of a selector list with more than one item
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function props_invalid_pattern(node) {
e(node, "props_invalid_pattern", "`$props()` assignment must not contain nested properties or computed keys");
export function css_global_block_invalid_list(node) {
e(node, "css_global_block_invalid_list", "A :global {...} block cannot be part of a selector list with more than one item");
}
/**
* `$props()` can only be used at the top level of components as a variable declaration initializer
* A :global {...} block cannot modify an existing selector
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function props_invalid_placement(node) {
e(node, "props_invalid_placement", "`$props()` can only be used at the top level of components as a variable declaration initializer");
export function css_global_block_invalid_modifier(node) {
e(node, "css_global_block_invalid_modifier", "A :global {...} block cannot modify an existing selector");
}
/**
* `%rune%` cannot be called with arguments
* :global(...) can be at the start or end of a selector sequence, but not in the middle
* @param {null | number | NodeLike} node
* @param {string} rune
* @returns {never}
*/
export function rune_invalid_arguments(node, rune) {
e(node, "rune_invalid_arguments", `\`${rune}\` cannot be called with arguments`);
export function css_global_invalid_placement(node) {
e(node, "css_global_invalid_placement", ":global(...) can be at the start or end of a selector sequence, but not in the middle");
}
/**
* `%rune%` must be called with %args%
* :global(...) must contain exactly one selector
* @param {null | number | NodeLike} node
* @param {string} rune
* @param {string} args
* @returns {never}
*/
export function rune_invalid_arguments_length(node, rune, args) {
e(node, "rune_invalid_arguments_length", `\`${rune}\` must be called with ${args}`);
export function css_global_invalid_selector(node) {
e(node, "css_global_invalid_selector", ":global(...) must contain exactly one selector");
}
/**
* Cannot use %rune% rune in non-runes mode
* :global(...) must not contain type or universal selectors when used in a compound selector
* @param {null | number | NodeLike} node
* @param {string} rune
* @returns {never}
*/
export function rune_invalid_usage(node, rune) {
e(node, "rune_invalid_usage", `Cannot use ${rune} rune in non-runes mode`);
export function css_global_invalid_selector_list(node) {
e(node, "css_global_invalid_selector_list", ":global(...) must not contain type or universal selectors when used in a compound selector");
}
/**
* %name% cannot be used in runes mode
* Expected a valid CSS identifier
* @param {null | number | NodeLike} node
* @param {string} name
* @returns {never}
*/
export function runes_mode_invalid_import(node, name) {
e(node, "runes_mode_invalid_import", `${name} cannot be used in runes mode`);
export function css_expected_identifier(node) {
e(node, "css_expected_identifier", "Expected a valid CSS identifier");
}
/**
* Cannot reassign or bind to snippet parameter
* Invalid selector
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function snippet_parameter_assignment(node) {
e(node, "snippet_parameter_assignment", "Cannot reassign or bind to snippet parameter");
export function css_selector_invalid(node) {
e(node, "css_selector_invalid", "Invalid selector");
}
/**
* Cannot export state from a module if it is reassigned. Either export a function returning the state value or only mutate the state value's properties
* :global(...) must not be followed with a type selector
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function state_invalid_export(node) {
e(node, "state_invalid_export", "Cannot export state from a module if it is reassigned. Either export a function returning the state value or only mutate the state value's properties");
export function css_type_selector_invalid_placement(node) {
e(node, "css_type_selector_invalid_placement", ":global(...) must not be followed with a type selector");
}
/**
* `%rune%(...)` can only be used as a variable declaration initializer or a class field
* Nesting selectors can only be used inside a rule
* @param {null | number | NodeLike} node
* @param {string} rune
* @returns {never}
*/
export function state_invalid_placement(node, rune) {
e(node, "state_invalid_placement", `\`${rune}(...)\` can only be used as a variable declaration initializer or a class field`);
export function css_nesting_selector_invalid_placement(node) {
e(node, "css_nesting_selector_invalid_placement", "Nesting selectors can only be used inside a rule");
}
/**

@ -352,7 +352,7 @@ function read_selector(parser, inside_pseudo_class = false) {
if (combinator) {
if (relative_selector.selectors.length === 0) {
if (!inside_pseudo_class) {
e.invalid_css_selector(start);
e.css_selector_invalid(start);
}
} else {
relative_selector.end = index;
@ -365,7 +365,7 @@ function read_selector(parser, inside_pseudo_class = false) {
parser.allow_whitespace();
if (parser.match(',') || (inside_pseudo_class ? parser.match(')') : parser.match('{'))) {
e.invalid_css_selector(parser.index);
e.css_selector_invalid(parser.index);
}
}
}
@ -471,12 +471,13 @@ function read_declaration(parser) {
const property = parser.read_until(REGEX_WHITESPACE_OR_COLON);
parser.allow_whitespace();
parser.eat(':');
let index = parser.index;
parser.allow_whitespace();
const value = read_value(parser);
if (!value && !property.startsWith('--')) {
e.invalid_css_declaration(parser.index);
e.css_empty_declaration({ start, end: index });
}
const end = parser.index;
@ -577,7 +578,7 @@ function read_identifier(parser) {
let identifier = '';
if (parser.match('--') || parser.match_regex(REGEX_LEADING_HYPHEN_OR_DIGIT)) {
e.invalid_css_identifier(start);
e.css_expected_identifier(start);
}
let escaped = false;
@ -602,7 +603,7 @@ function read_identifier(parser) {
}
if (identifier === '') {
e.invalid_css_identifier(start);
e.css_expected_identifier(start);
}
return identifier;

@ -98,26 +98,26 @@ const validation_visitors = {
Rule(node, context) {
if (node.metadata.is_global_block) {
if (node.prelude.children.length > 1) {
e.invalid_css_global_block_list(node.prelude);
e.css_global_block_invalid_list(node.prelude);
}
const complex_selector = node.prelude.children[0];
const relative_selector = complex_selector.children[complex_selector.children.length - 1];
if (relative_selector.selectors.length > 1) {
e.invalid_css_global_block_modifier(
e.css_global_block_invalid_modifier(
relative_selector.selectors[relative_selector.selectors.length - 1]
);
}
if (relative_selector.combinator && relative_selector.combinator.name !== ' ') {
e.invalid_css_global_block_combinator(relative_selector, relative_selector.combinator.name);
e.css_global_block_invalid_combinator(relative_selector, relative_selector.combinator.name);
}
const declaration = node.block.children.find((child) => child.type === 'Declaration');
if (declaration) {
e.invalid_css_global_block_declaration(declaration);
e.css_global_block_invalid_declaration(declaration);
}
}
@ -132,7 +132,7 @@ const validation_visitors = {
if (a !== b) {
for (let i = a; i <= b; i += 1) {
if (is_global(node.children[i])) {
e.invalid_css_global_placement(node.children[i].selectors[0]);
e.css_global_invalid_placement(node.children[i].selectors[0]);
}
}
}
@ -147,12 +147,12 @@ const validation_visitors = {
const child = selector.args?.children[0].children[0];
// ensure `:global(element)` to be at the first position in a compound selector
if (child?.selectors[0].type === 'TypeSelector' && i !== 0) {
e.invalid_css_global_selector_list(selector);
e.css_global_invalid_selector_list(selector);
}
// ensure `:global(.class)` is not followed by a type selector, eg: `:global(.class)element`
if (relative_selector.selectors[i + 1]?.type === 'TypeSelector') {
e.invalid_css_type_selector_placement(relative_selector.selectors[i + 1]);
e.css_type_selector_invalid_placement(relative_selector.selectors[i + 1]);
}
// ensure `:global(...)`contains a single selector
@ -162,7 +162,7 @@ const validation_visitors = {
selector.args.children.length > 1 &&
(node.children.length > 1 || relative_selector.selectors.length > 1)
) {
e.invalid_css_global_selector(selector);
e.css_global_invalid_selector(selector);
}
}
}
@ -171,7 +171,7 @@ const validation_visitors = {
NestingSelector(node, context) {
const rule = /** @type {import('#compiler').Css.Rule} */ (context.state.rule);
if (!rule.metadata.parent_rule) {
e.invalid_nesting_selector(node);
e.css_nesting_selector_invalid_placement(node);
}
}
};

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({
error: {
code: 'invalid_css_global_block_combinator',
code: 'css_global_block_invalid_combinator',
message: 'A :global {...} block cannot follow a > combinator',
position: [12, 21]
}

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({
error: {
code: 'invalid_css_global_block_declaration',
code: 'css_global_block_invalid_declaration',
message: 'A :global {...} block can only contain rules, not declarations',
position: [24, 34]
}

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({
error: {
code: 'invalid_css_global_block_modifier',
code: 'css_global_block_invalid_modifier',
message: 'A :global {...} block cannot modify an existing selector',
position: [14, 21]
}

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({
error: {
code: 'invalid_css_global_block_list',
code: 'css_global_block_invalid_list',
message: 'A :global {...} block cannot be part of a selector list with more than one item',
position: [9, 31]
}

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({
error: {
code: 'invalid_css_identifier',
code: 'css_expected_identifier',
message: 'Expected a valid CSS identifier',
position: [25, 25]
}

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({
error: {
code: 'invalid_css_identifier',
code: 'css_expected_identifier',
message: 'Expected a valid CSS identifier',
position: [9, 9]
}

@ -1,6 +1,6 @@
[
{
"code": "invalid_css_selector",
"code": "css_selector_invalid",
"message": "Invalid selector",
"start": {
"line": 10,

@ -1,6 +1,6 @@
[
{
"code": "invalid_css_selector",
"code": "css_selector_invalid",
"message": "Invalid selector",
"start": {
"line": 8,

@ -1,6 +1,6 @@
[
{
"code": "invalid_css_selector",
"code": "css_selector_invalid",
"message": "Invalid selector",
"start": {
"line": 5,

@ -1,6 +1,6 @@
[
{
"code": "invalid_css_selector",
"code": "css_selector_invalid",
"message": "Invalid selector",
"start": {
"line": 4,

@ -1,6 +1,6 @@
[
{
"code": "invalid_css_global_placement",
"code": "css_global_invalid_placement",
"message": ":global(...) can be at the start or end of a selector sequence, but not in the middle",
"start": {
"line": 8,

@ -1,6 +1,6 @@
[
{
"code": "invalid_css_global_placement",
"code": "css_global_invalid_placement",
"message": ":global(...) can be at the start or end of a selector sequence, but not in the middle",
"start": {
"line": 5,

@ -1,6 +1,6 @@
[
{
"code": "invalid_css_global_selector_list",
"code": "css_global_invalid_selector_list",
"message": ":global(...) must not contain type or universal selectors when used in a compound selector",
"start": {
"line": 2,

@ -1,6 +1,6 @@
[
{
"code": "invalid_css_global_selector_list",
"code": "css_global_invalid_selector_list",
"message": ":global(...) must not contain type or universal selectors when used in a compound selector",
"start": {
"line": 2,

@ -1,6 +1,6 @@
[
{
"code": "invalid_css_global_selector_list",
"code": "css_global_invalid_selector_list",
"message": ":global(...) must not contain type or universal selectors when used in a compound selector",
"start": {
"line": 5,

@ -1,6 +1,6 @@
[
{
"code": "invalid_css_global_placement",
"code": "css_global_invalid_placement",
"message": ":global(...) can be at the start or end of a selector sequence, but not in the middle",
"start": {
"line": 2,

@ -1,6 +1,6 @@
[
{
"code": "invalid_css_global_selector",
"code": "css_global_invalid_selector",
"message": ":global(...) must contain exactly one selector",
"start": {
"line": 11,

@ -1,6 +1,6 @@
[
{
"code": "invalid_css_global_selector",
"code": "css_global_invalid_selector",
"message": ":global(...) must contain exactly one selector",
"start": {
"line": 5,

@ -1,6 +1,6 @@
[
{
"code": "invalid_css_global_selector",
"code": "css_global_invalid_selector",
"message": ":global(...) must contain exactly one selector",
"start": {
"line": 2,

@ -1,6 +1,6 @@
[
{
"code": "invalid_css_global_selector",
"code": "css_global_invalid_selector",
"message": ":global(...) must contain exactly one selector",
"start": {
"line": 5,

@ -1,6 +1,6 @@
[
{
"code": "invalid_css_global_selector",
"code": "css_global_invalid_selector",
"message": ":global(...) must contain exactly one selector",
"start": {
"line": 5,

@ -1,6 +1,6 @@
[
{
"code": "invalid_css_global_selector_list",
"code": "css_global_invalid_selector_list",
"message": ":global(...) must not contain type or universal selectors when used in a compound selector",
"start": {
"line": 20,

@ -1,6 +1,6 @@
[
{
"code": "invalid_css_global_selector",
"code": "css_global_invalid_selector",
"message": ":global(...) must contain exactly one selector",
"start": {
"line": 11,

@ -1,6 +1,6 @@
[
{
"code": "invalid_css_type_selector_placement",
"code": "css_type_selector_invalid_placement",
"message": ":global(...) must not be followed with a type selector",
"start": {
"line": 17,

@ -1,6 +1,6 @@
[
{
"code": "invalid_css_declaration",
"code": "css_empty_declaration",
"message": "Declaration cannot be empty",
"start": {
"line": 5,

Loading…
Cancel
Save