Skip to content

Commit

Permalink
refactor: Ignore resolveLinks.ts from tsLint check
Browse files Browse the repository at this point in the history
  • Loading branch information
d3xter666 committed Aug 2, 2024
1 parent e0aae21 commit c50991d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 13 deletions.
5 changes: 5 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ export default tseslint.config(
...tseslint.configs.recommendedTypeChecked,
...tseslint.configs.stylisticTypeChecked,
],
ignores: [
// This file is a copy of an openui5 resource which is located at
// https://github.com/SAP/openui5/blob/master/lib/jsdoc/transformApiJson.js

Check warning on line 53 in eslint.config.js

View check run for this annotation

In Solidarity / Inclusive Language

Match Found

You might want to consider an alternative to the term "master". Possibilities might include: "active", "central", "initiator", "leader", "main", "orchestrator", "parent", "primary", "server". (This check uses pattern-matching and may therefore be incorrect. To improve the patterns or to make other suggestions, please open an issue or pull-request at https://github.com/ietf/terminology/issues.)
Raw output
/\bmaster\w*\b/gi
"src/formatter/lib/resolveLinks.ts",
],
languageOptions: {
ecmaVersion: 2022,
sourceType: "module",
Expand Down
42 changes: 29 additions & 13 deletions src/formatter/lib/resolveLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,25 @@ function _preProcessLinksInTextBlock(sText: string, ui5Url: string, ui5Version:
}

// If the link has a protocol, do not modify, but open in a new window
if (sTarget.includes("://")) {
if (/:\/\//.test(sTarget)) {
return formatUrlToLink(sTarget, sText);
}
// topic:xxx Topic
aMatch = /^topic:(\w{32}(?:#\w*)?(?:\/\w*)?)$/.exec(sTarget);
aMatch = sTarget.match(
/^topic:(\w{32}(?:#\w*)?(?:\/\w*)?)$/
);
if (aMatch) {
return formatUrlToLink(`${ui5Url}/#/topic/${aMatch[1]}`, sText);
}
// demo:xxx Demo, open the demonstration page in a new window
aMatch = /^demo:([a-zA-Z0-9/.]*)$/.exec(sTarget);
aMatch = sTarget.match(/^demo:([a-zA-Z0-9/.]*)$/);
if (aMatch) {
return formatUrlToLink(`${ui5Url}/${ui5Version}/#/test-resources/${aMatch[1]}`, sText);
}
// sap.x.Xxx.prototype.xxx - In case of prototype we have a link to method
aMatch = /([a-zA-Z0-9.$_]+?)\.prototype\.([a-zA-Z0-9.$_]+)$/.exec(sTarget);
aMatch = sTarget.match(
/([a-zA-Z0-9.$_]+?)\.prototype\.([a-zA-Z0-9.$_]+)$/
);
if (aMatch) {
return createLink({
name: aMatch[2],
Expand All @@ -110,7 +114,9 @@ function _preProcessLinksInTextBlock(sText: string, ui5Url: string, ui5Version:
// Heuristics: Extend is always a static method
// sap.x.Xxx.extend
// module:sap/x/Xxx.extend
aMatch = /^(module:)?([a-zA-Z0-9.$_/]+?)\.extend$/.exec(sTarget);
aMatch = sTarget.match(
/^(module:)?([a-zA-Z0-9.$_/]+?)\.extend$/
);
if (aMatch) {
const [, sModule, sClass] = aMatch;
return createLink({
Expand All @@ -126,7 +132,9 @@ function _preProcessLinksInTextBlock(sText: string, ui5Url: string, ui5Version:
// sap.x.Xxx#constructor
// module:sap/x/Xxx.constructor
// #constructor
aMatch = /^(module:)?([a-zA-Z0-9.$_/]+?)?[.#]constructor$/i.exec(sTarget);
aMatch = sTarget.match(
/^(module:)?([a-zA-Z0-9.$_/]+?)?[.#]constructor$/i
);
if (aMatch) {
const [, sModule, sClass] = aMatch;
let sName = "";
Expand All @@ -143,7 +151,7 @@ function _preProcessLinksInTextBlock(sText: string, ui5Url: string, ui5Version:
// #.setText - local static method
// #setText - local instance method
// #.setText.from - local nested method
aMatch = /^#(\.)?([a-zA-Z0-9.$_]+)$/.exec(sTarget);
aMatch = sTarget.match(/^#(\.)?([a-zA-Z0-9.$_]+)$/);
if (aMatch) {
return createLink({
name: aMatch[2],
Expand All @@ -154,7 +162,7 @@ function _preProcessLinksInTextBlock(sText: string, ui5Url: string, ui5Version:
});
}
// #annotation:TextArrangement - local annotation
aMatch = /^#annotation:([a-zA-Z0-9$_]+)$/.exec(sTarget);
aMatch = sTarget.match(/^#annotation:([a-zA-Z0-9$_]+)$/);
if (aMatch) {
return createLink({
name: aMatch[1],
Expand All @@ -169,7 +177,9 @@ function _preProcessLinksInTextBlock(sText: string, ui5Url: string, ui5Version:
// sap.ui.comp.smartfield.SmartField.annotation:TextArrangement
// module:sap/ui/comp/smartfield/SmartField.annotation:TextArrangement
// module:sap/ui/comp/smartfield/SmartField#annotation:TextArrangement
aMatch = /^(module:)?([a-zA-Z0-9.$_/]+?)[.#]annotation:([a-zA-Z0-9$_]+)$/.exec(sTarget);
aMatch = sTarget.match(
/^(module:)?([a-zA-Z0-9.$_/]+?)[.#]annotation:([a-zA-Z0-9$_]+)$/
);
if (aMatch) {
const [, sModule, sClass, sAnnotation] = aMatch;
return createLink({
Expand All @@ -181,7 +191,7 @@ function _preProcessLinksInTextBlock(sText: string, ui5Url: string, ui5Version:
});
}
// #event:press - local event
aMatch = /^#event:([a-zA-Z0-9$_]+)$/.exec(sTarget);
aMatch = sTarget.match(/^#event:([a-zA-Z0-9$_]+)$/);
if (aMatch) {
return createLink({
name: aMatch[1],
Expand All @@ -196,7 +206,9 @@ function _preProcessLinksInTextBlock(sText: string, ui5Url: string, ui5Version:
// sap.m.Button.event:press
// module:sap/m/Button.event:press
// module:sap/m/Button#event:press
aMatch = /^(module:)?([a-zA-Z0-9.$_/]+?)[.#]event:([a-zA-Z0-9$_]+)$/.exec(sTarget);
aMatch = sTarget.match(
/^(module:)?([a-zA-Z0-9.$_/]+?)[.#]event:([a-zA-Z0-9$_]+)$/
);
if (aMatch) {
const [, sModule, sClass, sEvent] = aMatch;
return createLink({
Expand All @@ -209,7 +221,9 @@ function _preProcessLinksInTextBlock(sText: string, ui5Url: string, ui5Version:
}
// sap.m.Button#setText - instance method
// module:sap/m/Button#setText
aMatch = /^(module:)?([a-zA-Z0-9.$_/]+)#([a-zA-Z0-9.$_]+)$/.exec(sTarget);
aMatch = sTarget.match(
/^(module:)?([a-zA-Z0-9.$_/]+)#([a-zA-Z0-9.$_]+)$/
);
if (aMatch) {
const [, sModule, sClass, sMethod] = aMatch;
return createLink({
Expand All @@ -221,7 +235,9 @@ function _preProcessLinksInTextBlock(sText: string, ui5Url: string, ui5Version:
});
}
// module:sap/m/Button.setText
aMatch = /^(module:)([a-zA-Z0-9.$_/]+)\.([a-zA-Z0-9.$_]+)$/.exec(sTarget);
aMatch = sTarget.match(
/^(module:)([a-zA-Z0-9.$_/]+)\.([a-zA-Z0-9.$_]+)$/
);
if (aMatch) {
const [, sModule, sClass, sMethod] = aMatch;
return createLink({
Expand Down

0 comments on commit c50991d

Please sign in to comment.