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.
eslint-plugin-use-decorator
Advanced tools
This is a custom plugin for eslint which enforces the use of decorators on methods.
This is a custom plugin for eslint which enforces the use of decorators on methods.
This only works with the @typescript-eslint
plugin
npm install --save-dev eslint-plugin-use-decorator
Add this to your .eslintrc
// .eslintrc
{
"plugins": ["use-decorator"],
"rules": {
"use-decorator/use-decorator": [1, {
"params": [
{
"name": "assertParameter",
"public": true
}
],
"methods": [
{
"name": "assert",
"public": true
},
{
"name": "errorcatch",
"async": true,
"private": true
}
],
"class": [
{
"superClass": ["Vue", "Mixins"],
"name": "Component"
},
]
}]
}
}
Now methods and its parameters are checked for their decorators. Above rule would enforce following custom decorators:
class SomeClass {
@assert
someMethod(
@assertParameter
someParameter: number
): number {
return someParameter;
}
@errorcatch
private async somePrivateAsyncMethod(
someParameter: number
): Promise<number> {
return someParameter;
}
/**
* This one does not need a decorator, because its only async.
* It would need to be private as well for the linting to take effect.
*/
async someAsyncMethod(
someParameter: number
): Promise<number> {
return someParameter;
}
}
The options object looks like this:
{
"params": [
{
"name": "string",
"private?": "boolean", // default: false
"public?": "boolean", // default: false
"async?": "boolean", // default: false,
"static?": "boolean" // default: false
}
],
"methods": [
{
"name": "assert",
"private?": "boolean", // default: false
"public?": "boolean", // default: false
"async?": "boolean", // default: false
"static?": "boolean" // default: false
}
]
}
FAQs
This is a custom plugin for eslint which enforces the use of decorators on methods.
We found that eslint-plugin-use-decorator 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.