diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 00000000000..605758e6df6 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,73 @@ +module.exports = { + root: true, + extends: [ + "eslint:recommended", + "plugin:compat/recommended", + "plugin:svelte/base", + "plugin:svelte/recommended", + "plugin:svelte/prettier", + "plugin:@typescript-eslint/recommended", + "plugin:@typescript-eslint/eslint-recommended", + "prettier", + ], + parser: "@typescript-eslint/parser", + parserOptions: { + extraFileExtensions: [".svelte"], + }, + plugins: [ + "svelte", + "simple-import-sort", + "import", + "@typescript-eslint", + "@typescript-eslint/eslint-plugin", + ], + rules: { + "prefer-const": "warn", + "no-nested-ternary": "warn", + "simple-import-sort/imports": "warn", + "simple-import-sort/exports": "warn", + "import/first": "warn", + "import/newline-after-import": "warn", + "import/no-useless-path-segments": "warn", + "import/no-duplicates": "warn", + "@typescript-eslint/no-non-null-assertion": "off", + "@typescript-eslint/ban-ts-comment": "warn", + "@typescript-eslint/no-unused-vars": [ + "warn", + { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }, + ], + }, + overrides: [ + { + files: "*.svelte", + parser: "svelte-eslint-parser", + parserOptions: { + parser: "@typescript-eslint/parser", + }, + rules: { + "svelte/no-useless-mustaches": "warn", + "svelte/require-optimized-style-attribute": "warn", + "svelte/html-quotes": "warn", + "svelte/prefer-class-directive": "warn", + "svelte/prefer-style-directive": "warn", + "svelte/shorthand-attribute": "warn", + "svelte/shorthand-directive": "warn", + "no-redeclare": "off", + "no-global-assign": "off", + "no-self-assign": "off", + "no-undef": "off", + "svelte/no-at-html-tags": "off", + /* We would also ideally get rid of this: */ + "@typescript-eslint/no-explicit-any": "off", + /* Does not recognize that `store` and `$store` belongs to the same var: */ + "@typescript-eslint/no-unused-vars": "off", + }, + }, + ], + env: { browser: true }, + ignorePatterns: ["backend_proto.d.ts", "*.svelte.d.ts"], + globals: { + globalThis: false, + NodeListOf: false, + }, +}; diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index 4f93aaee50c..00000000000 --- a/.prettierrc +++ /dev/null @@ -1,6 +0,0 @@ -{ - "trailingComma": "all", - "printWidth": 88, - "tabWidth": 4, - "semi": true -} diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 00000000000..e4ecc75d9c2 --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,6 @@ + module.exports = { + trailingComma: "all", + printWidth: 88, + tabWidth: 4, + semi: true, +}; diff --git a/BUILD.bazel b/BUILD.bazel index d6dc535baf3..ad0d082f355 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -35,5 +35,7 @@ pkg_tar( exports_files([ "defs.bzl", "package.json", - ".prettierrc", + ".prettierignore", + ".prettierrc.js", + ".eslintrc.js", ]) diff --git a/docs/BUILD.bazel b/docs/BUILD.bazel index 23af06ebb71..ed474913b98 100644 --- a/docs/BUILD.bazel +++ b/docs/BUILD.bazel @@ -1,4 +1,3 @@ load("//ts:prettier.bzl", "prettier_test") # formatting of the .md files -prettier_test() diff --git a/package.json b/package.json index e15003ea326..992146ec23c 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,9 @@ "diff": "^5.0.0", "escodegen": "^2.0.0", "eslint": "^7.24.0", + "eslint-config-prettier": "^8.5.0", "eslint-plugin-compat": "^3.13.0", + "eslint-plugin-svelte": "^2.2.0", "espree": "^9.0.0", "estraverse": "^5.2.0", "glob": "^7.1.6", @@ -69,7 +71,6 @@ "d3": "^7.0.0", "eslint-plugin-import": "^2.25.4", "eslint-plugin-simple-import-sort": "^7.0.0", - "eslint-plugin-svelte3": "^3.4.0", "intl-pluralrules": "^1.2.2", "jquery": "^3.5.1", "jquery-ui-dist": "^1.12.1", diff --git a/ts/.eslintrc.js b/ts/.eslintrc.js deleted file mode 100644 index 1b909510744..00000000000 --- a/ts/.eslintrc.js +++ /dev/null @@ -1,53 +0,0 @@ -module.exports = { - extends: ["eslint:recommended", "plugin:compat/recommended"], - parser: "@typescript-eslint/parser", - plugins: [ - "svelte3", - "import", - "simple-import-sort", - "@typescript-eslint", - "@typescript-eslint/eslint-plugin", - ], - rules: { - "@typescript-eslint/ban-ts-comment": "warn", - "@typescript-eslint/no-unused-vars": [ - "warn", - { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }, - ], - "import/newline-after-import": "warn", - "import/no-useless-path-segments": "warn", - "simple-import-sort/imports": "warn", - "simple-import-sort/exports": "warn", - "prefer-const": "warn", - "no-nested-ternary": "warn", - }, - overrides: [ - { - files: "**/*.ts", - extends: [ - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended", - ], - rules: { - "@typescript-eslint/no-non-null-assertion": "off", - }, - }, - { - files: "**/*.svelte", - processor: "svelte3/svelte3", - rules: { - "no-redeclare": "off", - "no-global-assign": "off", - }, - }, - ], - env: { browser: true }, - ignorePatterns: ["backend_proto.d.ts", "*.svelte.d.ts"], - globals: { - globalThis: false, - NodeListOf: false, - }, - settings: { - "svelte3/typescript": () => require("typescript"), - }, -}; diff --git a/ts/BUILD.bazel b/ts/BUILD.bazel index 9fb25671afa..4cdcc86935b 100644 --- a/ts/BUILD.bazel +++ b/ts/BUILD.bazel @@ -9,13 +9,13 @@ prettier_test() ################# exports_files([ - ".eslintrc.js", "licenses.json", "sql_format.ts", "jest.config.js", - "package.json", "protobuf-no-long.js", "page.html", + "tsconfig.json", + "format.sh", ]) # a copy needs to be placed in bazel-bin for libs with diff --git a/ts/card-info/BUILD.bazel b/ts/card-info/BUILD.bazel index 5f8829d95da..05f0c15faf1 100644 --- a/ts/card-info/BUILD.bazel +++ b/ts/card-info/BUILD.bazel @@ -1,5 +1,5 @@ -load("//ts:prettier.bzl", "prettier_test") load("//ts:eslint.bzl", "eslint_test") +load("//ts:prettier.bzl", "prettier_test") load("//ts/svelte:svelte.bzl", "compile_svelte", "svelte_check") load("//ts:esbuild.bzl", "esbuild") load("//ts:generate_page.bzl", "generate_page") @@ -61,7 +61,6 @@ prettier_test() eslint_test() svelte_check( - name = "svelte_check", srcs = glob([ "*.ts", "*.svelte", diff --git a/ts/card-info/CardInfo.svelte b/ts/card-info/CardInfo.svelte index 694452ea23d..128dab7b54d 100644 --- a/ts/card-info/CardInfo.svelte +++ b/ts/card-info/CardInfo.svelte @@ -11,7 +11,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import CardStats from "./CardStats.svelte"; import Revlog from "./Revlog.svelte"; - export let includeRevlog: boolean = true; + export let includeRevlog = true; let stats: Stats.CardStatsResponse | null = null; let revlog: Stats.CardStatsResponse.StatsRevlogEntry[] | null = null; diff --git a/ts/change-notetype/Alert.svelte b/ts/change-notetype/Alert.svelte index 8275373e5d1..795f37970fc 100644 --- a/ts/change-notetype/Alert.svelte +++ b/ts/change-notetype/Alert.svelte @@ -19,8 +19,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html ? tr.changeNotetypeWillDiscardContent() : tr.changeNotetypeWillDiscardCards(); - const maxItems: number = 3; - let collapsed: boolean = true; + const maxItems = 3; + let collapsed = true; $: collapseMsg = collapsed ? tr.changeNotetypeExpand() : tr.changeNotetypeCollapse(); diff --git a/ts/change-notetype/ChangeNotetypePage.svelte b/ts/change-notetype/ChangeNotetypePage.svelte index b1106af9ffc..c8ea1711ffa 100644 --- a/ts/change-notetype/ChangeNotetypePage.svelte +++ b/ts/change-notetype/ChangeNotetypePage.svelte @@ -23,7 +23,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html -
+
diff --git a/ts/change-notetype/MapperRow.svelte b/ts/change-notetype/MapperRow.svelte index 71caf78cf70..9afe323adeb 100644 --- a/ts/change-notetype/MapperRow.svelte +++ b/ts/change-notetype/MapperRow.svelte @@ -21,7 +21,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html - diff --git a/ts/components/WithContext.svelte b/ts/components/WithContext.svelte index a34d83f8bfb..2e225bd37ac 100644 --- a/ts/components/WithContext.svelte +++ b/ts/components/WithContext.svelte @@ -8,7 +8,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html type T = boolean; - export let key: Symbol | string; + export let key: symbol | string; const store = getContext>(key); diff --git a/ts/components/WithDropdown.svelte b/ts/components/WithDropdown.svelte index 24955a8f787..2610a524fb7 100644 --- a/ts/components/WithDropdown.svelte +++ b/ts/components/WithDropdown.svelte @@ -63,7 +63,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html : false; } - const noop = () => {}; + const noop = () => { + /* noop */ + }; function createDropdown(toggle: HTMLElement): Dropdown { /* avoid focusing element toggle on menu activation */ toggle.focus = noop; @@ -87,7 +89,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html show: dropdown.show.bind(dropdown), // TODO this is quite confusing, but having a noop function fixes Bootstrap // in the deck-options when not including Bootstrap via diff --git a/ts/deck-options/NewOptions.svelte b/ts/deck-options/NewOptions.svelte index 647260daa05..fee3fbfaa60 100644 --- a/ts/deck-options/NewOptions.svelte +++ b/ts/deck-options/NewOptions.svelte @@ -94,7 +94,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html bind:value={$config.newCardInsertOrder} defaultValue={defaults.newCardInsertOrder} choices={newInsertOrderChoices} - breakpoint={"md"} + breakpoint="md" markdownTooltip={tr.deckConfigNewInsertionOrderTooltip()} > {tr.deckConfigNewInsertionOrder()} diff --git a/ts/deck-options/TabbedValue.svelte b/ts/deck-options/TabbedValue.svelte index 3490d3dde76..2308d9e57e9 100644 --- a/ts/deck-options/TabbedValue.svelte +++ b/ts/deck-options/TabbedValue.svelte @@ -44,7 +44,7 @@
    {#each tabs as tab, idx} -
  • +
  • {tab.title}
  • {/each} diff --git a/ts/deck-options/TimerOptions.svelte b/ts/deck-options/TimerOptions.svelte index 920d1dfa248..977a47cca92 100644 --- a/ts/deck-options/TimerOptions.svelte +++ b/ts/deck-options/TimerOptions.svelte @@ -44,7 +44,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html -
    +
    { }); } -import EnumSelectorRow from "./EnumSelectorRow.svelte"; -import SpinBoxFloatRow from "./SpinBoxFloatRow.svelte"; -import SpinBoxRow from "./SpinBoxRow.svelte"; -import SwitchRow from "./SwitchRow.svelte"; -import TitledContainer from "./TitledContainer.svelte"; - export const components = { TitledContainer, SpinBoxRow, diff --git a/ts/editable/BUILD.bazel b/ts/editable/BUILD.bazel index b9aceca1564..c88686184fc 100644 --- a/ts/editable/BUILD.bazel +++ b/ts/editable/BUILD.bazel @@ -60,7 +60,6 @@ prettier_test() eslint_test() svelte_check( - name = "svelte_check", srcs = glob([ "*.ts", "*.svelte", diff --git a/ts/editable/Mathjax.svelte b/ts/editable/Mathjax.svelte index 03687b73a70..26038da966a 100644 --- a/ts/editable/Mathjax.svelte +++ b/ts/editable/Mathjax.svelte @@ -84,7 +84,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html src="data:image/svg+xml,{encoded}" class:block class:empty - style="--vertical-center: {verticalCenter}px;" + style:--vertical-center="{verticalCenter}px" alt="Mathjax" {title} data-anki="mathjax" diff --git a/ts/editor/BUILD.bazel b/ts/editor/BUILD.bazel index 25cb334b28d..54af2622f2f 100644 --- a/ts/editor/BUILD.bazel +++ b/ts/editor/BUILD.bazel @@ -1,7 +1,7 @@ load("//ts/svelte:svelte.bzl", "compile_svelte", "svelte_check") -load("//ts:prettier.bzl", "prettier_test") load("//ts:eslint.bzl", "eslint_test") load("//ts:esbuild.bzl", "esbuild") +load("//ts:prettier.bzl", "prettier_test") load("//ts:compile_sass.bzl", "compile_sass") load("//ts:typescript.bzl", "typescript") @@ -21,11 +21,11 @@ compile_sass( _ts_deps = [ "//ts/components", - "//ts/editable:editable_ts", - "//ts/html-filter", - "//ts/lib", "//ts/domlib", + "//ts/lib", "//ts/sveltelib", + "//ts/editable:editable_ts", + "//ts/html-filter", "//ts/tag-editor", "@npm//@fluent", "@npm//@types/codemirror", @@ -91,12 +91,11 @@ esbuild( # Tests ################ -prettier_test() - eslint_test() +prettier_test + svelte_check( - name = "svelte_check", srcs = glob([ "**/*.ts", "**/*.svelte", diff --git a/ts/editor/EditorField.svelte b/ts/editor/EditorField.svelte index 29788cbbfa8..aa0cdf4803b 100644 --- a/ts/editor/EditorField.svelte +++ b/ts/editor/EditorField.svelte @@ -3,7 +3,7 @@ Copyright: Ankitects Pty Ltd and contributors License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html --> {#each buttons as button, index} -
    +
    {@html button}
    {/each} diff --git a/ts/editor/editor-toolbar/EditorToolbar.svelte b/ts/editor/editor-toolbar/EditorToolbar.svelte index e015e2f1571..a498e952307 100644 --- a/ts/editor/editor-toolbar/EditorToolbar.svelte +++ b/ts/editor/editor-toolbar/EditorToolbar.svelte @@ -9,11 +9,11 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import type { SurroundFormat } from "../../domlib/surround"; import type { DefaultSlotInterface } from "../../sveltelib/dynamic-slotting"; - export function updateActiveButtons(event: Event) { + export function updateActiveButtons(event: Event): void { updateAllState(event); } - export function clearActiveButtons() { + export function clearActiveButtons(): void { resetAllState(false); } diff --git a/ts/editor/editor-toolbar/InlineButtons.svelte b/ts/editor/editor-toolbar/InlineButtons.svelte index ba8625f4bbb..a777974c627 100644 --- a/ts/editor/editor-toolbar/InlineButtons.svelte +++ b/ts/editor/editor-toolbar/InlineButtons.svelte @@ -17,8 +17,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html export let api = {}; - let textColor: string = "black"; - let highlightColor: string = "black"; + let textColor = "black"; + let highlightColor = "black"; export function setColorButtons([textClr, highlightClr]: [string, string]): void { textColor = textClr; highlightColor = highlightClr; diff --git a/ts/editor/editor-toolbar/LatexButton.svelte b/ts/editor/editor-toolbar/LatexButton.svelte index ffd535dc1da..fd09f62b8cd 100644 --- a/ts/editor/editor-toolbar/LatexButton.svelte +++ b/ts/editor/editor-toolbar/LatexButton.svelte @@ -70,14 +70,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html } - - + + {@html functionIcon} diff --git a/ts/editor/editor-toolbar/RemoveFormatButton.svelte b/ts/editor/editor-toolbar/RemoveFormatButton.svelte index 8998b60f813..875c35b249c 100644 --- a/ts/editor/editor-toolbar/RemoveFormatButton.svelte +++ b/ts/editor/editor-toolbar/RemoveFormatButton.svelte @@ -10,8 +10,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import IconButton from "../../components/IconButton.svelte"; import Shortcut from "../../components/Shortcut.svelte"; import WithDropdown from "../../components/WithDropdown.svelte"; - import type { SurroundFormat } from "../../domlib/surround"; - import type { MatchType } from "../../domlib/surround"; + import type { SurroundFormat, MatchType } from "../../domlib/surround"; import * as tr from "../../lib/ftl"; import { altPressed } from "../../lib/keys"; import { getPlatformString } from "../../lib/shortcuts"; @@ -20,8 +19,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import { Surrounder } from "../surround"; import type { RemoveFormat } from "./EditorToolbar.svelte"; import { context as editorToolbarContext } from "./EditorToolbar.svelte"; - import { eraserIcon } from "./icons"; - import { arrowIcon } from "./icons"; + import { eraserIcon, arrowIcon } from "./icons"; const { focusedInput } = noteEditorContext.get(); const surrounder = Surrounder.make(); diff --git a/ts/editor/editor-toolbar/SubscriptButton.svelte b/ts/editor/editor-toolbar/SubscriptButton.svelte index 5fdb113b4bf..c34d20360d4 100644 --- a/ts/editor/editor-toolbar/SubscriptButton.svelte +++ b/ts/editor/editor-toolbar/SubscriptButton.svelte @@ -34,8 +34,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html -
    +
    diff --git a/ts/editor/image-overlay/FloatButtons.svelte b/ts/editor/image-overlay/FloatButtons.svelte index 570be110184..061003e1df0 100644 --- a/ts/editor/image-overlay/FloatButtons.svelte +++ b/ts/editor/image-overlay/FloatButtons.svelte @@ -3,8 +3,7 @@ Copyright: Ankitects Pty Ltd and contributors License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html --> diff --git a/ts/import-csv/Tags.svelte b/ts/import-csv/Tags.svelte index 721b96dbfa3..ad2ee89a128 100644 --- a/ts/import-csv/Tags.svelte +++ b/ts/import-csv/Tags.svelte @@ -23,7 +23,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html (globalTags = detail.tags)} - keyCombination={"Control+T"} + keyCombination="Control+T" /> diff --git a/ts/licenses.json b/ts/licenses.json index 80797feb848..057b076c37e 100644 --- a/ts/licenses.json +++ b/ts/licenses.json @@ -206,12 +206,6 @@ "licenseFile": "node_modules/acorn-jsx/LICENSE" }, "acorn@7.4.1": { - "licenses": "MIT", - "repository": "https://github.com/acornjs/acorn", - "path": "node_modules/@eslint/eslintrc/node_modules/acorn", - "licenseFile": "node_modules/@eslint/eslintrc/node_modules/acorn/LICENSE" - }, - "acorn@8.7.0": { "licenses": "MIT", "repository": "https://github.com/acornjs/acorn", "path": "node_modules/acorn", @@ -823,13 +817,6 @@ "path": "node_modules/eslint-plugin-simple-import-sort", "licenseFile": "node_modules/eslint-plugin-simple-import-sort/LICENSE" }, - "eslint-plugin-svelte3@3.4.1": { - "licenses": "MIT", - "repository": "https://github.com/sveltejs/eslint-plugin-svelte3", - "publisher": "Conduitry", - "path": "node_modules/eslint-plugin-svelte3", - "licenseFile": "node_modules/eslint-plugin-svelte3/LICENSE" - }, "eslint-scope@5.1.1": { "licenses": "BSD-2-Clause", "repository": "https://github.com/eslint/eslint-scope", @@ -840,16 +827,16 @@ "licenses": "MIT", "repository": "https://github.com/mysticatea/eslint-utils", "publisher": "Toru Nagashima", - "path": "node_modules/eslint-utils", - "licenseFile": "node_modules/eslint-utils/LICENSE" + "path": "node_modules/eslint/node_modules/eslint-utils", + "licenseFile": "node_modules/eslint/node_modules/eslint-utils/LICENSE" }, "eslint-visitor-keys@1.3.0": { "licenses": "Apache-2.0", "repository": "https://github.com/eslint/eslint-visitor-keys", "publisher": "Toru Nagashima", "url": "https://github.com/mysticatea", - "path": "node_modules/eslint-utils/node_modules/eslint-visitor-keys", - "licenseFile": "node_modules/eslint-utils/node_modules/eslint-visitor-keys/LICENSE" + "path": "node_modules/@eslint/eslintrc/node_modules/eslint-visitor-keys", + "licenseFile": "node_modules/@eslint/eslintrc/node_modules/eslint-visitor-keys/LICENSE" }, "eslint-visitor-keys@2.1.0": { "licenses": "Apache-2.0", @@ -1817,13 +1804,6 @@ "path": "node_modules/supports-preserve-symlinks-flag", "licenseFile": "node_modules/supports-preserve-symlinks-flag/LICENSE" }, - "svelte@3.49.0": { - "licenses": "MIT", - "repository": "https://github.com/sveltejs/svelte", - "publisher": "Rich Harris", - "path": "node_modules/svelte", - "licenseFile": "node_modules/svelte/LICENSE.md" - }, "table@6.8.0": { "licenses": "BSD-3-Clause", "repository": "https://github.com/gajus/table", @@ -1934,4 +1914,3 @@ "licenseFile": "node_modules/yallist/LICENSE" } } - diff --git a/ts/prettier.bzl b/ts/prettier.bzl index 26d2e8bea6c..7eb6c00ece0 100644 --- a/ts/prettier.bzl +++ b/ts/prettier.bzl @@ -16,11 +16,11 @@ def prettier_test(name = "format_check", srcs = None, exclude = [], **kwargs): name = name, args = [ "--config", - "$(location //:.prettierrc)", + "$(location //:.prettierrc.js)", "--check", ] + [native.package_name() + "/" + f for f in srcs], data = [ - "//:.prettierrc", + "//:.prettierrc.js", "@npm//prettier-plugin-svelte", ] + srcs, **kwargs @@ -29,7 +29,7 @@ def prettier_test(name = "format_check", srcs = None, exclude = [], **kwargs): def prettier(name = "format", **kwargs): native.sh_binary( name = name, - srcs = ["format.sh"], + srcs = ["//ts:format.sh"], args = ["$(location @nodejs//:node_bin)"], data = ["@nodejs//:node_bin"], ) diff --git a/ts/reviewer/index.ts b/ts/reviewer/index.ts index e857df809e0..b912dab478c 100644 --- a/ts/reviewer/index.ts +++ b/ts/reviewer/index.ts @@ -7,17 +7,16 @@ import "css-browser-selector/css_browser_selector.min"; -export { default as $, default as jQuery } from "jquery/dist/jquery"; - +import { bridgeCommand } from "../lib/bridgecommand"; import { mutateNextCardStates } from "./answering"; +import { maybePreloadExternalCss } from "./css"; +import { allImagesLoaded, preloadAnswerImages } from "./images"; + +export { default as $, default as jQuery } from "jquery/dist/jquery"; globalThis.anki = globalThis.anki || {}; globalThis.anki.mutateNextCardStates = mutateNextCardStates; -import { bridgeCommand } from "../lib/bridgecommand"; -import { maybePreloadExternalCss } from "./css"; -import { allImagesLoaded, preloadAnswerImages } from "./images"; - declare const MathJax: any; type Callback = () => void | Promise; diff --git a/ts/sveltelib/dynamic-slotting.ts b/ts/sveltelib/dynamic-slotting.ts index f0bfb7f5d3f..d0015a493ff 100644 --- a/ts/sveltelib/dynamic-slotting.ts +++ b/ts/sveltelib/dynamic-slotting.ts @@ -4,13 +4,13 @@ import type { SvelteComponent } from "svelte"; import type { Readable, Writable } from "svelte/store"; import { writable } from "svelte/store"; -import type { Identifier } from "../lib/children-access"; -import type { ChildrenAccess } from "../lib/children-access"; +import type { ChildrenAccess, Identifier } from "../lib/children-access"; import childrenAccess from "../lib/children-access"; import { nodeIsElement } from "../lib/dom"; import type { Callback } from "../lib/helpers"; import { removeItem } from "../lib/helpers"; import { promiseWithResolver } from "../lib/promise"; +import contextProperty from "./context-property"; export interface DynamicSvelteComponent { component: typeof SvelteComponent; @@ -291,8 +291,6 @@ export function defaultInterface({ }; } -import contextProperty from "./context-property"; - const key = Symbol("dynamicSlotting"); const [defaultSlotHostContext, setSlotHostContext] = contextProperty>(key); diff --git a/ts/tag-editor/BUILD.bazel b/ts/tag-editor/BUILD.bazel index c88efa63016..7ef89730c49 100644 --- a/ts/tag-editor/BUILD.bazel +++ b/ts/tag-editor/BUILD.bazel @@ -32,7 +32,6 @@ prettier_test() eslint_test() svelte_check( - name = "svelte_check", srcs = glob([ "**/*.ts", "**/*.svelte", diff --git a/ts/tag-editor/Tag.svelte b/ts/tag-editor/Tag.svelte index acf66d4468a..82b885a1327 100644 --- a/ts/tag-editor/Tag.svelte +++ b/ts/tag-editor/Tag.svelte @@ -7,7 +7,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import { pageTheme } from "../sveltelib/theme"; - let className: string = ""; + let className = ""; export { className as class }; export let tooltip: string | undefined = undefined; @@ -15,7 +15,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html const dispatch = createEventDispatcher(); - let flashing: boolean = false; + let flashing = false; export function flash(): void { flashing = true; diff --git a/ts/tag-editor/TagDeleteBadge.svelte b/ts/tag-editor/TagDeleteBadge.svelte index 15dcd69e209..01c872e2e89 100644 --- a/ts/tag-editor/TagDeleteBadge.svelte +++ b/ts/tag-editor/TagDeleteBadge.svelte @@ -6,7 +6,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import Badge from "../components/Badge.svelte"; import { deleteIcon } from "./icons"; - let className: string = ""; + let className = ""; export { className as class }; diff --git a/ts/tag-editor/TagEditMode.svelte b/ts/tag-editor/TagEditMode.svelte index 49159e439aa..a54619db1c9 100644 --- a/ts/tag-editor/TagEditMode.svelte +++ b/ts/tag-editor/TagEditMode.svelte @@ -9,7 +9,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import TagWithTooltip from "./TagWithTooltip.svelte"; export let name: string; - let className: string = ""; + let className = ""; export { className as class }; export let tooltip: string; diff --git a/ts/tag-editor/TagEditor.svelte b/ts/tag-editor/TagEditor.svelte index ea5156fd1c8..224bbbc3a86 100644 --- a/ts/tag-editor/TagEditor.svelte +++ b/ts/tag-editor/TagEditor.svelte @@ -23,7 +23,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import WithAutocomplete from "./WithAutocomplete.svelte"; export let tags: Writable; - export let keyCombination: string = "Control+Shift+T"; + export let keyCombination = "Control+Shift+T"; let tagTypes: TagType[]; function tagsToTagTypes(tags: string[]): void { @@ -52,7 +52,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html let activeInput: HTMLInputElement; let autocomplete: any; - let autocompleteDisabled: boolean = false; + let autocompleteDisabled = false; async function fetchSuggestions(input: string): Promise { const { tags } = await tagsService.completeTag( diff --git a/ts/tag-editor/TagInput.svelte b/ts/tag-editor/TagInput.svelte index e388e2bf68c..cac346615e1 100644 --- a/ts/tag-editor/TagInput.svelte +++ b/ts/tag-editor/TagInput.svelte @@ -14,7 +14,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html } from "./tags"; export let id: string | undefined = undefined; - let className: string = ""; + let className = ""; export { className as class }; export let name: string; @@ -114,7 +114,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html event.preventDefault(); } - async function onDelimiter(event: Event, single: boolean = false): Promise { + async function onDelimiter(event: Event, single = false): Promise { const positionStart = input.selectionStart!; const positionEnd = input.selectionEnd!; diff --git a/ts/tag-editor/TagWithTooltip.svelte b/ts/tag-editor/TagWithTooltip.svelte index a4a1f17bda2..3cdead96e27 100644 --- a/ts/tag-editor/TagWithTooltip.svelte +++ b/ts/tag-editor/TagWithTooltip.svelte @@ -12,7 +12,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import { delimChar } from "./tags"; export let name: string; - let className: string = ""; + let className = ""; export { className as class }; export let tooltip: string; diff --git a/ts/tag-editor/WithAutocomplete.svelte b/ts/tag-editor/WithAutocomplete.svelte index e71aba8262a..0a6db7a78e5 100644 --- a/ts/tag-editor/WithAutocomplete.svelte +++ b/ts/tag-editor/WithAutocomplete.svelte @@ -24,7 +24,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html }); let selected: number | null = null; - let active: boolean = false; + let active = false; const dispatch = createEventDispatcher<{ update: void; @@ -124,13 +124,16 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html } - - + + diff --git a/ts/tag-editor/tag-options-button/TagsSelectedButton.svelte b/ts/tag-editor/tag-options-button/TagsSelectedButton.svelte index 4ae80c8a2da..140ddecca5e 100644 --- a/ts/tag-editor/tag-options-button/TagsSelectedButton.svelte +++ b/ts/tag-editor/tag-options-button/TagsSelectedButton.svelte @@ -21,13 +21,11 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html const removeShortcut = "Backspace"; - +
    {@html dotsIcon} diff --git a/yarn.lock b/yarn.lock index 948a07178e5..f1bee839bb2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2255,6 +2255,11 @@ escodegen@^2.0.0: optionalDependencies: source-map "~0.6.1" +eslint-config-prettier@^8.5.0: + version "8.5.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz#5a81680ec934beca02c7b1a61cf8ca34b66feab1" + integrity sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q== + eslint-import-resolver-node@^0.3.6: version "0.3.6" resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.6.tgz#4048b958395da89668252001dbd9eca6b83bacbd" @@ -2309,10 +2314,19 @@ eslint-plugin-simple-import-sort@^7.0.0: resolved "https://registry.yarnpkg.com/eslint-plugin-simple-import-sort/-/eslint-plugin-simple-import-sort-7.0.0.tgz#a1dad262f46d2184a90095a60c66fef74727f0f8" integrity sha512-U3vEDB5zhYPNfxT5TYR7u01dboFZp+HNpnGhkDB2g/2E4wZ/g1Q9Ton8UwCLfRV9yAKyYqDh62oHOamvkFxsvw== -eslint-plugin-svelte3@^3.4.0: - version "3.4.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-svelte3/-/eslint-plugin-svelte3-3.4.1.tgz#3618700333c8f8f12e28aec93bf18440d44a61fd" - integrity sha512-7p59WG8qV8L6wLdl4d/c3mdjkgVglQCdv5XOTk/iNPBKXuuV+Q0eFP5Wa6iJd/G2M1qR3BkLPEzaANOqKAZczw== +eslint-plugin-svelte@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-svelte/-/eslint-plugin-svelte-2.2.0.tgz#fe7376245af002681aad38a9ba266391acab6723" + integrity sha512-V7LwA2lEzGqQ1/Cor3uZS/dL3ff6kdHX44TNYViXyHifIEsFiN2TJWdnH+n6NewjCQ93KVI4cWeZI0Pl7ET/hA== + dependencies: + debug "^4.3.1" + eslint-utils "^3.0.0" + known-css-properties "^0.25.0" + postcss "^8.4.5" + postcss-load-config "^3.1.4" + postcss-safe-parser "^6.0.0" + sourcemap-codec "^1.4.8" + svelte-eslint-parser "^0.16.0" eslint-scope@^5.1.1: version "5.1.1" @@ -2322,6 +2336,14 @@ eslint-scope@^5.1.1: esrecurse "^4.3.0" estraverse "^4.1.1" +eslint-scope@^7.0.0: + version "7.1.1" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-7.1.1.tgz#fff34894c2f65e5226d3041ac480b4513a163642" + integrity sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw== + dependencies: + esrecurse "^4.3.0" + estraverse "^5.2.0" + eslint-utils@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-2.1.0.tgz#d2de5e03424e707dc10c74068ddedae708741b27" @@ -2346,7 +2368,7 @@ eslint-visitor-keys@^2.0.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz#f65328259305927392c938ed44eb0a5c9b2bd303" integrity sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw== -eslint-visitor-keys@^3.3.0: +eslint-visitor-keys@^3.0.0, eslint-visitor-keys@^3.3.0: version "3.3.0" resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz#f6480fa6b1f30efe2d1968aa8ac745b862469826" integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA== @@ -3576,6 +3598,11 @@ kleur@^3.0.3: resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e" integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w== +known-css-properties@^0.25.0: + version "0.25.0" + resolved "https://registry.yarnpkg.com/known-css-properties/-/known-css-properties-0.25.0.tgz#6ebc4d4b412f602e5cfbeb4086bd544e34c0a776" + integrity sha512-b0/9J1O9Jcyik1GC6KC42hJ41jKwdO/Mq8Mdo5sYN+IuRTXs2YFHZC3kZSx6ueusqa95x3wLYe/ytKjbAfGixA== + leven@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/leven/-/leven-3.1.0.tgz#77891de834064cccba82ae7842bb6b14a13ed7f2" @@ -3613,6 +3640,11 @@ license-checker-rseidelsohn@^2.1.1: spdx-satisfies "^5.0.1" treeify "^1.1.0" +lilconfig@^2.0.5: + version "2.0.6" + resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-2.0.6.tgz#32a384558bd58af3d4c6e077dd1ad1d397bc69d4" + integrity sha512-9JROoBW7pobfsx+Sq2JsASvCo6Pfo6WWoUW79HuB1BCoBXD4PLWJPqDF6fNj67pqBYTbAHkE57M1kS/+L1neOg== + lines-and-columns@^1.1.6: version "1.2.4" resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632" @@ -3827,6 +3859,11 @@ ms@^2.1.1: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== +nanoid@^3.3.4: + version "3.3.4" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.4.tgz#730b67e3cd09e2deacf03c027c81c9d9dbc5e8ab" + integrity sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw== + natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" @@ -4132,6 +4169,28 @@ pkg-dir@^4.2.0: dependencies: find-up "^4.0.0" +postcss-load-config@^3.1.4: + version "3.1.4" + resolved "https://registry.yarnpkg.com/postcss-load-config/-/postcss-load-config-3.1.4.tgz#1ab2571faf84bb078877e1d07905eabe9ebda855" + integrity sha512-6DiM4E7v4coTE4uzA8U//WhtPwyhiim3eyjEMFCnUpzbrkK9wJHgKDT2mR+HbtSrd/NubVaYTOpSpjUl8NQeRg== + dependencies: + lilconfig "^2.0.5" + yaml "^1.10.2" + +postcss-safe-parser@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/postcss-safe-parser/-/postcss-safe-parser-6.0.0.tgz#bb4c29894171a94bc5c996b9a30317ef402adaa1" + integrity sha512-FARHN8pwH+WiS2OPCxJI8FuRJpTVnn6ZNFiqAM2aeW2LwTHWWmWgIyKC6cUo0L8aeKiF/14MNvnpls6R2PBeMQ== + +postcss@^8.4.5: + version "8.4.14" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.14.tgz#ee9274d5622b4858c1007a74d76e42e56fd21caf" + integrity sha512-E398TUmfAYFPBSdzgeieK2Y1+1cpdxJx8yXbK/m57nRhKSmk1GB2tO4lbLBtlkfPQTDKfe4Xqv1ASWPpayPEig== + dependencies: + nanoid "^3.3.4" + picocolors "^1.0.0" + source-map-js "^1.0.2" + prelude-ls@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" @@ -4492,6 +4551,11 @@ sorcery@^0.10.0: sander "^0.5.0" sourcemap-codec "^1.3.0" +source-map-js@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.0.2.tgz#adbc361d9c62df380125e7f161f71c826f1e490c" + integrity sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw== + source-map-support@0.5.9: version "0.5.9" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.9.tgz#41bc953b2534267ea2d605bccfa7bfa3111ced5f" @@ -4705,6 +4769,15 @@ svelte-check@^2.2.6: svelte-preprocess "^4.0.0" typescript "*" +svelte-eslint-parser@^0.16.0: + version "0.16.4" + resolved "https://registry.yarnpkg.com/svelte-eslint-parser/-/svelte-eslint-parser-0.16.4.tgz#7bdfdc9de82f89fa5f47fbc909f8cb4ea078ba25" + integrity sha512-hKTQxH0jiFBnvdAaNcYFScxLNqJf9+tzMDr4ojdjfVrc7OORwkK+eMNuyazhCMc2UD7Ikv+3gGrWiaCeYd5dAQ== + dependencies: + eslint-scope "^7.0.0" + eslint-visitor-keys "^3.0.0" + espree "^9.0.0" + svelte-preprocess@^4.0.0, svelte-preprocess@^4.6.9: version "4.10.4" resolved "https://registry.yarnpkg.com/svelte-preprocess/-/svelte-preprocess-4.10.4.tgz#308a410266bfc55b4e608da8d552b63580141260" @@ -5083,6 +5156,11 @@ yallist@^4.0.0: resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== +yaml@^1.10.2: + version "1.10.2" + resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b" + integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg== + yargs-parser@^21.0.0: version "21.0.1" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.0.1.tgz#0267f286c877a4f0f728fceb6f8a3e4cb95c6e35"