-
-
Notifications
You must be signed in to change notification settings - Fork 648
/
dot-notation.js
34 lines (31 loc) · 1003 Bytes
/
dot-notation.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
/**
* @author Yosuke Ota
*/
'use strict'
const RuleTester = require('eslint').RuleTester
const rule = require('../../../lib/rules/dot-notation')
const tester = new RuleTester({
parser: require.resolve('vue-eslint-parser'),
parserOptions: { ecmaVersion: 2015 }
})
tester.run('dot-notation', rule, {
valid: [
`<template><div :attr="foo.bar" /></template>`,
'<template><div attr="foo[\'bar\']" /></template>',
`<template><div :[foo.bar]="a" /></template>`,
`<template><div :attr="foo[bar]" /></template>`,
`<template><div :[foo[bar]]="a" /></template>`
],
invalid: [
{
code: `<template><div :attr="foo['bar']" /></template>`,
output: `<template><div :attr="foo.bar" /></template>`,
errors: ['["bar"] is better written in dot notation.']
},
{
code: `<template><div :[foo[\`bar\`]]="a" /></template>`,
output: `<template><div :[foo.bar]="a" /></template>`,
errors: ['[`bar`] is better written in dot notation.']
}
]
})