Skip to content
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

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

Open
wants to merge 32 commits into
base: master
Choose a base branch
from

Conversation

JoCa96
Copy link

@JoCa96 JoCa96 commented Sep 16, 2024

Implementation of my proposed rule #2557 Rule Proposal: Disallow shadowing of native HTML event names.
The implementation is heavily based on require-explicit-emits.
The dom-events.json file is based on the Events interface of @vue/runtime-dom/dist/runtime-dom.d.ts.

@FloEdelmann FloEdelmann linked an issue Sep 16, 2024 that may be closed by this pull request
@FloEdelmann
Copy link
Member

Could you please fix the lint and test failures?

@JoCa96
Copy link
Author

JoCa96 commented Sep 16, 2024

@FloEdelmann Of course! Done!

JoCa96 added a commit to SchwarzIT/onyx that referenced this pull request Sep 17, 2024
…lint-plugin-vue" until its released (#1877)

Duplicate "no-shadow-native-events" from "eslint-plugin-vue" until it is
released:
- PR with `eslint-plugin-vue`:
vuejs/eslint-plugin-vue#2558
  - Tests can also be found in that PR
- Official Rule proposal:
vuejs/eslint-plugin-vue#2557

Relates to #1603
Copy link
Member

@FloEdelmann FloEdelmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't looked at the code yet, only at docs and tests. Apart from a few minor suggestions, those look good already!

Comment on lines +904 to +923
{
filename: 'test.vue',
code: `
<template>
<div @click="$emit('click')"/>
</template>
<script setup>
defineEmits(['click'])
</script>
`,
errors: [
{
messageId: 'violation',
line: 6,
column: 20,
endLine: 6,
endColumn: 27
}
]
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this report both the $emit() call and the defineEmits definition?

export type Emits2 = {
(e: 'click' | 'bar', payload: string): void
(e: 'keydown', payload: number): void
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this used for?

docs/rules/no-shadow-native-events.md Outdated Show resolved Hide resolved
docs/rules/no-shadow-native-events.md Outdated Show resolved Hide resolved
docs/rules/no-shadow-native-events.md Outdated Show resolved Hide resolved
Comment on lines +1114 to +1127
{
messageId: 'violation',
line: 4,
column: 32,
endLine: 4,
endColumn: 37
},
{
messageId: 'violation',
line: 4,
column: 32,
endLine: 4,
endColumn: 37
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should only report once

@@ -97,5 +97,6 @@
"prettier": "^3.3.3",
"typescript": "^5.5.4",
"vitepress": "^1.3.1"
}
},
"packageManager": "[email protected]+sha512.60c18acd138bff695d339be6ad13f7e936eea6745660d4cc4a776d5247c540d0edee1a563695c183a66eb917ef88f2b4feb1fc25f32a7adcadc7aaf3438e99c1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please revert this change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rule Proposal: Disallow shadowing of native HTML event names
2 participants