eslint-plugin-conventions 7.0.4 → 7.1.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/AGENTS.md +24 -0
- package/README.md +98 -69
- package/package.json +1 -1
- package/src/index.js +1 -1
- package/src/lib/guidance-files.js +1 -0
- package/src/lib/report-loc.js +1 -0
- package/src/rules/conventions/no-commented-code.js +1 -1
- package/src/rules/guidance/enforced-rule-in-prose.js +1 -0
- package/src/rules/guidance/guidance-budget.js +1 -0
- package/src/rules/guidance/no-duplicated-guidance.js +1 -0
- package/src/rules/guidance/procedure-in-memory.js +1 -0
- package/src/rules/guidance/subagent-declares-model.js +1 -0
package/AGENTS.md
CHANGED
|
@@ -30,6 +30,7 @@ Each preset is one flat config object: put it in the array as an element, do not
|
|
|
30
30
|
| Preset | Rules | Errors | Warnings |
|
|
31
31
|
| ------------- | ----- | ------ | -------- |
|
|
32
32
|
| `recommended` | 6 | 3 | 3 |
|
|
33
|
+
| `guidance` | 5 | 0 | 5 |
|
|
33
34
|
|
|
34
35
|
### `recommended`
|
|
35
36
|
|
|
@@ -42,6 +43,29 @@ Each preset is one flat config object: put it in the array as an element, do not
|
|
|
42
43
|
- `no-raw-cross-property-href` (error): Forbid hand-written cross-property hrefs; use buildUtmHref() from lib/utm.ts.
|
|
43
44
|
- `analytics-event-naming` (error): Analytics event names (track/capture) must follow ANALYTICS_PHILOSOPHY.md principle 4: lowercase snake_case, category:object_action, fixed verb list.
|
|
44
45
|
|
|
46
|
+
### `guidance`
|
|
47
|
+
|
|
48
|
+
5 rules:
|
|
49
|
+
|
|
50
|
+
- `guidance-budget` (warn): Keep always-loaded agent guidance (CLAUDE.md, AGENTS.md) and skills inside a ratcheted size budget.
|
|
51
|
+
- `enforced-rule-in-prose` (warn): Report never/always lines in agent guidance that a tool could enforce, unlinked to the tool that does.
|
|
52
|
+
- `procedure-in-memory` (warn): Disallow long numbered procedures in always-loaded agent guidance; move them to a skill.
|
|
53
|
+
- `subagent-declares-model` (warn): Require every .claude/agents/*.md subagent to declare a model and a tool allowlist in its frontmatter.
|
|
54
|
+
- `no-duplicated-guidance` (warn): Disallow the same guidance line in two always-loaded agent files (CLAUDE.md, AGENTS.md, GEMINI.md) of one repo.
|
|
55
|
+
|
|
56
|
+
This preset lints Markdown, so it needs `@eslint/markdown` registered as the `markdown` plugin beside it:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npm install --save-dev @eslint/markdown
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
import markdown from '@eslint/markdown';
|
|
64
|
+
import conventions from 'eslint-plugin-conventions';
|
|
65
|
+
|
|
66
|
+
export default [{ plugins: { markdown } }, conventions.configs.guidance];
|
|
67
|
+
```
|
|
68
|
+
|
|
45
69
|
### Rules in no preset
|
|
46
70
|
|
|
47
71
|
Enable these by name (`'conventions/<rule>': 'error'`):
|
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ This plugin provides Project conventions: naming, file structure, and code style
|
|
|
51
51
|
|
|
52
52
|
- **Why** — a linter nobody reads protects nothing. We would rather miss a finding
|
|
53
53
|
than spend your attention on one that was never real.
|
|
54
|
-
- **How** — evidence, not names. A rule fires on what the code
|
|
54
|
+
- **How** — evidence, not names. A rule fires on what the code _does_, resolved
|
|
55
55
|
through the AST and ESLint's own scope analysis.
|
|
56
56
|
- **What** — every finding carries its fix, in prose for a human and as structured
|
|
57
57
|
JSON for an agent. Security rules add a CWE mapping and, where assigned, a CVSS score.
|
|
@@ -64,13 +64,16 @@ That trade costs recall, and we measure it:
|
|
|
64
64
|
<!-- AUTO-GENERATED:DOCTRINE:END -->
|
|
65
65
|
|
|
66
66
|
## ⚙️ Configuration Presets
|
|
67
|
-
|
|
68
|
-
|
|
|
69
|
-
|
|
|
67
|
+
|
|
68
|
+
| Preset | Description |
|
|
69
|
+
| :------------ | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
70
|
+
| `recommended` | Balanced conventions for most teams |
|
|
71
|
+
| `guidance` | Agent guidance files (`CLAUDE.md`, `AGENTS.md`, `GEMINI.md`, skills, subagents): size budgets, rules held only by prose, procedures in always-loaded files, subagent model and tools, duplicated lines. Markdown, at `warn`. |
|
|
70
72
|
|
|
71
73
|
---
|
|
72
74
|
|
|
73
75
|
## 🏢 Usage Example
|
|
76
|
+
|
|
74
77
|
```js
|
|
75
78
|
// eslint.config.js
|
|
76
79
|
import conventions from 'eslint-plugin-conventions';
|
|
@@ -78,13 +81,32 @@ import conventions from 'eslint-plugin-conventions';
|
|
|
78
81
|
export default [conventions.configs.recommended];
|
|
79
82
|
```
|
|
80
83
|
|
|
84
|
+
### Agent guidance files
|
|
85
|
+
|
|
86
|
+
The `guidance` preset lints agent guidance as Markdown, so it needs ESLint 9 or later (language
|
|
87
|
+
plugins) and [`@eslint/markdown`](https://github.com/eslint/markdown) registered as the `markdown`
|
|
88
|
+
plugin:
|
|
89
|
+
|
|
90
|
+
```js
|
|
91
|
+
// eslint.config.js
|
|
92
|
+
import markdown from '@eslint/markdown';
|
|
93
|
+
import { configs } from 'eslint-plugin-conventions';
|
|
94
|
+
|
|
95
|
+
export default [{ plugins: { markdown } }, configs.guidance];
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Each rule asks a question a parser can answer — is this file over its ratcheted budget, does this
|
|
99
|
+
`never`/`always` line name something a tool could check without linking the tool that does, is a
|
|
100
|
+
long procedure in a file read on every session — and leaves the judgment to a person.
|
|
101
|
+
|
|
81
102
|
---
|
|
82
103
|
|
|
83
104
|
## 📦 Compatibility
|
|
84
|
-
|
|
85
|
-
|
|
|
86
|
-
|
|
|
87
|
-
|
|
|
105
|
+
|
|
106
|
+
| Package | Version |
|
|
107
|
+
| :------ | :--------------------------------- |
|
|
108
|
+
| ESLint | `^8.40.0 \|\| ^9.0.0 \|\| ^10.0.0` |
|
|
109
|
+
| Node.js | `>=22.13.0` |
|
|
88
110
|
|
|
89
111
|
See the [ESLint Version Support Policy](../../docs/ESLINT_VERSION_SUPPORT.md) — current ecosystem share data, the 20% gate, and the forward-looking exception that covers v10.
|
|
90
112
|
|
|
@@ -92,35 +114,42 @@ See the [ESLint Version Support Policy](../../docs/ESLINT_VERSION_SUPPORT.md)
|
|
|
92
114
|
|
|
93
115
|
**Legend**
|
|
94
116
|
|
|
95
|
-
| Icon | Description
|
|
96
|
-
|
|
|
97
|
-
|
|
|
98
|
-
|
|
|
99
|
-
|
|
|
100
|
-
|
|
|
101
|
-
|
|
|
102
|
-
|
|
|
103
|
-
|
|
|
104
|
-
|
|
|
117
|
+
| Icon | Description |
|
|
118
|
+
| :--: | :------------------------------------------------------------------------ |
|
|
119
|
+
| 💼 | **Recommended**: Included in the recommended preset. |
|
|
120
|
+
| ⚠️ | **Warns**: Set to warn in recommended preset. |
|
|
121
|
+
| 🔧 | **Auto-fixable**: Automatically fixable by the `--fix` CLI option. |
|
|
122
|
+
| 💡 | **Suggestions**: Providing code suggestions in IDE. |
|
|
123
|
+
| 🚫 | **Deprecated**: This rule is deprecated. |
|
|
124
|
+
| 🟢 | **Type-unaware**: AST-only, runs in oxlint JS-plugin tier. |
|
|
125
|
+
| 🟡 | **Type-aware (refining)**: pure-AST primary path; types refine precision. |
|
|
126
|
+
| 🟠 | **Type-aware (graceful)**: requires TS program; silent without it. |
|
|
105
127
|
|
|
106
128
|
<!-- AUTO-GENERATED:RULES_TABLE:START - Do not edit manually -->
|
|
107
|
-
|
|
108
|
-
|
|
|
109
|
-
|
|
|
110
|
-
| [
|
|
111
|
-
| [
|
|
112
|
-
| [
|
|
113
|
-
| [
|
|
114
|
-
| [
|
|
115
|
-
| [
|
|
116
|
-
| [no-
|
|
117
|
-
| [no-
|
|
118
|
-
| [no-
|
|
119
|
-
| [
|
|
120
|
-
| [
|
|
121
|
-
| [
|
|
122
|
-
| [
|
|
123
|
-
| [
|
|
129
|
+
|
|
130
|
+
| Rule | CWE | OWASP | CVSS | Description | 🧠 | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
|
|
131
|
+
| :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------: | :---: | :--: | :------------------------------------------------------------------------------------------------------------- | :-: | :-: | :-: | :-: | :-: | :-: |
|
|
132
|
+
| [analytics-event-naming](https://eslint.interlace.tools/docs/quality/plugin-conventions/rules/analytics-event-naming?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-conventions) | | | | Analytics event names (track/capture) must follow ANALYTICS_PHILOSOPHY.md principle 4: lowercase snake_case… | 🟢 | 💼 | | | | |
|
|
133
|
+
| [consistent-existence-index-check](https://eslint.interlace.tools/docs/quality/plugin-conventions/rules/consistent-existence-index-check?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-conventions) | | | | Enforce one form for checking whether an object has a property | 🟢 | | | | 💡 | |
|
|
134
|
+
| [enforced-rule-in-prose](https://eslint.interlace.tools/docs/quality/plugin-conventions/rules/enforced-rule-in-prose?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-conventions) | | | | Report never/always lines in agent guidance that a tool could enforce, unlinked to the tool that does | 🟢 | | | | | |
|
|
135
|
+
| [expiring-todo-comments](https://eslint.interlace.tools/docs/quality/plugin-conventions/rules/expiring-todo-comments?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-conventions) | | | | Add expiration conditions to TODO comments to prevent forgotten tasks. This rule is part of eslint-plugin-c… | 🟢 | | ⚠️ | | 💡 | |
|
|
136
|
+
| [filename-case](https://eslint.interlace.tools/docs/quality/plugin-conventions/rules/filename-case?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-conventions) | | | | Enforce filename case conventions for consistency across your codebase | 🟢 | | | | 💡 | |
|
|
137
|
+
| [guidance-budget](https://eslint.interlace.tools/docs/quality/plugin-conventions/rules/guidance-budget?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-conventions) | | | | Keep always-loaded agent guidance (CLAUDE.md, AGENTS.md) and skills inside a ratcheted size budget | 🟢 | | | | | |
|
|
138
|
+
| [no-commented-code](https://eslint.interlace.tools/docs/quality/plugin-conventions/rules/no-commented-code?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-conventions) | | | | Disallow commented-out code: delete it and let version control keep the history. | 🟢 | | ⚠️ | | 💡 | |
|
|
139
|
+
| [no-console-spaces](https://eslint.interlace.tools/docs/quality/plugin-conventions/rules/no-console-spaces?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-conventions) | | | | Disallow leading/trailing whitespace in console arguments. This rule is part of eslint-plugin-conventions. | 🟢 | | | | | |
|
|
140
|
+
| [no-deprecated-api](https://eslint.interlace.tools/docs/quality/plugin-conventions/rules/no-deprecated-api?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-conventions) | CWE-1078 | | | Prevent usage of deprecated APIs with migration context and timeline. This rule is part of eslint-plugin-co… | 🟢 | | ⚠️ | | 💡 | |
|
|
141
|
+
| [no-duplicated-guidance](https://eslint.interlace.tools/docs/quality/plugin-conventions/rules/no-duplicated-guidance?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-conventions) | | | | Disallow the same guidance line in two always-loaded agent files (CLAUDE.md, AGENTS.md, GEMINI.md) of one repo | 🟢 | | | | | |
|
|
142
|
+
| [no-json-schema-tags](https://eslint.interlace.tools/docs/quality/plugin-conventions/rules/no-json-schema-tags?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-conventions) | | | | Disallow JSON Schema keywords (e.g. @minimum, @maximum, @pattern, @format) used as JSDoc tags. | 🟢 | | | | 💡 | |
|
|
143
|
+
| [no-magic-numbers](https://eslint.interlace.tools/docs/quality/plugin-conventions/rules/no-magic-numbers?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-conventions) | | | | Disallow magic numbers (numeric literals without a named constant) | 🟢 | | | | 💡 | |
|
|
144
|
+
| [no-raw-cross-property-href](https://eslint.interlace.tools/docs/quality/plugin-conventions/rules/no-raw-cross-property-href?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-conventions) | | | | Forbid hand-written cross-property hrefs; use buildUtmHref() from lib/utm.ts | 🟢 | 💼 | | | | |
|
|
145
|
+
| [prefer-code-point](https://eslint.interlace.tools/docs/quality/plugin-conventions/rules/prefer-code-point?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-conventions) | | | | Prefer String.codePointAt() over String.charCodeAt(). This rule is part of eslint-plugin-conventions. | 🟢 | | | | | |
|
|
146
|
+
| [prefer-dependency-version-strategy](https://eslint.interlace.tools/docs/quality/plugin-conventions/rules/prefer-dependency-version-strategy?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-conventions) | | | | Enforce consistent version strategy (caret ^, tilde ~, exact, range, or any) for package.json dependencies.… | 🟢 | | | | 💡 | |
|
|
147
|
+
| [prefer-dom-node-text-content](https://eslint.interlace.tools/docs/quality/plugin-conventions/rules/prefer-dom-node-text-content?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-conventions) | | | | Prefer textContent over innerText. This rule is part of eslint-plugin-conventions. | 🟢 | | | | 💡 | |
|
|
148
|
+
| [procedure-in-memory](https://eslint.interlace.tools/docs/quality/plugin-conventions/rules/procedure-in-memory?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-conventions) | | | | Disallow long numbered procedures in always-loaded agent guidance; move them to a skill | 🟢 | | | | | |
|
|
149
|
+
| [require-data-testid](https://eslint.interlace.tools/docs/quality/plugin-conventions/rules/require-data-testid?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-conventions) | | | | Require stable data-testid attributes on interactive elements for end-to-end test reliability | 🟢 | | | | 💡 | |
|
|
150
|
+
| [subagent-declares-model](https://eslint.interlace.tools/docs/quality/plugin-conventions/rules/subagent-declares-model?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-conventions) | | | | Require every .claude/agents/*.md subagent to declare a model and a tool allowlist in its frontmatter | 🟢 | | | | | |
|
|
151
|
+
| [utm-taxonomy](https://eslint.interlace.tools/docs/quality/plugin-conventions/rules/utm-taxonomy?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-conventions) | | | | Validate utm_source and utm_medium values against the fixed taxonomy in UTM_PHILOSOPHY.md | 🟢 | 💼 | | | | |
|
|
152
|
+
|
|
124
153
|
<!-- AUTO-GENERATED:RULES_TABLE:END -->
|
|
125
154
|
<!-- AUTO-GENERATED:ECOSYSTEM_TABLE:START - Do not edit manually -->
|
|
126
155
|
|
|
@@ -130,43 +159,43 @@ Part of the **Interlace ESLint ecosystem** — AI-native rules with LLM-optimize
|
|
|
130
159
|
|
|
131
160
|
**Security**
|
|
132
161
|
|
|
133
|
-
| Plugin
|
|
134
|
-
|
|
|
135
|
-
| [`eslint-plugin-anthropic-security`](https://www.npmjs.com/package/eslint-plugin-anthropic-security)
|
|
136
|
-
| [`eslint-plugin-browser-security`](https://www.npmjs.com/package/eslint-plugin-browser-security)
|
|
137
|
-
| [`eslint-plugin-drizzle-security`](https://www.npmjs.com/package/eslint-plugin-drizzle-security)
|
|
138
|
-
| [`eslint-plugin-express-security`](https://www.npmjs.com/package/eslint-plugin-express-security)
|
|
139
|
-
| [`eslint-plugin-gemini-security`](https://www.npmjs.com/package/eslint-plugin-gemini-security)
|
|
140
|
-
| [`eslint-plugin-jwt-security`](https://www.npmjs.com/package/eslint-plugin-jwt-security)
|
|
141
|
-
| [`eslint-plugin-knex-security`](https://www.npmjs.com/package/eslint-plugin-knex-security)
|
|
142
|
-
| [`eslint-plugin-lambda-security`](https://www.npmjs.com/package/eslint-plugin-lambda-security)
|
|
143
|
-
| [`eslint-plugin-mcp-sdk-security`](https://www.npmjs.com/package/eslint-plugin-mcp-sdk-security)
|
|
144
|
-
| [`eslint-plugin-mongodb-security`](https://www.npmjs.com/package/eslint-plugin-mongodb-security)
|
|
145
|
-
| [`eslint-plugin-mysql-security`](https://www.npmjs.com/package/eslint-plugin-mysql-security)
|
|
146
|
-
| [`eslint-plugin-nestjs-security`](https://www.npmjs.com/package/eslint-plugin-nestjs-security)
|
|
147
|
-
| [`eslint-plugin-node-security`](https://www.npmjs.com/package/eslint-plugin-node-security)
|
|
148
|
-
| [`eslint-plugin-openai-security`](https://www.npmjs.com/package/eslint-plugin-openai-security)
|
|
149
|
-
| [`eslint-plugin-postgresql-security`](https://www.npmjs.com/package/eslint-plugin-postgresql-security) | [](https://www.npmjs.com/package/eslint-plugin-postgresql-security) | PostgreSQL security.
|
|
150
|
-
| [`eslint-plugin-prisma-security`](https://www.npmjs.com/package/eslint-plugin-prisma-security)
|
|
151
|
-
| [`eslint-plugin-secure-coding`](https://www.npmjs.com/package/eslint-plugin-secure-coding)
|
|
152
|
-
| [`eslint-plugin-sequelize-security`](https://www.npmjs.com/package/eslint-plugin-sequelize-security)
|
|
153
|
-
| [`eslint-plugin-sqlite-security`](https://www.npmjs.com/package/eslint-plugin-sqlite-security)
|
|
154
|
-
| [`eslint-plugin-supabase-security`](https://www.npmjs.com/package/eslint-plugin-supabase-security)
|
|
155
|
-
| [`eslint-plugin-typeorm-security`](https://www.npmjs.com/package/eslint-plugin-typeorm-security)
|
|
156
|
-
| [`eslint-plugin-vercel-ai-security`](https://www.npmjs.com/package/eslint-plugin-vercel-ai-security)
|
|
162
|
+
| Plugin | Downloads | Description |
|
|
163
|
+
| :----------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------- |
|
|
164
|
+
| [`eslint-plugin-anthropic-security`](https://www.npmjs.com/package/eslint-plugin-anthropic-security) | [](https://www.npmjs.com/package/eslint-plugin-anthropic-security) | Anthropic SDK security. |
|
|
165
|
+
| [`eslint-plugin-browser-security`](https://www.npmjs.com/package/eslint-plugin-browser-security) | [](https://www.npmjs.com/package/eslint-plugin-browser-security) | XSS, DOM security. |
|
|
166
|
+
| [`eslint-plugin-drizzle-security`](https://www.npmjs.com/package/eslint-plugin-drizzle-security) | [](https://www.npmjs.com/package/eslint-plugin-drizzle-security) | Drizzle security. |
|
|
167
|
+
| [`eslint-plugin-express-security`](https://www.npmjs.com/package/eslint-plugin-express-security) | [](https://www.npmjs.com/package/eslint-plugin-express-security) | Express middleware hardening. |
|
|
168
|
+
| [`eslint-plugin-gemini-security`](https://www.npmjs.com/package/eslint-plugin-gemini-security) | [](https://www.npmjs.com/package/eslint-plugin-gemini-security) | Google Gemini SDK security. |
|
|
169
|
+
| [`eslint-plugin-jwt-security`](https://www.npmjs.com/package/eslint-plugin-jwt-security) | [](https://www.npmjs.com/package/eslint-plugin-jwt-security) | Token security. |
|
|
170
|
+
| [`eslint-plugin-knex-security`](https://www.npmjs.com/package/eslint-plugin-knex-security) | [](https://www.npmjs.com/package/eslint-plugin-knex-security) | Knex security. |
|
|
171
|
+
| [`eslint-plugin-lambda-security`](https://www.npmjs.com/package/eslint-plugin-lambda-security) | [](https://www.npmjs.com/package/eslint-plugin-lambda-security) | AWS Lambda hardening. |
|
|
172
|
+
| [`eslint-plugin-mcp-sdk-security`](https://www.npmjs.com/package/eslint-plugin-mcp-sdk-security) | [](https://www.npmjs.com/package/eslint-plugin-mcp-sdk-security) | MCP SDK security. |
|
|
173
|
+
| [`eslint-plugin-mongodb-security`](https://www.npmjs.com/package/eslint-plugin-mongodb-security) | [](https://www.npmjs.com/package/eslint-plugin-mongodb-security) | MongoDB injection. |
|
|
174
|
+
| [`eslint-plugin-mysql-security`](https://www.npmjs.com/package/eslint-plugin-mysql-security) | [](https://www.npmjs.com/package/eslint-plugin-mysql-security) | MySQL security. |
|
|
175
|
+
| [`eslint-plugin-nestjs-security`](https://www.npmjs.com/package/eslint-plugin-nestjs-security) | [](https://www.npmjs.com/package/eslint-plugin-nestjs-security) | NestJS framework hardening. |
|
|
176
|
+
| [`eslint-plugin-node-security`](https://www.npmjs.com/package/eslint-plugin-node-security) | [](https://www.npmjs.com/package/eslint-plugin-node-security) | Server-side patterns. |
|
|
177
|
+
| [`eslint-plugin-openai-security`](https://www.npmjs.com/package/eslint-plugin-openai-security) | [](https://www.npmjs.com/package/eslint-plugin-openai-security) | OpenAI SDK security. |
|
|
178
|
+
| [`eslint-plugin-postgresql-security`](https://www.npmjs.com/package/eslint-plugin-postgresql-security) | [](https://www.npmjs.com/package/eslint-plugin-postgresql-security) | PostgreSQL security. |
|
|
179
|
+
| [`eslint-plugin-prisma-security`](https://www.npmjs.com/package/eslint-plugin-prisma-security) | [](https://www.npmjs.com/package/eslint-plugin-prisma-security) | Prisma security. |
|
|
180
|
+
| [`eslint-plugin-secure-coding`](https://www.npmjs.com/package/eslint-plugin-secure-coding) | [](https://www.npmjs.com/package/eslint-plugin-secure-coding) | Injection prevention. |
|
|
181
|
+
| [`eslint-plugin-sequelize-security`](https://www.npmjs.com/package/eslint-plugin-sequelize-security) | [](https://www.npmjs.com/package/eslint-plugin-sequelize-security) | Sequelize ORM security. |
|
|
182
|
+
| [`eslint-plugin-sqlite-security`](https://www.npmjs.com/package/eslint-plugin-sqlite-security) | [](https://www.npmjs.com/package/eslint-plugin-sqlite-security) | SQLite security. |
|
|
183
|
+
| [`eslint-plugin-supabase-security`](https://www.npmjs.com/package/eslint-plugin-supabase-security) | [](https://www.npmjs.com/package/eslint-plugin-supabase-security) | Supabase security. |
|
|
184
|
+
| [`eslint-plugin-typeorm-security`](https://www.npmjs.com/package/eslint-plugin-typeorm-security) | [](https://www.npmjs.com/package/eslint-plugin-typeorm-security) | TypeORM security. |
|
|
185
|
+
| [`eslint-plugin-vercel-ai-security`](https://www.npmjs.com/package/eslint-plugin-vercel-ai-security) | [](https://www.npmjs.com/package/eslint-plugin-vercel-ai-security) | AI SDK security. |
|
|
157
186
|
|
|
158
187
|
**Code quality**
|
|
159
188
|
|
|
160
|
-
| Plugin
|
|
161
|
-
|
|
|
162
|
-
| [`eslint-plugin-import-next`](https://www.npmjs.com/package/eslint-plugin-import-next)
|
|
163
|
-
| [`eslint-plugin-maintainability`](https://www.npmjs.com/package/eslint-plugin-maintainability) | [](https://www.npmjs.com/package/eslint-plugin-maintainability) | Cognitive load and clean-code patterns.
|
|
164
|
-
| [`eslint-plugin-modernization`](https://www.npmjs.com/package/eslint-plugin-modernization)
|
|
165
|
-
| [`eslint-plugin-modularity`](https://www.npmjs.com/package/eslint-plugin-modularity)
|
|
166
|
-
| [`eslint-plugin-operability`](https://www.npmjs.com/package/eslint-plugin-operability)
|
|
167
|
-
| [`eslint-plugin-react-a11y`](https://www.npmjs.com/package/eslint-plugin-react-a11y)
|
|
168
|
-
| [`eslint-plugin-react-features`](https://www.npmjs.com/package/eslint-plugin-react-features)
|
|
169
|
-
| [`eslint-plugin-reliability`](https://www.npmjs.com/package/eslint-plugin-reliability)
|
|
189
|
+
| Plugin | Downloads | Description |
|
|
190
|
+
| :--------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------- |
|
|
191
|
+
| [`eslint-plugin-import-next`](https://www.npmjs.com/package/eslint-plugin-import-next) | [](https://www.npmjs.com/package/eslint-plugin-import-next) | Fast cycle + import-graph analysis. |
|
|
192
|
+
| [`eslint-plugin-maintainability`](https://www.npmjs.com/package/eslint-plugin-maintainability) | [](https://www.npmjs.com/package/eslint-plugin-maintainability) | Cognitive load and clean-code patterns. |
|
|
193
|
+
| [`eslint-plugin-modernization`](https://www.npmjs.com/package/eslint-plugin-modernization) | [](https://www.npmjs.com/package/eslint-plugin-modernization) | ESNext migration + syntax evolution. |
|
|
194
|
+
| [`eslint-plugin-modularity`](https://www.npmjs.com/package/eslint-plugin-modularity) | [](https://www.npmjs.com/package/eslint-plugin-modularity) | Structural integrity and DDD patterns. |
|
|
195
|
+
| [`eslint-plugin-operability`](https://www.npmjs.com/package/eslint-plugin-operability) | [](https://www.npmjs.com/package/eslint-plugin-operability) | Production readiness and resource health. |
|
|
196
|
+
| [`eslint-plugin-react-a11y`](https://www.npmjs.com/package/eslint-plugin-react-a11y) | [](https://www.npmjs.com/package/eslint-plugin-react-a11y) | React accessibility / WCAG. |
|
|
197
|
+
| [`eslint-plugin-react-features`](https://www.npmjs.com/package/eslint-plugin-react-features) | [](https://www.npmjs.com/package/eslint-plugin-react-features) | React best practices and optimization. |
|
|
198
|
+
| [`eslint-plugin-reliability`](https://www.npmjs.com/package/eslint-plugin-reliability) | [](https://www.npmjs.com/package/eslint-plugin-reliability) | Runtime stability and error safety. |
|
|
170
199
|
|
|
171
200
|
<!-- AUTO-GENERATED:ECOSYSTEM_TABLE:END -->
|
|
172
201
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-conventions",
|
|
3
|
-
"version": "7.0
|
|
3
|
+
"version": "7.1.0",
|
|
4
4
|
"description": "ESLint conventions rules for team code — enforces filename case, magic-number bans, commented-out code, expiring TODOs, and deprecated-API usage.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"sideEffects": false,
|
package/src/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.configs=exports.plugin=exports.rules=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.rules={get"no-commented-code"(){return require("./rules/conventions/no-commented-code").noCommentedCode},get"expiring-todo-comments"(){return require("./rules/conventions/expiring-todo-comments").expiringTodoComments},get"prefer-code-point"(){return require("./rules/conventions/prefer-code-point").preferCodePoint},get"prefer-dom-node-text-content"(){return require("./rules/conventions/prefer-dom-node-text-content").preferDomNodeTextContent},get"no-console-spaces"(){return require("./rules/conventions/no-console-spaces").noConsoleSpaces},get"no-deprecated-api"(){return require("./rules/deprecation/no-deprecated-api").noDeprecatedApi},get"prefer-dependency-version-strategy"(){return require("./rules/conventions/prefer-dependency-version-strategy").preferDependencyVersionStrategy},get"filename-case"(){return require("./rules/conventions/filename-case").filenameCase},get"consistent-existence-index-check"(){return require("./rules/conventions/consistent-existence-index-check").consistentExistenceIndexCheck},get"no-json-schema-tags"(){return require("./rules/conventions/no-json-schema-tags").noJsonSchemaTags},get"require-data-testid"(){return require("./rules/conventions/require-data-testid").requireDataTestId},get"utm-taxonomy"(){return require("./rules/conventions/utm-taxonomy").utmTaxonomy},get"no-raw-cross-property-href"(){return require("./rules/conventions/no-raw-cross-property-href").noRawCrossPropertyHref},get"analytics-event-naming"(){return require("./rules/conventions/analytics-event-naming").analyticsEventNaming},get"no-magic-numbers"(){return require("./rules/conventions/no-magic-numbers").noMagicNumbers}};(0,eslint_devkit_1.withCanonicalDocsUrls)("plugin-conventions",exports.rules);exports.plugin={meta:{name:"eslint-plugin-conventions",version:"7.0
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.configs=exports.GUIDANCE_FILES=exports.plugin=exports.rules=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.rules={get"no-commented-code"(){return require("./rules/conventions/no-commented-code").noCommentedCode},get"expiring-todo-comments"(){return require("./rules/conventions/expiring-todo-comments").expiringTodoComments},get"prefer-code-point"(){return require("./rules/conventions/prefer-code-point").preferCodePoint},get"prefer-dom-node-text-content"(){return require("./rules/conventions/prefer-dom-node-text-content").preferDomNodeTextContent},get"no-console-spaces"(){return require("./rules/conventions/no-console-spaces").noConsoleSpaces},get"no-deprecated-api"(){return require("./rules/deprecation/no-deprecated-api").noDeprecatedApi},get"prefer-dependency-version-strategy"(){return require("./rules/conventions/prefer-dependency-version-strategy").preferDependencyVersionStrategy},get"filename-case"(){return require("./rules/conventions/filename-case").filenameCase},get"consistent-existence-index-check"(){return require("./rules/conventions/consistent-existence-index-check").consistentExistenceIndexCheck},get"no-json-schema-tags"(){return require("./rules/conventions/no-json-schema-tags").noJsonSchemaTags},get"require-data-testid"(){return require("./rules/conventions/require-data-testid").requireDataTestId},get"utm-taxonomy"(){return require("./rules/conventions/utm-taxonomy").utmTaxonomy},get"no-raw-cross-property-href"(){return require("./rules/conventions/no-raw-cross-property-href").noRawCrossPropertyHref},get"analytics-event-naming"(){return require("./rules/conventions/analytics-event-naming").analyticsEventNaming},get"no-magic-numbers"(){return require("./rules/conventions/no-magic-numbers").noMagicNumbers},get"guidance-budget"(){return require("./rules/guidance/guidance-budget").guidanceBudget},get"enforced-rule-in-prose"(){return require("./rules/guidance/enforced-rule-in-prose").enforcedRuleInProse},get"procedure-in-memory"(){return require("./rules/guidance/procedure-in-memory").procedureInMemory},get"subagent-declares-model"(){return require("./rules/guidance/subagent-declares-model").subagentDeclaresModel},get"no-duplicated-guidance"(){return require("./rules/guidance/no-duplicated-guidance").noDuplicatedGuidance}};(0,eslint_devkit_1.withCanonicalDocsUrls)("plugin-conventions",exports.rules);exports.plugin={meta:{name:"eslint-plugin-conventions",version:"7.1.0"},rules:exports.rules};exports.GUIDANCE_FILES=["**/CLAUDE.md","**/CLAUDE.local.md","**/AGENTS.md","**/GEMINI.md","**/.claude/skills/**/SKILL.md","**/.claude/agents/*.md"];exports.configs={recommended:{plugins:{conventions:exports.plugin},rules:{"conventions/no-commented-code":"warn","conventions/expiring-todo-comments":"warn","conventions/no-deprecated-api":"warn","conventions/utm-taxonomy":"error","conventions/no-raw-cross-property-href":"error","conventions/analytics-event-naming":"error"}},guidance:{files:[...exports.GUIDANCE_FILES],language:"markdown/gfm",plugins:{conventions:exports.plugin},rules:{"conventions/guidance-budget":"warn","conventions/enforced-rule-in-prose":"warn","conventions/procedure-in-memory":"warn","conventions/subagent-declares-model":"warn","conventions/no-duplicated-guidance":"warn"}}};exports.default=exports.plugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?(function(o,m,k,k2){if(k2===void 0)k2=k;var desc=Object.getOwnPropertyDescriptor(m,k);if(!desc||("get"in desc?!m.__esModule:desc.writable||desc.configurable)){desc={enumerable:true,get:function(){return m[k]}}}Object.defineProperty(o,k2,desc)}):(function(o,m,k,k2){if(k2===void 0)k2=k;o[k2]=m[k]}));var __setModuleDefault=this&&this.__setModuleDefault||(Object.create?(function(o,v){Object.defineProperty(o,"default",{enumerable:true,value:v})}):function(o,v){o["default"]=v});var __importStar=this&&this.__importStar||(function(){var ownKeys=function(o){ownKeys=Object.getOwnPropertyNames||function(o2){var ar=[];for(var k in o2)if(Object.prototype.hasOwnProperty.call(o2,k))ar[ar.length]=k;return ar};return ownKeys(o)};return function(mod){if(mod&&mod.__esModule)return mod;var result={};if(mod!=null){for(var k=ownKeys(mod),i=0;i<k.length;i++)if(k[i]!=="default")__createBinding(result,mod,k[i])}__setModuleDefault(result,mod);return result}})();Object.defineProperty(exports,"__esModule",{value:true});exports.guidanceKind=guidanceKind;exports.frontmatter=frontmatter;exports.proseLines=proseLines;exports.isGenerated=isGenerated;exports.repoRelative=repoRelative;exports.readIfExists=readIfExists;const fs=__importStar(require("node:fs"));const path=__importStar(require("node:path"));const MEMORY_FILES=new Set(["CLAUDE.md","CLAUDE.local.md","AGENTS.md","GEMINI.md"]);function guidanceKind(filename){const normalized=filename.replace(/\\/g,"/");const base=normalized.slice(normalized.lastIndexOf("/")+1);if(MEMORY_FILES.has(base))return"memory";if(base==="SKILL.md")return"skill";if(/(?:^|\/)\.claude\/agents\/[^/]+\.md$/.test(normalized))return"agent";return null}const BLOCK_SCALAR=/^([|>])[+-]?\d*$/;const LIST_ITEM=/^\s*-\s+(.*)$/;function frontmatter(lines){if(lines[0]?.trim()!=="---")return null;const keys=new Map;let key=null;let nested=[];const settle=()=>{if(key!==null&&nested.length)keys.set(key,nestedValue(keys.get(key),nested));key=null;nested=[]};for(let i=1;i<lines.length;i++){const line=lines[i];if(line.trim()==="---"){settle();return{keys,endLine:i+1}}const match=/^([A-Za-z_][\w-]*):\s*(.*)$/.exec(line);if(match){settle();key=match[1];keys.set(key,match[2].trim())}else if(key!==null&&/^(?:\s|-\s)/.test(line)){nested.push(line.trim())}}return null}function nestedValue(head,nested){const scalar=BLOCK_SCALAR.exec(head);if(scalar)return nested.join(scalar[1]==="|"?"\n":" ").trim();if(head!=="")return[head,...nested].join(" ");return nested.map(l=>LIST_ITEM.exec(l)?.[1].trim()??"").filter(Boolean).join(", ")}const FENCE=/^\s{0,3}(`{3,}|~{3,})(.*)$/;function proseLines(lines){const start=frontmatter(lines)?.endLine??0;const prose=[];let fence=null;for(let i=start;i<lines.length;i++){const text=lines[i];const open=FENCE.exec(text);if(fence){if(open&&open[1][0]===fence[0]&&open[1].length>=fence.length&&open[2].trim()===""){fence=null}continue}if(open){fence=open[1];continue}prose.push({line:i+1,text})}return prose}function isGenerated(lines){return lines.slice(0,5).some(l=>/\b(?:auto-?)?generated (?:by|from)\b|@generated\b/i.test(l))}function repoRelative(cwd,file){return path.relative(cwd,file).replace(/\\/g,"/")}function readIfExists(file){try{return fs.readFileSync(file,"utf8")}catch{return null}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.lineLoc=lineLoc;function lineLoc(line,text){return{start:{line,column:1},end:{line,column:text.length+1}}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noCommentedCode=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");function looksLikeCode(comment,isBlockComment){if(isBlockComment&&comment.startsWith("*")){return false}let text=comment;if(isBlockComment){text=text.replace(/^\s*\/\*+/,"").replace(/\*+\/\s*$/,"");text=text.split("\n").map(line=>line.replace(/^\s*\*+\s*/,"")).join("\n")}else{text=text.split("\n").map(line=>line.replace(/^\s*\/\/+\s*/,"")).join("\n")}const lines=text.split("\n").map(line=>line.trim()).filter(line=>line.length>0);if(lines.length===0){return false}const STRUCTURAL_CODE=[/^(const|let|var)\s+[A-Za-z_$][\w$]*(\s*:[^=]+)?\s*=/,/^import\s+[^;]*\bfrom\b/,/^import\s+["']/,/^export\s+(default|const|let|var|function|class|\{|\*)/,/^throw\s+new\s+[A-Za-z_$]/,/^(throw|await|yield)\s+[A-Za-z_$][\w$]*\s*[.([]/,/^return\s+(new|await)\s/,/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\[\s*['"][^'"]+['"]\s*\])+\s*\(/,/=>/,/===|!==/,/^@[A-Za-z_$][\w$]*\s*\(/,/^<[A-Z][\w$]*[\s/>]/];const codePatterns=[/^(const|let|var|function|class|if|for|while|return|import|export)\s
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noCommentedCode=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");function looksLikeCode(comment,isBlockComment){if(isBlockComment&&comment.startsWith("*")){return false}let text=comment;if(isBlockComment){text=text.replace(/^\s*\/\*+/,"").replace(/\*+\/\s*$/,"");text=text.split("\n").map(line=>line.replace(/^\s*\*+\s*/,"")).join("\n")}else{text=text.split("\n").map(line=>line.replace(/^\s*\/\/+\s*/,"")).join("\n")}const lines=text.split("\n").map(line=>line.trim()).filter(line=>line.length>0);if(lines.length===0){return false}const STRUCTURAL_CODE=[/^(const|let|var)\s+[A-Za-z_$][\w$]*(\s*:[^=]+)?\s*=/,/^import\s+[^;]*\bfrom\b/,/^import\s+["']/,/^export\s+(default|const|let|var|function|class|\{|\*)/,/^throw\s+new\s+[A-Za-z_$]/,/^(throw|await|yield)\s+[A-Za-z_$][\w$]*\s*[.([]/,/^return\s+(new|await)\s/,/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\[\s*['"][^'"]+['"]\s*\])+\s*\(/,/=>/,/===|!==/,/^@[A-Za-z_$][\w$]*\s*\(/,/^<[A-Z][\w$]*[\s/>]/];const LABEL_OR_ASSIGN=/^[a-zA-Z_$][a-zA-Z0-9_$]*\s*([=:])\s*/;const BARE_WORD_RUN=/^[A-Za-z_$][\w$]*\s+[A-Za-z_$]/;const codePatterns=[/^(const|let|var|function|class|if|for|while|return|import|export)\s+/,LABEL_OR_ASSIGN,/^[a-zA-Z_$][a-zA-Z0-9_$]*\(/,/^[{}[\]]/];const URL_LINE=/^[a-z][a-z0-9+.-]*:\/\//i;const ENDS_LIKE_CODE=/[;{},()[\]]$|=>$/;let codeLikeLines=0;for(const line of lines){if(/^(TODO|FIXME|HACK|XXX)/i.test(line)){continue}if(URL_LINE.test(line)){continue}if(!STRUCTURAL_CODE.some(pattern=>pattern.test(line))&&!ENDS_LIKE_CODE.test(line)){continue}if(STRUCTURAL_CODE.some(pattern=>pattern.test(line))){codeLikeLines++;continue}for(const pattern of codePatterns){if(pattern===LABEL_OR_ASSIGN){const match=LABEL_OR_ASSIGN.exec(line);if(match&&match[1]===":"&&BARE_WORD_RUN.test(line.slice(match[0].length))){continue}}if(pattern.test(line)){codeLikeLines++;break}}}return codeLikeLines>0}function countCommentLines(comment){if(!comment)return 0;const newlineCount=(comment.match(/\n/g)||[]).length;return newlineCount>0?newlineCount+1:1}exports.noCommentedCode=(0,eslint_devkit_2.createRule)({name:"no-commented-code",skipGeneratedFiles:true,meta:{interop:{runtimes:["eslint","oxlint"]},type:"suggestion",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-conventions/docs/rules/no-commented-code.md",description:"Detects commented-out code blocks"},hasSuggestions:true,messages:{commentedCode:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.WARNING,issueName:"Commented code",description:"Commented-out code detected ({{lines}} lines)",severity:"LOW",fix:"Remove commented code or use version control for history",documentationLink:"https://rules.sonarsource.com/javascript/RSPEC-125/"}),removeCode:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Remove Code",description:"Remove commented code block",severity:"LOW",fix:"Delete the commented code block",documentationLink:"https://rules.sonarsource.com/javascript/RSPEC-125/"}),useVersionControl:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Use Git",description:"Use version control for code history",severity:"LOW",fix:"Delete commented code and use git history instead",documentationLink:"https://git-scm.com/docs/git-log"})},schema:[{type:"object",properties:{ignoreSingleLine:{type:"boolean",default:false,description:"Ignore single-line comments"},ignoreInTests:{type:"boolean",default:true,description:"Ignore comments in test files"},minLines:{type:"number",default:1,minimum:1,description:"Minimum lines of commented code to trigger"}},additionalProperties:false}]},defaultOptions:[{ignoreSingleLine:false,ignoreInTests:true,minLines:1}],createOnce(context,currentOptions){let ignoreSingleLine;let ignoreInTests;let minLines;let sourceCode;function checkComment(node){try{const commentText=node.value||"";const isBlockComment=node.type==="Block";const lines=countCommentLines(commentText);if(ignoreSingleLine&&lines===1&&!isBlockComment){return}if(lines<minLines){return}if(looksLikeCode(commentText,isBlockComment)){context.report({node,messageId:"commentedCode",data:{lines:String(lines)},suggest:[{messageId:"removeCode",fix:fixer=>{try{return fixer.remove(node)}catch{return null}}},{messageId:"useVersionControl",fix:()=>null}]})}}catch{return}}function hasCodeBetween(before,after){const nextToken=sourceCode.getTokenAfter(before,{includeComments:false});return nextToken!==null&&nextToken.range[0]<after.range[0]}return{before(){const[options={}]=currentOptions();({ignoreSingleLine=false,ignoreInTests=true,minLines=1}=options||{});const filename=context.filename;const isTestFile=ignoreInTests&&/\.(test|spec)\.[cm]?[jt]sx?$/.test(filename);if(isTestFile){return false}sourceCode=context.sourceCode;return true},Program(){const comments=sourceCode.getAllComments();const groupedComments=[];let currentGroup=[];for(let i=0;i<comments.length;i++){const comment=comments[i];const commentText=comment.value||"";const isBlockComment=comment.type==="Block";if(looksLikeCode(commentText,isBlockComment)){const previous=currentGroup[currentGroup.length-1];if(previous&&hasCodeBetween(previous,comment)){groupedComments.push([...currentGroup]);currentGroup=[]}currentGroup.push(comment)}else{if(currentGroup.length>0){groupedComments.push([...currentGroup]);currentGroup=[]}}}if(currentGroup.length>0){groupedComments.push(currentGroup)}groupedComments.forEach(group=>{if(group.length===1){checkComment(group[0])}else{const firstComment=group[0];const totalLines=group.reduce((sum,comment)=>{const commentText=comment.value||"";return sum+countCommentLines(commentText)},0);if(totalLines>=minLines){context.report({node:firstComment,messageId:"commentedCode",data:{lines:String(totalLines)},suggest:[{messageId:"removeCode",fix:fixer=>{try{return fixer.removeRange([group[0].range[0],group[group.length-1].range[1]])}catch{return null}}},{messageId:"useVersionControl",fix:()=>null}]})}}})}}}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.enforcedRuleInProse=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const guidance_files_1=require("../../lib/guidance-files");const report_loc_1=require("../../lib/report-loc");const EMPHASIS=String.raw`(?:\*\*|__|_|\*)?`;const IMPERATIVE=new RegExp([String.raw`[.;:!?(—–]\s*${EMPHASIS}(?:IMPORTANT|NEVER|ALWAYS|MUST|[Nn]ever|[Aa]lways|[Dd]o not|[Dd]on't|[Mm]ust not)\b`,String.raw`^\s*(?:(?:[-*+]|\d+[.)])\s+)?${EMPHASIS}(?:IMPORTANT|NEVER|ALWAYS|MUST|Never|Always|Do not|Don't|Must not)\b`,String.raw`\b(?:[Yy]ou|[Aa]gents?|Claude|[Ww]e)\s+(?:must|should never|must not|may not)\b`].join("|"));const CHECKABLE=/`[^`]+`|(?:^|\s)--[a-z][\w-]+|\b[\w.-]+\.(?:json|jsonc|ya?ml|[cm]?[jt]sx?|toml|sh|lock)\b/;const LINK=/\[[^\]]*\]\(([^)\s]+)[^)]*\)/g;const LEVER=/(?:eslint|oxlint|lint|lefthook|husky|hooks?\b|hooks\/|pre-commit|pre-push|\.test\.|\.spec\.|lock|gate|\.github\/workflows|rules\/|settings\.json|commitlint)/i;const DOCS="https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-conventions/docs/rules/enforced-rule-in-prose.md";exports.enforcedRuleInProse=(0,eslint_devkit_1.createRule)({name:"enforced-rule-in-prose",meta:{interop:{runtimes:["eslint"]},type:"suggestion",docs:{url:DOCS,description:"Report never/always lines in agent guidance that a tool could enforce, unlinked to the tool that does"},messages:{unenforced:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.QUALITY,issueName:"Rule Held Only by Prose",description:"An imperative guidance line names something a tool could check, and links no rule, hook, lock test or gate that enforces it",severity:"MEDIUM",fix:"Enforce it with a tool \u2014 a lint rule, a lefthook or Claude Code hook, a lock test or a CI gate \u2014 then link that lever from this line or delete the line. If no tool can check it, reword it without the checkable target.",documentationLink:DOCS}),removable:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.QUALITY,issueName:"Rule Already Enforced by a Tool",description:"This imperative line links the tool that enforces it, so the tool holds the rule and the always-loaded line repeats it",severity:"LOW",fix:"Delete the line; the linked lever reports the violation with its own fix. Keep it only if the line says something the tool output does not.",documentationLink:DOCS})},schema:[]},defaultOptions:[],createOnce(context){return{before(){return(0,guidance_files_1.guidanceKind)(context.filename)!==null},root(){const lines=context.sourceCode.text.split("\n");if((0,guidance_files_1.isGenerated)(lines))return;for(const{line,text}of(0,guidance_files_1.proseLines)(lines)){if(!IMPERATIVE.test(text))continue;const withoutLinks=text.replace(LINK," ");if(!CHECKABLE.test(withoutLinks))continue;const targets=[...text.matchAll(LINK)].map(m=>m[1]);context.report({loc:(0,report_loc_1.lineLoc)(line,text),messageId:targets.some(t=>LEVER.test(t))?"removable":"unenforced"})}}}}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?(function(o,m,k,k2){if(k2===void 0)k2=k;var desc=Object.getOwnPropertyDescriptor(m,k);if(!desc||("get"in desc?!m.__esModule:desc.writable||desc.configurable)){desc={enumerable:true,get:function(){return m[k]}}}Object.defineProperty(o,k2,desc)}):(function(o,m,k,k2){if(k2===void 0)k2=k;o[k2]=m[k]}));var __setModuleDefault=this&&this.__setModuleDefault||(Object.create?(function(o,v){Object.defineProperty(o,"default",{enumerable:true,value:v})}):function(o,v){o["default"]=v});var __importStar=this&&this.__importStar||(function(){var ownKeys=function(o){ownKeys=Object.getOwnPropertyNames||function(o2){var ar=[];for(var k in o2)if(Object.prototype.hasOwnProperty.call(o2,k))ar[ar.length]=k;return ar};return ownKeys(o)};return function(mod){if(mod&&mod.__esModule)return mod;var result={};if(mod!=null){for(var k=ownKeys(mod),i=0;i<k.length;i++)if(k[i]!=="default")__createBinding(result,mod,k[i])}__setModuleDefault(result,mod);return result}})();Object.defineProperty(exports,"__esModule",{value:true});exports.guidanceBudget=void 0;const path=__importStar(require("node:path"));const eslint_devkit_1=require("@interlace/eslint-devkit");const guidance_files_1=require("../../lib/guidance-files");const report_loc_1=require("../../lib/report-loc");const DOCS="https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-conventions/docs/rules/guidance-budget.md";exports.guidanceBudget=(0,eslint_devkit_1.createRule)({name:"guidance-budget",meta:{interop:{runtimes:["eslint"]},type:"suggestion",docs:{url:DOCS,description:"Keep always-loaded agent guidance (CLAUDE.md, AGENTS.md) and skills inside a ratcheted size budget"},messages:{overBudget:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.QUALITY,issueName:"Guidance Over Budget",description:"This {{kind}} file is {{actual}} {{measure}}, over its budget of {{budget}}",severity:"MEDIUM",fix:"Move what a tool can enforce into a lint rule, hook or lock test and delete the line; move procedures into a skill; link to docs instead of restating them. Raise a budget only by decision.",documentationLink:DOCS}),looseRatchet:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.QUALITY,issueName:"Guidance Ratchet Can Tighten",description:"This file is {{actual}} {{measure}} and its ratchet entry still allows {{budget}}",severity:"LOW",fix:"Lower the entry for {{file}} in {{ratchetFile}} to {{actual}} so the space cannot be refilled.",documentationLink:DOCS})},schema:[{type:"object",properties:{memoryBytes:{type:"integer",minimum:1},memoryLines:{type:"integer",minimum:1},skillLines:{type:"integer",minimum:1},descriptionChars:{type:"integer",minimum:1},ratchetFile:{type:"string"}},additionalProperties:false}]},defaultOptions:[{memoryBytes:4096,memoryLines:200,skillLines:500,descriptionChars:1024,ratchetFile:".guidance-budget.json"}],createOnce(context,options){return{before(){return(0,guidance_files_1.guidanceKind)(context.filename)!==null},root(){const kind=(0,guidance_files_1.guidanceKind)(context.filename);const[opts]=options();const ratchetFile=opts.ratchetFile;const ratchet=readRatchet(path.resolve(context.cwd,ratchetFile));const file=(0,guidance_files_1.repoRelative)(context.cwd,context.filename);const entry=ratchet[file]??{};const text=context.sourceCode.text;const lines=text.split("\n");const measured=[];if(kind==="memory"){measured.push(["bytes",Buffer.byteLength(text,"utf8"),opts.memoryBytes,1]);measured.push(["lines",lines.length,opts.memoryLines,1])}else{const front=(0,guidance_files_1.frontmatter)(lines);const bodyLines=lines.length-(front?.endLine??0);measured.push(["lines",bodyLines,opts.skillLines,1]);const description=front?.keys.get("description");if(description!==void 0){measured.push(["descriptionChars",description.length,opts.descriptionChars,lineOf(lines,"description:")])}}for(const[measure,actual,fallback,line]of measured){const ratcheted=entry[measure];const budget=ratcheted??fallback;const data={kind,measure,actual:String(actual),budget:String(budget),file,ratchetFile};const loc=(0,report_loc_1.lineLoc)(line,lines[line-1]);if(actual>budget){context.report({loc,messageId:"overBudget",data})}else if(ratcheted!==void 0&&ratcheted>fallback&&actual<ratcheted){context.report({loc,messageId:"looseRatchet",data})}}}}}});function lineOf(lines,prefix){return lines.findIndex(l=>l.startsWith(prefix))+1}const MEASURES=new Set(["bytes","lines","descriptionChars"]);function readRatchet(file){const text=(0,guidance_files_1.readIfExists)(file);if(text===null)return{};const fail=why=>{throw new Error(`guidance-budget: ${file} ${why}. fix: repair it, or delete it to fall back to the default budgets.`)};let parsed;try{parsed=JSON.parse(text)}catch(error){fail(`is not valid JSON (${error.message})`)}if(!isObject(parsed))fail("is not a JSON object of file entries");for(const[entryFile,entry]of Object.entries(parsed)){if(!isObject(entry))fail(`has a non-object entry for ${entryFile}`);for(const[measure,value]of Object.entries(entry)){if(!MEASURES.has(measure)||!Number.isInteger(value)||value<0){fail(`has ${entryFile}.${measure} = ${JSON.stringify(value)}; each entry holds bytes, lines or descriptionChars as a whole number`)}}}return parsed}function isObject(value){return typeof value==="object"&&value!==null&&!Array.isArray(value)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?(function(o,m,k,k2){if(k2===void 0)k2=k;var desc=Object.getOwnPropertyDescriptor(m,k);if(!desc||("get"in desc?!m.__esModule:desc.writable||desc.configurable)){desc={enumerable:true,get:function(){return m[k]}}}Object.defineProperty(o,k2,desc)}):(function(o,m,k,k2){if(k2===void 0)k2=k;o[k2]=m[k]}));var __setModuleDefault=this&&this.__setModuleDefault||(Object.create?(function(o,v){Object.defineProperty(o,"default",{enumerable:true,value:v})}):function(o,v){o["default"]=v});var __importStar=this&&this.__importStar||(function(){var ownKeys=function(o){ownKeys=Object.getOwnPropertyNames||function(o2){var ar=[];for(var k in o2)if(Object.prototype.hasOwnProperty.call(o2,k))ar[ar.length]=k;return ar};return ownKeys(o)};return function(mod){if(mod&&mod.__esModule)return mod;var result={};if(mod!=null){for(var k=ownKeys(mod),i=0;i<k.length;i++)if(k[i]!=="default")__createBinding(result,mod,k[i])}__setModuleDefault(result,mod);return result}})();Object.defineProperty(exports,"__esModule",{value:true});exports.noDuplicatedGuidance=void 0;exports.normalizeGuidance=normalizeGuidance;const path=__importStar(require("node:path"));const eslint_devkit_1=require("@interlace/eslint-devkit");const guidance_files_1=require("../../lib/guidance-files");const report_loc_1=require("../../lib/report-loc");const MEMORY_NAMES=["AGENTS.md","CLAUDE.md","CLAUDE.local.md","GEMINI.md"];const DOCS="https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-conventions/docs/rules/no-duplicated-guidance.md";function normalizeGuidance(text){return text.replace(/^\s*(?:[-*+]|\d+[.)])\s+/,"").replace(/[*_`>#]/g,"").replace(/\s+/g," ").trim().toLowerCase()}exports.noDuplicatedGuidance=(0,eslint_devkit_1.createRule)({name:"no-duplicated-guidance",meta:{interop:{runtimes:["eslint"]},type:"suggestion",docs:{url:DOCS,description:"Disallow the same guidance line in two always-loaded agent files (CLAUDE.md, AGENTS.md, GEMINI.md) of one repo"},messages:{duplicated:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.QUALITY,issueName:"Duplicated Guidance",description:"This line also appears in {{other}}:{{otherLine}}, which is loaded in the same sessions",severity:"LOW",fix:"Keep the line in one file and delete it here. If this file must stand alone, import the other (`@AGENTS.md`) instead of copying from it.",documentationLink:DOCS})},schema:[{type:"object",properties:{minLength:{type:"integer",minimum:1}},additionalProperties:false}]},defaultOptions:[{minLength:40}],createOnce(context,options){return{before(){return(0,guidance_files_1.guidanceKind)(context.filename)==="memory"},root(){const minLength=options()[0].minLength;const self=path.resolve(context.filename);const selfKey=(0,guidance_files_1.repoRelative)(context.cwd,self);const seen=new Map;for(const other of companions(self,context.cwd)){const otherKey=(0,guidance_files_1.repoRelative)(context.cwd,other);const sameDir=path.dirname(other)===path.dirname(self);if(sameDir&&otherKey>selfKey)continue;const text=(0,guidance_files_1.readIfExists)(other);if(text===null)continue;for(const{line,text:lineText}of(0,guidance_files_1.proseLines)(text.split("\n"))){const key=normalizeGuidance(lineText);if(key.length<minLength||seen.has(key))continue;seen.set(key,{file:otherKey,line})}}const lines=context.sourceCode.text.split("\n");for(const{line,text}of(0,guidance_files_1.proseLines)(lines)){const match=seen.get(normalizeGuidance(text));if(!match)continue;context.report({loc:(0,report_loc_1.lineLoc)(line,text),messageId:"duplicated",data:{other:match.file,otherLine:String(match.line)}})}}}}});function companions(file,cwd){const found=[];const root=path.resolve(cwd);let dir=path.dirname(file);for(;;){for(const name of MEMORY_NAMES){const candidate=path.join(dir,name);if(candidate!==file)found.push(candidate)}if(dir===root||!dir.startsWith(root+path.sep))break;dir=path.dirname(dir)}return found}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.procedureInMemory=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const guidance_files_1=require("../../lib/guidance-files");const report_loc_1=require("../../lib/report-loc");const STEP=/^(\s{0,3})\d{1,3}[.)]\s+\S/;const DOCS="https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-conventions/docs/rules/procedure-in-memory.md";exports.procedureInMemory=(0,eslint_devkit_1.createRule)({name:"procedure-in-memory",meta:{interop:{runtimes:["eslint"]},type:"suggestion",docs:{url:DOCS,description:"Disallow long numbered procedures in always-loaded agent guidance; move them to a skill"},messages:{procedureInMemory:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.QUALITY,issueName:"Procedure in Always-Loaded Guidance",description:"A {{steps}}-step numbered procedure sits in a file read on every session (limit {{maxSteps}})",severity:"LOW",fix:"Move the procedure into a skill (.claude/skills/<name>/SKILL.md) whose description names when it applies, and leave at most a one-line pointer here.",documentationLink:DOCS})},schema:[{type:"object",properties:{maxSteps:{type:"integer",minimum:1}},additionalProperties:false}]},defaultOptions:[{maxSteps:5}],createOnce(context,options){return{before(){return(0,guidance_files_1.guidanceKind)(context.filename)==="memory"},root(){const maxSteps=options()[0].maxSteps;const lines=context.sourceCode.text.split("\n");let first=null;let indent=0;let steps=0;let previous=0;const flush=()=>{if(first&&steps>maxSteps){context.report({loc:(0,report_loc_1.lineLoc)(first.line,first.text),messageId:"procedureInMemory",data:{steps:String(steps),maxSteps:String(maxSteps)}})}first=null;steps=0};for(const prose of(0,guidance_files_1.proseLines)(lines)){if(prose.line>previous+1&&!/^\s/.test(lines[previous])){flush()}previous=prose.line;const step=STEP.exec(prose.text);if(step&&(first===null||step[1].length<indent+2)){if(first===null){first=prose;indent=step[1].length}steps++}else if(!(prose.text.trim()===""||/^\s{2,}\S/.test(prose.text))){flush()}}flush()}}}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.subagentDeclaresModel=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const guidance_files_1=require("../../lib/guidance-files");const report_loc_1=require("../../lib/report-loc");const DOCS="https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-conventions/docs/rules/subagent-declares-model.md";exports.subagentDeclaresModel=(0,eslint_devkit_1.createRule)({name:"subagent-declares-model",meta:{interop:{runtimes:["eslint"]},type:"suggestion",docs:{url:DOCS,description:"Require every .claude/agents/*.md subagent to declare a model and a tool allowlist in its frontmatter"},messages:{missingKey:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.QUALITY,issueName:"Subagent Without {{key}}",description:"This subagent has no `{{key}}:` in its frontmatter, so it inherits {{inherits}}",severity:"MEDIUM",fix:"{{fix}}",documentationLink:DOCS})},schema:[]},defaultOptions:[],createOnce(context){return{before(){return(0,guidance_files_1.guidanceKind)(context.filename)==="agent"},root(){const lines=context.sourceCode.text.split("\n");const keys=(0,guidance_files_1.frontmatter)(lines)?.keys??new Map;const loc=(0,report_loc_1.lineLoc)(1,lines[0]);if(!keys.get("model")){context.report({loc,messageId:"missingKey",data:{key:"model",inherits:"the parent session's model",fix:"Add `model: haiku` (or sonnet / opus) to the frontmatter: the cheapest model that does the narrow task well."}})}if(!keys.get("tools")){context.report({loc,messageId:"missingKey",data:{key:"tools",inherits:"every tool, including the ones that write",fix:"Add `tools: Read, Grep, Glob` (the tools the task needs, and no more) to the frontmatter."}})}}}}});
|