external/ag-shared/prompts/skills/batch-lint-cleanup/SKILL.md
Analyze ESLint violations or fix a specific rule in isolation.
/lint-fix
Shows top ESLint violations by count with recommendations.
/lint-fix <rule-name>
Examples:
/lint-fix unicorn/no-zero-fractions/lint-fix unicorn/prefer-number-properties/lint-fix unicorn/no-array-for-eachRun ESLint and analyze violations:
nx run-many -t lint:eslint 2>&1 | tee /tmp/eslint-output.txt
Count violations by rule:
grep -oE 'unicorn/[a-z-]+|@typescript-eslint/[a-z-]+|no-[a-z-]+|sonarjs/[a-z-]+' /tmp/eslint-output.txt | sort | uniq -c | sort -rn | head -20
Generate a formatted report showing:
Format output as a table:
## ESLint Violations Report
| Rank | Rule | Count | Auto-Fix | Description |
| ---- | -------------------------------- | ----- | -------- | -------------------------------------- |
| 1 | unicorn/prefer-number-properties | 170 | ✅ | Use `Number.*` APIs instead of globals |
| 2 | unicorn/no-array-for-each | 166 | ✅ | Prefer for...of over .forEach() |
| 3 | no-negated-condition | 37 | ❌ | Prefer positive conditions |
...
Provide actionable recommendation:
### 🎯 Recommended Next Fix
**`unicorn/prefer-number-properties`** - 170 violations
- Auto-fixable: ✅ Yes
- Changes: `isNaN()` → `Number.isNaN()`, `parseInt()` → `Number.parseInt()`
- Impact: Better global scope hygiene
- Risk: Low - semantically equivalent
**To fix:** `/lint-fix unicorn/prefer-number-properties`
Input: Rule name (e.g., unicorn/no-zero-fractions)
CRITICAL: Isolated Fixing Strategy
Each rule MUST be fixed in complete isolation to prevent merge conflicts and allow precise review:
git status
If there are uncommitted changes:
nx run-many -t lint:eslint -- --rule "<rule-name>: error" --fix 2>&1 | tee /tmp/lint-fix.txt
Check results:
# Count remaining violations
grep -c "<rule-name>" /tmp/lint-fix.txt || echo "0"
# Format all changes
yarn nx format --sort-root-tsconfig-paths=false
# Run full lint to ensure no new issues
yarn nx lint <affected-packages>
# Run type-check
yarn nx build:types <affected-packages>
If all pass:
git add -A
git commit -m "fix(lint): auto-fix <rule-name> violations"
For non-auto-fixable rules or remaining violations after auto-fix:
List all remaining violations:
nx run-many -t lint:eslint -- --rule "<rule-name>: error" 2>&1 | grep "<rule-name>"
Group by file/pattern for efficient fixing
Fix each file systematically:
After each batch of fixes:
# Verify the fix works
nx run-many -t lint:eslint -- --rule "<rule-name>: error"
When complete:
yarn nx format --sort-root-tsconfig-paths=false
yarn nx lint <affected-packages>
yarn nx build:types <affected-packages>
git add -A
git commit -m "fix(lint): manually fix <rule-name> violations"
| Rule | Auto-Fix | Typical Change |
|---|---|---|
unicorn/prefer-number-properties | ✅ | isNaN() → Number.isNaN() |
unicorn/no-array-for-each | ✅ | .forEach() → for...of |
unicorn/no-zero-fractions | ✅ | 1.0 → 1 |
unicorn/prefer-string-slice | ✅ | .substr() → .slice() |
@typescript-eslint/no-unused-vars | ❌ | Remove or use variable |
no-negated-condition | ❌ | Invert condition logic |
sonarjs/cognitive-complexity | ❌ | Refactor complex function |
Before ANY commit:
yarn nx format --sort-root-tsconfig-paths=false passesyarn nx lint <affected-packages> passesyarn nx build:types <affected-packages> passesIf any check fails: STOP and report to user