Skip to content

Commit

Permalink
Merge pull request #5509 from dodona-edu/chore/update-eslint-and-node
Browse files Browse the repository at this point in the history
Update major Node and Eslint versions
  • Loading branch information
jorg-vr authored Jul 12, 2024
2 parents fa2f65f + c4b0dad commit 5f7c99f
Show file tree
Hide file tree
Showing 45 changed files with 457 additions and 292 deletions.
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

83 changes: 0 additions & 83 deletions .eslintrc

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 16.x
node-version: 22.x
cache: yarn
- name: Install dependencies
run: |
Expand All @@ -53,7 +53,7 @@ jobs:
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 16.x
node-version: 22.x
cache: yarn
- name: Install dependencies
run: |
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ jobs:
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Use node 16
- name: Use node 22
uses: actions/setup-node@v4
with:
node-version: 16.x
node-version: 22.x
cache: yarn
- name: Run tests
env:
Expand All @@ -63,7 +63,7 @@ jobs:
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 16.x
node-version: 22.x
cache: yarn
- name: Install dependencies
run: |
Expand Down Expand Up @@ -102,10 +102,10 @@ jobs:
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Use node 16
- name: Use node 22
uses: actions/setup-node@v4
with:
node-version: 16.x
node-version: 22.x
cache: yarn
- name: Setup chromium-chromedriver
uses: nanasess/setup-chromedriver@master
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { customElement, property } from "lit/decorators.js";
import { html, TemplateResult } from "lit";
import { html, PropertyValues, TemplateResult } from "lit";
import { watchMixin } from "components/meta/watch_mixin";
import { createRef, Ref, ref } from "lit/directives/ref.js";
import "components/saved_annotations/saved_annotation_input";
Expand Down Expand Up @@ -210,7 +210,7 @@ export class AnnotationForm extends watchMixin(DodonaElement) {
this.inputRef.value.focus();
}

updated(changedProperties: Map<string, any>): void {
updated(changedProperties: PropertyValues): void {
// Focus the newly shown title input if the user wants to save the annotation.
if (changedProperties.has("saveAnnotation") && this.saveAnnotation) {
this.titleRef.value.focus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class AnnotationsCell extends DodonaElement {
const mode = annotationState.isQuestionMode ? "question" : "annotation";
await userAnnotationState.create(annotationData, submissionState.id, mode, e.detail.saveAnnotation, e.detail.savedAnnotationTitle);
this.closeForm();
} catch (err) {
} catch {
this.annotationFormRef.value.hasErrors = true;
this.annotationFormRef.value.disabled = false;
}
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/components/annotations/thread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class Thread extends DodonaElement {
const mode = annotationState.isQuestionMode ? "question" : "annotation";
await userAnnotationState.create(annotationData, submissionState.id, mode, e.detail.saveAnnotation, e.detail.savedAnnotationTitle);
this.formShown = false;
} catch (err) {
} catch {
this.annotationFormRef.value.hasErrors = true;
this.annotationFormRef.value.disabled = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class UserAnnotationComponent extends DodonaElement {
});
}
this.editing = false;
} catch (e) {
} catch {
this.annotationFormRef.value.hasErrors = true;
this.annotationFormRef.value.disabled = false;
}
Expand All @@ -128,7 +128,7 @@ export class UserAnnotationComponent extends DodonaElement {
try {
// Ask MathJax to search for math in the annotations
window.MathJax.typeset([this]);
} catch (e) {
} catch {
// MathJax is not loaded
console.warn("MathJax is not loaded");
}
Expand Down
2 changes: 2 additions & 0 deletions app/assets/javascripts/components/meta/i18n_mixin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { LitElement } from "lit";
import { ready } from "utilities";

// eslint-disable-next-line @typescript-eslint/no-explicit-any
type Constructor = new (...args: any[]) => LitElement;

export function i18nMixin<T extends Constructor>(superClass: T): T {
Expand All @@ -9,6 +10,7 @@ export function i18nMixin<T extends Constructor>(superClass: T): T {
* It also makes sure that the component is rerendered when the language becomes available
*/
class I18nMixinClass extends superClass {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
constructor(...args: any[]) {
super(args);
// Reload when I18n is available
Expand Down
5 changes: 3 additions & 2 deletions app/assets/javascripts/components/meta/watch_mixin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { LitElement } from "lit";
import { LitElement, PropertyValues } from "lit";

// eslint-disable-next-line @typescript-eslint/no-explicit-any
type Constructor = abstract new (...args: any[]) => LitElement;

export function watchMixin<T extends Constructor>(superClass: T): T {
Expand All @@ -9,7 +10,7 @@ export function watchMixin<T extends Constructor>(superClass: T): T {
abstract class WatchMixinClass extends superClass {
abstract get watch(): {[key: string]: (old: unknown) => void};

update(changedProperties: Map<string, unknown>): void {
update(changedProperties: PropertyValues): void {
for (const [key, f] of Object.entries(this.watch)) {
if (changedProperties.has(key)) {
f.bind(this);
Expand Down
5 changes: 3 additions & 2 deletions app/assets/javascripts/components/modal_mixin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html, TemplateResult, render } from "lit";
import { html, TemplateResult, render, PropertyValues } from "lit";
import { ref } from "lit/directives/ref.js";
import { Modal as Modal } from "bootstrap";
import { DodonaElement } from "components/meta/dodona_element";
Expand All @@ -20,6 +20,7 @@ export declare abstract class ModalMixinInterface {
hideModal(): void;
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
type Constructor<T> = abstract new (...args: any[]) => T;

export function modalMixin<T extends Constructor<DodonaElement>>(superClass: T): Constructor<ModalMixinInterface> & T {
Expand Down Expand Up @@ -60,7 +61,7 @@ export function modalMixin<T extends Constructor<DodonaElement>>(superClass: T):
// This can cause unexpected behaviour if update is triggered on a modal component which is different from the currently active modalcomponent
// (As there is only one real html modal, the wrong `filledModalTemplate` will be displayed)
// This could be solved by tracking which modalcomponent is currently active
update(changedProperties: Map<string, any>): void {
update(changedProperties: PropertyValues): void {
super.update(changedProperties);
this.renderModal();
}
Expand Down
6 changes: 3 additions & 3 deletions app/assets/javascripts/components/progress_bar.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { html, TemplateResult } from "lit";
import { html, PropertyValues, TemplateResult } from "lit";
import { customElement, property } from "lit/decorators.js";
import { initTooltips, ready } from "../utilities";
import { initTooltips } from "../utilities";
import { i18n } from "i18n/i18n";
import { DodonaElement } from "components/meta/dodona_element";

Expand Down Expand Up @@ -38,7 +38,7 @@ export class ProgressBar extends DodonaElement {
return i18n.t(this.titleKey + i18n.t(this.titleKey + ".key", index), { index: index, smart_count: value });
}

updated(changedProperties: Map<string, any>): void {
updated(changedProperties: PropertyValues): void {
initTooltips(this);
super.updated(changedProperties);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class FilterCollectionElement extends DodonaElement {
searchQueryState.arrayQueryParams.set(this.param, [...this.multiSelected, this.str(label)]);
}

private singleUnSelect(label: Label): void {
private singleUnSelect(): void {
searchQueryState.queryParams.set(this.param, undefined);
}

Expand All @@ -80,7 +80,7 @@ export class FilterCollectionElement extends DodonaElement {
}

isSelected = this.singleIsSelected;
unSelect = this.singleUnSelect;
unSelect: (label: Label) => void = this.singleUnSelect;
select = this.singleSelect;

toggle(label: Label): void {
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/components/search/loading_bar.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html, PropertyValues, TemplateResult } from "lit";
import { html, TemplateResult } from "lit";
import { customElement, property } from "lit/decorators.js";
import { search } from "search";
import { DodonaElement } from "components/meta/dodona_element";
Expand Down
1 change: 0 additions & 1 deletion app/assets/javascripts/components/search/search_option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { customElement, property } from "lit/decorators.js";
import { DodonaElement } from "components/meta/dodona_element";
import { searchQueryState } from "state/SearchQuery";
import { html, TemplateResult } from "lit";
import { i18n } from "i18n/i18n";

export type Option = {param: string, label: string};

Expand Down
1 change: 0 additions & 1 deletion app/assets/javascripts/components/sign_in_search_bar.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { customElement, property } from "lit/decorators.js";
import { html, TemplateResult } from "lit";
import { Option } from "components/datalist_input";
import { ready } from "utilities";
import "components/datalist_input";
import { DodonaElement } from "components/meta/dodona_element";
import { i18n } from "i18n/i18n";
Expand Down
24 changes: 13 additions & 11 deletions app/assets/javascripts/course.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,39 +226,41 @@ function initCourseNew(): void {
const formCollapse = new bootstrap.Collapse(formCollapseElement, { toggle: false });

function initPanelLogic(): void {
document.getElementById("new-course").addEventListener("click", function () {
const newCourseButton = document.getElementById("new-course");
newCourseButton.addEventListener("click", function () {
choosePanel.classList.add("hidden");
formPanel.querySelector(".step-circle").innerHTML = "2";
this.closest(".panel")
newCourseButton.closest(".panel")
.querySelector(".answer")
.textContent = this.dataset.answer;
.textContent = newCourseButton.dataset.answer;
fetch("/courses/new.js")
.then(req => req.text())
.then(resp => eval(resp));
});

document.getElementById("copy-course").addEventListener("click", function () {
const copyCourseButton = document.getElementById("copy-course");
copyCourseButton.addEventListener("click", function () {
choosePanel.classList.remove("hidden");
chooseCollapse.show();
choosePanel.querySelectorAll<HTMLInputElement>(`input[type="radio"]`).forEach(el => {
el.checked = false;
});
formPanel.classList.add("hidden");
formPanel.querySelector(".step-circle").innerHTML = "3";
this.closest(".panel")
copyCourseButton.closest(".panel")
.querySelector(".answer")
.textContent = this.dataset.answer;
.textContent = copyCourseButton.dataset.answer;
});
}

function copyCoursesLoaded(): void {
document.querySelectorAll("[data-course_id]").forEach(el => {
document.querySelectorAll("[data-course_id]").forEach((el: HTMLElement) => {
el.addEventListener("click", function () {
this.querySelector(`input[type="radio"]`).checked = true;
this.closest(".panel")
(el.querySelector(`input[type="radio"]`) as HTMLInputElement).checked = true;
el.closest(".panel")
.querySelector(".answer")
.textContent = this.dataset.answer;
fetch(`/courses/new.js?copy_options[base_id]=${this.dataset.course_id}`)
.textContent = el.dataset.answer;
fetch(`/courses/new.js?copy_options[base_id]=${el.dataset.course_id}`)
.then(req => req.text())
.then(resp => eval(resp));
});
Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/drag_and_drop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ function initDragAndDrop(args: DragAndDropArguments): void {
const tableBody = document.querySelectorAll(args.table_selector)[0];

dragula([tableBody], {
moves: (el, source, handle, sibling) => {
moves: (el, source, handle) => {
return handle.classList.contains("drag-handle") || getParentByClassName(handle, "drag-handle") !== null;
},
mirrorContainer: tableBody,
})
.on("cloned", (clone, original, type) => {
.on("cloned", (clone, original) => {
copyWidth(clone, original, "td");
})
.on("drop", () => {
Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/exercise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function showLightbox(content): void {
// MathJax to search for new math (but only in the captions).
try {
window.MathJax.typeset( Array.from(document.querySelectorAll(".gslide-description")));
} catch (e) {
} catch {
// MathJax is not loaded
console.warn("MathJax is not loaded");
}
Expand Down Expand Up @@ -410,7 +410,7 @@ async function initExerciseShow(options: {
} else if (errors.exercise && errors.exercise[0] === "not permitted") {
message = i18n.t("js.submission-not-allowed");
}
} catch (e) {
} catch {
message = i18n.t("js.submission-failed");
}
}
Expand Down
Loading

0 comments on commit 5f7c99f

Please sign in to comment.