Skip to content

Commit 82123a3

Browse files
committed
add explanatory comments
1 parent 7d47fac commit 82123a3

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

lib/rules/no-shadow-native-events.js

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ module.exports = {
6060
categories: undefined,
6161
url: 'https://eslint.vuejs.org/rules/no-shadow-native-events.html'
6262
},
63-
fixable: null,
64-
hasSuggestions: false,
6563
schema: [],
6664
messages: {
6765
violation:
@@ -73,7 +71,10 @@ module.exports = {
7371
/** @type {Map<ObjectExpression | Program, { contextReferenceIds: Set<Identifier>, emitReferenceIds: Set<Identifier> }>} */
7472
const setupContexts = new Map()
7573

76-
/** @type {Set<string>} */
74+
/**
75+
* Tracks violating emit definitions, so that calls of this emit are not reported additionally.
76+
* @type {Set<string>}
77+
* */
7778
const definedAndReportedEmits = new Set()
7879

7980
/**
@@ -95,6 +96,7 @@ module.exports = {
9596
}
9697

9798
/**
99+
* Verify if an emit call violates the rule of not using a native dom event name.
98100
* @param {NameWithLoc} nameWithLoc
99101
*/
100102
function verifyEmit(nameWithLoc) {
@@ -111,6 +113,25 @@ module.exports = {
111113
})
112114
}
113115

116+
/**
117+
* Verify if an emit declaration violates the rule of not using a native dom event name.
118+
* @param {ComponentEmit[]} emits
119+
*/
120+
const verifyEmitDeclaration = (emits) => {
121+
for (const { node, emitName } of emits) {
122+
if (!node || !emitName || !domEvents.includes(emitName.toLowerCase())) {
123+
continue
124+
}
125+
126+
definedAndReportedEmits.add(emitName)
127+
context.report({
128+
messageId: 'violation',
129+
data: { name: emitName },
130+
loc: node.loc
131+
})
132+
}
133+
}
134+
114135
const callVisitor = {
115136
/**
116137
* @param {CallExpression} node
@@ -162,23 +183,6 @@ module.exports = {
162183
}
163184
}
164185
}
165-
/**
166-
* @param {ComponentEmit[]} emits
167-
*/
168-
const verifyEmitDeclaration = (emits) => {
169-
for (const { node, emitName } of emits) {
170-
if (!node || !emitName || !domEvents.includes(emitName.toLowerCase())) {
171-
continue
172-
}
173-
174-
definedAndReportedEmits.add(emitName)
175-
context.report({
176-
messageId: 'violation',
177-
data: { name: emitName },
178-
loc: node.loc
179-
})
180-
}
181-
}
182186

183187
return utils.compositingVisitors(
184188
utils.defineTemplateBodyVisitor(

0 commit comments

Comments
 (0)