Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 18 additions & 36 deletions lib/rules/custom-event-name-casing.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,6 @@ function getCalleeMemberNode(node) {
return null
}

const OBJECT_OPTION_SCHEMA = {
type: 'object',
properties: {
ignores: {
type: 'array',
items: { type: 'string' },
uniqueItems: true,
additionalItems: false
}
},
additionalProperties: false
}
module.exports = {
meta: {
type: 'suggestion',
Expand All @@ -75,24 +63,23 @@ module.exports = {
url: 'https://eslint.vuejs.org/rules/custom-event-name-casing.html'
},
fixable: null,
schema: {
anyOf: [
{
type: 'array',
items: [
{
enum: ALLOWED_CASE_OPTIONS
},
OBJECT_OPTION_SCHEMA
]
schema: [
{
enum: ALLOWED_CASE_OPTIONS
},
{
type: 'object',
properties: {
ignores: {
type: 'array',
items: { type: 'string' },
uniqueItems: true,
additionalItems: false
}
},
// For backward compatibility
{
type: 'array',
items: [OBJECT_OPTION_SCHEMA]
}
]
},
additionalProperties: false
}
],
messages: {
unexpected: "Custom event name '{{name}}' must be {{caseType}}."
}
Expand All @@ -102,13 +89,8 @@ module.exports = {
/** @type {Map<ObjectExpression|Program, {contextReferenceIds:Set<Identifier>,emitReferenceIds:Set<Identifier>}>} */
const setupContexts = new Map()
let emitParamName = ''
const options =
context.options.length === 1 && typeof context.options[0] !== 'string'
? // For backward compatibility
[undefined, context.options[0]]
: context.options
const caseType = options[0] || DEFAULT_CASE
const objectOption = options[1] || {}
const caseType = context.options[0] || DEFAULT_CASE
const objectOption = context.options[1] || {}
const caseChecker = casing.getChecker(caseType)
/** @type {RegExp[]} */
const ignores = (objectOption.ignores || []).map(toRegExp)
Expand Down
12 changes: 0 additions & 12 deletions tests/lib/rules/custom-event-name-casing.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,18 +237,6 @@ tester.run('custom-event-name-casing', rule, {
]
},

// For backward compatibility
{
filename: 'test.vue',
code: `
<template>
<input
@click="$emit('fooBar')">
</template>
`,
options: [{ ignores: ['fooBar'] }]
},

// camelCase
{
filename: 'test.vue',
Expand Down