From dfdd4ede703b4eb747c1a0de2bb7ade8e1925153 Mon Sep 17 00:00:00 2001 From: Anton Date: Fri, 29 Sep 2023 13:42:53 +0300 Subject: [PATCH] Prettier fixes (#23) * Ensure prettier follows .editorconfig * Fix prettier plugin bug (https://github.com/prettier/prettier/issues/15079) --- .eslintrc.cjs | 56 ++++++------- .github/ISSUE_TEMPLATE/bug_report.md | 4 +- .github/ISSUE_TEMPLATE/feature_request.md | 4 +- .prettierrc | 8 -- package.json | 4 +- playwright.config.ts | 10 +-- prettier.config.js | 11 +++ src/index.test.ts | 6 +- src/lib/classes/automaton.test.ts | 79 ++++++++++++------- src/lib/classes/automaton.ts | 42 +++++----- src/lib/classes/automaton/backend.ts | 2 +- src/lib/classes/automaton/component.ts | 34 ++++---- .../classes/automaton/component_instance.ts | 2 +- src/lib/classes/automaton/declaration.ts | 8 +- src/lib/classes/automaton/declaration_type.ts | 4 +- src/lib/classes/automaton/edge.ts | 42 +++++----- src/lib/classes/automaton/invariant.ts | 2 +- src/lib/classes/automaton/location.ts | 29 ++++--- src/lib/classes/automaton/location_type.ts | 10 +-- src/lib/classes/automaton/nickname.ts | 2 +- src/lib/classes/automaton/operator.ts | 6 +- src/lib/classes/automaton/operator_type.ts | 10 +-- src/lib/classes/automaton/property.ts | 9 ++- src/lib/classes/automaton/property_type.ts | 10 +-- src/lib/classes/automaton/query.ts | 27 +++++-- src/lib/classes/automaton/raw.ts | 12 +-- src/lib/classes/automaton/raw/component.ts | 4 +- src/lib/classes/automaton/status.ts | 4 +- src/lib/classes/automaton/system.ts | 30 +++---- src/lib/classes/automaton/urgency.ts | 8 +- src/lib/classes/draw.ts | 4 +- src/routes/+page.svelte | 17 ++-- svelte.config.js | 8 +- tests/test.ts | 6 +- vite.config.ts | 8 +- 35 files changed, 292 insertions(+), 230 deletions(-) delete mode 100644 .prettierrc create mode 100644 prettier.config.js diff --git a/.eslintrc.cjs b/.eslintrc.cjs index ebc19589..04fd1924 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,30 +1,30 @@ module.exports = { - root: true, - extends: [ - 'eslint:recommended', - 'plugin:@typescript-eslint/recommended', - 'plugin:svelte/recommended', - 'prettier' - ], - parser: '@typescript-eslint/parser', - plugins: ['@typescript-eslint'], - parserOptions: { - sourceType: 'module', - ecmaVersion: 2020, - extraFileExtensions: ['.svelte'] - }, - env: { - browser: true, - es2017: true, - node: true - }, - overrides: [ - { - files: ['*.svelte'], - parser: 'svelte-eslint-parser', - parserOptions: { - parser: '@typescript-eslint/parser' - } - } - ] + root: true, + extends: [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "plugin:svelte/recommended", + "prettier", + ], + parser: "@typescript-eslint/parser", + plugins: ["@typescript-eslint"], + parserOptions: { + sourceType: "module", + ecmaVersion: 2020, + extraFileExtensions: [".svelte"], + }, + env: { + browser: true, + es2017: true, + node: true, + }, + overrides: [ + { + files: ["*.svelte"], + parser: "svelte-eslint-parser", + parserOptions: { + parser: "@typescript-eslint/parser", + }, + }, + ], }; diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 20e7f9b0..39441c92 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,9 +1,9 @@ --- name: Bug about: File a bug report -title: '[BUG] ' +title: "[BUG] <title>" labels: bug -assignees: '' +assignees: "" --- <!-- diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 97499f3c..dae615a0 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,9 +1,9 @@ --- name: Feature about: Suggest a new feature -title: '[Feature] <title>' +title: "[Feature] <title>" labels: enhancement -assignees: '' +assignees: "" --- <!-- diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index 95730232..00000000 --- a/.prettierrc +++ /dev/null @@ -1,8 +0,0 @@ -{ - "useTabs": true, - "singleQuote": true, - "trailingComma": "none", - "printWidth": 100, - "plugins": ["prettier-plugin-svelte"], - "overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }] -} diff --git a/package.json b/package.json index 659b0309..e9520d6a 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,8 @@ "test": "yarn test:integration && yarn test:unit", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", - "lint": "prettier --check . && eslint .", - "format": "prettier --write .", + "lint": "prettier --plugin prettier-plugin-svelte --check . && eslint .", + "format": "prettier --plugin prettier-plugin-svelte --write .", "test:install": "playwright install --with-deps", "test:integration": "playwright test", "test:unit": "vitest" diff --git a/playwright.config.ts b/playwright.config.ts index 54646be1..f26edaad 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -1,12 +1,12 @@ -import type { PlaywrightTestConfig } from '@playwright/test'; +import type { PlaywrightTestConfig } from "@playwright/test"; const config: PlaywrightTestConfig = { webServer: { - command: 'yarn build && yarn preview', - port: 4173 + command: "yarn build && yarn preview", + port: 4173, }, - testDir: 'tests', - testMatch: /(.+\.)?(test|spec)\.[jt]s/ + testDir: "tests", + testMatch: /(.+\.)?(test|spec)\.[jt]s/, }; export default config; diff --git a/prettier.config.js b/prettier.config.js new file mode 100644 index 00000000..8989c0ed --- /dev/null +++ b/prettier.config.js @@ -0,0 +1,11 @@ +export default { + plugins: ["prettier-plugin-svelte"], + overrides: [ + { + files: "*.svelte", + options: { + parser: "svelte", + }, + }, + ], +}; diff --git a/src/index.test.ts b/src/index.test.ts index e07cbbd7..808401ed 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -1,7 +1,7 @@ -import { describe, it, expect } from 'vitest'; +import { describe, it, expect } from "vitest"; -describe('sum test', () => { - it('adds 1 + 2 to equal 3', () => { +describe("sum test", () => { + it("adds 1 + 2 to equal 3", () => { expect(1 + 2).toBe(3); }); }); diff --git a/src/lib/classes/automaton.test.ts b/src/lib/classes/automaton.test.ts index da97e8c2..89245f21 100644 --- a/src/lib/classes/automaton.test.ts +++ b/src/lib/classes/automaton.test.ts @@ -1,16 +1,23 @@ -import { describe, it, expect } from 'vitest'; -import { Location, Edge, Component, System, Queries, Declaration } from './automaton'; +import { describe, it, expect } from "vitest"; +import { + Location, + Edge, + Component, + System, + Queries, + Declaration, +} from "./automaton"; import type { RawLocation, RawEdge, RawComponent, RawSystem, RawQuery, - RawDeclaration -} from './automaton'; + RawDeclaration, +} from "./automaton"; -describe('Location test', () => { - it('serializes into location', () => { +describe("Location test", () => { + it("serializes into location", () => { const location = Location.deserializeRaw(locationData); const raw: RawLocation = JSON.parse(locationData); expect(location.id).toBe(raw.id); @@ -27,7 +34,7 @@ describe('Location test', () => { expect(location.invariant.position.y).toBe(raw.invariantY); }); - it('serializes and deserializes to the same object', () => { + it("serializes and deserializes to the same object", () => { const o = Location.deserializeRaw(locationData); const rawObj = o.toRaw(); const rawParse = JSON.parse(locationData); @@ -35,8 +42,8 @@ describe('Location test', () => { }); }); -describe('Edge test', () => { - it('serializes into an Edge', () => { +describe("Edge test", () => { + it("serializes into an Edge", () => { const edge = Edge.deserializeRaw(edgeData); const data: RawEdge = JSON.parse(edgeData); expect(edge.id).toBe(data.id); @@ -57,7 +64,7 @@ describe('Edge test', () => { expect(edge.nails[0].property.position.y).toBe(data.nails[0].propertyY); }); - it('serializes and deserializes to the same object', () => { + it("serializes and deserializes to the same object", () => { const o = Edge.deserializeRaw(edgeData); const rawObj = o.toRaw(); const rawParse = JSON.parse(edgeData); @@ -65,8 +72,8 @@ describe('Edge test', () => { }); }); -describe('Component test', () => { - it('serializes into a Component', () => { +describe("Component test", () => { + it("serializes into a Component", () => { const component = Component.deserializeRaw(componentData); const data: RawComponent = JSON.parse(componentData); expect(component.name).toBe(data.name); @@ -79,10 +86,12 @@ describe('Component test', () => { expect(component.dimensions.width).toBe(data.width); expect(component.dimensions.height).toBe(data.height); expect(component.color).toBe(data.color); - expect(component.includeInPeriodicCheck).toBe(data.includeInPeriodicCheck); + expect(component.includeInPeriodicCheck).toBe( + data.includeInPeriodicCheck, + ); }); - it('serializes and deserializes to the same object', () => { + it("serializes and deserializes to the same object", () => { const o = Component.deserializeRaw(componentData); const rawObj = o.toRaw(); const rawParse = JSON.parse(componentData); @@ -90,8 +99,8 @@ describe('Component test', () => { }); }); -describe('System test', () => { - it('serializes into a system', () => { +describe("System test", () => { + it("serializes into a system", () => { const system = System.deserializeRaw(systemData); const data: RawSystem = JSON.parse(systemData); expect(system.name).toBe(data.name); @@ -100,22 +109,34 @@ describe('System test', () => { expect(system.position.y).toBe(data.y); expect(system.color).toBe(data.color); expect(system.systemRootX).toBe(data.systemRootX); - expect(system.componentInstances.length).toBe(data.componentInstances.length); - expect(system.componentInstances[0].name).toBe(data.componentInstances[0].componentName); - expect(system.componentInstances[0].id).toBe(data.componentInstances[0].id); - expect(system.componentInstances[0].position.x).toBe(data.componentInstances[0].x); - expect(system.componentInstances[0].position.y).toBe(data.componentInstances[0].y); + expect(system.componentInstances.length).toBe( + data.componentInstances.length, + ); + expect(system.componentInstances[0].name).toBe( + data.componentInstances[0].componentName, + ); + expect(system.componentInstances[0].id).toBe( + data.componentInstances[0].id, + ); + expect(system.componentInstances[0].position.x).toBe( + data.componentInstances[0].x, + ); + expect(system.componentInstances[0].position.y).toBe( + data.componentInstances[0].y, + ); expect(system.operators.length).toBe(data.operators.length); expect(system.operators[0].id).toBe(data.operators[0].id); expect(system.operators[0].position.x).toBe(data.operators[0].x); expect(system.operators[0].position.y).toBe(data.operators[0].y); - expect(system.operators[0].type.toLowerCase()).toBe(data.operators[0].type); + expect(system.operators[0].type.toLowerCase()).toBe( + data.operators[0].type, + ); expect(system.edges.length).toBe(data.edges.length); expect(system.edges[0].parent).toBe(data.edges[0].parent); expect(system.edges[0].child).toBe(data.edges[0].child); }); - it('serializes and deserializes to the same object', () => { + it("serializes and deserializes to the same object", () => { const o = System.deserializeRaw(systemData); const rawObj = o.toRaw(); const rawParse = JSON.parse(systemData); @@ -123,8 +144,8 @@ describe('System test', () => { }); }); -describe('Queries test', () => { - it('serializes into a query array', () => { +describe("Queries test", () => { + it("serializes into a query array", () => { const queries = Queries.deserializeRaw(queriesData); const data: RawQuery[] = JSON.parse(queriesData); @@ -137,7 +158,7 @@ describe('Queries test', () => { } }); - it('serializes and deserializes to the same object', () => { + it("serializes and deserializes to the same object", () => { const o = Queries.deserializeRaw(queriesData); const rawObj = o.toRaw(); const rawParse = JSON.parse(queriesData); @@ -145,8 +166,8 @@ describe('Queries test', () => { }); }); -describe('Declarations test', () => { - it('serializes into a declaration', () => { +describe("Declarations test", () => { + it("serializes into a declaration", () => { const queries = Declaration.deserializeRaw(declarationData); const data: RawDeclaration = JSON.parse(declarationData); @@ -154,7 +175,7 @@ describe('Declarations test', () => { expect(queries.type).toStrictEqual(data.name); }); - it('serializes and deserializes to the same object', () => { + it("serializes and deserializes to the same object", () => { const o = Declaration.deserializeRaw(declarationData); const rawObj = o.toRaw(); const rawParse = JSON.parse(declarationData); diff --git a/src/lib/classes/automaton.ts b/src/lib/classes/automaton.ts index bd162e1f..b64c0462 100644 --- a/src/lib/classes/automaton.ts +++ b/src/lib/classes/automaton.ts @@ -9,30 +9,30 @@ export type { FromRaw, ToRaw, SerializeRaw, - DeserializeRaw -} from './automaton/raw'; + DeserializeRaw, +} from "./automaton/raw"; // Enums -export { Backend } from './automaton/backend'; -export { DeclarationType } from './automaton/declaration_type'; -export { Status } from './automaton/status'; -export { LocationType } from './automaton/location_type'; -export { OperatorType } from './automaton/operator_type'; -export { PropertyType } from './automaton/property_type'; -export { Urgency } from './automaton/urgency'; +export { Backend } from "./automaton/backend"; +export { DeclarationType } from "./automaton/declaration_type"; +export { Status } from "./automaton/status"; +export { LocationType } from "./automaton/location_type"; +export { OperatorType } from "./automaton/operator_type"; +export { PropertyType } from "./automaton/property_type"; +export { Urgency } from "./automaton/urgency"; // Minor Classes -export { Invariant } from './automaton/invariant'; -export { Nickname } from './automaton/nickname'; -export { Operator } from './automaton/operator'; -export { Property } from './automaton/property'; -export { SystemEdge } from './automaton/system_edge'; -export { ComponentInstance } from './automaton/component_instance'; +export { Invariant } from "./automaton/invariant"; +export { Nickname } from "./automaton/nickname"; +export { Operator } from "./automaton/operator"; +export { Property } from "./automaton/property"; +export { SystemEdge } from "./automaton/system_edge"; +export { ComponentInstance } from "./automaton/component_instance"; // Major Classes -export { Declaration } from './automaton/declaration'; -export { Component } from './automaton/component'; -export { Edge } from './automaton/edge'; -export { Location } from './automaton/location'; -export { Query, Queries } from './automaton/query'; -export { System } from './automaton/system'; +export { Declaration } from "./automaton/declaration"; +export { Component } from "./automaton/component"; +export { Edge } from "./automaton/edge"; +export { Location } from "./automaton/location"; +export { Query, Queries } from "./automaton/query"; +export { System } from "./automaton/system"; diff --git a/src/lib/classes/automaton/backend.ts b/src/lib/classes/automaton/backend.ts index c6fbf2ee..6a8cfaf8 100644 --- a/src/lib/classes/automaton/backend.ts +++ b/src/lib/classes/automaton/backend.ts @@ -5,5 +5,5 @@ * */ export enum Backend { J_ECDAR = 0, - REVEAAL = 1 + REVEAAL = 1, } diff --git a/src/lib/classes/automaton/component.ts b/src/lib/classes/automaton/component.ts index 09ab3bec..63333ffa 100644 --- a/src/lib/classes/automaton/component.ts +++ b/src/lib/classes/automaton/component.ts @@ -1,7 +1,13 @@ -import { Point, Dimensions } from '$lib/classes/draw'; +import { Point, Dimensions } from "$lib/classes/draw"; -import { Edge, Location } from '../automaton'; -import type { SerializeRaw, ToRaw, FromRaw, DeserializeRaw, RawComponent } from '../automaton'; +import { Edge, Location } from "../automaton"; +import type { + SerializeRaw, + ToRaw, + FromRaw, + DeserializeRaw, + RawComponent, +} from "../automaton"; /** * # An Ecdar component @@ -11,12 +17,12 @@ export class Component implements SerializeRaw, ToRaw<RawComponent> { /** * The name of the component * */ - name: string = ''; + name: string = ""; /** * The declarations of the component ex "clock t;" * */ - declarations: string = ''; + declarations: string = ""; /** * A list of Locations in the Component @@ -31,7 +37,7 @@ export class Component implements SerializeRaw, ToRaw<RawComponent> { /** * A description of the Component * */ - description: string = ''; + description: string = ""; /** * The position of the Component @@ -46,7 +52,7 @@ export class Component implements SerializeRaw, ToRaw<RawComponent> { /** * The color of the Component * */ - color: string = '0'; + color: string = "0"; /** * Include in periodic checks @@ -55,15 +61,15 @@ export class Component implements SerializeRaw, ToRaw<RawComponent> { includeInPeriodicCheck: boolean = false; constructor( - name: string = '', - declarations: string = '', + name: string = "", + declarations: string = "", locations: Location[] = [], edges: Edge[] = [], - description: string = '', + description: string = "", position = new Point(0, 0), dimensions = new Dimensions(100, 100), - color: string = '0', - includeInPeriodicCheck: boolean = false + color: string = "0", + includeInPeriodicCheck: boolean = false, ) { this.name = name; this.declarations = declarations; @@ -92,7 +98,7 @@ export class Component implements SerializeRaw, ToRaw<RawComponent> { width: this.dimensions.width, height: this.dimensions.height, color: this.color, - includeInPeriodicCheck: this.includeInPeriodicCheck + includeInPeriodicCheck: this.includeInPeriodicCheck, }; } @@ -117,7 +123,7 @@ export class Component implements SerializeRaw, ToRaw<RawComponent> { new Point(raw.x, raw.y), new Dimensions(raw.width, raw.height), raw.color, - raw.includeInPeriodicCheck + raw.includeInPeriodicCheck, ); }; diff --git a/src/lib/classes/automaton/component_instance.ts b/src/lib/classes/automaton/component_instance.ts index d2859917..c8f1ef64 100644 --- a/src/lib/classes/automaton/component_instance.ts +++ b/src/lib/classes/automaton/component_instance.ts @@ -1,4 +1,4 @@ -import type { Point } from '$lib/classes/draw'; +import type { Point } from "$lib/classes/draw"; /** * # A Component Instance diff --git a/src/lib/classes/automaton/declaration.ts b/src/lib/classes/automaton/declaration.ts index 1c526a8a..ce1ab3ba 100644 --- a/src/lib/classes/automaton/declaration.ts +++ b/src/lib/classes/automaton/declaration.ts @@ -4,8 +4,8 @@ import { type FromRaw, type DeserializeRaw, type RawDeclaration, - DeclarationType -} from '../automaton'; + DeclarationType, +} from "../automaton"; /** * The top level declarations @@ -14,7 +14,7 @@ export class Declaration implements SerializeRaw, ToRaw<RawDeclaration> { type: DeclarationType; declarations: string; - constructor(type = DeclarationType.GLOBAL, declarations = '') { + constructor(type = DeclarationType.GLOBAL, declarations = "") { this.type = type; this.declarations = declarations; } @@ -31,7 +31,7 @@ export class Declaration implements SerializeRaw, ToRaw<RawDeclaration> { toRaw() { return { name: this.type, - declarations: this.declarations + declarations: this.declarations, }; } diff --git a/src/lib/classes/automaton/declaration_type.ts b/src/lib/classes/automaton/declaration_type.ts index e8ca7a11..4a06c31c 100644 --- a/src/lib/classes/automaton/declaration_type.ts +++ b/src/lib/classes/automaton/declaration_type.ts @@ -1,4 +1,4 @@ export enum DeclarationType { - GLOBAL = 'Global Declarations', - SYSETEM = 'System Declarations' + GLOBAL = "Global Declarations", + SYSETEM = "System Declarations", } diff --git a/src/lib/classes/automaton/edge.ts b/src/lib/classes/automaton/edge.ts index 6fa2ccb5..f9222d29 100644 --- a/src/lib/classes/automaton/edge.ts +++ b/src/lib/classes/automaton/edge.ts @@ -1,7 +1,13 @@ -import { Point } from '$lib/classes/draw'; +import { Point } from "$lib/classes/draw"; -import { Status, Property, PropertyType } from '../automaton'; -import type { SerializeRaw, ToRaw, FromRaw, DeserializeRaw, RawEdge } from '../automaton'; +import { Status, Property, PropertyType } from "../automaton"; +import type { + SerializeRaw, + ToRaw, + FromRaw, + DeserializeRaw, + RawEdge, +} from "../automaton"; /** * # An Ecdar Edge @@ -75,20 +81,20 @@ export class Edge implements SerializeRaw, ToRaw<RawEdge> { }[]; constructor( - id: string = '', - group: string = '', - sourceLocation: string = '', - targetLocation: string = '', + id: string = "", + group: string = "", + sourceLocation: string = "", + targetLocation: string = "", status: Status = Status.INPUT, - select: string = '', - guard: string = '', - update: string = '', - sync: string = '', + select: string = "", + guard: string = "", + update: string = "", + sync: string = "", isLocked: boolean = true, nails: { position: Point; property: Property; - }[] = [] + }[] = [], ) { this.id = id; this.group = group; @@ -122,12 +128,12 @@ export class Edge implements SerializeRaw, ToRaw<RawEdge> { y: c.position.y, propertyType: c.property.type, propertyX: c.property.position.x, - propertyY: c.property.position.y + propertyY: c.property.position.y, }); return res; }, - <RawEdge['nails']>[] - ) + <RawEdge["nails"]>[], + ), }; } serializeRaw() { @@ -154,10 +160,10 @@ export class Edge implements SerializeRaw, ToRaw<RawEdge> { position: new Point(nail.x, nail.y), property: new Property( nail.propertyType as PropertyType, - new Point(nail.propertyX, nail.propertyY) - ) + new Point(nail.propertyX, nail.propertyY), + ), }; - }) + }), ); }; diff --git a/src/lib/classes/automaton/invariant.ts b/src/lib/classes/automaton/invariant.ts index 8a620e69..62471805 100644 --- a/src/lib/classes/automaton/invariant.ts +++ b/src/lib/classes/automaton/invariant.ts @@ -1,4 +1,4 @@ -import type { Point } from '$lib/classes/draw'; +import type { Point } from "$lib/classes/draw"; export class Invariant { /** diff --git a/src/lib/classes/automaton/location.ts b/src/lib/classes/automaton/location.ts index 20de6562..9c7cb52e 100644 --- a/src/lib/classes/automaton/location.ts +++ b/src/lib/classes/automaton/location.ts @@ -1,6 +1,12 @@ -import { Point } from '$lib/classes/draw'; -import { Nickname, Invariant, LocationType, Urgency } from '../automaton'; -import type { SerializeRaw, ToRaw, FromRaw, DeserializeRaw, RawLocation } from '../automaton'; +import { Point } from "$lib/classes/draw"; +import { Nickname, Invariant, LocationType, Urgency } from "../automaton"; +import type { + SerializeRaw, + ToRaw, + FromRaw, + DeserializeRaw, + RawLocation, +} from "../automaton"; export class Location implements SerializeRaw, ToRaw<RawLocation> { /** @@ -39,13 +45,13 @@ export class Location implements SerializeRaw, ToRaw<RawLocation> { color: string; constructor( - id: string = '', + id: string = "", position: Point = new Point(0, 0), - nickname: Nickname = new Nickname('', new Point(0, 0)), - invariant: Invariant = new Invariant('', new Point(0, 0)), + nickname: Nickname = new Nickname("", new Point(0, 0)), + invariant: Invariant = new Invariant("", new Point(0, 0)), type: LocationType = LocationType.NORMAL, urgency: Urgency = Urgency.NORMAL, - color: string = '' + color: string = "", ) { this.id = id; this.position = position; @@ -72,7 +78,7 @@ export class Location implements SerializeRaw, ToRaw<RawLocation> { nicknameX: this.nickname.position.x, nicknameY: this.nickname.position.y, invariantX: this.invariant.position.x, - invariantY: this.invariant.position.y + invariantY: this.invariant.position.y, }; } @@ -88,10 +94,13 @@ export class Location implements SerializeRaw, ToRaw<RawLocation> { raw.id, new Point(raw.x, raw.y), new Nickname(raw.nickname, new Point(raw.nicknameX, raw.nicknameY)), - new Invariant(raw.invariant, new Point(raw.invariantX, raw.invariantY)), + new Invariant( + raw.invariant, + new Point(raw.invariantX, raw.invariantY), + ), raw.type as LocationType, raw.urgency as Urgency, - raw.color + raw.color, ); }; diff --git a/src/lib/classes/automaton/location_type.ts b/src/lib/classes/automaton/location_type.ts index 5b7db1fd..056cc3c3 100644 --- a/src/lib/classes/automaton/location_type.ts +++ b/src/lib/classes/automaton/location_type.ts @@ -11,26 +11,26 @@ export enum LocationType { * It is an initial Location * only one allowed per Component * */ - INITIAL = 'INITIAL', + INITIAL = "INITIAL", /** * No modifires * */ - NORMAL = 'NORMAL', + NORMAL = "NORMAL", /** * ????? * */ - UNIVERSAL = 'UNIVERSAL', + UNIVERSAL = "UNIVERSAL", /** * ????? * */ - INCONSISTENT = 'INCONSISTENT', + INCONSISTENT = "INCONSISTENT", /** * DO NOT USE * Reveaal will panic * */ - ANY = 'ANY' + ANY = "ANY", } diff --git a/src/lib/classes/automaton/nickname.ts b/src/lib/classes/automaton/nickname.ts index e7b156e2..e9a64d4f 100644 --- a/src/lib/classes/automaton/nickname.ts +++ b/src/lib/classes/automaton/nickname.ts @@ -1,4 +1,4 @@ -import type { Point } from '$lib/classes/draw'; +import type { Point } from "$lib/classes/draw"; /** * A user defined name for the location diff --git a/src/lib/classes/automaton/operator.ts b/src/lib/classes/automaton/operator.ts index 9f57f0fc..8a2d3f80 100644 --- a/src/lib/classes/automaton/operator.ts +++ b/src/lib/classes/automaton/operator.ts @@ -1,6 +1,6 @@ -import { Point } from '$lib/classes/draw'; +import { Point } from "$lib/classes/draw"; -import { OperatorType } from './operator_type'; +import { OperatorType } from "./operator_type"; /** * Defines an operator for a System @@ -25,7 +25,7 @@ export class Operator { constructor( id: number = 0, type: OperatorType = OperatorType.COMPOSITION, - position: Point = new Point(0, 0) + position: Point = new Point(0, 0), ) { this.id = id; this.type = type; diff --git a/src/lib/classes/automaton/operator_type.ts b/src/lib/classes/automaton/operator_type.ts index a1b52669..b056f7bb 100644 --- a/src/lib/classes/automaton/operator_type.ts +++ b/src/lib/classes/automaton/operator_type.ts @@ -2,9 +2,9 @@ * The operator types supported by Ecdar * */ export enum OperatorType { - COMPOSITION = 'COMPOSITION', - CONJUNCTION = 'CONJUNCTION', - REFINEMENT = 'REFINEMENT', - QUOTIENT = 'QUOTIENT', - SIMPLE = 'SIMPLE' + COMPOSITION = "COMPOSITION", + CONJUNCTION = "CONJUNCTION", + REFINEMENT = "REFINEMENT", + QUOTIENT = "QUOTIENT", + SIMPLE = "SIMPLE", } diff --git a/src/lib/classes/automaton/property.ts b/src/lib/classes/automaton/property.ts index 2183aaa5..40412427 100644 --- a/src/lib/classes/automaton/property.ts +++ b/src/lib/classes/automaton/property.ts @@ -1,6 +1,6 @@ -import { Point } from '$lib/classes/draw'; +import { Point } from "$lib/classes/draw"; -import { PropertyType } from './property_type'; +import { PropertyType } from "./property_type"; /** * The properties of a nail @@ -15,7 +15,10 @@ export class Property { * The position of the property * */ position: Point = new Point(0, 0); - constructor(type: PropertyType = PropertyType.NONE, position = new Point(0, 0)) { + constructor( + type: PropertyType = PropertyType.NONE, + position = new Point(0, 0), + ) { this.type = type; this.position = position; } diff --git a/src/lib/classes/automaton/property_type.ts b/src/lib/classes/automaton/property_type.ts index ccb315fa..5c8f2729 100644 --- a/src/lib/classes/automaton/property_type.ts +++ b/src/lib/classes/automaton/property_type.ts @@ -6,25 +6,25 @@ export enum PropertyType { /** * Matches no field * */ - NONE = 'NONE', + NONE = "NONE", /** * Links to the select property of an Edge * */ - SELECTION = 'SELECTION', + SELECTION = "SELECTION", /** * Links to the guard property of an Edge * */ - GUARD = 'GUARD', + GUARD = "GUARD", /** * Links to the sync property of an Edge * */ - SYNCHRONIZATION = 'SYNCHRONIZATION', + SYNCHRONIZATION = "SYNCHRONIZATION", /** * Links to the update property of an Edge * */ - UPDATE = 'UPDATE' + UPDATE = "UPDATE", } diff --git a/src/lib/classes/automaton/query.ts b/src/lib/classes/automaton/query.ts index 31981c3b..5d306cb1 100644 --- a/src/lib/classes/automaton/query.ts +++ b/src/lib/classes/automaton/query.ts @@ -1,5 +1,11 @@ -import { Backend } from '../automaton'; -import type { SerializeRaw, ToRaw, FromRaw, DeserializeRaw, RawQuery } from '../automaton'; +import { Backend } from "../automaton"; +import type { + SerializeRaw, + ToRaw, + FromRaw, + DeserializeRaw, + RawQuery, +} from "../automaton"; /** * # An Ecdar Query @@ -35,15 +41,15 @@ export class Query implements SerializeRaw, ToRaw<RawQuery> { isPeriodic: this.isPeriodic, ignoredInputs: {}, ignoredOutputs: {}, - backend: this.backend + backend: this.backend, }; } constructor( - query: string = '', - comment: string = '', + query: string = "", + comment: string = "", isPeriodic: boolean = false, - backend: Backend = Backend.REVEAAL + backend: Backend = Backend.REVEAAL, ) { this.query = query; this.comment = comment; @@ -60,7 +66,12 @@ export class Query implements SerializeRaw, ToRaw<RawQuery> { * Creates a query from a RawQuery * */ static fromRaw: FromRaw<RawQuery, Query> = (raw) => { - return new Query(raw.query, raw.comment, raw.isPeriodic, raw.backend as Backend); + return new Query( + raw.query, + raw.comment, + raw.isPeriodic, + raw.backend as Backend, + ); }; /** @@ -108,7 +119,7 @@ export class Queries implements SerializeRaw, ToRaw<RawQuery[]> { return new Queries( raw.map((rawSingle) => { return Query.fromRaw(rawSingle); - }) + }), ); }; } diff --git a/src/lib/classes/automaton/raw.ts b/src/lib/classes/automaton/raw.ts index bb2e8fc4..5b1b8965 100644 --- a/src/lib/classes/automaton/raw.ts +++ b/src/lib/classes/automaton/raw.ts @@ -1,9 +1,9 @@ -export type { RawComponent } from './raw/component'; -export type { RawDeclaration } from './raw/declaration'; -export type { RawEdge } from './raw/edge'; -export type { RawLocation } from './raw/location'; -export type { RawQuery } from './raw/query'; -export type { RawSystem } from './raw/system'; +export type { RawComponent } from "./raw/component"; +export type { RawDeclaration } from "./raw/declaration"; +export type { RawEdge } from "./raw/edge"; +export type { RawLocation } from "./raw/location"; +export type { RawQuery } from "./raw/query"; +export type { RawSystem } from "./raw/system"; export interface SerializeRaw { /** diff --git a/src/lib/classes/automaton/raw/component.ts b/src/lib/classes/automaton/raw/component.ts index 1fba2fd7..9b0a302d 100644 --- a/src/lib/classes/automaton/raw/component.ts +++ b/src/lib/classes/automaton/raw/component.ts @@ -1,5 +1,5 @@ -import type { RawLocation } from './location'; -import type { RawEdge } from './edge'; +import type { RawLocation } from "./location"; +import type { RawEdge } from "./edge"; /** * The raw Object for a Component that is used to save and communicate in JSON. diff --git a/src/lib/classes/automaton/status.ts b/src/lib/classes/automaton/status.ts index 024b38e8..3151349b 100644 --- a/src/lib/classes/automaton/status.ts +++ b/src/lib/classes/automaton/status.ts @@ -4,6 +4,6 @@ * - Output * */ export enum Status { - INPUT = 'INPUT', - OUTPUT = 'OUTPUT' + INPUT = "INPUT", + OUTPUT = "OUTPUT", } diff --git a/src/lib/classes/automaton/system.ts b/src/lib/classes/automaton/system.ts index 3cf2c13e..3b69ca97 100644 --- a/src/lib/classes/automaton/system.ts +++ b/src/lib/classes/automaton/system.ts @@ -1,13 +1,13 @@ -import { Point, Dimensions } from '$lib/classes/draw'; -import { Operator, ComponentInstance, SystemEdge } from '../automaton'; +import { Point, Dimensions } from "$lib/classes/draw"; +import { Operator, ComponentInstance, SystemEdge } from "../automaton"; import type { OperatorType, SerializeRaw, ToRaw, FromRaw, DeserializeRaw, - RawSystem -} from '../automaton'; + RawSystem, +} from "../automaton"; /** * An Ecdar System @@ -59,15 +59,15 @@ export class System implements SerializeRaw, ToRaw<RawSystem> { edges: SystemEdge[]; constructor( - name: string = '', - description: string = '', + name: string = "", + description: string = "", position: Point = new Point(0, 0), dimensions: Dimensions = new Dimensions(0, 0), - color: string = '', + color: string = "", systemRootX: number = 0, componentInstances: ComponentInstance[] = [], operators: Operator[] = [], - edges: SystemEdge[] = [] + edges: SystemEdge[] = [], ) { this.name = name; this.description = description; @@ -98,7 +98,7 @@ export class System implements SerializeRaw, ToRaw<RawSystem> { id: instance.id, componentName: instance.name, x: instance.position.x, - y: instance.position.y + y: instance.position.y, }; }), operators: this.operators.map((o) => { @@ -107,15 +107,15 @@ export class System implements SerializeRaw, ToRaw<RawSystem> { y: o.position.y, // BECAUSE OF COMPATIBILITY type: o.type.toLowerCase(), - id: o.id + id: o.id, }; }), edges: this.edges.map((e) => { return { child: e.child, - parent: e.parent + parent: e.parent, }; - }) + }), }; } @@ -138,7 +138,7 @@ export class System implements SerializeRaw, ToRaw<RawSystem> { return new ComponentInstance( instance.id, instance.componentName, - new Point(instance.x, instance.y) + new Point(instance.x, instance.y), ); }), raw.operators.map((o) => { @@ -146,12 +146,12 @@ export class System implements SerializeRaw, ToRaw<RawSystem> { o.id, /// BECAUSE OF COMPATIBILITY o.type.toUpperCase() as OperatorType, - new Point(o.x, o.y) + new Point(o.x, o.y), ); }), raw.edges.map((e) => { return new SystemEdge(e.parent, e.child); - }) + }), ); }; diff --git a/src/lib/classes/automaton/urgency.ts b/src/lib/classes/automaton/urgency.ts index 5e13ac79..e035e48b 100644 --- a/src/lib/classes/automaton/urgency.ts +++ b/src/lib/classes/automaton/urgency.ts @@ -6,20 +6,20 @@ export enum Urgency { /** * Normal TIOA rules apply * */ - NORMAL = 'NORMAL', + NORMAL = "NORMAL", /** * ???? * */ - PROHIBITED = 'PROHIBITED', + PROHIBITED = "PROHIBITED", /** * Make a move instantly no matter the timer * */ - URGENT = 'URGENT', + URGENT = "URGENT", /** * ???? * */ - COMMITTED = 'COMMITTED' + COMMITTED = "COMMITTED", } diff --git a/src/lib/classes/draw.ts b/src/lib/classes/draw.ts index ffca1112..232df822 100644 --- a/src/lib/classes/draw.ts +++ b/src/lib/classes/draw.ts @@ -1,2 +1,2 @@ -export { Point } from './draw/point'; -export { Dimensions } from './draw/dimensions'; +export { Point } from "./draw/point"; +export { Dimensions } from "./draw/dimensions"; diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 2b6d8470..a391f962 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -2,7 +2,7 @@ enum SidePanel { Left, Right, - Neither + Neither, } let currentResizablePanel: SidePanel = SidePanel.Neither; @@ -32,9 +32,9 @@ event.preventDefault(); currentResizablePanel = side; mainContainer.setPointerCapture(event.pointerId); - mainContainer.addEventListener('pointermove', resizeSidePanel); - mainContainer.addEventListener('pointerup', stopResizingSidePanel); - mainContainer.addEventListener('pointercancel', stopResizingSidePanel); + mainContainer.addEventListener("pointermove", resizeSidePanel); + mainContainer.addEventListener("pointerup", stopResizingSidePanel); + mainContainer.addEventListener("pointercancel", stopResizingSidePanel); } /** @@ -44,9 +44,12 @@ function stopResizingSidePanel(event: PointerEvent) { currentResizablePanel = SidePanel.Neither; mainContainer.releasePointerCapture(event.pointerId); - mainContainer.removeEventListener('pointermove', resizeSidePanel); - mainContainer.removeEventListener('pointerup', stopResizingSidePanel); - mainContainer.removeEventListener('pointercancel', stopResizingSidePanel); + mainContainer.removeEventListener("pointermove", resizeSidePanel); + mainContainer.removeEventListener("pointerup", stopResizingSidePanel); + mainContainer.removeEventListener( + "pointercancel", + stopResizingSidePanel, + ); } </script> diff --git a/svelte.config.js b/svelte.config.js index 849bacf4..abe2436e 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -1,7 +1,7 @@ -import { vitePreprocess } from '@sveltejs/kit/vite'; +import { vitePreprocess } from "@sveltejs/kit/vite"; // We render our app to static files because it needs to run packaged without a server -import adapter from '@sveltejs/adapter-static'; +import adapter from "@sveltejs/adapter-static"; /** @type {import('@sveltejs/kit').Config} */ const config = { @@ -11,8 +11,8 @@ const config = { kit: { // See https://kit.svelte.dev/docs/adapters for more information about adapters. - adapter: adapter() - } + adapter: adapter(), + }, }; export default config; diff --git a/tests/test.ts b/tests/test.ts index d5349656..c602428a 100644 --- a/tests/test.ts +++ b/tests/test.ts @@ -1,6 +1,6 @@ -import { expect, test } from '@playwright/test'; +import { expect, test } from "@playwright/test"; -test('page title is ecdar', async ({ page }) => { - await page.goto('/'); +test("page title is ecdar", async ({ page }) => { + await page.goto("/"); await expect(page).toHaveTitle(/Ecdar/); }); diff --git a/vite.config.ts b/vite.config.ts index 37b6a84b..08e3ed5c 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,9 +1,9 @@ -import { sveltekit } from '@sveltejs/kit/vite'; -import { defineConfig } from 'vitest/config'; +import { sveltekit } from "@sveltejs/kit/vite"; +import { defineConfig } from "vitest/config"; export default defineConfig({ plugins: [sveltekit()], test: { - include: ['src/**/*.{test,spec}.{js,ts}'] - } + include: ["src/**/*.{test,spec}.{js,ts}"], + }, });