eslint-plugin-deprecated
v0.3.0
Published
ESLint deprecation rules plugin, based on API blacklist.
Downloads
296
Maintainers
Readme
eslint-plugin-deprecated
ESLint ~~@deprecation~~ rules plugin, based on API blacklist.
:sparkles: Features
- [x] Modules and globals API options support. @v0.0.1
- [x]
MessageTemplate
option supports. @v0.2.0 - [x] Specific
messageTemplates
option (noReplacedBy
,noSince
andeither
) supports. @v0.3.0 (Breaking Change involved: Do not supportMessageTemplate
option any more, usemessageTemplates
instead.) - [ ] File level deprecation. @next-version
💿 Installation
$ npm install --save-dev eslint eslint-plugin-deprecated
- Requires Node.js
>=6.0.0
🔧 Configs
package.json (An example)
{
"name": "your-module",
"version": "1.0.0",
"engines": {
"node": ">=6.0.0"
}
}
.eslintrc.json (An example)
{
"plugins": [
"deprecated"
],
"rules": {
"deprecated/no-deprecated-api": ["error", {
"modules": {},
"globals": {
"eval": {
"[CALL]": {
"replacedBy": "DO NOT use it.",
"since": "1.0.0"
}
},
"name": {
"[READ]": {
"replacedBy": "Use 'window.name' instead.",
"since": "1.2.0"
}
},
"Function": {
"[CONSSTRUCT]": {
"replacedBy": "DO NOT use it.",
"since": "1.0.3"
}
}
},
"messageTemplate": {
"normal": "{{name}} was DEPRECATED since {{version}\n{{replace}}.",
"noReplacedBy": "{{name}} was DEPRECATED since {{version}\nNo plans to support.",
"noSince": "{{name}} was DEPRECATED\n{{replace}}.",
"neither": "{{name}} was DEPRECATED.",
}
}]
}
}
Examples of :-1: incorrect code for this rule:
// example.js
(function() {
name;
})();
eval('1 + 2');
new Function('a', 'b', 'return a + b')(1, 2);
ESLint output:
path/to/example.js
2:3 error 'name' was DEPRECATED
Use 'window.name' instead deprecated/no-deprecated-api
4:1 error 'eval()' was DEPRECATED
DO NOT use it deprecated/no-deprecated-api
5:1 error 'new Function()' was DEPRECATED
DO NOT use it deprecated/no-deprecated-api
📖 Rules
- ⭐️ - the mark of recommended rules.
- ✒️ - the mark of fixable rules.
Best Practices
| Rule ID | Description | | |:--------|:------------|:--:| | no-deprecated-api | disallow deprecated APIs | ⭐️ |
👫 Known Limitations
This rule cannot report the following cases:
non-static properties
- async_hooks
- buffer
- cluster
- crypto
- http
- net
- repl
replServer.convertToContext
(undocumented)- replServer.turnOffEditorMode
- replServer.memory
types of arguments
- fs
fs.truncate()
andfs.truncateSync()
usage with a file descriptor has been deprecated.
- url
url.format()
with legacyurlObject
has been deprecated.
dynamic things
require(foo).aDeprecatedProperty;
require("http")[A_DEPRECATED_PROPERTY]();
assignments to properties
var obj = {
Buffer: require("buffer").Buffer
};
new obj.Buffer(); /* missing. */
var obj = {};
obj.Buffer = require("buffer").Buffer
new obj.Buffer(); /* missing. */
giving arguments
(function(Buffer) {
new Buffer(); /* missing. */
})(require("buffer").Buffer);
reassignments
var Buffer = require("buffer").Buffer;
Buffer = require("another-buffer");
new Buffer(); /*ERROR: 'buffer.Buffer' constructor was deprecated.*/
🚥 Semantic Versioning Policy
eslint-plugin-deprecated
follows semantic versioning and ESLint's Semantic Versioning Policy.
- Patch release (intended to not break your lint build)
- A bug fix in a rule that results in it reporting fewer errors.
- Improvements to documentation.
- Non-user-facing changes such as refactoring code, adding, deleting, or modifying tests, and increasing test coverage.
- Re-releasing after a failed release (i.e., publishing a release that doesn't work for anyone).
- Minor release (might break your lint build)
- A bug fix in a rule that results in it reporting more errors.
- A new rule is created.
- A new option to an existing rule is created.
- An existing rule is deprecated.
- Major release (likely to break your lint build)
- A support for old Node version is dropped.
- A support for old ESLint version is dropped.
- An existing rule is changed in it reporting more errors.
- An existing rule is removed.
- An existing option of a rule is removed.
- An existing config is updated.
📰 Changelog
💎 Contributing
Welcome contributing!
Please use GitHub's Issues/PRs.
Development Tools
npm test
runs tests and measures coverage.npm run coverage
shows the coverage result ofnpm test
command.npm run clean
removes the coverage result ofnpm test
command.