mirror of https://github.com/sveltejs/svelte
chore: runtime linting (#12314)
- check that the runtime doesn't use methods that are too new - add linting rule to prevent references to the compiler in the runtime (this is important for the first check, else the ambient node typings would be included, which includes a definition for `at()`, which means we no longer would get errors when violating the "don't use new methods" rule in the runtime) - fix code as a result of these new checks closes #10438pull/12329/head
parent
ed6084806d
commit
5eff68f63d
@ -1,74 +0,0 @@
|
||||
export const reserved = [
|
||||
'arguments',
|
||||
'await',
|
||||
'break',
|
||||
'case',
|
||||
'catch',
|
||||
'class',
|
||||
'const',
|
||||
'continue',
|
||||
'debugger',
|
||||
'default',
|
||||
'delete',
|
||||
'do',
|
||||
'else',
|
||||
'enum',
|
||||
'eval',
|
||||
'export',
|
||||
'extends',
|
||||
'false',
|
||||
'finally',
|
||||
'for',
|
||||
'function',
|
||||
'if',
|
||||
'implements',
|
||||
'import',
|
||||
'in',
|
||||
'instanceof',
|
||||
'interface',
|
||||
'let',
|
||||
'new',
|
||||
'null',
|
||||
'package',
|
||||
'private',
|
||||
'protected',
|
||||
'public',
|
||||
'return',
|
||||
'static',
|
||||
'super',
|
||||
'switch',
|
||||
'this',
|
||||
'throw',
|
||||
'true',
|
||||
'try',
|
||||
'typeof',
|
||||
'var',
|
||||
'void',
|
||||
'while',
|
||||
'with',
|
||||
'yield'
|
||||
];
|
||||
|
||||
const void_element_names = [
|
||||
'area',
|
||||
'base',
|
||||
'br',
|
||||
'col',
|
||||
'command',
|
||||
'embed',
|
||||
'hr',
|
||||
'img',
|
||||
'input',
|
||||
'keygen',
|
||||
'link',
|
||||
'meta',
|
||||
'param',
|
||||
'source',
|
||||
'track',
|
||||
'wbr'
|
||||
];
|
||||
|
||||
/** @param {string} name */
|
||||
export function is_void(name) {
|
||||
return void_element_names.includes(name) || name.toLowerCase() === '!doctype';
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
// Ensure we don't use any methods that are not available in all browser for a long period of time
|
||||
// so that people don't need to polyfill them. Example array.at(...) was introduced to Safari only in 2022
|
||||
"target": "es2021",
|
||||
"lib": ["es2021", "DOM", "DOM.Iterable"],
|
||||
"types": [] // prevent automatic inclusion of @types/node
|
||||
},
|
||||
"include": ["./src/"],
|
||||
// Compiler is allowed to use more recent methods; people using it in the browser are expected to know
|
||||
// how to polyfill missing methods. Also make sure to not include test files as these include Vitest
|
||||
// which then loads node globals.
|
||||
"exclude": ["./src/compiler/**/*", "./src/**/*.test.ts"]
|
||||
}
|
Loading…
Reference in new issue