Skip to content

Commit

Permalink
🚀 4.2.1, #269
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinTail authored Jul 6, 2024
2 parents f323c97 + 7f8694a commit ddf42f6
Show file tree
Hide file tree
Showing 14 changed files with 1,216 additions and 2,154 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## Version 4

### 4.2.1

- Technical update:
- Dependencies reduced by half;
- Upgraded testing framework;
- Removed a redundant statement.

### 4.2.0

- Supporting OctoPrint 1.10 and Python 3.12.
Expand Down
32 changes: 0 additions & 32 deletions ui/.eslintrc.json

This file was deleted.

8 changes: 4 additions & 4 deletions ui/bindings.spec.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { readFileSync } from "node:fs";
import { JSDOM } from "jsdom";
import { Window } from "happy-dom";
import { describe, test, expect } from "vitest";

describe("Knockout bindings", () => {
const html = readFileSync(
const document = new Window().document;
document.body.innerHTML = readFileSync(
"../octoprint_octorelay/templates/octorelay_settings.jinja2",
"utf-8",
);
const document = JSDOM.fragment(html);
const usingContexts = [
"settings.plugins.octorelay.r{{n}}",
"settings.plugins.octorelay",
"r{{n}}",
"rules.{{event}}",
];
const settingRegex = /([\w\{}]+).*$/;
const settingRegex = /([\w{}]+).*$/;
const relaySettings = [
"active",
"relay_pin",
Expand Down
46 changes: 46 additions & 0 deletions ui/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import globals from "globals";
import jsPlugin from "@eslint/js";
import tsPlugin from "typescript-eslint";
import prettierOverrides from "eslint-config-prettier";
import prettierRules from "eslint-plugin-prettier/recommended";
import unicornPlugin from "eslint-plugin-unicorn";
import importPlugin from "eslint-plugin-import";

export default [
{
languageOptions: {
globals: { ...globals.browser, ...globals.node, ...globals.jquery },
},
plugins: {
unicorn: unicornPlugin,
import: importPlugin,
},
settings: {
// "import-x" plugin installed as "import", in order to suppress the warning from the typescript resolver
// @link https://github.com/import-js/eslint-import-resolver-typescript/issues/293
"import-x/resolver": { typescript: true, node: true },
},
},
jsPlugin.configs.recommended,
...tsPlugin.configs.recommended,
prettierOverrides,
prettierRules,
// Things to turn off globally
{ ignores: ["coverage/", "styles/"] },
// Things to turn on globally
{
rules: {
"import/named": "error",
"import/export": "error",
"import/no-duplicates": "warn",
"unicorn/prefer-node-protocol": "error",
},
},
// For the sources
{
files: ["model/*.ts", "helpers/*.ts"],
rules: {
"import/no-extraneous-dependencies": "error",
},
},
];
2 changes: 1 addition & 1 deletion ui/helpers/countdown.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from "vitest";

describe("Countdown helpers", () => {
const setIntervalMock = vi.fn<[() => void, number], void>(
const setIntervalMock = vi.fn<(handler: () => void, delay: number) => void>(
() => "mockedInterval",
);
const clearIntervalMock = vi.fn();
Expand Down
2 changes: 1 addition & 1 deletion ui/helpers/hints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const showHints = ({
hints.filter(({ relay }) => hasUpcomingTask(relay)).length > 1;
hints.sort(compareDeadlines);
let title = "";
let content: string[] = [];
const content: string[] = [];
let target: JQuery | undefined = undefined;
let originalSubject = "";
const items: PopoverItem[] = [];
Expand Down
2 changes: 1 addition & 1 deletion ui/mocks/jQuery.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { vi, Mock } from "vitest";
import { vi, type Mock } from "vitest";

export const elementMock: Record<
| "toggle"
Expand Down
7 changes: 3 additions & 4 deletions ui/model/OctoRelayModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ export const OctoRelayViewModel: OwnModel = function (
this,
[settingsViewModel, loginStateViewModel],
) {
const self = this;
self.settingsViewModel = settingsViewModel;
self.loginState = loginStateViewModel;
self.onDataUpdaterPluginMessage = makeMessageHandler(self);
this.settingsViewModel = settingsViewModel;
this.loginState = loginStateViewModel;
this.onDataUpdaterPluginMessage = makeMessageHandler(this);
};
2 changes: 1 addition & 1 deletion ui/model/messageHandler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { OwnModel, OwnProperties } from "../types/OwnModel";
import { clearMock, showMock } from "../mocks/hints";
import { toggleMock } from "../mocks/actions";
import { makeMessageHandler } from "./messageHandler";
import { describe, vi, Mock, afterEach, test, expect } from "vitest";
import { describe, vi, type Mock, afterEach, test, expect } from "vitest";

describe("makeMessageHandler()", () => {
Object.assign(global, {
Expand Down
30 changes: 16 additions & 14 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"license": "AGPL-3.0-only",
"scripts": {
"lint": "eslint ./",
"lint": "eslint",
"test": "tsc --noEmit && TZ=UTC vitest run",
"build": "yarn build:js && yarn build:styles",
"build:js": "tsup",
Expand All @@ -20,22 +20,24 @@
"devDependencies": {
"@tsconfig/node18": "^18.2.2",
"@types/jquery": "^3.5.22",
"@types/jsdom": "^21.1.3",
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"@vitest/coverage-istanbul": "^1.1.0",
"eslint": "^8.51.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^18.0.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-prettier": "^5.0.0",
"jsdom": "^23.0.1",
"@types/node": "^20.14.10",
"@vitest/coverage-istanbul": "^2.0.0-beta.13",
"eslint": "^9.4.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "https://registry.npmjs.org/eslint-plugin-import-x/-/eslint-plugin-import-x-0.5.3.tgz",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-unicorn": "^53.0.0",
"happy-dom": "^14.12.3",
"mockdate": "^3.0.5",
"prettier": "^3.0.3",
"prettier": "3.3.2",
"sass": "^1.68.0",
"tsup": "^8.0.1",
"typescript": "^5.2.2",
"vitest": "^1.1.0"
"typescript-eslint": "^8.0.0-alpha.39",
"vitest": "^2.0.0-beta.13"
},
"resolutions": {
"**/@typescript-eslint/utils": "^8.0.0-alpha.39"
}
}
2 changes: 1 addition & 1 deletion ui/types/Hints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ export interface PopoverItem {
cancelId: string;
timeTagId: string;
deadline: number;
cancel: () => JQuery.Promise<any>;
cancel: () => JQuery.Promise<unknown>;
}
2 changes: 1 addition & 1 deletion ui/types/OctoPrint.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ declare const OctoPrint: {
command: string,
payload: object,
opts?: object,
) => JQuery.Promise<any>;
) => JQuery.Promise<unknown>;
};
2 changes: 1 addition & 1 deletion ui/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default defineConfig({
enabled: true,
provider: "istanbul",
reporter: ["json", "lcov", "text", "html"],
exclude: ["mocks"],
exclude: ["mocks", "*.config.ts", "**/*.spec.ts"],
},
},
});
Loading

0 comments on commit ddf42f6

Please sign in to comment.