Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
babel-plugin-jsx-event-modifiers
Advanced tools
This babel plugin adds some syntactic sugar to JSX.
npm i babel-plugin-jsx-event-modifiers -D
or
yarn add babel-plugin-jsx-event-modifiers -D
Then add jsx-event-modifiers
to your .babelrc
file under plugins
example .babelrc (for vue):
{
"presets": ["es2015"],
"plugins": ["jsx-event-modifiers", "transform-vue-jsx"]
}
example .babelrc (for react):
{
"presets": [
"es2015",
"react"
],
"plugins": ["jsx-event-modifiers"]
}
Example:
export default {
render () {
return (
<input
onKeyup:up={this.methodForPressingUp}
onKeyup:down={this.methodForPressingDown}
onKeyup:bare-shift-enter={this.methodOnlyOnShiftEnter}
onKeyup:bare-alt-enter={this.methodOnlyOnAltEnter}
/>
)
}
}
will be transpiled into:
export default {
render() {
return (
<input
{...{
on: {
keyup: [
$event => {
if (!('button' in $event) && this._k($event.keyCode, 'up', 38)) return null
this.methodForPressingUp($event)
},
$event => {
if (!('button' in $event) && this._k($event.keyCode, 'down', 40)) return null
this.methodForPressingDown($event)
},
$event => {
if (
($event.ctrlKey && $event.altKey && $event.metaKey) ||
!$event.shiftKey ||
(!('button' in $event) && this._k($event.keyCode, 'enter', 13))
)
return null
this.methodOnlyOnShiftEnter($event)
},
$event => {
if (
($event.ctrlKey && $event.shiftKey && $event.metaKey) ||
!$event.altKey ||
(!('button' in $event) && this._k($event.keyCode, 'enter', 13))
)
return null
this.methodOnlyOnAltEnter($event)
},
],
},
}}
/>
)
},
}
Vue template:
<input
@keyup.up="methodForPressingUp"
@keyup.down="methodForPressingDown"
@keyup.bare.shift.enter="methodOnlyOnShiftEnter"
@keyup.bare.alt.enter="methodOnlyOnAltEnter"
@keyup.120="onPressKey120('some', 'arguments')"
>
JSX:
<input
onKeyup:up={this.methodForPressingUp}
onKeyup:down={this.methodForPressingDown}
onKeyup:bare-shift-enter={this.methodOnlyOnShiftEnter}
onKeyup:bare-alt-enter={this.methodOnlyOnAltEnter}
onKeyup:k120={() => this.onPressKey120('some', 'arguments')}
/>
:
and separated by -
(in vue: prefixed by .
and separated by .
)k
FAQs
JSX Syntactic Sugar Plugin for Event Modifiers
The npm package babel-plugin-jsx-event-modifiers receives a total of 62,051 weekly downloads. As such, babel-plugin-jsx-event-modifiers popularity was classified as popular.
We found that babel-plugin-jsx-event-modifiers demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.