eslint-plugin-deprecation
Advanced tools
Comparing version 1.2.1 to 1.3.0
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41480
13
+ Added@eslint-community/eslint-utils@4.4.0(transitive)
+ Added@eslint-community/regexpp@4.11.1(transitive)
+ Added@eslint/eslintrc@2.1.4(transitive)
+ Added@eslint/js@8.57.1(transitive)
+ Added@humanwhocodes/config-array@0.13.0(transitive)
+ Added@humanwhocodes/module-importer@1.0.1(transitive)
+ Added@humanwhocodes/object-schema@2.0.3(transitive)
+ Added@nodelib/fs.scandir@2.1.5(transitive)
+ Added@nodelib/fs.stat@2.0.5(transitive)
+ Added@nodelib/fs.walk@1.2.8(transitive)
+ Added@types/semver@7.5.8(transitive)
+ Added@typescript-eslint/experimental-utils@5.62.0(transitive)
+ Added@typescript-eslint/scope-manager@5.62.0(transitive)
+ Added@typescript-eslint/types@5.62.0(transitive)
+ Added@typescript-eslint/typescript-estree@5.62.0(transitive)
+ Added@typescript-eslint/utils@5.62.0(transitive)
+ Added@typescript-eslint/visitor-keys@5.62.0(transitive)
+ Added@ungap/structured-clone@1.2.0(transitive)
+ Addedacorn@8.12.1(transitive)
+ Addedargparse@2.0.1(transitive)
+ Addedarray-union@2.1.0(transitive)
+ Addedbraces@3.0.3(transitive)
+ Addeddir-glob@3.0.1(transitive)
+ Addedeslint@8.57.1(transitive)
+ Addedeslint-scope@7.2.2(transitive)
+ Addedeslint-visitor-keys@3.4.3(transitive)
+ Addedespree@9.6.1(transitive)
+ Addedfast-glob@3.3.2(transitive)
+ Addedfastq@1.17.1(transitive)
+ Addedfill-range@7.1.1(transitive)
+ Addedfind-up@5.0.0(transitive)
+ Addedglob-parent@6.0.2(transitive)
+ Addedglobby@11.1.0(transitive)
+ Addedgraphemer@1.4.0(transitive)
+ Addedignore@5.3.2(transitive)
+ Addedis-number@7.0.0(transitive)
+ Addedis-path-inside@3.0.3(transitive)
+ Addedjs-yaml@4.1.0(transitive)
+ Addedlocate-path@6.0.0(transitive)
+ Addedmerge2@1.4.1(transitive)
+ Addedmicromatch@4.0.8(transitive)
+ Addedp-limit@3.1.0(transitive)
+ Addedp-locate@5.0.0(transitive)
+ Addedpath-exists@4.0.0(transitive)
+ Addedpath-type@4.0.0(transitive)
+ Addedpicomatch@2.3.1(transitive)
+ Addedqueue-microtask@1.2.3(transitive)
+ Addedreusify@1.0.4(transitive)
+ Addedrun-parallel@1.2.0(transitive)
+ Addedslash@3.0.0(transitive)
+ Addedto-regex-range@5.0.1(transitive)
+ Addedtslib@2.7.0(transitive)
+ Addedyocto-queue@0.1.0(transitive)
- Removed@babel/code-frame@7.12.11(transitive)
- Removed@babel/helper-validator-identifier@7.24.7(transitive)
- Removed@babel/highlight@7.24.7(transitive)
- Removed@eslint/eslintrc@0.4.3(transitive)
- Removed@humanwhocodes/config-array@0.5.0(transitive)
- Removed@humanwhocodes/object-schema@1.2.1(transitive)
- Removed@typescript-eslint/experimental-utils@3.10.1(transitive)
- Removed@typescript-eslint/types@3.10.1(transitive)
- Removed@typescript-eslint/typescript-estree@3.10.1(transitive)
- Removed@typescript-eslint/visitor-keys@3.10.1(transitive)
- Removedacorn@7.4.1(transitive)
- Removedajv@8.17.1(transitive)
- Removedansi-colors@4.1.3(transitive)
- Removedansi-styles@3.2.1(transitive)
- Removedargparse@1.0.10(transitive)
- Removedastral-regex@2.0.0(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedemoji-regex@8.0.0(transitive)
- Removedenquirer@2.4.1(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedeslint@7.32.0(transitive)
- Removedeslint-utils@2.1.0(transitive)
- Removedeslint-visitor-keys@1.3.02.1.0(transitive)
- Removedespree@7.3.1(transitive)
- Removedesprima@4.0.1(transitive)
- Removedfast-uri@3.0.1(transitive)
- Removedfunctional-red-black-tree@1.0.1(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedignore@4.0.6(transitive)
- Removedis-fullwidth-code-point@3.0.0(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedjs-yaml@3.14.1(transitive)
- Removedjson-schema-traverse@1.0.0(transitive)
- Removedlodash@4.17.21(transitive)
- Removedlodash.truncate@4.4.2(transitive)
- Removedpicocolors@1.1.0(transitive)
- Removedprogress@2.0.3(transitive)
- Removedregexpp@3.2.0(transitive)
- Removedrequire-from-string@2.0.2(transitive)
- Removedslice-ansi@4.0.0(transitive)
- Removedsprintf-js@1.0.3(transitive)
- Removedstring-width@4.2.3(transitive)
- Removedsupports-color@5.5.0(transitive)
- Removedtable@6.8.2(transitive)
- Removedv8-compile-cache@2.4.0(transitive)
Updatedtslib@^2.3.1
Updatedtsutils@^3.21.0