@alien_intelligence/eslint-plugin-nitpicker 0.7.6 → 0.7.7
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 +37 -22
- package/dist/index.js +14 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -73,28 +73,30 @@ Nitpicker ships five shared flat configs:
|
|
|
73
73
|
The **base** rules are the universal ruleset shipped by `recommended`; the **React** and **AdonisJS** rules ship only in their framework configs. Every rule is enabled as a warning. The Fixable column marks rules that `eslint --fix` can resolve automatically.
|
|
74
74
|
|
|
75
75
|
### Base rules
|
|
76
|
-
| Rule | Fixable | Description
|
|
77
|
-
|
|
78
|
-
| `nitpicker/max-jsdoc-description-length` | | Enforce a maximum character length for a JSDoc description (default 250).
|
|
79
|
-
| `nitpicker/
|
|
80
|
-
| `nitpicker/
|
|
81
|
-
| `nitpicker/no-
|
|
82
|
-
| `nitpicker/no-
|
|
83
|
-
| `nitpicker/no-
|
|
84
|
-
| `nitpicker/no-
|
|
85
|
-
| `nitpicker/no-
|
|
86
|
-
| `nitpicker/no-jsdoc-
|
|
87
|
-
| `nitpicker/no-
|
|
88
|
-
| `nitpicker/no-line-comment-
|
|
89
|
-
| `nitpicker/no-
|
|
90
|
-
| `nitpicker/no-property-
|
|
91
|
-
| `nitpicker/no-
|
|
92
|
-
| `nitpicker/no-
|
|
93
|
-
| `nitpicker/
|
|
94
|
-
| `nitpicker/require-
|
|
95
|
-
| `nitpicker/require-
|
|
96
|
-
| `nitpicker/require-
|
|
97
|
-
| `nitpicker/require-
|
|
76
|
+
| Rule | Fixable | Description |
|
|
77
|
+
|----------------------------------------------|---------|-----------------------------------------------------------------------------------------------------|
|
|
78
|
+
| `nitpicker/max-jsdoc-description-length` | | Enforce a maximum character length for a JSDoc description (default 250). |
|
|
79
|
+
| `nitpicker/max-line-comment-length` | | Enforce a maximum prose length for a run of consecutive `//` comments (default 200). |
|
|
80
|
+
| `nitpicker/catch-error-name` | | Require a `catch` clause to bind its error as `error` (`_error` for an unused binding). |
|
|
81
|
+
| `nitpicker/no-alias-variables` | | Disallow a `const` whose whole value is another variable; use the source directly. |
|
|
82
|
+
| `nitpicker/no-british-english` | yes | Disallow British spellings in identifiers and comments, reporting the American equivalent. |
|
|
83
|
+
| `nitpicker/no-decorative-comment-separators` | | Disallow decorative separators (banners, box-drawing, repeated dashes) inside comments. |
|
|
84
|
+
| `nitpicker/no-em-dash` | | Disallow the em dash (—) character anywhere in the source (`allow` option for copy). |
|
|
85
|
+
| `nitpicker/no-emojis` | | Disallow emoji anywhere in the source (`allow` option for copy). Reported, never auto-removed. |
|
|
86
|
+
| `nitpicker/no-jsdoc-blank-before-tags` | yes | Disallow blank lines before JSDoc tags such as `@param` or `@returns`. |
|
|
87
|
+
| `nitpicker/no-jsdoc-returns-on-void` | yes | Disallow a JSDoc `@returns` tag on a function that returns nothing. |
|
|
88
|
+
| `nitpicker/no-line-comment-backticks` | yes | Disallow backticks in `//` line comments; use double quotes for code references. |
|
|
89
|
+
| `nitpicker/no-line-comment-period` | yes¹ | Disallow prose periods in `//` line comments (code dots, quoted spans, ellipses, `e.g.` are OK). |
|
|
90
|
+
| `nitpicker/no-property-access-alias` | | Disallow a `const` whose whole value is a single property access; inline the expression instead. |
|
|
91
|
+
| `nitpicker/no-property-destructuring` | | Disallow shorthand destructuring off a plain object reference; access the property directly. |
|
|
92
|
+
| `nitpicker/no-relative-imports` | | Disallow relative (`./`, `../`) import/re-export paths; use the package alias (`allowIn` option). |
|
|
93
|
+
| `nitpicker/no-single-line-jsdoc` | yes | Require JSDoc comments to span multiple lines rather than a single line. |
|
|
94
|
+
| `nitpicker/require-capitalized-comments` | yes | Require a comment to start with an uppercase letter. |
|
|
95
|
+
| `nitpicker/require-complete-jsdoc` | | Require a function's JSDoc to document every parameter and its return value. |
|
|
96
|
+
| `nitpicker/require-framework-config` | | Warn when a file uses a framework whose Nitpicker config is not enabled. |
|
|
97
|
+
| `nitpicker/require-function-jsdoc` | | Require a JSDoc on functions, including class methods and nested ones (`include`/`ignore` options). |
|
|
98
|
+
| `nitpicker/require-jsdoc-delimiter-lines` | yes | Require a JSDoc's `/**` and `*/` to sit on their own lines, not share one with prose. |
|
|
99
|
+
| `nitpicker/require-multiline-object` | yes² | Require an object literal with more than a few properties (default 2) to span multiple lines. |
|
|
98
100
|
|
|
99
101
|
### React rules
|
|
100
102
|
Shipped by the `react` config (and `all`).
|
|
@@ -127,6 +129,19 @@ A few rules accept options. Pass them by overriding the rule with a `["warn", {
|
|
|
127
129
|
"nitpicker/max-jsdoc-description-length": ["warn", { max: 200 }],
|
|
128
130
|
```
|
|
129
131
|
|
|
132
|
+
`max-line-comment-length` takes `{ max: number }`, the cap on the joined prose of a run of consecutive `//` comments, defaulting to `200`. It is tighter than the JSDoc cap because a stacked wall of `//` lines reads worse than a block:
|
|
133
|
+
```js
|
|
134
|
+
"nitpicker/max-line-comment-length": ["warn", { max: 160 }],
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
`require-function-jsdoc` takes `{ include, ignore }`. `include` picks which function kinds are required on top of top-level ones, out of `"class-methods"`, `"object-methods"` and `"nested"`, defaulting to `["class-methods", "nested"]`. `object-methods` is off by default because callback and visitor objects share the shape of a genuine method bag. `ignore` lists names to skip, for an inherited or framework member whose purpose is fixed by the interface it implements:
|
|
138
|
+
```js
|
|
139
|
+
"nitpicker/require-function-jsdoc": ["warn", {
|
|
140
|
+
include: ["class-methods", "object-methods", "nested"],
|
|
141
|
+
ignore: ["create", "render"],
|
|
142
|
+
}],
|
|
143
|
+
```
|
|
144
|
+
|
|
130
145
|
`max-classname-length` takes `{ max: number }`, the maximum length of a `className` class string, defaulting to `120`:
|
|
131
146
|
```js
|
|
132
147
|
"nitpicker/max-classname-length": ["warn", { max: 100 }],
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import {ESLintUtils,ASTUtils}from'@typescript-eslint/utils';var
|
|
1
|
+
import {ESLintUtils,ASTUtils}from'@typescript-eslint/utils';var Pt={PLUGIN_NAME:"nitpicker",REPO_URL:"https://github.com/Alien-Intelligence/eslint-plugin-nitpicker",EM_DASH:"\u2014",EMOJI:new RegExp("\\p{Regional_Indicator}\\p{Regional_Indicator}|\\p{Emoji_Presentation}(?:\\uFE0F|\\p{Emoji_Modifier})?(?:\\u200D\\p{Emoji_Presentation}(?:\\uFE0F|\\p{Emoji_Modifier})?)*|\\p{Extended_Pictographic}\\uFE0F","gu"),COMMENTS:{BOX_DRAWING:/[─-▟]/,PURE_SEPARATOR:/^[-=~*#_+]{3,}$/,WRAPPED_LABEL:/^[-=~*#_+]{2,}\s.*\s[-=~*#_+]{2,}$/,DIRECTIVE:/^\s*(?:eslint\b|eslint-|globals?\b|exported\b|jshint\b|jslint\b|istanbul\b|[cv]8\b|ts-|prettier-ignore|biome-ignore|webpack\b|noinspection\b|@)/,QUOTES:new Set(['"',"`"]),ABBREVIATIONS:["e.g.","i.e.","etc.","vs.","cf.","al.","approx.","resp."],MAX_RUN_LENGTH:200},JSDOC:{TAG:/^\s*\*?\s*@(\w+)/,PARAM_TAG:/^\s*\*?\s*@param\s+(?:\{[^}]*\}\s*)?\[?([\w$]+)/,MAX_DESCRIPTION_LENGTH:250},WORDS:{WORD_CHAR:/[\p{L}\p{N}_$]/u,SUB_WORD:/[A-Z]+(?![a-z])|[A-Z][a-z]+|[a-z]+/g},OBJECTS:{MAX_INLINE_KEYS:2,INDENT_WIDTH:4},FUNCTIONS:{NODE_TYPES:new Set(["FunctionDeclaration","FunctionExpression","ArrowFunctionExpression"])},FRAMEWORKS:{ADONIS_SUBPATH:/^#(models|controllers|services|middleware|validators|policies|config|start|database|providers|lib)\b/,REACT_FILE:/\.[jt]sx$/},REACT:{HOOK:/^use[A-Z]/,CONTEXT_HOOK:/^use[A-Z]\w*Context$/,MEMO_HOOKS:new Set(["useMemo","useCallback"]),MAX_CLASSNAME_LENGTH:120},REQUEST:{RAW_ACCESSORS:new Set(["input","body","qs","all","only","except"])},MIGRATIONS:{INDEX_METHODS:new Set(["index","unique","primary","foreign"]),TIMESTAMP_METHODS:new Set(["timestamp","dateTime","datetime"]),AUDIT_TIMESTAMPS:new Set(["created_at","updated_at","deleted_at"]),CATEGORY_ORDER:["column","timestamp","index"]}},l=Pt;var xe=ESLintUtils.RuleCreator(()=>`${l.REPO_URL}/blob/main/README.md#rules`);var p=class{toRuleModule(){return xe({name:this.name,meta:this.meta,defaultOptions:this.defaultOptions,create:(e,i)=>this.create(e,i)})}};function c({problem:t,why:e,fix:i}){return `${t}
|
|
2
2
|
- why: ${e}
|
|
3
|
-
- fix: ${i}`}function
|
|
4
|
-
`)){let s=(n.match(/^\s*\*?\s*/u)?.[0]??"").length,r=n.slice(s).charAt(0);if(r!=="")return {index:e+i+s,char:r};i+=n.length+1;}return null}function
|
|
5
|
-
`)){let n=i.match(
|
|
6
|
-
`).some(e=>{let i=I(e);return i==="returns"||i==="return"})}function
|
|
7
|
-
`)){let n=i.replace(/^\s*\*? ?/,"").trimEnd();if(n.startsWith("@"))break;e.push(n);}return e.join(" ").replace(/\s+/g," ").trim()}function Ae(t,e){let i=-1;for(let s=e.loc.start.line+1;s<e.loc.end.line;s++){let r=I(t.lines[s-1]??"");if(r==="returns"||r==="return"){i=s;break}}if(i===-1)return null;let n=e.loc.end.line-1;for(let s=i+1;s<e.loc.end.line;s++)if(U(t.lines[s-1]??"")){n=s-1;break}return {from:i,to:n}}var W=class extends p{name="require-controller-jsdoc";defaultOptions=[];meta={type:"suggestion",docs:{description:"Require a JSDoc comment describing an AdonisJS controller.",recommended:true,category:"adonisjs"},schema:[],messages:{missingJSDoc:l({problem:"This controller has no JSDoc describing what it does.",why:"A controller's responsibility should be readable at a glance, before diving into its handler methods",fix:"Add a `/** ... */` JSDoc above the controller class summarizing what it handles"})}};create(e){return {ClassDeclaration(i){Ie(i)&&(S(e.sourceCode,i.parent)||e.report({node:i.id??i,messageId:"missingJSDoc"}));}}}},ve=new W;var q=class extends p{name="require-migration-jsdoc";defaultOptions=[];meta={type:"suggestion",docs:{description:"Require a JSDoc comment describing an AdonisJS migration.",recommended:true,category:"adonisjs"},schema:[],messages:{missingJSDoc:l({problem:"This migration has no JSDoc describing what it does.",why:"A migration's intent should be readable at a glance, the timestamped filename does not convey the schema change",fix:"Add a `/** ... */` JSDoc above the migration class summarizing the change"})}};create(e){return {ClassDeclaration(i){Ee(i)&&(S(e.sourceCode,i.parent)||e.report({node:i.id??i,messageId:"missingJSDoc"}));}}}},ze=new q;function _t(t){let e=t.replace(/\\/g,"/"),i="^";for(let n=0;n<e.length;n++){let s=e[n];if(s===void 0)break;s==="*"?e[n+1]==="*"?(i+=".*",n++,e[n+1]==="/"&&n++):i+="[^/]*":"\\^$.|?+()[]{}".includes(s)?i+=`\\${s}`:i+=s;}return new RegExp(`${i}$`)}function E(t,e){let i=t.replace(/\\/g,"/");return e.some(n=>_t(n).test(i))}var B=class extends p{name="require-validated-request";defaultOptions=[{allowIn:[]}];meta={type:"suggestion",docs:{description:"Require request data to be read through a Vine validator, not raw request accessors.",recommended:true,category:"adonisjs"},schema:[{type:"object",properties:{allowIn:{type:"array",items:{type:"string"}}},additionalProperties:false}],messages:{rawRead:l({problem:"`request.{{method}}()` reads request data directly.",why:"Request data must pass through a Vine validator so it is typed and checked, a raw accessor bypasses that contract",fix:"Read it through `request.validateUsing(someValidator)` instead"})}};create(e,i){let n=i[0]?.allowIn??[];if(n.length>0&&E(e.filename,n))return {};let s=r=>r.type==="Identifier"?r.name==="request":r.type==="MemberExpression"&&r.property.type==="Identifier"&&r.property.name==="request";return {CallExpression(r){r.callee.type!=="MemberExpression"||r.callee.property.type!=="Identifier"||!o.REQUEST.RAW_ACCESSORS.has(r.callee.property.name)||!s(r.callee.object)||e.report({node:r.callee.property,messageId:"rawRead",data:{method:r.callee.property.name}});}}}},Fe=new B;var V=class extends p{name="catch-error-name";defaultOptions=[];meta={type:"suggestion",docs:{description:"Require a `catch` clause to bind its error as `error`.",recommended:true,category:"base"},schema:[],messages:{rename:l({problem:"This `catch` binds the error as `{{name}}`.",why:"Every catch binds the error as `error` so error handling reads the same across the codebase",fix:"Rename the binding to `error`, or `_error` if it is intentionally unused"})}};create(e){return {CatchClause(i){i.param?.type==="Identifier"&&(i.param.name==="error"||i.param.name.startsWith("_")||e.report({node:i.param,messageId:"rename",data:{name:i.param.name}}));}}}},Pe=new V;var je=250,G=class extends p{name="max-jsdoc-description-length";defaultOptions=[{max:je}];meta={type:"suggestion",docs:{description:"Enforce a maximum character length for a JSDoc description.",recommended:true,category:"base"},schema:[{type:"object",properties:{max:{type:"integer",minimum:1}},additionalProperties:false}],messages:{tooLong:l({problem:"This JSDoc description is {{length}} characters, over the {{max}}-character limit.",why:"A JSDoc description should summarize what something is, an oversized one usually restates the code or explains how it is used, which does not belong here",fix:'Trim it to a concise summary of what it does, and remove any note about how or where it is used (e.g "used by X to ...", "called from Y"), which is an anti-pattern'})}};create(e,i){let n=i[0]?.max??je;return {Program(){for(let s of e.sourceCode.getAllComments()){if(!y(s))continue;let r=Me(s).length;r<=n||e.report({loc:s.loc,messageId:"tooLong",data:{length:r,max:n}});}}}}},Je=new G;function C(t){let e=[],i=t;for(;;){if(i.type==="ChainExpression"||i.type==="TSNonNullExpression"){i=i.expression;continue}if(i.type==="MemberExpression"){if(i.computed||i.property.type!=="Identifier")return null;e.unshift(i.property.name),i=i.object;continue}break}return e.length===0?null:i.type==="ThisExpression"?["this",...e].join("."):i.type==="Identifier"?[i.name,...e].join("."):null}function _e(t){return C(t)!==null}function D(t,e){let i=ASTUtils.findVariable(t,e);if(i===null)return false;let n=new Set(i.defs.map(s=>s.name));return i.references.some(s=>s.isWrite()&&!n.has(s.identifier))}function Ue(t,e){for(let i of t)if(e===i||e.startsWith(`${i}.`))return true;return false}function We(t){return t.properties.length===0?false:t.properties.every(e=>e.type==="Property"&&e.shorthand&&!e.computed&&e.value.type==="Identifier")}var K=class extends p{name="no-alias-variables";defaultOptions=[];meta={type:"suggestion",docs:{description:"Disallow a `const` whose whole value is another variable, use the source directly.",recommended:true,category:"base"},schema:[],messages:{alias:l({problem:"`{{name}}` only aliases `{{source}}`.",why:"A variable that just renames another hides the original and adds a name to track for no gain",fix:"Remove it and use `{{source}}` directly, or rename `{{source}}` itself if the new name is better"})}};create(e){return {VariableDeclarator(i){i.parent.type!=="VariableDeclaration"||i.parent.kind!=="const"||i.parent.parent.type!=="ExportNamedDeclaration"&&(i.id.type!=="Identifier"||i.init?.type!=="Identifier"||i.id.typeAnnotation===void 0&&(D(e.sourceCode.getScope(i),i.init.name)||e.report({node:i,messageId:"alias",data:{name:i.id.name,source:i.init.name}})));}}}},qe=new K;var Be={colour:"color",colours:"colors",coloured:"colored",colouring:"coloring",behaviour:"behavior",behaviours:"behaviors",favour:"favor",favours:"favors",favoured:"favored",favouring:"favoring",favourable:"favorable",favourite:"favorite",favourites:"favorites",flavour:"flavor",flavours:"flavors",honour:"honor",honours:"honors",honoured:"honored",honouring:"honoring",labour:"labor",labours:"labors",laboured:"labored",labouring:"laboring",neighbour:"neighbor",neighbours:"neighbors",humour:"humor",humours:"humors",rumour:"rumor",rumours:"rumors",harbour:"harbor",harbours:"harbors",endeavour:"endeavor",endeavours:"endeavors",endeavoured:"endeavored",endeavouring:"endeavoring",normalise:"normalize",normalised:"normalized",normalising:"normalizing",normalisation:"normalization",initialise:"initialize",initialises:"initializes",initialised:"initialized",initialising:"initializing",initialisation:"initialization",serialise:"serialize",serialised:"serialized",serialising:"serializing",serialisation:"serialization",organise:"organize",organises:"organizes",organised:"organized",organising:"organizing",organisation:"organization",optimise:"optimize",optimised:"optimized",optimising:"optimizing",optimisation:"optimization",customise:"customize",customised:"customized",customising:"customizing",sanitise:"sanitize",sanitised:"sanitized",sanitising:"sanitizing",synchronise:"synchronize",synchronised:"synchronized",synchronising:"synchronizing",synchronisation:"synchronization",authorise:"authorize",authorised:"authorized",authorising:"authorizing",authorisation:"authorization",finalise:"finalize",finalised:"finalized",finalising:"finalizing",capitalise:"capitalize",capitalised:"capitalized",capitalising:"capitalizing",categorise:"categorize",categorises:"categorizes",categorised:"categorized",categorising:"categorizing",categorisation:"categorization",utilise:"utilize",utilises:"utilizes",utilised:"utilized",utilising:"utilizing",utilisation:"utilization",realise:"realize",realises:"realizes",realised:"realized",realising:"realizing",realisation:"realization",recognise:"recognize",recognises:"recognizes",recognised:"recognized",recognising:"recognizing",summarise:"summarize",summarises:"summarizes",summarised:"summarized",summarising:"summarizing",specialise:"specialize",specialises:"specializes",specialised:"specialized",specialising:"specializing",specialisation:"specialization",minimise:"minimize",minimises:"minimizes",minimised:"minimized",minimising:"minimizing",minimisation:"minimization",maximise:"maximize",maximises:"maximizes",maximised:"maximized",maximising:"maximizing",maximisation:"maximization",prioritise:"prioritize",prioritises:"prioritizes",prioritised:"prioritized",prioritising:"prioritizing",prioritisation:"prioritization",standardise:"standardize",standardises:"standardizes",standardised:"standardized",standardising:"standardizing",standardisation:"standardization",harmonise:"harmonize",harmonises:"harmonizes",harmonised:"harmonized",harmonising:"harmonizing",harmonisation:"harmonization",centralise:"centralize",centralises:"centralizes",centralised:"centralized",centralising:"centralizing",centralisation:"centralization",decentralise:"decentralize",decentralises:"decentralizes",decentralised:"decentralized",decentralising:"decentralizing",decentralisation:"decentralization",emphasise:"emphasize",emphasises:"emphasizes",emphasised:"emphasized",emphasising:"emphasizing",visualise:"visualize",visualises:"visualizes",visualised:"visualized",visualising:"visualizing",visualisation:"visualization",analyse:"analyze",analyses:"analyzes",analysed:"analyzed",analysing:"analyzing",paralyse:"paralyze",paralyses:"paralyzes",paralysed:"paralyzed",paralysing:"paralyzing",centre:"center",centred:"centered",centres:"centers",fibre:"fiber",fibres:"fibers",metre:"meter",metres:"meters",litre:"liter",litres:"liters",theatre:"theater",theatres:"theaters",calibre:"caliber",spectre:"specter",spectres:"specters",licence:"license",defence:"defense",offence:"offense",pretence:"pretense",practise:"practice",cancelled:"canceled",cancelling:"canceling",labelled:"labeled",labelling:"labeling",modelled:"modeled",modelling:"modeling",travelled:"traveled",travelling:"traveling",signalled:"signaled",signalling:"signaling",fuelled:"fueled",fuelling:"fueling",marvellous:"marvelous",counsellor:"counselor",fulfil:"fulfill",fulfils:"fulfills",fulfilment:"fulfillment",enrol:"enroll",enrols:"enrolls",enrolment:"enrollment",instalment:"installment",skilful:"skillful",wilful:"willful",dialogue:"dialog",dialogues:"dialogs",catalogue:"catalog",catalogues:"catalogs",analogue:"analog",analogues:"analogs",grey:"gray",artefact:"artifact",artefacts:"artifacts",sceptic:"skeptic",sceptical:"skeptical",programme:"program",programmes:"programs",enquiry:"inquiry",enquiries:"inquiries",aluminium:"aluminum",tyre:"tire",tyres:"tires"};function Ve(t,e,i){let n=Object.create(null);for(let[s,r]of Object.entries(t))n[s.toLowerCase()]=r;for(let[s,r]of Object.entries(e))n[s.toLowerCase()]=r;for(let s of i)delete n[s.toLowerCase()];return n}var $=class extends p{name="no-british-english";defaultOptions=[{extra:{},ignore:[]}];meta={type:"suggestion",docs:{description:"Disallow British English spellings in identifiers and comments.",recommended:true,category:"base"},fixable:"code",schema:[{type:"object",properties:{extra:{type:"object",additionalProperties:{type:"string"}},ignore:{type:"array",items:{type:"string"}}},additionalProperties:false}],messages:{british:l({problem:"British spelling `{{british}}`, this codebase uses American English.",why:"One spelling convention keeps identifiers and docs consistent and searchable",fix:"Use `{{american}}` instead"})}};create(e,i){let n=Ve(Be,i[0]?.extra??{},i[0]?.ignore??[]);return {Identifier(s){if(!(s.parent.type==="MemberExpression"&&s.parent.property===s&&!s.parent.computed))for(let r of P(s.name)){let a=n[r.text.toLowerCase()];a!==void 0&&e.report({node:s,messageId:"british",data:{british:r.text,american:j(r.text,a)}});}},Program(){for(let s of e.sourceCode.getAllComments())for(let r of P(s.value)){let a=n[r.text.toLowerCase()];if(a===void 0)continue;let u=j(r.text,a),d=s.range[0]+2+r.index,g=d+r.text.length;e.report({loc:{start:e.sourceCode.getLocFromIndex(d),end:e.sourceCode.getLocFromIndex(g)},messageId:"british",data:{british:r.text,american:u},fix:k=>k.replaceTextRange([d,g],u)});}}}}},Ge=new $;function Ke(t){let e=t.replace(/^\s*\*?\s*/,"").trimEnd();return e.length===0?false:o.COMMENTS.BOX_DRAWING.test(e)||o.COMMENTS.PURE_SEPARATOR.test(e)||o.COMMENTS.WRAPPED_LABEL.test(e)}var H=class extends p{name="no-decorative-comment-separators";defaultOptions=[{allowIn:[]}];meta={type:"layout",docs:{description:"Disallow decorative separators (banners, box-drawing, repeated dashes) inside comments.",recommended:true,category:"base"},schema:[{type:"object",properties:{allowIn:{type:"array",items:{type:"string"}}},additionalProperties:false}],messages:{decorative:l({problem:"This comment uses a decorative separator.",why:"Repeated separator characters and box-drawing lines are visual noise that add nothing over a plain label",fix:"Remove the separator, a one-line label or a blank line already divides sections clearly"})}};create(e,i){let n=i[0]?.allowIn??[];return n.length>0&&E(e.filename,n)?{}:{Program(){for(let s of e.sourceCode.getAllComments()){let r=s.value.split(`
|
|
8
|
-
`);for(let a=0;a<r.length;a++){let u=r[a];if(u===void 0||!Ke(u))continue;let d=s.loc.start.line+a,g=e.sourceCode.lines[d-1]??"";e.report({loc:{start:{line:d,column:0},end:{line:d,column:g.length}},messageId:"decorative"});}}}}}},$e=new H;var Wt={strings:"String",templates:"Template",jsx:"JSXText"};function w(t,e){let i=new Set(e),n=[];if(i.size===0)return n;let s=new Set([...i].map(r=>Wt[r]).filter(r=>r!==void 0));for(let r of t.ast.tokens??[])s.has(r.type)&&n.push(r.range);if(i.has("comments"))for(let r of t.getAllComments())n.push(r.range);return n}function M(t,e){return e.some(([i,n])=>t>=i&&t<n)}var X=class extends p{name="no-em-dash";defaultOptions=[{allow:[]}];meta={type:"suggestion",docs:{description:"Disallow the em dash (\u2014) character anywhere in the source.",recommended:true},schema:[{type:"object",properties:{allow:{type:"array",items:{type:"string",enum:["strings","templates","jsx","comments"]}}},additionalProperties:false}],messages:{emDash:l({problem:"Found an em dash (\u2014) character.",why:"Em dashes are typically introduced by AI-generated or auto-formatted text and are discouraged here.",fix:"Replace the em dash with a hyphen (-), a comma (,), or reword the sentence to avoid it, or allow it here with the rule's `allow` option if it is deliberate user-facing copy."})}};create(e,i){return {Program(){let n=e.sourceCode.getText(),s=w(e.sourceCode,i[0]?.allow??[]);for(let r=0;r<n.length;r++)n[r]===o.EM_DASH&&(M(r,s)||e.report({loc:{start:e.sourceCode.getLocFromIndex(r),end:e.sourceCode.getLocFromIndex(r+1)},messageId:"emDash"}));}}}},He=new X;var Y=class extends p{name="no-emojis";defaultOptions=[{allow:[]}];meta={type:"suggestion",docs:{description:"Disallow emoji characters anywhere in the source.",recommended:true,category:"base"},schema:[{type:"object",properties:{allow:{type:"array",items:{type:"string",enum:["strings","templates","jsx","comments"]}}},additionalProperties:false}],messages:{emoji:l({problem:"Found an emoji ({{emoji}}).",why:"Emojis are usually introduced by AI-generated text and add noise to code, comments, and identifiers",fix:"Remove the emoji, or allow it here with the rule's `allow` option if it is deliberate user-facing copy"})}};create(e,i){return {Program(){let n=e.sourceCode.getText(),s=w(e.sourceCode,i[0]?.allow??[]);for(let r of n.matchAll(o.EMOJI))M(r.index,s)||e.report({loc:{start:e.sourceCode.getLocFromIndex(r.index),end:e.sourceCode.getLocFromIndex(r.index+r[0].length)},messageId:"emoji",data:{emoji:r[0]}});}}}},Xe=new Y;var Z=class extends p{name="no-jsdoc-blank-before-tags";defaultOptions=[];meta={type:"layout",fixable:"code",docs:{description:"Disallow blank lines before JSDoc tags such as `@param` or `@returns`.",recommended:true},schema:[],messages:{blankBeforeTag:l({problem:"There is a blank line before a JSDoc tag.",why:"Tags should follow the description directly; an empty line there is noise that inflates the comment.",fix:"Remove the blank line so the tag follows on directly."})}};create(e){return {Program(){for(let i of e.sourceCode.getAllComments())if(y(i)&&i.loc.start.line!==i.loc.end.line)for(let n=i.loc.start.line;n<=i.loc.end.line;n++){let s=e.sourceCode.lines[n-1];if(s===void 0||!_(s))continue;let r=n;for(;r<i.loc.end.line&&_(e.sourceCode.lines[r]??"");)r++;let a=e.sourceCode.lines[r];if(a!==void 0&&U(a)){let u=e.sourceCode.getIndexFromLoc({line:n,column:0}),d=e.sourceCode.getIndexFromLoc({line:r+1,column:0});e.report({loc:{start:{line:n,column:0},end:{line:r,column:s.length}},messageId:"blankBeforeTag",fix:g=>g.removeRange([u,d])});}n=r;}}}}},Ye=new Z;function h(t){let e=t;return e.parent.type==="Property"||e.parent.type==="MethodDefinition"?e.parent:(e.parent.type==="VariableDeclarator"&&e.parent.parent.type==="VariableDeclaration"&&(e=e.parent.parent),(e.parent.type==="ExportNamedDeclaration"||e.parent.type==="ExportDefaultDeclaration")&&(e=e.parent),e)}function Ze(t){return t.parent?.type==="Program"}function Qe(t){let e=[],i=n=>{switch(n.type){case "Identifier":e.push({kind:"name",name:n.name,node:n});return;case "AssignmentPattern":i(n.left);return;case "RestElement":i(n.argument);return;case "TSParameterProperty":i(n.parameter);return;case "ObjectPattern":{let s=[];for(let r of n.properties)r.type==="RestElement"?r.argument.type==="Identifier"&&s.push({name:r.argument.name,node:r.argument}):r.key.type==="Identifier"&&s.push({name:r.key.name,node:r.key});s.length>0&&e.push({kind:"object",names:s,node:n});return}default:return}};for(let n of t.params)i(n);return e}function et(t){let e=t.parent;for(;e;){if(o.FUNCTIONS.NODE_TYPES.has(e.type))return e;e=e.parent;}return null}function tt(t){return t.type==="ArrowFunctionExpression"&&t.params.length===0&&t.body.type==="ImportExpression"}function x(t){if((t.type==="FunctionDeclaration"||t.type==="FunctionExpression")&&t.id)return t.id.name;if(t.parent.type==="VariableDeclarator"&&t.parent.id.type==="Identifier")return t.parent.id.name}function R(t,e,i){if(t.type==="ReturnStatement")return i(t.argument);for(let n of e[t.type]??[]){let s=t[n],r=Array.isArray(s)?s:[s];for(let a of r){let u=a;if(!(!u||typeof u.type!="string")&&!o.FUNCTIONS.NODE_TYPES.has(u.type)&&R(u,e,i))return true}}return false}function qt(t,e){return t.type==="ArrowFunctionExpression"&&t.body.type!=="BlockStatement"?true:R(t.body,e,i=>i!==null)}function Bt(t){return t.typeAnnotation.type==="TSVoidKeyword"?true:t.typeAnnotation.type==="TSTypeReference"&&t.typeAnnotation.typeName.type==="Identifier"&&t.typeAnnotation.typeName.name==="Promise"?t.typeAnnotation.typeArguments?.params.length===1&&t.typeAnnotation.typeArguments?.params[0]?.type==="TSVoidKeyword":false}function A(t,e){return t.returnType?Bt(t.returnType):!qt(t,e)}var Q=class extends p{name="no-jsdoc-returns-on-void";defaultOptions=[];meta={type:"suggestion",fixable:"code",docs:{description:"Disallow a JSDoc `@returns` tag on a function that returns nothing.",recommended:true,category:"base"},schema:[],messages:{voidReturns:l({problem:"This function returns nothing, but its JSDoc has a `@returns` tag.",why:"A `@returns` on a void function documents a value that never exists and drifts from the code",fix:"Remove the `@returns` tag"})}};create(e){let i=(n,s)=>{let r=e.sourceCode.getCommentsBefore(s).at(-1);if(r===void 0||!y(r))return;let a=Ae(e.sourceCode,r);if(a===null||!A(n,e.sourceCode.visitorKeys))return;let u=e.sourceCode.getIndexFromLoc({line:a.from,column:0}),d=e.sourceCode.getIndexFromLoc({line:a.to+1,column:0});e.report({loc:{start:{line:a.from,column:0},end:{line:a.to,column:(e.sourceCode.lines[a.to-1]??"").length}},messageId:"voidReturns",fix:g=>g.removeRange([u,d])});};return {FunctionDeclaration(n){i(n,h(n));},VariableDeclarator(n){(n.init?.type==="ArrowFunctionExpression"||n.init?.type==="FunctionExpression")&&i(n.init,h(n.init));},MethodDefinition(n){n.value.type==="FunctionExpression"&&i(n.value,n);}}}},it=new Q;var ee=class extends p{name="no-line-comment-backticks";defaultOptions=[];meta={type:"suggestion",fixable:"code",docs:{description:"Disallow backticks in `//` line comments, use double quotes for code references.",recommended:true,category:"base"},schema:[],messages:{backticks:l({problem:"This line comment wraps `{{text}}` in backticks.",why:"Backticks only render as code inside a JSDoc block, in a `//` comment they stay literal characters, so double quotes read better",fix:'Wrap it in double quotes instead: "{{text}}"'})}};create(e){return {Program(){for(let i of e.sourceCode.getAllComments())if(!(i.type!=="Line"||b(i)))for(let n of Ce(i))e.report({loc:{start:e.sourceCode.getLocFromIndex(n.start),end:e.sourceCode.getLocFromIndex(n.end+1)},messageId:"backticks",data:{text:n.text},fix:s=>[s.replaceTextRange([n.start,n.start+1],'"'),s.replaceTextRange([n.end,n.end+1],'"')]});}}}},rt=new ee;var te=class extends p{name="no-line-comment-period";defaultOptions=[];meta={type:"layout",fixable:"code",docs:{description:"Disallow prose periods in `//` line comments (code-reference dots and ellipses are allowed).",recommended:true},schema:[],messages:{period:l({problem:"This line comment ends with a period.",why:"Line comments should be short, clear fragments, not full sentences, so a closing period is just noise, dots inside code references like `foo.bar` are allowed.",fix:"Remove the period and keep the comment terse."}),sentence:l({problem:"This line comment runs two sentences together with a period.",why:"Line comments should be short, clear fragments, dropping the period on its own would leave a run-on, so the sentences belong on separate lines",fix:"Split it into one `//` line per fragment, or reword it as a single fragment (reported, not auto-fixed, so wrapped prose is never mangled)"})}};create(e){return {Program(){for(let i of e.sourceCode.getAllComments())if(i.type==="Line")for(let n of ke(i)){let s={start:e.sourceCode.getLocFromIndex(n.index),end:e.sourceCode.getLocFromIndex(n.index+1)};if(n.terminal){e.report({loc:s,messageId:"period",fix:r=>r.removeRange([n.index,n.index+1])});continue}e.report({loc:s,messageId:"sentence"});}}}}},nt=new te;var ie=class extends p{name="no-property-access-alias";defaultOptions=[];meta={type:"suggestion",docs:{description:"Disallow a `const` whose whole value is a single property access, inline the expression instead.",recommended:true,category:"base"},schema:[],messages:{propertyAccessAlias:l({problem:"`{{name}}` only aliases the property access `{{expression}}`.",why:"A variable that just renames a property hides where the value comes from when scanning the code",fix:"Remove it and use `{{expression}}` inline, or use `let` if it is reassigned later"})}};create(e){let i=[],n=new Set,s=r=>{if(r.type!=="MemberExpression")return;let a=C(r);a!==null&&n.add(a);};return {AssignmentExpression(r){s(r.left);},UpdateExpression(r){s(r.argument);},VariableDeclarator(r){if(r.parent.type!=="VariableDeclaration"||r.parent.kind!=="const"||r.parent.parent.type==="ExportNamedDeclaration"||r.id.type!=="Identifier"||r.init===null||r.id.typeAnnotation!==void 0)return;let a=C(r.init);if(a===null)return;let u=a.slice(0,a.indexOf("."));u!=="this"&&D(e.sourceCode.getScope(r),u)||i.push({node:r,name:r.id.name,path:a,expression:e.sourceCode.getText(r.init)});},"Program:exit"(){for(let r of i)Ue(n,r.path)||e.report({node:r.node,messageId:"propertyAccessAlias",data:{name:r.name,expression:r.expression}});}}}},st=new ie;var re=class extends p{name="no-property-destructuring";defaultOptions=[];meta={type:"suggestion",docs:{description:"Disallow shorthand destructuring off a plain object reference, access the property directly.",recommended:true,category:"base"},schema:[],messages:{destructure:l({problem:"Destructuring from `{{source}}` here just aliases its properties.",why:"Reading `{{source}}.x` at the use site keeps the origin visible, destructuring a plain object hides where a value comes from (destructuring a call or hook result is fine)",fix:"Access the properties on `{{source}}` directly instead of destructuring"})}};create(e){return {VariableDeclarator(i){i.parent.type!=="VariableDeclaration"||i.parent.kind!=="const"||i.parent.parent.type!=="ExportNamedDeclaration"&&(i.id.type!=="ObjectPattern"||i.init===null||i.init.type!=="Identifier"&&!_e(i.init)||We(i.id)&&e.report({node:i,messageId:"destructure",data:{source:e.sourceCode.getText(i.init)}}));}}}},ot=new re;var ne=class extends p{name="no-relative-imports";defaultOptions=[{allowIn:[]}];meta={type:"suggestion",docs:{description:"Disallow relative import and re-export specifiers, use the package path alias.",recommended:true,category:"base"},schema:[{type:"object",properties:{allowIn:{type:"array",items:{type:"string"}}},additionalProperties:false}],messages:{relative:l({problem:"This import uses a relative path (`{{path}}`).",why:"A relative path breaks when a file moves and hides which package a module belongs to, the path alias is stable and explicit",fix:"Import through the package alias (`#...` or `@frontend/...`) instead of a relative path"})}};create(e,i){let n=i[0]?.allowIn??[];if(n.length>0&&E(e.filename,n))return {};let s=r=>{r!=null&&(!r.value.startsWith("./")&&!r.value.startsWith("../")||e.report({node:r,messageId:"relative",data:{path:r.value}}));};return {ImportDeclaration(r){s(r.source);},ExportNamedDeclaration(r){s(r.source);},ExportAllDeclaration(r){s(r.source);},ImportExpression(r){r.source.type==="Literal"&&typeof r.source.value=="string"&&s(r.source);}}}},at=new ne;var se=class extends p{name="no-single-line-jsdoc";defaultOptions=[];meta={type:"layout",fixable:"code",docs:{description:"Require JSDoc comments to span multiple lines rather than sit on a single line.",recommended:true},schema:[],messages:{singleLine:l({problem:"This JSDoc comment is written on a single line.",why:"Multi-line JSDoc is easier to read, diff, and extend with additional tags, and is the house style.",fix:"Put the opening `/**`, the ` * ` content, and the closing `*/` each on their own line."})}};create(e){return {Program(){for(let i of e.sourceCode.getAllComments()){if(!y(i)||i.loc.start.line!==i.loc.end.line)continue;let n=i.value.replace(/^\*/,"").trim();n.length!==0&&e.report({loc:i.loc,messageId:"singleLine",fix(s){let r=" ".repeat(i.loc.start.column),a=`/**
|
|
3
|
+
- fix: ${i}`}function Re(t){return t.parent.type==="ExportDefaultDeclaration"&&t.superClass?.type==="Identifier"&&t.superClass.name==="BaseSchema"}function Oe(t){if(t.callee.type!=="MemberExpression"||t.callee.property.type!=="Identifier"||t.callee.property.name!=="createTable"||t.callee.object.type!=="MemberExpression"||t.callee.object.property.type!=="Identifier"||t.callee.object.property.name!=="schema")return null;let e=t.arguments.at(-1);return e?.type!=="ArrowFunctionExpression"&&e?.type!=="FunctionExpression"||e.body.type!=="BlockStatement"||e.params[0]?.type!=="Identifier"?null:{body:e.body.body,builderName:e.params[0].name}}function Ne(t,e){if(t.type!=="ExpressionStatement")return null;let i=_t(t.expression,e);return i===null?null:l.MIGRATIONS.INDEX_METHODS.has(i.method)?"index":i.method==="timestamps"?"timestamp":l.MIGRATIONS.TIMESTAMP_METHODS.has(i.method)?i.firstArgument!==void 0&&l.MIGRATIONS.AUDIT_TIMESTAMPS.has(i.firstArgument)?"timestamp":null:"column"}function _t(t,e){let i=t;for(;i.type==="CallExpression"&&i.callee.type==="MemberExpression";){if(i.callee.object.type==="Identifier"&&i.callee.object.name===e){if(i.callee.property.type!=="Identifier")return null;let n=i.arguments[0],s=n?.type==="Literal"&&typeof n.value=="string"?n.value:void 0;return {method:i.callee.property.name,firstArgument:s}}i=i.callee.object;}return null}var F=class extends p{name="migration-table-order";defaultOptions=[];meta={type:"suggestion",docs:{description:"Group migration table statements as columns, then timestamps, then indexes and constraints.",recommended:true,category:"adonisjs"},schema:[],messages:{outOfOrder:c({problem:"This {{category}} is out of order in the table definition.",why:"A migration reads consistently when columns come first, then timestamps, then indexes and constraints, each grouped together",fix:"Move it into its group so the order stays columns, timestamps, then indexes and constraints"})}};create(e){return {CallExpression(i){let n=Oe(i);if(n===null)return;let s=0;for(let r of n.body){let o=Ne(r,n.builderName);if(o===null)continue;let m=l.MIGRATIONS.CATEGORY_ORDER.indexOf(o);m<s&&e.report({node:r,messageId:"outOfOrder",data:{category:o}}),s=Math.max(s,m);}}}}},Ie=new F;function Le(t){return t.parent.type==="ExportDefaultDeclaration"&&t.id?.name.endsWith("Controller")===true}function P(t){let e=[];for(let i of t.matchAll(l.WORDS.SUB_WORD))i.index!==void 0&&e.push({text:i[0],index:i.index});return e}function j(t,e){return t===t.toUpperCase()?e.toUpperCase():t.charAt(0)===t.charAt(0).toUpperCase()?e.charAt(0).toUpperCase()+e.slice(1):e}function Ce(t){return t!==void 0&&l.WORDS.WORD_CHAR.test(t)}function h(t){return l.COMMENTS.DIRECTIVE.test(t.value)}function ke(t){let e=t.range[0]+2;if(t.type==="Line"){let n=t.value.match(/\S/u);return n?.index===void 0?null:{index:e+n.index,char:n[0]}}let i=0;for(let n of t.value.split(`
|
|
4
|
+
`)){let s=(n.match(/^\s*\*?\s*/u)?.[0]??"").length,r=n.slice(s).charAt(0);if(r!=="")return {index:e+i+s,char:r};i+=n.length+1;}return null}function De(t){let e=[],i=t.range[0]+2,n=null;for(let s=0;s<t.value.length;s++){let r=t.value.charAt(s);if(n!==null){r===n&&(n=null);continue}if(l.COMMENTS.QUOTES.has(r)&&t.value.includes(r,s+1)){n=r;continue}if(r!==".")continue;if(t.value.charAt(s+1)==="."){for(;t.value.charAt(s+1)===".";)s++;continue}let o=t.value.slice(s+1);o!==""&&!/^\s/u.test(o)||Jt(t.value.slice(0,s+1))||e.push({index:i+s,terminal:o.trim()===""});}return e}function we(t){let e=[],i=t.range[0]+2;for(let n=0;n<t.value.length;n++){if(t.value.charAt(n)!=="`")continue;if(t.value.charAt(n+1)==="`"){for(;t.value.charAt(n+1)==="`";)n++;continue}let s=t.value.indexOf("`",n+1);if(s===-1)break;let r=t.value.slice(n+1,s);r.includes('"')||e.push({start:i+n,end:i+s,text:r}),n=s;}return e}function Jt(t){let e=t.toLowerCase();return l.COMMENTS.ABBREVIATIONS.some(i=>{if(!e.endsWith(i))return false;let n=e.charAt(e.length-i.length-1);return n===""||!Ce(n)})}function S(t){return t.type==="Block"&&t.value.startsWith("*")}function Ut(t){let e=(t.type==="ExportDefaultDeclaration"||t.type==="ExportNamedDeclaration")&&t.declaration!==null?t.declaration:t,n=("decorators"in e?e.decorators:void 0)?.reduce((s,r)=>s===void 0||r.range[0]<s.range[0]?r:s,void 0);return n!==void 0&&n.range[0]<t.range[0]?n:t}function _(t,e){let i=t.getCommentsBefore(Ut(e)),n=i.length-1;for(;n>=0;){let r=i[n];if(r===void 0||!h(r))break;n--;}let s=i[n];return s!==void 0&&S(s)?s:null}function Me(t){let e=new Set;for(let i of t.value.split(`
|
|
5
|
+
`)){let n=i.match(l.JSDOC.PARAM_TAG)?.[1];n!==void 0&&e.add(n);}return e}function Ae(t){return t.value.split(`
|
|
6
|
+
`).some(e=>{let i=I(e);return i==="returns"||i==="return"})}function T(t,e){return _(t,e)!==null}function J(t){return /^\s*\*\s*$/.test(t)}function I(t){return t.match(l.JSDOC.TAG)?.[1]??null}function U(t){return I(t)!==null}function ve(t){let e=[];for(let i of t.value.split(`
|
|
7
|
+
`)){let n=i.replace(/^\s*\*? ?/,"").trimEnd();if(n.startsWith("@"))break;e.push(n);}return e.join(" ").replace(/\s+/g," ").trim()}function ze(t,e){let i=-1;for(let s=e.loc.start.line+1;s<e.loc.end.line;s++){let r=I(t.lines[s-1]??"");if(r==="returns"||r==="return"){i=s;break}}if(i===-1)return null;let n=e.loc.end.line-1;for(let s=i+1;s<e.loc.end.line;s++)if(U(t.lines[s-1]??"")){n=s-1;break}return {from:i,to:n}}var q=class extends p{name="require-controller-jsdoc";defaultOptions=[];meta={type:"suggestion",docs:{description:"Require a JSDoc comment describing an AdonisJS controller.",recommended:true,category:"adonisjs"},schema:[],messages:{missingJSDoc:c({problem:"This controller has no JSDoc describing what it does.",why:"A controller's responsibility should be readable at a glance, before diving into its handler methods",fix:"Add a `/** ... */` JSDoc above the controller class summarizing what it handles"})}};create(e){return {ClassDeclaration(i){Le(i)&&(T(e.sourceCode,i.parent)||e.report({node:i.id??i,messageId:"missingJSDoc"}));}}}},Fe=new q;var B=class extends p{name="require-migration-jsdoc";defaultOptions=[];meta={type:"suggestion",docs:{description:"Require a JSDoc comment describing an AdonisJS migration.",recommended:true,category:"adonisjs"},schema:[],messages:{missingJSDoc:c({problem:"This migration has no JSDoc describing what it does.",why:"A migration's intent should be readable at a glance, the timestamped filename does not convey the schema change",fix:"Add a `/** ... */` JSDoc above the migration class summarizing the change"})}};create(e){return {ClassDeclaration(i){Re(i)&&(T(e.sourceCode,i.parent)||e.report({node:i.id??i,messageId:"missingJSDoc"}));}}}},Pe=new B;function qt(t){let e=t.replace(/\\/g,"/"),i="^";for(let n=0;n<e.length;n++){let s=e[n];if(s===void 0)break;s==="*"?e[n+1]==="*"?(i+=".*",n++,e[n+1]==="/"&&n++):i+="[^/]*":"\\^$.|?+()[]{}".includes(s)?i+=`\\${s}`:i+=s;}return new RegExp(`${i}$`)}function x(t,e){let i=t.replace(/\\/g,"/");return e.some(n=>qt(n).test(i))}var W=class extends p{name="require-validated-request";defaultOptions=[{allowIn:[]}];meta={type:"suggestion",docs:{description:"Require request data to be read through a Vine validator, not raw request accessors.",recommended:true,category:"adonisjs"},schema:[{type:"object",properties:{allowIn:{type:"array",items:{type:"string"}}},additionalProperties:false}],messages:{rawRead:c({problem:"`request.{{method}}()` reads request data directly.",why:"Request data must pass through a Vine validator so it is typed and checked, a raw accessor bypasses that contract",fix:"Read it through `request.validateUsing(someValidator)` instead"})}};create(e,i){let n=i[0]?.allowIn??[];if(n.length>0&&x(e.filename,n))return {};let s=r=>r.type==="Identifier"?r.name==="request":r.type==="MemberExpression"&&r.property.type==="Identifier"&&r.property.name==="request";return {CallExpression(r){r.callee.type!=="MemberExpression"||r.callee.property.type!=="Identifier"||!l.REQUEST.RAW_ACCESSORS.has(r.callee.property.name)||!s(r.callee.object)||e.report({node:r.callee.property,messageId:"rawRead",data:{method:r.callee.property.name}});}}}},je=new W;var G=class extends p{name="catch-error-name";defaultOptions=[];meta={type:"suggestion",docs:{description:"Require a `catch` clause to bind its error as `error`.",recommended:true,category:"base"},schema:[],messages:{rename:c({problem:"This `catch` binds the error as `{{name}}`.",why:"Every catch binds the error as `error` so error handling reads the same across the codebase",fix:"Rename the binding to `error`, or `_error` if it is intentionally unused"})}};create(e){return {CatchClause(i){i.param?.type==="Identifier"&&(i.param.name==="error"||i.param.name.startsWith("_")||e.report({node:i.param,messageId:"rename",data:{name:i.param.name}}));}}}},_e=new G;var V=class extends p{name="max-jsdoc-description-length";defaultOptions=[{max:l.JSDOC.MAX_DESCRIPTION_LENGTH}];meta={type:"suggestion",docs:{description:"Enforce a maximum character length for a JSDoc description.",recommended:true,category:"base"},schema:[{type:"object",properties:{max:{type:"integer",minimum:1}},additionalProperties:false}],messages:{tooLong:c({problem:"This JSDoc description is {{length}} characters, over the {{max}}-character limit.",why:"A JSDoc description should summarize what something is, an oversized one usually restates the code or explains how it is used, which does not belong here",fix:'Trim it to a concise summary of what it does, and remove any note about how or where it is used (e.g "used by X to ...", "called from Y"), which is an anti-pattern'})}};create(e,i){let n=i[0]?.max??l.JSDOC.MAX_DESCRIPTION_LENGTH;return {Program(){for(let s of e.sourceCode.getAllComments()){if(!S(s))continue;let r=ve(s).length;r<=n||e.report({loc:s.loc,messageId:"tooLong",data:{length:r,max:n}});}}}}},Je=new V;var $=class extends p{name="max-line-comment-length";defaultOptions=[{max:l.COMMENTS.MAX_RUN_LENGTH}];meta={type:"suggestion",docs:{description:"Enforce a maximum prose length for a run of consecutive `//` line comments.",recommended:true,category:"base"},schema:[{type:"object",properties:{max:{type:"integer",minimum:1}},additionalProperties:false}],messages:{tooLong:c({problem:"This run of line comments is {{length}} characters, over the {{max}}-character limit.",why:"A wall of stacked `//` lines is a paragraph in disguise, it buries the point and is hard to read next to the code",fix:"Cut it to the essential why, or move the long explanation into a JSDoc on the declaration it belongs to"})}};create(e,i){let n=i[0]?.max??l.COMMENTS.MAX_RUN_LENGTH,s=o=>o.map(m=>m.value.trim()).filter(m=>m!=="").join(" "),r=o=>{if(o.length===0)return;let m=s(o).length;if(m<=n)return;let a=o[0],f=o.at(-1);a===void 0||f===void 0||e.report({loc:{start:a.loc.start,end:f.loc.end},messageId:"tooLong",data:{length:m,max:n}});};return {Program(){let o=[];for(let m of e.sourceCode.getAllComments()){let a=o.at(-1),f=a!==void 0&&m.loc.start.line===a.loc.start.line+1;if(m.type!=="Line"||h(m)||!f){r(o),o=m.type==="Line"&&!h(m)?[m]:[];continue}o.push(m);}r(o);}}}},Ue=new $;function k(t){let e=[],i=t;for(;;){if(i.type==="ChainExpression"||i.type==="TSNonNullExpression"){i=i.expression;continue}if(i.type==="MemberExpression"){if(i.computed||i.property.type!=="Identifier")return null;e.unshift(i.property.name),i=i.object;continue}break}return e.length===0?null:i.type==="ThisExpression"?["this",...e].join("."):i.type==="Identifier"?[i.name,...e].join("."):null}function qe(t){return k(t)!==null}function D(t,e){let i=ASTUtils.findVariable(t,e);if(i===null)return false;let n=new Set(i.defs.map(s=>s.name));return i.references.some(s=>s.isWrite()&&!n.has(s.identifier))}function Be(t,e){for(let i of t)if(e===i||e.startsWith(`${i}.`))return true;return false}function We(t){return t.properties.length===0?false:t.properties.every(e=>e.type==="Property"&&e.shorthand&&!e.computed&&e.value.type==="Identifier")}var H=class extends p{name="no-alias-variables";defaultOptions=[];meta={type:"suggestion",docs:{description:"Disallow a `const` whose whole value is another variable, use the source directly.",recommended:true,category:"base"},schema:[],messages:{alias:c({problem:"`{{name}}` only aliases `{{source}}`.",why:"A variable that just renames another hides the original and adds a name to track for no gain",fix:"Remove it and use `{{source}}` directly, or rename `{{source}}` itself if the new name is better"})}};create(e){return {VariableDeclarator(i){i.parent.type!=="VariableDeclaration"||i.parent.kind!=="const"||i.parent.parent.type!=="ExportNamedDeclaration"&&(i.id.type!=="Identifier"||i.init?.type!=="Identifier"||i.id.typeAnnotation===void 0&&(D(e.sourceCode.getScope(i),i.init.name)||e.report({node:i,messageId:"alias",data:{name:i.id.name,source:i.init.name}})));}}}},Ge=new H;var Ve={colour:"color",colours:"colors",coloured:"colored",colouring:"coloring",behaviour:"behavior",behaviours:"behaviors",favour:"favor",favours:"favors",favoured:"favored",favouring:"favoring",favourable:"favorable",favourite:"favorite",favourites:"favorites",flavour:"flavor",flavours:"flavors",honour:"honor",honours:"honors",honoured:"honored",honouring:"honoring",labour:"labor",labours:"labors",laboured:"labored",labouring:"laboring",neighbour:"neighbor",neighbours:"neighbors",humour:"humor",humours:"humors",rumour:"rumor",rumours:"rumors",harbour:"harbor",harbours:"harbors",endeavour:"endeavor",endeavours:"endeavors",endeavoured:"endeavored",endeavouring:"endeavoring",normalise:"normalize",normalised:"normalized",normalising:"normalizing",normalisation:"normalization",initialise:"initialize",initialises:"initializes",initialised:"initialized",initialising:"initializing",initialisation:"initialization",serialise:"serialize",serialised:"serialized",serialising:"serializing",serialisation:"serialization",organise:"organize",organises:"organizes",organised:"organized",organising:"organizing",organisation:"organization",optimise:"optimize",optimised:"optimized",optimising:"optimizing",optimisation:"optimization",customise:"customize",customised:"customized",customising:"customizing",sanitise:"sanitize",sanitised:"sanitized",sanitising:"sanitizing",synchronise:"synchronize",synchronised:"synchronized",synchronising:"synchronizing",synchronisation:"synchronization",authorise:"authorize",authorised:"authorized",authorising:"authorizing",authorisation:"authorization",finalise:"finalize",finalised:"finalized",finalising:"finalizing",capitalise:"capitalize",capitalised:"capitalized",capitalising:"capitalizing",categorise:"categorize",categorises:"categorizes",categorised:"categorized",categorising:"categorizing",categorisation:"categorization",utilise:"utilize",utilises:"utilizes",utilised:"utilized",utilising:"utilizing",utilisation:"utilization",realise:"realize",realises:"realizes",realised:"realized",realising:"realizing",realisation:"realization",recognise:"recognize",recognises:"recognizes",recognised:"recognized",recognising:"recognizing",summarise:"summarize",summarises:"summarizes",summarised:"summarized",summarising:"summarizing",specialise:"specialize",specialises:"specializes",specialised:"specialized",specialising:"specializing",specialisation:"specialization",minimise:"minimize",minimises:"minimizes",minimised:"minimized",minimising:"minimizing",minimisation:"minimization",maximise:"maximize",maximises:"maximizes",maximised:"maximized",maximising:"maximizing",maximisation:"maximization",prioritise:"prioritize",prioritises:"prioritizes",prioritised:"prioritized",prioritising:"prioritizing",prioritisation:"prioritization",standardise:"standardize",standardises:"standardizes",standardised:"standardized",standardising:"standardizing",standardisation:"standardization",harmonise:"harmonize",harmonises:"harmonizes",harmonised:"harmonized",harmonising:"harmonizing",harmonisation:"harmonization",centralise:"centralize",centralises:"centralizes",centralised:"centralized",centralising:"centralizing",centralisation:"centralization",decentralise:"decentralize",decentralises:"decentralizes",decentralised:"decentralized",decentralising:"decentralizing",decentralisation:"decentralization",emphasise:"emphasize",emphasises:"emphasizes",emphasised:"emphasized",emphasising:"emphasizing",visualise:"visualize",visualises:"visualizes",visualised:"visualized",visualising:"visualizing",visualisation:"visualization",analyse:"analyze",analyses:"analyzes",analysed:"analyzed",analysing:"analyzing",paralyse:"paralyze",paralyses:"paralyzes",paralysed:"paralyzed",paralysing:"paralyzing",centre:"center",centred:"centered",centres:"centers",fibre:"fiber",fibres:"fibers",metre:"meter",metres:"meters",litre:"liter",litres:"liters",theatre:"theater",theatres:"theaters",calibre:"caliber",spectre:"specter",spectres:"specters",licence:"license",defence:"defense",offence:"offense",pretence:"pretense",practise:"practice",cancelled:"canceled",cancelling:"canceling",labelled:"labeled",labelling:"labeling",modelled:"modeled",modelling:"modeling",travelled:"traveled",travelling:"traveling",signalled:"signaled",signalling:"signaling",fuelled:"fueled",fuelling:"fueling",marvellous:"marvelous",counsellor:"counselor",fulfil:"fulfill",fulfils:"fulfills",fulfilment:"fulfillment",enrol:"enroll",enrols:"enrolls",enrolment:"enrollment",instalment:"installment",skilful:"skillful",wilful:"willful",dialogue:"dialog",dialogues:"dialogs",catalogue:"catalog",catalogues:"catalogs",analogue:"analog",analogues:"analogs",grey:"gray",artefact:"artifact",artefacts:"artifacts",sceptic:"skeptic",sceptical:"skeptical",programme:"program",programmes:"programs",enquiry:"inquiry",enquiries:"inquiries",aluminium:"aluminum",tyre:"tire",tyres:"tires"};function $e(t,e,i){let n=Object.create(null);for(let[s,r]of Object.entries(t))n[s.toLowerCase()]=r;for(let[s,r]of Object.entries(e))n[s.toLowerCase()]=r;for(let s of i)delete n[s.toLowerCase()];return n}var K=class extends p{name="no-british-english";defaultOptions=[{extra:{},ignore:[]}];meta={type:"suggestion",docs:{description:"Disallow British English spellings in identifiers and comments.",recommended:true,category:"base"},fixable:"code",schema:[{type:"object",properties:{extra:{type:"object",additionalProperties:{type:"string"}},ignore:{type:"array",items:{type:"string"}}},additionalProperties:false}],messages:{british:c({problem:"British spelling `{{british}}`, this codebase uses American English.",why:"One spelling convention keeps identifiers and docs consistent and searchable",fix:"Use `{{american}}` instead"})}};create(e,i){let n=$e(Ve,i[0]?.extra??{},i[0]?.ignore??[]);return {Identifier(s){if(!(s.parent.type==="MemberExpression"&&s.parent.property===s&&!s.parent.computed))for(let r of P(s.name)){let o=n[r.text.toLowerCase()];o!==void 0&&e.report({node:s,messageId:"british",data:{british:r.text,american:j(r.text,o)}});}},Program(){for(let s of e.sourceCode.getAllComments())for(let r of P(s.value)){let o=n[r.text.toLowerCase()];if(o===void 0)continue;let m=j(r.text,o),a=s.range[0]+2+r.index,f=a+r.text.length;e.report({loc:{start:e.sourceCode.getLocFromIndex(a),end:e.sourceCode.getLocFromIndex(f)},messageId:"british",data:{british:r.text,american:m},fix:y=>y.replaceTextRange([a,f],m)});}}}}},He=new K;function Ke(t){let e=t.replace(/^\s*\*?\s*/,"").trimEnd();return e.length===0?false:l.COMMENTS.BOX_DRAWING.test(e)||l.COMMENTS.PURE_SEPARATOR.test(e)||l.COMMENTS.WRAPPED_LABEL.test(e)}var X=class extends p{name="no-decorative-comment-separators";defaultOptions=[{allowIn:[]}];meta={type:"layout",docs:{description:"Disallow decorative separators (banners, box-drawing, repeated dashes) inside comments.",recommended:true,category:"base"},schema:[{type:"object",properties:{allowIn:{type:"array",items:{type:"string"}}},additionalProperties:false}],messages:{decorative:c({problem:"This comment uses a decorative separator.",why:"Repeated separator characters and box-drawing lines are visual noise that add nothing over a plain label",fix:"Remove the separator, a one-line label or a blank line already divides sections clearly"})}};create(e,i){let n=i[0]?.allowIn??[];return n.length>0&&x(e.filename,n)?{}:{Program(){for(let s of e.sourceCode.getAllComments()){let r=s.value.split(`
|
|
8
|
+
`);for(let o=0;o<r.length;o++){let m=r[o];if(m===void 0||!Ke(m))continue;let a=s.loc.start.line+o,f=e.sourceCode.lines[a-1]??"";e.report({loc:{start:{line:a,column:0},end:{line:a,column:f.length}},messageId:"decorative"});}}}}}},Xe=new X;var Wt={strings:"String",templates:"Template",jsx:"JSXText"};function w(t,e){let i=new Set(e),n=[];if(i.size===0)return n;let s=new Set([...i].map(r=>Wt[r]).filter(r=>r!==void 0));for(let r of t.ast.tokens??[])s.has(r.type)&&n.push(r.range);if(i.has("comments"))for(let r of t.getAllComments())n.push(r.range);return n}function M(t,e){return e.some(([i,n])=>t>=i&&t<n)}var Y=class extends p{name="no-em-dash";defaultOptions=[{allow:[]}];meta={type:"suggestion",docs:{description:"Disallow the em dash (\u2014) character anywhere in the source.",recommended:true},schema:[{type:"object",properties:{allow:{type:"array",items:{type:"string",enum:["strings","templates","jsx","comments"]}}},additionalProperties:false}],messages:{emDash:c({problem:"Found an em dash (\u2014) character.",why:"Em dashes are typically introduced by AI-generated or auto-formatted text and are discouraged here.",fix:"Replace the em dash with a hyphen (-), a comma (,), or reword the sentence to avoid it, or allow it here with the rule's `allow` option if it is deliberate user-facing copy."})}};create(e,i){return {Program(){let n=e.sourceCode.getText(),s=w(e.sourceCode,i[0]?.allow??[]);for(let r=0;r<n.length;r++)n[r]===l.EM_DASH&&(M(r,s)||e.report({loc:{start:e.sourceCode.getLocFromIndex(r),end:e.sourceCode.getLocFromIndex(r+1)},messageId:"emDash"}));}}}},Ye=new Y;var Z=class extends p{name="no-emojis";defaultOptions=[{allow:[]}];meta={type:"suggestion",docs:{description:"Disallow emoji characters anywhere in the source.",recommended:true,category:"base"},schema:[{type:"object",properties:{allow:{type:"array",items:{type:"string",enum:["strings","templates","jsx","comments"]}}},additionalProperties:false}],messages:{emoji:c({problem:"Found an emoji ({{emoji}}).",why:"Emojis are usually introduced by AI-generated text and add noise to code, comments, and identifiers",fix:"Remove the emoji, or allow it here with the rule's `allow` option if it is deliberate user-facing copy"})}};create(e,i){return {Program(){let n=e.sourceCode.getText(),s=w(e.sourceCode,i[0]?.allow??[]);for(let r of n.matchAll(l.EMOJI))M(r.index,s)||e.report({loc:{start:e.sourceCode.getLocFromIndex(r.index),end:e.sourceCode.getLocFromIndex(r.index+r[0].length)},messageId:"emoji",data:{emoji:r[0]}});}}}},Ze=new Z;var Q=class extends p{name="no-jsdoc-blank-before-tags";defaultOptions=[];meta={type:"layout",fixable:"code",docs:{description:"Disallow blank lines before JSDoc tags such as `@param` or `@returns`.",recommended:true},schema:[],messages:{blankBeforeTag:c({problem:"There is a blank line before a JSDoc tag.",why:"Tags should follow the description directly; an empty line there is noise that inflates the comment.",fix:"Remove the blank line so the tag follows on directly."})}};create(e){return {Program(){for(let i of e.sourceCode.getAllComments())if(S(i)&&i.loc.start.line!==i.loc.end.line)for(let n=i.loc.start.line;n<=i.loc.end.line;n++){let s=e.sourceCode.lines[n-1];if(s===void 0||!J(s))continue;let r=n;for(;r<i.loc.end.line&&J(e.sourceCode.lines[r]??"");)r++;let o=e.sourceCode.lines[r];if(o!==void 0&&U(o)){let m=e.sourceCode.getIndexFromLoc({line:n,column:0}),a=e.sourceCode.getIndexFromLoc({line:r+1,column:0});e.report({loc:{start:{line:n,column:0},end:{line:r,column:s.length}},messageId:"blankBeforeTag",fix:f=>f.removeRange([m,a])});}n=r;}}}}},Qe=new Q;function E(t){let e=t;return e.parent.type==="Property"||e.parent.type==="MethodDefinition"?e.parent:(e.parent.type==="VariableDeclarator"&&e.parent.parent.type==="VariableDeclaration"&&(e=e.parent.parent),(e.parent.type==="ExportNamedDeclaration"||e.parent.type==="ExportDefaultDeclaration")&&(e=e.parent),e)}function et(t){return t.parent?.type==="Program"}function tt(t){let e=[],i=n=>{switch(n.type){case "Identifier":e.push({kind:"name",name:n.name,node:n});return;case "AssignmentPattern":i(n.left);return;case "RestElement":i(n.argument);return;case "TSParameterProperty":i(n.parameter);return;case "ObjectPattern":{let s=[];for(let r of n.properties)r.type==="RestElement"?r.argument.type==="Identifier"&&s.push({name:r.argument.name,node:r.argument}):r.key.type==="Identifier"&&s.push({name:r.key.name,node:r.key});s.length>0&&e.push({kind:"object",names:s,node:n});return}default:return}};for(let n of t.params)i(n);return e}function it(t){let e=t.parent;for(;e;){if(l.FUNCTIONS.NODE_TYPES.has(e.type))return e;e=e.parent;}return null}function rt(t){return t.type==="ArrowFunctionExpression"&&t.params.length===0&&t.body.type==="ImportExpression"}function R(t){if((t.type==="FunctionDeclaration"||t.type==="FunctionExpression")&&t.id)return t.id.name;if(t.parent.type==="VariableDeclarator"&&t.parent.id.type==="Identifier")return t.parent.id.name}function O(t,e,i){if(t.type==="ReturnStatement")return i(t.argument);for(let n of e[t.type]??[]){let s=t[n],r=Array.isArray(s)?s:[s];for(let o of r){let m=o;if(!(!m||typeof m.type!="string")&&!l.FUNCTIONS.NODE_TYPES.has(m.type)&&O(m,e,i))return true}}return false}function Gt(t,e){return t.type==="ArrowFunctionExpression"&&t.body.type!=="BlockStatement"?true:O(t.body,e,i=>i!==null)}function Vt(t){return t.typeAnnotation.type==="TSVoidKeyword"?true:t.typeAnnotation.type==="TSTypeReference"&&t.typeAnnotation.typeName.type==="Identifier"&&t.typeAnnotation.typeName.name==="Promise"?t.typeAnnotation.typeArguments?.params.length===1&&t.typeAnnotation.typeArguments?.params[0]?.type==="TSVoidKeyword":false}function A(t,e){return t.returnType?Vt(t.returnType):!Gt(t,e)}var ee=class extends p{name="no-jsdoc-returns-on-void";defaultOptions=[];meta={type:"suggestion",fixable:"code",docs:{description:"Disallow a JSDoc `@returns` tag on a function that returns nothing.",recommended:true,category:"base"},schema:[],messages:{voidReturns:c({problem:"This function returns nothing, but its JSDoc has a `@returns` tag.",why:"A `@returns` on a void function documents a value that never exists and drifts from the code",fix:"Remove the `@returns` tag"})}};create(e){let i=(n,s)=>{let r=e.sourceCode.getCommentsBefore(s).at(-1);if(r===void 0||!S(r))return;let o=ze(e.sourceCode,r);if(o===null||!A(n,e.sourceCode.visitorKeys))return;let m=e.sourceCode.getIndexFromLoc({line:o.from,column:0}),a=e.sourceCode.getIndexFromLoc({line:o.to+1,column:0});e.report({loc:{start:{line:o.from,column:0},end:{line:o.to,column:(e.sourceCode.lines[o.to-1]??"").length}},messageId:"voidReturns",fix:f=>f.removeRange([m,a])});};return {FunctionDeclaration(n){i(n,E(n));},VariableDeclarator(n){(n.init?.type==="ArrowFunctionExpression"||n.init?.type==="FunctionExpression")&&i(n.init,E(n.init));},MethodDefinition(n){n.value.type==="FunctionExpression"&&i(n.value,n);}}}},nt=new ee;var te=class extends p{name="no-line-comment-backticks";defaultOptions=[];meta={type:"suggestion",fixable:"code",docs:{description:"Disallow backticks in `//` line comments, use double quotes for code references.",recommended:true,category:"base"},schema:[],messages:{backticks:c({problem:"This line comment wraps `{{text}}` in backticks.",why:"Backticks only render as code inside a JSDoc block, in a `//` comment they stay literal characters, so double quotes read better",fix:'Wrap it in double quotes instead: "{{text}}"'})}};create(e){return {Program(){for(let i of e.sourceCode.getAllComments())if(!(i.type!=="Line"||h(i)))for(let n of we(i))e.report({loc:{start:e.sourceCode.getLocFromIndex(n.start),end:e.sourceCode.getLocFromIndex(n.end+1)},messageId:"backticks",data:{text:n.text},fix:s=>[s.replaceTextRange([n.start,n.start+1],'"'),s.replaceTextRange([n.end,n.end+1],'"')]});}}}},st=new te;var ie=class extends p{name="no-line-comment-period";defaultOptions=[];meta={type:"layout",fixable:"code",docs:{description:"Disallow prose periods in `//` line comments (code-reference dots and ellipses are allowed).",recommended:true},schema:[],messages:{period:c({problem:"This line comment ends with a period.",why:"Line comments should be short, clear fragments, not full sentences, so a closing period is just noise, dots inside code references like `foo.bar` are allowed.",fix:"Remove the period and keep the comment terse."}),sentence:c({problem:"This line comment runs two sentences together with a period.",why:"Line comments should be short, clear fragments, dropping the period on its own would leave a run-on, so the sentences belong on separate lines",fix:"Split it into one `//` line per fragment, or reword it as a single fragment (reported, not auto-fixed, so wrapped prose is never mangled)"})}};create(e){return {Program(){for(let i of e.sourceCode.getAllComments())if(i.type==="Line")for(let n of De(i)){let s={start:e.sourceCode.getLocFromIndex(n.index),end:e.sourceCode.getLocFromIndex(n.index+1)};if(n.terminal){e.report({loc:s,messageId:"period",fix:r=>r.removeRange([n.index,n.index+1])});continue}e.report({loc:s,messageId:"sentence"});}}}}},ot=new ie;var re=class extends p{name="no-property-access-alias";defaultOptions=[];meta={type:"suggestion",docs:{description:"Disallow a `const` whose whole value is a single property access, inline the expression instead.",recommended:true,category:"base"},schema:[],messages:{propertyAccessAlias:c({problem:"`{{name}}` only aliases the property access `{{expression}}`.",why:"A variable that just renames a property hides where the value comes from when scanning the code",fix:"Remove it and use `{{expression}}` inline, or use `let` if it is reassigned later"})}};create(e){let i=[],n=new Set,s=r=>{if(r.type!=="MemberExpression")return;let o=k(r);o!==null&&n.add(o);};return {AssignmentExpression(r){s(r.left);},UpdateExpression(r){s(r.argument);},VariableDeclarator(r){if(r.parent.type!=="VariableDeclaration"||r.parent.kind!=="const"||r.parent.parent.type==="ExportNamedDeclaration"||r.id.type!=="Identifier"||r.init===null||r.id.typeAnnotation!==void 0)return;let o=k(r.init);if(o===null)return;let m=o.slice(0,o.indexOf("."));m!=="this"&&D(e.sourceCode.getScope(r),m)||i.push({node:r,name:r.id.name,path:o,expression:e.sourceCode.getText(r.init)});},"Program:exit"(){for(let r of i)Be(n,r.path)||e.report({node:r.node,messageId:"propertyAccessAlias",data:{name:r.name,expression:r.expression}});}}}},at=new re;var ne=class extends p{name="no-property-destructuring";defaultOptions=[];meta={type:"suggestion",docs:{description:"Disallow shorthand destructuring off a plain object reference, access the property directly.",recommended:true,category:"base"},schema:[],messages:{destructure:c({problem:"Destructuring from `{{source}}` here just aliases its properties.",why:"Reading `{{source}}.x` at the use site keeps the origin visible, destructuring a plain object hides where a value comes from (destructuring a call or hook result is fine)",fix:"Access the properties on `{{source}}` directly instead of destructuring"})}};create(e){return {VariableDeclarator(i){i.parent.type!=="VariableDeclaration"||i.parent.kind!=="const"||i.parent.parent.type!=="ExportNamedDeclaration"&&(i.id.type!=="ObjectPattern"||i.init===null||i.init.type!=="Identifier"&&!qe(i.init)||We(i.id)&&e.report({node:i,messageId:"destructure",data:{source:e.sourceCode.getText(i.init)}}));}}}},lt=new ne;var se=class extends p{name="no-relative-imports";defaultOptions=[{allowIn:[]}];meta={type:"suggestion",docs:{description:"Disallow relative import and re-export specifiers, use the package path alias.",recommended:true,category:"base"},schema:[{type:"object",properties:{allowIn:{type:"array",items:{type:"string"}}},additionalProperties:false}],messages:{relative:c({problem:"This import uses a relative path (`{{path}}`).",why:"A relative path breaks when a file moves and hides which package a module belongs to, the path alias is stable and explicit",fix:"Import through the package alias (`#...` or `@frontend/...`) instead of a relative path"})}};create(e,i){let n=i[0]?.allowIn??[];if(n.length>0&&x(e.filename,n))return {};let s=r=>{r!=null&&(!r.value.startsWith("./")&&!r.value.startsWith("../")||e.report({node:r,messageId:"relative",data:{path:r.value}}));};return {ImportDeclaration(r){s(r.source);},ExportNamedDeclaration(r){s(r.source);},ExportAllDeclaration(r){s(r.source);},ImportExpression(r){r.source.type==="Literal"&&typeof r.source.value=="string"&&s(r.source);}}}},ct=new se;var oe=class extends p{name="no-single-line-jsdoc";defaultOptions=[];meta={type:"layout",fixable:"code",docs:{description:"Require JSDoc comments to span multiple lines rather than sit on a single line.",recommended:true},schema:[],messages:{singleLine:c({problem:"This JSDoc comment is written on a single line.",why:"Multi-line JSDoc is easier to read, diff, and extend with additional tags, and is the house style.",fix:"Put the opening `/**`, the ` * ` content, and the closing `*/` each on their own line."})}};create(e){return {Program(){for(let i of e.sourceCode.getAllComments()){if(!S(i)||i.loc.start.line!==i.loc.end.line)continue;let n=i.value.replace(/^\*/,"").trim();n.length!==0&&e.report({loc:i.loc,messageId:"singleLine",fix(s){let r=" ".repeat(i.loc.start.column),o=`/**
|
|
9
9
|
${r} * ${n}
|
|
10
|
-
${r} */`;return s.replaceTextRange(i.range,
|
|
11
|
-
|
|
10
|
+
${r} */`;return s.replaceTextRange(i.range,o)}});}}}}},pt=new oe;var ae=class extends p{name="require-capitalized-comments";defaultOptions=[];meta={type:"suggestion",fixable:"code",docs:{description:"Require a comment to start with an uppercase letter.",recommended:true,category:"base"},schema:[],messages:{capitalize:c({problem:"This comment starts with a lowercase letter.",why:"A comment reads as a sentence, and a sentence starts with a capital letter",fix:"Capitalize the first letter of the comment"})}};create(e){let i=n=>{if(n.type!=="Line")return false;let s=e.sourceCode.lines[n.loc.start.line-2];return s!==void 0&&/^\s*\/\//.test(s)};return {Program(){for(let n of e.sourceCode.getAllComments()){if(h(n)||i(n))continue;let s=ke(n);s===null||!new RegExp("\\p{Ll}","u").test(s.char)||/^(?:https?:\/\/|www\.)/u.test(e.sourceCode.getText().slice(s.index))||e.report({loc:{start:e.sourceCode.getLocFromIndex(s.index),end:e.sourceCode.getLocFromIndex(s.index+s.char.length)},messageId:"capitalize",fix:r=>r.replaceTextRange([s.index,s.index+s.char.length],s.char.toUpperCase())});}}}}},mt=new ae;function le(t){return /^[A-Z]/.test(t)}function v(t){return l.REACT.HOOK.test(t)}function ut(t){return l.REACT.CONTEXT_HOOK.test(t)}function ce(t){return t?t.type==="ArrowFunctionExpression"||t.type==="FunctionExpression"?true:t.type==="CallExpression"&&t.callee.type==="Identifier"&&t.callee.name==="useCallback":false}function b(t){if(!t)return false;switch(t.type){case "JSXElement":case "JSXFragment":return true;case "ConditionalExpression":return b(t.consequent)||b(t.alternate);case "LogicalExpression":return b(t.left)||b(t.right);case "SequenceExpression":return b(t.expressions.at(-1));default:return false}}function L(t,e){return t.type==="ArrowFunctionExpression"&&t.body.type!=="BlockStatement"?b(t.body):O(t.body,e,b)}function dt(t,e){let i=R(t);return i===void 0?false:v(i)||le(i)&&L(t,e)}function ft(t,e){if(t.type==="CallExpression")return !(t.callee.type==="Identifier"&&v(t.callee.name));for(let i of e[t.type]??[]){let n=t[i],s=Array.isArray(n)?n:[n];for(let r of s){let o=r;if(!(!o||typeof o.type!="string")&&!l.FUNCTIONS.NODE_TYPES.has(o.type)&&ft(o,e))return true}}return false}function gt(t,e){return t.type==="ArrowFunctionExpression"||t.type==="FunctionExpression"?false:ft(t,e)}var pe=class extends p{name="require-complete-jsdoc";defaultOptions=[];meta={type:"suggestion",docs:{description:"Require a function's JSDoc to document every parameter and its return value.",recommended:true,category:"base"},schema:[],messages:{missingParam:c({problem:"The JSDoc does not document the parameter `{{name}}`.",why:"A JSDoc that skips a parameter drifts from the signature and stops describing what the function takes",fix:"Add an `@param {{name}} ...` line describing what it is"}),missingReturns:c({problem:"The JSDoc has no `@returns`, but this function returns a value.",why:"A documented function should say what it hands back, a missing `@returns` leaves the caller guessing",fix:"Add a `@returns ...` line describing the value (a void or `Promise<void>` function needs none)"})}};create(e){let i=n=>{let s=_(e.sourceCode,E(n));if(s===null)return;let r=Me(s),o=tt(n),m=new Set(o.filter(a=>a.kind==="name").map(a=>a.name));for(let a of o){if(a.kind==="name"){r.has(a.name)||e.report({node:a.node,messageId:"missingParam",data:{name:a.name}});continue}if(a.names.every(g=>r.has(g.name)))continue;let f=new Set(a.names.map(g=>g.name));if(![...r].some(g=>!f.has(g)&&!m.has(g)))for(let g of a.names)r.has(g.name)||e.report({node:g.node,messageId:"missingParam",data:{name:g.name}});}Ae(s)||A(n,e.sourceCode.visitorKeys)||L(n,e.sourceCode.visitorKeys)||e.report({node:s,messageId:"missingReturns"});};return {FunctionDeclaration(n){i(n);},FunctionExpression(n){i(n);},ArrowFunctionExpression(n){i(n);}}}},yt=new pe;var St={adonisjs:"AdonisJS",react:"React"};function $t(t){let e=[];for(let i of t.ast.body)i.type==="ImportDeclaration"&&e.push(String(i.source.value));return e}function ht(t,e){let i=new Set,n=$t(t);return n.some(r=>r.startsWith("@adonisjs/")||l.FRAMEWORKS.ADONIS_SUBPATH.test(r))&&i.add("adonisjs"),(n.some(r=>r==="react"||r.startsWith("react/")||r==="react-dom")||l.FRAMEWORKS.REACT_FILE.test(e))&&i.add("react"),i}var me=class extends p{name="require-framework-config";defaultOptions=[{ignore:[]}];meta={type:"suggestion",docs:{description:"Warn when a file uses a framework whose Nitpicker config is not enabled.",recommended:true,category:"base"},schema:[{type:"object",properties:{ignore:{type:"array",items:{type:"string",enum:["adonisjs","react"]}}},additionalProperties:false}],messages:{missingConfig:c({problem:"This file uses {{framework}} but the Nitpicker {{framework}} rules are not enabled.",why:"Framework rules only run when you opt into the matching config, so files like this one go unchecked",fix:"Add `nitpicker.configs.{{config}}` (scoped to these files) to your ESLint config, or turn off `nitpicker/require-framework-config`"})}};create(e,i){let n=new Set(i[0]?.ignore??[]),s=e.settings[l.PLUGIN_NAME]??{};return {Program(r){let o=ht(e.sourceCode,e.filename);for(let m of o)n.has(m)||s[m]||e.report({node:r,messageId:"missingConfig",data:{framework:St[m],config:m}});}}}},Tt=new me;var ue=class extends p{name="require-function-jsdoc";defaultOptions=[{include:["class-methods","nested"],ignore:[]}];meta={type:"suggestion",docs:{description:"Require a JSDoc comment on functions, except React component functions.",recommended:true},schema:[{type:"object",properties:{include:{type:"array",items:{type:"string",enum:["class-methods","object-methods","nested"]}},ignore:{type:"array",items:{type:"string"}}},additionalProperties:false}],messages:{missingJSDoc:c({problem:"The function `{{name}}` has no JSDoc comment.",why:"A function must document its purpose, parameters, and return value, React component functions are the only exception",fix:"Add a `/** ... */` JSDoc block immediately above it describing what it does"})}};create(e,i){let n=new Set(i[0]?.include??["class-methods","nested"]),s=new Set(i[0]?.ignore??[]),r=(a,f,y,g)=>{s.has(y)||rt(a)||le(y)&&L(a,e.sourceCode.visitorKeys)||T(e.sourceCode,f)||e.report({node:g,messageId:"missingJSDoc",data:{name:y}});},o=(a,f)=>{let y=R(a);if(y===void 0)return;let g=E(a);g.type==="MethodDefinition"||g.type==="Property"||!et(g)&&!n.has("nested")||r(a,g,y,f);},m=a=>{if(a.type==="Identifier")return a.name;if(a.type==="Literal"&&typeof a.value=="string")return a.value};return {FunctionDeclaration(a){o(a,a.id??a);},VariableDeclarator(a){a.init&&(a.init.type!=="ArrowFunctionExpression"&&a.init.type!=="FunctionExpression"||o(a.init,a.id));},MethodDefinition(a){if(!n.has("class-methods")||a.computed||a.value.type!=="FunctionExpression")return;let f=m(a.key);f!==void 0&&r(a.value,a,f,a.key);},Property(a){if(!n.has("object-methods")||a.computed||a.value.type!=="ArrowFunctionExpression"&&a.value.type!=="FunctionExpression")return;let f=m(a.key);f!==void 0&&r(a.value,a,f,a.key);}}}},Et=new ue;var de=class extends p{name="require-jsdoc-delimiter-lines";defaultOptions=[];meta={type:"layout",fixable:"whitespace",docs:{description:"Require a JSDoc's opening and closing delimiters to sit on their own lines.",recommended:true,category:"base"},schema:[],messages:{openingLine:c({problem:"This JSDoc starts its text on the same line as the opening delimiter.",why:"A block that opens mid-line breaks the aligned column of markers and reads unevenly",fix:"Move the text to the next line so the opening delimiter sits alone"}),closingLine:c({problem:"This JSDoc ends its text on the same line as the closing delimiter.",why:"A block that closes mid-line breaks the aligned column of markers and reads unevenly",fix:"Move the closing delimiter onto its own line below the text"})}};create(e){let i=n=>{if(n.loc.start.line===n.loc.end.line)return;let s=n.value.split(`
|
|
11
|
+
`),r=" ".repeat(n.loc.start.column),o=(s[0]??"").replace(/^\*/,"");if(o.trim()!==""){let a=n.range[0]+3,f=o.startsWith(" ")?"":" ";e.report({loc:{start:n.loc.start,end:e.sourceCode.getLocFromIndex(a+o.length)},messageId:"openingLine",fix:y=>y.insertTextBeforeRange([a,a],`
|
|
12
|
+
${r} *${f}`)});}if((s.at(-1)??"").replace(/^\s*\*?/,"").trim()!==""){let a=n.range[1]-2;e.report({loc:{start:e.sourceCode.getLocFromIndex(a),end:n.loc.end},messageId:"closingLine",fix:f=>f.insertTextBeforeRange([a,a],`
|
|
13
|
+
${r} `)});}};return {Program(){for(let n of e.sourceCode.getAllComments())S(n)&&i(n);}}}},bt=new de;function xt(t,e,i){let s=(t.lines[e.loc.start.line-1]??"").match(/^\s*/)?.[0]??"",r=s+" ".repeat(i);return `{
|
|
14
|
+
${e.properties.map(m=>`${r}${t.getText(m)}`).join(`,
|
|
12
15
|
`)},
|
|
13
|
-
${s}}`}var
|
|
14
|
-
`)??[]).filter(
|
|
16
|
+
${s}}`}var fe=class extends p{name="require-multiline-object";defaultOptions=[{maxKeys:l.OBJECTS.MAX_INLINE_KEYS,indent:l.OBJECTS.INDENT_WIDTH}];meta={type:"suggestion",fixable:"code",docs:{description:"Require an object literal with more than a few properties to span multiple lines.",recommended:true,category:"base"},schema:[{type:"object",properties:{maxKeys:{type:"integer",minimum:1},indent:{type:"integer",minimum:1}},additionalProperties:false}],messages:{shouldWrap:c({problem:"This object literal has {{count}} properties packed onto a single line.",why:"An object with more than {{max}} properties is easier to scan, diff, and edit when each property sits on its own line",fix:"Break it across multiple lines, one property per line with a trailing comma"})}};create(e,i){let n=i[0]?.maxKeys??l.OBJECTS.MAX_INLINE_KEYS,s=i[0]?.indent??l.OBJECTS.INDENT_WIDTH;return {ObjectExpression(r){if(r.properties.length<=n||r.loc.start.line!==r.loc.end.line)return;let o=e.sourceCode.getCommentsInside(r).length>0;e.report({node:r,messageId:"shouldWrap",data:{count:r.properties.length,max:n},fix:o?null:m=>m.replaceText(r,xt(e.sourceCode,r,s))});}}}},Rt=new fe;var ge=class extends p{name="max-classname-length";defaultOptions=[{max:l.REACT.MAX_CLASSNAME_LENGTH}];meta={type:"suggestion",docs:{description:"Enforce a maximum length for a `className` class string.",recommended:true,category:"react"},schema:[{type:"object",properties:{max:{type:"integer",minimum:1}},additionalProperties:false}],messages:{tooLong:c({problem:"This `className` string is {{length}} characters, over the {{max}}-character limit.",why:"A long wall of Tailwind classes is hard to scan and diff, and it overflows the line",fix:"Break the classes across multiple lines, grouping related ones into separate `cn()` arguments"})}};create(e,i){let n=i[0]?.max??l.REACT.MAX_CLASSNAME_LENGTH,s=(r,o)=>{if(r){if(r.type==="Literal"){typeof r.value=="string"&&o.push({node:r,text:r.value});return}if(r.type==="TemplateLiteral"){r.expressions.length===0&&o.push({node:r,text:r.quasis[0]?.value.cooked??""});return}for(let m of e.sourceCode.visitorKeys[r.type]??[]){let a=r[m],f=Array.isArray(a)?a:[a];for(let y of f){let g=y;!g||typeof g.type!="string"||l.FUNCTIONS.NODE_TYPES.has(g.type)||s(g,o);}}}};return {JSXAttribute(r){if(r.name.type!=="JSXIdentifier"||r.name.name!=="className"||r.value===null)return;let o=[];s(r.value,o);for(let{node:m,text:a}of o)a.length<=n||e.report({node:m,messageId:"tooLong",data:{length:a.length,max:n}});}}}},Ot=new ge;var ye=class extends p{name="no-jsx-comments";defaultOptions=[];meta={type:"suggestion",docs:{description:"Disallow inline `{/* ... */}` comments inside JSX.",recommended:true,category:"react"},schema:[],messages:{jsxComment:c({problem:"This JSX holds an inline `{/* ... */}` comment.",why:"A comment labeling a JSX section is a sign it should be its own named component, JSX should read as structure, not carry prose markers",fix:"Extract the section into a named sub-component whose name says what the comment said, or drop the comment"})}};create(e){return {JSXExpressionContainer(i){i.expression.type==="JSXEmptyExpression"&&e.sourceCode.getCommentsInside(i).length!==0&&e.report({node:i,messageId:"jsxComment"});}}}},Nt=new ye;var Se=class extends p{name="require-context-hook-destructure";defaultOptions=[];meta={type:"suggestion",docs:{description:"Require the result of a context-consumer hook to be destructured.",recommended:true,category:"react"},schema:[],messages:{destructure:c({problem:"`{{hook}}` is bound whole instead of destructured.",why:"Destructuring at the call site names exactly what the caller uses and reads better than repeated `{{name}}.member` access",fix:"Destructure the members in use, e.g. `const { a, b } = {{hook}}()`"})}};create(e){return {VariableDeclarator(i){i.id.type!=="Identifier"||i.init?.type!=="CallExpression"||i.init.callee.type!=="Identifier"||!ut(i.init.callee.name)||e.report({node:i,messageId:"destructure",data:{hook:i.init.callee.name,name:i.id.name}});}}}},It=new Se;var he=class extends p{name="require-derived-usememo";defaultOptions=[];meta={type:"suggestion",docs:{description:"Require a derived value in a component or hook to be memoized with useMemo.",recommended:true,category:"react"},schema:[],messages:{useMemo:c({problem:"This derived value is computed inline on every render.",why:"A value derived through a call is recomputed each render and has nowhere to document itself, a useMemo makes it stable and gives it a JSDoc home",fix:"Wrap it in `useMemo(() => ..., [deps])` with a JSDoc describing the value, even for a one-liner"})}};create(e){return {VariableDeclarator(i){if(i.parent.type!=="VariableDeclaration"||i.parent.kind!=="const"||i.id.type!=="Identifier"||i.init===null)return;let n=it(i);n===null||!dt(n,e.sourceCode.visitorKeys)||gt(i.init,e.sourceCode.visitorKeys)&&e.report({node:i,messageId:"useMemo"});}}}},Lt=new he;var Te=class extends p{name="require-hook-object-return";defaultOptions=[];meta={type:"suggestion",fixable:"code",docs:{description:"Require a custom hook to return an object rather than a bare function.",recommended:true,category:"react"},schema:[],messages:{wrapInObject:c({problem:"This hook returns a bare function instead of an object.",why:"Returning an object lets the hook expose new members later without changing every call site, a bare function locks its shape",fix:"Return the function inside an object, e.g. `return { handleThing }`"})}};create(e){let i=r=>{if(ce(r))return true;if(r.type!=="Identifier")return false;let m=ASTUtils.findVariable(e.sourceCode.getScope(r),r.name)?.defs.at(-1)?.node;return m?.type==="VariableDeclarator"&&ce(m.init)},n=r=>{e.report({node:r,messageId:"wrapInObject",fix:r.type==="Identifier"?o=>o.replaceText(r,`{ ${r.name} }`):void 0});},s=r=>{let o=R(r);if(!(o===void 0||!v(o))){if(r.type==="ArrowFunctionExpression"&&r.body.type!=="BlockStatement"){i(r.body)&&n(r.body);return}O(r.body,e.sourceCode.visitorKeys,m=>(m!==null&&i(m)&&n(m),false));}};return {FunctionDeclaration(r){s(r);},FunctionExpression(r){s(r);},ArrowFunctionExpression(r){s(r);}}}},Ct=new Te;var Ee=class extends p{name="require-memo-callback-jsdoc";defaultOptions=[];meta={type:"suggestion",docs:{description:"Require a JSDoc on a useMemo or useCallback (with an `@param` per useCallback parameter).",recommended:true,category:"react"},schema:[],messages:{missingJSDoc:c({problem:"This `{{hook}}` has no JSDoc.",why:"A memoized value or handler should document what it is, so its purpose is clear without reading the factory",fix:"Add a `/** ... */` JSDoc above the `const`"}),missingParam:c({problem:"This `useCallback`'s JSDoc documents fewer parameters than the callback takes.",why:"A callback is a function, so each parameter it takes should be documented like any other",fix:"Add an `@param` line for each parameter of the callback"})}};create(e){return {VariableDeclarator(i){if(i.init?.type!=="CallExpression"||i.init.callee.type!=="Identifier"||!l.REACT.MEMO_HOOKS.has(i.init.callee.name))return;let n=i.parent;if(n.parent?.type==="ExportNamedDeclaration"&&(n=n.parent),!T(e.sourceCode,n)){e.report({node:i.id,messageId:"missingJSDoc",data:{hook:i.init.callee.name}});return}if(i.init.callee.name!=="useCallback")return;let s=i.init.arguments[0];if(s?.type!=="ArrowFunctionExpression"&&s?.type!=="FunctionExpression"||s.params.length===0)return;(e.sourceCode.getCommentsBefore(n).at(-1)?.value.split(`
|
|
17
|
+
`)??[]).filter(m=>I(m)==="param").length<s.params.length&&e.report({node:i.id,messageId:"missingParam"});}}}},kt=new Ee;var Kt=[Ie,Fe,Pe,je,_e,Je,Ue,Ge,He,Xe,Ye,Ze,Qe,nt,st,ot,at,lt,ct,pt,mt,yt,Tt,bt,Et,Rt,Ot,Nt,It,Lt,Ct,kt],C=Object.fromEntries(Kt.map(t=>[t.name,t.toRuleModule()]));function N(t){let e={};for(let[i,n]of Object.entries(C))(n.meta.docs?.category??"base")===t&&(e[`${l.PLUGIN_NAME}/${i}`]="warn");return e}function Dt(){let t={};for(let e of Object.keys(C))t[`${l.PLUGIN_NAME}/${e}`]="warn";return t}function wt(t){return {name:`${l.PLUGIN_NAME}/all`,plugins:{[l.PLUGIN_NAME]:t},settings:{[l.PLUGIN_NAME]:{adonisjs:true,react:true}},rules:Dt()}}function z(t){return {name:`${l.PLUGIN_NAME}/base`,plugins:{[l.PLUGIN_NAME]:t},rules:N("base")}}function Mt(t){return {...z(t),name:`${l.PLUGIN_NAME}/recommended`}}var Xt=["**/start/routes.ts","**/start/routes/**/*.ts"];function At(t){return {name:`${l.PLUGIN_NAME}/adonisjs`,plugins:{[l.PLUGIN_NAME]:t},settings:{[l.PLUGIN_NAME]:{adonisjs:true}},rules:{...N("adonisjs"),[`${l.PLUGIN_NAME}/no-decorative-comment-separators`]:["warn",{allowIn:Xt}]}}}function vt(t){return {name:`${l.PLUGIN_NAME}/react`,plugins:{[l.PLUGIN_NAME]:t},settings:{[l.PLUGIN_NAME]:{react:true}},rules:N("react")}}function zt(t){return {base:z(t),recommended:Mt(t),adonisjs:At(t),react:vt(t),all:wt(t)}}var Ft="0.7.7";var be={meta:{name:`eslint-plugin-${l.PLUGIN_NAME}`,version:Ft},rules:C,configs:{}};be.configs=zt(be);var Aa=be;export{Aa as default};//# sourceMappingURL=index.js.map
|
|
15
18
|
//# sourceMappingURL=index.js.map
|