chore: add no-debugger eslint rule (#5906)
This commit is contained in:
		
							parent
							
								
									8a123ac34f
								
							
						
					
					
						commit
						9ecee16f89
					
				@ -7,6 +7,7 @@ module.exports = {
 | 
				
			|||||||
    sourceType: 'module'
 | 
					    sourceType: 'module'
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  rules: {
 | 
					  rules: {
 | 
				
			||||||
 | 
					    'no-debugger': 'error',
 | 
				
			||||||
    'no-unused-vars': [
 | 
					    'no-unused-vars': [
 | 
				
			||||||
      'error',
 | 
					      'error',
 | 
				
			||||||
      // we are only using this rule to check for unused arguments since TS
 | 
					      // we are only using this rule to check for unused arguments since TS
 | 
				
			||||||
 | 
				
			|||||||
@ -29,7 +29,7 @@ export const DOMNodeTransforms: NodeTransform[] = [
 | 
				
			|||||||
]
 | 
					]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const DOMDirectiveTransforms: Record<string, DirectiveTransform> = {
 | 
					export const DOMDirectiveTransforms: Record<string, DirectiveTransform> = {
 | 
				
			||||||
cloak: noopDirectiveTransform,
 | 
					  cloak: noopDirectiveTransform,
 | 
				
			||||||
  html: transformVHtml,
 | 
					  html: transformVHtml,
 | 
				
			||||||
  text: transformVText,
 | 
					  text: transformVText,
 | 
				
			||||||
  model: transformModel, // override compiler-core
 | 
					  model: transformModel, // override compiler-core
 | 
				
			||||||
 | 
				
			|||||||
@ -257,7 +257,6 @@ describe('component: proxy', () => {
 | 
				
			|||||||
    expect(instanceProxy.isDisplayed).toBe(true)
 | 
					    expect(instanceProxy.isDisplayed).toBe(true)
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
					 | 
				
			||||||
  test('allow jest spying on proxy methods with Object.defineProperty', () => {
 | 
					  test('allow jest spying on proxy methods with Object.defineProperty', () => {
 | 
				
			||||||
    // #5417
 | 
					    // #5417
 | 
				
			||||||
    let instanceProxy: any
 | 
					    let instanceProxy: any
 | 
				
			||||||
@ -426,7 +425,6 @@ describe('component: proxy', () => {
 | 
				
			|||||||
    expect(instanceProxy.fromProp).toBe(false)
 | 
					    expect(instanceProxy.fromProp).toBe(false)
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
  // #864
 | 
					  // #864
 | 
				
			||||||
  test('should not warn declared but absent props', () => {
 | 
					  test('should not warn declared but absent props', () => {
 | 
				
			||||||
    const Comp = {
 | 
					    const Comp = {
 | 
				
			||||||
 | 
				
			|||||||
@ -443,10 +443,8 @@ describe('api: template refs', () => {
 | 
				
			|||||||
    expect(mapRefs()).toMatchObject(['2', '3', '4'])
 | 
					    expect(mapRefs()).toMatchObject(['2', '3', '4'])
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  test('named ref in v-for', async () => {
 | 
					  test('named ref in v-for', async () => {
 | 
				
			||||||
    const show = ref(true);
 | 
					    const show = ref(true)
 | 
				
			||||||
    const list = reactive([1, 2, 3])
 | 
					    const list = reactive([1, 2, 3])
 | 
				
			||||||
    const listRefs = ref([])
 | 
					    const listRefs = ref([])
 | 
				
			||||||
    const mapRefs = () => listRefs.value.map(n => serializeInner(n))
 | 
					    const mapRefs = () => listRefs.value.map(n => serializeInner(n))
 | 
				
			||||||
@ -495,6 +493,4 @@ describe('api: template refs', () => {
 | 
				
			|||||||
    await nextTick()
 | 
					    await nextTick()
 | 
				
			||||||
    expect(mapRefs()).toMatchObject(['2', '3', '4'])
 | 
					    expect(mapRefs()).toMatchObject(['2', '3', '4'])
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
				
			|||||||
@ -135,8 +135,8 @@ const enum BooleanFlags {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// extract props which defined with default from prop options
 | 
					// extract props which defined with default from prop options
 | 
				
			||||||
export type ExtractDefaultPropTypes<O> = O extends object
 | 
					export type ExtractDefaultPropTypes<O> = O extends object
 | 
				
			||||||
  // use `keyof Pick<O, DefaultKeys<O>>` instead of `DefaultKeys<O>` to support IDE features
 | 
					  ? // use `keyof Pick<O, DefaultKeys<O>>` instead of `DefaultKeys<O>` to support IDE features
 | 
				
			||||||
  ? { [K in keyof Pick<O, DefaultKeys<O>>]: InferPropType<O[K]> }
 | 
					    { [K in keyof Pick<O, DefaultKeys<O>>]: InferPropType<O[K]> }
 | 
				
			||||||
  : {}
 | 
					  : {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type NormalizedProp =
 | 
					type NormalizedProp =
 | 
				
			||||||
@ -226,7 +226,7 @@ export function updateProps(
 | 
				
			|||||||
      for (let i = 0; i < propsToUpdate.length; i++) {
 | 
					      for (let i = 0; i < propsToUpdate.length; i++) {
 | 
				
			||||||
        let key = propsToUpdate[i]
 | 
					        let key = propsToUpdate[i]
 | 
				
			||||||
        // skip if the prop key is a declared emit event listener
 | 
					        // skip if the prop key is a declared emit event listener
 | 
				
			||||||
        if (isEmitListener(instance.emitsOptions, key)){
 | 
					        if (isEmitListener(instance.emitsOptions, key)) {
 | 
				
			||||||
          continue
 | 
					          continue
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        // PROPS flag guarantees rawProps to be non-null
 | 
					        // PROPS flag guarantees rawProps to be non-null
 | 
				
			||||||
 | 
				
			|||||||
@ -113,7 +113,7 @@ export function createHydrationFunctions(
 | 
				
			|||||||
          nextNode = onMismatch()
 | 
					          nextNode = onMismatch()
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
          if ((node as Text).data !== vnode.children) {
 | 
					          if ((node as Text).data !== vnode.children) {
 | 
				
			||||||
            hasMismatch = true; debugger
 | 
					            hasMismatch = true
 | 
				
			||||||
            __DEV__ &&
 | 
					            __DEV__ &&
 | 
				
			||||||
              warn(
 | 
					              warn(
 | 
				
			||||||
                `Hydration text mismatch:` +
 | 
					                `Hydration text mismatch:` +
 | 
				
			||||||
@ -351,7 +351,7 @@ export function createHydrationFunctions(
 | 
				
			|||||||
        )
 | 
					        )
 | 
				
			||||||
        let hasWarned = false
 | 
					        let hasWarned = false
 | 
				
			||||||
        while (next) {
 | 
					        while (next) {
 | 
				
			||||||
          hasMismatch = true; debugger
 | 
					          hasMismatch = true
 | 
				
			||||||
          if (__DEV__ && !hasWarned) {
 | 
					          if (__DEV__ && !hasWarned) {
 | 
				
			||||||
            warn(
 | 
					            warn(
 | 
				
			||||||
              `Hydration children mismatch in <${vnode.type as string}>: ` +
 | 
					              `Hydration children mismatch in <${vnode.type as string}>: ` +
 | 
				
			||||||
@ -366,7 +366,7 @@ export function createHydrationFunctions(
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
      } else if (shapeFlag & ShapeFlags.TEXT_CHILDREN) {
 | 
					      } else if (shapeFlag & ShapeFlags.TEXT_CHILDREN) {
 | 
				
			||||||
        if (el.textContent !== vnode.children) {
 | 
					        if (el.textContent !== vnode.children) {
 | 
				
			||||||
          hasMismatch = true; debugger
 | 
					          hasMismatch = true
 | 
				
			||||||
          __DEV__ &&
 | 
					          __DEV__ &&
 | 
				
			||||||
            warn(
 | 
					            warn(
 | 
				
			||||||
              `Hydration text content mismatch in <${
 | 
					              `Hydration text content mismatch in <${
 | 
				
			||||||
@ -411,7 +411,7 @@ export function createHydrationFunctions(
 | 
				
			|||||||
      } else if (vnode.type === Text && !vnode.children) {
 | 
					      } else if (vnode.type === Text && !vnode.children) {
 | 
				
			||||||
        continue
 | 
					        continue
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        hasMismatch = true; debugger
 | 
					        hasMismatch = true
 | 
				
			||||||
        if (__DEV__ && !hasWarned) {
 | 
					        if (__DEV__ && !hasWarned) {
 | 
				
			||||||
          warn(
 | 
					          warn(
 | 
				
			||||||
            `Hydration children mismatch in <${container.tagName.toLowerCase()}>: ` +
 | 
					            `Hydration children mismatch in <${container.tagName.toLowerCase()}>: ` +
 | 
				
			||||||
@ -465,7 +465,7 @@ export function createHydrationFunctions(
 | 
				
			|||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      // fragment didn't hydrate successfully, since we didn't get a end anchor
 | 
					      // fragment didn't hydrate successfully, since we didn't get a end anchor
 | 
				
			||||||
      // back. This should have led to node/children mismatch warnings.
 | 
					      // back. This should have led to node/children mismatch warnings.
 | 
				
			||||||
      hasMismatch = true; debugger
 | 
					      hasMismatch = true
 | 
				
			||||||
      // since the anchor is missing, we need to create one and insert it
 | 
					      // since the anchor is missing, we need to create one and insert it
 | 
				
			||||||
      insert((vnode.anchor = createComment(`]`)), container, next)
 | 
					      insert((vnode.anchor = createComment(`]`)), container, next)
 | 
				
			||||||
      return next
 | 
					      return next
 | 
				
			||||||
@ -480,7 +480,7 @@ export function createHydrationFunctions(
 | 
				
			|||||||
    slotScopeIds: string[] | null,
 | 
					    slotScopeIds: string[] | null,
 | 
				
			||||||
    isFragment: boolean
 | 
					    isFragment: boolean
 | 
				
			||||||
  ): Node | null => {
 | 
					  ): Node | null => {
 | 
				
			||||||
    hasMismatch = true; debugger
 | 
					    hasMismatch = true
 | 
				
			||||||
    __DEV__ &&
 | 
					    __DEV__ &&
 | 
				
			||||||
      warn(
 | 
					      warn(
 | 
				
			||||||
        `Hydration node mismatch:\n- Client vnode:`,
 | 
					        `Hydration node mismatch:\n- Client vnode:`,
 | 
				
			||||||
 | 
				
			|||||||
@ -15,8 +15,7 @@ describe('createApp for dom', () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  // #4398
 | 
					  // #4398
 | 
				
			||||||
  test('should not mutate original root component options object', () => {
 | 
					  test('should not mutate original root component options object', () => {
 | 
				
			||||||
    
 | 
					    const originalObj = {
 | 
				
			||||||
    const originalObj =  {
 | 
					 | 
				
			||||||
      data() {
 | 
					      data() {
 | 
				
			||||||
        return {
 | 
					        return {
 | 
				
			||||||
          counter: 0
 | 
					          counter: 0
 | 
				
			||||||
@ -28,17 +27,16 @@ describe('createApp for dom', () => {
 | 
				
			|||||||
      expect(msg).toMatch(`Component is missing template or render function`)
 | 
					      expect(msg).toMatch(`Component is missing template or render function`)
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const Root = { ...originalObj}
 | 
					    const Root = { ...originalObj }
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    const app = createApp(Root)
 | 
					    const app = createApp(Root)
 | 
				
			||||||
    app.config.warnHandler = handler
 | 
					    app.config.warnHandler = handler
 | 
				
			||||||
    app.mount(document.createElement('div')) 
 | 
					    app.mount(document.createElement('div'))
 | 
				
			||||||
 
 | 
					
 | 
				
			||||||
    // ensure mount is based on a copy of Root object rather than Root object itself 
 | 
					    // ensure mount is based on a copy of Root object rather than Root object itself
 | 
				
			||||||
    expect(app._component).not.toBe(Root)
 | 
					    expect(app._component).not.toBe(Root)
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    // ensure no mutation happened to Root object
 | 
					    // ensure no mutation happened to Root object
 | 
				
			||||||
    expect(originalObj).toMatchObject(Root)
 | 
					    expect(originalObj).toMatchObject(Root)
 | 
				
			||||||
    
 | 
					 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
				
			|||||||
@ -12,7 +12,9 @@ import {
 | 
				
			|||||||
} from '@vue/shared'
 | 
					} from '@vue/shared'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// leading comma for empty string ""
 | 
					// leading comma for empty string ""
 | 
				
			||||||
const shouldIgnoreProp = makeMap(`,key,ref,innerHTML,textContent,ref_key,ref_for`)
 | 
					const shouldIgnoreProp = makeMap(
 | 
				
			||||||
 | 
					  `,key,ref,innerHTML,textContent,ref_key,ref_for`
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function ssrRenderAttrs(
 | 
					export function ssrRenderAttrs(
 | 
				
			||||||
  props: Record<string, unknown>,
 | 
					  props: Record<string, unknown>,
 | 
				
			||||||
 | 
				
			|||||||
@ -7,7 +7,6 @@ export type UnionToIntersection<U> = (
 | 
				
			|||||||
// make keys required but keep undefined values
 | 
					// make keys required but keep undefined values
 | 
				
			||||||
export type LooseRequired<T> = { [P in string & keyof T]: T[P] }
 | 
					export type LooseRequired<T> = { [P in string & keyof T]: T[P] }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
// If the the type T accepts type "any", output type Y, otherwise output type N.
 | 
					// If the the type T accepts type "any", output type Y, otherwise output type N.
 | 
				
			||||||
// https://stackoverflow.com/questions/49927523/disallow-call-with-any/49928360#49928360
 | 
					// https://stackoverflow.com/questions/49927523/disallow-call-with-any/49928360#49928360
 | 
				
			||||||
export type IfAny<T, Y, N> = 0 extends (1 & T) ? Y : N
 | 
					export type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user