centy-plugin-routines 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalog.js +7 -0
- package/package.json +1 -1
- package/routines/add-lint-rules.md +67 -0
package/dist/catalog.js
CHANGED
|
@@ -23,4 +23,11 @@ export const catalog = [
|
|
|
23
23
|
version: 2,
|
|
24
24
|
body: withVersion(loadRoutine('release-new-version.md'), 2),
|
|
25
25
|
},
|
|
26
|
+
{
|
|
27
|
+
slug: 'add-lint-rules',
|
|
28
|
+
title: 'Add Lint Rules',
|
|
29
|
+
description: 'Analyze code and add new error-level lint rules to improve code quality, then open a PR',
|
|
30
|
+
version: 1,
|
|
31
|
+
body: withVersion(loadRoutine('add-lint-rules.md'), 1),
|
|
32
|
+
},
|
|
26
33
|
];
|
package/package.json
CHANGED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Add Lint Rules
|
|
2
|
+
|
|
3
|
+
Analyze the codebase, identify opportunities for stricter linting, add new error-level lint rules, fix all violations, and open a PR to main.
|
|
4
|
+
|
|
5
|
+
**Important: This routine must be executed fully autonomously. Do not ask the user for input. Determine everything from the project context.**
|
|
6
|
+
|
|
7
|
+
## Step 0 — Detect Ecosystem and Linter
|
|
8
|
+
|
|
9
|
+
1. Identify the project type by inspecting manifest and config files:
|
|
10
|
+
- **Rust**: `Cargo.toml` — linter is `clippy` (configured via `clippy.toml`, `Cargo.toml [lints]`, or `#![deny(...)]` / `#![warn(...)]` attributes)
|
|
11
|
+
- **JavaScript/TypeScript**: `package.json` — linter is `eslint` (configured via `eslint.config.*`, `.eslintrc.*`)
|
|
12
|
+
- **Python**: `pyproject.toml` / `setup.py` — linter is `ruff` or `pylint` / `flake8` (configured via `pyproject.toml [tool.ruff]`, `ruff.toml`, `.pylintrc`, etc.)
|
|
13
|
+
- **Go**: `go.mod` — linter is `golangci-lint` (configured via `.golangci.yml`)
|
|
14
|
+
- Other ecosystems: adapt accordingly
|
|
15
|
+
2. Read the existing lint configuration to understand which rules are already enabled and at what severity
|
|
16
|
+
3. Run the linter as-is and note any existing warnings or errors — the codebase must be clean before proceeding
|
|
17
|
+
|
|
18
|
+
## Step 1 — Analyze the Code
|
|
19
|
+
|
|
20
|
+
1. Read through the source files and identify recurring patterns, code smells, or risky practices that a lint rule could catch. Focus on:
|
|
21
|
+
- Correctness issues (e.g., unused variables, unreachable code, implicit type coercions)
|
|
22
|
+
- Safety and security (e.g., unwrap in Rust, eval in JS, bare except in Python)
|
|
23
|
+
- Consistency (e.g., naming conventions, import ordering, brace style)
|
|
24
|
+
- Maintainability (e.g., overly complex functions, deeply nested logic, missing return types)
|
|
25
|
+
2. Note which of these are already covered by existing lint rules and which are not
|
|
26
|
+
|
|
27
|
+
## Step 2 — Research and Select New Rules
|
|
28
|
+
|
|
29
|
+
1. Search the web for the linter's full rule catalog and any recent additions relevant to the detected ecosystem version
|
|
30
|
+
2. Cross-reference with the patterns found in Step 1 to select rules that would catch real issues in this codebase — do not add rules that would produce zero findings or are purely stylistic noise
|
|
31
|
+
3. Also consider broadly recommended rule sets or presets that the project has not yet adopted (e.g., clippy::pedantic, eslint recommended configs, ruff's extended rule sets)
|
|
32
|
+
4. Aim for a focused set of **3-10 new rules** promoted to error level. Quality over quantity — each rule should have a clear benefit for this specific codebase
|
|
33
|
+
5. For each selected rule, note:
|
|
34
|
+
- The rule identifier
|
|
35
|
+
- What it catches
|
|
36
|
+
- Why it is beneficial for this codebase specifically
|
|
37
|
+
|
|
38
|
+
## Step 3 — Apply the Rules and Fix Violations
|
|
39
|
+
|
|
40
|
+
1. Create a new branch named `lint/<short-description>` (e.g., `lint/stricter-clippy`, `lint/eslint-no-implicit-coercion`)
|
|
41
|
+
2. Update the lint configuration to add the new rules at error level:
|
|
42
|
+
- **Rust**: add `#![deny(...)]` attributes or `[lints.clippy]` entries in `Cargo.toml`
|
|
43
|
+
- **JS/TS**: add rule entries with `"error"` severity in the ESLint config
|
|
44
|
+
- **Python (ruff)**: add rule codes to `select` in `pyproject.toml` or `ruff.toml`
|
|
45
|
+
- **Go**: add linter entries and rule settings in `.golangci.yml`
|
|
46
|
+
3. Run the linter and fix every violation. Prefer automated fixes where the linter supports `--fix`. For remaining violations, fix them manually — do not suppress or disable rules to pass
|
|
47
|
+
4. Run the project's test suite to ensure nothing broke
|
|
48
|
+
5. If a rule causes too many false positives or would require invasive refactoring, remove it from the set and document why in the PR description
|
|
49
|
+
|
|
50
|
+
## Step 4 — Commit and Open a PR
|
|
51
|
+
|
|
52
|
+
1. Stage all changes (config + code fixes)
|
|
53
|
+
2. Write a clear commit message: `chore(lint): add <N> new error-level <linter> rules`
|
|
54
|
+
3. Commit and push the branch
|
|
55
|
+
4. Open a pull request to `main` with:
|
|
56
|
+
- **Title**: `chore(lint): add stricter <linter> rules`
|
|
57
|
+
- **Body**: a summary listing each new rule, what it catches, and a count of violations that were fixed
|
|
58
|
+
5. Verify CI passes on the PR. If it fails, inspect logs and fix.
|
|
59
|
+
|
|
60
|
+
## Notes
|
|
61
|
+
|
|
62
|
+
- Do not prompt the user for any input — infer everything from the project context
|
|
63
|
+
- Do not downgrade any existing error-level rules
|
|
64
|
+
- Do not add rules that are already enabled at any severity
|
|
65
|
+
- If the codebase has no linter configured at all, set one up following current best practices for the ecosystem before adding rules
|
|
66
|
+
- If any step fails, stop and create a centy issue describing the failure
|
|
67
|
+
- Mark this routine as completed once the PR is open and CI has passed
|