mirror of
https://github.com/youzan/vant.git
synced 2025-10-18 17:51:54 +00:00
fix: eslint .tsx file failed (#8358)
This commit is contained in:
38
packages/vant-eslint-config/test/index.spec.js
Normal file
38
packages/vant-eslint-config/test/index.spec.js
Normal file
@@ -0,0 +1,38 @@
|
||||
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',
|
||||
'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/no-ref-as-operand',
|
||||
'@typescript-eslint/no-empty-interface',
|
||||
]).toEqual(rest);
|
||||
});
|
Reference in New Issue
Block a user