You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							46 lines
						
					
					
						
							1.2 KiB
						
					
					
				
			
		
		
	
	
							46 lines
						
					
					
						
							1.2 KiB
						
					
					
				/** | 
						|
 * @fileoverview disallow unused variable definitions of v-for directives or scope attributes. | 
						|
 * @author 薛定谔的猫<hh_2013@foxmail.com> | 
						|
 */ | 
						|
'use strict' | 
						|
 | 
						|
const utils = require('../utils') | 
						|
 | 
						|
// ------------------------------------------------------------------------------ | 
						|
// Rule Definition | 
						|
// ------------------------------------------------------------------------------ | 
						|
 | 
						|
module.exports = { | 
						|
  meta: { | 
						|
    type: 'suggestion', | 
						|
    docs: { | 
						|
      description: 'disallow unused variable definitions of v-for directives or scope attributes', | 
						|
      category: 'essential', | 
						|
      url: 'https://eslint.vuejs.org/rules/no-unused-vars.html' | 
						|
    }, | 
						|
    fixable: null, | 
						|
    schema: [] | 
						|
  }, | 
						|
 | 
						|
  create (context) { | 
						|
    return utils.defineTemplateBodyVisitor(context, { | 
						|
      VElement (node) { | 
						|
        const variables = node.variables | 
						|
 | 
						|
        for ( | 
						|
          let i = variables.length - 1; | 
						|
          i >= 0 && !variables[i].references.length; | 
						|
          i-- | 
						|
        ) { | 
						|
          const variable = variables[i] | 
						|
          context.report({ | 
						|
            node: variable.id, | 
						|
            loc: variable.id.loc, | 
						|
            message: `'{{name}}' is defined but never used.`, | 
						|
            data: variable.id | 
						|
          }) | 
						|
        } | 
						|
      } | 
						|
    }) | 
						|
  } | 
						|
}
 | 
						|
 |