mirror of
				https://gitee.com/vant-contrib/vant.git
				synced 2025-11-04 12:52:08 +08:00 
			
		
		
		
	* chore(eslint-config): update dependencies, test cases * chore: update file .lock * fix: wrong .lock file * fix: code style * chore: update `eslint-plugin-vue`
		
			
				
	
	
		
			42 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			42 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
const { ESLint } = require('eslint');
 | 
						|
const path = require('path');
 | 
						|
 | 
						|
const eslint = new ESLint();
 | 
						|
 | 
						|
async function lintProject(name) {
 | 
						|
  const projectPath = path.resolve(__dirname, name);
 | 
						|
  const filesToLint = path.resolve(projectPath, '**');
 | 
						|
  const rest = await eslint.lintFiles(filesToLint);
 | 
						|
  const ruleId = [];
 | 
						|
  rest.forEach((res) =>
 | 
						|
    res.messages.forEach((msg) => {
 | 
						|
      if (ruleId.indexOf(msg.ruleId) < 0) {
 | 
						|
        ruleId.push(msg.ruleId);
 | 
						|
      }
 | 
						|
    })
 | 
						|
  );
 | 
						|
  return ruleId;
 | 
						|
}
 | 
						|
 | 
						|
test('a vue project should pass lint', async () => {
 | 
						|
  const rest = await lintProject('vue');
 | 
						|
 | 
						|
  expect([
 | 
						|
    'no-const-assign',
 | 
						|
    '@typescript-eslint/no-unused-vars',
 | 
						|
    'vue/multi-word-component-names',
 | 
						|
    'no-undef',
 | 
						|
  ]).toEqual(rest);
 | 
						|
});
 | 
						|
 | 
						|
test('a vue-tsx project should pass lint', async () => {
 | 
						|
  const rest = await lintProject('vue-tsx');
 | 
						|
 | 
						|
  expect([
 | 
						|
    '@typescript-eslint/no-unused-vars',
 | 
						|
    'vue/multi-word-component-names',
 | 
						|
    'vue/no-ref-as-operand',
 | 
						|
    '@typescript-eslint/no-empty-interface',
 | 
						|
  ]).toEqual(rest);
 | 
						|
});
 |