foo(event)" />
+ `,
+ output: `
+
+
+ `,
+ options: [['method', 'inline-function']],
+ errors: [
+ {
+ message: 'Prefer method handler over inline function in v-on.',
+ line: 2,
+ column: 22
+ },
+ {
+ message: 'Prefer method handler over inline function in v-on.',
+ line: 3,
+ column: 22
+ }
+ ]
+ },
{
filename: 'test.vue',
code: `
@@ -1136,6 +1195,143 @@ tester.run('v-on-handler-style', rule, {
column: 25
}
]
+ },
+ // ['inline', 'inline-function']
+ {
+ filename: 'test.vue',
+ code: `
+ `,
+ output: `
+
+
+
+
+ foo(event)" />
+
+ foo(event, e)" />
+
+ `,
+ options: [['inline', 'inline-function']],
+ errors: [
+ {
+ message: 'Prefer inline handler over inline function in v-on.',
+ line: 2,
+ column: 25
+ },
+ {
+ message: 'Prefer inline handler over method handler in v-on.',
+ line: 3,
+ column: 25
+ },
+ {
+ message: 'Prefer inline handler over inline function in v-on.',
+ line: 4,
+ column: 25
+ },
+ {
+ message: 'Prefer inline handler over inline function in v-on.',
+ line: 5,
+ column: 25
+ },
+ {
+ message: 'Prefer inline handler over inline function in v-on.',
+ line: 6,
+ column: 25
+ },
+ {
+ message: 'Prefer inline handler over inline function in v-on.',
+ line: 8,
+ column: 27
+ }
+ ]
+ },
+ // ['inline', 'inline-function'] + allowInlineFuncSingleArg
+ {
+ filename: 'test.vue',
+ code: `
+ value++" />
+
+ foo()" />
+ foo($event)" />
+ foo(event)" />
+
+ foo(e)" />
+ foo(event, e)" />
+
+ `,
+ output: `
+
+
+
+
+ foo(event)" />
+
+
+ foo(event, e)" />
+
+ `,
+ options: [
+ ['inline', 'inline-function'],
+ { allowInlineFuncSingleArg: true }
+ ],
+ errors: [
+ {
+ message: 'Prefer inline handler over inline function in v-on.',
+ line: 2,
+ column: 25
+ },
+ {
+ message: 'Prefer inline handler over method handler in v-on.',
+ line: 3,
+ column: 25
+ },
+ {
+ message: 'Prefer inline handler over inline function in v-on.',
+ line: 4,
+ column: 25
+ },
+ {
+ message: 'Prefer inline handler over inline function in v-on.',
+ line: 5,
+ column: 25
+ },
+ {
+ message: 'Prefer inline handler over inline function in v-on.',
+ line: 8,
+ column: 27
+ }
+ ]
+ },
+ // ['method', 'inline-function'] + allowInlineFuncSingleArg
+ {
+ filename: 'test.vue',
+ code: `
+ foo()" />
+
foo(event)" />
+ `,
+ output: `
+
+ foo(event)" />
+ `,
+ options: [
+ ['method', 'inline-function'],
+ { allowInlineFuncSingleArg: true }
+ ],
+ errors: [
+ {
+ message: 'Prefer method handler over inline function in v-on.',
+ line: 2,
+ column: 22
+ }
+ ]
}
]
})