diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..10e7193 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,30 @@ +# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs +name: CI + +on: + push: + branches: ['main'] + pull_request: + branches: ['main'] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v7.0.0 + - name: Install Node.js + uses: actions/setup-node@v6.4.0 + with: + node-version: 22.20.0 + - name: Install Dependencies + run: npm install --no-fund + - parallel: + - name: Typecheck + run: npm run test:types + - name: Lint + run: npm run lint + - name: Unit Test + run: npm run test:unit + - name: Build + run: npm run build diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..7282254 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,68 @@ +import { defineConfig } from 'eslint/config'; +import globals from 'globals'; +import js from '@eslint/js'; +import tseslint from 'typescript-eslint'; + +export default defineConfig([ + tseslint.configs.recommended, + { + extends: [js.configs.recommended, ...tseslint.configs.recommended], + files: ['src/server/**/*.{ts,tsx,mjs,cjs,js}'], + languageOptions: { + ecmaVersion: 2023, + globals: globals.node, + parserOptions: { + project: ['./tools/tsconfig.server.json'], + tsconfigRootDir: import.meta.dirname, + }, + }, + }, + { + extends: [js.configs.recommended, ...tseslint.configs.recommended], + files: ['src/shared/**/*.{ts,tsx,mjs,cjs,js}'], + languageOptions: { + ecmaVersion: 2023, + globals: globals.browser, + parserOptions: { + project: ['./tools/tsconfig.shared.json'], + tsconfigRootDir: import.meta.dirname, + }, + }, + }, + { + extends: [js.configs.recommended, ...tseslint.configs.recommended], + files: ['src/client/**/*.{ts,tsx}'], + ignores: ['src/server/**/*.{ts,tsx}'], + languageOptions: { + ecmaVersion: 2023, + globals: globals.browser, + parserOptions: { + project: ['./tools/tsconfig.client.json'], + tsconfigRootDir: import.meta.dirname, + }, + }, + }, + { + files: ['**/*.{js,mjs,cjs,ts,tsx}'], + rules: { + '@typescript-eslint/no-floating-promises': 'error', + '@typescript-eslint/no-unused-vars': ['off'], + 'no-unused-vars': ['off'], + }, + ignores: [ + '**/node_modules/**', + '**/dist/**', + '**/build/**', + 'eslint.config.js', + '**/vite.config.ts', + 'devvit.config.ts', + ], + languageOptions: { + parserOptions: { + tsconfigRootDir: import.meta.dirname, + }, + }, + plugins: { js }, + extends: ['js/recommended'], + }, +]); diff --git a/package.json b/package.json index b889b71..f20576c 100644 --- a/package.json +++ b/package.json @@ -6,13 +6,14 @@ "type": "module", "scripts": { "build": "vite build", - "deploy": "npm run type-check && npm run lint && devvit upload", + "deploy": "npm run test:types && npm run lint && devvit upload", "dev": "devvit playtest", "launch": "npm run deploy && devvit publish", "lint": "eslint 'src/**/*.{ts,tsx}'", "login": "devvit login", "prettier": "prettier --write .", - "type-check": "tsc --build" + "test:types": "tsc --build", + "test:unit": "node --experimental-strip-types --no-warnings=ExperimentalWarning --test \"src/**/*.test.ts\"" }, "engines": { "node": ">=22.12.0" @@ -30,7 +31,7 @@ "eslint": "10.8.0", "globals": "17.8.0", "prettier": "3.9.6", - "typescript": "7.0.2", + "typescript": "6.0.3", "typescript-eslint": "8.65.0", "vite": "8.1.5" }