
Security News
TC39 Advances 11 Proposals for Math Precision, Binary APIs, and More
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
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.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.