Socket
Socket
Sign inDemoInstall

eslint-plugin-deprecation

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-deprecation - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

dist/eslint-plugin-deprecation-1.3.0.tgz

3

dist/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var rules = require("./rules");
exports.rules = void 0;
const rules = require("./rules");
exports.rules = rules;
//# sourceMappingURL=index.js.map

@@ -18,6 +18,6 @@ "use strict";

*/
var experimental_utils_1 = require("@typescript-eslint/experimental-utils");
var tsutils_1 = require("tsutils");
var ts = require("typescript");
var createRule = experimental_utils_1.ESLintUtils.RuleCreator(function () { return 'https://github.com/gund/eslint-plugin-deprecation'; });
const experimental_utils_1 = require("@typescript-eslint/experimental-utils");
const tsutils_1 = require("tsutils");
const ts = require("typescript");
const createRule = experimental_utils_1.ESLintUtils.RuleCreator(() => 'https://github.com/gund/eslint-plugin-deprecation');
exports.default = createRule({

@@ -29,3 +29,2 @@ name: 'deprecation',

description: 'Do not use deprecated APIs.',
category: 'Best Practices',
recommended: 'warn',

@@ -35,3 +34,3 @@ requiresTypeChecking: true,

messages: {
deprecated: "'{{name}}' is deprecated. {{reason}}",
deprecated: `'{{name}}' is deprecated. {{reason}}`,
},

@@ -41,4 +40,4 @@ schema: [],

defaultOptions: [],
create: function (context) {
var identifierRule = createRuleForIdentifier(context);
create(context) {
const identifierRule = createRuleForIdentifier(context);
return {

@@ -53,17 +52,17 @@ Identifier: identifierRule,

var _a;
var services = experimental_utils_1.ESLintUtils.getParserServices(context);
const services = experimental_utils_1.ESLintUtils.getParserServices(context);
// Don't consider deprecations in certain cases:
// - Inside an import
var isInsideImport = context
const isInsideImport = context
.getAncestors()
.some(function (anc) { return anc.type.includes('Import'); });
.some((anc) => anc.type.includes('Import'));
// - At the spot where something is declared
var isIdDeclaration = (id.type === 'Identifier' || id.type === 'JSXIdentifier') &&
const isIdDeclaration = (id.type === 'Identifier' || id.type === 'JSXIdentifier') &&
isDeclaration(id, context);
// - On JSX closing elements (only flag the opening element)
var isClosingElement = id.type === 'JSXIdentifier' && ((_a = id.parent) === null || _a === void 0 ? void 0 : _a.type) === 'JSXClosingElement';
const isClosingElement = id.type === 'JSXIdentifier' && ((_a = id.parent) === null || _a === void 0 ? void 0 : _a.type) === 'JSXClosingElement';
if (isInsideImport || isIdDeclaration || isClosingElement) {
return;
}
var deprecation = getDeprecation(id, services, context);
const deprecation = getDeprecation(id, services, context);
if (deprecation) {

@@ -82,3 +81,3 @@ context.report({

function getParent(context) {
var ancestors = context.getAncestors();
const ancestors = context.getAncestors();
return ancestors.length > 0 ? ancestors[ancestors.length - 1] : undefined;

@@ -88,7 +87,7 @@ }

// `const { foo } = bar` will be processed twice.
var lastProcessedDuplicateName;
let lastProcessedDuplicateName;
function isDeclaration(id, context) {
var _a, _b, _c;
var parent = getParent(context);
switch ((_a = parent) === null || _a === void 0 ? void 0 : _a.type) {
var _a, _b;
const parent = getParent(context);
switch (parent === null || parent === void 0 ? void 0 : parent.type) {
case 'TSEnumDeclaration':

@@ -118,3 +117,3 @@ case 'TSInterfaceDeclaration':

return parent.id === id;
case 'ClassProperty':
case 'PropertyDefinition':
// Prevent considering value to be a declaration

@@ -128,3 +127,3 @@ return parent.key === id;

// no for ObjectExpression: `const foo = { bar: baz }`
if (((_b = parent.parent) === null || _b === void 0 ? void 0 : _b.type) === 'ObjectPattern') {
if (((_a = parent.parent) === null || _a === void 0 ? void 0 : _a.type) === 'ObjectPattern') {
if (isShortHandProperty(parent)) {

@@ -148,3 +147,3 @@ // foo in `const { foo } = bar` will be processed twice, as key and

case 'AssignmentPattern':
if (((_c = parent.parent) === null || _c === void 0 ? void 0 : _c.type) === 'Property' &&
if (((_b = parent.parent) === null || _b === void 0 ? void 0 : _b.type) === 'Property' &&
isShortHandProperty(parent.parent)) {

@@ -167,9 +166,9 @@ // Variant of the Property/ObjectPattern case above: foo in

function getDeprecation(id, services, context) {
var tc = services.program.getTypeChecker();
var callExpression = getCallExpression(context, id);
const tc = services.program.getTypeChecker();
const callExpression = getCallExpression(context, id);
if (callExpression) {
var tsCallExpression = services.esTreeNodeToTSNodeMap.get(callExpression);
var signature = tc.getResolvedSignature(tsCallExpression);
const tsCallExpression = services.esTreeNodeToTSNodeMap.get(callExpression);
const signature = tc.getResolvedSignature(tsCallExpression);
if (signature) {
var deprecation = getJsDocDeprecation(signature.getJsDocTags());
const deprecation = getJsDocDeprecation(signature.getJsDocTags());
if (deprecation) {

@@ -180,3 +179,3 @@ return deprecation;

}
var symbol = getSymbol(id, services, tc);
const symbol = getSymbol(id, services, tc);
if (!symbol) {

@@ -191,5 +190,5 @@ return undefined;

function getSymbol(id, services, tc) {
var symbol;
var tsId = services.esTreeNodeToTSNodeMap.get(id);
var parent = tsId.parent;
let symbol;
const tsId = services.esTreeNodeToTSNodeMap.get(id);
const parent = tsId.parent;
if (parent.kind === ts.SyntaxKind.BindingElement) {

@@ -201,3 +200,3 @@ symbol = tc.getTypeAtLocation(parent.parent).getProperty(tsId.text);

parent.name === tsId &&
tsutils_1.isReassignmentTarget(tsId))) {
(0, tsutils_1.isReassignmentTarget)(tsId))) {
try {

@@ -221,5 +220,5 @@ symbol = tc.getPropertySymbolOfDestructuringAssignment(tsId);

function getCallExpression(context, id) {
var ancestors = context.getAncestors();
var callee = id;
var parent = ancestors.length > 0 ? ancestors[ancestors.length - 1] : undefined;
const ancestors = context.getAncestors();
let callee = id;
let parent = ancestors.length > 0 ? ancestors[ancestors.length - 1] : undefined;
if (parent && parent.type === 'MemberExpression' && parent.property === id) {

@@ -248,4 +247,3 @@ callee = parent;

function getJsDocDeprecation(tags) {
for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) {
var tag = tags_1[_i];
for (const tag of tags) {
if (tag.name === 'deprecated') {

@@ -258,3 +256,3 @@ return { reason: tag.text || '' };

function isFunction(symbol) {
var declarations = symbol.declarations;
const { declarations } = symbol;
if (declarations === undefined || declarations.length === 0) {

@@ -261,0 +259,0 @@ return false;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var deprecation_1 = require("./deprecation");
exports.deprecation = void 0;
const deprecation_1 = require("./deprecation");
exports.deprecation = deprecation_1.default;
//# sourceMappingURL=index.js.map
{
"name": "eslint-plugin-deprecation",
"version": "1.2.1",
"version": "1.3.0",
"description": "ESLint rule that reports usage of deprecated code",

@@ -27,34 +27,34 @@ "author": "Alex Malkevich <malkevich.alex@gmail.com>",

"dependencies": {
"@typescript-eslint/experimental-utils": "^2.19.2 || ^3.0.0",
"tslib": "^1.10.0",
"tsutils": "^3.0.0"
"@typescript-eslint/experimental-utils": "^5.0.0",
"tslib": "^2.3.1",
"tsutils": "^3.21.0"
},
"peerDependencies": {
"eslint": "^6.0.0 || ^7.0.0",
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0",
"typescript": "^3.7.5 || ^4.0.0"
},
"devDependencies": {
"@commitlint/cli": "^8.3.5",
"@commitlint/config-conventional": "^8.3.4",
"@semantic-release/changelog": "^5.0.0",
"@semantic-release/commit-analyzer": "^8.0.1",
"@semantic-release/git": "^9.0.0",
"@semantic-release/github": "^7.0.3",
"@semantic-release/npm": "^7.0.3",
"@semantic-release/release-notes-generator": "^9.0.0",
"@types/jest": "^25.0.0",
"@types/node": "^13.7.1",
"@typescript-eslint/eslint-plugin": "^2.34.0",
"@typescript-eslint/parser": "^2.34.0",
"eslint": "^6.8.0",
"commitizen": "^4.0.3",
"cz-conventional-changelog": "^3.1.0",
"husky": "^4.2.3",
"lint-staged": "^10.5.4",
"jest": "^25.0.0",
"prettier": "^1.19.1",
"@commitlint/cli": "^13.2.1",
"@commitlint/config-conventional": "^13.2.0",
"@semantic-release/changelog": "^6.0.0",
"@semantic-release/commit-analyzer": "^9.0.1",
"@semantic-release/git": "^10.0.0",
"@semantic-release/github": "^8.0.1",
"@semantic-release/npm": "^8.0.0",
"@semantic-release/release-notes-generator": "^10.0.2",
"@types/jest": "^27.0.2",
"@types/node": "^16.10.3",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"eslint": "^8.0.0",
"commitizen": "^4.2.4",
"cz-conventional-changelog": "^3.3.0",
"husky": "^7.0.2",
"lint-staged": "^11.2.3",
"jest": "^27.2.5",
"prettier": "^2.4.1",
"rimraf": "^3.0.2",
"semantic-release": "^17.0.3",
"ts-jest": "^25.0.0",
"typescript": "^3.7.5"
"semantic-release": "^18.0.0",
"ts-jest": "^27.0.5",
"typescript": "^4.4.3"
},

@@ -61,0 +61,0 @@ "config": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc