eslint-plugin-conventions 4.2.8 → 4.2.10
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/README.md +40 -0
- package/package.json +2 -2
- package/src/index.js +1 -1
- package/src/rules/conventions/analytics-event-naming.js +1 -1
- package/src/rules/conventions/no-commented-code.js +1 -1
- package/src/rules/conventions/no-raw-cross-property-href.js +1 -1
- package/src/rules/conventions/utm-taxonomy.js +1 -1
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
<a href="https://opensource.org/licenses/MIT" target="_blank"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="Package License" /></a>
|
|
17
17
|
<a href="https://app.codecov.io/gh/ofri-peretz/eslint/components?components%5B0%5D=eslint-plugin-conventions" target="_blank"><img src="https://codecov.io/gh/ofri-peretz/eslint/graph/badge.svg?component=eslint-plugin-conventions" alt="Codecov" /></a>
|
|
18
18
|
<a href="https://github.com/ofri-peretz/eslint" target="_blank"><img src="https://img.shields.io/badge/Since-Dec_2025-blue?logo=rocket&logoColor=white" alt="Since Dec 2025" /></a>
|
|
19
|
+
<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>
|
|
19
20
|
</p>
|
|
20
21
|
|
|
21
22
|
> ⭐ If this plugin caught a real bug for you, [**star the repo**](https://github.com/ofri-peretz/eslint) — it's the signal that keeps these rules maintained.
|
|
@@ -28,6 +29,45 @@ This plugin provides Project conventions: naming, file structure, and code style
|
|
|
28
29
|
|
|
29
30
|
**Interlace** fosters **strength through integration**. Instead of stacking isolated rules, we **interlace** security directly into your workflow to create a resilient fabric of code. We believe tools should **guide rather than gatekeep**, providing educational feedback that strengthens the developer with every interaction.
|
|
30
31
|
|
|
32
|
+
<!-- AUTO-GENERATED:DOCTRINE:START - Do not edit manually -->
|
|
33
|
+
|
|
34
|
+
## Why these rules are quiet
|
|
35
|
+
|
|
36
|
+
**Noise creates apathy, and apathy is not a security posture.** A linter that reports
|
|
37
|
+
a thousand things a week gets switched off in a month, and the real finding goes with
|
|
38
|
+
it. So every rule here is built to be worth reading: we would rather miss a finding
|
|
39
|
+
than spend your attention on one that was never real.
|
|
40
|
+
|
|
41
|
+
That is a trade, and it is made deliberately. It costs recall, and we measure what it
|
|
42
|
+
costs rather than assuming it is free.
|
|
43
|
+
|
|
44
|
+
## How the rules decide
|
|
45
|
+
|
|
46
|
+
**Evidence, not names.** A rule fires on what the code *does*, resolved through the
|
|
47
|
+
AST and ESLint's own scope analysis — not on an identifier that happens to contain
|
|
48
|
+
`query`, a method called `setItem`, or a file whose path contains `key`. Every one of
|
|
49
|
+
those was a real false positive in this ecosystem, found by reading our own output on
|
|
50
|
+
open-source projects and fixed with a test that fails on the unfixed rule.
|
|
51
|
+
|
|
52
|
+
Where a rule has known false-positive shapes, its page carries a **Not a finding**
|
|
53
|
+
section: what it deliberately stays quiet on, and what to check first when it fires
|
|
54
|
+
and you disagree.
|
|
55
|
+
|
|
56
|
+
## What you get
|
|
57
|
+
|
|
58
|
+
The rules below. Security rules carry a CWE mapping and, where one is assigned, a
|
|
59
|
+
CVSS score; every rule carries a fix on its message — in prose for a human and as
|
|
60
|
+
structured JSON for an agent. Install it, enable
|
|
61
|
+
`recommended`, and read the findings. If one of them is wrong,
|
|
62
|
+
[open an issue](https://github.com/ofri-peretz/eslint/issues) — a false positive is a
|
|
63
|
+
bug here, not a tuning exercise for you.
|
|
64
|
+
|
|
65
|
+
How that is measured, on which projects, and where it falls short:
|
|
66
|
+
[benchmark methodology](https://github.com/ofri-peretz/eslint/blob/main/BENCHMARK-METHODOLOGY.md)
|
|
67
|
+
and [results](https://github.com/ofri-peretz/eslint/blob/main/BENCHMARK-RESULTS.md).
|
|
68
|
+
|
|
69
|
+
<!-- AUTO-GENERATED:DOCTRINE:END -->
|
|
70
|
+
|
|
31
71
|
## Getting Started
|
|
32
72
|
|
|
33
73
|
- 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). 📚
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-conventions",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.10",
|
|
4
4
|
"description": "ESLint plugin for team code conventions — enforces filename case, magic-number bans, commented-out code, expiring TODOs, and deprecated-API usage.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"node": ">=18.0.0"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@interlace/eslint-devkit": "^1.
|
|
53
|
+
"@interlace/eslint-devkit": "^1.12.0"
|
|
54
54
|
},
|
|
55
55
|
"repository": {
|
|
56
56
|
"type": "git",
|
package/src/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.configs=exports.plugin=exports.rules=void 0;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}};exports.plugin={meta:{name:"eslint-plugin-conventions",version:"4.2.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.configs=exports.plugin=exports.rules=void 0;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}};exports.plugin={meta:{name:"eslint-plugin-conventions",version:"4.2.10"},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","conventions/no-magic-numbers":"warn"}}};exports.default=exports.plugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.analyticsEventNaming=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const ACTION_VERBS=["click","submit","view","add","remove","start","end","generate","send","cancel","fail","create","delete","update","invite"].join("|");const EVENT_NAME_RE=new RegExp(`^[a-z][a-z0-9_]*:[a-z][a-z0-9_]*_(${ACTION_VERBS})$|^\\$[a-z_]+$`);exports.analyticsEventNaming=(0,eslint_devkit_1.createRule)({name:"analytics-event-naming",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-conventions/docs/rules/analytics-event-naming.md",description:"Analytics event names (track/capture) must follow ANALYTICS_PHILOSOPHY.md principle 4: lowercase snake_case, category:object_action, fixed verb list"},fixable:void 0,hasSuggestions:false,messages:{invalidEventName:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Invalid analytics event name",description:'Event "{{name}}" does not match category:object_action grammar (lowercase snake_case, action from fixed verb list).',severity:"HIGH",fix:"Rename to match `<category>:<object>_<verb>` where verb \u2208 {click, submit, view, add, remove, start, end, generate, send, cancel, fail, create, delete, update, invite}. Vendor reserved events ($pageview, $set, \u2026) are exempt.",documentationLink:"https://github.com/ofri-peretz/
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.analyticsEventNaming=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const ACTION_VERBS=["click","submit","view","add","remove","start","end","generate","send","cancel","fail","create","delete","update","invite"].join("|");const EVENT_NAME_RE=new RegExp(`^[a-z][a-z0-9_]*:[a-z][a-z0-9_]*_(${ACTION_VERBS})$|^\\$[a-z_]+$`);exports.analyticsEventNaming=(0,eslint_devkit_1.createRule)({name:"analytics-event-naming",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-conventions/docs/rules/analytics-event-naming.md",description:"Analytics event names (track/capture) must follow ANALYTICS_PHILOSOPHY.md principle 4: lowercase snake_case, category:object_action, fixed verb list"},fixable:void 0,hasSuggestions:false,messages:{invalidEventName:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Invalid analytics event name",description:'Event "{{name}}" does not match category:object_action grammar (lowercase snake_case, action from fixed verb list).',severity:"HIGH",fix:"Rename to match `<category>:<object>_<verb>` where verb \u2208 {click, submit, view, add, remove, start, end, generate, send, cancel, fail, create, delete, update, invite}. Vendor reserved events ($pageview, $set, \u2026) are exempt.",documentationLink:"https://github.com/ofri-peretz/interlace/blob/main/docs/philosophies/ANALYTICS_PHILOSOPHY.md"}),interpolatedEventName:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Interpolated analytics event name",description:"Event names must be static string literals. Template literals create an unbounded catalog (ANALYTICS_PHILOSOPHY.md principle 3).",severity:"HIGH",fix:"Move the dynamic part into an event property: track('category:object_view', { slug }).",documentationLink:"https://github.com/ofri-peretz/interlace/blob/main/docs/philosophies/ANALYTICS_PHILOSOPHY.md"})},schema:[]},defaultOptions:[],create(context){function isCaptureLike(node){if(node.callee.type==="MemberExpression"&&node.callee.property.type==="Identifier"&&(node.callee.property.name==="capture"||node.callee.property.name==="track")){return true}if(node.callee.type==="Identifier"&&node.callee.name==="track"){return true}return false}return{CallExpression(node){if(!isCaptureLike(node)||node.arguments.length===0)return;const first=node.arguments[0];if(first.type==="Literal"&&typeof first.value==="string"){if(!EVENT_NAME_RE.test(first.value)){context.report({node:first,messageId:"invalidEventName",data:{name:first.value}})}return}if(first.type==="TemplateLiteral"&&first.expressions.length>0){context.report({node:first,messageId:"interpolatedEventName"})}}}}});
|
|
@@ -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){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 codePatterns=[/^(const|let|var|function|class|if|for|while|return|import|export)\s+/,/^[a-zA-Z_$][a-zA-Z0-9_$]*\s*[=:]\s*/,/^[a-zA-Z_$][a-zA-Z0-9_$]*\
|
|
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){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 codePatterns=[/^(const|let|var|function|class|if|for|while|return|import|export)\s+/,/^[a-zA-Z_$][a-zA-Z0-9_$]*\s*[=:]\s*/,/^[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(!ENDS_LIKE_CODE.test(line)){continue}for(const pattern of codePatterns){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",meta:{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}],create(context,[options={}]){const{ignoreSingleLine=false,ignoreInTests=true,minLines=1}=options||{};const filename=context.filename;const isTestFile=ignoreInTests&&/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);if(isTestFile){return{}}const sourceCode=context.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}}return{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)){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}]})}}})}}}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noRawCrossPropertyHref=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const CROSS_PROPERTY_HOSTS=new Set(["ofriperetz.dev","interlace.tools","eslint.interlace.tools","serverless.interlace.tools","ds.interlace.tools","storybook.interlace.tools"]);exports.noRawCrossPropertyHref=(0,eslint_devkit_1.createRule)({name:"no-raw-cross-property-href",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-conventions/docs/rules/no-raw-cross-property-href.md",description:"Forbid hand-written cross-property hrefs; use buildUtmHref() from lib/utm.ts"},fixable:void 0,hasSuggestions:false,messages:{rawCrossPropertyHref:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Raw cross-property href",description:'href "{{href}}" points to a cross-property surface ({{host}}). Use buildUtmHref() from lib/utm.ts so the link carries UTM and ph_distinct_id.',severity:"HIGH",fix:"Replace with buildUtmHref('{{href}}', { source, medium, campaign, content }).",documentationLink:"https://github.com/ofri-peretz/
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noRawCrossPropertyHref=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const CROSS_PROPERTY_HOSTS=new Set(["ofriperetz.dev","interlace.tools","eslint.interlace.tools","serverless.interlace.tools","ds.interlace.tools","storybook.interlace.tools"]);exports.noRawCrossPropertyHref=(0,eslint_devkit_1.createRule)({name:"no-raw-cross-property-href",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-conventions/docs/rules/no-raw-cross-property-href.md",description:"Forbid hand-written cross-property hrefs; use buildUtmHref() from lib/utm.ts"},fixable:void 0,hasSuggestions:false,messages:{rawCrossPropertyHref:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Raw cross-property href",description:'href "{{href}}" points to a cross-property surface ({{host}}). Use buildUtmHref() from lib/utm.ts so the link carries UTM and ph_distinct_id.',severity:"HIGH",fix:"Replace with buildUtmHref('{{href}}', { source, medium, campaign, content }).",documentationLink:"https://github.com/ofri-peretz/interlace/blob/main/docs/philosophies/UTM_PHILOSOPHY.md"})},schema:[]},defaultOptions:[],create(context){function parseHost(value){if(!/^https?:\/\//i.test(value))return null;try{return new URL(value).hostname.toLowerCase()}catch{return null}}function isCrossPropertyHref(href){const host=parseHost(href);if(!host)return null;if(!CROSS_PROPERTY_HOSTS.has(host))return null;return{host}}return{JSXAttribute(node){if(node.name.type!=="JSXIdentifier"||node.name.name!=="href"||!node.value||node.value.type!=="Literal"||typeof node.value.value!=="string"){return}const result=isCrossPropertyHref(node.value.value);if(!result)return;context.report({node:node.value,messageId:"rawCrossPropertyHref",data:{href:node.value.value,host:result.host}})}}}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.utmTaxonomy=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const VALID_UTM_SOURCES=new Set(["ofriperetz_dev","interlace","eslint_docs","serverless_docs","ds","storybook","devto","github","npm","x","linkedin","email"]);const VALID_UTM_MEDIUMS=new Set(["article","blog","docs","landing","social","email","referral","cli"]);const UTM_PARAM_RE=/[?&](utm_source|utm_medium)=([^&#]+)/g;exports.utmTaxonomy=(0,eslint_devkit_1.createRule)({name:"utm-taxonomy",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-conventions/docs/rules/utm-taxonomy.md",description:"Validate utm_source and utm_medium values against the fixed taxonomy in UTM_PHILOSOPHY.md"},fixable:void 0,hasSuggestions:false,messages:{invalidUtmSource:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Invalid utm_source",description:'utm_source="{{value}}" is not in the fixed taxonomy. Allowed: {{allowed}}',severity:"HIGH",fix:"Use one of the allowed values, or extend the taxonomy in UTM_PHILOSOPHY.md and this rule together.",documentationLink:"https://github.com/ofri-peretz/
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.utmTaxonomy=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const VALID_UTM_SOURCES=new Set(["ofriperetz_dev","interlace","eslint_docs","serverless_docs","ds","storybook","devto","github","npm","x","linkedin","email"]);const VALID_UTM_MEDIUMS=new Set(["article","blog","docs","landing","social","email","referral","cli"]);const UTM_PARAM_RE=/[?&](utm_source|utm_medium)=([^&#]+)/g;exports.utmTaxonomy=(0,eslint_devkit_1.createRule)({name:"utm-taxonomy",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-conventions/docs/rules/utm-taxonomy.md",description:"Validate utm_source and utm_medium values against the fixed taxonomy in UTM_PHILOSOPHY.md"},fixable:void 0,hasSuggestions:false,messages:{invalidUtmSource:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Invalid utm_source",description:'utm_source="{{value}}" is not in the fixed taxonomy. Allowed: {{allowed}}',severity:"HIGH",fix:"Use one of the allowed values, or extend the taxonomy in UTM_PHILOSOPHY.md and this rule together.",documentationLink:"https://github.com/ofri-peretz/interlace/blob/main/docs/philosophies/UTM_PHILOSOPHY.md"}),invalidUtmMedium:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.WARNING,issueName:"Invalid utm_medium",description:'utm_medium="{{value}}" is not in the fixed taxonomy. Allowed: {{allowed}}',severity:"HIGH",fix:"Use one of the allowed values, or extend the taxonomy in UTM_PHILOSOPHY.md and this rule together.",documentationLink:"https://github.com/ofri-peretz/interlace/blob/main/docs/philosophies/UTM_PHILOSOPHY.md"})},schema:[]},defaultOptions:[],create(context){function checkString(node,value){UTM_PARAM_RE.lastIndex=0;let match;while((match=UTM_PARAM_RE.exec(value))!==null){const[,key,raw]=match;const decoded=decodeURIComponent(raw);if(key==="utm_source"&&!VALID_UTM_SOURCES.has(decoded)){context.report({node,messageId:"invalidUtmSource",data:{value:decoded,allowed:[...VALID_UTM_SOURCES].join(", ")}})}else if(key==="utm_medium"&&!VALID_UTM_MEDIUMS.has(decoded)){context.report({node,messageId:"invalidUtmMedium",data:{value:decoded,allowed:[...VALID_UTM_MEDIUMS].join(", ")}})}}}return{Literal(node){if(typeof node.value==="string"&&node.value.includes("utm_")){checkString(node,node.value)}},TemplateLiteral(node){for(const quasi of node.quasis){if(quasi.value.cooked&&quasi.value.cooked.includes("utm_")){checkString(quasi,quasi.value.cooked)}}}}}});
|