Skip to content

Commit 0332c17

Browse files
authored
Improves ESLint/Next/TypeScript integration (#929)
* Improves ESLint/Next/TypeScript integration * Adds linting to pipeline * Updates CLAUDE.md to run linting
1 parent c2c3f3d commit 0332c17

7 files changed

Lines changed: 3790 additions & 4545 deletions

File tree

.eslint.config.mjs

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and test
1+
name: QA
22

33
on: [push, pull_request]
44

@@ -16,3 +16,12 @@ jobs:
1616
build: npm run build
1717
start: npm start
1818
wait-on: 'http://localhost:3000'
19+
lint:
20+
runs-on: ubuntu-24.04
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
- name: Install dependencies
25+
run: npm ci && npm i --os=linux --cpu=x64 sharp
26+
- name: Run ESLint
27+
run: npm run lint

CLAUDE.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,18 @@ Uses Shiki (migrated from Prism) with night-owl theme. Configured in `src/pages/
100100
- Test files: `404-page.cy.js`, `about-page.cy.js`, `index-page.cy.js`, `navigation.cy.js`
101101
- Uses `@testing-library/cypress` and `cypress-real-events`
102102

103+
## Code Quality
104+
105+
**IMPORTANT: Always run linting after implementing changes**
106+
107+
After making any code changes (adding features, fixing bugs, refactoring), you MUST run:
108+
109+
```bash
110+
npm run lint
111+
```
112+
113+
If linting errors are found, fix them before considering the task complete. This ensures code quality and consistency across the codebase.
114+
103115
## Key Constraints
104116

105117
- Must use `--webpack` flag with Next.js commands (required for mdx-bundler)

cypress/.eslintrc.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import js from '@eslint/js'
2+
import tseslint from 'typescript-eslint'
3+
import reactHooksPlugin from 'eslint-plugin-react-hooks'
4+
import cypressPlugin from 'eslint-plugin-cypress'
5+
import prettierConfig from 'eslint-config-prettier'
6+
7+
const eslintConfig = [
8+
// 1. Base ESLint recommended rules
9+
js.configs.recommended,
10+
11+
// 2. TypeScript ESLint recommended rules (without type-checking for performance)
12+
...tseslint.configs.recommended,
13+
14+
// 3. React Hooks configuration for all JS/TS files
15+
{
16+
files: ['**/*.{ts,tsx,js,jsx}'],
17+
plugins: {
18+
'react-hooks': reactHooksPlugin,
19+
},
20+
rules: {
21+
'react-hooks/rules-of-hooks': 'error',
22+
'react-hooks/exhaustive-deps': 'warn',
23+
},
24+
},
25+
26+
// 4. TypeScript-specific overrides
27+
{
28+
files: ['**/*.{ts,tsx}'],
29+
rules: {
30+
// Allow unused vars with underscore prefix (common pattern)
31+
'@typescript-eslint/no-unused-vars': [
32+
'warn',
33+
{
34+
argsIgnorePattern: '^_',
35+
varsIgnorePattern: '^_',
36+
},
37+
],
38+
// Allow explicit any when necessary
39+
'@typescript-eslint/no-explicit-any': 'warn',
40+
// Allow require statements in config files
41+
'@typescript-eslint/no-require-imports': 'off',
42+
},
43+
},
44+
45+
// 5. Cypress test files
46+
{
47+
files: ['cypress/**/*.{js,ts}'],
48+
plugins: {
49+
cypress: cypressPlugin,
50+
},
51+
languageOptions: {
52+
globals: {
53+
...cypressPlugin.environments.globals.globals,
54+
},
55+
},
56+
rules: {
57+
...cypressPlugin.configs.recommended.rules,
58+
// Cypress commands create false positives
59+
'no-undef': 'off',
60+
// Allow require() in Cypress files (CommonJS)
61+
'@typescript-eslint/no-require-imports': 'off',
62+
},
63+
},
64+
65+
// 6. Node.js scripts (build scripts, config files)
66+
{
67+
files: ['scripts/**/*.{js,mjs}', '*.config.{js,ts,mjs}'],
68+
languageOptions: {
69+
globals: {
70+
process: 'readonly',
71+
__dirname: 'readonly',
72+
__filename: 'readonly',
73+
module: 'readonly',
74+
require: 'readonly',
75+
console: 'readonly',
76+
},
77+
},
78+
rules: {
79+
'@typescript-eslint/no-require-imports': 'off',
80+
'no-console': 'off',
81+
},
82+
},
83+
84+
// 7. Prettier integration (must be last to override formatting rules)
85+
prettierConfig,
86+
87+
// 8. Ignore patterns
88+
{
89+
ignores: [
90+
'node_modules/**',
91+
'.next/**',
92+
'out/**',
93+
'public/**',
94+
'coverage/**',
95+
'.cache/**',
96+
'dist/**',
97+
'build/**',
98+
'*.min.js',
99+
'next-env.d.ts',
100+
],
101+
},
102+
]
103+
104+
export default eslintConfig

0 commit comments

Comments
 (0)