pickier 0.1.69 → 0.1.71

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 (36) hide show
  1. package/dist/bin/cli.js +1 -1
  2. package/dist/{chunk-1c4363f9.js → chunk-0b2yx624.js} +2 -2
  3. package/dist/chunk-1jtr81zg.js +25 -0
  4. package/dist/chunk-3h389bm4.js +2 -0
  5. package/dist/{chunk-0wjnsb7e.js → chunk-5c026tb4.js} +1 -1
  6. package/dist/chunk-6vptsmta.js +128 -0
  7. package/dist/{chunk-jqsghmew.js → chunk-8m82hwdv.js} +2 -2
  8. package/dist/chunk-99jrtc0c.js +3 -0
  9. package/dist/chunk-c82emw32.js +3 -0
  10. package/dist/{chunk-861zc8zq.js → chunk-gpfjzx90.js} +1 -1
  11. package/dist/chunk-jerw13hn.js +2 -0
  12. package/dist/chunk-m9ym248d.js +2 -0
  13. package/dist/{chunk-zp6n036m.js → chunk-qjzzx1m2.js} +18 -18
  14. package/dist/chunk-vrbz87a8.js +3 -0
  15. package/dist/chunk-wx92kdf9.js +9 -0
  16. package/dist/chunk-xgm5reee.js +2 -0
  17. package/dist/native/darwin-arm64/pickier-native +0 -0
  18. package/dist/native/darwin-x64/pickier-native +0 -0
  19. package/dist/native/linux-arm64/pickier-native +0 -0
  20. package/dist/native/linux-x64/pickier-native +0 -0
  21. package/dist/native/win32-arm64/pickier-native.exe +0 -0
  22. package/dist/native/win32-x64/pickier-native.exe +0 -0
  23. package/dist/src/index.js +1 -1
  24. package/dist/src/lint-worker.js +1 -1
  25. package/dist/src/rules/shell/_continuation.d.ts +4 -0
  26. package/package.json +1 -1
  27. package/dist/chunk-1gsmqw00.js +0 -2
  28. package/dist/chunk-1r811fef.js +0 -9
  29. package/dist/chunk-9nk05dhr.js +0 -3
  30. package/dist/chunk-9w2q7ghj.js +0 -2
  31. package/dist/chunk-acdw0br0.js +0 -3
  32. package/dist/chunk-dqv1qww5.js +0 -128
  33. package/dist/chunk-hyabhvem.js +0 -2
  34. package/dist/chunk-vjsh2bkt.js +0 -25
  35. package/dist/chunk-w7q10fyj.js +0 -2
  36. package/dist/chunk-yvrap76h.js +0 -3
@@ -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-xgm5reee.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,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,2 @@
1
+ // @bun
2
+ import{F,S,D,j,k,B}from"./chunk-6vptsmta.js";import"./chunk-1jtr81zg.js";import"./chunk-99jrtc0c.js";export{S as fixText,k as lintFileForRun,F as lintText,j as plannedCheckRules,B as runLint,D as runLintProgrammatic};
package/dist/src/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{a,B,d,S,C,k,E,u,Y,r,M,f,L,R,o,Z,g,U,V,K,z,q,G,t,p,l,y,P,m,h,X}from"../chunk-vjsh2bkt.js";import{W,N,I,F,j}from"../chunk-dqv1qww5.js";import"../chunk-9nk05dhr.js";import{_}from"../chunk-acdw0br0.js";export{M as ALWAYS_IGNORES,r as ENV,E as MAX_FIXER_PASSES,f as UNIVERSAL_IGNORES,z as blue,G as bold,g as colorize,t as colors,B as config,h as createIgnoreMatcher,Y as createLimiter,a as defaultConfig,S as detectQuoteIssues,y as expandPatterns,I as fixText,d as formatCode,k as formatImports,L as getRuleSetting,u as glob,q as gray,U as green,C as hasIndentIssue,P as isCodeFile,Z as isRuleOff,N as lintText,l as loadConfigFromPath,p as mergeConfig,R as normalizeRuleSeverity,V as red,o as resolveRuleSeverity,_ as run,W as runFormat,j as runLint,F as runLintProgrammatic,X as shouldIgnorePath,m as withAlwaysIgnores,K 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-6vptsmta.js";import"../chunk-99jrtc0c.js";import{N}from"../chunk-vrbz87a8.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};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{l}from"../chunk-vjsh2bkt.js";import{w,x}from"../chunk-dqv1qww5.js";import"../chunk-9nk05dhr.js";var s,i=null;self.onmessage=async(n)=>{let t=n.data;if(t.type==="init"){s=t.options,i=l(s.config);return}try{let e=await i,o=[];for(let[r,a]of t.batch)o.push([r,await x(a,e,s)]);await w(),postMessage({type:"done",results:o})}catch(e){await w(),postMessage({type:"error",message:e?.message||String(e)})}};
2
+ import{c}from"../chunk-1jtr81zg.js";import{x,k}from"../chunk-6vptsmta.js";import"../chunk-99jrtc0c.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)})}};
@@ -0,0 +1,4 @@
1
+ /** Continuation indentation is temporary; only a completed header opens a block. */
2
+ export declare class ShellContinuation {
3
+ read(line: string): { continuation: boolean, closesHeader: boolean };
4
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pickier",
3
3
  "type": "module",
4
- "version": "0.1.69",
4
+ "version": "0.1.71",
5
5
  "description": "Format, lint and more in a fraction of seconds.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{_}from"./chunk-acdw0br0.js";import"./chunk-vjsh2bkt.js";export{_ as runUnified};
@@ -1,9 +0,0 @@
1
- // @bun
2
- import{n}from"./chunk-jqsghmew.js";import{c,i}from"./chunk-yvrap76h.js";var x={meta:{docs:"Use $() instead of backticks for command substitution",recommended:!0},check(a,h){let o=[],u=a.split(/\r?\n/),s=!1,r="",e=!1;for(let t=0;t<u.length;t++){let d=u[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 g=d[l];if(g==="#"&&!e)break;if(g==="\\"){l++;continue}if(g==="'"){e=!e;continue}if(e)continue;if(g==="`"){o.push({filePath:h.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(a,h){let o=a.split(/\r?\n/),u=[],s=!1,r="";for(let e of o){if(s){if(u.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,f=0;while(f<e.length){let l=e[f];if(l==="#"&&!m){d+=e.slice(f);break}if(l==="\\"){d+=e.slice(f,f+2),f+=2;continue}if(l==="'"){m=!m,d+=l,f++;continue}if(m){d+=l,f++;continue}if(l==="`"){let g="";f++;while(f<e.length&&e[f]!=="`")if(e[f]==="\\")g+=e[f+1]||"",f+=2;else g+=e[f],f++;f++,d+=`$(${g})`}else d+=l,f++}u.push(d)}return u.join(`
3
- `)}};var w={meta:{docs:"Require error handling after cd commands",recommended:!0},check(a,h){let o=[],u=a.split(/\r?\n/),s=!1,r="";for(let e=0;e<u.length;e++){let t=u[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 f=m.match(/^cd\s+/);if(!f)continue;let l=/\|\||&&/.test(t),g=/^\s*(?:if|elif|while|until)\s/.test(m)||/\bif\s+cd\b/.test(t),p=/\(.*\bcd\b.*\)/.test(t);if(!l&&!g&&!p)o.push({filePath:h.filePath,line:e+1,column:f.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 k={meta:{docs:"Disallow use of eval in shell scripts",recommended:!0},check(a,h){let o=[],u=a.split(/\r?\n/),s=!1,r="";for(let e=0;e<u.length;e++){let t=u[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:h.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 v={meta:{docs:"Flag exit inside subshells where it only exits the subshell",recommended:!0},check(a,h){let o=[],u=a.split(/\r?\n/),s=!1,r="",e=0;for(let t=0;t<u.length;t++){let d=u[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,g=!1;for(let p=0;p<d.length;p++){let b=d[p];if(b==="#"&&!l&&!g)break;if(b==="\\"&&!l){p++;continue}if(b==="'"&&!g){l=!l;continue}if(b==='"'&&!l){g=!g;continue}if(!l&&!g){if(b==="("&&p>0&&d[p-1]!=="$"&&d[p+1]!=="(")e++;else if(b==="("&&p===0&&d[p+1]!=="(")e++;else if(b===")"&&e>0&&(p+1>=d.length||d[p+1]!==")"))e--}}if(e>0){let p=d.match(/\bexit\b/);if(p)o.push({filePath:h.filePath,line:t+1,column:p.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 p=d.match(/(?<!\$)\((?!\()([^)]*\bexit\b[^)]*)\)(?!\))/);if(p){let b=d.indexOf("exit",p.index);o.push({filePath:h.filePath,line:t+1,column:b+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 P={meta:{docs:"Disallow parsing ls output \u2014 use globs or find instead",recommended:!0},check(a,h){let o=[],u=a.split(/\r?\n/),s=!1,r="";for(let e=0;e<u.length;e++){let t=u[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 p=t.indexOf("ls");o.push({filePath:h.filePath,line:e+1,column:p+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 p=l.index+1;o.push({filePath:h.filePath,line:e+1,column:p,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 g=t.match(/`\s*ls\b/);if(g){let p=g.index+1;o.push({filePath:h.filePath,line:e+1,column:p,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 S={meta:{docs:"Detect useless use of cat (UUOC)",recommended:!0},check(a,h){let o=[],u=a.split(/\r?\n/),s=!1,r="";for(let e=0;e<u.length;e++){let t=u[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 f=t.match(/\bcat\s+(["']?[\w.\/~${}*?-]+["']?)\s*\|/);if(f){let l=t.indexOf("cat");o.push({filePath:h.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 ${f[1]} | ...\``,severity:"warning",help:`Use \`cmd < ${f[1]}\` or pass the file as an argument to the command`})}}return o}};var D={meta:{docs:"Flag variables inside single quotes where they won't expand",recommended:!0},check(a,h){let o=[],u=a.split(/\r?\n/),s=!1,r="";for(let e=0;e<u.length;e++){let t=u[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 f=!1,l=!1,g=-1;for(let p=0;p<t.length;p++){let b=t[p];if(b==="#"&&!f&&!l)break;if(b==="\\"&&!f){p++;continue}if(b==='"'&&!f){l=!l;continue}if(b==="'"&&!l)if(!f)f=!0,g=p;else{let y=t.slice(g+1,p).match(/\$(?:[A-Za-z_]\w*|\{[^}]+\}|\([^)]*\))/);if(y)o.push({filePath:h.filePath,line:e+1,column:g+1+y.index+1,ruleId:"shell/no-variable-in-single-quotes",message:`Variable ${y[0]} is inside single quotes and won't be expanded`,severity:"warning",help:`Use double quotes if you want variable expansion: "..." instead of '...'`});f=!1}}}return o}};var X=[/^\s*(?:local|export|declare|typeset|readonly)\s+/,/\[\[.*\]\]/,/\(\(.*\)\)/],M=/^\$(?:\{[A-Za-z_]\w*(?:[:#%\/][^}]*)?\}|[A-Za-z_]\w*)/,I={meta:{docs:"Quote variable expansions to prevent word splitting and globbing",recommended:!0},check(a,h){let o=[],u=a.split(/\r?\n/),s=!1,r="";for(let e=0;e<u.length;e++){let t=u[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(X.some((g)=>g.test(t)))continue;let f=[],l=0;while(l<t.length){let g=f[f.length-1];if(g==="squote"){if(t[l]==="'")f.pop();l++;continue}if(t[l]==="\\"&&l+1<t.length){l+=2;continue}if(g==="dquote"){let b=t[l];if(b==='"'){f.pop(),l++;continue}if(b==="$"&&t[l+1]==="("&&t[l+2]==="("){f.push("arith"),l+=3;continue}if(b==="$"&&t[l+1]==="("){f.push("subshell"),l+=2;continue}if(b==="$"){let R=t.slice(l).match(M);if(R){l+=R[0].length;continue}}l++;continue}if(g==="arith"){let b=t[l];if(b===")"&&t[l+1]===")"){f.pop(),l+=2;continue}if(b==="$"){let R=t.slice(l).match(M);if(R){l+=R[0].length;continue}}l++;continue}let p=t[l];if(p==="#"&&(l===0||/\s/.test(t[l-1])))break;if(p==="'"){f.push("squote"),l++;continue}if(p==='"'){f.push("dquote"),l++;continue}if(p==="$"&&t[l+1]==="("&&t[l+2]==="("){f.push("arith"),l+=3;continue}if(p==="$"&&t[l+1]==="("){f.push("subshell"),l+=2;continue}if(p===")"&&g==="subshell"){f.pop(),l++;continue}if(p==="$"){let b=t.slice(l).match(M);if(b){let R=b[0];if(!/^\$[?!#@*0-9-]/.test(R))o.push({filePath:h.filePath,line:e+1,column:l+1,ruleId:"shell/quote-variables",message:`Unquoted variable ${R} \u2014 use "${R}" to prevent word splitting`,severity:"warning",help:`Wrap in double quotes: "${R}"`});l+=R.length;continue}}l++}}return o}};var T={meta:{docs:"Enforce consistent function declaration style",recommended:!0},check(a,h){let o=[],u=a.split(/\r?\n/),s=!1,r="";for(let e=0;e<u.length;e++){let t=u[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 f=m.match(/^function\s+(\w+)\s*(?:\(\s*\))?\s*\{?\s*$/);if(f){let l=f[1],g=t.indexOf("function");o.push({filePath:h.filePath,line:e+1,column:g+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(a){let h=a.split(/\r?\n/),o=[];for(let u of h){let s=u.match(/^(\s*)function\s+(\w+)\s*(?:\(\s*\))?\s*(\{?\s*)$/);if(s){let[,r,e,t]=s;o.push(`${r}${e}() ${t||"{"}`)}else o.push(u)}return o.join(`
4
- `)}};function W(a,h){if(/^then\b/.test(a)||/^do\b/.test(a)||/^else\b/.test(a))return!0;if(/^if\b/.test(a)&&/\bthen\s*$/.test(a))return!0;if(/^elif\b/.test(a)&&/\bthen\s*$/.test(a))return!0;if(/^(?:while|for|until)\b/.test(a)&&/\bdo\s*$/.test(a))return!0;if(/^case\b/.test(a)&&/\bin\s*$/.test(a))return!0;if(h&&/\)\s*$/.test(a)&&!/\$\(/.test(a)&&!/^\s*\(/.test(a)&&!a.startsWith("#"))return!0;if(/\{\s*$/.test(a)&&!a.startsWith("#"))return!0;return!1}function H(a){return/^(?:fi|done|esac|elif|else)\b/.test(a)||/^\}/.test(a)||/^;[;&]\s*$/.test(a)}var E={meta:{docs:"Enforce consistent indentation in shell scripts",recommended:!0},check(a,h){let o=[],u=a.split(/\r?\n/),s=h.config.format.indent||2,r=0,e=!1,t="",d=!1,m=0;for(let f=0;f<u.length;f++){let l=u[f];if(/^\s*$/.test(l))continue;if(e){if(l.trim()===t)e=!1;continue}let g=l.match(/<<-?\s*['"]?(\w+)['"]?/);if(g)e=!0,t=g[1];let p=l.replace(/^\s+/,"");if(f===0&&p.startsWith("#!"))continue;if(/^case\b/.test(p)&&/\bin\s*$/.test(p))m++,d=!0;if(/^esac\b/.test(p)){if(m=Math.max(0,m-1),m===0)d=!1}if(H(p))r=Math.max(0,r-1);let b=0;for(let y=0;y<l.length;y++)if(l[y]===" ")b++;else if(l[y]==="\t")b+=s;else break;let R=r*s;if(b!==R&&!p.startsWith("#"))o.push({filePath:h.filePath,line:f+1,column:1,ruleId:"shell/indent",message:`Expected ${R} spaces of indentation, found ${b}`,severity:"warning"});if(W(p,d))r++}return o},fix(a,h){let o=a.split(/\r?\n/),u=h.config.format.indent||2,s=h.config.format.indentStyle==="tabs",r=[],e=0,t=!1,d="",m=!1,f=0;for(let l=0;l<o.length;l++){let g=o[l];if(/^\s*$/.test(g)){r.push("");continue}if(t){if(r.push(g),g.trim()===d)t=!1;continue}let p=g.match(/<<-?\s*['"]?(\w+)['"]?/);if(p)t=!0,d=p[1];let b=g.replace(/^\s+/,"").trimEnd();if(l===0&&b.startsWith("#!")){r.push(b);continue}if(/^case\b/.test(b)&&/\bin\s*$/.test(b))f++,m=!0;if(/^esac\b/.test(b)){if(f=Math.max(0,f-1),f===0)m=!1}if(H(b))e=Math.max(0,e-1);let R=s?"\t".repeat(e):" ".repeat(e*u);if(r.push(R+b),W(b,m))e++}return r.join(`
5
- `)}};var q={meta:{docs:"Enforce spacing around shell keywords (if, then, do, else, fi, etc.)",recommended:!0},check(a,h){let o=[],u=a.split(/\r?\n/),s=!1,r="";for(let e=0;e<u.length;e++){let t=u[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 f=c(t),l=f.match(/;(?![;\s$])\S/);if(l)o.push({filePath:h.filePath,line:e+1,column:(l.index||0)+1,ruleId:"shell/keyword-spacing",message:"Missing space after semicolon",severity:"warning"});let g=f.match(/\w(then|do|else|elif|fi|done|esac)\b/);if(g&&!/[a-z]/.test(f[g.index])){let p=g[1],b=f[g.index];if(b!==" "&&b!=="\t"&&b!==";")o.push({filePath:h.filePath,line:e+1,column:(g.index||0)+2,ruleId:"shell/keyword-spacing",message:`Missing space before keyword '${p}'`,severity:"warning"})}}return o}};var C={meta:{docs:"Disallow unnecessary trailing semicolons",recommended:!0},check(a,h){let o=[],u=a.split(/\r?\n/),s=!1,r="";for(let e=0;e<u.length;e++){let t=u[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 f=t.lastIndexOf(";");o.push({filePath:h.filePath,line:e+1,column:f+1,ruleId:"shell/no-trailing-semicolons",message:"Unnecessary trailing semicolon",severity:"warning"})}}return o},fix(a){let h=a.split(/\r?\n/),o=[],u=!1,s="";for(let r of h){if(u){if(o.push(r),r.trim()===s)u=!1;continue}let e=r.match(/<<-?\s*['"]?(\w+)['"]?/);if(e)u=!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 O={meta:{docs:"Disallow trailing whitespace",recommended:!0},check(a,h){let o=[],u=a.split(/\r?\n/),s=!1,r="";for(let e=0;e<u.length;e++){let t=u[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:h.filePath,line:e+1,column:m.index+1,ruleId:"shell/no-trailing-whitespace",message:"Trailing whitespace",severity:"error"})}}return o},fix(a){let h=a.split(/\r?\n/),o=!1,u="";return h.map((r)=>{if(o){if(r.trim()===u)o=!1;return r}let e=i(r);if(e)o=!0,u=e;return r.replace(/[ \t]+$/,"")}).join(`
7
- `)}};var A={meta:{docs:"Enforce spaces inside [ ] and [[ ]] test expressions",recommended:!0},check(a,h){let o=[],u=a.split(/\r?\n/),s=!1,r="";for(let e=0;e<u.length;e++){let t=u[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 f=c(t);for(let l of G(f,e+1,h.filePath))o.push(l)}return o},fix(a){let h=a.split(/\r?\n/),o=[],u=!1,s="";for(let r of h){if(u){if(r.trim()===s)u=!1;o.push(r);continue}let e=i(r);if(e){u=!0,s=e,o.push(r);continue}if(r.replace(/^\s+/,"").startsWith("#")){o.push(r);continue}o.push(K(r))}return o.join(`
8
- `)}};function G(a,h,o){let u=[],s=/\[\[(?!\s|\]|$)/g;for(let e of a.matchAll(s))u.push({filePath:o,line:h,column:(e.index??0)+1,ruleId:"shell/operator-spacing",message:"Missing space after [[",severity:"warning"});let r=/(?<!\s|\[)\]\]/g;for(let e of a.matchAll(r))u.push({filePath:o,line:h,column:(e.index??0)+1,ruleId:"shell/operator-spacing",message:"Missing space before ]]",severity:"warning"});for(let e=0;e<a.length;e++){if(a[e]!=="[")continue;if(a[e+1]==="[")continue;if(e>0&&a[e-1]==="[")continue;if(!U(a,e))continue;let t=a[e+1];if(t!==void 0&&t!==" "&&t!=="\t")u.push({filePath:o,line:h,column:e+1,ruleId:"shell/operator-spacing",message:"Missing space after [",severity:"warning"})}for(let e=0;e<a.length;e++){if(a[e]!=="]")continue;if(a[e+1]==="]")continue;if(e>0&&a[e-1]==="]")continue;if(!j(a,e))continue;let t=a[e-1];if(t!==void 0&&t!==" "&&t!=="\t")u.push({filePath:o,line:h,column:e+1,ruleId:"shell/operator-spacing",message:"Missing space before ]",severity:"warning"})}return u}function K(a){let h=c(a),o=[];for(let s of h.matchAll(/\[\[(?!\s|\]|$)/g)){let r=(s.index??0)+2;o.push({pos:r,text:" "})}for(let s of h.matchAll(/(?<!\s|\[)\]\]/g)){let r=s.index??0;o.push({pos:r,text:" "})}for(let s=0;s<h.length;s++){if(h[s]!=="[")continue;if(h[s+1]==="[")continue;if(s>0&&h[s-1]==="[")continue;if(!U(h,s))continue;let r=h[s+1];if(r!==void 0&&r!==" "&&r!=="\t")o.push({pos:s+1,text:" "})}for(let s=0;s<h.length;s++){if(h[s]!=="]")continue;if(h[s+1]==="]")continue;if(s>0&&h[s-1]==="]")continue;if(!j(h,s))continue;let r=h[s-1];if(r!==void 0&&r!==" "&&r!=="\t")o.push({pos:s,text:" "})}if(o.length===0)return a;o.sort((s,r)=>r.pos-s.pos);let u=a;for(let{pos:s,text:r}of o)u=`${u.slice(0,s)}${r}${u.slice(s)}`;return u}function U(a,h){let o=h-1;while(o>=0&&(a[o]===" "||a[o]==="\t"))o--;if(o<0)return!0;let u=a[o];if(u===";"||u==="|"||u==="&"||u==="!"||u==="(")return!0;let s=a.slice(0,o+1);if(/(?:^|\s)(?:if|while|until|elif|then|else|do)\s*$/.test(s))return!0;return!1}function j(a,h){let o=a[h+1];if(o===void 0)return!0;return o===" "||o==="\t"||o===";"||o==="|"||o==="&"||o===")"}var N=/^#!\s*(?:\/usr\/bin\/env\s+(?:ba|z|k|da)?sh|\/bin\/(?:ba|z|k|da)?sh|\/usr\/bin\/(?:ba|z|k|da)?sh)\b/,B={meta:{docs:"Ensure shell scripts have a proper shebang line",recommended:!0},check(a,h){let o=[],u=a.split(/\r?\n/);if(u.length===0)return o;let s=u[0];if(u.every((r)=>r.trim()===""))return o;if(!s.startsWith("#!"))return o.push({filePath:h.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(!N.test(s))o.push({filePath:h.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 z={meta:{docs:"Enforce consistent case statement terminator placement",recommended:!0},check(a,h){let o=[],u=a.split(/\r?\n/),s=!1,r="",e=[];for(let t of u){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(c(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 p=t+1;p<e.length;p++){let b=e[p].trimEnd();if(/^\s*esac\b/.test(b)){if(d--,d===0){m=p;break}continue}if(/\bcase\b[\s\S]*\bin\s*$/.test(b))d++}if(m===-1)continue;let f=0,l=!1,g=!1;for(let p=t+1;p<m;p++){let b=e[p],R=b.trim();if(R==="")continue;if(f===0){let y=J(b);if(y!==-1){if(l&&g)o.push({filePath:h.filePath,line:p+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,g=!0;let F=b.slice(y+1).trimEnd();if(/;;\s*$/.test(F))l=!1;continue}}if(f+=Y(b),f<0)f=0;if(l&&f===0&&/;;\s*$/.test(R))l=!1}}return o}};function J(a){let h=a.replace(/^\s+/,"");if(h==="")return-1;if(/^(?:for|while|until|if|case|do|then|else|elif|fi|done|esac)\b/.test(h))return-1;let o=a.length-h.length,u=0;if(h[u]==="(")u++;let s=0;while(u<h.length){let r=h[u];if(r==="(")s++;else if(r===")"){if(s===0)return o+u;s--}else if(r===";"||r==="&"||r==="<"||r===">"||r==="=")return-1;u++}return-1}function Y(a){let h=a.trim();if(h==="")return 0;let o=h.split(/[\s;]+/),u=0;for(let s of o)if(s==="if"||s==="for"||s==="while"||s==="until")u++;else if(s==="fi"||s==="done")u--;return u}var Q={meta:{docs:"Recommend <<- for heredocs inside indented blocks"},check(a,h){let o=[],u=a.split(/\r?\n/);for(let s=0;s<u.length;s++){let r=u[s];if(r.replace(/^\s+/,"").startsWith("#"))continue;if(!r.match(/^\s+/))continue;let m=c(r).match(/(?<!<)<<(?![<-])/);if(!m||m.index===void 0)continue;let l=r.slice(m.index+2).match(/^\s*(['"]?)(\w+)\1\s*$/);if(l){let g=l[2];o.push({filePath:h.filePath,line:s+1,column:m.index+1,ruleId:"shell/heredoc-indent",message:`Use <<- instead of << for indented heredoc (delimiter '${g}' must be at column 0 otherwise)`,severity:"warning",help:"Use <<- to strip leading tabs from heredoc content, allowing proper indentation"})}}return o}};var L={meta:{docs:"Detect incorrect redirect ordering (2>&1 before > file)",recommended:!0},check(a,h){let o=[],u=a.split(/\r?\n/),s=!1,r="";for(let e=0;e<u.length;e++){let t=u[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 f=c(t);if(f.match(/2>&1\s+>(?!&)\s*\S/)){let g=f.indexOf("2>&1");o.push({filePath:h.filePath,line:e+1,column:g+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 V={meta:{docs:"Prefer [[ ]] over [ ] for test expressions in bash/zsh",recommended:!0},check(a,h){let o=[],u=a.split(/\r?\n/)[0]||"",s=/bash|zsh/.test(u);if(/^#!.*\bsh\b/.test(u)&&!s||!s)return o;let e=a.split(/\r?\n/),t=!1,d="";for(let m=0;m<e.length;m++){let f=e[m];if(t){if(f.trim()===d)t=!1;continue}let l=f.match(/<<-?\s*['"]?(\w+)['"]?/);if(l)t=!0,d=l[1];if(f.replace(/^\s+/,"").startsWith("#"))continue;if(f.match(/(?:^|\s|;)\[\s(?!\[)/)){if(/(?<!\])\](?!\])/.test(f)){let b=f.indexOf("[");o.push({filePath:h.filePath,line:m+1,column:b+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(a){let h=a.split(/\r?\n/)[0]||"";if(!/bash|zsh/.test(h))return a;let u=a.split(/\r?\n/),s=[];for(let r of u){let e=r;e=e.replace(/(?:^|(?<=\s|;))\[(\s(?!\[).*?(?<!\]))\](?!\])/g,"[[$1]]"),s.push(e)}return s.join(`
9
- `)}};var _={meta:{docs:"Prefer printf over echo -e and echo -n",recommended:!0},check(a,h){let o=[],u=a.split(/\r?\n/),s=!1,r="";for(let e=0;e<u.length;e++){let t=u[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 f=t.match(/\becho\s+-[en]+\b/);if(f){let l=t.indexOf("echo"),g=f[0].replace("echo ","");o.push({filePath:h.filePath,line:e+1,column:l+1,ruleId:"shell/prefer-printf",message:`Use printf instead of echo ${g} \u2014 echo behavior varies across platforms`,severity:"warning",help:'printf is portable: printf "format\\n" args... (use \\n for newline)'})}}return o}};var Z={meta:{docs:"Recommend set -euo pipefail for safer script execution"},check(a,h){let o=[],u=a.split(/\r?\n/),s=!1,r=!1,e=!1,t=-1,d=!1;for(let f=0;f<u.length;f++){let l=u[f].replace(/^\s+/,"");if(f===0&&l.startsWith("#!")){t=f;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:h.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 Ke={name:"shell",rules:{"command-substitution":n(x),"quote-variables":n(I),"no-cd-without-check":n(w),"no-eval":n(k),"no-useless-cat":n(S),"no-ls-parsing":n(P),"no-variable-in-single-quotes":n(D),"no-exit-in-subshell":n(v),shebang:n(B),indent:n(E),"function-style":n(T),"operator-spacing":n(A),"keyword-spacing":n(q),"no-trailing-semicolons":n(C),"no-trailing-whitespace":n(O),"prefer-double-brackets":n(V),"set-options":n(Z),"prefer-printf":n(_),"consistent-case-terminators":n(z),"no-broken-redirect":n(L),"heredoc-indent":n(Q)}};export{Ke as shellPlugin};
@@ -1,3 +0,0 @@
1
- // @bun
2
- var Q="pickier",ee="module",T="0.1.69",te="Format, lint and more in a fraction of seconds.",ne="Chris Breuer <chris@stacksjs.org>",se="MIT",re="https://github.com/pickier/pickier#readme",ie={type:"git",url:"git+https://github.com/pickier/pickier.git"},oe={url:"https://github.com/pickier/pickier/issues"},ae=["pickier","linter","formatter","bun","fast"],le={".":{types:"./dist/src/index.d.ts",import:"./dist/src/index.js"},"./*":{import:"./dist/*"}},ce="./dist/src/index.js",ue="./dist/src/index.d.ts",fe={pickier:"./dist/bin/cli.js"},me=["README.md","dist"],he={build:"bun --bun build.ts","build:bin":"bun --bun build.ts && bun run compile","build:native":"bun scripts/build-native.ts",compile:"bun build ./bin/cli.ts --compile --minify --outfile bin/pickier","compile:all":"bun run compile:linux-x64 && bun run compile:linux-arm64 && bun run compile:linux-x64-musl && bun run compile:linux-arm64-musl && bun run compile:windows-x64 && bun run compile:windows-arm64 && bun run compile:darwin-x64 && bun run compile:darwin-arm64","compile:linux-x64":"bun build ./bin/cli.ts --compile --minify --target=bun-linux-x64 --outfile bin/pickier-linux-x64","compile:linux-arm64":"bun build ./bin/cli.ts --compile --minify --target=bun-linux-arm64 --outfile bin/pickier-linux-arm64","compile:linux-x64-musl":"bun build ./bin/cli.ts --compile --minify --target=bun-linux-x64-musl --outfile bin/pickier-linux-x64-musl","compile:linux-arm64-musl":"bun build ./bin/cli.ts --compile --minify --target=bun-linux-arm64-musl --outfile bin/pickier-linux-arm64-musl","compile:windows-x64":"bun build ./bin/cli.ts --compile --minify --target=bun-windows-x64 --outfile bin/pickier-windows-x64.exe","compile:windows-arm64":"bun build ./bin/cli.ts --compile --minify --target=bun-windows-arm64 --outfile bin/pickier-windows-arm64.exe","compile:darwin-x64":"bun build ./bin/cli.ts --compile --minify --target=bun-darwin-x64 --outfile bin/pickier-darwin-x64","compile:darwin-arm64":"bun build ./bin/cli.ts --compile --minify --target=bun-darwin-arm64 --outfile bin/pickier-darwin-arm64",zip:"bun run zip:all","zip:all":"bun run zip:linux-x64 && bun run zip:linux-arm64 && bun run zip:linux-x64-musl && bun run zip:linux-arm64-musl && bun run zip:windows-x64 && bun run zip:windows-arm64 && bun run zip:darwin-x64 && bun run zip:darwin-arm64","zip:linux-x64":"zip -j bin/pickier-linux-x64.zip bin/pickier-linux-x64","zip:linux-arm64":"zip -j bin/pickier-linux-arm64.zip bin/pickier-linux-arm64","zip:linux-x64-musl":"zip -j bin/pickier-linux-x64-musl.zip bin/pickier-linux-x64-musl","zip:linux-arm64-musl":"zip -j bin/pickier-linux-arm64-musl.zip bin/pickier-linux-arm64-musl","zip:windows-x64":"zip -j bin/pickier-windows-x64.zip bin/pickier-windows-x64.exe","zip:windows-arm64":"zip -j bin/pickier-windows-arm64.zip bin/pickier-windows-arm64.exe","zip:darwin-x64":"zip -j bin/pickier-darwin-x64.zip bin/pickier-darwin-x64","zip:darwin-arm64":"zip -j bin/pickier-darwin-arm64.zip bin/pickier-darwin-arm64",prepublishOnly:"bun --bun run build && bun scripts/build-native.ts --required && bun run compile:all && bun run zip",test:"PICKIER_NO_AUTO_CONFIG=1 bun test --coverage","test:core":"PICKIER_NO_AUTO_CONFIG=1 bun test test/core","test:format":"PICKIER_NO_AUTO_CONFIG=1 bun test test/format","test:lint":"PICKIER_NO_AUTO_CONFIG=1 bun test test/lint","test:rules":"PICKIER_NO_AUTO_CONFIG=1 bun test test/rules","test:rules:sort":"PICKIER_NO_AUTO_CONFIG=1 bun test test/rules/sort","test:rules:style":"PICKIER_NO_AUTO_CONFIG=1 bun test test/rules/style","test:rules:quality":"PICKIER_NO_AUTO_CONFIG=1 bun test test/rules/quality","test:rules:imports":"PICKIER_NO_AUTO_CONFIG=1 bun test test/rules/imports","test:rules:typescript":"PICKIER_NO_AUTO_CONFIG=1 bun test test/rules/typescript","test:rules:regexp":"PICKIER_NO_AUTO_CONFIG=1 bun test test/rules/regexp","test:plugin":"PICKIER_NO_AUTO_CONFIG=1 bun test test/plugin","test:watch":"PICKIER_NO_AUTO_CONFIG=1 bun test --watch"},de={"@stacksjs/clarity":"^0.3.24","@stacksjs/clapp":"^0.2.3"},pe={"@stacksjs/ts-spell-check":"^0.1.0"},ge={bunfig:"^0.15.13"},ye={name:Q,type:ee,version:T,description:te,author:ne,license:se,homepage:re,repository:ie,bugs:oe,keywords:ae,exports:le,module:ce,types:ue,bin:fe,files:me,scripts:he,dependencies:de,optionalDependencies:pe,devDependencies:ge};
3
- export{Q,ee,T,te,ne,se,re,ie,oe,ae,le,ce,ue,fe,me,he,de,pe,ge,ye};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{N,I,F,D,x,j}from"./chunk-dqv1qww5.js";import"./chunk-vjsh2bkt.js";import"./chunk-9nk05dhr.js";export{I as fixText,x as lintFileForRun,N as lintText,D as plannedCheckRules,j as runLint,F as runLintProgrammatic};
@@ -1,3 +0,0 @@
1
- // @bun
2
- import{d,l}from"./chunk-vjsh2bkt.js";import{readFileSync as s,statSync as o,writeFileSync as y}from"fs";import{isAbsolute as O,resolve as p}from"path";async function _(r,t){let a=t.mode||"auto";if(a==="format"&&r.length===1&&!/[*?[\]{}()!]/.test(r[0]))try{let n=r[0],i=O(n)?n:p(process.cwd(),n);if(o(i).isFile()){let u=await l(t.config),c=s(i,"utf8"),f=d(c,u,i);if(t.check&&f!==c)return 1;if(t.write&&f!==c)y(i,f,"utf8");return 0}}catch{}let{runLint:e}=await import("./chunk-9w2q7ghj.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 m={...t,fix:!0,dryRun:!!t.check,ext:t.ext};return e(r,m)}
3
- export{_};