Skip to content

Commit

Permalink
Remove legacy schema from vue/custom-event-name-casing (#2626)
Browse files Browse the repository at this point in the history
  • Loading branch information
FloEdelmann authored Nov 30, 2024
1 parent 29317fb commit 1f88354
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 48 deletions.
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

0 comments on commit 1f88354

Please sign in to comment.