From 6f0680197dd9818f8a31f020f79978d146a57b34 Mon Sep 17 00:00:00 2001 From: Adriaan van Rossum <1079135+adriaanvanrossum@users.noreply.github.com> Date: Thu, 29 May 2025 18:07:39 +0200 Subject: [PATCH 1/4] Run browserstack not every time, and add linting --- .eslintrc.js | 18 ++++++++++++++++ .github/workflows/testing.yml | 40 +++++++++++++++++++++++++---------- package.json | 1 + src/auto-events.js | 4 +++- 4 files changed, 51 insertions(+), 12 deletions(-) create mode 100644 .eslintrc.js diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..87ea188 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,18 @@ +module.exports = { + env: { + browser: true, + commonjs: true, + es6: true, + node: true, + }, + extends: "eslint:recommended", + ignorePatterns: ["dist/"], + globals: { + Atomics: "readonly", + SharedArrayBuffer: "readonly", + }, + parserOptions: { + ecmaVersion: 2018, + }, + rules: {}, +}; diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index ecf3031..7398f8c 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -5,10 +5,37 @@ on: types: [opened, synchronize] push: branches: - - master - main + workflow_dispatch: jobs: + prettier: + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' + + strategy: + matrix: + node-version: [22.16] + + steps: + - uses: actions/checkout@v4 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + + - name: Run npm ci + run: npm ci + + - name: Run npm prettier + continue-on-error: true + run: | + ./node_modules/.bin/prettier --check . || echo "::warning::Prettier found formatting issues. Fix it locally by running './node_modules/.bin/prettier --write .'" + + - name: Run ESLint + run: ./node_modules/.bin/eslint --ext .js . + unit-tests: runs-on: ubuntu-latest @@ -39,6 +66,7 @@ jobs: browserstack: runs-on: ubuntu-latest needs: unit-tests + if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' strategy: matrix: @@ -60,16 +88,6 @@ jobs: - uses: actions/checkout@v4 - - name: Prettier Action on PR - uses: creyD/prettier_action@v4.5 - with: - dry: true - prettier_options: "--write {**/*,*}.{js,hbs,html,json,md,yml,css,scss} !.github/workflows/**/* !dist/**/*" - commit_message: "Run prettier via GitHub Action" - file_pattern: "." - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4 with: diff --git a/package.json b/package.json index 2809e6a..d2b3294 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "playground": "./playground.sh", "watch": "node_modules/.bin/nodemon compile.js --ignore dist", "build": "node compile.js", + "lint": "./node_modules/.bin/eslint --ext .js .", "pretest": "npm run build -- testing", "test": "node -r dotenv/config ./test/index.js", "posttest": "npm run build", diff --git a/src/auto-events.js b/src/auto-events.js index af554a9..a61a614 100644 --- a/src/auto-events.js +++ b/src/auto-events.js @@ -73,7 +73,7 @@ if (typeof optionsLink === "undefined") log("options object not found, please specify", "warn"); - window.saAutomatedLink = function saAutomatedLink(element, type) { + var saAutomatedLink = function saAutomatedLink(element, type) { try { if (!element) return log("no element found"); var sent = false; @@ -146,6 +146,8 @@ } }; + window.saAutomatedLink = saAutomatedLink; + function collectLink(link, onclick) { var collect = false; From b721ad0b386da84fdfe1c457083685ee816af1f7 Mon Sep 17 00:00:00 2001 From: Adriaan van Rossum <1079135+adriaanvanrossum@users.noreply.github.com> Date: Thu, 29 May 2025 18:09:13 +0200 Subject: [PATCH 2/4] Run browserstack not every time, for real --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 7398f8c..0633467 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -66,7 +66,7 @@ jobs: browserstack: runs-on: ubuntu-latest needs: unit-tests - if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' + if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch' strategy: matrix: From 495be42448eb05799f531f5ebad33414f80e4e71 Mon Sep 17 00:00:00 2001 From: Adriaan van Rossum <1079135+adriaanvanrossum@users.noreply.github.com> Date: Thu, 29 May 2025 18:10:15 +0200 Subject: [PATCH 3/4] Require prettier for brwoserstack too --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 0633467..f63fddd 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -65,7 +65,7 @@ jobs: browserstack: runs-on: ubuntu-latest - needs: unit-tests + needs: [unit-tests, prettier] if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch' strategy: From 6bb5c0d0df21957d4f94a9454d6348a629db0735 Mon Sep 17 00:00:00 2001 From: Adriaan van Rossum <1079135+adriaanvanrossum@users.noreply.github.com> Date: Thu, 29 May 2025 18:11:26 +0200 Subject: [PATCH 4/4] Rename prettier to linting --- .github/workflows/testing.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index f63fddd..256291e 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -9,7 +9,7 @@ on: workflow_dispatch: jobs: - prettier: + linting: runs-on: ubuntu-latest if: github.event_name == 'pull_request' @@ -65,7 +65,7 @@ jobs: browserstack: runs-on: ubuntu-latest - needs: [unit-tests, prettier] + needs: [unit-tests, linting] if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch' strategy: