eslint-plugin-conventions 7.0.2 → 7.0.4
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 +63 -0
- package/README.md +27 -41
- package/package.json +3 -2
- package/src/index.js +1 -1
package/AGENTS.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<!-- Generated by scripts/generate-plugin-agents-md.ts from package.json and the plugin exports. Do not edit by hand; run `npm run agents-md`. -->
|
|
2
|
+
|
|
3
|
+
# eslint-plugin-conventions
|
|
4
|
+
|
|
5
|
+
Guide for AI coding assistants using this plugin in a project. To change the plugin's own source, read https://github.com/ofri-peretz/eslint/blob/main/AGENTS.md instead.
|
|
6
|
+
|
|
7
|
+
> ESLint conventions rules for team code — enforces filename case, magic-number bans, commented-out code, expiring TODOs, and deprecated-API usage.
|
|
8
|
+
|
|
9
|
+
## Enable it
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install --save-dev eslint-plugin-conventions
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Requires ESLint ^8.40.0 || ^9.0.0 || ^10.0.0 and Node >=22.13.0.
|
|
16
|
+
|
|
17
|
+
Flat config files (`eslint.config.*`) are found by ESLint 8.57 and newer; on ESLint 9 and 10 they are the default.
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
// eslint.config.mjs
|
|
21
|
+
import conventions from 'eslint-plugin-conventions';
|
|
22
|
+
|
|
23
|
+
export default [conventions.configs.recommended];
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Each preset is one flat config object: put it in the array as an element, do not spread it. Rule ids are prefixed `conventions/`. Add it to the config you already have; do not remove other plugins. TypeScript files need a TypeScript parser in the config (`typescript-eslint`).
|
|
27
|
+
|
|
28
|
+
## Presets
|
|
29
|
+
|
|
30
|
+
| Preset | Rules | Errors | Warnings |
|
|
31
|
+
| ------------- | ----- | ------ | -------- |
|
|
32
|
+
| `recommended` | 6 | 3 | 3 |
|
|
33
|
+
|
|
34
|
+
### `recommended`
|
|
35
|
+
|
|
36
|
+
6 rules:
|
|
37
|
+
|
|
38
|
+
- `no-commented-code` (warn): Detects commented-out code blocks.
|
|
39
|
+
- `expiring-todo-comments` (warn): Add expiration conditions to TODO comments to prevent forgotten tasks.
|
|
40
|
+
- `no-deprecated-api` (warn): Prevent usage of deprecated APIs with migration context.
|
|
41
|
+
- `utm-taxonomy` (error): Validate utm_source and utm_medium values against the fixed taxonomy in UTM_PHILOSOPHY.md.
|
|
42
|
+
- `no-raw-cross-property-href` (error): Forbid hand-written cross-property hrefs; use buildUtmHref() from lib/utm.ts.
|
|
43
|
+
- `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
|
+
### Rules in no preset
|
|
46
|
+
|
|
47
|
+
Enable these by name (`'conventions/<rule>': 'error'`):
|
|
48
|
+
|
|
49
|
+
- `prefer-code-point`: Prefer codePointAt over charCodeAt for proper Unicode character handling.
|
|
50
|
+
- `prefer-dom-node-text-content`: Prefer textContent over innerText for better performance and reliability.
|
|
51
|
+
- `no-console-spaces`: Prevent leading/trailing space between console.log parameters.
|
|
52
|
+
- `prefer-dependency-version-strategy`: Enforce consistent version strategy (caret, tilde, exact, etc.) for package.json dependencies.
|
|
53
|
+
- `filename-case`: Enforce filename case conventions for consistency.
|
|
54
|
+
- `consistent-existence-index-check`: Enforce consistent style for checking object property existence.
|
|
55
|
+
- `no-json-schema-tags`: Disallow JSON Schema keywords used as JSDoc tags (e.g. @minimum, @maximum).
|
|
56
|
+
- `require-data-testid`: Require stable `data-testid` attributes on interactive elements and custom components for testability.
|
|
57
|
+
- `no-magic-numbers`: Disallow magic numbers (numeric literals without a named constant).
|
|
58
|
+
|
|
59
|
+
## More
|
|
60
|
+
|
|
61
|
+
- Docs: https://eslint.interlace.tools/docs/quality/plugin-conventions
|
|
62
|
+
- README.md in this package: every rule with examples.
|
|
63
|
+
- `eslint-plugin-conventions/oxlint` is an entry point for oxlint's JS plugin support; see the README.
|
package/README.md
CHANGED
|
@@ -20,7 +20,28 @@
|
|
|
20
20
|
<a href="https://scorecard.dev/viewer/?uri=github.com/ofri-peretz/eslint" target="_blank"><img src="https://api.securityscorecards.dev/projects/github.com/ofri-peretz/eslint/badge" alt="OpenSSF Scorecard" /></a>
|
|
21
21
|
</p>
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
## Getting Started
|
|
24
|
+
|
|
25
|
+
- To check out the [guide](https://eslint.interlace.tools/docs/quality/plugin-conventions?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-conventions), visit [eslint.interlace.tools](https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-conventions). 📚
|
|
26
|
+
|
|
27
|
+
<!-- AUTO-GENERATED:INSTALL:START - Do not edit manually -->
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install --save-dev eslint eslint-plugin-conventions
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
// eslint.config.mjs
|
|
35
|
+
import { configs } from 'eslint-plugin-conventions';
|
|
36
|
+
|
|
37
|
+
export default [configs.recommended];
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`recommended` is the preset to start with. The others are listed under Configuration Presets below.
|
|
41
|
+
|
|
42
|
+
Using oxlint or Vite+? Install `oxlint-plugin-conventions`: the same rules under the same `conventions/<rule>` IDs, without ESLint. Its [page](https://www.npmjs.com/package/oxlint-plugin-conventions) has the setup.
|
|
43
|
+
|
|
44
|
+
<!-- AUTO-GENERATED:INSTALL:END -->
|
|
24
45
|
|
|
25
46
|
## Description
|
|
26
47
|
|
|
@@ -42,40 +63,6 @@ That trade costs recall, and we measure it:
|
|
|
42
63
|
|
|
43
64
|
<!-- AUTO-GENERATED:DOCTRINE:END -->
|
|
44
65
|
|
|
45
|
-
## Getting Started
|
|
46
|
-
|
|
47
|
-
- To check out the [guide](https://eslint.interlace.tools/docs/quality/plugin-conventions?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-conventions), visit [eslint.interlace.tools](https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-conventions). 📚
|
|
48
|
-
|
|
49
|
-
<!-- AUTO-GENERATED:INSTALL:START - Do not edit manually -->
|
|
50
|
-
|
|
51
|
-
**oxlint / Vite+** — the same rules under the same `conventions/<rule>` IDs, without ESLint:
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
npm install oxlint-plugin-conventions --save-dev
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
```jsonc
|
|
58
|
-
// .oxlintrc.json
|
|
59
|
-
{ "jsPlugins": ["oxlint-plugin-conventions"] }
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
```ts
|
|
63
|
-
// vite.config.ts
|
|
64
|
-
import { defineConfig } from 'vite-plus';
|
|
65
|
-
|
|
66
|
-
export default defineConfig({
|
|
67
|
-
lint: { jsPlugins: ['oxlint-plugin-conventions'] },
|
|
68
|
-
});
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
**ESLint:**
|
|
72
|
-
|
|
73
|
-
```bash
|
|
74
|
-
npm install eslint-plugin-conventions --save-dev
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
<!-- AUTO-GENERATED:INSTALL:END -->
|
|
78
|
-
|
|
79
66
|
## ⚙️ Configuration Presets
|
|
80
67
|
| Preset | Description |
|
|
81
68
|
| :------------ | :---------------------------------- |
|
|
@@ -123,13 +110,13 @@ See the [ESLint Version Support Policy](../../docs/ESLINT_VERSION_SUPPORT.md)
|
|
|
123
110
|
| [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 | 🟢 | | | | 💡 | |
|
|
124
111
|
| [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… | 🟢 | | ⚠️ | | 💡 | |
|
|
125
112
|
| [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 | 🟢 | | | | 💡 | |
|
|
126
|
-
| [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) | | | |
|
|
127
|
-
| [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. | 🟢 | | | |
|
|
113
|
+
| [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. | 🟢 | | ⚠️ | | 💡 | |
|
|
114
|
+
| [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. | 🟢 | | | | | |
|
|
128
115
|
| [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… | 🟢 | | ⚠️ | | 💡 | |
|
|
129
116
|
| [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. | 🟢 | | | | 💡 | |
|
|
130
117
|
| [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) | 🟢 | | | | 💡 | |
|
|
131
118
|
| [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 | 🟢 | 💼 | | | | |
|
|
132
|
-
| [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. | 🟢 | | | |
|
|
119
|
+
| [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. | 🟢 | | | | | |
|
|
133
120
|
| [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.… | 🟢 | | | | 💡 | |
|
|
134
121
|
| [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. | 🟢 | | | | 💡 | |
|
|
135
122
|
| [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 | 🟢 | | | | 💡 | |
|
|
@@ -184,11 +171,10 @@ Part of the **Interlace ESLint ecosystem** — AI-native rules with LLM-optimize
|
|
|
184
171
|
<!-- AUTO-GENERATED:ECOSYSTEM_TABLE:END -->
|
|
185
172
|
|
|
186
173
|
<!-- INTERLACE:STAR_CTA:START -->
|
|
187
|
-
## ⭐ Support & follow
|
|
188
174
|
|
|
189
|
-
|
|
175
|
+
## Support
|
|
190
176
|
|
|
191
|
-
[
|
|
177
|
+
Found a false positive? [Open an issue](https://github.com/ofri-peretz/eslint/issues): that is a bug. If the plugin helped, a star on [ofri-peretz/eslint](https://github.com/ofri-peretz/eslint) helps others find it.
|
|
192
178
|
|
|
193
179
|
<!-- INTERLACE:STAR_CTA:END -->
|
|
194
180
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-conventions",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.4",
|
|
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,
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"files": [
|
|
25
25
|
"src/",
|
|
26
26
|
"README.md",
|
|
27
|
-
"LICENSE"
|
|
27
|
+
"LICENSE",
|
|
28
|
+
"AGENTS.md"
|
|
28
29
|
],
|
|
29
30
|
"keywords": [
|
|
30
31
|
"eslint",
|
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.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.4"},rules:exports.rules};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"}}};exports.default=exports.plugin;
|