-
-
Notifications
You must be signed in to change notification settings - Fork 681
/
Copy pathno-useless-concat.js
46 lines (43 loc) · 1.08 KB
/
no-useless-concat.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
42
43
44
45
46
/**
* @author Yosuke Ota
*/
'use strict'
const RuleTester = require('../../eslint-compat').RuleTester
const rule = require('../../../lib/rules/no-useless-concat')
const tester = new RuleTester({
languageOptions: { parser: require('vue-eslint-parser'), ecmaVersion: 2015 }
})
tester.run('no-useless-concat', rule, {
valid: [
`<template><div :attr="'foo-bar'" /></template>`,
'<template><div attr="foo-bar" /></template>',
`<template><div :[\`foo-bar\`]="a" /></template>`,
// CSS vars injection
`
<style>
.text {
color: v-bind('"red"')
}
</style>`
],
invalid: [
{
code: `<template><div :attr="'foo'+'bar'" /></template>`,
errors: ['Unexpected string concatenation of literals.']
},
{
code: `<template><div :[\`foo\`+\`bar\`]="a" /></template>`,
errors: ['Unexpected string concatenation of literals.']
},
// CSS vars injection
{
code: `
<style>
.text {
color: v-bind('"re" + "d"')
}
</style>`,
errors: ['Unexpected string concatenation of literals.']
}
]
})