diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0d4b99f2b..c904f389c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -60,6 +60,9 @@ jobs: wasm: name: Wasm runs-on: ubuntu-latest + defaults: + run: + working-directory: ./playground steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 @@ -74,11 +77,13 @@ jobs: path: ./playground/node_modules key: ${{ hashFiles('./playground/package.json') }} - name: Build playground - run: cd ./playground && make build + run: make build - name: Lint playground - run: cd ./playground && npm run lint + run: npm run lint - name: Run tests for wasm - run: cd ./playground && npm test + run: npm test + - name: Check eslint config + run: npx tsc --checkJs --noEmit --module nodenext --strict eslint.config.mjs lint: name: Lint runs-on: ubuntu-latest diff --git a/playground/.eslintrc.json b/playground/.eslintrc.json deleted file mode 100644 index f8df5346b..000000000 --- a/playground/.eslintrc.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "root": true, - "env": { - "browser": true, - "es2021": true, - "mocha": true - }, - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended" - ], - "plugins": [ - "@typescript-eslint" - ], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": 12, - "project": "./tsconfig.json" - }, - "globals": { - "CodeMirror": "readonly", - "isMobile": "readonly", - "Go": "readonly" - }, - "rules": { - "indent": [ - "error", - 4 - ], - "linebreak-style": [ - "error", - "unix" - ], - "quotes": [ - "error", - "single" - ], - "semi": [ - "error", - "always" - ], - "eqeqeq": [ - "error", - "always" - ], - "no-constant-condition": [ - "error", - { "checkLoops": false } - ] - } -} diff --git a/playground/eslint.config.mjs b/playground/eslint.config.mjs new file mode 100644 index 000000000..0f81bd152 --- /dev/null +++ b/playground/eslint.config.mjs @@ -0,0 +1,37 @@ +// @ts-check + +import eslint from '@eslint/js'; +import ts from 'typescript-eslint'; + +export default ts.config( + eslint.configs.recommended, + ...ts.configs.recommendedTypeChecked, + { + languageOptions: { + parserOptions: { + project: true, + tsconfigRootDir: import.meta.dirname, + }, + }, + }, + { + files: ['index.ts', 'test.ts'], + rules: { + indent: ['error', 4], + quotes: ['error', 'single'], + 'linebreak-style': ['error', 'unix'], + semi: ['error', 'always'], + eqeqeq: ['error', 'always'], + 'no-constant-condition': ['error', { checkLoops: false }], + '@typescript-eslint/no-unsafe-member-access': 'off', + '@typescript-eslint/no-unsafe-argument': 'off', + '@typescript-eslint/no-unsafe-assignment': 'off', + }, + }, + { + files: ['test.ts'], + rules: { + '@typescript-eslint/unbound-method': 'off', // For checking `window.runActionlint` + }, + } +); diff --git a/playground/index.ts b/playground/index.ts index 25a3b0c55..6e14a0511 100644 --- a/playground/index.ts +++ b/playground/index.ts @@ -264,6 +264,7 @@ jobs: } }); + // eslint-disable-next-line @typescript-eslint/no-misused-promises checkUrlButton.addEventListener('click', async e => { e.preventDefault(); const input = checkUrlInput.value; diff --git a/playground/package.json b/playground/package.json index 3c1bab831..24ace600a 100644 --- a/playground/package.json +++ b/playground/package.json @@ -32,15 +32,15 @@ "devDependencies": { "@peculiar/webcrypto": "^1.4.5", "@types/codemirror": "^5.60.15", + "@types/eslint__js": "^8.42.3", "@types/node": "^20.11.24", "@types/pako": "^2.0.3", - "@typescript-eslint/eslint-plugin": "^7.1.1", - "@typescript-eslint/parser": "^7.1.1", "eslint": "^8.57.0", "http-server": "^14.1.1", "prettier": "^3.2.5", "stylelint": "^16.2.1", "stylelint-config-standard": "^36.0.0", - "typescript": "^5.3.3" + "typescript": "^5.3.3", + "typescript-eslint": "^7.1.1" } } diff --git a/playground/test.ts b/playground/test.ts index 20b67f8cb..8d37a8f5d 100644 --- a/playground/test.ts +++ b/playground/test.ts @@ -64,6 +64,9 @@ jobs: const go = new Go(); const bin = await fs.readFile('./main.wasm'); const result = await WebAssembly.instantiate(bin, go.importObject); + + // Do not `await` this method call since it will never be settled + // eslint-disable-next-line @typescript-eslint/no-floating-promises go.run(result.instance); });