|
3 | 3 | ## Migration Checklist
|
4 | 4 |
|
5 | 5 | ### Batch 1: Small npm utilities
|
6 |
| -- [ ] npm/grep |
| 6 | +- [x] npm/grep |
7 | 7 | - [ ] npm/puppeteer
|
8 | 8 | - [ ] npm/mount-utils
|
9 | 9 | - [ ] npm/cypress-schematic
|
@@ -150,10 +150,161 @@ For each package in the batch:
|
150 | 150 |
|
151 | 151 | ---
|
152 | 152 |
|
| 153 | +## Troubleshooting Guide |
| 154 | +
|
| 155 | +### Common Issues and Solutions |
| 156 | +
|
| 157 | +#### 1. **Jiti Version Compatibility Error** |
| 158 | +**Error:** `Error: You are using an outdated version of the 'jiti' library. Please update to the latest version of 'jiti' to ensure compatibility and access to the latest features.` |
| 159 | +
|
| 160 | +**Solution:** |
| 161 | +- Add `jiti: "^2.4.2"` to the package's `devDependencies` |
| 162 | +- ESLint 9.x requires jiti >= 2.2.0, but monorepo dependencies might provide older versions |
| 163 | +
|
| 164 | +#### 2. **TypeScript Project Service Errors** |
| 165 | +**Error:** `was not found by the project service. Consider either including it in the tsconfig.json or including it in allowDefaultProject` |
| 166 | +
|
| 167 | +**Solutions:** |
| 168 | +- **Create/update `tsconfig.json`** that extends the base config: |
| 169 | + ```json |
| 170 | + { |
| 171 | + "extends": "../../packages/ts/tsconfig.json", |
| 172 | + "compilerOptions": { |
| 173 | + "esModuleInterop": true, |
| 174 | + "allowJs": true, |
| 175 | + "checkJs": false |
| 176 | + }, |
| 177 | + "include": [ |
| 178 | + "src/**/*", |
| 179 | + "cypress/**/*", |
| 180 | + "*.js", |
| 181 | + "*.ts", |
| 182 | + "*.jsx", |
| 183 | + "*.tsx" |
| 184 | + ], |
| 185 | + "exclude": ["node_modules", "dist"] |
| 186 | + } |
| 187 | + ``` |
| 188 | +- **For Cypress packages**, ensure `cypress/tsconfig.json` includes all test files: |
| 189 | + ```json |
| 190 | + { |
| 191 | + "compilerOptions": { |
| 192 | + "types": ["cypress"] |
| 193 | + }, |
| 194 | + "include": [ |
| 195 | + "**/*.ts", |
| 196 | + "**/*.js" |
| 197 | + ] |
| 198 | + } |
| 199 | + ``` |
| 200 | +- **Add `allowDefaultProject: true`** to ESLint config for problematic files: |
| 201 | + ```ts |
| 202 | + { |
| 203 | + files: ['**/*.js', '**/*.ts', '**/*.jsx', '**/*.tsx'], |
| 204 | + languageOptions: { |
| 205 | + parserOptions: { |
| 206 | + allowDefaultProject: true, |
| 207 | + }, |
| 208 | + }, |
| 209 | + } |
| 210 | + ``` |
| 211 | + |
| 212 | +#### 3. **Skip Comment Rule Violations** |
| 213 | +**Error:** `@cypress/dev/skip-comment` rule violations for `it.skip()` tests |
| 214 | + |
| 215 | +**Solution:** |
| 216 | +- Replace `eslint-disable-next-line @cypress/dev/skip-comment` with proper explanatory comments: |
| 217 | + ```js |
| 218 | + // NOTE: This test is skipped for demonstration purposes |
| 219 | + it.skip('first test', () => {}) |
| 220 | + ``` |
| 221 | + |
| 222 | +#### 4. **Rule Mismatches in Pre-commit Hook** |
| 223 | +**Error:** ESLint rule violations that don't match the package's ESLint configuration (e.g., `Unexpected console statement` when `no-console` is off in package config) |
| 224 | + |
| 225 | +**Root Cause:** Pre-commit hook runs ESLint from root directory using root-level config, not package-specific config |
| 226 | + |
| 227 | +**Solution:** |
| 228 | +- Add package-specific lint-staged rule in root `package.json`: |
| 229 | + ```json |
| 230 | + "lint-staged": { |
| 231 | + "npm/grep/**/*.{js,jsx,ts,tsx}": "cd npm/grep && eslint --fix", |
| 232 | + "*.{js,jsx,ts,tsx,json,eslintrc,vue}": "eslint --fix" |
| 233 | + } |
| 234 | + ``` |
| 235 | + |
| 236 | +#### 5. **ESLint Script Changes** |
| 237 | +**Before ESLint 9.x:** |
| 238 | +```json |
| 239 | +"lint": "eslint . --ext .js,.ts" |
| 240 | +``` |
| 241 | + |
| 242 | +**After ESLint 9.x:** |
| 243 | +```json |
| 244 | +"lint": "eslint ." |
| 245 | +``` |
| 246 | +ESLint 9.x auto-detects file extensions, so `--ext` flag is no longer needed. |
| 247 | + |
| 248 | +#### 6. **Package Dependencies** |
| 249 | +**Required additions to `package.json`:** |
| 250 | +```json |
| 251 | +{ |
| 252 | + "devDependencies": { |
| 253 | + "@packages/eslint-config": "0.0.0-development", |
| 254 | + "eslint": "^9.18.0", |
| 255 | + "jiti": "^2.4.2" |
| 256 | + } |
| 257 | +} |
| 258 | +``` |
| 259 | + |
| 260 | +#### 7. **Custom Package Rules** |
| 261 | +If a package needs custom rules, extend the base config: |
| 262 | +```ts |
| 263 | +import baseConfig from '@packages/eslint-config' |
| 264 | + |
| 265 | +export default [ |
| 266 | + ...baseConfig, |
| 267 | + { |
| 268 | + files: ['**/*.js', '**/*.ts', '**/*.jsx', '**/*.tsx'], |
| 269 | + rules: { |
| 270 | + 'no-console': 'off', |
| 271 | + 'no-restricted-syntax': 'off', |
| 272 | + }, |
| 273 | + }, |
| 274 | + { |
| 275 | + files: ['cypress/**/*.js', 'cypress/**/*.ts'], |
| 276 | + languageOptions: { |
| 277 | + globals: { |
| 278 | + Cypress: 'readonly', |
| 279 | + cy: 'readonly', |
| 280 | + }, |
| 281 | + }, |
| 282 | + }, |
| 283 | +] |
| 284 | +``` |
| 285 | + |
| 286 | +### Migration Checklist Template |
| 287 | + |
| 288 | +For each package, ensure you've completed: |
| 289 | + |
| 290 | +- [ ] Removed `.eslintrc*` files |
| 291 | +- [ ] Created `eslint.config.ts` with proper configuration |
| 292 | +- [ ] Added required dependencies (`eslint`, `@packages/eslint-config`, `jiti`) |
| 293 | +- [ ] Created/updated `tsconfig.json` that extends base config |
| 294 | +- [ ] Updated ESLint scripts (removed `--ext` flag) |
| 295 | +- [ ] Fixed skip comment violations |
| 296 | +- [ ] Resolved console statement issues |
| 297 | +- [ ] Added package-specific lint-staged rule (if needed) |
| 298 | +- [ ] Ran `yarn lint` successfully |
| 299 | +- [ ] Ran tests to ensure nothing broke |
| 300 | + |
| 301 | +--- |
| 302 | + |
153 | 303 | ## Tips
|
154 | 304 | - Use a tracking issue or project board to coordinate and document progress.
|
155 | 305 | - If a package is especially noisy, consider splitting it into its own PR.
|
156 | 306 | - Communicate with the team about the migration timeline and process.
|
| 307 | +- **Test the pre-commit hook** before pushing to ensure lint-staged works correctly. |
157 | 308 |
|
158 | 309 | ---
|
159 | 310 |
|
|
0 commit comments