Skip to content

Commit d263e99

Browse files
Copilotchiga0
andauthored
Fix CI failures: missing lockfile, ESLint v9 flat config migration, lint errors (#22)
* Initial plan * Add E2E tests for CI and GitHub Actions workflow - Create playwright.ci.config.ts targeting reader.chigao.site - Add E2E tests: page load, feed subscription, theme, settings - Create .github/workflows/ci.yml for automated testing on PR/push - Add test:e2e:ci script to package.json Co-authored-by: chiga0 <24784430+chiga0@users.noreply.github.com> * Address code review: replace waitForTimeout with proper assertions Co-authored-by: chiga0 <24784430+chiga0@users.noreply.github.com> * Add explicit permissions to CI workflow for security Co-authored-by: chiga0 <24784430+chiga0@users.noreply.github.com> * Add comprehensive user stories document at docs/user-stories.md Co-authored-by: chiga0 <24784430+chiga0@users.noreply.github.com> * Add AI user stories, new E2E tests for favorites/history/search/feed-mgmt/AI features - Add US-17 (AI Translation) and US-18 (AI Summarization) to user stories - Add E2E tests: favorites, history, search, feedManagement, articleReading, aiFeatures - Add search and feed-management page load tests to pageLoad.spec.ts - Update coverage matrix in user stories document - Remove waitForTimeout anti-patterns from new tests Co-authored-by: chiga0 <24784430+chiga0@users.noreply.github.com> * Fix user stories coverage markers to match actual E2E test coverage Co-authored-by: chiga0 <24784430+chiga0@users.noreply.github.com> * Refactor: extract shared helper, fix language-agnostic selectors in E2E tests Co-authored-by: chiga0 <24784430+chiga0@users.noreply.github.com> * fix: resolve CI failures - add package-lock.json, migrate ESLint to flat config, fix lint errors Root causes: 1. package-lock.json was in .gitignore, causing `npm ci` to fail 2. ESLint v9 requires flat config (eslint.config.js), but only .eslintrc.cjs existed 3. eslint-plugin-react-refresh was missing from devDependencies 4. 23 ESLint errors across src and test files Fixes: - Remove package-lock.json from .gitignore and commit the lockfile - Create eslint.config.js (flat config) for ESLint v9 compatibility - Add eslint-plugin-react-refresh to devDependencies - Fix all 23 ESLint errors: - Remove unused imports (Heart, ComponentType, useStore, vi, renderHook, act, etc.) - Remove unused variables (handleThemeChange, initialHasLight, initialIsDark, etc.) - Escape quotes in JSX (react/no-unescaped-entities) - Fix unnecessary regex escapes (no-useless-escape) - Prefix intentionally unused params with _ (catch clauses, event handlers) - Disable react/prop-types (TypeScript handles this) - Configure @typescript-eslint/no-unused-vars with _-prefix patterns - Update lint script: remove deprecated --ext flag for ESLint v9 - Update CI workflow lint command to match Co-authored-by: chiga0 <24784430+chiga0@users.noreply.github.com> * fix: resolve ReDoS vulnerability in URL validator regex Change `([-.]?[a-z0-9]+)*` to `(?:[-.][a-z0-9]+)*` to prevent exponential backtracking on malicious inputs like 'http://0' + '0'*n. Co-authored-by: chiga0 <24784430+chiga0@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: chiga0 <24784430+chiga0@users.noreply.github.com>
1 parent f5af555 commit d263e99

34 files changed

Lines changed: 18815 additions & 27 deletions

‎.github/workflows/ci.yml‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
unit-tests:
14+
name: Unit & Integration Tests
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: '20'
22+
23+
- name: Install dependencies
24+
run: npm ci
25+
26+
- name: Type check
27+
run: npx tsc --noEmit
28+
29+
- name: Lint
30+
run: npx eslint src tests
31+
32+
- name: Run unit & integration tests
33+
run: npx vitest --run
34+
35+
e2e-tests:
36+
name: E2E Tests
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- uses: actions/setup-node@v4
42+
with:
43+
node-version: '20'
44+
45+
- name: Install dependencies
46+
run: npm ci
47+
48+
- name: Install Playwright browsers
49+
run: npx playwright install --with-deps chromium
50+
51+
- name: Run E2E tests against live site
52+
run: npx playwright test --config=playwright.ci.config.ts
53+
54+
- name: Upload test results
55+
uses: actions/upload-artifact@v4
56+
if: ${{ !cancelled() }}
57+
with:
58+
name: playwright-report
59+
path: playwright-report/
60+
retention-days: 14

‎.gitignore‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Dependencies
22
node_modules
3-
package-lock.json
43

54
# Build outputs
65
dist

‎docs/user-stories.md‎

Lines changed: 366 additions & 0 deletions
Large diffs are not rendered by default.

‎eslint.config.js‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import js from '@eslint/js';
2+
import tseslint from 'typescript-eslint';
3+
import reactPlugin from 'eslint-plugin-react';
4+
import reactHooksPlugin from 'eslint-plugin-react-hooks';
5+
import reactRefreshPlugin from 'eslint-plugin-react-refresh';
6+
import globals from 'globals';
7+
8+
export default tseslint.config(
9+
{ ignores: ['dist', 'node_modules'] },
10+
js.configs.recommended,
11+
...tseslint.configs.recommended,
12+
{
13+
files: ['**/*.{ts,tsx}'],
14+
plugins: {
15+
react: reactPlugin,
16+
'react-hooks': reactHooksPlugin,
17+
'react-refresh': reactRefreshPlugin,
18+
},
19+
languageOptions: {
20+
globals: {
21+
...globals.browser,
22+
...globals.es2020,
23+
},
24+
},
25+
settings: {
26+
react: {
27+
version: 'detect',
28+
},
29+
},
30+
rules: {
31+
...reactPlugin.configs.recommended.rules,
32+
...reactHooksPlugin.configs.recommended.rules,
33+
'react/react-in-jsx-scope': 'off',
34+
'react/prop-types': 'off',
35+
'react-refresh/only-export-components': [
36+
'warn',
37+
{ allowConstantExport: true },
38+
],
39+
'@typescript-eslint/no-explicit-any': [
40+
'warn',
41+
{ ignoreRestArgs: true },
42+
],
43+
'@typescript-eslint/no-unused-vars': [
44+
'error',
45+
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' },
46+
],
47+
'no-console': [
48+
'warn',
49+
{ allow: ['warn', 'error'] },
50+
],
51+
},
52+
},
53+
);

0 commit comments

Comments
 (0)