Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(no-shadow-native-events): initial implementation #2558

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
JoCa96 wants to merge 34 commits into vuejs:master
base: master
Choose a base branch
Loading
from JoCa96:joca96/feat-no-shadow-native
Open
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7b640fe
initial version
JoCa96 Sep 16, 2024
8ad0f4b
added invalid tests
JoCa96 Sep 16, 2024
fe3615d
added valid tests cases
JoCa96 Sep 16, 2024
892f277
clean up
JoCa96 Sep 16, 2024
391a4bb
add docs
JoCa96 Sep 16, 2024
654332a
update related docs
JoCa96 Sep 16, 2024
300c138
add missing test fixture
JoCa96 Sep 16, 2024
c3e68ca
fix link
JoCa96 Sep 16, 2024
218a577
fix missing typedef for NameWithLoc
JoCa96 Sep 16, 2024
4e55123
lint issue: remove todo
JoCa96 Sep 16, 2024
ddfb904
fix lint issue: "space inside link text"
JoCa96 Sep 16, 2024
81ddf6a
remove unused options
JoCa96 Sep 16, 2024
7d47fac
replace array with Set
JoCa96 Sep 16, 2024
82123a3
add explanatory comments
JoCa96 Sep 16, 2024
c72133f
initial version
JoCa96 Sep 16, 2024
1c40d3b
added invalid tests
JoCa96 Sep 16, 2024
8e2cfd7
added valid tests cases
JoCa96 Sep 16, 2024
9d0e1c2
clean up
JoCa96 Sep 16, 2024
84b7b78
add docs
JoCa96 Sep 16, 2024
7bdf176
update related docs
JoCa96 Sep 16, 2024
b10bae2
add missing test fixture
JoCa96 Sep 16, 2024
2dc6949
fix link
JoCa96 Sep 16, 2024
9a8ccd7
fix missing typedef for NameWithLoc
JoCa96 Sep 16, 2024
dc011e0
lint issue: remove todo
JoCa96 Sep 16, 2024
8c71413
fix lint issue: "space inside link text"
JoCa96 Sep 16, 2024
f3ffb7d
remove unused options
JoCa96 Sep 16, 2024
066689b
replace array with Set
JoCa96 Sep 16, 2024
7941f9c
add explanatory comments
JoCa96 Sep 16, 2024
3901c99
review: execute "npm run update"
JoCa96 Sep 19, 2024
44f5eb4
Merge branch 'joca96/feat-no-shadow-native' of https://github.com/JoC...
JoCa96 Sep 19, 2024
b62c161
Update docs/rules/no-shadow-native-events.md
JoCa96 Sep 19, 2024
4feb834
Update docs/rules/no-shadow-native-events.md
JoCa96 Sep 19, 2024
3e9e020
review: revert accidental packageManager field in package.json
JoCa96 Sep 20, 2024
df3e87e
Merge branch 'joca96/feat-no-shadow-native' of https://github.com/JoC...
JoCa96 Sep 20, 2024
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
Prev Previous commit
Next Next commit
add docs
  • Loading branch information
JoCa96 committed Sep 16, 2024
commit 391a4bb83d21c7c96ad91e26faebfa0dc10a332d
50 changes: 50 additions & 0 deletions docs/rules/no-shadow-native-events.md
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
pageClass: rule-details
sidebarDepth: 0
title: vue/no-shadow-native-events
description: disallow `emits` which would shadow native html events
---
# vue/no-shadow-native-events

> disallow `emits` which would shadow native HTML events

- :exclamation: <badge text="This rule has not been released yet." vertical="middle" type="error"> _**This rule has not been released yet.**_ </badge>

## :book: Rule Details

This rule reports emits that shadow native HTML events. (The `emits` option is a new in Vue.js 3.0.0+)

Using native event names for emits can lead to incorrect assumptions about an emit and cause confusion. This is caused by Vue emits behaving differently from native events. E.g. :
- The payload of an emit can be chosen arbitrarily
- Vue emits do not bubble, while most native events do
- [Event modifiers](https://vuejs.org/guide/essentials/event-handling.html#event-modifiers) only work on HTML events or when the original event is re-emitted as emit payload.
- When the native event is remitted the `event.target` might not match the actual event-listeners location.

The rule is mostly aimed at developers of component libraries.

<eslint-code-block :rules="{'vue/no-shadow-native-events': ['error']}">

```vue
<template>
<!-- ✓ GOOD -->
<button @click="$emit('close')">Close</button>
<!-- ✗ BAD -->
<button @click="$emit('click')">Close</button>
</template>
```

</eslint-code-block>

## :wrench: Options

Nothing.

## :couple: Related Rules

- [vue/no-unused-emit-declarations](./no-unused-emit-declarations.md)
- [vue/require-explicit-emits](./require-explicit-emits.md)

## :books: Further Reading

- [Components In-Depth - Events / Component Events ](https://vuejs.org/guide/components/events.html#event-arguments)
- [Vue RFCs - 0030-emits-option](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0030-emits-option.md)

AltStyle によって変換されたページ (->オリジナル) /