Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ jobs:

- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
- name: Install web-ext
run: npm install --global web-ext
- name: Install the dependencies
run: npm ci
- name: Display web-ext version
run: web-ext --version
run: npx web-ext --version

- name: Build with web-ext
run: web-ext build
run: npm run build

- name: Upload Firefox artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,21 @@ jobs:

- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
- name: Install the dependencies
run: npm ci

# eslint
- name: Lint the scripts
run: npm run lint

# web-ext
- name: Install web-ext
run: npm install --global web-ext
- name: Display web-ext version
run: web-ext --version
run: npx web-ext --version
# Firefox ignores Chrome's "service_worker" key and web-ext lint warns
# about it: BACKGROUND_SERVICE_WORKER_IGNORED. Strip it before linting
- name: Drop Chrome-only service_worker key for Firefox lint
run: |
jq 'del(.background.service_worker)' manifest.json > manifest.tmp
mv manifest.tmp manifest.json
- name: Lint the webextension
run: web-ext lint --warnings-as-errors
run: npm run lint:webext -- --warnings-as-errors
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
web-ext-artifacts/
1 change: 1 addition & 0 deletions .web-ext-config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export default {
ignoreFiles: [
'eslint.config.js',
'package-lock.json',
'package.json',
'tests',
Expand Down
22 changes: 22 additions & 0 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ request question: instead of *"which files does this PR change?"*, it tells you
- [Authentication](#authentication)
- [Forges](#forges)
- [Internationalization](#internationalization)
- [Development](#development)
- [Install](#install)
- [Troubleshooting](#troubleshooting)

Expand Down Expand Up @@ -86,6 +87,10 @@ On open, the popup:
├── static/
│ ├── icon-*.png # toolbar / store icons
│ └── icon.svg # source icon
├── tests/ # test suite (node --test), one file per module
├── package.json # npm scripts + dev dependencies (ESLint, web-ext)
├── eslint.config.js # ESLint flat config
├── .web-ext-config.mjs # web-ext config: files to keep out of the package
└── .github/ # CI workflows (lint, test, build) + dependabot
```

Expand Down Expand Up @@ -220,6 +225,23 @@ If you add a translatable string:
- add the string to `_locales/template.json`
- update `_locales/en/messages.json` with a description and a translation

## Development

The dev tools (ESLint, web-ext) are npm dev dependencies; install them once
with `npm ci`. Then:

- `npm test` — run the test suite (`npm run test:coverage` adds coverage)
- `npm run lint` — lint the scripts with ESLint
- `npm run lint:webext` — validate the extension with `web-ext lint`. It
always warns that Firefox ignores the Chrome-only
`background.service_worker` manifest key; the CI lint workflow strips that
key first and escalates any other warning to an error
- `npm run build` — package the extension into `web-ext-artifacts/`
(the development files listed in `.web-ext-config.mjs` stay out)

The CI workflows run the same scripts: lint and test on every push, build on
the main branch and tags.

## Install
### Firefox

Expand Down
2 changes: 1 addition & 1 deletion background.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ function handleUpdated(tabId, changeInfo, tabInfo) {
}
}

async function handleRemoved(tabId, removeInfo) {
async function handleRemoved(tabId) {
// forget the closed tab's result
try {
await clearTabResult(tabId)
Expand Down
18 changes: 18 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import js from "@eslint/js"
import globals from "globals"

export default [
js.configs.recommended,
{
// extension code runs in the browser; tests run under Node
languageOptions: {
globals: globals.browser,
},
},
{
files: ["tests/**"],
languageOptions: {
globals: globals.nodeBuiltin,
},
},
]
Loading