Skip to content

Commit

Permalink
Update to TypeScript 4.9 (#3569)
Browse files Browse the repository at this point in the history
  • Loading branch information
saberduck authored Nov 22, 2022
1 parent d1c917b commit 6357df7
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 44 deletions.
14 changes: 7 additions & 7 deletions eslint-bridge/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion eslint-bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"scslre": "0.1.6",
"stylelint": "14.13.0",
"tmp": "0.2.1",
"typescript": "4.8.3",
"typescript": "4.9.3",
"vue-eslint-parser": "9.1.0",
"yaml": "2.1.1"
},
Expand Down
6 changes: 3 additions & 3 deletions eslint-bridge/src/linting/eslint/rules/helpers/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,12 @@ export function getUniqueWriteUsageOrNode(
}
}

export function getValueOfExpression<T extends Node['type']>(
export function getValueOfExpression<T extends estree.Node['type']>(
context: Rule.RuleContext,
expr: Node | undefined | null,
expr: estree.Node | undefined | null,
type: T,
recursive = false,
): Extract<Node, { type: T }> | undefined {
): Extract<estree.Node, { type: T }> | undefined {
if (!expr) {
return undefined;
}
Expand Down
19 changes: 13 additions & 6 deletions eslint-bridge/src/linting/eslint/rules/helpers/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import assert from 'assert';
import { Rule, Scope } from 'eslint';
import * as estree from 'estree';
import { TSESTree } from '@typescript-eslint/experimental-utils';
import {
Node,
isDefaultSpecifier,
Expand Down Expand Up @@ -270,7 +271,7 @@ export function hasFullyQualifiedName(
*/
export function getFullyQualifiedName(
context: Rule.RuleContext,
node: Node,
node: estree.Node,
fqn: string[] = [],
scope?: Scope.Scope,
): string | null {
Expand Down Expand Up @@ -339,7 +340,7 @@ export function getFullyQualifiedName(
* @param node the Node to traverse
* @param fqn the array with the qualifiers
*/
export function reduceToIdentifier(node: Node, fqn: string[] = []): Node {
export function reduceToIdentifier(node: estree.Node, fqn: string[] = []): estree.Node {
return reduceTo('Identifier', node, fqn);
}

Expand All @@ -351,8 +352,12 @@ export function reduceToIdentifier(node: Node, fqn: string[] = []): Node {
* @param node the Node to traverse
* @param fqn the array with the qualifiers
*/
export function reduceTo<T extends Node['type']>(type: T, node: Node, fqn: string[] = []): Node {
let nodeToCheck: Node = node;
export function reduceTo<T extends estree.Node['type']>(
type: T,
node: estree.Node,
fqn: string[] = [],
): estree.Node {
let nodeToCheck: estree.Node = node;

while (nodeToCheck.type !== type) {
if (nodeToCheck.type === 'MemberExpression') {
Expand All @@ -369,8 +374,10 @@ export function reduceTo<T extends Node['type']>(type: T, node: Node, fqn: strin
nodeToCheck = nodeToCheck.callee;
} else if (nodeToCheck.type === 'ChainExpression') {
nodeToCheck = nodeToCheck.expression;
} else if (nodeToCheck.type === 'TSNonNullExpression') {
nodeToCheck = nodeToCheck.expression;
} else if ((nodeToCheck as TSESTree.Node).type === 'TSNonNullExpression') {
// we should migrate to use only TSESTree types everywhere to avoid casting
nodeToCheck = (nodeToCheck as unknown as TSESTree.TSNonNullExpression)
.expression as estree.Expression;
} else {
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void test() {
BuildResult buildResult = runBuild(orchestrator);
assertThat(buildResult.getLogsLines(l -> l.matches(".*DEBUG: Deploying custom rules bundle jar:file:.*/custom-eslint-based-rules-1\\.0\\.0\\.tgz to .*"))).hasSize(1);
assertThat(buildResult.getLogsLines(l -> l.contains("Custom JavaScript rules are deprecated and API will be removed in future version."))).isEmpty();
assertThat(buildResult.getLogsLines(l -> l.contains("TS API in custom rule: TS version 4.8.3"))).hasSize(2);
assertThat(buildResult.getLogsLines(l -> l.contains("TS API in custom rule: TS version 4.9.3"))).hasSize(2);
List<Issue> issues = findIssues("eslint-custom-rules:sqKey", orchestrator);
assertThat(issues).hasSize(2);
assertThat(issues).extracting(Issue::getRule, Issue::getComponent, Issue::getLine, Issue::getMessage)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
'es5-shim:es5-sham.js':[
214,
],
'es5-shim:es5-shim.js':[
1949,
1950,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
'mootools-core:Source/Fx/Fx.CSS.js':[
125,
],
'mootools-core:Source/Types/Function.js':[
91,
],
Expand Down
16 changes: 0 additions & 16 deletions its/ruling/src/test/expected/js/paper.js/javascript-S2259.json

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
'prototype:src/prototype/ajax/request.js':[
327,
],
'prototype:src/prototype/ajax/response.js':[
159,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
917,
985,
1362,
1366,
],
'TypeScript:src/compiler/declarationEmitter.ts':[
789,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@
90,
91,
],
'ant-design:site/theme/template/Layout/Header/SearchBar.tsx':[
38,
],
}

0 comments on commit 6357df7

Please sign in to comment.