
Research
Security News
The Landscape of Malicious Open Source Packages: 2025 Mid‑Year Threat Report
A look at the top trends in how threat actors are weaponizing open source packages to deliver malware and persist across the software supply chain.
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.
The npm package eslint-plugin-use-decorator receives a total of 5,653 weekly downloads. As such, eslint-plugin-use-decorator popularity was classified as popular.
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
A look at the top trends in how threat actors are weaponizing open source packages to deliver malware and persist across the software supply chain.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.