Skip to content

Commit 6ebc951

Browse files
authored
chore(dev-deps): update typescript and related deps (#165)
1 parent dfb6cc4 commit 6ebc951

File tree

11 files changed

+198
-130
lines changed

11 files changed

+198
-130
lines changed

.eslintrc.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,18 @@ module.exports = {
1313
"error",
1414
{ functions: false, classes: false },
1515
],
16-
// We actually need to ignore multiple things the TypeScript Compiler cannot
17-
// seem to figure out by itself.
18-
"@typescript-eslint/ban-ts-ignore": "off",
19-
// This rule replaces `ban-ts-ignore` but we need to upgrade to latest major version of eslint+typescript
20-
// to have full configuration options for it.
21-
"@typescript-eslint/ban-ts-comment": "off",
16+
"@typescript-eslint/ban-ts-comment": [
17+
"error",
18+
{
19+
// We only allow ts-expect-error comments to enforce removal
20+
// of outdated suppression comments when the underlying issue has been resolved.
21+
// https://devblogs.microsoft.com/typescript/announcing-typescript-3-9/#what-about-ts-ignore
22+
"ts-expect-error": "allow-with-description",
23+
"ts-ignore": true,
24+
"ts-nocheck": true,
25+
"ts-check": true,
26+
},
27+
],
2228
"eslint-comments/disable-enable-pair": ["error", { allowWholeFile: true }],
2329
},
2430
ignorePatterns: ["**/*.js"],

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939
"@types/fs-extra": "9.0.1",
4040
"chai": "4.2.0",
4141
"deep-equal-in-any-order": "^1.0.24",
42-
"eslint": "6.8.0",
43-
"@typescript-eslint/parser": "2.34.0",
44-
"@typescript-eslint/eslint-plugin": "2.34.0",
42+
"eslint": "7.1.0",
43+
"@typescript-eslint/parser": "3.1.0",
44+
"@typescript-eslint/eslint-plugin": "3.1.0",
4545
"eslint-config-prettier": "6.11.0",
4646
"eslint-plugin-eslint-comments": "3.1.2",
4747
"husky": "4.2.5",
@@ -52,7 +52,7 @@
5252
"nyc": "15.1.0",
5353
"prettier": "2.0.5",
5454
"source-map-support": "0.5.19",
55-
"typescript": "3.8.3",
55+
"typescript": "3.9.3",
5656
"cz-conventional-changelog": "3.2.0",
5757
"@commitlint/cli": "8.3.5",
5858
"@commitlint/config-conventional": "8.3.4",

packages/logic-utils/src/utils/documentation.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ function replace(
186186
matcher: RegExp,
187187
replacement: string | ReplaceFunction
188188
): string {
189-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
190-
//@ts-ignore - 'replace' is defined with 2 overloads instead of a union type in the definitions file
189+
// @ts-expect-error - 'replace' is defined with 2 overloads instead of a union type in the definitions file
191190
return string.replace(matcher, replacement);
192191
}
193192

packages/semantic-model/.eslintrc.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
// Fixing and or ignoring issues in generated files is not scalable
3+
// unless one also implemented the generator.
4+
ignorePatterns: ["src/api-json.d.ts"],
5+
};

packages/semantic-model/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"dependencies": {
1717
"@ui5-language-assistant/semantic-model-types": "^1.3.0",
1818
"ajv": "6.12.2",
19+
"fs-extra": "9.0.1",
1920
"deep-freeze-strict": "1.1.1",
2021
"lodash": "4.17.15"
2122
},
@@ -32,7 +33,7 @@
3233
"lint": "eslint . --ext .ts --max-warnings=0 --ignore-path=../../.gitignore",
3334
"test": "mocha",
3435
"coverage": "nyc mocha",
35-
"generate-json-api": "json2ts -i ./resources/sap-ui-library-api.json -o ./src/api-json.d.ts --no-unknownAny --bannerComment \"/* eslint-disable @typescript-eslint/no-explicit-any */ /* This file is automatically generated. DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file (sap-ui-library-api.json) and run generate-json-api from the package.json to regenerate this file. */\" && prettier --write ./src/api-json.d.ts"
36+
"generate-json-api": "json2ts -i ./resources/sap-ui-library-api.json -o ./src/api-json.d.ts --no-unknownAny --bannerComment \"/* This file is automatically generated. DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file (sap-ui-library-api.json) and run generate-json-api from the package.json to regenerate this file. */\" && prettier --write ./src/api-json.d.ts"
3637
},
3738
"publishConfig": {
3839
"access": "public"

packages/semantic-model/src/api-json.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable @typescript-eslint/no-explicit-any */ /* This file is automatically generated. DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file (sap-ui-library-api.json) and run generate-json-api from the package.json to regenerate this file. */
1+
/* This file is automatically generated. DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file (sap-ui-library-api.json) and run generate-json-api from the package.json to regenerate this file. */
22

33
export type LibraryVersion = string;
44
export type ConcreteSymbol =

packages/semantic-model/src/validate.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1-
import Ajv, { ValidateFunction } from "ajv";
1+
import { ValidateFunction } from "ajv";
2+
import Ajv from "ajv";
3+
import { readJsonSync } from "fs-extra";
4+
import { isPlainObject, isArray } from "lodash";
5+
import * as schema from "@ui5-language-assistant/semantic-model/resources/sap-ui-library-api.json";
26
import { Json } from "../api";
37
import { SchemaForApiJsonFiles } from "./api-json";
4-
import * as schema from "@ui5-language-assistant/semantic-model/resources/sap-ui-library-api.json";
5-
import * as jsonDraft06Schema from "ajv/lib/refs/json-schema-draft-06.json";
6-
import { isPlainObject, isArray } from "lodash";
8+
9+
// https://github.com/microsoft/TypeScript/issues/38540
10+
// TODO: revert back to: `import * as jsonDraft06Schema from "ajv/lib/refs/json-schema-draft-06.json"`
11+
// once TypeScript 3.9.5 is released.
12+
const jsonDraft06Schema = readJsonSync(
13+
require.resolve("ajv/lib/refs/json-schema-draft-06.json")
14+
);
715

816
const validate = createSchemaValidator();
917

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { expect } from "chai";
2+
import {
3+
expectExists,
4+
generateModel,
5+
} from "@ui5-language-assistant/test-utils";
6+
import { UI5SemanticModel } from "@ui5-language-assistant/semantic-model-types";
7+
8+
import { findSymbol } from "../src/api";
9+
10+
describe("The semantic model utils", () => {
11+
let model: UI5SemanticModel;
12+
13+
before(async () => {
14+
model = await generateModel({ version: "1.74.0" });
15+
});
16+
17+
context("findSymbols", () => {
18+
it("can locate a UI5 symbol in the model by FQN", () => {
19+
const button = findSymbol(model, "sap.m.Button");
20+
expectExists(button, "find symbol failed");
21+
expect(button.kind).to.eql("UI5Class");
22+
// cannot use FQN utility here due to cyclic packages deps
23+
// TODO: fix cyclic packages deps (test-utils and semantic-model)
24+
expect(button.name).to.eql("Button");
25+
});
26+
});
27+
});

packages/xml-views-validation/src/validators/document/non-unique-id.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ function buildIssuesForSingleID(
4444
);
4545

4646
return {
47-
kind: "NonUniqueIDIssue" as "NonUniqueIDIssue",
47+
kind: "NonUniqueIDIssue" as const,
4848
message: getMessage(NON_UNIQUE_ID, id),
49-
severity: "error" as "error",
49+
severity: "error" as const,
5050
offsetRange: {
5151
start: currDupIdValToken.startOffset,
5252
end: currDupIdValToken.endOffset,
@@ -84,10 +84,10 @@ class IdsCollectorVisitor implements XMLAstVisitor {
8484
!isNoneUI5id(attrib)
8585
) {
8686
if (this.idsToXMLElements[attrib.value] === undefined) {
87-
// @ts-ignore - TSC does not understand: `attrib.syntax.value !== undefined` is a type guard
87+
// @ts-expect-error - TSC does not understand: `attrib.syntax.value !== undefined` is a type guard
8888
this.idsToXMLElements[attrib.value] = [attrib];
8989
} else {
90-
// @ts-ignore - TSC does not understand: `attrib.syntax.value !== undefined` is a type guard
90+
// @ts-expect-error - TSC does not understand: `attrib.syntax.value !== undefined` is a type guard
9191
this.idsToXMLElements[attrib.value].push(attrib);
9292
}
9393
}

packages/xml-views-validation/src/validators/elements/unknown-tag-name.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ function validateTagWithNamespace(
5858
model: UI5SemanticModel
5959
): UnknownTagNameIssue[] {
6060
const issueDefaults = {
61-
kind: "UnknownTagName" as "UnknownTagName",
61+
kind: "UnknownTagName" as const,
6262
offsetRange: {
6363
start: xmlElement.syntax.openName.startOffset,
6464
end: xmlElement.syntax.openName.endOffset,
6565
},
66-
severity: "error" as "error",
66+
severity: "error" as const,
6767
};
6868

6969
// To avoid false positives, we assume unrecognized namespaces are user-defined so we don't validate tags in them
@@ -124,12 +124,12 @@ function validateTagWithoutNamespace(
124124
model: UI5SemanticModel
125125
): UnknownTagNameIssue[] {
126126
const issueDefaults = {
127-
kind: "UnknownTagName" as "UnknownTagName",
127+
kind: "UnknownTagName" as const,
128128
offsetRange: {
129129
start: xmlElement.syntax.openName.startOffset,
130130
end: xmlElement.syntax.openName.endOffset,
131131
},
132-
severity: "error" as "error",
132+
severity: "error" as const,
133133
};
134134

135135
// If the default namespace is defined and it's not a known namespace, don't validate

0 commit comments

Comments
 (0)