Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Misc] Code style: use arrow functions #689

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion core/backends/backend-github/src/githubStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class GitHubStorage extends AbstractStorage {
return `${this.wikiConfig.baseRestURL}${directory}${image}`;
}

hashCode = function (str: string): string {
hashCode = (str: string): string => {
let hash = 0,
i,
chr;
Expand Down
5 changes: 2 additions & 3 deletions core/markdown/markdown-default/src/parseInternalImages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,8 @@ export function parseInternalImages(
modelReferenceParser: ModelReferenceParser,
remoteURLSerializer: RemoteURLSerializer,
): MarkdownIt.Core.RuleCore {
return function (state: StateCore): void {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
state.tokens.forEach((blockToken: any) => {
return (state) => {
state.tokens.forEach((blockToken) => {
if (blockToken.type == "inline") {
handleInlineBlockToken(
blockToken,
Expand Down
5 changes: 2 additions & 3 deletions core/markdown/markdown-default/src/parseInternalLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,8 @@ export function parseInternalLinks(
modelReferenceParser: ModelReferenceParser,
remoteURLSerializer: RemoteURLSerializer,
): MarkdownIt.Core.RuleCore {
return function (state: StateCore): void {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
state.tokens.forEach((blockToken: any) => {
return (state) => {
state.tokens.forEach((blockToken) => {
if (blockToken.type == "inline") {
handleInlineBlockToken(
blockToken,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ function serializeExternal(node: Node, state: MarkdownSerializerState) {
* We need to override the default image view to be able to easily add widgets (i.e., visual elements that are not
* part of the persisted DOM) using Vue.
*/
const initTiptapImage = function (
const initTiptapImage = (
serializer: ModelReferenceSerializer,
parser: RemoteURLParser,
) {
) => {
function parseLink(mark: Node): EntityReference | undefined {
try {
return parser.parse(mark.attrs.src as string);
Expand Down
4 changes: 2 additions & 2 deletions editors/tiptap/src/components/extensions/link-suggest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ function initSuggestionsService(
// Return an array of suggestions from a query
// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
return async function ({
return async ({
query,
}: {
query: string;
}): Promise<LinkSuggestionActionDescriptor[]> {
}): Promise<LinkSuggestionActionDescriptor[]> => {
// TODO: add upload attachment action
// TODO: add create new page action
// TODO: add links suggestions
Expand Down
2 changes: 1 addition & 1 deletion editors/tiptap/src/extensions/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default function initLinkExtension(
return "[";
}
},
close: function (state: unknown, mark: Mark) {
close: (state: unknown, mark: Mark) => {
if (parseLink(mark)) {
return `|${serializer.serialize(parser.parse(mark.attrs.href))}]]`;
} else {
Expand Down
6 changes: 3 additions & 3 deletions editors/tiptap/src/extensions/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ import { RemoteURLSerializer } from "@xwiki/cristal-model-remote-url-api";
import MarkdownIt from "markdown-it";
import { Markdown } from "tiptap-markdown";

export default function (
export default (
modelReferenceParser: ModelReferenceParser,
remoteURLSerializer: RemoteURLSerializer,
) {
) => {
return Markdown.extend({
onBeforeCreate() {
const content = this.editor.options.content;
Expand All @@ -56,4 +56,4 @@ export default function (
this.editor.storage.markdown.parser.parse(content);
},
});
}
};
2 changes: 1 addition & 1 deletion sharedworker/impl/src/components/defaultQueueWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default class DefaultQueueWorker implements QueueWorker {
// eslint-disable-next-line @typescript-eslint/no-this-alias
const that = this;
this.workerInstance.setPageLoadedCallback(
Comlink.proxy(function (page: string) {
Comlink.proxy((page) => {
that.pageLoaded(page);
}),
);
Expand Down
4 changes: 1 addition & 3 deletions skin/src/vue/c-field.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ export default defineComponent({
.get();
logger?.debug("Ready to get edit field", props.name);
editFieldValue.value = "";
storage.getEditField(document, props.name).then(function (
editField: string,
) {
storage.getEditField(document, props.name).then((editField: string) => {
editFieldValue.value = editField;
});
} else {
Expand Down
23 changes: 19 additions & 4 deletions skin/src/vue/contentTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export class ContentTools {
const contentToInject = range.createContextualFragment(html);
contentToInject
.querySelectorAll("link[href], script[src]")
<<<<<<< HEAD
// TODO get rid of any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.forEach(function (resource: any) {
Expand All @@ -121,14 +122,28 @@ export class ContentTools {
return null;
}
});
=======
.forEach((resource) => {
url1 = resource.getAttribute("src") ?? resource.getAttribute("ref");
document
.querySelectorAll("link[href], script[src]")
.forEach((resource2) => {
const url2 =
resource2.getAttribute("src") ?? resource2.getAttribute("href");

if (url1 && url1 == url2) {
return null;
}
});
>>>>>>> ad4c7cd7 ([Misc] Code style: use arrow functions)
});
return url1;
}

public static transformImages(cristal: CristalApp, element: string): void {
const xwikiContentEl = document.getElementById(element);
if (xwikiContentEl) {
const transform = function (img: HTMLImageElement | HTMLScriptElement) {
const transform = (img: HTMLImageElement | HTMLScriptElement) => {
const srcItem = img.attributes.getNamedItem("src");
if (srcItem) {
ContentTools.logger?.debug("Found image with url ", srcItem.value);
Expand All @@ -148,7 +163,7 @@ export class ContentTools {
}
}
};
new MutationObserver(function (mutations: Array<MutationRecord>) {
new MutationObserver((mutations) => {
ContentTools.logger?.debug("Called in mutation records");
for (const { addedNodes } of mutations) {
addedNodes.forEach((addedNode) => {
Expand All @@ -171,7 +186,7 @@ export class ContentTools {
* Experimental function to transform scripts
*/
public static transformScripts(): void {
const transformScript = function (scriptEl: HTMLScriptElement) {
const transformScript = (scriptEl: HTMLScriptElement) => {
const srcItem = scriptEl.attributes.getNamedItem("src");
if (srcItem) {
ContentTools.logger?.debug(
Expand All @@ -197,7 +212,7 @@ export class ContentTools {
}
};

new MutationObserver(function (mutations: Array<MutationRecord>) {
new MutationObserver((mutations) => {
ContentTools.logger?.debug("Called in mutation records");
for (const { addedNodes } of mutations) {
addedNodes.forEach((addedNode) => {
Expand Down
2 changes: 1 addition & 1 deletion xwiki/remoteinlineeditor/src/vue/c-edit-xwikiremote.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default {
let path = "/" + cristal?.getCurrentPage() + "/view";
logger?.debug("pushing path in router", path);
cristal?.getRouter().push({ path: path });
cristal?.loadPage().then(function () {});
cristal?.loadPage().then(() => { });
}
},
false,
Expand Down