Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
eslint-plugin-deprecation
Advanced tools
The eslint-plugin-deprecation package is an ESLint plugin that helps developers identify and manage deprecated code in their JavaScript projects. It allows you to mark certain functions, methods, or properties as deprecated and provides warnings or errors when they are used.
Detect Deprecated Functions
This feature allows you to specify deprecated functions and provide a custom message. When the deprecated function is used, ESLint will warn the developer.
module.exports = {
rules: {
'deprecation/deprecation': [
'warn',
{
'methods': {
'myDeprecatedFunction': 'This function is deprecated. Use newFunction instead.'
}
}
]
}
};
Detect Deprecated Properties
This feature allows you to mark object properties as deprecated. When the deprecated property is accessed, ESLint will issue a warning.
module.exports = {
rules: {
'deprecation/deprecation': [
'warn',
{
'properties': {
'myObject.oldProperty': 'This property is deprecated. Use newProperty instead.'
}
}
]
}
};
Custom Deprecation Messages
This feature allows you to provide custom deprecation messages for both methods and properties, giving developers clear guidance on what to use instead.
module.exports = {
rules: {
'deprecation/deprecation': [
'warn',
{
'methods': {
'oldFunction': 'oldFunction is deprecated. Please use newFunction.'
},
'properties': {
'oldProperty': 'oldProperty is deprecated. Please use newProperty.'
}
}
]
}
};
eslint-plugin-deprecate is an ESLint plugin that allows you to mark functions, methods, and properties as deprecated. It provides warnings when deprecated code is used. This package is similar to eslint-plugin-deprecation but may have different syntax and configuration options.
ESLint rule that reports usage of deprecated code
This plugin only works with @typescript-eslint/parser
.
Which means that you should install dev deps:
@typescript-eslint/parser
typescript
Then configure ESLint to parse TypeScript and include type information:
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"project": "./tsconfig.json" // <-- Point to your project's tsconfig.json or create new one
}
}
Install the plugin
npm i -D eslint-plugin-deprecation
Now add deprecation plugin and rule to your .eslintrc
:
{
"plugins": ["deprecation", ...],
"rules": {
"deprecation/deprecation": "warn", // or "error" to have stricter rule
...
}
}
Now eslint will report all deprecated code that you use!
NOTE: This rule was ported from https://github.com/SonarSource/SonarJS repository.
FAQs
ESLint rule that reports usage of deprecated code
The npm package eslint-plugin-deprecation receives a total of 654,297 weekly downloads. As such, eslint-plugin-deprecation popularity was classified as popular.
We found that eslint-plugin-deprecation demonstrated a healthy version release cadence and project activity because the last version was released less than 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
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.