diff --git a/.eslintrc.cjs b/.eslintrc.cjs index f403dca..5bb87a1 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -3,14 +3,8 @@ module.exports = { env: { browser: true, es6: true, - 'vitest-globals/env': true, }, - extends: [ - 'standard', - 'plugin:vitest-globals/recommended', - 'plugin:svelte/recommended', - 'prettier', - ], + extends: ['standard', 'plugin:svelte/recommended', 'prettier'], plugins: ['svelte', 'simple-import-sort', 'json-files'], rules: { 'simple-import-sort/imports': 'error', @@ -51,6 +45,6 @@ module.exports = { ecmaVersion: 2022, sourceType: 'module', }, - globals: { $state: 'readonly', $props: 'readonly' }, + globals: { afterEach: 'readonly', $state: 'readonly', $props: 'readonly' }, ignorePatterns: ['!/.*'], } diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7b7ca01..9dbf325 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,9 +17,8 @@ jobs: main: # ignore all-contributors PRs if: ${{ !contains(github.head_ref, 'all-contributors') }} - name: Node ${{ matrix.node }}, Svelte ${{ matrix.svelte }}, ${{ matrix.test-runner }} + name: Node ${{ matrix.node }}, Svelte ${{ matrix.svelte }}, ${{ matrix.check }} runs-on: ubuntu-latest - continue-on-error: ${{ matrix.experimental }} # enable OIDC for codecov uploads permissions: @@ -30,21 +29,17 @@ jobs: matrix: node: ['16', '18', '20'] svelte: ['3', '4'] - test-runner: ['vitest:jsdom', 'vitest:happy-dom', 'jest'] - experimental: [false] + check: ['test:vitest:jsdom', 'test:vitest:happy-dom', 'test:jest'] include: - - node: '20' - svelte: 'next' - test-runner: 'vitest:jsdom' - experimental: true - - node: '20' - svelte: 'next' - test-runner: 'vitest:happy-dom' - experimental: true - - node: '20' - svelte: 'next' - test-runner: 'jest' - experimental: true + # We only need to lint once, so do it on latest Node and Svelte + - { node: '20', svelte: '4', check: 'lint' } + # `SvelteComponent` is not generic in Svelte 3, so type-checking only passes in >= 4 + - { node: '20', svelte: '4', check: 'types' } + - { node: '20', svelte: 'next', check: 'types' } + # Only run Svelte 5 checks on latest Node + - { node: '20', svelte: 'next', check: 'test:vitest:jsdom' } + - { node: '20', svelte: 'next', check: 'test:vitest:happy-dom' } + - { node: '20', svelte: 'next', check: 'test:jest' } steps: - name: ⬇️ Checkout repo @@ -60,15 +55,11 @@ jobs: npm install --no-package-lock npm install --no-save svelte@${{ matrix.svelte }} - - name: ▶️ Run tests - run: npm run test:${{ matrix.test-runner }} - - - name: ▶️ Run type-checks - # NOTE: `SvelteComponent` is not generic in Svelte v3, so type-checking will not pass - if: ${{ matrix.node == '20' && matrix.svelte != '3' && matrix.test-runner == 'vitest:jsdom' }} - run: npm run types + - name: ▶️ Run ${{ matrix.check }} + run: npm run ${{ matrix.check }} - name: ⬆️ Upload coverage report + if: ${{ startsWith(matrix.check, 'test:') }} uses: codecov/codecov-action@v4 with: use_oidc: true diff --git a/package.json b/package.json index c4924f5..15fcd34 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ "!__tests__" ], "scripts": { + "all": "npm-run-all contributors:generate toc format types build test:vitest:* test:jest", "toc": "doctoc README.md", "lint": "prettier . --check && eslint .", "lint:delta": "npm-run-all -p prettier:delta eslint:delta", @@ -62,7 +63,7 @@ "format:delta": "npm-run-all format:prettier:delta format:eslint:delta", "format:prettier:delta": "prettier --write `./scripts/changed-files`", "format:eslint:delta": "eslint --fix `./scripts/changed-files`", - "setup": "npm install && npm run validate", + "setup": "npm install && npm run all", "test": "vitest run --coverage", "test:watch": "vitest", "test:vitest:jsdom": "vitest run --coverage --environment jsdom", @@ -96,34 +97,33 @@ "@sveltejs/vite-plugin-svelte": "^3.1.1", "@testing-library/jest-dom": "^6.3.0", "@testing-library/user-event": "^14.5.2", - "@typescript-eslint/eslint-plugin": "7.15.0", - "@typescript-eslint/parser": "7.15.0", - "@vitest/coverage-v8": "^1.5.2", + "@typescript-eslint/eslint-plugin": "^7.16.0", + "@typescript-eslint/parser": "^7.16.0", + "@vitest/coverage-v8": "^2.0.2", "all-contributors-cli": "^6.26.1", "doctoc": "^2.2.1", - "eslint": "8.57.0", - "eslint-config-prettier": "9.1.0", - "eslint-config-standard": "17.1.0", - "eslint-plugin-import": "2.29.1", + "eslint": "^8.57.0", + "eslint-config-prettier": "^9.1.0", + "eslint-config-standard": "^17.1.0", + "eslint-plugin-import": "^2.29.1", "eslint-plugin-json-files": "^4.1.0", - "eslint-plugin-n": "16.6.2", - "eslint-plugin-promise": "6.4.0", - "eslint-plugin-simple-import-sort": "12.1.0", - "eslint-plugin-svelte": "2.41.0", - "eslint-plugin-vitest-globals": "1.5.0", + "eslint-plugin-n": "^16.6.2", + "eslint-plugin-promise": "^6.4.0", + "eslint-plugin-simple-import-sort": "^12.1.1", + "eslint-plugin-svelte": "^2.42.0", "expect-type": "^0.19.0", - "happy-dom": "^14.7.1", + "happy-dom": "^14.12.3", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", "jsdom": "^24.0.0", "npm-run-all": "^4.1.5", - "prettier": "3.3.2", - "prettier-plugin-svelte": "3.2.5", + "prettier": "^3.3.3", + "prettier-plugin-svelte": "^3.2.5", "svelte": "^3 || ^4 || ^5 || ^5.0.0-next.0", - "svelte-check": "^3.6.3", + "svelte-check": "^3.8.4", "svelte-jester": "^5.0.0", - "typescript": "^5.3.3", - "vite": "^5.1.1", - "vitest": "^1.5.2" + "typescript": "^5.5.3", + "vite": "^5.3.3", + "vitest": "^2.0.2" } }