diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..4d01a2c --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,40 @@ +module.exports = { + env: { + browser: true, + es2021: true, + }, + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'prettier', + ], + overrides: [ + { + env: { + node: true, + }, + files: ['.eslintrc.{js,cjs}'], + parserOptions: { + sourceType: 'script', + }, + }, + ], + parser: '@typescript-eslint/parser', + parserOptions: { + ecmaVersion: 'latest', + sourceType: 'module', + }, + plugins: ['@typescript-eslint', 'prettier'], + rules: { + 'prettier/prettier': 'error', + '@typescript-eslint/ban-ts-comment': [ + 'error', + { + 'ts-expect-error': 'allow-with-description', + 'ts-ignore': true, + 'ts-nocheck': true, + 'ts-check': false, + }, + ], + }, +}; diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index aef3a1b..a0d5573 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build Package +name: Build & Test on: push: @@ -34,3 +34,40 @@ jobs: - name: Build run: sh build.sh + + - uses: pnpm/action-setup@v2 + name: Install pnpm + with: + version: latest + run_install: false + + - name: Get pnpm store directory + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Use Node.js LTS + uses: actions/setup-node@v3 + with: + node-version: 18 + registry-url: https://npm.pkg.github.com + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install + + - name: Lint + run: pnpm lint + + - name: Install playwright browser + run: pnpm playwright install firefox + + - name: Run playwright test + run: pnpm test -- --forbid-only diff --git a/.gitignore b/.gitignore index b988642..857b71f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ wasm-pack.log node_modules/ data/ +test-results/ diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..57415eb --- /dev/null +++ b/.prettierrc @@ -0,0 +1,6 @@ +{ + "singleQuote": true, + "trailingComma": "es5", + "tabWidth": 2, + "arrowParens": "avoid" +} \ No newline at end of file diff --git a/build.sh b/build.sh index 5f76aec..62676b5 100644 --- a/build.sh +++ b/build.sh @@ -26,5 +26,5 @@ echo "$(jq --argjson FILES $(ls pkg | jq -R -s -c 'split("\n")[:-1]') \ .exports.".".import.default |= "./esm/intl_segmenter_polyfill_rs.mjs" | .exports.".".require.types |= "./esm/intl_segmenter_polyfill_rs.d.ts" | .exports.".".require.default |= "./cjs/intl_segmenter_polyfill_rs.js" | - .sideEffects[0] |= "./esm/intl_segmenter_polyfill_rs.js"' \ + .sideEffects[0] |= "./esm/intl_segmenter_polyfill_rs.mjs"' \ pkg/package.json)" > pkg/package.json diff --git a/index.html b/example/index.html similarity index 81% rename from index.html rename to example/index.html index 64e1045..d135f0c 100644 --- a/index.html +++ b/example/index.html @@ -6,6 +6,6 @@
- + -