forked from vuejs/eslint-plugin-vue
/
html-forbid-elements.js
41 lines (38 loc) · 1014 Bytes
/
html-forbid-elements.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* @author Doug Wade
*/
'use strict'
const RuleTester = require('eslint').RuleTester
const rule = require('../../../lib/rules/html-forbid-elements')
const tester = new RuleTester({
parser: require.resolve('vue-eslint-parser'),
parserOptions: { ecmaVersion: 2015 }
})
tester.run('html-forbid-elements', rule, {
valid: [
{
filename: 'test.vue',
code: '',
options: [{ forbid: ['button'] }]
},
{
filename: 'test.vue',
code: '<template><div class="foo"></div></template>',
options: [{ forbid: ['button'] }]
}
],
invalid: [
{
filename: 'test.vue',
code: '<template><button type="submit"></button></template>',
errors: ['Unexpected use of forbidden HTML element button.'],
options: [{ forbid: ['button'] }]
},
{
filename: 'test.vue',
code: "<template><div class='foo'></div></template>",
errors: ['Unexpected use of forbidden HTML element div.'],
options: [{ forbid: ['div'] }]
}
]
})