chore(lint): allow DOM globals in runtime-vapor

This commit is contained in:
Evan You 2025-02-01 21:07:06 +08:00
parent 5a62266e13
commit 01d6aa0d33
No known key found for this signature in database
GPG Key ID: 00E9AB7A6704CE0A
6 changed files with 2 additions and 10 deletions

View File

@ -106,7 +106,7 @@ export default tseslint.config(
// Packages targeting DOM
{
files: ['packages/{vue,vue-compat,runtime-dom}/**'],
files: ['packages/{vue,vue-compat,runtime-dom,runtime-vapor}/**'],
rules: {
'no-restricted-globals': ['error', ...NodeGlobals],
},

View File

@ -37,8 +37,7 @@ export class DynamicFragment extends Fragment {
this.anchor =
__DEV__ && anchorLabel
? createComment(anchorLabel)
: // eslint-disable-next-line no-restricted-globals
document.createTextNode('')
: document.createTextNode('')
}
update(render?: BlockFn, key: any = render): void {

View File

@ -452,7 +452,6 @@ export function createComponentWithFallback(
return createComponent(comp, rawProps, rawSlots, isSingleRoot)
}
// eslint-disable-next-line no-restricted-globals
const el = document.createElement(comp)
// mark single root
;(el as any).$root = isSingleRoot

View File

@ -76,7 +76,6 @@ export const delegateEvents = (...names: string[]): void => {
for (const name of names) {
if (!delegatedEvents[name]) {
delegatedEvents[name] = true
// eslint-disable-next-line no-restricted-globals
document.addEventListener(name, delegatedEventHandler)
}
}
@ -93,7 +92,6 @@ const delegatedEventHandler = (e: Event) => {
Object.defineProperty(e, 'currentTarget', {
configurable: true,
get() {
// eslint-disable-next-line no-restricted-globals
return node || document
},
})

View File

@ -3,7 +3,6 @@ import { renderEffect } from '../renderEffect'
import { setText } from './prop'
export function createTextNode(values?: any[] | (() => any[])): Text {
// eslint-disable-next-line no-restricted-globals
const node = document.createTextNode('')
if (values) {
if (isArray(values)) {
@ -17,12 +16,10 @@ export function createTextNode(values?: any[] | (() => any[])): Text {
/*! #__NO_SIDE_EFFECTS__ */
export function createComment(data: string): Comment {
// eslint-disable-next-line no-restricted-globals
return document.createComment(data)
}
/*! #__NO_SIDE_EFFECTS__ */
export function querySelector(selectors: string): Element | null {
// eslint-disable-next-line no-restricted-globals
return document.querySelector(selectors)
}

View File

@ -2,7 +2,6 @@
export function template(html: string, root?: boolean) {
let node: ChildNode
const create = () => {
// eslint-disable-next-line no-restricted-globals
const t = document.createElement('template')
t.innerHTML = html
return t.content.firstChild!