Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

feat(deps): update deps, support of eslint 8 #38

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
dist
.idea
.vscode
5 changes: 5 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.*
/src
/tests
*.config*
tsconfig*.json
3 changes: 3 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ module.exports = {
},
testRegex: './tests/.+\\.test\\.ts$',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
moduleNameMapper: {
'@eslint/eslintrc/universal': '@eslint/eslintrc/dist/eslintrc-universal.cjs',
},
};
26,817 changes: 16,825 additions & 9,992 deletions package-lock.json

Large diffs are not rendered by default.

64 changes: 35 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
{
"name": "eslint-plugin-deprecation",
"version": "0.0.0-development",
"name": "@delagen/eslint-plugin-deprecation",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like some of the changes include in this file might not have been intended for the upstream update?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because of fork. I updated this project in master branch

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timgates42 if you has permission to merge and publish npm, I can rebase this Mr

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

truncated into #39

"version": "1.3.0",
"description": "ESLint rule that reports usage of deprecated code",
"author": "Alex Malkevich <[email protected]>",
"contributors": [
{
"name": "Vohmyanin Sergey",
"email": "[email protected]"
}
],
"license": "LGPL-3.0-or-later",
"repository": {
"type": "git",
"url": "https://github.com/gund/eslint-plugin-deprecation.git"
"url": "https://github.com/delagen/eslint-plugin-deprecation.git"
},
"main": "dist/index.js",
"files": [
Expand All @@ -24,38 +30,38 @@
"semantic-release": "semantic-release"
},
"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": "^14.1.0",
"@commitlint/config-conventional": "^14.1.0",
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/commit-analyzer": "^9.0.1",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^8.0.2",
"@semantic-release/npm": "^8.0.3",
"@semantic-release/release-notes-generator": "^10.0.2",
"@types/jest": "^27.0.2",
"@types/node": "^16.11.7",
"@typescript-eslint/eslint-plugin": "^5.3.1",
"@typescript-eslint/parser": "^5.3.1",
"eslint": "^8.2.0",
"commitizen": "^4.2.4",
"cz-conventional-changelog": "^3.3.0",
"husky": "^7.0.4",
"lint-staged": "^11.2.6",
"jest": "^27.3.1",
"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.7",
"typescript": "^4.4.4"
},
"config": {
"commitizen": {
Expand Down
8 changes: 4 additions & 4 deletions src/rules/deprecation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
} from '@typescript-eslint/experimental-utils';
import { isReassignmentTarget } from 'tsutils';
import * as ts from 'typescript';
import { stringifyJSDocTagInfoText } from '../utils/stringifyJSDocTagInfoText';

const createRule = ESLintUtils.RuleCreator(
() => 'https://github.com/gund/eslint-plugin-deprecation',
Expand All @@ -35,7 +36,6 @@ export default createRule<Options, MessageIds>({
type: 'problem',
docs: {
description: 'Do not use deprecated APIs.',
category: 'Best Practices',
recommended: 'warn',
requiresTypeChecking: true,
},
Expand Down Expand Up @@ -64,7 +64,7 @@ function createRuleForIdentifier(
// - Inside an import
const isInsideImport = context
.getAncestors()
.some(anc => anc.type.includes('Import'));
.some((anc) => anc.type.includes('Import'));
// - At the spot where something is declared
const isIdDeclaration =
(id.type === 'Identifier' || id.type === 'JSXIdentifier') &&
Expand Down Expand Up @@ -132,7 +132,7 @@ function isDeclaration(
// Prevent considering initializer, extends, or implements to be declaration
return parent.id === id;

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

Expand Down Expand Up @@ -289,7 +289,7 @@ function isCallExpression(
function getJsDocDeprecation(tags: ts.JSDocTagInfo[]) {
for (const tag of tags) {
if (tag.name === 'deprecated') {
return { reason: tag.text || '' };
return { reason: stringifyJSDocTagInfoText(tag) };
}
}
return undefined;
Expand Down
27 changes: 27 additions & 0 deletions src/utils/stringifyJSDocTagInfoText.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import * as ts from 'typescript';

/**
* Stringifies the text within a JSDocTagInfo AST node with compatibility for
* pre/post TypeScript 4.3 API changes.
*/
export function stringifyJSDocTagInfoText(tag: ts.JSDocTagInfo): string {
return isJSDocTagInfo4Point3Plus(tag)
? ts.displayPartsToString(tag.text)
: (<any>tag).text ?? '';
}

/**
* Copied from TypeScript 4.3.
*
* The `text` field was changed from `string` to `SymbolDisplayPart[]` in 4.3.
*/
interface JSDocTagInfo4Point3Plus {
name: string;
text?: ts.SymbolDisplayPart[];
}

function isJSDocTagInfo4Point3Plus(
tag: ts.JSDocTagInfo | JSDocTagInfo4Point3Plus,
): tag is JSDocTagInfo4Point3Plus {
return Array.isArray(tag.text);
}
36 changes: 18 additions & 18 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
// tsconfig for editor must include both src and tests
"compilerOptions": {
"noEmit": true,
"rootDir": ".",
"strict": true,
"declaration": true,
"noEmitHelpers": true,
"importHelpers": true,
"sourceMap": true,
"module": "CommonJS",
"target": "ES5",
"lib": ["ES2015"],
"types": ["node", "jest"],
"jsx": "preserve"
},
"include": ["src", "tests"]
}
{
// tsconfig for editor must include both src and tests
"compilerOptions": {
"noEmit": true,
"rootDir": ".",
"strict": true,
"declaration": true,
"noEmitHelpers": true,
"importHelpers": true,
"sourceMap": true,
"module": "CommonJS",
"target": "ES2015",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if relevant but the change from ES5 to ES2015 is a breaking change :)

ES5 is not ES2015. ES2015 is ES6.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you see supported versions of node.js by eslint, I think it can be even higher

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. I just saw the target change and figured I'd point it out :)

But given that ESLint 8 only supports "node": "^12.22.0 || ^14.17.0 || >=16.0.0" then I guess it's safe to use ES2019
https://node.green/#ES2019

"lib": ["ESNext"],
"types": ["node", "jest"],
"jsx": "preserve"
},
"include": ["src", "tests"]
}