Skip to content

Commit e4ff0be

Browse files
matz3GitHub Enterprise
authored andcommitted
[FIX] Use single quotes for deprecated import message (#63)
1 parent 3180e85 commit e4ff0be

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

packages/ui5-linter/src/detectors/typeChecker/FileLinter.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,12 @@ export default class FileLinter {
317317

318318
analyzeImportDeclaration(importDeclarationNode: ts.ImportDeclaration) {
319319
const moduleSpecifierNode = importDeclarationNode.moduleSpecifier;
320+
if (!ts.isStringLiteral(moduleSpecifierNode)) {
321+
// An ImportDeclaration moduleSpecifier is of type Expression, but the docs says:
322+
// "If this is not a StringLiteral it will be a grammar error."
323+
// So we ignore such cases here.
324+
return;
325+
}
320326
const symbol = this.#checker.getSymbolAtLocation(moduleSpecifierNode);
321327
// Only check for the "default" export regardless of what's declared
322328
// as UI5 / AMD only supports importing the default anyways.
@@ -329,7 +335,7 @@ export default class FileLinter {
329335
ruleId: "ui5-linter-no-deprecated-api",
330336
message:
331337
`Import of deprecated module ` +
332-
`${moduleSpecifierNode.getText()}`,
338+
`'${moduleSpecifierNode.text}'`,
333339
messageDetails: this.extractDeprecatedMessage(defaultExportSymbol),
334340
});
335341
}

packages/ui5-linter/test/lib/linter/rules/snapshots/NoDeprecatedApi.ts.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Generated by [AVA](https://avajs.dev).
1919
column: 16,
2020
fatal: undefined,
2121
line: 1,
22-
message: 'Import of deprecated module "sap/ui/model/odata/ODataModel"',
22+
message: 'Import of deprecated module \'sap/ui/model/odata/ODataModel\'',
2323
messageDetails: 'Deprecated test message',
2424
ruleId: 'ui5-linter-no-deprecated-api',
2525
severity: 2,
@@ -44,7 +44,7 @@ Generated by [AVA](https://avajs.dev).
4444
column: 18,
4545
fatal: undefined,
4646
line: 2,
47-
message: 'Import of deprecated module "sap/m/DateTimeInput"',
47+
message: 'Import of deprecated module \'sap/m/DateTimeInput\'',
4848
messageDetails: 'Deprecated test message',
4949
ruleId: 'ui5-linter-no-deprecated-api',
5050
severity: 2,
@@ -53,7 +53,7 @@ Generated by [AVA](https://avajs.dev).
5353
column: 41,
5454
fatal: undefined,
5555
line: 2,
56-
message: 'Import of deprecated module "sap/base/util/includes"',
56+
message: 'Import of deprecated module \'sap/base/util/includes\'',
5757
messageDetails: 'Deprecated test message',
5858
ruleId: 'ui5-linter-no-deprecated-api',
5959
severity: 2,
@@ -250,7 +250,7 @@ Generated by [AVA](https://avajs.dev).
250250
column: 2,
251251
fatal: undefined,
252252
line: 6,
253-
message: 'Import of deprecated module "sap/m/DateTimeInput"',
253+
message: 'Import of deprecated module \'sap/m/DateTimeInput\'',
254254
messageDetails: 'Deprecated test message',
255255
ruleId: 'ui5-linter-no-deprecated-api',
256256
severity: 2,
@@ -320,7 +320,7 @@ Generated by [AVA](https://avajs.dev).
320320
column: 2,
321321
fatal: undefined,
322322
line: 7,
323-
message: 'Import of deprecated module "sap/m/DateTimeInput"',
323+
message: 'Import of deprecated module \'sap/m/DateTimeInput\'',
324324
messageDetails: 'Deprecated test message',
325325
ruleId: 'ui5-linter-no-deprecated-api',
326326
severity: 2,
@@ -434,7 +434,7 @@ Generated by [AVA](https://avajs.dev).
434434
column: 2,
435435
fatal: undefined,
436436
line: 4,
437-
message: 'Import of deprecated module "sap/ui/core/Message"',
437+
message: 'Import of deprecated module \'sap/ui/core/Message\'',
438438
messageDetails: 'Deprecated test message',
439439
ruleId: 'ui5-linter-no-deprecated-api',
440440
severity: 2,
@@ -459,7 +459,7 @@ Generated by [AVA](https://avajs.dev).
459459
column: 2,
460460
fatal: undefined,
461461
line: 6,
462-
message: 'Import of deprecated module "sap/ui/core/Message"',
462+
message: 'Import of deprecated module \'sap/ui/core/Message\'',
463463
messageDetails: 'Deprecated test message',
464464
ruleId: 'ui5-linter-no-deprecated-api',
465465
severity: 2,
@@ -468,7 +468,7 @@ Generated by [AVA](https://avajs.dev).
468468
column: 8,
469469
fatal: undefined,
470470
line: 9,
471-
message: 'Import of deprecated module "sap/ui/model/odata/ODataModel"',
471+
message: 'Import of deprecated module \'sap/ui/model/odata/ODataModel\'',
472472
messageDetails: 'Deprecated test message',
473473
ruleId: 'ui5-linter-no-deprecated-api',
474474
severity: 2,
@@ -493,7 +493,7 @@ Generated by [AVA](https://avajs.dev).
493493
column: 2,
494494
fatal: undefined,
495495
line: 7,
496-
message: 'Import of deprecated module "sap/m/DateTimeInput"',
496+
message: 'Import of deprecated module \'sap/m/DateTimeInput\'',
497497
messageDetails: 'Deprecated test message',
498498
ruleId: 'ui5-linter-no-deprecated-api',
499499
severity: 2,
Binary file not shown.

packages/ui5-linter/test/lib/linter/snapshots/linter.ts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ Generated by [AVA](https://avajs.dev).
705705
column: 2,
706706
fatal: undefined,
707707
line: 11,
708-
message: 'Import of deprecated module "sap/m/MessagePage"',
708+
message: 'Import of deprecated module \'sap/m/MessagePage\'',
709709
messageDetails: 'Deprecated test message',
710710
ruleId: 'ui5-linter-no-deprecated-api',
711711
severity: 2,
Binary file not shown.

0 commit comments

Comments
 (0)