mirror of https://github.com/sveltejs/svelte
parent
bb71afa821
commit
34e8562f33
@ -0,0 +1,15 @@
|
||||
## avoid_is
|
||||
|
||||
The "is" attribute is not supported cross-browser and should be avoided
|
||||
|
||||
## global_event_reference
|
||||
|
||||
You are referencing globalThis.%name%. Did you forget to declare a variable with that name?
|
||||
|
||||
## illegal_attribute_character
|
||||
|
||||
Attributes should not contain ':' characters to prevent ambiguity with Svelte directives
|
||||
|
||||
## invalid_html_attribute
|
||||
|
||||
'%wrong%' is not a valid HTML attribute. Did you mean '%right%'?
|
||||
@ -0,0 +1,3 @@
|
||||
## css_unused_selector
|
||||
|
||||
Unused CSS selector "%name%"
|
||||
@ -0,0 +1,51 @@
|
||||
import { getLocator } from 'locate-character';
|
||||
|
||||
/** @typedef {{ start?: number, end?: number }} NodeLike */
|
||||
|
||||
// TODO no need to export these, it's temporary
|
||||
/** @type {import('#compiler').Warning[]} */
|
||||
export let warnings = [];
|
||||
/** @type {string | undefined} */
|
||||
export let filename;
|
||||
export let locator = getLocator('', { offsetLine: 1 });
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* source: string;
|
||||
* filename: string | undefined;
|
||||
* }} options
|
||||
* @returns {import('#compiler').Warning[]}
|
||||
*/
|
||||
export function reset_warnings(options) {
|
||||
filename = options.filename;
|
||||
locator = getLocator(options.source, { offsetLine: 1 });
|
||||
|
||||
return (warnings = []);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {null | NodeLike} node
|
||||
* @param {string} code
|
||||
* @param {string} message
|
||||
*/
|
||||
function w(node, code, message) {
|
||||
// @ts-expect-error
|
||||
if (node.ignores?.has(code)) return;
|
||||
|
||||
warnings.push({
|
||||
code,
|
||||
message,
|
||||
filename,
|
||||
start: node?.start !== undefined ? locator(node.start) : undefined,
|
||||
end: node?.end !== undefined ? locator(node.end) : undefined
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {null | NodeLike} node
|
||||
* @param {string} PARAMETER
|
||||
*/
|
||||
export function CODE(node, PARAMETER) {
|
||||
w(node, 'CODE', MESSAGE);
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
/* This file is generated by scripts/process-messages.js. Do not edit! */
|
||||
|
||||
import { getLocator } from 'locate-character';
|
||||
|
||||
/** @typedef {{ start?: number, end?: number }} NodeLike */
|
||||
// TODO no need to export these, it's temporary
|
||||
/** @type {import('#compiler').Warning[]} */
|
||||
export let warnings = [];
|
||||
/** @type {string | undefined} */
|
||||
export let filename;
|
||||
export let locator = getLocator('', { offsetLine: 1 });
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* source: string;
|
||||
* filename: string | undefined;
|
||||
* }} options
|
||||
* @returns {import('#compiler').Warning[]}
|
||||
*/
|
||||
export function reset_warnings(options) {
|
||||
filename = options.filename;
|
||||
locator = getLocator(options.source, { offsetLine: 1 });
|
||||
return warnings = [];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {null | NodeLike} node
|
||||
* @param {string} code
|
||||
* @param {string} message
|
||||
*/
|
||||
function w(node, code, message) {
|
||||
// @ts-expect-error
|
||||
if (node.ignores?.has(code)) return;
|
||||
|
||||
warnings.push({
|
||||
code,
|
||||
message,
|
||||
filename,
|
||||
start: node?.start !== undefined ? locator(node.start) : undefined,
|
||||
end: node?.end !== undefined ? locator(node.end) : undefined
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {null | NodeLike} node
|
||||
|
||||
*/
|
||||
export function avoid_is(node) {
|
||||
w(node, "avoid_is", "The \"is\" attribute is not supported cross-browser and should be avoided");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {null | NodeLike} node
|
||||
* @param {string} name
|
||||
*/
|
||||
export function global_event_reference(node, name) {
|
||||
w(node, "global_event_reference", `You are referencing globalThis.${name}. Did you forget to declare a variable with that name?`);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {null | NodeLike} node
|
||||
|
||||
*/
|
||||
export function illegal_attribute_character(node) {
|
||||
w(node, "illegal_attribute_character", "Attributes should not contain ':' characters to prevent ambiguity with Svelte directives");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {null | NodeLike} node
|
||||
* @param {string} wrong
|
||||
* @param {string} right
|
||||
*/
|
||||
export function invalid_html_attribute(node, wrong, right) {
|
||||
w(node, "invalid_html_attribute", `'${wrong}' is not a valid HTML attribute. Did you mean '${right}'?`);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {null | NodeLike} node
|
||||
* @param {string} name
|
||||
*/
|
||||
export function css_unused_selector(node, name) {
|
||||
w(node, "css_unused_selector", `Unused CSS selector "${name}"`);
|
||||
}
|
||||
Loading…
Reference in new issue