Phase 6: tooling (lint, format, build, CI)#9
Conversation
Расширение собиралось рукой: README показывал zip-команду с exclusions, lint/format не было. Добавлен минимальный node-based tooling без bundler (vanilla content scripts остаются как есть). - package.json: scripts lint, format, package, check. Только две devDependencies — eslint и prettier. Без bundler в этом PR; будущий PR-4 (options split) подключит esbuild сюда же. - eslint.config.js (flat config, ESLint 9): WebExtensions + browser globals; правила мягкие — no-undef, no-unused-vars (warn), без style rules (это prettier). Игнорируются tweai-mcp-server, docs, _locales. - .prettierrc.json + .prettierignore: 100col, single quotes, trailing commas all, LF endings. - tools/build.mjs: копирует runtime-файлы в dist/ исключая tweai-mcp-server, docs, dev-инфраструктуру; собирает tweai-v<version>.zip системным zip'ом (есть на macOS/Linux/CI без лишних JS-deps). - .github/workflows/checks.yml: на PR/main гонит lint + format + build, заливает zip как artifact на 14 дней. - .github/workflows/release.yml: на push тега v* собирает zip, создаёт GitHub release с auto-generated notes и прикладывает артефакт. - .gitignore: добавлены dist/, *.zip, .eslintcache. Smoke: `node tools/build.mjs` собирает 14-файловый dist/ + 77.9 KB zip (без mcp-server и docs). `node --check` зелёный на конфигах. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 52eace3036
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| files: ['**/*.js', '**/*.mjs'], | ||
| languageOptions: { | ||
| ecmaVersion: 2022, | ||
| sourceType: 'script', |
There was a problem hiding this comment.
Exclude ESLint config from script-mode linting
When npm run lint runs eslint ., this glob also matches eslint.config.js, but the matched config forces every .js file to be parsed as sourceType: 'script'. Because this file itself contains export default, the lint job fails immediately with Parsing error: 'import' and 'export' may appear only with 'sourceType: module'; exclude eslint.config.js or add a module override for it.
Useful? React with 👍 / 👎.
| - run: npm ci || npm install | ||
| - run: npm run lint | ||
| - run: npm run format |
There was a problem hiding this comment.
Format files before enforcing Prettier
I checked the new workflow by running prettier --check ., and the current tree reports 15 unformatted files including .github/dependabot.yml, .github/workflows/codeql.yml, background.js, content_script.js, and options.js. Since this PR gates every PR/main push on npm run format, the Checks workflow is red until those existing files are formatted or deliberately ignored.
Useful? React with 👍 / 👎.
| Event: 'readonly', | ||
| CustomEvent: 'readonly', | ||
| HTMLElement: 'readonly', |
There was a problem hiding this comment.
Add the browser globals used by current scripts
After the config-file parsing issue is fixed, this browser globals list still makes no-undef fail on existing runtime code: options.js uses alert and profile-scraper.js uses HTMLImageElement, but neither global is declared while no-undef is an error. Add the missing globals, or import the standard browser globals set, so the newly required lint job can pass for the current extension code.
Useful? React with 👍 / 👎.
Summary
Расширение собиралось руками — README показывал длинную zip-команду с exclusions, ни линта ни prettier. Минимальный node-based tooling без bundler. Vanilla content scripts остаются как есть; bundler (esbuild) подтянется в PR-4 (options split) когда понадобится.
Что добавлено
package.json—scripts: lint, format, package, check. Две devDeps:eslintиprettier.eslint.config.js(flat config, ESLint 9) — WebExtensions + browser globals, мягкие правила (no-undef, no-unused-vars warn). Игнорируютсяtweai-mcp-server/,docs/,_locales/..prettierrc.json+.prettierignore— 100col, single quotes, trailing commas all, LF.tools/build.mjs— копирует runtime-файлы вdist/(без mcp-server, docs), собираетtweai-v<version>.zipчерез системныйzip..github/workflows/checks.yml— на PR/main: lint + format + build, заливает zip как artifact (14 дней)..github/workflows/release.yml— на push тегаv*: build →gh release createс auto-generated notes + zip..gitignore—dist/,*.zip,.eslintcache.Smoke
Локально проверено:
node tools/build.mjsсобирает 14-файловыйdist/+ 77.9 KB zip.node --checkзелёный на всех конфигах.Что НЕ в этом PR
Test plan
npm install && npm run lint— отрабатывает (предупреждения OK)npm run packageсоздаётtweai-v1.8.1.zipкоторый грузится в Chrome unpacked без warnings🤖 Generated with Claude Code