From 095333897e6005f07c740c3aca8cab28f20377cf Mon Sep 17 00:00:00 2001 From: Rostyslav Zatserkovnyi Date: Tue, 22 Oct 2024 19:21:40 +0300 Subject: [PATCH] Fix eslint #3 --- .eslintrc.js | 1 + src/components/tree/TreeInnerNode.svelte | 15 +++++++++++++-- src/components/tree/TreeLeafNode.svelte | 9 +++++++++ src/data/DataSet.ts | 5 ++++- src/data/EpiDate.ts | 6 +++++- src/data/EpiPoint.ts | 5 ++++- tsconfig.json | 2 +- 7 files changed, 37 insertions(+), 6 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 360ad1c..75c2b93 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -40,6 +40,7 @@ module.exports = { rules: { '@typescript-eslint/no-non-null-assertion': 'off', '@typescript-eslint/no-unnecessary-type-assertion': 'off', // generate as a bunch of false positives + '@typescript-eslint/no-base-to-string': 'off', // false positives in deriveLinkDefaults }, }, ], diff --git a/src/components/tree/TreeInnerNode.svelte b/src/components/tree/TreeInnerNode.svelte index 82a5a4d..e430626 100644 --- a/src/components/tree/TreeInnerNode.svelte +++ b/src/components/tree/TreeInnerNode.svelte @@ -1,7 +1,7 @@
- + { + if (e.key !== 'Enter' && e.key !== ' ') return; + e.preventDefault(); + if (e.target != null) { + e.target.click(); + } + }} + > {node.title} diff --git a/src/components/tree/TreeLeafNode.svelte b/src/components/tree/TreeLeafNode.svelte index 43e6466..4f11511 100644 --- a/src/components/tree/TreeLeafNode.svelte +++ b/src/components/tree/TreeLeafNode.svelte @@ -30,6 +30,15 @@ class="tv_node" class:selected on:click={toggleSelected} + role="button" + tabindex="0" + on:keydown={(e) => { + if (e.key !== 'Enter' && e.key !== ' ') return; + e.preventDefault(); + if (e.target != null) { + e.target.click(); + } + }} title="click to toggle the visibility of this dataset" uk-tooltip="pos: right" > diff --git a/src/data/DataSet.ts b/src/data/DataSet.ts index eab8ebc..eb97475 100644 --- a/src/data/DataSet.ts +++ b/src/data/DataSet.ts @@ -103,7 +103,10 @@ export default class DataSet { export class DataGroup { public parent?: DataGroup; - constructor(public readonly title: string, public readonly datasets: (DataSet | DataGroup)[]) {} + constructor( + public readonly title: string, + public readonly datasets: (DataSet | DataGroup)[], + ) {} flat(arr: DataSet[]): void { for (const child of this.datasets) { diff --git a/src/data/EpiDate.ts b/src/data/EpiDate.ts index 26cb05a..8059404 100644 --- a/src/data/EpiDate.ts +++ b/src/data/EpiDate.ts @@ -3,7 +3,11 @@ export default class EpiDate { private static CUMULATIVE_DAYS_PER_MONTH = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334]; private static DAY_OF_WEEK_TABLE = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4]; - constructor(private readonly year: number, private readonly month: number, private readonly day: number) { + constructor( + private readonly year: number, + private readonly month: number, + private readonly day: number, + ) { // constructor logic if ( year < 1 || diff --git a/src/data/EpiPoint.ts b/src/data/EpiPoint.ts index b7e04d8..59cb551 100644 --- a/src/data/EpiPoint.ts +++ b/src/data/EpiPoint.ts @@ -1,7 +1,10 @@ import type EpiDate from './EpiDate'; export default class EpiPoint { - constructor(private readonly date: EpiDate, private readonly value: number) {} + constructor( + private readonly date: EpiDate, + private readonly value: number, + ) {} getDate(): EpiDate { return this.date; } diff --git a/tsconfig.json b/tsconfig.json index 8a0d7dc..88fa8fd 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,7 +15,7 @@ "strictNullChecks": true, "strictPropertyInitialization": true, "resolveJsonModule": true, - "verbatimModuleSyntax": true, + "verbatimModuleSyntax": true }, "include": ["src/**/*", "types.d.ts"], "exclude": ["node_modules/*", "__sapper__/*", "public/*"]