diff --git a/.github/workflows/fmt-check.yml b/.github/workflows/fmt-check.yml new file mode 100644 index 0000000000..75d1b2ec99 --- /dev/null +++ b/.github/workflows/fmt-check.yml @@ -0,0 +1,54 @@ +# This is a basic workflow to help you get started with Actions + +name: fmt-check + +# Controls when the action will run. +on: + # Triggers the workflow on push or pull request events but only for the master branch + push: + branches-ignore: + - 'develop' + - 'develop*' + - 'archive/**' + - 'deploy/**' + paths-ignore: + - '.gitignore' + - '**.png' + - '**.jpg' + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + fmt-check: + # The type of runner that the job will run on + runs-on: ubuntu-latest + timeout-minutes: 15 + + strategy: + fail-fast: true + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + - name: Checkout + uses: actions/checkout@v4.2.2 + + - name: Set up Node.js 20.x + uses: actions/setup-node@v4.2.0 + id: setup_node_id + with: + node-version: 20 + cache: 'yarn' + cache-dependency-path: yarn.lock + + # - run: echo '${{ toJSON(steps.setup_node_id.outputs) }}' + # - if: ${{ steps.setup_node_id.outputs.cache-hit != 'true' }} + - name: Install dependencies + run: yarn + + - name: Setup + run: yarn fmt + + - name: Check if there is no file diff + run: yarn zz:check:no-diff diff --git a/.github/workflows/lint-test-type-check.yml b/.github/workflows/lint-test-type-check.yml index a9f0a7ca2e..c72e5ae3c7 100644 --- a/.github/workflows/lint-test-type-check.yml +++ b/.github/workflows/lint-test-type-check.yml @@ -37,7 +37,7 @@ jobs: fail-fast: true matrix: command: - - fmt:all + - fmt - ws:gi - type-check-eslint-configs - ws:type-check diff --git a/experimental/my-svelte-app/eslint.config.js b/experimental/my-svelte-app/eslint.config.js index e18311fa76..97e7731884 100644 --- a/experimental/my-svelte-app/eslint.config.js +++ b/experimental/my-svelte-app/eslint.config.js @@ -1,34 +1,34 @@ -import prettier from "eslint-config-prettier"; -import js from '@eslint/js'; import { includeIgnoreFile } from '@eslint/compat'; +import js from '@eslint/js'; +import prettier from 'eslint-config-prettier'; import svelte from 'eslint-plugin-svelte'; import globals from 'globals'; import { fileURLToPath } from 'node:url'; import ts from 'typescript-eslint'; -const gitignorePath = fileURLToPath(new URL("./.gitignore", import.meta.url)); +const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url)); export default ts.config( includeIgnoreFile(gitignorePath), js.configs.recommended, ...ts.configs.recommended, - ...svelte.configs["flat/recommended"], + ...svelte.configs['flat/recommended'], prettier, ...svelte.configs['flat/prettier'], { languageOptions: { - globals: { - ...globals.browser, - ...globals.node - } - } + globals: { + ...globals.browser, + ...globals.node, + }, + }, }, { - files: ["**/*.svelte"], + files: ['**/*.svelte'], languageOptions: { - parserOptions: { - parser: ts.parser - } - } - } + parserOptions: { + parser: ts.parser, + }, + }, + }, ); diff --git a/experimental/my-svelte-app/package.json b/experimental/my-svelte-app/package.json index bfcd98b918..ccae7bfd33 100644 --- a/experimental/my-svelte-app/package.json +++ b/experimental/my-svelte-app/package.json @@ -1,40 +1,40 @@ { - "name": "my-svelte-app", - "private": true, - "version": "0.0.1", - "type": "module", - "scripts": { - "dev": "vite dev", - "build": "vite build", - "preview": "vite preview", - "prepare": "svelte-kit sync || echo ''", - "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", - "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", - "format": "prettier --write .", - "lint": "prettier --check . && eslint .", - "test:unit": "vitest", - "test": "npm run test:unit -- --run" - }, - "devDependencies": { - "@eslint/compat": "^1.2.5", - "@eslint/js": "^9.18.0", - "@sveltejs/adapter-auto": "^4.0.0", - "@sveltejs/kit": "^2.16.0", - "@sveltejs/vite-plugin-svelte": "^5.0.0", - "@testing-library/jest-dom": "^6.6.3", - "@testing-library/svelte": "^5.2.4", - "eslint": "^9.18.0", - "eslint-config-prettier": "^10.0.1", - "eslint-plugin-svelte": "^2.46.1", - "globals": "^15.14.0", - "jsdom": "^25.0.1", - "prettier": "^3.4.2", - "prettier-plugin-svelte": "^3.3.3", - "svelte": "^5.0.0", - "svelte-check": "^4.0.0", - "typescript": "^5.0.0", - "typescript-eslint": "^8.20.0", - "vite": "^6.0.0", - "vitest": "^3.0.0" - } + "name": "my-svelte-app", + "version": "0.0.1", + "private": true, + "type": "module", + "scripts": { + "build": "vite build", + "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", + "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", + "dev": "vite dev", + "format": "prettier --write .", + "lint": "prettier --check . && eslint .", + "prepare": "svelte-kit sync || echo ''", + "preview": "vite preview", + "test": "npm run test:unit -- --run", + "test:unit": "vitest" + }, + "devDependencies": { + "@eslint/compat": "^1.2.5", + "@eslint/js": "^9.18.0", + "@sveltejs/adapter-auto": "^4.0.0", + "@sveltejs/kit": "^2.16.0", + "@sveltejs/vite-plugin-svelte": "^5.0.0", + "@testing-library/jest-dom": "^6.6.3", + "@testing-library/svelte": "^5.2.4", + "eslint": "^9.18.0", + "eslint-config-prettier": "^10.0.1", + "eslint-plugin-svelte": "^2.46.1", + "globals": "^15.14.0", + "jsdom": "^25.0.1", + "prettier": "^3.4.2", + "prettier-plugin-svelte": "^3.3.3", + "svelte": "^5.0.0", + "svelte-check": "^4.0.0", + "typescript": "^5.0.0", + "typescript-eslint": "^8.20.0", + "vite": "^6.0.0", + "vitest": "^3.0.0" + } } diff --git a/experimental/my-svelte-app/src/app.d.ts b/experimental/my-svelte-app/src/app.d.ts index da08e6da59..520c4217a1 100644 --- a/experimental/my-svelte-app/src/app.d.ts +++ b/experimental/my-svelte-app/src/app.d.ts @@ -1,13 +1,13 @@ // See https://svelte.dev/docs/kit/types#app.d.ts // for information about these interfaces declare global { - namespace App { - // interface Error {} - // interface Locals {} - // interface PageData {} - // interface PageState {} - // interface Platform {} - } + namespace App { + // interface Error {} + // interface Locals {} + // interface PageData {} + // interface PageState {} + // interface Platform {} + } } export {}; diff --git a/experimental/my-svelte-app/src/app.html b/experimental/my-svelte-app/src/app.html index 77a5ff52c9..84ffad1665 100644 --- a/experimental/my-svelte-app/src/app.html +++ b/experimental/my-svelte-app/src/app.html @@ -1,12 +1,12 @@ - - - - - %sveltekit.head% - - -
%sveltekit.body%
- + + + + + %sveltekit.head% + + +
%sveltekit.body%
+ diff --git a/experimental/my-svelte-app/src/demo.spec.ts b/experimental/my-svelte-app/src/demo.spec.ts index e07cbbd725..aa93426376 100644 --- a/experimental/my-svelte-app/src/demo.spec.ts +++ b/experimental/my-svelte-app/src/demo.spec.ts @@ -1,7 +1,7 @@ -import { describe, it, expect } from 'vitest'; +import { describe, expect, it } from 'vitest'; describe('sum test', () => { - it('adds 1 + 2 to equal 3', () => { - expect(1 + 2).toBe(3); - }); + it('adds 1 + 2 to equal 3', () => { + expect(1 + 2).toBe(3); + }); }); diff --git a/experimental/my-svelte-app/svelte.config.js b/experimental/my-svelte-app/svelte.config.js index 1295460d12..ff3d5f7c03 100644 --- a/experimental/my-svelte-app/svelte.config.js +++ b/experimental/my-svelte-app/svelte.config.js @@ -3,16 +3,16 @@ import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; /** @type {import('@sveltejs/kit').Config} */ const config = { - // Consult https://svelte.dev/docs/kit/integrations - // for more information about preprocessors - preprocess: vitePreprocess(), + // Consult https://svelte.dev/docs/kit/integrations + // for more information about preprocessors + preprocess: vitePreprocess(), - kit: { - // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list. - // If your environment is not supported, or you settled on a specific environment, switch out the adapter. - // See https://svelte.dev/docs/kit/adapters for more information about adapters. - adapter: adapter() - } + kit: { + // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list. + // If your environment is not supported, or you settled on a specific environment, switch out the adapter. + // See https://svelte.dev/docs/kit/adapters for more information about adapters. + adapter: adapter(), + }, }; export default config; diff --git a/experimental/my-svelte-app/tsconfig.json b/experimental/my-svelte-app/tsconfig.json index 0b2d8865f4..f4d0a0e167 100644 --- a/experimental/my-svelte-app/tsconfig.json +++ b/experimental/my-svelte-app/tsconfig.json @@ -1,19 +1,19 @@ { - "extends": "./.svelte-kit/tsconfig.json", - "compilerOptions": { - "allowJs": true, - "checkJs": true, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "resolveJsonModule": true, - "skipLibCheck": true, - "sourceMap": true, - "strict": true, - "moduleResolution": "bundler" - } - // Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias - // except $lib which is handled by https://svelte.dev/docs/kit/configuration#files - // - // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes - // from the referenced tsconfig.json - TypeScript does not merge them in + "extends": "./.svelte-kit/tsconfig.json", + "compilerOptions": { + "allowJs": true, + "checkJs": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "resolveJsonModule": true, + "skipLibCheck": true, + "sourceMap": true, + "strict": true, + "moduleResolution": "bundler" + } + // Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias + // except $lib which is handled by https://svelte.dev/docs/kit/configuration#files + // + // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes + // from the referenced tsconfig.json - TypeScript does not merge them in } diff --git a/experimental/my-svelte-app/vite.config.ts b/experimental/my-svelte-app/vite.config.ts index 53ec8936c5..0da926553d 100644 --- a/experimental/my-svelte-app/vite.config.ts +++ b/experimental/my-svelte-app/vite.config.ts @@ -1,32 +1,35 @@ -import { svelteTesting } from "@testing-library/svelte/vite"; import { sveltekit } from '@sveltejs/kit/vite'; +import { svelteTesting } from '@testing-library/svelte/vite'; import { defineConfig } from 'vite'; export default defineConfig({ - plugins: [sveltekit()], + plugins: [sveltekit()], - test: { - workspace: [{ - extends: "./vite.config.ts", - plugins: [svelteTesting()], + test: { + workspace: [ + { + extends: './vite.config.ts', + plugins: [svelteTesting()], - test: { - name: "client", - environment: "jsdom", - clearMocks: true, - include: ['src/**/*.svelte.{test,spec}.{js,ts}'], - exclude: ['src/lib/server/**'], - setupFiles: ['./vitest-setup-client.ts'] - } - }, { - extends: "./vite.config.ts", + test: { + name: 'client', + environment: 'jsdom', + clearMocks: true, + include: ['src/**/*.svelte.{test,spec}.{js,ts}'], + exclude: ['src/lib/server/**'], + setupFiles: ['./vitest-setup-client.ts'], + }, + }, + { + extends: './vite.config.ts', - test: { - name: "server", - environment: "node", - include: ['src/**/*.{test,spec}.{js,ts}'], - exclude: ['src/**/*.svelte.{test,spec}.{js,ts}'] - } - }] - } + test: { + name: 'server', + environment: 'node', + include: ['src/**/*.{test,spec}.{js,ts}'], + exclude: ['src/**/*.svelte.{test,spec}.{js,ts}'], + }, + }, + ], + }, }); diff --git a/experimental/my-svelte-app/vitest-setup-client.ts b/experimental/my-svelte-app/vitest-setup-client.ts index d2ef9ab9c9..e814f5e257 100644 --- a/experimental/my-svelte-app/vitest-setup-client.ts +++ b/experimental/my-svelte-app/vitest-setup-client.ts @@ -3,16 +3,16 @@ import { vi } from 'vitest'; // required for svelte5 + jsdom as jsdom does not support matchMedia Object.defineProperty(window, 'matchMedia', { - writable: true, - enumerable: true, - value: vi.fn().mockImplementation(query => ({ - matches: false, - media: query, - onchange: null, - addEventListener: vi.fn(), - removeEventListener: vi.fn(), - dispatchEvent: vi.fn(), - })), -}) + writable: true, + enumerable: true, + value: vi.fn().mockImplementation((query) => ({ + matches: false, + media: query, + onchange: null, + addEventListener: vi.fn(), + removeEventListener: vi.fn(), + dispatchEvent: vi.fn(), + })), +}); // add more mocks here if you need them