pickier 0.1.68 → 0.1.70

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.
Files changed (136) hide show
  1. package/dist/bin/cli.js +2 -2
  2. package/dist/chunk-0b2yx624.js +3 -0
  3. package/dist/chunk-1jtr81zg.js +25 -0
  4. package/dist/chunk-5c026tb4.js +3 -0
  5. package/dist/chunk-5tx5kfq7.js +2 -0
  6. package/dist/chunk-8m82hwdv.js +3 -0
  7. package/dist/chunk-c82emw32.js +3 -0
  8. package/dist/chunk-dxrcbgyc.js +49 -0
  9. package/dist/chunk-gpfjzx90.js +2 -0
  10. package/dist/chunk-he3fbz3w.js +8 -0
  11. package/dist/chunk-m9ym248d.js +2 -0
  12. package/dist/chunk-mqjmcycy.js +128 -0
  13. package/dist/chunk-ng3egs14.js +2 -0
  14. package/dist/chunk-pvptb0h1.js +3 -0
  15. package/dist/chunk-qjzzx1m2.js +61 -0
  16. package/dist/chunk-t4eg5fx5.js +41 -0
  17. package/dist/chunk-t776wefr.js +2 -0
  18. package/dist/chunk-wx92kdf9.js +9 -0
  19. package/dist/chunk-xjt8q744.js +3 -0
  20. package/dist/native/darwin-arm64/pickier-native +0 -0
  21. package/dist/native/darwin-x64/pickier-native +0 -0
  22. package/dist/native/linux-arm64/pickier-native +0 -0
  23. package/dist/native/linux-x64/pickier-native +0 -0
  24. package/dist/native/win32-arm64/pickier-native.exe +0 -0
  25. package/dist/native/win32-x64/pickier-native.exe +0 -0
  26. package/dist/src/cache.d.ts +21 -0
  27. package/dist/src/index.js +1 -1
  28. package/dist/src/lexer.d.ts +2 -0
  29. package/dist/src/lint-worker.d.ts +1 -0
  30. package/dist/src/lint-worker.js +2 -0
  31. package/dist/src/linter.d.ts +17 -1
  32. package/dist/src/logger.d.ts +20 -0
  33. package/dist/src/native.d.ts +64 -0
  34. package/dist/src/parallel.d.ts +17 -0
  35. package/dist/src/plugins/lazy.d.ts +10 -0
  36. package/dist/src/plugins/manifest.d.ts +123 -0
  37. package/dist/src/plugins/utils.d.ts +6 -0
  38. package/dist/src/rules/shell/_continuation.d.ts +4 -0
  39. package/dist/src/rules/style/consistent-list-newline.d.ts +2 -0
  40. package/dist/src/types.d.ts +1 -0
  41. package/dist/src/utils.d.ts +1 -0
  42. package/package.json +3 -2
  43. package/dist/chunk-5dpt7qv4.js +0 -2
  44. package/dist/chunk-ek25vxkw.js +0 -2
  45. package/dist/chunk-jcy3sgzh.js +0 -2
  46. package/dist/chunk-q47v401h.js +0 -92
  47. package/dist/chunk-s0n5r5hb.js +0 -227
  48. package/dist/chunk-zeaz9zt8.js +0 -2
  49. package/dist/src/plugins/index.d.ts +0 -2
  50. package/dist/src/plugins/lockfile.d.ts +0 -22
  51. package/dist/src/plugins/markdown.d.ts +0 -2
  52. package/dist/src/plugins/publint.d.ts +0 -10
  53. package/dist/src/plugins/shell.d.ts +0 -2
  54. package/dist/src/plugins/spell.d.ts +0 -3
  55. package/dist/src/rules/lockfile/parser.d.ts +0 -85
  56. package/dist/src/rules/lockfile/validate-host.d.ts +0 -18
  57. package/dist/src/rules/lockfile/validate-https.d.ts +0 -14
  58. package/dist/src/rules/lockfile/validate-integrity.d.ts +0 -19
  59. package/dist/src/rules/lockfile/validate-package-names.d.ts +0 -23
  60. package/dist/src/rules/lockfile/validate-scheme.d.ts +0 -17
  61. package/dist/src/rules/markdown/_fence-tracking.d.ts +0 -70
  62. package/dist/src/rules/markdown/_shared.d.ts +0 -9
  63. package/dist/src/rules/markdown/blanks-around-fences.d.ts +0 -5
  64. package/dist/src/rules/markdown/blanks-around-headings.d.ts +0 -5
  65. package/dist/src/rules/markdown/blanks-around-lists.d.ts +0 -5
  66. package/dist/src/rules/markdown/blanks-around-tables.d.ts +0 -5
  67. package/dist/src/rules/markdown/code-block-style.d.ts +0 -5
  68. package/dist/src/rules/markdown/code-fence-style.d.ts +0 -5
  69. package/dist/src/rules/markdown/commands-show-output.d.ts +0 -5
  70. package/dist/src/rules/markdown/descriptive-link-text.d.ts +0 -5
  71. package/dist/src/rules/markdown/emphasis-style.d.ts +0 -5
  72. package/dist/src/rules/markdown/fenced-code-language.d.ts +0 -5
  73. package/dist/src/rules/markdown/first-line-heading.d.ts +0 -5
  74. package/dist/src/rules/markdown/heading-increment.d.ts +0 -5
  75. package/dist/src/rules/markdown/heading-start-left.d.ts +0 -5
  76. package/dist/src/rules/markdown/heading-style.d.ts +0 -5
  77. package/dist/src/rules/markdown/hr-style.d.ts +0 -5
  78. package/dist/src/rules/markdown/line-length.d.ts +0 -5
  79. package/dist/src/rules/markdown/link-fragments.d.ts +0 -5
  80. package/dist/src/rules/markdown/link-image-reference-definitions.d.ts +0 -5
  81. package/dist/src/rules/markdown/link-image-style.d.ts +0 -5
  82. package/dist/src/rules/markdown/list-indent.d.ts +0 -5
  83. package/dist/src/rules/markdown/list-marker-space.d.ts +0 -5
  84. package/dist/src/rules/markdown/no-alt-text.d.ts +0 -5
  85. package/dist/src/rules/markdown/no-bare-urls.d.ts +0 -5
  86. package/dist/src/rules/markdown/no-blanks-blockquote.d.ts +0 -5
  87. package/dist/src/rules/markdown/no-duplicate-heading.d.ts +0 -10
  88. package/dist/src/rules/markdown/no-emphasis-as-heading.d.ts +0 -9
  89. package/dist/src/rules/markdown/no-empty-links.d.ts +0 -5
  90. package/dist/src/rules/markdown/no-hard-tabs.d.ts +0 -5
  91. package/dist/src/rules/markdown/no-inline-html.d.ts +0 -5
  92. package/dist/src/rules/markdown/no-missing-space-atx.d.ts +0 -5
  93. package/dist/src/rules/markdown/no-missing-space-closed-atx.d.ts +0 -5
  94. package/dist/src/rules/markdown/no-multiple-blanks.d.ts +0 -5
  95. package/dist/src/rules/markdown/no-multiple-space-atx.d.ts +0 -5
  96. package/dist/src/rules/markdown/no-multiple-space-blockquote.d.ts +0 -5
  97. package/dist/src/rules/markdown/no-multiple-space-closed-atx.d.ts +0 -5
  98. package/dist/src/rules/markdown/no-reversed-links.d.ts +0 -5
  99. package/dist/src/rules/markdown/no-space-in-code.d.ts +0 -5
  100. package/dist/src/rules/markdown/no-space-in-emphasis.d.ts +0 -5
  101. package/dist/src/rules/markdown/no-space-in-links.d.ts +0 -5
  102. package/dist/src/rules/markdown/no-trailing-punctuation.d.ts +0 -5
  103. package/dist/src/rules/markdown/no-trailing-spaces.d.ts +0 -5
  104. package/dist/src/rules/markdown/ol-prefix.d.ts +0 -5
  105. package/dist/src/rules/markdown/proper-names.d.ts +0 -5
  106. package/dist/src/rules/markdown/reference-links-images.d.ts +0 -14
  107. package/dist/src/rules/markdown/required-headings.d.ts +0 -5
  108. package/dist/src/rules/markdown/single-title.d.ts +0 -5
  109. package/dist/src/rules/markdown/single-trailing-newline.d.ts +0 -5
  110. package/dist/src/rules/markdown/strong-style.d.ts +0 -16
  111. package/dist/src/rules/markdown/table-column-count.d.ts +0 -5
  112. package/dist/src/rules/markdown/table-column-style.d.ts +0 -5
  113. package/dist/src/rules/markdown/table-pipe-style.d.ts +0 -5
  114. package/dist/src/rules/markdown/ul-indent.d.ts +0 -14
  115. package/dist/src/rules/markdown/ul-style.d.ts +0 -5
  116. package/dist/src/rules/shell/command-substitution.d.ts +0 -6
  117. package/dist/src/rules/shell/consistent-case-terminators.d.ts +0 -9
  118. package/dist/src/rules/shell/function-style.d.ts +0 -6
  119. package/dist/src/rules/shell/heredoc-indent.d.ts +0 -7
  120. package/dist/src/rules/shell/indent.d.ts +0 -2
  121. package/dist/src/rules/shell/keyword-spacing.d.ts +0 -10
  122. package/dist/src/rules/shell/no-broken-redirect.d.ts +0 -7
  123. package/dist/src/rules/shell/no-cd-without-check.d.ts +0 -6
  124. package/dist/src/rules/shell/no-eval.d.ts +0 -6
  125. package/dist/src/rules/shell/no-exit-in-subshell.d.ts +0 -7
  126. package/dist/src/rules/shell/no-ls-parsing.d.ts +0 -7
  127. package/dist/src/rules/shell/no-trailing-semicolons.d.ts +0 -6
  128. package/dist/src/rules/shell/no-trailing-whitespace.d.ts +0 -5
  129. package/dist/src/rules/shell/no-useless-cat.d.ts +0 -6
  130. package/dist/src/rules/shell/no-variable-in-single-quotes.d.ts +0 -7
  131. package/dist/src/rules/shell/operator-spacing.d.ts +0 -11
  132. package/dist/src/rules/shell/prefer-double-brackets.d.ts +0 -6
  133. package/dist/src/rules/shell/prefer-printf.d.ts +0 -6
  134. package/dist/src/rules/shell/quote-variables.d.ts +0 -2
  135. package/dist/src/rules/shell/set-options.d.ts +0 -8
  136. package/dist/src/rules/shell/shebang.d.ts +0 -2
@@ -0,0 +1,41 @@
1
+ // @bun
2
+ var S={meta:{docs:"Fenced code blocks should be surrounded by blank lines"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=!1;for(let e=0;e<t.length;e++){let n=t[e];if(/^(?:`{3,}|~{3,})/.test(n.trim()))if(!o){let i=e>0?t[e-1]:"";if(e>0&&i.trim().length>0){if(!/^:::/.test(i.trim()))l.push({filePath:s.filePath,line:e+1,column:1,ruleId:"markdown/blanks-around-fences",message:"Fenced code blocks should be surrounded by blank lines",severity:"error"})}o=!0}else{let i=e+1<t.length?t[e+1]:"";if(e+1<t.length&&i.trim().length>0){if(!/^:::/.test(i.trim()))l.push({filePath:s.filePath,line:e+1,column:1,ruleId:"markdown/blanks-around-fences",message:"Fenced code blocks should be surrounded by blank lines",severity:"error"})}o=!1}}return l},fix:(u)=>{let s=u.split(/\r?\n/),l=[],t=!1;for(let o=0;o<s.length;o++){let e=s[o],n=o>0?s[o-1]:"",r=/^(?:`{3,}|~{3,})/.test(e.trim());if(r)if(!t){if(o>0&&n.trim().length>0&&!/^:::/.test(n.trim())&&l.length>0)l.push("");t=!0}else t=!1;if(l.push(e),r&&!t&&o+1<s.length){let i=s[o+1];if(i.trim().length>0&&!/^:::/.test(i.trim()))l.push("")}}return l.join(`
3
+ `)}};var _={meta:{docs:"Headings should be surrounded by blank lines"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=!1;for(let e=0;e<t.length;e++){let n=t[e],r=e>0?t[e-1]:"",i=e+1<t.length?t[e+1]:"";if(/^(?:`{3,}|~{3,})/.test(n.trim())){o=!o;continue}if(o)continue;let c=/^#{1,6}\s/.test(n),a=e+1<t.length&&/^(?:=+|-+)\s*$/.test(i)&&n.trim().length>0;if(c){if(e>0&&r.trim().length>0)l.push({filePath:s.filePath,line:e+1,column:1,ruleId:"markdown/blanks-around-headings",message:"Headings should be surrounded by blank lines",severity:"error"});if(e+1<t.length&&i.trim().length>0&&!/^#{1,6}\s/.test(i))l.push({filePath:s.filePath,line:e+1,column:1,ruleId:"markdown/blanks-around-headings",message:"Headings should be surrounded by blank lines",severity:"error"})}if(a){if(e>0&&r.trim().length>0)l.push({filePath:s.filePath,line:e+1,column:1,ruleId:"markdown/blanks-around-headings",message:"Headings should be surrounded by blank lines",severity:"error"});let d=e+2<t.length?t[e+2]:"";if(e+2<t.length&&d.trim().length>0)l.push({filePath:s.filePath,line:e+1,column:1,ruleId:"markdown/blanks-around-headings",message:"Headings should be surrounded by blank lines",severity:"error"})}}return l},fix:(u)=>{let s=u.split(/\r?\n/),l=[],t=!1;for(let o=0;o<s.length;o++){let e=s[o],n=o>0?s[o-1]:"",r=o+1<s.length?s[o+1]:"";if(/^(?:`{3,}|~{3,})/.test(e.trim())){t=!t,l.push(e);continue}if(t){l.push(e);continue}let i=/^#{1,6}\s/.test(e),c=o+1<s.length&&/^(?:=+|-+)\s*$/.test(r)&&e.trim().length>0;if(i||c){if(o>0&&n.trim().length>0&&l.length>0)l.push("")}if(l.push(e),i){if(o+1<s.length&&r.trim().length>0&&!/^#{1,6}\s/.test(r))l.push("")}if(o>0&&/^(?:=+|-+)\s*$/.test(e)&&s[o-1].trim().length>0){if((o+1<s.length?s[o+1]:"").trim().length>0)l.push("")}}return l.join(`
4
+ `)}};var A={meta:{docs:"Lists should be surrounded by blank lines"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=!1,e=!1;for(let n=0;n<t.length;n++){let r=t[n],i=n>0?t[n-1]:"";if(/^(?:`{3,}|~{3,})/.test(r.trim())){if(e=!e,o)o=!1;continue}if(e)continue;let c=/^(?:\s*)(?:[*\-+]|\d+\.)\s+/.test(r),a=o&&!c&&r.trim().length>0&&/^\s+/.test(r);if(c&&!o){if(o=!0,n>0&&i.trim().length>0)l.push({filePath:s.filePath,line:n+1,column:1,ruleId:"markdown/blanks-around-lists",message:"Lists should be surrounded by blank lines",severity:"error"})}else if(!c&&!a&&o&&r.trim().length>0){if(o=!1,/^(?:\s*)(?:[*\-+]|\d+\.)\s+/.test(i))l.push({filePath:s.filePath,line:n,column:1,ruleId:"markdown/blanks-around-lists",message:"Lists should be surrounded by blank lines",severity:"error"})}}return l},fix:(u)=>{let s=u.split(/\r?\n/),l=[],t=!1,o=!1,e=(n)=>/^(?:\s*)(?:[*\-+]|\d+\.)\s+/.test(n);for(let n=0;n<s.length;n++){let r=s[n],i=n>0?s[n-1]:"";if(/^(?:`{3,}|~{3,})/.test(r.trim())){o=!o,t=!1,l.push(r);continue}if(o){l.push(r);continue}let c=e(r),a=r.trim().length===0,d=t&&!c&&!a&&/^\s/.test(r);if(c&&!t){if(n>0&&i.trim().length>0&&l.length>0)l.push("");t=!0}else if(!c&&!d&&!a&&t){if(t=!1,l.length>0)l.push("")}else if(a){let f=n+1<s.length?s[n+1]:"",m=e(f),g=/^\s+\S/.test(f);if(!m&&!g&&t)t=!1}l.push(r)}return l.join(`
5
+ `)}};function h(u){let s=new Set,l=null,t=0,o=!1,e=!1;for(let n=0;n<u.length;n++){let r=u[n],i=r.trim();if(l===null){let f=i.match(/^(`{3,}|~{3,})(.*)$/);if(f){let m=f[1],g=f[2],k=m[0];if(k==="`"&&g.includes("`"));else{l=k,t=m.length,s.add(n),o=!1,e=!1;continue}}}else{s.add(n);let f=i.match(/^(`{3,}|~{3,})\s*$/);if(f&&f[1][0]===l&&f[1].length>=t)l=null,t=0;continue}let c=r.length-r.trimStart().length,a=/^\t/.test(r);if((c>=4||a)&&i.length>0){if(e||o||n===0)s.add(n),e=!0;o=e;continue}if(i.length===0){if(e)s.add(n),o=!0;else o=!0;continue}e=!1,o=!1}return s}function B(u,s,l){let t=0,o=0;while(t<u.length){if(u[t]!=="`"){t++;continue}let e=0;while(u[t+e]==="`")e++;let n=t+e,r=-1;while(n<u.length)if(u[n]==="`"){let i=0;while(u[n+i]==="`")i++;if(i===e){r=n;break}n+=i}else n++;if(r===-1){t+=e;continue}if(o<t)s(u.slice(o,t));l(u.slice(t,r+e)),t=r+e,o=t}if(o<u.length)s(u.slice(o))}function L(u,s){let l="";return B(u,(t)=>{l+=s(t)},(t)=>{l+=t}),l}function b(u){let s="";return B(u,(l)=>{s+=l},(l)=>{s+=" ".repeat(l.length)}),s}function E(u){let s=h(u),l=[],t=0;for(let o=0;o<u.length;o++){let e=u[o];if(s.has(o)||e.trim()===""){t=0,l.push(e);continue}if(t===0){let i=b(e),c=Ee(i);if(!c){l.push(i);continue}t=c.length,l.push(i.slice(0,c.index)+" ".repeat(i.length-c.index));continue}let n=new RegExp(`(?<!\`)\`{${t}}(?!\`)`).exec(e);if(!n){l.push(" ".repeat(e.length));continue}let r=n.index+n[0].length;t=0,l.push(" ".repeat(r)+b(e.slice(r)))}return l}function Ee(u){let s=/(?<!`)(`+)(?!`)(?=[^`]*$)/.exec(u);return s?{index:s.index,length:s[1].length}:null}function x(u){let s=new Set,l=h(u);for(let t=0;t<u.length;t++){if(l.has(t))continue;let o=u[t];if(!Te(o))continue;if(t>0&&!l.has(t-1)&&/\|/.test(u[t-1])&&u[t-1].trim().length>0)s.add(t-1);s.add(t);for(let e=t+1;e<u.length;e++){if(l.has(e))break;let n=u[e];if(n.trim().length===0||!/\|/.test(n))break;s.add(e)}}return s}function Te(u){let s=u.trim();if(!s.includes("|"))return!1;if(!/^[|\s:-]+$/.test(s))return!1;if(!/-{3,}/.test(s))return!1;return!0}var T={meta:{docs:"Tables should be surrounded by blank lines"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=!1,e=!1,n=x(t);for(let r=0;r<t.length;r++){let i=t[r],c=r>0?t[r-1]:"";if(/^(?:`{3,}|~{3,})/.test(i.trim())){if(e=!e,o)o=!1;continue}if(e)continue;let a=n.has(r)&&/\|/.test(i)&&i.trim().length>0;if(a&&!o){if(o=!0,r>0&&c.trim().length>0)l.push({filePath:s.filePath,line:r+1,column:1,ruleId:"markdown/blanks-around-tables",message:"Tables should be surrounded by blank lines",severity:"error"})}else if(!a&&o){if(o=!1,i.trim().length>0)l.push({filePath:s.filePath,line:r+1,column:1,ruleId:"markdown/blanks-around-tables",message:"Tables should be surrounded by blank lines",severity:"error"})}}return l},fix:(u)=>{let s=u.split(/\r?\n/),l=h(s),t=x(s),o=[],e=!1;for(let r=0;r<s.length;r++){let i=s[r];if(l.has(r)){o.push(i);continue}let c=t.has(r)&&/\|/.test(i)&&i.trim().length>0;if(c&&!e){let a=o.length-1;if(a>=0&&o[a].trim().length>0)o.push("");e=!0,o.push(i);continue}if(!c&&e){if(e=!1,i.trim().length>0)o.push("")}o.push(i)}let n=o.join(`
6
+ `);return n!==u?n:u}};var F={meta:{docs:"Code block style should be consistent"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),e=(s.options||{}).style||"consistent",n=null,r=!1;for(let i=0;i<t.length;i++){let c=t[i];if(/^(?:`{3,}|~{3,})/.test(c)){if(r=!r,e==="indented")l.push({filePath:s.filePath,line:i+1,column:1,ruleId:"markdown/code-block-style",message:"Expected indented code block style",severity:"error"});else if(e==="consistent"){if(n===null)n="fenced";else if(n==="indented")l.push({filePath:s.filePath,line:i+1,column:1,ruleId:"markdown/code-block-style",message:"Code block style should be consistent throughout document",severity:"error"})}continue}if(r)continue;if(/^(?: {4}|\t)/.test(c)&&c.trim().length>0){let m=(i>0?t[i-1]:"").trim().length===0||i===0;if(m&&e==="fenced")l.push({filePath:s.filePath,line:i+1,column:1,ruleId:"markdown/code-block-style",message:"Expected fenced code block style",severity:"error"});else if(m&&e==="consistent"){if(n===null)n="indented";else if(n==="fenced")l.push({filePath:s.filePath,line:i+1,column:1,ruleId:"markdown/code-block-style",message:"Code block style should be consistent throughout document",severity:"error"})}}}return l}};function H(u){let s=new Set,l=null,t=0;for(let o=0;o<u.length;o++){let e=u[o].trim();if(l===null){let n=e.match(/^(`{3,}|~{3,})(.*)$/);if(n){let r=n[1][0];if(r==="`"&&n[2].includes("`"))continue;l=r,t=n[1].length,s.add(o)}}else{let n=e.match(/^(`{3,}|~{3,})\s*$/);if(n&&n[1][0]===l&&n[1].length>=t)s.add(o),l=null,t=0}}return s}var j={meta:{docs:"Code fence style should be consistent (backtick or tilde)"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=H(t),n=(s.options||{}).style||"consistent",r=null;for(let i of o){let c=t[i],d=/^`{3,}/.test(c.trim())?"backtick":"tilde";if(n==="backtick"||n==="tilde"){if(d!==n)l.push({filePath:s.filePath,line:i+1,column:1,ruleId:"markdown/code-fence-style",message:n==="tilde"?"Expected tilde (~~~) code fence":"Expected backtick (```) code fence",severity:"error"})}else if(n==="consistent"){if(r===null)r=d;else if(r!==d)l.push({filePath:s.filePath,line:i+1,column:1,ruleId:"markdown/code-fence-style",message:"Code fence style should be consistent throughout document",severity:"error"})}}return l},fix:(u,s)=>{let t=(s.options||{}).style||"consistent",o=u.split(/\r?\n/),e=H(o),n="backtick";if(t==="backtick"||t==="tilde")n=t;else for(let a of e){n=/^`{3,}/.test(o[a].trim())?"backtick":"tilde";break}let r=n==="backtick"?"`":"~",i=n==="backtick"?/^(\s*)(~{3,})(.*)$/:/^(\s*)(`{3,})(.*)$/;return o.map((a,d)=>{if(!e.has(d))return a;return a.replace(i,(f,m,g,k)=>`${m}${r.repeat(g.length)}${k}`)}).join(`
7
+ `)}};var U={meta:{docs:"Commands in code blocks should not be prefixed with $ unless showing output"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=!1,e=-1;for(let n=0;n<t.length;n++){let r=t[n];if(/^(?:`{3,}|~{3,})/.test(r)){if(!o)o=!0,e=n;else o=!1;continue}if(o&&/^\$\s+/.test(r.trim())){let i=!0,c=!1;for(let a=e+1;a<n;a++){let d=t[a].trim();if(d.length>0){if(c=!0,!d.startsWith("$")){i=!1;break}}}if(i&&c)l.push({filePath:s.filePath,line:n+1,column:r.indexOf("$")+1,ruleId:"markdown/commands-show-output",message:"Dollar signs used before commands without showing output",severity:"warning"})}}return l}};var q={meta:{docs:"Link text should be meaningful and descriptive"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=["click here","here","link","read more","more","this"],e=!1;for(let n=0;n<t.length;n++){let r=t[n];if(/^(?:`{3,}|~{3,})/.test(r.trim())){e=!e;continue}if(e)continue;let c=r.replace(/``[^`]+``/g,(a)=>" ".repeat(a.length)).replace(/`[^`]+`/g,(a)=>" ".repeat(a.length)).matchAll(/\[([^\]]+)\]\([^)]+\)/g);for(let a of c){let d=a[1].toLowerCase().trim();if(o.includes(d)){let f=a.index+1;l.push({filePath:s.filePath,line:n+1,column:f,ruleId:"markdown/descriptive-link-text",message:`Link text '${a[1]}' is not descriptive`,severity:"warning"})}}}return l}};var w="(?<!\\*)\\*(?!\\*)(?!\\s)([^*]*[^*\\s])\\*(?!\\*)",Fe=new RegExp(w),v="(?<![A-Za-z0-9_])_(?!_)([^_]+)_(?![A-Za-z0-9_])",He=new RegExp(v),z={meta:{docs:"Emphasis style should be consistent (asterisk or underscore)"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),e=(s.options||{}).style||"consistent",n=null,r=h(t),i=E(t);for(let c=0;c<t.length;c++){let a=t[c];if(r.has(c))continue;let d=i[c]??b(a),f=d.matchAll(new RegExp(w,"g"));for(let g of f)if(e==="underscore")l.push({filePath:s.filePath,line:c+1,column:g.index+1,ruleId:"markdown/emphasis-style",message:"Expected underscore (_) for emphasis",severity:"error"});else if(e==="consistent"){if(n===null)n="asterisk";else if(n==="underscore")l.push({filePath:s.filePath,line:c+1,column:g.index+1,ruleId:"markdown/emphasis-style",message:"Emphasis style should be consistent throughout document",severity:"error"})}let m=d.matchAll(new RegExp(v,"g"));for(let g of m)if(e==="asterisk")l.push({filePath:s.filePath,line:c+1,column:g.index+1,ruleId:"markdown/emphasis-style",message:"Expected asterisk (*) for emphasis",severity:"error"});else if(e==="consistent"){if(n===null)n="underscore";else if(n==="asterisk")l.push({filePath:s.filePath,line:c+1,column:g.index+1,ruleId:"markdown/emphasis-style",message:"Emphasis style should be consistent throughout document",severity:"error"})}}return l},fix:(u,s)=>{let t=(s.options||{}).style||"consistent",o=u.split(/\r?\n/),e=h(o),n="asterisk";if(t==="asterisk")n="asterisk";else if(t==="underscore")n="underscore";else if(t==="consistent"){let i=null,c=null;for(let d=0;d<o.length;d++){if(e.has(d))continue;let f=b(o[d]);if(i===null){let m=f.match(Fe);if(m)i={line:d,col:m.index}}if(c===null){let m=f.match(He);if(m)c={line:d,col:m.index}}if(i&&c)break}if(i&&(!c||((d,f)=>d.line!==f.line?d.line-f.line:d.col-f.col)(i,c)<0))n="asterisk";else if(c)n="underscore"}let r=!1;for(let i=0;i<o.length;i++){if(e.has(i))continue;let c=L(o[i],(a)=>n==="asterisk"?a.replace(new RegExp(v,"g"),"*$1*"):a.replace(new RegExp(w,"g"),"_$1_"));if(c!==o[i])o[i]=c,r=!0}return r?o.join(`
8
+ `):u}};var O={meta:{docs:"Fenced code blocks should have a language specified"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/);for(let o=0;o<t.length;o++)if(t[o].match(/^(?:`{3,}|~{3,})\s*$/)){let r=!0;for(let i=o-1;i>=0;i--)if(/^(?:`{3,}|~{3,})/.test(t[i])){r=!1;break}if(r)l.push({filePath:s.filePath,line:o+1,column:1,ruleId:"markdown/fenced-code-language",message:"Fenced code blocks should have a language specified",severity:"error"})}return l}};var W={meta:{docs:"First line in a file should be a top-level heading"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=-1;for(let i=0;i<t.length;i++)if(t[i].trim().length>0){o=i;break}if(o===-1)return l;let e=t[o],n=/^#\s/.test(e),r=o+1<t.length&&/^=+\s*$/.test(t[o+1]);if(!n&&!r)l.push({filePath:s.filePath,line:o+1,column:1,ruleId:"markdown/first-line-heading",message:"First line in a file should be a top-level heading",severity:"warning"});return l}};var N={meta:{docs:"Heading levels should only increment by one level at a time"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=h(t),e=0;for(let n=0;n<t.length;n++){if(o.has(n))continue;let i=t[n].match(/^(#{1,6})\s/);if(i){let c=i[1].length;if(e>0&&c>e+1)l.push({filePath:s.filePath,line:n+1,column:1,ruleId:"markdown/heading-increment",message:`Heading level should not skip from h${e} to h${c}`,severity:"error"});e=c}}return l},fix:(u)=>{let s=u.split(/\r?\n/),l=h(s),t=0,o=!1;for(let e=0;e<s.length;e++){if(l.has(e))continue;let r=s[e].match(/^(#{1,6})(\s.*)$/);if(!r)continue;let i=r[1].length,c=t===0?i:Math.min(i,t+1);if(c!==i)s[e]="#".repeat(c)+r[2],o=!0;t=c}return o?s.join(`
9
+ `):u}};var Z={meta:{docs:"Headings must start at the beginning of the line"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=h(t);for(let e=0;e<t.length;e++){let n=t[e];if(o.has(e))continue;if(n.match(/^(\s+)(#{1,6}\s)/))l.push({filePath:s.filePath,line:e+1,column:1,ruleId:"markdown/heading-start-left",message:"Headings must start at the beginning of the line",severity:"error"})}return l},fix:(u)=>{let s=u.split(/\r?\n/),l=h(s);return s.map((o,e)=>l.has(e)?o:o.replace(/^(\s+)(#{1,6}\s)/,"$2")).join(`
10
+ `)}};var D={meta:{docs:"Heading style should be consistent (atx, setext, or consistent)"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),e=(s.options||{}).style||"consistent",n=null,r=h(t);for(let i=0;i<t.length;i++){if(r.has(i))continue;let c=t[i],a=i+1<t.length?t[i+1]:"",d=c.match(/^#{1,6}\s/),f=a.match(/^(?:=+|-+)\s*$/)&&c.trim().length>0&&!r.has(i+1);if(d){if(e==="setext")l.push({filePath:s.filePath,line:i+1,column:1,ruleId:"markdown/heading-style",message:"Expected setext style heading",severity:"error"});else if(e==="consistent"){if(n===null)n="atx";else if(n==="setext")l.push({filePath:s.filePath,line:i+1,column:1,ruleId:"markdown/heading-style",message:"Heading style should be consistent throughout document",severity:"error"})}}else if(f){if(e==="atx")l.push({filePath:s.filePath,line:i+1,column:1,ruleId:"markdown/heading-style",message:"Expected atx style heading",severity:"error"});else if(e==="consistent"){if(n===null)n="setext";else if(n==="atx")l.push({filePath:s.filePath,line:i+1,column:1,ruleId:"markdown/heading-style",message:"Heading style should be consistent throughout document",severity:"error"})}}}return l},fix:(u,s)=>{let t=(s.options||{}).style||"consistent",o=u.split(/\r?\n/),e=h(o),n=t==="consistent"?null:t;if(n===null)for(let c=0;c<o.length;c++){if(e.has(c))continue;let a=o[c],d=c+1<o.length?o[c+1]:"";if(/^#{1,6}\s/.test(a)){n="atx";break}if(/^(?:=+|-+)\s*$/.test(d)&&a.trim().length>0&&!e.has(c+1)){n="setext";break}}if(n===null)return u;let r=[],i=!1;for(let c=0;c<o.length;c++){let a=o[c];if(e.has(c)){r.push(a);continue}let d=c+1<o.length?o[c+1]:"";if(n==="atx"){let f=/^=+\s*$/.test(d),m=/^-+\s*$/.test(d),g=e.has(c+1);if((f||m)&&!g&&a.trim().length>0&&!/^#{1,6}\s/.test(a)){let k=f?"#":"##";r.push(`${k} ${a.trim()}`),c++,i=!0;continue}}if(n==="setext"){let f=a.match(/^(#{1,2})\s+(.+?)\s*#*\s*$/);if(f){let m=f[1].length,g=f[2],k=(m===1?"=":"-").repeat(Math.max(3,g.length));r.push(g),r.push(k),i=!0;continue}}r.push(a)}return i?r.join(`
11
+ `):u}};var X={meta:{docs:"Horizontal rule style should be consistent"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),e=(s.options||{}).style||"consistent",n=null;for(let r=0;r<t.length;r++){let i=t[r].trim();if(i.match(/^([-*_])\1{2,}$/)){let a=i;if(e!=="consistent"&&i!==e)l.push({filePath:s.filePath,line:r+1,column:1,ruleId:"markdown/hr-style",message:`Expected horizontal rule style '${e}'`,severity:"error"});else if(e==="consistent"){if(n===null)n=a;else if(n!==a)l.push({filePath:s.filePath,line:r+1,column:1,ruleId:"markdown/hr-style",message:"Horizontal rule style should be consistent throughout document",severity:"error"})}}}return l}};var K={meta:{docs:"Lines should not exceed a specified length"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=s.options||{},e=o.line_length||80,n=o.code_blocks!==!1,r=o.tables!==!1,i=o.headings!==!1,c=!1;for(let a=0;a<t.length;a++){let d=t[a];if(/^(?:`{3,}|~{3,})/.test(d)){c=!c;continue}if(c&&!n)continue;if(!r&&/\|/.test(d))continue;if(!i&&/^#{1,6}\s/.test(d))continue;if(d.length>e)l.push({filePath:s.filePath,line:a+1,column:e+1,ruleId:"markdown/line-length",message:`Line length exceeds ${e} characters (${d.length} characters)`,severity:"warning"})}return l}};function je(u){return u.toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s/g,"-")}var G={meta:{docs:"Link fragments should reference valid headings"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=h(t),e=new Set;for(let n=0;n<t.length;n++){if(o.has(n))continue;let i=t[n].match(/^#{1,6}\s+(.+?)(?:\s*#+\s*)?$/);if(i){let c=i[1].trim();e.add(je(c))}}for(let n=0;n<t.length;n++){if(o.has(n))continue;let i=t[n].matchAll(/\[[^\]]+\]\(#([^)]+)\)/g);for(let c of i){let a=c[1];if(!e.has(a)){let d=c.index+1;l.push({filePath:s.filePath,line:n+1,column:d,ruleId:"markdown/link-fragments",message:`Link fragment '#${a}' does not match any heading`,severity:"error"})}}}return l}};var J={meta:{docs:"Link and image reference definitions should be used"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=h(t),e=new Map;for(let r=0;r<t.length;r++){if(o.has(r))continue;let c=t[r].match(/^\[([^\]]+)\]:\s*\S+/);if(c)e.set(c[1].toLowerCase(),r+1)}let n=new Set;for(let r=0;r<t.length;r++){if(o.has(r))continue;let i=t[r];if(i.match(/^\[(?:[^\]]+)\]:\s*\S+/))continue;let c=i.matchAll(/\[([^\]]+)\](?:\[([^\]]+)\])?(?!\()/g);for(let a of c){let d=(a[2]||a[1]).toLowerCase();n.add(d)}}for(let[r,i]of e)if(!n.has(r))l.push({filePath:s.filePath,line:i,column:1,ruleId:"markdown/link-image-reference-definitions",message:`Unused reference definition '[${r}]'`,severity:"warning"});return l},fix:(u)=>{let s=u.split(/\r?\n/),l=h(s),t=new Map;for(let n=0;n<s.length;n++){if(l.has(n))continue;let r=s[n].match(/^\s*\[([^\]]+)\]:\s*\S+/);if(r)t.set(n,r[1].toLowerCase())}if(t.size===0)return u;let o=new Set;for(let n=0;n<s.length;n++){if(l.has(n))continue;if(t.has(n))continue;let i=s[n].matchAll(/\[([^\]]+)\](?:\[([^\]]*)\])?(?!\()/g);for(let c of i){let a=(c[2]&&c[2].length>0?c[2]:c[1]).toLowerCase();o.add(a)}}let e=new Set;for(let[n,r]of t)if(!o.has(r))e.add(n);if(e.size===0)return u;return s.filter((n,r)=>!e.has(r)).join(`
12
+ `)}};var Q={meta:{docs:"Link and image style should be consistent"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=h(t),n=(s.options||{}).style||"consistent",r=n==="consistent"?null:n;if(r===null){let c=0,a=0,d=!1;for(let f=0;f<t.length;f++){if(o.has(f))continue;let m=t[f];if(m.includes("<!--"))d=!0;if(m.includes("-->")){d=!1;continue}if(d)continue;if(/^\s*\[(?:[^\]]+)\]:\s*\S+/.test(m))continue;let g=C(m);c+=(g.match(/\[[^\]]+\]\([^)]+\)/g)||[]).length,a+=(g.match(/\[[^\]]+\]\[(?:[^\]]*)\]/g)||[]).length}r=a>c?"reference":"inline"}let i=!1;for(let c=0;c<t.length;c++){if(o.has(c))continue;let a=t[c];if(a.includes("<!--"))i=!0;if(a.includes("-->")){i=!1;continue}if(i)continue;if(a.match(/^\[(?:[^\]]+)\]:\s*\S+/))continue;let d=C(a),f=d.matchAll(/\[[^\]]+\]\([^)]+\)/g);for(let g of f)if(r==="reference")l.push({filePath:s.filePath,line:c+1,column:g.index+1,ruleId:"markdown/link-image-style",message:n==="consistent"?"Link style should be consistent throughout document":"Expected reference style link",severity:n==="consistent"?"warning":"error"});let m=d.matchAll(/\[[^\]]+\]\[(?:[^\]]+)\]/g);for(let g of m)if(r==="inline")l.push({filePath:s.filePath,line:c+1,column:g.index+1,ruleId:"markdown/link-image-style",message:n==="consistent"?"Link style should be consistent throughout document":"Expected inline style link",severity:n==="consistent"?"warning":"error"})}return l},fix:(u,s)=>{let t=(s.options||{}).style||"consistent",o=u.split(/\r?\n/),e=h(o),n=new Map;for(let c=0;c<o.length;c++){if(e.has(c))continue;let a=o[c].match(/^\s*\[([^\]]+)\]:\s*(\S+)(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?\s*$/);if(a){let d=a[1].toLowerCase(),f=a[2],m=a[3]??a[4]??a[5];if(!n.has(d))n.set(d,{url:f,title:m})}}if(n.size===0)return u;let r=t==="reference"?"reference":"inline";if(t==="consistent"){let c=0,a=0;for(let d=0;d<o.length;d++){if(e.has(d))continue;let f=o[d];if(/^\s*\[(?:[^\]]+)\]:\s*\S+/.test(f))continue;let m=C(f);c+=(m.match(/\[[^\]]+\]\([^)]+\)/g)||[]).length,a+=(m.match(/\[[^\]]+\]\[(?:[^\]]*)\]/g)||[]).length}r=a>c?"reference":"inline"}if(r!=="inline")return u;let i=!1;for(let c=0;c<o.length;c++){if(e.has(c))continue;let a=o[c];if(/^\s*\[(?:[^\]]+)\]:\s*\S+/.test(a))continue;let d=a;for(let f=0;f<8;f++){let m=d.replace(/(!?)\[((?:[^[\]]|\[[^\]]*\]\([^)]*\))+)\]\[([^\]]*)\]/g,(g,k,P,R)=>{let y=(R.trim()===""?P:R).toLowerCase(),I=n.get(y);if(!I)return g;let M=I.title?` "${I.title}"`:"";return`${k}[${P}](${I.url}${M})`});if(m===d)break;d=m}if(d!==a)o[c]=d,i=!0}return i?o.join(`
13
+ `):u}};function C(u){return u.replace(/(`+)([^`]+?)\1/g,(s)=>" ".repeat(s.length))}var V={meta:{docs:"List items at the same level should have consistent indentation"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=new Map,e=!1;for(let n=0;n<t.length;n++){let r=t[n],i=r.match(/^(\s*)(?:[*\-+]|\d+\.)\s+/);if(i){e=!0;let c=i[1].length,a=Math.floor(c/2);if(o.has(a)){let d=o.get(a);if(c!==d)l.push({filePath:s.filePath,line:n+1,column:1,ruleId:"markdown/list-indent",message:`Inconsistent indentation for list items at the same level. Expected ${d} spaces, found ${c}`,severity:"error"})}else o.set(a,c)}else if(r.trim().length===0){if(e){let c=t.slice(n+1).find((a)=>a.trim().length>0);if(c&&!/^(?:\s*)(?:[*\-+]|\d+\.)\s+/.test(c))e=!1,o.clear()}}}return l}};var Y={meta:{docs:"Spaces after list markers should be consistent"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=s.options||{},e=o.ul_single||1,n=o.ol_single||1;for(let r=0;r<t.length;r++){let i=t[r],c=i.match(/^(\s*)([*\-+])(\s+)/);if(c){let d=c[3].length;if(d!==e)l.push({filePath:s.filePath,line:r+1,column:c[1].length+2,ruleId:"markdown/list-marker-space",message:`Expected ${e} space${e!==1?"s":""} after list marker, found ${d}`,severity:"error"})}let a=i.match(/^(\s*)(\d+\.)(\s+)/);if(a){let d=a[3].length;if(d!==n)l.push({filePath:s.filePath,line:r+1,column:a[1].length+a[2].length+1,ruleId:"markdown/list-marker-space",message:`Expected ${n} space${n!==1?"s":""} after list marker, found ${d}`,severity:"error"})}}return l},fix:(u,s)=>{let l=s.options||{},t=l.ul_single||1,o=l.ol_single||1;return u.split(/\r?\n/).map((r)=>(r=r.replace(/^(\s*)([*\-+])\s+/,(i,c,a)=>`${c}${a}${" ".repeat(t)}`),r=r.replace(/^(\s*)(\d+\.)\s+/,(i,c,a)=>`${c}${a}${" ".repeat(o)}`),r)).join(`
14
+ `)}};var ee={meta:{docs:"Images should have alternate text"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=!1;for(let e=0;e<t.length;e++){let n=t[e];if(/^(?:`{3,}|~{3,})/.test(n.trim())){o=!o;continue}if(o)continue;let i=n.replace(/``[^`]+``/g,(c)=>" ".repeat(c.length)).replace(/`[^`]+`/g,(c)=>" ".repeat(c.length)).matchAll(/!\[\s*\]\([^)]+\)/g);for(let c of i){let a=c.index+1;l.push({filePath:s.filePath,line:e+1,column:a,ruleId:"markdown/no-alt-text",message:"Images should have alternate text (alt text)",severity:"error"})}}return l}};var te={meta:{docs:"Bare URLs should be wrapped in angle brackets"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=h(t),e=!1;for(let n=0;n<t.length;n++){let r=t[n];if(o.has(n))continue;if(r.includes("<!--"))e=!0;if(r.includes("-->")){e=!1;continue}if(e)continue;if(/^\[(?:[^\]]+)\]:\s*\S+/.test(r))continue;let i=r.replace(/`[^`]+`/g,(d)=>" ".repeat(d.length)),c=/(?<![<(="'])https?:\/\/[^\s<>`)\]"']+(?![>\])"'])/g,a=i.matchAll(c);for(let d of a)l.push({filePath:s.filePath,line:n+1,column:d.index+1,ruleId:"markdown/no-bare-urls",message:"Bare URL used. Wrap in angle brackets: <url>",severity:"error"})}return l},fix:(u)=>{let s=u.split(/\r?\n/),l=h(s),t=!1;return s.map((e,n)=>{if(l.has(n))return e;if(e.includes("<!--"))t=!0;if(e.includes("-->"))return t=!1,e;if(t)return e;if(/^\[(?:[^\]]+)\]:\s*\S+/.test(e))return e;return L(e,(r)=>r.replace(/(?<![<(="'])https?:\/\/[^\s<>`)\]"']+(?![>\])"'])/g,"<$&>"))}).join(`
15
+ `)}};var ne={meta:{docs:"Blank lines inside blockquotes should use the blockquote symbol"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=!1,e=!1;for(let n=0;n<t.length;n++){let r=t[n],i=n+1<t.length?t[n+1]:"";if(/^(?:`{3,}|~{3,})/.test(r.trim())){e=!e,o=!1;continue}if(e)continue;let c=/^\s*>/.test(r),a=r.trim().length===0,d=/^\s*>/.test(i);if(c)o=!0;else if(a&&o&&d)l.push({filePath:s.filePath,line:n+1,column:1,ruleId:"markdown/no-blanks-blockquote",message:"Blank line inside blockquote should use blockquote symbol (>)",severity:"error"});else if(!c&&!a)o=!1}return l},fix:(u)=>{let s=u.split(/\r?\n/),l=!1,t=!1,o=!1;for(let e=0;e<s.length;e++){let n=s[e],r=e+1<s.length?s[e+1]:"";if(/^(?:`{3,}|~{3,})/.test(n.trim())){t=!t,l=!1;continue}if(t)continue;let i=/^\s*>/.test(n),c=n.trim().length===0,a=/^\s*>/.test(r);if(i)l=!0;else if(c&&l&&a){let d=r.match(/^(\s*)>/),f=d?`${d[1]}>`:">";s[e]=f,o=!0}else if(!i&&!c)l=!1}return o?s.join(`
16
+ `):u}};var se={meta:{docs:"Multiple headings should not have the same content"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=!1,e=Array.from({length:7},()=>new Map);for(let n=0;n<t.length;n++){let r=t[n];if(/^(?:`{3,}|~{3,})/.test(r.trim())){o=!o;continue}if(o)continue;if(/^\s*\[Compare changes\]\(/.test(r)){for(let f=2;f<=6;f++)e[f].clear();continue}let i=null,c=0,a=r.match(/^(#{1,6})\s+(.+?)(?:\s*#+\s*)?$/);if(a)c=a[1].length,i=a[2].trim();if(!i){let f=n+1<t.length?t[n+1]:"";if(/^(?:=+)\s*$/.test(f)&&r.trim().length>0)c=1,i=r.trim();else if(/^(?:-+)\s*$/.test(f)&&r.trim().length>0)c=2,i=r.trim()}if(!i||c===0)continue;for(let f=c+1;f<=6;f++)e[f].clear();let d=e[c];if(d.has(i))l.push({filePath:s.filePath,line:n+1,column:1,ruleId:"markdown/no-duplicate-heading",message:`Duplicate heading "${i}" (first occurrence on line ${d.get(i)})`,severity:"error"});else d.set(i,n+1)}return l}};var Ue=/[.!?:;,]\s*$/;function ie(u,s,l){let t=u.match(/^\*\*([^*]+)\*\*\s*$/)||u.match(/^__([^_]+)__\s*$/),o=u.match(/^\*([^*]+)\*\s*$/)||u.match(/^_([^_]+)_\s*$/),e=t||o;if(!e)return null;if(s.trim().length!==0||l.trim().length!==0)return null;let n=e[1];if(Ue.test(n))return null;if(n.trim().split(/\s+/).length>=7)return null;return n}var oe={meta:{docs:"Emphasis should not be used for headings"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=h(t);for(let e=0;e<t.length;e++){if(o.has(e))continue;let n=t[e],r=e>0?t[e-1]:"",i=e+1<t.length?t[e+1]:"";if(ie(n,r,i)===null)continue;l.push({filePath:s.filePath,line:e+1,column:1,ruleId:"markdown/no-emphasis-as-heading",message:"Emphasis used instead of a heading",severity:"warning"})}return l},fix:(u)=>{let s=u.split(/\r?\n/),l=h(s),t=2,o=!1;for(let e=0;e<s.length;e++){if(l.has(e))continue;let n=s[e],r=n.match(/^(#{1,6})\s/);if(r){t=r[1].length;continue}let i=e>0?s[e-1]:"",c=e+1<s.length?s[e+1]:"",a=ie(n,i,c);if(a===null)continue;let d=Math.min(6,Math.max(2,t+1));s[e]=`${"#".repeat(d)} ${a.trim()}`,o=!0}return o?s.join(`
17
+ `):u}};var le={meta:{docs:"Links should not be empty"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=!1;for(let e=0;e<t.length;e++){let n=t[e];if(/^(?:`{3,}|~{3,})/.test(n.trim())){o=!o;continue}if(o)continue;let r=n.replace(/`[^`]+`/g,(a)=>"x".repeat(a.length)),i=r.matchAll(/\[[^\]]+\]\(\s*\)/g);for(let a of i){let d=a.index+1;l.push({filePath:s.filePath,line:e+1,column:d,ruleId:"markdown/no-empty-links",message:"Empty link URL",severity:"error"})}let c=r.matchAll(/\[\s*\]\([^)]+\)/g);for(let a of c){let d=a.index+1;l.push({filePath:s.filePath,line:e+1,column:d,ruleId:"markdown/no-empty-links",message:"Empty link text",severity:"error"})}}return l}};var re={meta:{docs:"Spaces should be used instead of hard tabs"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=!1;for(let e=0;e<t.length;e++){let n=t[e];if(/^(?:`{3,}|~{3,})/.test(n.trim())){o=!o;continue}if(o)continue;let r=n.indexOf("\t");if(r!==-1)l.push({filePath:s.filePath,line:e+1,column:r+1,ruleId:"markdown/no-hard-tabs",message:"Hard tabs should not be used",severity:"error"})}return l},fix:(u)=>{let s=u.split(/\r?\n/),l=!1;return s.map((o)=>{if(/^(?:`{3,}|~{3,})/.test(o.trim()))return l=!l,o;if(l)return o;return o.replace(/\t/g," ")}).join(`
18
+ `)}};var ce={meta:{docs:"Inline HTML should not be used"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),e=(s.options||{}).allowed_elements||[],n=!1;for(let r=0;r<t.length;r++){let i=t[r];if(/^(?:`{3,}|~{3,})/.test(i.trim())){n=!n;continue}if(n)continue;let c=i;c=c.replace(/``[^`]+``/g,(d)=>" ".repeat(d.length)),c=c.replace(/`[^`]+`/g,(d)=>" ".repeat(d.length));let a=c.matchAll(/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi);for(let d of a){let f=d[1].toLowerCase(),m=c.slice(d.index+1+f.length);if(m.startsWith("://")||f==="mailto"&&m.startsWith(":"))continue;if(!e.includes(f)){let g=d.index+1;l.push({filePath:s.filePath,line:r+1,column:g,ruleId:"markdown/no-inline-html",message:`Inline HTML element '<${f}>' should not be used`,severity:"warning"})}}}return l}};var ue={meta:{docs:"ATX style headings must have a space after the hash"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=h(t);for(let e=0;e<t.length;e++){if(o.has(e))continue;let r=t[e].match(/^(#{1,6})([^\s#])/);if(r)l.push({filePath:s.filePath,line:e+1,column:r[1].length+1,ruleId:"markdown/no-missing-space-atx",message:"No space after hash on atx style heading",severity:"error"})}return l},fix:(u)=>{let s=u.split(/\r?\n/),l=h(s);return s.map((o,e)=>{if(l.has(e))return o;return o.replace(/^(#{1,6})([^\s#])/,"$1 $2")}).join(`
19
+ `)}};var ae={meta:{docs:"Closed ATX style headings must have spaces inside the hashes"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=h(t);for(let e=0;e<t.length;e++){if(o.has(e))continue;let n=t[e],r=n.match(/^(#{1,6})\s+(.+?)(#{1,6})\s*$/);if(r){let c=r[1],a=r[2],d=r[3];if(!a.endsWith(" ")){let f=c.length+1+a.length;l.push({filePath:s.filePath,line:e+1,column:f,ruleId:"markdown/no-missing-space-closed-atx",message:"No space inside hashes on closed atx style heading",severity:"error"})}}let i=n.match(/^(#{1,6})(\S.+?#{1,6})\s*$/);if(i)l.push({filePath:s.filePath,line:e+1,column:i[1].length+1,ruleId:"markdown/no-missing-space-closed-atx",message:"No space inside hashes on closed atx style heading",severity:"error"})}return l}};var de={meta:{docs:"Multiple consecutive blank lines should not be used"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=s.options||{},e=o.maximum!==void 0?o.maximum:1,n=h(t),r=0;for(let i=0;i<t.length;i++){let c=t[i];if(n.has(i))r=0;else if(c.trim().length===0){if(r++,r>e)l.push({filePath:s.filePath,line:i+1,column:1,ruleId:"markdown/no-multiple-blanks",message:`Multiple consecutive blank lines (max ${e})`,severity:"error"})}else r=0}return l},fix:(u,s)=>{let l=s.options||{},t=l.maximum!==void 0?l.maximum:1,o=u.split(/\r?\n/),e=[],n=h(o),r=0;for(let i=0;i<o.length;i++){let c=o[i];if(n.has(i))r=0,e.push(c);else if(c.trim().length===0){if(r++,r<=t)e.push(c)}else r=0,e.push(c)}return e.join(`
20
+ `)}};var fe={meta:{docs:"ATX style headings should have only one space after the hash"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=h(t);for(let e=0;e<t.length;e++){if(o.has(e))continue;let r=t[e].match(/^(#{1,6})\s{2,}/);if(r)l.push({filePath:s.filePath,line:e+1,column:r[1].length+1,ruleId:"markdown/no-multiple-space-atx",message:"Multiple spaces after hash on atx style heading",severity:"error"})}return l},fix:(u)=>{let s=u.split(/\r?\n/),l=h(s);return s.map((o,e)=>{if(l.has(e))return o;return o.replace(/^(#{1,6})\s{2,}/,"$1 ")}).join(`
21
+ `)}};var he={meta:{docs:"Blockquote symbols should be followed by a single space"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=h(t);for(let e=0;e<t.length;e++){if(o.has(e))continue;let r=t[e].match(/^(\s*)(>+)\s{2,}/);if(r){let i=r[1].length+r[2].length+1;l.push({filePath:s.filePath,line:e+1,column:i,ruleId:"markdown/no-multiple-space-blockquote",message:"Multiple spaces after blockquote symbol",severity:"error"})}}return l},fix:(u)=>{let s=u.split(/\r?\n/),l=h(s);return s.map((o,e)=>{if(l.has(e))return o;return o.replace(/^(\s*>+)\s{2,}/,"$1 ")}).join(`
22
+ `)}};var me={meta:{docs:"Closed ATX style headings should have only one space inside the hashes"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=h(t);for(let e=0;e<t.length;e++){if(o.has(e))continue;let n=t[e],r=n.match(/^(#{1,6})\s{2,}(?:\S.*?|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])#{1,6}\s*$/);if(r)l.push({filePath:s.filePath,line:e+1,column:r[1].length+1,ruleId:"markdown/no-multiple-space-closed-atx",message:"Multiple spaces inside hashes on closed atx style heading",severity:"error"});let i=n.match(/^#{1,6}\s+(?:\S.*?|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])\s{2,}(#{1,6})\s*$/);if(i){let c=n.lastIndexOf(i[1])-1;l.push({filePath:s.filePath,line:e+1,column:Math.max(1,c),ruleId:"markdown/no-multiple-space-closed-atx",message:"Multiple spaces inside hashes on closed atx style heading",severity:"error"})}}return l}};var pe={meta:{docs:"Link syntax should not be reversed"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=h(t);for(let e=0;e<t.length;e++){if(o.has(e))continue;let r=t[e].matchAll(/\(([^)]+)\)\[(?:[^\]]+)\]/g);for(let i of r){let c=i.index+1;l.push({filePath:s.filePath,line:e+1,column:c,ruleId:"markdown/no-reversed-links",message:"Reversed link syntax: should be [text](url) not (text)[url]",severity:"error"})}}return l}};function ge(u){let s=u.trim();return s.startsWith("`")||s.endsWith("`")}var ke={meta:{docs:"Code span elements should not have spaces inside the backticks"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=h(t);for(let e=0;e<t.length;e++){let n=t[e];if(o.has(e))continue;let r=/(`+)([\s\S]*?)\1/g;for(let i of n.matchAll(r)){let c=i[2];if(c.startsWith(" ")&&c.endsWith(" ")&&c.trim().length>0&&!(ge(c)&&c===` ${c.trim()} `))l.push({filePath:s.filePath,line:e+1,column:i.index+1,ruleId:"markdown/no-space-in-code",message:"Spaces inside code span elements",severity:"error"})}}return l},fix:(u)=>{let s=u.split(/\r?\n/),l=h(s),t=[];for(let o=0;o<s.length;o++){let e=s[o];if(l.has(o)){t.push(e);continue}t.push(e.replace(/(`+)([\s\S]*?)\1/g,(n,r,i)=>{if(i.startsWith(" ")&&i.endsWith(" ")&&i.trim().length>0)return ge(i)?`${r} ${i.trim()} ${r}`:`${r}${i.trim()}${r}`;return n}))}return t.join(`
23
+ `)}};var qe=[/(?<![A-Za-z0-9])\*\*\s+[^*]+?\*\*(?![A-Za-z0-9])/g,/(?<![A-Za-z0-9])\*\*[^*]+?\s+\*\*(?![A-Za-z0-9])/g,/(?<![A-Za-z0-9])__\s+[^_]+?__(?![A-Za-z0-9])/g,/(?<![A-Za-z0-9])__[^_]+?\s+__(?![A-Za-z0-9])/g],ye={meta:{docs:"Emphasis markers should not have spaces inside them"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=h(t);for(let e=0;e<t.length;e++){let n=t[e];if(o.has(e))continue;let r=n.replace(/`[^`]+`/g,(i)=>"\x01".repeat(i.length));for(let i of qe)for(let c of r.matchAll(i))l.push({filePath:s.filePath,line:e+1,column:c.index+1,ruleId:"markdown/no-space-in-emphasis",message:"Spaces inside emphasis markers",severity:"error"})}return l},fix:(u)=>{let s=u.split(/\r?\n/),l=h(s),t=[];for(let o=0;o<s.length;o++){let e=s[o];if(l.has(o)){t.push(e);continue}let n=L(e,(r)=>{let i=r;return i=i.replace(/(?<![A-Za-z0-9])(\*\*)\s+([^*]+?)\*\*(?![A-Za-z0-9])/g,"$1$2**"),i=i.replace(/(?<![A-Za-z0-9])(\*\*)([^*]+?)\s+\*\*(?![A-Za-z0-9])/g,"$1$2**"),i=i.replace(/(?<![A-Za-z0-9])(__)\s+([^_]+?)__(?![A-Za-z0-9])/g,"$1$2__"),i=i.replace(/(?<![A-Za-z0-9])(__)([^_]+?)\s+__(?![A-Za-z0-9])/g,"$1$2__"),i});t.push(n)}return t.join(`
24
+ `)}};var be={meta:{docs:"Link text should not have leading or trailing spaces"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=h(t);for(let e=0;e<t.length;e++){if(o.has(e))continue;let r=t[e].matchAll(/\[([^\][]*)\]\([^)]*\)/g);for(let i of r){let c=i[1];if(/^\s/.test(c)||/\s$/.test(c)){let a=i.index+1;l.push({filePath:s.filePath,line:e+1,column:a,ruleId:"markdown/no-space-in-links",message:"Spaces inside link text",severity:"error"})}}}return l}};var Le={meta:{docs:"Headings should not end with punctuation"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),e=(s.options||{}).punctuation||".,;:!\u3002\uFF0C\uFF1B\uFF1A\uFF01",n=!1;for(let r=0;r<t.length;r++){let i=t[r];if(/^(?:`{3,}|~{3,})/.test(i.trim())){n=!n;continue}if(n)continue;let c=i.match(/^#{1,6}\s+(.+?)(?:\s*#+\s*)?$/);if(c){let d=c[1].trim(),f=d[d.length-1];if(f&&e.includes(f))l.push({filePath:s.filePath,line:r+1,column:i.indexOf(d)+d.length,ruleId:"markdown/no-trailing-punctuation",message:`Trailing punctuation in heading: '${f}'`,severity:"error"})}let a=r+1<t.length?t[r+1]:"";if(/^(?:=+|-+)\s*$/.test(a)&&i.trim().length>0){let d=i.trim(),f=d[d.length-1];if(f&&e.includes(f))l.push({filePath:s.filePath,line:r+1,column:i.indexOf(d)+d.length,ruleId:"markdown/no-trailing-punctuation",message:`Trailing punctuation in heading: '${f}'`,severity:"error"})}}return l},fix:(u,s)=>{let t=(s.options||{}).punctuation||".,;:!\u3002\uFF0C\uFF1B\uFF1A\uFF01",o=new RegExp(`[${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}]+$`),e=u.split(/\r?\n/),n=!1;return e.map((i,c)=>{if(/^(?:`{3,}|~{3,})/.test(i.trim()))return n=!n,i;if(n)return i;let a=i.match(/^(#{1,6}\s+)(.+?)(\s*#+\s*)?$/);if(a){let f=a[1],m=a[2],g=a[3]||"",k=m.replace(o,"");return`${f}${k}${g}`}let d=c+1<e.length?e[c+1]:"";if(/^(?:=+|-+)\s*$/.test(d)&&i.trim().length>0)return i.replace(o,"");return i}).join(`
25
+ `)}};var xe={meta:{docs:"Lines should not end with trailing spaces"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/);for(let o=0;o<t.length;o++){let e=t[o],n=e.match(/\s+$/);if(n){let r=s.options||{},i=r.br_spaces!==void 0?r.br_spaces:2;if(i===0||n[0].length!==i)l.push({filePath:s.filePath,line:o+1,column:e.length-n[0].length+1,ruleId:"markdown/no-trailing-spaces",message:`Trailing spaces found (${n[0].length} space${n[0].length!==1?"s":""})`,severity:"error"})}}return l},fix:(u,s)=>{let l=u.split(/\r?\n/),t=s.options||{},o=t.br_spaces!==void 0?t.br_spaces:2;return l.map((n)=>{let r=n.match(/\s+$/);if(r){if(o>0&&r[0].length===o)return n;return n.replace(/\s+$/,"")}return n}).join(`
26
+ `)}};var Ie={meta:{docs:"Ordered list item prefix should follow specified style"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),e=(s.options||{}).style||"one_or_ordered",n=1;for(let r=0;r<t.length;r++){let i=t[r],c=i.match(/^(\s*)(\d+)\.\s+/);if(c){let a=Number.parseInt(c[2],10);if(e==="one"&&a!==1)l.push({filePath:s.filePath,line:r+1,column:c[1].length+1,ruleId:"markdown/ol-prefix",message:`Ordered list item prefix should be '1.', found '${a}.'`,severity:"error"});else if(e==="ordered"&&a!==n)l.push({filePath:s.filePath,line:r+1,column:c[1].length+1,ruleId:"markdown/ol-prefix",message:`Ordered list item prefix should be '${n}.', found '${a}.'`,severity:"error"});n++}else if(i.trim().length===0)n=1}return l},fix:(u,s)=>{let t=(s.options||{}).style||"one_or_ordered",o=u.split(/\r?\n/),e=[],n=1;for(let r of o){let i=r.match(/^(\s*)(\d+)(\.\s+)/);if(i){let c=i[1],a=i[3];if(t==="one")e.push(r.replace(/^(\s*)\d+(\.\s+)/,`${c}1${a}`));else if(t==="ordered")e.push(r.replace(/^(\s*)\d+(\.\s+)/,`${c}${n}${a}`)),n++;else e.push(r),n++}else if(e.push(r),r.trim().length===0)n=1}return e.join(`
27
+ `)}};var Re={meta:{docs:"Proper names should have correct capitalization"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=s.options||{},e=o.names||[],n=o.code_blocks!==!1;if(e.length===0)return l;let r=h(t);for(let i=0;i<t.length;i++){if(r.has(i)&&!n)continue;let c=t[i];for(let a of e){let d=new RegExp(`\\b${a}\\b`,"gi"),f=c.matchAll(d);for(let m of f)if(m[0]!==a){let g=m.index+1;l.push({filePath:s.filePath,line:i+1,column:g,ruleId:"markdown/proper-names",message:`Incorrect capitalization of '${m[0]}', should be '${a}'`,severity:"error"})}}}return l}};var Pe={meta:{docs:"Reference links and images should use defined labels"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=new Set;for(let r of t){let i=r.match(/^\s*\[([^\]]+)\]:\s*\S+/);if(i)o.add(i[1].toLowerCase())}let e=!1,n=!1;for(let r=0;r<t.length;r++){let i=t[r];if(/^(?:`{3,}|~{3,})/.test(i.trim())){e=!e;continue}if(e)continue;if(i.includes("<!--"))n=!0;if(i.includes("-->")){n=!1;continue}if(n)continue;if(/^\s*\[(?:[^\]]+)\]:\s*\S+/.test(i))continue;let c=i.replace(/`[^`]+`/g,(d)=>" ".repeat(d.length));c=c.replace(/!?\[[^\]]*\]\([^)]*\)/g,(d)=>" ".repeat(d.length));let a=c.matchAll(/!?\[([^\]]+)\]\[([^\]]*)\]/g);for(let d of a){let f=(d[2].trim()||d[1]).toLowerCase();if(!o.has(f))l.push({filePath:s.filePath,line:r+1,column:d.index+1,ruleId:"markdown/reference-links-images",message:`Reference link '[${f}]' is not defined`,severity:"error"})}}return l}};var Me={meta:{docs:"Document should have required heading structure"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),e=(s.options||{}).headings||[];if(e.length===0)return l;let n=[];for(let i of t){let c=i.match(/^#{1,6}\s+(.+?)(?:\s*#+\s*)?$/);if(c)n.push(c[1].trim())}let r=0;for(let i=0;i<n.length&&r<e.length;i++)if(n[i]===e[r])r++;if(r<e.length)l.push({filePath:s.filePath,line:1,column:1,ruleId:"markdown/required-headings",message:`Missing required heading: '${e[r]}'`,severity:"error"});return l}};var we={meta:{docs:"Document should have only one top-level heading (h1)"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=h(t),e=-1;for(let n=0;n<t.length;n++){if(o.has(n))continue;let r=t[n],i=n+1<t.length?t[n+1]:"",c=!1;if(/^#\s/.test(r))c=!0;if(/^=+\s*$/.test(i)&&r.trim().length>0&&!o.has(n+1))c=!0;if(c)if(e===-1)e=n+1;else l.push({filePath:s.filePath,line:n+1,column:1,ruleId:"markdown/single-title",message:`Multiple top-level headings in the same document (first h1 on line ${e})`,severity:"error"})}return l},fix:(u)=>{let s=u.split(/\r?\n/),l=h(s),t=[],o=!1,e=!1;for(let n=0;n<s.length;n++){if(l.has(n)){t.push(s[n]);continue}let r=s[n],i=n+1<s.length?s[n+1]:"",c=/^#\s/.test(r),a=/^=+\s*$/.test(i)&&r.trim().length>0&&!l.has(n+1);if(c){if(!o)o=!0,t.push(r);else t.push(`#${r}`),e=!0;continue}if(a){if(!o){o=!0,t.push(r);continue}t.push(`## ${r.trim()}`),n++,e=!0;continue}t.push(r)}return e?t.join(`
28
+ `):u}};var ve={meta:{docs:"Files should end with a single newline character"},check:(u,s)=>{let l=[];if(!u.endsWith(`
29
+ `)&&!u.endsWith(`\r
30
+ `)){let t=u.split(/\r?\n/);l.push({filePath:s.filePath,line:t.length,column:t[t.length-1].length+1,ruleId:"markdown/single-trailing-newline",message:"File should end with a single newline character",severity:"error"})}if(u.endsWith(`
31
+
32
+ `)||u.endsWith(`\r
33
+ \r
34
+ `)){let t=u.split(/\r?\n/);l.push({filePath:s.filePath,line:t.length,column:1,ruleId:"markdown/single-trailing-newline",message:"File should end with a single newline character (not multiple)",severity:"error"})}return l},fix:(u)=>`${u.replace(/[\r\n]+$/,"")}
35
+ `};var $e={meta:{docs:"Strong style should be consistent (asterisk or underscore)"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=h(t),n=(s.options||{}).style||"consistent",r=null;for(let i=0;i<t.length;i++){if(o.has(i))continue;let c=b(t[i]),a=c.matchAll(/\*\*([^*]+)\*\*/g);for(let f of a)if(n==="underscore")l.push({filePath:s.filePath,line:i+1,column:f.index+1,ruleId:"markdown/strong-style",message:"Expected underscore (__) for strong",severity:"error"});else if(n==="consistent"){if(r===null)r="asterisk";else if(r==="underscore")l.push({filePath:s.filePath,line:i+1,column:f.index+1,ruleId:"markdown/strong-style",message:"Strong style should be consistent throughout document",severity:"error"})}let d=c.matchAll(/__([^_]+)__/g);for(let f of d)if(n==="asterisk")l.push({filePath:s.filePath,line:i+1,column:f.index+1,ruleId:"markdown/strong-style",message:"Expected asterisk (**) for strong",severity:"error"});else if(n==="consistent"){if(r===null)r="underscore";else if(r==="asterisk")l.push({filePath:s.filePath,line:i+1,column:f.index+1,ruleId:"markdown/strong-style",message:"Strong style should be consistent throughout document",severity:"error"})}}return l},fix:(u,s)=>{let t=(s.options||{}).style||"consistent",o=u.split(/\r?\n/),e=h(o),n="asterisk";if(t==="asterisk")n="asterisk";else if(t==="underscore")n="underscore";else if(t==="consistent"){let i=null,c=null;for(let d=0;d<o.length;d++){if(e.has(d))continue;let f=b(o[d]);if(i===null){let m=f.match(/\*\*([^*]+)\*\*/);if(m)i={line:d,col:m.index}}if(c===null){let m=f.match(/__([^_]+)__/);if(m)c={line:d,col:m.index}}if(i&&c)break}if(i&&(!c||((d,f)=>d.line!==f.line?d.line-f.line:d.col-f.col)(i,c)<0))n="asterisk";else if(c)n="underscore"}let r=!1;for(let i=0;i<o.length;i++){if(e.has(i))continue;let c=o[i],a=L(c,(d)=>n==="asterisk"?d.replace(/__([^_]+)__/g,"**$1**"):d.replace(/\*\*([^*]+)\*\*/g,"__$1__"));if(a!==c)o[i]=a,r=!0}return r?o.join(`
36
+ `):u}};var Ce={meta:{docs:"Table rows should have consistent column counts"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=!1,e=-1,n=!1,r=x(t);for(let i=0;i<t.length;i++){let c=t[i];if(/^(?:`{3,}|~{3,})/.test(c.trim())){if(n=!n,o)o=!1,e=-1;continue}if(n)continue;let a=r.has(i)&&/\|/.test(c)&&c.trim().length>0;if(a){let d=ze(c);if(!o)o=!0,e=d;else if(d!==e)l.push({filePath:s.filePath,line:i+1,column:1,ruleId:"markdown/table-column-count",message:`Table row has ${d} column(s), expected ${e}`,severity:"error"})}else if(c.trim().length===0||!a){if(o)o=!1,e=-1}}return l}};function ze(u){let s=u.trim();if(s.startsWith("|"))s=s.slice(1);if(s.endsWith("|")&&!s.endsWith("\\|"))s=s.slice(0,-1);if(s==="")return 0;let l=1,t=!1,o=0,e=0;while(e<s.length){let n=s[e];if(n==="\\"&&s[e+1]==="|"){e+=2;continue}if(n==="`"){let r=0;while(s[e+r]==="`")r++;if(!t)t=!0,o=r;else if(r===o)t=!1,o=0;e+=r;continue}if(!t&&n==="|")l++;e++}return l}var Se={meta:{docs:"Table columns should have consistent alignment"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/);for(let o=0;o<t.length;o++){let e=t[o];if(/[-:]/.test(e)&&/\|/.test(e)){if(e.match(/^[|\s:.-]+$/)){let r=e.split("|").filter((i)=>i.trim().length>0);for(let i of r){let c=i.trim();if(!/^:?-+:?$/.test(c))l.push({filePath:s.filePath,line:o+1,column:e.indexOf(i)+1,ruleId:"markdown/table-column-style",message:"Invalid table column separator",severity:"error"})}}}}return l}};var _e={meta:{docs:"Table pipe style should be consistent"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),e=(s.options||{}).style||"leading_and_trailing",n=!1,r=x(t);for(let i=0;i<t.length;i++){let c=t[i];if(/^(?:`{3,}|~{3,})/.test(c.trim())){n=!n;continue}if(n)continue;if(r.has(i)&&/\|/.test(c)&&c.trim().length>0){let a=c.trim().startsWith("|"),d=c.trim().endsWith("|");if(e==="leading_and_trailing"){if(!a||!d)l.push({filePath:s.filePath,line:i+1,column:1,ruleId:"markdown/table-pipe-style",message:"Table rows should have leading and trailing pipes",severity:"error"})}else if(e==="leading_only"){if(!a||d)l.push({filePath:s.filePath,line:i+1,column:1,ruleId:"markdown/table-pipe-style",message:"Table rows should have leading pipe only",severity:"error"})}else if(e==="trailing_only"){if(a||!d)l.push({filePath:s.filePath,line:i+1,column:1,ruleId:"markdown/table-pipe-style",message:"Table rows should have trailing pipe only",severity:"error"})}else if(e==="no_leading_or_trailing"){if(a||d)l.push({filePath:s.filePath,line:i+1,column:1,ruleId:"markdown/table-pipe-style",message:"Table rows should not have leading or trailing pipes",severity:"error"})}}}return l}};var Ae={meta:{docs:"Unordered list indentation should be consistent"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),e=(s.options||{}).indent||2,n=!1,r=[];for(let i=0;i<t.length;i++){let c=t[i];if(/^(?:`{3,}|~{3,})/.test(c.trim())){n=!n;continue}if(n)continue;if(c.trim()==="")continue;let a=c.match(/^(\s*)([*\-+])(\s+)/),d=c.match(/^(\s*)(\d+[.)])(\s+)/);if(!a&&!d){let y=c.match(/^(\s*)/)?.[1].length||0;while(r.length>0&&r[r.length-1].contentCol>y)r.pop();continue}let f=a||d,m=f[1].length,g=f[2],k=f[3],P=m+g.length+k.length,R=a?"ul":"ol";while(r.length>0&&m<r[r.length-1].contentCol)r.pop();if(R==="ul"){let y=r.length>0?r[r.length-1]:null;if(!y){if(m!==0&&m%e!==0)l.push({filePath:s.filePath,line:i+1,column:1,ruleId:"markdown/ul-indent",message:`Unordered list indentation should be ${e} spaces per level. Found ${m} spaces`,severity:"error"})}else if(y.type==="ul"){let I=y.contentCol,M=y.indent+e;if(m!==I&&m!==M)l.push({filePath:s.filePath,line:i+1,column:1,ruleId:"markdown/ul-indent",message:`Unordered list indentation should be ${e} spaces per level. Found ${m} spaces`,severity:"error"})}}r.push({indent:m,contentCol:P,type:R})}return l}};var Be={meta:{docs:"Unordered list style should be consistent"},check:(u,s)=>{let l=[],t=u.split(/\r?\n/),o=h(t),n=(s.options||{}).style||"consistent",r=null;for(let i=0;i<t.length;i++){let c=t[i];if(o.has(i))continue;let a=c.match(/^(\s*)([*\-+])\s+/);if(a){let d=a[2];if(n==="asterisk"&&d!=="*")l.push({filePath:s.filePath,line:i+1,column:a[1].length+1,ruleId:"markdown/ul-style",message:`Expected asterisk (*) for unordered list, found '${d}'`,severity:"error"});else if(n==="dash"&&d!=="-")l.push({filePath:s.filePath,line:i+1,column:a[1].length+1,ruleId:"markdown/ul-style",message:`Expected dash (-) for unordered list, found '${d}'`,severity:"error"});else if(n==="plus"&&d!=="+")l.push({filePath:s.filePath,line:i+1,column:a[1].length+1,ruleId:"markdown/ul-style",message:`Expected plus (+) for unordered list, found '${d}'`,severity:"error"});else if(n==="consistent"){if(r===null)r=d;else if(r!==d)l.push({filePath:s.filePath,line:i+1,column:a[1].length+1,ruleId:"markdown/ul-style",message:`Unordered list style should be consistent throughout document. Expected '${r}', found '${d}'`,severity:"error"})}}}return l},fix:(u,s)=>{let t=(s.options||{}).style||"consistent",o=u.split(/\r?\n/),e=h(o),n="*";if(t==="asterisk")n="*";else if(t==="dash")n="-";else if(t==="plus")n="+";else if(t==="consistent")for(let i=0;i<o.length;i++){if(e.has(i))continue;let c=o[i].match(/^(\s*)([*\-+])\s+/);if(c){n=c[2];break}}return o.map((i,c)=>{if(e.has(c))return i;return i.replace(/^(\s*)([*\-+])(\s+)/,`$1${n}$3`)}).join(`
37
+ `)}};function Oe(u){let s=u.split(/\r?\n/);if(s[0]?.trim()!=="---")return{text:u,frontmatter:null,frontmatterEndLine:0};for(let l=1;l<s.length;l++)if(s[l].trim()==="---"){let t=s.slice(0,l+1);return{text:[...t.map(()=>""),...s.slice(l+1)].join(`
38
+ `),frontmatter:t,frontmatterEndLine:l+1}}return{text:u,frontmatter:null,frontmatterEndLine:0}}function We(u){let s=u.split(/\r?\n/);if(s[0]?.trim()!=="---")return{header:null,body:u};for(let l=1;l<s.length;l++)if(s[l].trim()==="---")return{header:s.slice(0,l+1).join(`
39
+ `),body:s.slice(l+1).join(`
40
+ `)};return{header:null,body:u}}function Ne(u){return{meta:u.meta,check:(s,l)=>l.filePath.endsWith(".md")?u.check(s,l):[],fix:u.fix?(s,l)=>l.filePath.endsWith(".md")?u.fix(s,l):s:void 0}}function p(u){return{meta:u.meta,check:(s,l)=>{if(!l.filePath.endsWith(".md"))return[];let{text:t,frontmatterEndLine:o}=Oe(s),e=u.check(t,l);if(o>0)return e.filter((n)=>n.line>o+1);return e},fix:u.fix?(s,l)=>{if(!l.filePath.endsWith(".md"))return s;let{header:t,body:o}=We(s);if(t===null)return u.fix(s,l);let e=u.fix(o,l);if(e===o)return s;return`${t}
41
+ ${e}`}:void 0}}var Ls={name:"markdown",rules:{"heading-increment":p(N),"heading-style":p(D),"no-missing-space-atx":p(ue),"no-multiple-space-atx":p(fe),"no-missing-space-closed-atx":p(ae),"no-multiple-space-closed-atx":p(me),"blanks-around-headings":p(_),"heading-start-left":p(Z),"no-duplicate-heading":p(se),"single-title":p(we),"no-trailing-punctuation":p(Le),"ul-style":p(Be),"list-indent":p(V),"ul-indent":p(Ae),"ol-prefix":p(Ie),"list-marker-space":p(Y),"blanks-around-lists":p(A),"no-trailing-spaces":p(xe),"no-hard-tabs":p(re),"no-multiple-blanks":p(de),"no-multiple-space-blockquote":p(he),"no-blanks-blockquote":p(ne),"blanks-around-fences":p(S),"single-trailing-newline":Ne(ve),"blanks-around-tables":p(T),"no-reversed-links":p(pe),"no-bare-urls":p(te),"no-space-in-links":p(be),"no-empty-links":p(le),"link-fragments":p(G),"reference-links-images":p(Pe),"link-image-reference-definitions":p(J),"link-image-style":p(Q),"descriptive-link-text":p(q),"line-length":p(K),"commands-show-output":p(U),"fenced-code-language":p(O),"code-block-style":p(F),"code-fence-style":p(j),"no-emphasis-as-heading":p(oe),"no-space-in-emphasis":p(ye),"no-space-in-code":p(ke),"emphasis-style":p(z),"strong-style":p($e),"no-inline-html":p(ce),"hr-style":p(X),"first-line-heading":p(W),"required-headings":p(Me),"proper-names":p(Re),"no-alt-text":p(ee),"table-pipe-style":p(_e),"table-column-count":p(Ce),"table-column-style":p(Se)}};export{Ls as markdownPlugin};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{F,S,D,j,k,B}from"./chunk-mqjmcycy.js";import"./chunk-1jtr81zg.js";import"./chunk-pvptb0h1.js";export{S as fixText,k as lintFileForRun,F as lintText,j as plannedCheckRules,B as runLint,D as runLintProgrammatic};
@@ -0,0 +1,9 @@
1
+ // @bun
2
+ import{n}from"./chunk-8m82hwdv.js";import{a,i,g}from"./chunk-c82emw32.js";var v={meta:{docs:"Use $() instead of backticks for command substitution",recommended:!0},check(u,f){let o=[],c=u.split(/\r?\n/),s=!1,r="",e=!1;for(let t=0;t<c.length;t++){let d=c[t];if(s){if(d.trim()===r)s=!1;continue}let m=d.match(/<<-?\s*['"]?(\w+)['"]?/);if(m)s=!0,r=m[1];if(d.replace(/^\s+/,"").startsWith("#"))continue;e=!1;for(let l=0;l<d.length;l++){let p=d[l];if(p==="#"&&!e)break;if(p==="\\"){l++;continue}if(p==="'"){e=!e;continue}if(e)continue;if(p==="`"){o.push({filePath:f.filePath,line:t+1,column:l+1,ruleId:"shell/command-substitution",message:"Use $(...) instead of backticks for command substitution",severity:"error",help:"Replace `cmd` with $(cmd) for better readability and nesting support"});for(l++;l<d.length&&d[l]!=="`";l++)if(d[l]==="\\")l++}}}return o},fix(u,f){let o=u.split(/\r?\n/),c=[],s=!1,r="";for(let e of o){if(s){if(c.push(e),e.trim()===r)s=!1;continue}let t=e.match(/<<-?\s*['"]?(\w+)['"]?/);if(t)s=!0,r=t[1];let d="",m=!1,h=0;while(h<e.length){let l=e[h];if(l==="#"&&!m){d+=e.slice(h);break}if(l==="\\"){d+=e.slice(h,h+2),h+=2;continue}if(l==="'"){m=!m,d+=l,h++;continue}if(m){d+=l,h++;continue}if(l==="`"){let p="";h++;while(h<e.length&&e[h]!=="`")if(e[h]==="\\")p+=e[h+1]||"",h+=2;else p+=e[h],h++;h++,d+=`$(${p})`}else d+=l,h++}c.push(d)}return c.join(`
3
+ `)}};var P={meta:{docs:"Require error handling after cd commands",recommended:!0},check(u,f){let o=[],c=u.split(/\r?\n/),s=!1,r="";for(let e=0;e<c.length;e++){let t=c[e];if(s){if(t.trim()===r)s=!1;continue}let d=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(d)s=!0,r=d[1];let m=t.replace(/^\s+/,"");if(m.startsWith("#"))continue;let h=m.match(/^cd\s+/);if(!h)continue;let l=/\|\||&&/.test(t),p=/^\s*(?:if|elif|while|until)\s/.test(m)||/\bif\s+cd\b/.test(t),b=/\(.*\bcd\b.*\)/.test(t);if(!l&&!p&&!b)o.push({filePath:f.filePath,line:e+1,column:h.index+1,ruleId:"shell/no-cd-without-check",message:"cd without error handling \u2014 if it fails, subsequent commands run in the wrong directory",severity:"warning",help:"Use: cd dir || exit 1 (or || return 1 inside functions)"})}return o}};var S={meta:{docs:"Disallow use of eval in shell scripts",recommended:!0},check(u,f){let o=[],c=u.split(/\r?\n/),s=!1,r="";for(let e=0;e<c.length;e++){let t=c[e];if(s){if(t.trim()===r)s=!1;continue}let d=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(d)s=!0,r=d[1];if(t.replace(/^\s+/,"").startsWith("#"))continue;if(t.match(/(?:^|[;&|]\s*|^\s+)eval\s/)){let l=t.indexOf("eval");o.push({filePath:f.filePath,line:e+1,column:l+1,ruleId:"shell/no-eval",message:"Avoid using eval \u2014 it re-parses arguments and can lead to code injection",severity:"error",help:"Refactor to avoid eval. Consider using arrays for dynamic commands or indirect variable references with ${!var}"})}}return o}};var D={meta:{docs:"Flag exit inside subshells where it only exits the subshell",recommended:!0},check(u,f){let o=[],c=u.split(/\r?\n/),s=!1,r="",e=0;for(let t=0;t<c.length;t++){let d=c[t];if(s){if(d.trim()===r)s=!1;continue}let m=d.match(/<<-?\s*['"]?(\w+)['"]?/);if(m)s=!0,r=m[1];if(d.replace(/^\s+/,"").startsWith("#"))continue;let l=!1,p=!1;for(let b=0;b<d.length;b++){let R=d[b];if(R==="#"&&!l&&!p)break;if(R==="\\"&&!l){b++;continue}if(R==="'"&&!p){l=!l;continue}if(R==='"'&&!l){p=!p;continue}if(!l&&!p){if(R==="("&&b>0&&d[b-1]!=="$"&&d[b+1]!=="(")e++;else if(R==="("&&b===0&&d[b+1]!=="(")e++;else if(R===")"&&e>0&&(b+1>=d.length||d[b+1]!==")"))e--}}if(e>0){let b=d.match(/\bexit\b/);if(b)o.push({filePath:f.filePath,line:t+1,column:b.index+1,ruleId:"shell/no-exit-in-subshell",message:"exit inside a subshell only exits the subshell, not the script",severity:"warning",help:"Restructure to avoid subshells, or use return if inside a function"})}if(e===0){let b=d.match(/(?<!\$)\((?!\()([^)]*\bexit\b[^)]*)\)(?!\))/);if(b){let R=d.indexOf("exit",b.index);o.push({filePath:f.filePath,line:t+1,column:R+1,ruleId:"shell/no-exit-in-subshell",message:"exit inside a subshell only exits the subshell, not the script",severity:"warning",help:"Restructure to avoid subshells, or use return if inside a function"})}}}return o}};var I={meta:{docs:"Disallow parsing ls output \u2014 use globs or find instead",recommended:!0},check(u,f){let o=[],c=u.split(/\r?\n/),s=!1,r="";for(let e=0;e<c.length;e++){let t=c[e];if(s){if(t.trim()===r)s=!1;continue}let d=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(d)s=!0,r=d[1];if(t.replace(/^\s+/,"").startsWith("#"))continue;if(t.match(/\bls\b[^|]*\|/)){let b=t.indexOf("ls");o.push({filePath:f.filePath,line:e+1,column:b+1,ruleId:"shell/no-ls-parsing",message:"Don't parse ls output \u2014 filenames can contain special characters",severity:"warning",help:'Use globs (for f in *.txt), find (find . -name "*.txt"), or stat instead'});continue}let l=t.match(/\$\(\s*ls\b/);if(l){let b=l.index+1;o.push({filePath:f.filePath,line:e+1,column:b,ruleId:"shell/no-ls-parsing",message:"Don't use ls in command substitution \u2014 use globs instead",severity:"warning",help:"Replace $(ls *.txt) with glob patterns: for f in *.txt; do ...; done"});continue}let p=t.match(/`\s*ls\b/);if(p){let b=p.index+1;o.push({filePath:f.filePath,line:e+1,column:b,ruleId:"shell/no-ls-parsing",message:"Don't use ls in command substitution \u2014 use globs instead",severity:"warning",help:"Replace `ls` with glob patterns"})}}return o}};var T={meta:{docs:"Detect useless use of cat (UUOC)",recommended:!0},check(u,f){let o=[],c=u.split(/\r?\n/),s=!1,r="";for(let e=0;e<c.length;e++){let t=c[e];if(s){if(t.trim()===r)s=!1;continue}let d=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(d)s=!0,r=d[1];if(t.replace(/^\s+/,"").startsWith("#"))continue;let h=t.match(/\bcat\s+(["']?[\w.\/~${}*?-]+["']?)\s*\|/);if(h){let l=t.indexOf("cat");o.push({filePath:f.filePath,line:e+1,column:l+1,ruleId:"shell/no-useless-cat",message:`Useless use of cat \u2014 pipe the file directly instead of \`cat ${h[1]} | ...\``,severity:"warning",help:`Use \`cmd < ${h[1]}\` or pass the file as an argument to the command`})}}return o}};var W={meta:{docs:"Flag variables inside single quotes where they won't expand",recommended:!0},check(u,f){let o=[],c=u.split(/\r?\n/),s=!1,r="";for(let e=0;e<c.length;e++){let t=c[e];if(s){if(t.trim()===r)s=!1;continue}let d=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(d)s=!0,r=d[1];if(t.replace(/^\s+/,"").startsWith("#"))continue;let h=!1,l=!1,p=-1;for(let b=0;b<t.length;b++){let R=t[b];if(R==="#"&&!h&&!l)break;if(R==="\\"&&!h){b++;continue}if(R==='"'&&!h){l=!l;continue}if(R==="'"&&!l)if(!h)h=!0,p=b;else{let M=t.slice(p+1,b).match(/\$(?:[A-Za-z_]\w*|\{[^}]+\}|\([^)]*\))/),w=/(?:^|[;&|])\s*(?:(?:then|do)\s+)?(?:(?:builtin|command)\s+)?trap\s+(?:--\s+)?$/.test(t.slice(0,p));if(M&&!w)o.push({filePath:f.filePath,line:e+1,column:p+1+M.index+1,ruleId:"shell/no-variable-in-single-quotes",message:`Variable ${M[0]} is inside single quotes and won't be expanded`,severity:"warning",help:`Use double quotes if you want variable expansion: "..." instead of '...'`});h=!1}}}return o}};var G=[/^\s*(?:local|export|declare|typeset|readonly)\s+/,/\[\[.*\]\]/,/\(\(.*\)\)/],k=/^\$(?:\{[A-Za-z_]\w*(?:[:#%\/][^}]*)?\}|[A-Za-z_]\w*)/,H={meta:{docs:"Quote variable expansions to prevent word splitting and globbing",recommended:!0},check(u,f){let o=[],c=u.split(/\r?\n/),s=!1,r="";for(let e=0;e<c.length;e++){let t=c[e];if(s){if(t.trim()===r)s=!1;continue}let d=i(t);if(d){if(s=!0,r=d,new RegExp(`<<-?\\s*['"]${d}['"]`).test(t))continue}if(t.replace(/^\s+/,"").startsWith("#"))continue;if(G.some((p)=>p.test(t)))continue;let h=[],l=0;while(l<t.length){let p=h[h.length-1];if(p==="squote"){if(t[l]==="'")h.pop();l++;continue}if(t[l]==="\\"&&l+1<t.length){l+=2;continue}if(p==="dquote"){let R=t[l];if(R==='"'){h.pop(),l++;continue}if(R==="$"&&t[l+1]==="("&&t[l+2]==="("){h.push("arith"),l+=3;continue}if(R==="$"&&t[l+1]==="("){h.push("subshell"),l+=2;continue}if(R==="$"){let y=t.slice(l).match(k);if(y){l+=y[0].length;continue}}l++;continue}if(p==="arith"){let R=t[l];if(R===")"&&t[l+1]===")"){h.pop(),l+=2;continue}if(R==="$"){let y=t.slice(l).match(k);if(y){l+=y[0].length;continue}}l++;continue}let b=t[l];if(b==="#"&&(l===0||/\s/.test(t[l-1])))break;if(b==="'"){h.push("squote"),l++;continue}if(b==='"'){h.push("dquote"),l++;continue}if(b==="$"&&t[l+1]==="("&&t[l+2]==="("){h.push("arith"),l+=3;continue}if(b==="$"&&t[l+1]==="("){h.push("subshell"),l+=2;continue}if(b===")"&&p==="subshell"){h.pop(),l++;continue}if(b==="$"){let R=t.slice(l).match(k);if(R){let y=R[0];if(!/^\$[?!#@*0-9-]/.test(y))o.push({filePath:f.filePath,line:e+1,column:l+1,ruleId:"shell/quote-variables",message:`Unquoted variable ${y} \u2014 use "${y}" to prevent word splitting`,severity:"warning",help:`Wrap in double quotes: "${y}"`});l+=y.length;continue}}l++}}return o}};var C={meta:{docs:"Enforce consistent function declaration style",recommended:!0},check(u,f){let o=[],c=u.split(/\r?\n/),s=!1,r="";for(let e=0;e<c.length;e++){let t=c[e];if(s){if(t.trim()===r)s=!1;continue}let d=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(d)s=!0,r=d[1];let m=t.replace(/^\s+/,"");if(m.startsWith("#"))continue;let h=m.match(/^function\s+(\w+)\s*(?:\(\s*\))?\s*\{?\s*$/);if(h){let l=h[1],p=t.indexOf("function");o.push({filePath:f.filePath,line:e+1,column:p+1,ruleId:"shell/function-style",message:`Use \`${l}() {\` instead of \`function ${l}\` \u2014 POSIX-compatible style`,severity:"warning",help:`Replace with: ${l}() {`})}}return o},fix(u){let f=u.split(/\r?\n/),o=[];for(let c of f){let s=c.match(/^(\s*)function\s+(\w+)\s*(?:\(\s*\))?\s*(\{?\s*)$/);if(s){let[,r,e,t]=s;o.push(`${r}${e}() ${t||"{"}`)}else o.push(c)}return o.join(`
4
+ `)}};function E(u,f){if(/^then\b/.test(u)||/^do\b/.test(u)||/^else\b/.test(u))return!0;if(/^if\b/.test(u)&&/\bthen\s*$/.test(u))return!0;if(/^elif\b/.test(u)&&/\bthen\s*$/.test(u))return!0;if(/^(?:while|for|until)\b/.test(u)&&/\bdo\s*$/.test(u))return!0;if(/^case\b/.test(u)&&/\bin\s*$/.test(u))return!0;if(f&&/\)\s*$/.test(u)&&!/\$\(/.test(u)&&!/^\s*\(/.test(u)&&!u.startsWith("#"))return!0;if(/\{\s*$/.test(u)&&!u.startsWith("#"))return!0;return!1}function q(u){return/^(?:fi|done|esac|elif|else)\b/.test(u)||/^\}/.test(u)||/^;[;&]\s*$/.test(u)}var O={meta:{docs:"Enforce consistent indentation in shell scripts",recommended:!0},check(u,f){let o=[],c=u.split(/\r?\n/),s=f.config.format.indent||2,r=0,e=new g,t=!1,d="",m=!1,h=0;for(let l=0;l<c.length;l++){let p=c[l];if(/^\s*$/.test(p))continue;if(t){if(p.trim()===d)t=!1;continue}let b=p.match(/<<-?\s*['"]?(\w+)['"]?/);if(b)t=!0,d=b[1];let R=p.replace(/^\s+/,""),y=e.read(R);if(l===0&&R.startsWith("#!"))continue;if(/^case\b/.test(R)&&/\bin\s*$/.test(R))h++,m=!0;if(/^esac\b/.test(R)){if(h=Math.max(0,h-1),h===0)m=!1}if(!y.continuation&&q(R))r=Math.max(0,r-1);let M=0;for(let x=0;x<p.length;x++)if(p[x]===" ")M++;else if(p[x]==="\t")M+=s;else break;let w=(r+Number(y.continuation))*s;if(M!==w&&!R.startsWith("#"))o.push({filePath:f.filePath,line:l+1,column:1,ruleId:"shell/indent",message:`Expected ${w} spaces of indentation, found ${M}`,severity:"warning"});if(y.closesHeader||!y.continuation&&E(R,m))r++}return o},fix(u,f){let o=u.split(/\r?\n/),c=f.config.format.indent||2,s=f.config.format.indentStyle==="tabs",r=[],e=0,t=new g,d=!1,m="",h=!1,l=0;for(let p=0;p<o.length;p++){let b=o[p];if(/^\s*$/.test(b)){r.push("");continue}if(d){if(r.push(b),b.trim()===m)d=!1;continue}let R=b.match(/<<-?\s*['"]?(\w+)['"]?/);if(R)d=!0,m=R[1];let y=b.replace(/^\s+/,"").trimEnd(),M=t.read(y);if(p===0&&y.startsWith("#!")){r.push(y);continue}if(/^case\b/.test(y)&&/\bin\s*$/.test(y))l++,h=!0;if(/^esac\b/.test(y)){if(l=Math.max(0,l-1),l===0)h=!1}if(!M.continuation&&q(y))e=Math.max(0,e-1);let w=e+Number(M.continuation),x=s?"\t".repeat(w):" ".repeat(w*c);if(r.push(x+y),M.closesHeader||!M.continuation&&E(y,h))e++}return r.join(`
5
+ `)}};var A={meta:{docs:"Enforce spacing around shell keywords (if, then, do, else, fi, etc.)",recommended:!0},check(u,f){let o=[],c=u.split(/\r?\n/),s=!1,r="";for(let e=0;e<c.length;e++){let t=c[e];if(s){if(t.trim()===r)s=!1;continue}let d=i(t);if(d)s=!0,r=d;if(t.replace(/^\s+/,"").startsWith("#"))continue;let h=a(t),l=h.match(/;(?![;\s$])\S/);if(l)o.push({filePath:f.filePath,line:e+1,column:(l.index||0)+1,ruleId:"shell/keyword-spacing",message:"Missing space after semicolon",severity:"warning"});let p=h.match(/\w(then|do|else|elif|fi|done|esac)\b/);if(p&&!/[a-z]/.test(h[p.index])){let b=p[1],R=h[p.index];if(R!==" "&&R!=="\t"&&R!==";")o.push({filePath:f.filePath,line:e+1,column:(p.index||0)+2,ruleId:"shell/keyword-spacing",message:`Missing space before keyword '${b}'`,severity:"warning"})}}return o}};var U={meta:{docs:"Disallow unnecessary trailing semicolons",recommended:!0},check(u,f){let o=[],c=u.split(/\r?\n/),s=!1,r="";for(let e=0;e<c.length;e++){let t=c[e];if(s){if(t.trim()===r)s=!1;continue}let d=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(d)s=!0,r=d[1];let m=t.replace(/^\s+/,"").trimEnd();if(m.startsWith("#"))continue;if(/;;\s*$/.test(m))continue;if(/\bfor\b/.test(m)||/\bwhile\b/.test(m)||/\buntil\b/.test(m))continue;if(/;\s*(?:then|do|else|elif|fi|done|esac)\s*$/.test(m))continue;if(/;\s*$/.test(m)){let h=t.lastIndexOf(";");o.push({filePath:f.filePath,line:e+1,column:h+1,ruleId:"shell/no-trailing-semicolons",message:"Unnecessary trailing semicolon",severity:"warning"})}}return o},fix(u){let f=u.split(/\r?\n/),o=[],c=!1,s="";for(let r of f){if(c){if(o.push(r),r.trim()===s)c=!1;continue}let e=r.match(/<<-?\s*['"]?(\w+)['"]?/);if(e)c=!0,s=e[1];let t=r.replace(/^\s+/,"").trimEnd();if(t.startsWith("#")||/;;\s*$/.test(t)||/\bfor\b/.test(t)||/\bwhile\b/.test(t)||/\buntil\b/.test(t)||/;\s*(?:then|do|else|elif|fi|done|esac)\s*$/.test(t)){o.push(r);continue}o.push(r.replace(/;\s*$/,""))}return o.join(`
6
+ `)}};var j={meta:{docs:"Disallow trailing whitespace",recommended:!0},check(u,f){let o=[],c=u.split(/\r?\n/),s=!1,r="";for(let e=0;e<c.length;e++){let t=c[e];if(s){if(t.trim()===r)s=!1;continue}let d=i(t);if(d)s=!0,r=d;if(/[ \t]+$/.test(t)){let m=t.match(/[ \t]+$/);o.push({filePath:f.filePath,line:e+1,column:m.index+1,ruleId:"shell/no-trailing-whitespace",message:"Trailing whitespace",severity:"error"})}}return o},fix(u){let f=u.split(/\r?\n/),o=!1,c="";return f.map((r)=>{if(o){if(r.trim()===c)o=!1;return r}let e=i(r);if(e)o=!0,c=e;return r.replace(/[ \t]+$/,"")}).join(`
7
+ `)}};var B={meta:{docs:"Enforce spaces inside [ ] and [[ ]] test expressions",recommended:!0},check(u,f){let o=[],c=u.split(/\r?\n/),s=!1,r="";for(let e=0;e<c.length;e++){let t=c[e];if(s){if(t.trim()===r)s=!1;continue}let d=i(t);if(d)s=!0,r=d;if(t.replace(/^\s+/,"").startsWith("#"))continue;let h=a(t);for(let l of K(h,e+1,f.filePath))o.push(l)}return o},fix(u){let f=u.split(/\r?\n/),o=[],c=!1,s="";for(let r of f){if(c){if(r.trim()===s)c=!1;o.push(r);continue}let e=i(r);if(e){c=!0,s=e,o.push(r);continue}if(r.replace(/^\s+/,"").startsWith("#")){o.push(r);continue}o.push(J(r))}return o.join(`
8
+ `)}};function K(u,f,o){let c=[],s=/\[\[(?!\s|\]|$)/g;for(let e of u.matchAll(s))c.push({filePath:o,line:f,column:(e.index??0)+1,ruleId:"shell/operator-spacing",message:"Missing space after [[",severity:"warning"});let r=/(?<!\s|\[)\]\]/g;for(let e of u.matchAll(r))c.push({filePath:o,line:f,column:(e.index??0)+1,ruleId:"shell/operator-spacing",message:"Missing space before ]]",severity:"warning"});for(let e=0;e<u.length;e++){if(u[e]!=="[")continue;if(u[e+1]==="[")continue;if(e>0&&u[e-1]==="[")continue;if(!z(u,e))continue;let t=u[e+1];if(t!==void 0&&t!==" "&&t!=="\t")c.push({filePath:o,line:f,column:e+1,ruleId:"shell/operator-spacing",message:"Missing space after [",severity:"warning"})}for(let e=0;e<u.length;e++){if(u[e]!=="]")continue;if(u[e+1]==="]")continue;if(e>0&&u[e-1]==="]")continue;if(!L(u,e))continue;let t=u[e-1];if(t!==void 0&&t!==" "&&t!=="\t")c.push({filePath:o,line:f,column:e+1,ruleId:"shell/operator-spacing",message:"Missing space before ]",severity:"warning"})}return c}function J(u){let f=a(u),o=[];for(let s of f.matchAll(/\[\[(?!\s|\]|$)/g)){let r=(s.index??0)+2;o.push({pos:r,text:" "})}for(let s of f.matchAll(/(?<!\s|\[)\]\]/g)){let r=s.index??0;o.push({pos:r,text:" "})}for(let s=0;s<f.length;s++){if(f[s]!=="[")continue;if(f[s+1]==="[")continue;if(s>0&&f[s-1]==="[")continue;if(!z(f,s))continue;let r=f[s+1];if(r!==void 0&&r!==" "&&r!=="\t")o.push({pos:s+1,text:" "})}for(let s=0;s<f.length;s++){if(f[s]!=="]")continue;if(f[s+1]==="]")continue;if(s>0&&f[s-1]==="]")continue;if(!L(f,s))continue;let r=f[s-1];if(r!==void 0&&r!==" "&&r!=="\t")o.push({pos:s,text:" "})}if(o.length===0)return u;o.sort((s,r)=>r.pos-s.pos);let c=u;for(let{pos:s,text:r}of o)c=`${c.slice(0,s)}${r}${c.slice(s)}`;return c}function z(u,f){let o=f-1;while(o>=0&&(u[o]===" "||u[o]==="\t"))o--;if(o<0)return!0;let c=u[o];if(c===";"||c==="|"||c==="&"||c==="!"||c==="(")return!0;let s=u.slice(0,o+1);if(/(?:^|\s)(?:if|while|until|elif|then|else|do)\s*$/.test(s))return!0;return!1}function L(u,f){let o=u[f+1];if(o===void 0)return!0;return o===" "||o==="\t"||o===";"||o==="|"||o==="&"||o===")"}var Y=/^#!\s*(?:\/usr\/bin\/env\s+(?:ba|z|k|da)?sh|\/bin\/(?:ba|z|k|da)?sh|\/usr\/bin\/(?:ba|z|k|da)?sh)\b/,Q={meta:{docs:"Ensure shell scripts have a proper shebang line",recommended:!0},check(u,f){let o=[],c=u.split(/\r?\n/);if(c.length===0)return o;let s=c[0];if(c.every((r)=>r.trim()===""))return o;if(!s.startsWith("#!"))return o.push({filePath:f.filePath,line:1,column:1,ruleId:"shell/shebang",message:"Missing shebang line \u2014 shell scripts should start with #!/usr/bin/env bash (or similar)",severity:"warning",help:"Add #!/usr/bin/env bash as the first line"}),o;if(!Y.test(s))o.push({filePath:f.filePath,line:1,column:1,ruleId:"shell/shebang",message:`Invalid shebang: ${s} \u2014 use #!/usr/bin/env bash or #!/bin/sh`,severity:"warning",help:"Use #!/usr/bin/env bash for portability or #!/bin/sh for POSIX scripts"});return o}};var V={meta:{docs:"Enforce consistent case statement terminator placement",recommended:!0},check(u,f){let o=[],c=u.split(/\r?\n/),s=!1,r="",e=[];for(let t of c){if(s){if(t.trim()===r)s=!1;e.push("");continue}let d=i(t);if(d)s=!0,r=d;if(t.replace(/^\s+/,"").startsWith("#")){e.push("");continue}e.push(a(t))}for(let t=0;t<e.length;t++){if(!/\bcase\b[\s\S]*\bin\s*$/.test(e[t].trimEnd()))continue;let d=1,m=-1;for(let b=t+1;b<e.length;b++){let R=e[b].trimEnd();if(/^\s*esac\b/.test(R)){if(d--,d===0){m=b;break}continue}if(/\bcase\b[\s\S]*\bin\s*$/.test(R))d++}if(m===-1)continue;let h=0,l=!1,p=!1;for(let b=t+1;b<m;b++){let R=e[b],y=R.trim();if(y==="")continue;if(h===0){let M=ee(R);if(M!==-1){if(l&&p)o.push({filePath:f.filePath,line:b+1,column:1,ruleId:"shell/consistent-case-terminators",message:"Missing ;; terminator for previous case branch",severity:"warning",help:"Add ;; at the end of the case branch before the next pattern"});l=!0,p=!0;let w=R.slice(M+1).trimEnd();if(/;;\s*$/.test(w))l=!1;continue}}if(h+=te(R),h<0)h=0;if(l&&h===0&&/;;\s*$/.test(y))l=!1}}return o}};function ee(u){let f=u.replace(/^\s+/,"");if(f==="")return-1;if(/^(?:for|while|until|if|case|do|then|else|elif|fi|done|esac)\b/.test(f))return-1;let o=u.length-f.length,c=0;if(f[c]==="(")c++;let s=0;while(c<f.length){let r=f[c];if(r==="(")s++;else if(r===")"){if(s===0)return o+c;s--}else if(r===";"||r==="&"||r==="<"||r===">"||r==="=")return-1;c++}return-1}function te(u){let f=u.trim();if(f==="")return 0;let o=f.split(/[\s;]+/),c=0;for(let s of o)if(s==="if"||s==="for"||s==="while"||s==="until")c++;else if(s==="fi"||s==="done")c--;return c}var _={meta:{docs:"Recommend <<- for heredocs inside indented blocks"},check(u,f){let o=[],c=u.split(/\r?\n/);for(let s=0;s<c.length;s++){let r=c[s];if(r.replace(/^\s+/,"").startsWith("#"))continue;if(!r.match(/^\s+/))continue;let m=a(r).match(/(?<!<)<<(?![<-])/);if(!m||m.index===void 0)continue;let l=r.slice(m.index+2).match(/^\s*(['"]?)(\w+)\1\s*$/);if(l){let p=l[2];o.push({filePath:f.filePath,line:s+1,column:m.index+1,ruleId:"shell/heredoc-indent",message:`Use <<- instead of << for indented heredoc (delimiter '${p}' must be at column 0 otherwise)`,severity:"warning",help:"Use <<- to strip leading tabs from heredoc content, allowing proper indentation"})}}return o}};var Z={meta:{docs:"Detect incorrect redirect ordering (2>&1 before > file)",recommended:!0},check(u,f){let o=[],c=u.split(/\r?\n/),s=!1,r="";for(let e=0;e<c.length;e++){let t=c[e];if(s){if(t.trim()===r)s=!1;continue}let d=i(t);if(d)s=!0,r=d;if(t.replace(/^\s+/,"").startsWith("#"))continue;let h=a(t);if(h.match(/2>&1\s+>(?!&)\s*\S/)){let p=h.indexOf("2>&1");o.push({filePath:f.filePath,line:e+1,column:p+1,ruleId:"shell/no-broken-redirect",message:"Broken redirect: 2>&1 before > file \u2014 stderr goes to terminal, not the file",severity:"error",help:"Swap the order: cmd > file 2>&1 (or use &> file in bash)"})}}return o}};var F={meta:{docs:"Prefer [[ ]] over [ ] for test expressions in bash/zsh",recommended:!0},check(u,f){let o=[],c=u.split(/\r?\n/)[0]||"",s=/bash|zsh/.test(c);if(/^#!.*\bsh\b/.test(c)&&!s||!s)return o;let e=u.split(/\r?\n/),t=!1,d="";for(let m=0;m<e.length;m++){let h=e[m];if(t){if(h.trim()===d)t=!1;continue}let l=h.match(/<<-?\s*['"]?(\w+)['"]?/);if(l)t=!0,d=l[1];if(h.replace(/^\s+/,"").startsWith("#"))continue;if(h.match(/(?:^|\s|;)\[\s(?!\[)/)){if(/(?<!\])\](?!\])/.test(h)){let R=h.indexOf("[");o.push({filePath:f.filePath,line:m+1,column:R+1,ruleId:"shell/prefer-double-brackets",message:"Use [[ ]] instead of [ ] for test expressions in bash/zsh",severity:"warning",help:"[[ ]] prevents word splitting and supports && || regex; [ ] is only needed for POSIX sh"})}}}return o},fix(u){let f=u.split(/\r?\n/)[0]||"";if(!/bash|zsh/.test(f))return u;let c=u.split(/\r?\n/),s=[];for(let r of c){let e=r;e=e.replace(/(?:^|(?<=\s|;))\[(\s(?!\[).*?(?<!\]))\](?!\])/g,"[[$1]]"),s.push(e)}return s.join(`
9
+ `)}};var X={meta:{docs:"Prefer printf over echo -e and echo -n",recommended:!0},check(u,f){let o=[],c=u.split(/\r?\n/),s=!1,r="";for(let e=0;e<c.length;e++){let t=c[e];if(s){if(t.trim()===r)s=!1;continue}let d=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(d)s=!0,r=d[1];if(t.replace(/^\s+/,"").startsWith("#"))continue;let h=t.match(/\becho\s+-[en]+\b/);if(h){let l=t.indexOf("echo"),p=h[0].replace("echo ","");o.push({filePath:f.filePath,line:e+1,column:l+1,ruleId:"shell/prefer-printf",message:`Use printf instead of echo ${p} \u2014 echo behavior varies across platforms`,severity:"warning",help:'printf is portable: printf "format\\n" args... (use \\n for newline)'})}}return o}};var N={meta:{docs:"Recommend set -euo pipefail for safer script execution"},check(u,f){let o=[],c=u.split(/\r?\n/),s=!1,r=!1,e=!1,t=-1,d=!1;for(let h=0;h<c.length;h++){let l=c[h].replace(/^\s+/,"");if(h===0&&l.startsWith("#!")){t=h;continue}if(l.startsWith("#"))continue;if(l==="")continue;if(d=!0,/\bset\s+-\w*e/.test(l))s=!0;if(/\bset\s+-\w*u/.test(l))r=!0;if(/\bset\s+.*-o\s+pipefail/.test(l))e=!0;if(/\bset\s+-euo\s+pipefail/.test(l))s=!0,r=!0,e=!0}if(!d)return o;let m=[];if(!s)m.push("-e");if(!r)m.push("-u");if(!e)m.push("-o pipefail");if(m.length>0)o.push({filePath:f.filePath,line:t>=0?t+2:1,column:1,ruleId:"shell/set-options",message:`Missing shell safety options: set ${m.join(" ")}`,severity:"warning",help:"Add `set -euo pipefail` near the top of the script for safer execution"});return o}};var Ye={name:"shell",rules:{"command-substitution":n(v),"quote-variables":n(H),"no-cd-without-check":n(P),"no-eval":n(S),"no-useless-cat":n(T),"no-ls-parsing":n(I),"no-variable-in-single-quotes":n(W),"no-exit-in-subshell":n(D),shebang:n(Q),indent:n(O),"function-style":n(C),"operator-spacing":n(B),"keyword-spacing":n(A),"no-trailing-semicolons":n(U),"no-trailing-whitespace":n(j),"prefer-double-brackets":n(F),"set-options":n(N),"prefer-printf":n(X),"consistent-case-terminators":n(V),"no-broken-redirect":n(Z),"heredoc-indent":n(_)}};export{Ye as shellPlugin};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{d,c}from"./chunk-1jtr81zg.js";import{readFileSync as o,statSync as y,writeFileSync as O}from"fs";import{isAbsolute as p,resolve as x}from"path";async function N(r,t){let a=t.mode||"auto";if(a==="format"&&r.length===1&&!/[*?[\]{}()!]/.test(r[0]))try{let n=r[0],i=p(n)?n:x(process.cwd(),n);if(y(i).isFile()){let s=await c(t.config),f=o(i,"utf8"),m=d(f,s,i);if(t.check&&m!==f)return 1;if(t.write&&m!==f)O(i,m,"utf8");return 0}}catch{}let{runLint:e}=await import("./chunk-t776wefr.js");if(a==="lint")return e(r,t);if(a==="format"){let n={...t,fix:!0,dryRun:!!t.check,ext:t.ext,_formatOnly:!0};return e(r,n)}if(!(t.fix===!0||t.write===!0||t.check===!0))return e(r,t);let u={...t,fix:!0,dryRun:!!t.check,ext:t.ext};return e(r,u)}
3
+ export{N};
@@ -0,0 +1,21 @@
1
+ import type { LintIssue, LintOptions, PickierConfig } from './types';
2
+ export declare function hashContent(content: string): string;
3
+ /** Whether this run may use the cache: asked for, and writing nothing. */
4
+ export declare function cacheApplies(cfg: PickierConfig, options: LintOptions): boolean;
5
+ export declare function openLintCache(cfg: PickierConfig, options: LintOptions, location?: string): LintCache;
6
+ /**
7
+ * Lint results kept between runs (`--cache`, or `lint.cache` in the config).
8
+ *
9
+ * An entry is a file's issues together with a hash of the content they were
10
+ * computed from, so an edited file is linted again. The cache as a whole is
11
+ * only reused by a run with the same Pickier version, the same resolved
12
+ * config - rule functions included, so a changed plugin invalidates it - and
13
+ * the same run options; anything else starts from empty. Runs that write
14
+ * files (`--fix`, `--write`) neither read nor write it.
15
+ */
16
+ export declare const DEFAULT_CACHE_LOCATION: '.pickiercache';
17
+ export declare interface LintCache {
18
+ get: (file: string, content: string) => LintIssue[] | undefined
19
+ set: (file: string, content: string, issues: LintIssue[]) => void
20
+ save: () => void
21
+ }
package/dist/src/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{s,S,f,k,y,p,b,i,D,n,R,o,v,g,a,j,h,T,L,A,O,_,N,e,m,u,d,w,l,c,B,I}from"../chunk-q47v401h.js";import{M,C,x,E,P}from"../chunk-s0n5r5hb.js";export{R as ALWAYS_IGNORES,n as ENV,b as MAX_FIXER_PASSES,o as UNIVERSAL_IGNORES,O as blue,N as bold,h as colorize,e as colors,S as config,c as createIgnoreMatcher,D as createLimiter,s as defaultConfig,k as detectQuoteIssues,d as expandPatterns,x as fixText,f as formatCode,p as formatImports,v as getRuleSetting,i as glob,_ as gray,T as green,y as hasIndentIssue,w as isCodeFile,j as isRuleOff,C as lintText,u as loadConfigFromPath,m as mergeConfig,g as normalizeRuleSeverity,L as red,a as resolveRuleSeverity,I as run,M as runFormat,P as runLint,E as runLintProgrammatic,B as shouldIgnorePath,l as withAlwaysIgnores,A as yellow};
2
+ import{l,W,d,M,E,R,P,u,Z,r,L,f,T,v,o,X,y,V,K,z,q,G,H,t,p,c,b,I,m,h,Q}from"../chunk-1jtr81zg.js";import{U,F,S,D,B}from"../chunk-mqjmcycy.js";import"../chunk-pvptb0h1.js";import{N}from"../chunk-xjt8q744.js";export{L as ALWAYS_IGNORES,r as ENV,P as MAX_FIXER_PASSES,f as UNIVERSAL_IGNORES,q as blue,H as bold,y as colorize,t as colors,W as config,h as createIgnoreMatcher,Z as createLimiter,l as defaultConfig,M as detectQuoteIssues,b as expandPatterns,S as fixText,d as formatCode,R as formatImports,T as getRuleSetting,u as glob,G as gray,V as green,E as hasIndentIssue,I as isCodeFile,X as isRuleOff,F as lintText,c as loadConfigFromPath,p as mergeConfig,v as normalizeRuleSeverity,K as red,o as resolveRuleSeverity,N as run,U as runFormat,B as runLint,D as runLintProgrammatic,Q as shouldIgnorePath,m as withAlwaysIgnores,z as yellow};
@@ -12,6 +12,8 @@ export declare function lexSource(text: string): LexResult;
12
12
  * blanked.
13
13
  */
14
14
  export declare function maskSource(text: string, options?: MaskOptions, lexed?: LexResult): string;
15
+ /** Forget the cached lex and masks; the linter calls this as each file starts. */
16
+ export declare function resetLexCache(): void;
15
17
  /** Every comment's contents blanked; everything else as written. */
16
18
  export declare function maskComments(text: string): string;
17
19
  /** Only code left: comments, strings, template bodies and regex patterns blanked. */
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{c}from"../chunk-1jtr81zg.js";import{x,k}from"../chunk-mqjmcycy.js";import"../chunk-pvptb0h1.js";var s,i=null;self.onmessage=async(n)=>{let t=n.data;if(t.type==="init"){s=t.options,i=c(s.config);return}try{let e=await i,o=[];for(let[r,a]of t.batch)o.push([r,await k(a,e,s)]);await x(),postMessage({type:"done",results:o})}catch(e){await x(),postMessage({type:"error",message:e?.message||String(e)})}};
@@ -12,10 +12,26 @@ export declare function lintText(text: string, cfg: PickierConfig, filePath?: st
12
12
  export declare function fixText(text: string, cfg: PickierConfig, filePath?: string): string;
13
13
  // Programmatic batch lint returning structured result, with optional cancellation
14
14
  export declare function runLintProgrammatic(globs: string[], options: LintOptions, signal?: AbortSignal): Promise<{ errors: number, warnings: number, issues: LintIssue[] }>;
15
- export declare function applyPlugins(filePath: string, content: string, cfg: PickierConfig): Promise<Array<any>> /* PluginLintIssue[] */;
15
+ /**
16
+ * The plugin rules a run with `cfg` checks, in the order it checks them, for
17
+ * the native engine (native.ts) to reproduce.
18
+ */
19
+ export declare function plannedCheckRules(cfg: PickierConfig): Array<{ id: string, plugin: string, severity?: 'error' | 'warning', options?: unknown }>;
20
+ /**
21
+ * Run the planned plugin rules on one file. With `skip`, the rules with those
22
+ * plan ids are left out and each issue carries `pos`, its rule's position in
23
+ * the plan.
24
+ */
25
+ export declare function applyPlugins(filePath: string, content: string, cfg: PickierConfig, skip?: ReadonlySet<string>): Promise<Array<any>> /* PluginLintIssue[] */;
16
26
  // Optimized version that accepts pre-computed directive and comment data
17
27
  export declare function scanContentOptimized(filePath: string, content: string, cfg: PickierConfig, suppress: DisableDirectives, commentLines: Set<number>): LintIssue[];
18
28
  export declare function scanContent(filePath: string, content: string, cfg: PickierConfig): LintIssue[];
29
+ /**
30
+ * Lint one file the way a CLI run does: format-only, or scan + plugin rules,
31
+ * then fixes when asked for. Shared by the main thread and the lint workers
32
+ * (lint-worker.ts) so both produce the same issues for the same file.
33
+ */
34
+ export declare function lintFileForRun(file: string, cfg: PickierConfig, options: LintOptions): Promise<LintIssue[]>;
19
35
  export declare function runLint(globs: string[], options: LintOptions): Promise<number>;
20
36
  declare interface DisableDirectives {
21
37
  nextLine: SuppressMap
@@ -0,0 +1,20 @@
1
+ /**
2
+ * A logger that imports @stacksjs/clarity the first time it is used.
3
+ *
4
+ * Importing clarity costs ~10 ms - it pulls in node:crypto, zlib and Node
5
+ * streams and loads its own config - and an ordinary lint run logs nothing
6
+ * through it. Messages logged before it has loaded are queued in order and
7
+ * written as soon as it is; callers that exit right after logging must await
8
+ * flushLogs() first.
9
+ */
10
+ export declare function createLazyLogger(name: string): LazyLogger;
11
+ /** Resolves once every message logged so far has been handed to clarity. */
12
+ export declare function flushLogs(): Promise<void>;
13
+ export declare interface LazyLogger {
14
+ debug: (...args: unknown[]) => void
15
+ info: (...args: unknown[]) => void
16
+ warn: (...args: unknown[]) => void
17
+ error: (...args: unknown[]) => void
18
+ ready: () => Promise<void>
19
+ }
20
+ declare type Level = 'debug' | 'info' | 'warn' | 'error';
@@ -0,0 +1,64 @@
1
+ import type { LintIssue, LintOptions, PickierConfig } from './types';
2
+ /** What the run's settings ask of a code file, or every rule involved. */
3
+ export declare function nativeRequest(cfg: PickierConfig): { request: NativeRequest, ruleIds: string[] };
4
+ /** Files the native engine lints: what the TypeScript linter treats as code. */
5
+ export declare function isNativeFile(path: string): boolean;
6
+ /**
7
+ * How the native engine takes part in a run, or null when it cannot: no
8
+ * binary, a run that fixes or formats, PICKIER_NATIVE=0, a custom plugin
9
+ * under a built-in plugin's name, or no rule it runs.
10
+ */
11
+ export declare function nativePlan(cfg: PickierConfig, options: LintOptions): NativePlan | null;
12
+ /**
13
+ * The native binary: $PICKIER_NATIVE_BINARY, the one shipped in this package
14
+ * for this platform (dist/native/<platform>-<arch>, built by
15
+ * scripts/build-native.ts), or a development build in packages/zig. Null when
16
+ * there is none.
17
+ */
18
+ export declare function nativeBinary(): string | null;
19
+ /**
20
+ * Lint `files` natively: one entry per file, null for a file the engine left
21
+ * to the TypeScript linter. Null overall when the engine is unavailable or
22
+ * declined the request.
23
+ *
24
+ * With `positions`, each issue also carries `pos`: its rule's position in the
25
+ * run's plan (-1 for a built-in check), for mergeIssues.
26
+ */
27
+ export declare function lintNative(files: string[], request: NativeRequest, binary: string, threads?: number, positions?: number[]): Array<LintIssue[] | null> | null;
28
+ /** lintNative, leaving this thread free while the engine runs. */
29
+ export declare function lintNativeAsync(files: string[], request: NativeRequest, binary: string, positions?: number[]): Promise<Array<LintIssue[] | null> | null>;
30
+ /**
31
+ * One file's issues from the engine and from the TypeScript linter's run of
32
+ * the remaining rules, as a TypeScript-only run reports them: built-in checks
33
+ * first, then each rule's issues in plan order, the first of any with the same
34
+ * line, column and rule kept.
35
+ */
36
+ export declare function mergeIssues(native: LintIssue[], typescript: LintIssue[]): LintIssue[];
37
+ /**
38
+ * The native lint engine: `pickier-zig lint-batch` (packages/zig), which
39
+ * lints TS/JS files on every core and reports exactly what the TypeScript
40
+ * linter reports for them.
41
+ *
42
+ * A run's code files go to it whenever it can take part: it runs the built-in
43
+ * checks and every rule whose native port is verified identical (NATIVE_RULES,
44
+ * checked by packages/zig/scripts/parity.ts), and the TypeScript linter runs
45
+ * whatever rules are left on the same files at the same time; the two sets of
46
+ * issues are merged in the order a TypeScript-only run reports them. --fix,
47
+ * formatting and files the engine declines stay on the TypeScript path.
48
+ */
49
+ /** Built-in checks and plugin rules whose native output matches TypeScript. */
50
+ export declare const NATIVE_RULES: ReadonlySet<string>;
51
+ export declare interface NativeRequest {
52
+ format: { quotes: 'single' | 'double', indent: number, indentStyle: 'spaces' | 'tabs' }
53
+ builtins: Record<string, 'error' | 'warning' | null>
54
+ rules: Array<{ id: string, severity: 'error' | 'warning' | null, options: unknown }>
55
+ }
56
+ export declare interface NativePlan {
57
+ request: NativeRequest
58
+ binary: string
59
+ positions: number[]
60
+ nativeRules: string[]
61
+ hybrid: boolean
62
+ }
63
+ /** An issue with its rule's position in the run's plan (-1: a built-in check). */
64
+ export type PlannedIssue = LintIssue & { pos: number }
@@ -0,0 +1,17 @@
1
+ import type { LintIssue, LintOptions } from './types';
2
+ /**
3
+ * How many worker threads to lint `fileCount` files with; 0 or 1 means the
4
+ * main thread alone. PICKIER_WORKERS overrides the choice.
5
+ */
6
+ export declare function workerThreadsFor(fileCount: number): number;
7
+ /**
8
+ * Lint `files` across `count` worker threads, each running the same
9
+ * `lintFileForRun` the main thread does with the same config, and return the
10
+ * issues in file order - exactly what linting them one by one returns.
11
+ *
12
+ * Files are handed out a few at a time as workers free up. A file a worker
13
+ * could not finish (it failed to start, or crashed) is linted on this thread
14
+ * with `lintHere`, as is everything when no worker can be started. An error
15
+ * thrown while linting a file is rethrown here, as it would be on one thread.
16
+ */
17
+ export declare function lintInWorkers(files: string[], options: LintOptions, count: number, lintHere: (file: string) => Promise<LintIssue[]>, entry?: string | null): Promise<LintIssue[][]>;
@@ -0,0 +1,10 @@
1
+ import { LAZY_PLUGIN_RULES } from './manifest';
2
+ import type { PickierPlugin } from '../types';
3
+ /**
4
+ * The core plugins, in the same order as `getAllPlugins`, with the non-code
5
+ * plugins replaced by stand-ins that load on first use. A rule's plan, its
6
+ * options and which duplicate rule name wins are all decided from names, so
7
+ * they come out the same; only the loading moves to when a rule runs.
8
+ */
9
+ export declare function getLazyPlugins(): PickierPlugin[];
10
+ declare type LazyName = keyof typeof LAZY_PLUGIN_RULES;
@@ -0,0 +1,123 @@
1
+ /**
2
+ * The rules of the plugins that only apply to non-code files, by plugin, in
3
+ * the order each plugin declares them. `true` marks a rule with a fixer.
4
+ *
5
+ * The linter plans from this list and loads a plugin the first time one of
6
+ * its rules runs (see lazy.ts), so linting TypeScript never loads the
7
+ * Markdown, shell or package.json rules. Kept in step with the plugins by
8
+ * test/plugin/lazy-plugins.test.ts.
9
+ * @defaultValue
10
+ * ```ts
11
+ * {
12
+ * markdown: {
13
+ * 'heading-increment': true,
14
+ * 'heading-style': true,
15
+ * 'no-missing-space-atx': true,
16
+ * 'no-multiple-space-atx': true,
17
+ * 'no-missing-space-closed-atx': false,
18
+ * 'no-multiple-space-closed-atx': false,
19
+ * 'blanks-around-headings': true,
20
+ * 'heading-start-left': true,
21
+ * 'no-duplicate-heading': false,
22
+ * 'single-title': true,
23
+ * 'no-trailing-punctuation': true,
24
+ * 'ul-style': true,
25
+ * 'list-indent': false,
26
+ * 'ul-indent': false,
27
+ * 'ol-prefix': true,
28
+ * 'list-marker-space': true,
29
+ * 'blanks-around-lists': true,
30
+ * 'no-trailing-spaces': true,
31
+ * 'no-hard-tabs': true,
32
+ * 'no-multiple-blanks': true,
33
+ * 'no-multiple-space-blockquote': true,
34
+ * 'no-blanks-blockquote': true,
35
+ * 'blanks-around-fences': true,
36
+ * 'single-trailing-newline': true,
37
+ * 'blanks-around-tables': true,
38
+ * 'no-reversed-links': false,
39
+ * 'no-bare-urls': true,
40
+ * 'no-space-in-links': false,
41
+ * 'no-empty-links': false,
42
+ * 'link-fragments': false,
43
+ * 'reference-links-images': false,
44
+ * 'link-image-reference-definitions': true,
45
+ * 'link-image-style': true,
46
+ * 'descriptive-link-text': false,
47
+ * 'line-length': false,
48
+ * 'commands-show-output': false,
49
+ * 'fenced-code-language': false,
50
+ * 'code-block-style': false,
51
+ * 'code-fence-style': true,
52
+ * 'no-emphasis-as-heading': true,
53
+ * 'no-space-in-emphasis': true,
54
+ * 'no-space-in-code': true,
55
+ * 'emphasis-style': true,
56
+ * 'strong-style': true,
57
+ * 'no-inline-html': false,
58
+ * 'hr-style': false,
59
+ * 'first-line-heading': false,
60
+ * 'required-headings': false,
61
+ * 'proper-names': false,
62
+ * 'no-alt-text': false,
63
+ * 'table-pipe-style': false,
64
+ * 'table-column-count': false,
65
+ * 'table-column-style': false
66
+ * },
67
+ * shell: {
68
+ * 'command-substitution': true,
69
+ * 'quote-variables': false,
70
+ * 'no-cd-without-check': false,
71
+ * 'no-eval': false,
72
+ * 'no-useless-cat': false,
73
+ * 'no-ls-parsing': false,
74
+ * 'no-variable-in-single-quotes': false,
75
+ * 'no-exit-in-subshell': false,
76
+ * 'shebang': false,
77
+ * 'indent': true,
78
+ * 'function-style': true,
79
+ * 'operator-spacing': true,
80
+ * 'keyword-spacing': false,
81
+ * 'no-trailing-semicolons': true,
82
+ * 'no-trailing-whitespace': true,
83
+ * 'prefer-double-brackets': true,
84
+ * 'set-options': false,
85
+ * 'prefer-printf': false,
86
+ * 'consistent-case-terminators': false,
87
+ * 'no-broken-redirect': false,
88
+ * 'heredoc-indent': false
89
+ * },
90
+ * spell: { 'check': false, 'check-comments': false, 'check-markdown': false },
91
+ * lockfile: {
92
+ * 'validate-host': false,
93
+ * 'validate-https': false,
94
+ * 'validate-integrity': false,
95
+ * 'validate-package-names': false,
96
+ * 'validate-scheme': false
97
+ * },
98
+ * publint: {
99
+ * 'use-type': false,
100
+ * 'local-dependency': false,
101
+ * 'deprecated-field-jsnext': false,
102
+ * 'has-module-but-no-exports': false,
103
+ * 'field-invalid-value-type': false,
104
+ * 'exports-types-should-be-first': false,
105
+ * 'exports-default-should-be-last': false,
106
+ * 'exports-module-should-precede-require': false,
107
+ * 'exports-value-invalid': false,
108
+ * 'exports-missing-root-entrypoint': false,
109
+ * 'exports-fallback-array-use': false,
110
+ * 'imports-key-invalid': false,
111
+ * 'imports-value-invalid': false,
112
+ * 'imports-default-should-be-last': false,
113
+ * 'imports-module-should-precede-require': false,
114
+ * 'file-does-not-exist': false,
115
+ * 'file-invalid-format': false,
116
+ * 'module-should-be-esm': false,
117
+ * 'bin-file-not-executable': false,
118
+ * 'exports-module-should-be-esm': false
119
+ * }
120
+ * }
121
+ * ```
122
+ */
123
+ export declare const LAZY_PLUGIN_RULES: Record<'markdown' | 'shell' | 'spell' | 'lockfile' | 'publint', Record<string, boolean>>;
@@ -1,4 +1,10 @@
1
1
  import type { RuleModule } from '../types';
2
2
  export declare function codeOnly(rule: RuleModule): RuleModule;
3
+ /**
4
+ * A rule for any text file except Markdown, where spacing is syntax: two
5
+ * trailing spaces are a hard line break, and runs of spaces align code
6
+ * blocks and tables. The markdown plugin has its own rules for these.
7
+ */
8
+ export declare function notMarkdown(rule: RuleModule): RuleModule;
3
9
  export declare function shellOnly(rule: RuleModule): RuleModule;
4
10
  export declare function packageJsonOnly(rule: RuleModule): RuleModule;