pickier 0.1.65 → 0.1.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/cli.js +2 -2
- package/dist/chunk-13r0v0m9.js +226 -0
- package/dist/chunk-bxyt25b3.js +2 -0
- package/dist/chunk-by60fzz0.js +92 -0
- package/dist/chunk-p0j2ra3t.js +31 -0
- package/dist/chunk-rtzfbwtn.js +2 -0
- package/dist/chunk-tvt73e07.js +2 -0
- package/dist/chunk-xf6t6ene.js +2 -0
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/lexer.d.ts +44 -0
- package/dist/src/linter.d.ts +9 -0
- package/dist/src/rules/general/_template-tracking.d.ts +5 -18
- package/dist/src/rules/general/no-unused-vars.d.ts +12 -0
- package/dist/src/rules/ts/no-top-level-await.d.ts +7 -1
- package/package.json +1 -1
- package/dist/chunk-awmb5sg5.js +0 -3
- package/dist/chunk-bnbsk67m.js +0 -2
- package/dist/chunk-gy6wyx8t.js +0 -62
- package/dist/chunk-hwa8gmzb.js +0 -156
- package/dist/chunk-qh9cawym.js +0 -2
- package/dist/chunk-sj3ctzyt.js +0 -3
- package/dist/chunk-tskywgx9.js +0 -226
- package/dist/chunk-vdbbvx8x.js +0 -33
- package/dist/chunk-wh52kdr1.js +0 -2
- package/dist/chunk-z7exyj5z.js +0 -2
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{existsSync as z}from"fs";import O from"fs/promises";import N from"os";import E from"path";import y from"process";import{EventEmitter as Y}from"events";import v from"process";import R from"process";import k from"process";import _ from"process";import C from"process";import W from"tty";import Le,{stdin as at,stdout as lt}from"process";class P{configPath;config=null;events=[];retryCount=0;maxRetries=3;retryDelayMs=1000;constructor(){let e=N.homedir(),t=E.join(e,".config","clapp");this.configPath=E.join(t,"telemetry.json")}async isEnabled(){if(y.env.DO_NOT_TRACK==="1"||y.env.DO_NOT_TRACK==="true")return!1;if(y.env.NO_TELEMETRY==="1"||y.env.NO_TELEMETRY==="true")return!1;return(await this.loadConfig()).enabled}async enable(){let e=await this.loadConfig();if(e.enabled=!0,!e.userId)e.userId=this.generateUserId();await this.saveConfig(e)}async disable(){let e=await this.loadConfig();e.enabled=!1,await this.saveConfig(e)}async track(e,t){if(!await this.isEnabled())return;let i={event:e,...t,timestamp:Date.now(),platform:N.platform(),nodeVersion:y.version};if(this.events.push(i),this.events.length>=10)await this.send()}async trackCommand(e,t){await this.track("command",{command:e,duration:t})}async trackError(e,t){await this.track("error",{error:e,command:t})}async send(){if(!await this.isEnabled()||this.events.length===0)return!0;try{this.events=[],this.retryCount=0;let t=await this.loadConfig();return t.lastSent=Date.now(),await this.saveConfig(t),!0}catch{if(this.retryCount<this.maxRetries){this.retryCount++;let t=this.retryDelayMs*2**(this.retryCount-1);return await this.sleep(t),this.send()}return this.events=[],this.retryCount=0,!1}}async flush(){if(this.events.length===0)return!0;return this.send()}sleep(e){return new Promise((t)=>setTimeout(t,e))}async status(){let e=await this.loadConfig();return{enabled:e.enabled,doNotTrack:y.env.DO_NOT_TRACK==="1"||y.env.DO_NOT_TRACK==="true",eventsQueued:this.events.length,lastSent:e.lastSent}}async loadConfig(){if(this.config)return this.config;try{if(z(this.configPath)){let e=await O.readFile(this.configPath,"utf-8");return this.config=JSON.parse(e),this.config}}catch{}return this.config={enabled:!1},this.config}async saveConfig(e){this.config=e;try{let t=E.dirname(this.configPath);await O.mkdir(t,{recursive:!0}),await O.writeFile(this.configPath,JSON.stringify(e,null,2),"utf-8")}catch{}}generateUserId(){let e=Math.random().toString(36).substring(2,15),t=Date.now().toString(36);return`${e}-${t}`}}var ze=new P;function J(e,t={}){let s={_:[]},i=t.alias||{},r=new Set(t.boolean||[]),a={};for(let o of Object.keys(i))for(let n of i[o])a[n]=o;for(let o of r)if(i[o])for(let n of i[o])r.add(n);function u(o,n){let l=a[o]||o;if(s[l]=n,i[l])for(let c of i[l])s[c]=n;if(a[o]&&i[a[o]])for(let c of i[a[o]])s[c]=n;s[o]=n}for(let o=0;o<e.length;o++){let n=e[o];if(n==="--"){s._.push(...e.slice(o+1));break}if(n.startsWith("--")){let l=n.indexOf("=");if(l!==-1){let c=n.slice(2,l),h=n.slice(l+1);u(c,h)}else{let c=n.slice(2);if(c.startsWith("no-")){let m=c.slice(3);u(m,!1);continue}let h=a[c]||c;if(r.has(h)||r.has(c))u(c,!0);else{let m=e[o+1];if(m!==void 0&&!m.startsWith("-"))u(c,m),o++;else u(c,!0)}}}else if(n.startsWith("-")&&n.length>1){let l=n.slice(1);for(let c=0;c<l.length;c++){let h=l[c],m=a[h]||h;if(c===l.length-1&&!r.has(m)&&!r.has(h)){let d=e[o+1];if(d!==void 0&&!d.startsWith("-"))u(h,d),o++;else u(h,!0)}else u(h,!0)}}else s._.push(n)}return s}function T(e){return e.replace(/[<[].+/,"").trim()}function Q(e){let t=/<([^>]+)>/g,s=/\[([^\]]+)\]/g,i=[],r=(o)=>{let n=!1,l=o[1];if(l.startsWith("..."))l=l.slice(3),n=!0;return{required:o[0].startsWith("<"),value:l,variadic:n}},a;while(a=t.exec(e))i.push(r(a));let u;while(u=s.exec(e))i.push(r(u));return i}function X(e){let t={alias:{},boolean:[]};for(let[s,i]of e.entries()){if(i.names.length>1)t.alias[i.names[0]]=i.names.slice(1);if(i.isBoolean)if(i.negated){if(!e.some((a,u)=>u!==s&&a.names.some((o)=>i.names.includes(o))&&typeof a.required==="boolean"))t.boolean.push(i.names[0])}else t.boolean.push(i.names[0])}return t}function j(e){return e.reduce((t,s)=>t.length>=s.length?t:s,"")}function B(e,t){return e.length>=t?e:`${e}${" ".repeat(t-e.length)}`}function Z(e){return e.replace(/([a-z])-([a-z])/g,(t,s,i)=>s+i.toUpperCase())}function ee(e,t,s){let i=0,r=t.length,a=e,u;for(;i<r;++i)u=a[t[i]],a=a[t[i]]=i===r-1?s:u!=null?u:!!~t[i+1].indexOf(".")||!(+t[i+1]>-1)?{}:[]}function te(e,t){for(let s of Object.keys(t)){let i=t[s];if(i.shouldTransform){if(e[s]=Array.prototype.concat.call([],e[s]),typeof i.transformFunction==="function")e[s]=e[s].map(i.transformFunction)}}}function se(e){let t=/([^\\/]+)$/.exec(e);return t?t[1]:""}function F(e){return e.split(".").map((t,s)=>s===0?Z(t):t).join(".")}class S extends Error{exitCode=2;isUsageError=!0;constructor(e){super(e);if(this.name=this.constructor.name,typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,this.constructor);else this.stack=Error(e).stack}format(e=!1){if(e&&this.stack)return`${this.message}
|
|
3
|
+
|
|
4
|
+
Stack trace:
|
|
5
|
+
${this.stack}`;return this.message}}function ie(){let{env:e}=R,{TERM:t,TERM_PROGRAM:s}=e;if(R.platform!=="win32")return t!=="linux";return Boolean(e.WT_SESSION)||Boolean(e.TERMINUS_SUBLIME)||e.ConEmuTask==="{cmd::Cmder}"||s==="Terminus-Sublime"||s==="vscode"||t==="xterm-256color"||t==="alacritty"||t==="rxvt-unicode"||t==="rxvt-unicode-256color"||e.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var I="\x1B",g=`${I}[`;var L={to(e,t){if(!t)return`${g}${e+1}G`;return`${g}${t+1};${e+1}H`},move(e,t){let s="";if(e<0)s+=`${g}${-e}D`;else if(e>0)s+=`${g}${e}C`;if(t<0)s+=`${g}${-t}A`;else if(t>0)s+=`${g}${t}B`;return s},up:(e=1)=>`${g}${e}A`,down:(e=1)=>`${g}${e}B`,forward:(e=1)=>`${g}${e}C`,backward:(e=1)=>`${g}${e}D`,nextLine:(e=1)=>`${g}E`.repeat(e),prevLine:(e=1)=>`${g}F`.repeat(e),left:`${g}G`,hide:`${g}?25l`,show:`${g}?25h`,save:`${I}7`,restore:`${I}8`};var Xe={screen:`${g}2J`,up:(e=1)=>`${g}1J`.repeat(e),down:(e=1)=>`${g}J`.repeat(e),line:`${g}2K`,lineEnd:`${g}K`,lineStart:`${g}1K`,lines(e){let t="";for(let s=0;s<e;s++)t+=this.line+(s<e-1?L.up():"");if(e)t+=L.left;return t}},Ze={screen:`${I}c`};function ne(e,t){let s=[];for(let i=0;i<=t.length;i++)s[i]=[i];for(let i=0;i<=e.length;i++)s[0][i]=i;for(let i=1;i<=t.length;i++)for(let r=1;r<=e.length;r++)if(t.charAt(i-1)===e.charAt(r-1))s[i][r]=s[i-1][r-1];else s[i][r]=Math.min(s[i-1][r-1]+1,s[i][r-1]+1,s[i-1][r]+1);return s[t.length][e.length]}function H(e,t,s=2,i=3){return t.map((r)=>({cmd:r,distance:ne(e,r)})).filter(({distance:r})=>r<=s).sort((r,a)=>r.distance-a.distance).slice(0,i).map(({cmd:r})=>r)}class U{rawName;description;name;names;isBoolean;required;config;negated;constructor(e,t,s){if(this.rawName=e,this.description=t,this.config=Object.assign({},s),e=e.replace(/\.\*/g,""),this.negated=!1,this.names=T(e).split(",").map((i)=>{let r=i.trim().replace(/^-{1,2}/,"");if(r.startsWith("no-"))this.negated=!0,r=r.replace(/^no-/,"");return F(r)}).sort((i,r)=>i.length>r.length?1:-1),this.name=this.names[this.names.length-1],this.negated&&this.config.default==null)this.config.default=!0;if(e.includes("<"))this.required=!0;else if(e.includes("["))this.required=!1;else this.isBoolean=!0}}var tt=k.argv,re=`${k.platform}-${k.arch} bun-v${typeof Bun<"u"?Bun.version:"unknown"}`,D=_.argv,oe=`${_.platform}-${_.arch} node-${_.version}`;class V{rawName;description;config;cli;options;aliasNames;name;namespace;args;commandAction;usageText;versionNumber;examples;helpCallback;globalCommand;beforeHooks;afterHooks;middleware;constructor(e,t,s,i){this.rawName=e,this.description=t,this.config=s,this.cli=i,this.options=[],this.aliasNames=[],this.name=T(e);let r=T(e),a=r.indexOf(":");if(a>0)this.namespace=r.substring(0,a),this.name=r.substring(a+1);if(this.args=Q(e),this.examples=[],this.beforeHooks=[],this.afterHooks=[],this.middleware=[],!s)this.config={}}usage(e){return this.usageText=e,this}allowUnknownOptions(){return this.config.allowUnknownOptions=!0,this}ignoreOptionDefaultValue(){return this.config.ignoreOptionDefaultValue=!0,this}version(e,t="-v, --version"){return this.versionNumber=e,this.option(t,"Display version number"),this}example(e){return this.examples.push(e),this}option(e,t,s){let i=new U(e,t,s);return this.options.push(i),this}alias(e){return this.aliasNames.push(e),this}action(e){return this.commandAction=e,this}before(e){return this.beforeHooks.push(e),this}after(e){return this.afterHooks.push(e),this}use(e){return this.middleware.push(e),this}isMatched(e){if(this.aliasNames.includes(e))return!0;if(this.namespace)return`${this.namespace}:${this.name}`===e;return this.name===e}get isDefaultCommand(){return this.name===""||this.aliasNames.includes("!")}get isGlobalCommand(){return this instanceof M}get displayName(){return this.namespace?`${this.namespace}:${this.name}`:this.name}hasOption(e){return e=e.split(".")[0],!!this.options.find((t)=>t.names.includes(e))}outputHelp(){let{name:e,commands:t}=this.cli,{versionNumber:s,options:i,helpCallback:r}=this.cli.globalCommand,a=[{body:`${e}${s?`/${s}`:""}`}];if(a.push({title:"Usage",body:` $ ${e} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&t.length>0){let n=j(t.map((d)=>d.rawName)),l=new Map,c=[];for(let d of t)if(d.namespace){if(!l.has(d.namespace))l.set(d.namespace,[]);l.get(d.namespace).push(d)}else c.push(d);let h="";if(c.length>0)h+=c.map((d)=>` ${B(d.rawName,n.length)} ${d.description}`).join(`
|
|
6
|
+
`);let m=Array.from(l.keys()).sort();for(let d of m){let q=l.get(d);if(h.length>0)h+=`
|
|
7
|
+
|
|
8
|
+
`;h+=` ${d}:
|
|
9
|
+
`,h+=q.map((A)=>` ${B(A.rawName,n.length-2)} ${A.description}`).join(`
|
|
10
|
+
`)}a.push({title:"Commands",body:h}),a.push({title:"For more info, run any command with the `--help` flag",body:t.map((d)=>` $ ${e}${d.displayName===""?"":` ${d.displayName}`} --help`).join(`
|
|
11
|
+
`)})}let o=this.isGlobalCommand?i:[...this.options,...i||[]];if(!this.isGlobalCommand&&!this.isDefaultCommand)o=o.filter((n)=>n.name!=="version");if(o.length>0){let n=j(o.map((l)=>l.rawName));a.push({title:"Options",body:o.map((l)=>` ${B(l.rawName,n.length)} ${l.description} ${l.config.default===void 0?"":`(default: ${l.config.default})`}`).join(`
|
|
12
|
+
`)})}if(this.examples.length>0)a.push({title:"Examples",body:this.examples.map((n)=>{if(typeof n==="function")return n(e);return n}).join(`
|
|
13
|
+
`)});if(r)a=r(a)||a;console.log(a.map((n)=>n.title?`${n.title}:
|
|
14
|
+
${n.body}`:n.body).join(`
|
|
15
|
+
|
|
16
|
+
`))}outputVersion(){let{name:e}=this.cli,{versionNumber:t}=this.cli.globalCommand;if(t)console.log(`${e}/${t} ${typeof Bun<"u"?re:oe}`)}checkRequiredArgs(){let e=this.args.filter((t)=>t.required).length;if(this.cli.args.length<e){let s=this.args.filter((r)=>r.required).slice(this.cli.args.length),i=s.map((r)=>`<${r.value}>`).join(" ");throw new S(`Missing required argument${s.length>1?"s":""}: ${i}
|
|
17
|
+
|
|
18
|
+
Run \`${this.cli.name} ${this.rawName} --help\` for usage information.`)}}checkUnknownOptions(){let{options:e,globalCommand:t}=this.cli;if(!this.config.allowUnknownOptions){for(let s of Object.keys(e))if(s!=="--"&&!this.hasOption(s)&&!t.hasOption(s)){let r=[...t.options,...this.options].flatMap((n)=>n.names),a=s.length>1?`--${s}`:`-${s}`,u=H(s,r),o=`Unknown option \`${a}\``;if(u.length>0)o+=`
|
|
19
|
+
|
|
20
|
+
Did you mean one of these?`,u.forEach((n)=>{let l=n.length>1?`--${n}`:`-${n}`;o+=`
|
|
21
|
+
\u2022 ${l}`});throw o+=`
|
|
22
|
+
|
|
23
|
+
Run \`${this.cli.name} ${this.rawName} --help\` to see available options.`,new S(o)}}}checkOptionValue(){let{options:e,globalCommand:t}=this.cli,s=[...t.options,...this.options];for(let i of s){let r=e[i.name.split(".")[0]];if(i.required){let a=s.some((u)=>u.negated&&u.names.includes(i.name));if(r===!0||r===!1&&!a)throw new S(`Option \`${i.rawName}\` requires a value.
|
|
24
|
+
|
|
25
|
+
Example: ${this.cli.name} ${this.rawName} ${i.rawName} <value>`)}}}}class M extends V{constructor(e){super("@@global@@","",{},e)}}var ae=V,w={red:["\x1B[31m","\x1B[39m"],green:["\x1B[32m","\x1B[39m"],blue:["\x1B[34m","\x1B[39m"],yellow:["\x1B[33m","\x1B[39m"],cyan:["\x1B[36m","\x1B[39m"],magenta:["\x1B[35m","\x1B[39m"],white:["\x1B[37m","\x1B[39m"],gray:["\x1B[90m","\x1B[39m"],bgRed:["\x1B[41m","\x1B[49m"],bgGreen:["\x1B[42m","\x1B[49m"],bgBlue:["\x1B[44m","\x1B[49m"],bgYellow:["\x1B[43m","\x1B[49m"],bgCyan:["\x1B[46m","\x1B[49m"],bgMagenta:["\x1B[45m","\x1B[49m"],bold:["\x1B[1m","\x1B[22m"],italic:["\x1B[3m","\x1B[23m"],underline:["\x1B[4m","\x1B[24m"],dim:["\x1B[2m","\x1B[22m"],inverse:["\x1B[7m","\x1B[27m"],hidden:["\x1B[8m","\x1B[28m"],strikethrough:["\x1B[9m","\x1B[29m"]};var b={primary:"blue",secondary:"cyan",success:"green",warning:"yellow",error:"red",info:"magenta",muted:"gray"};function le(){return!0}function ue(){let e={};e.supportsColor=le();function t(i,r=[]){let a=i===""?[]:[...r,i],u=function(n){if(!e.supportsColor)return n;let l="",c="";for(let h of a)if(h in b&&b[h]in w){let m=b[h];l+=w[m][0],c=w[m][1]+c}else if(h in w)l+=w[h][0],c=w[h][1]+c;return l+n+c},o=[...Object.keys(w),...Object.keys(b)];for(let n of o)if(!(n in u))Object.defineProperty(u,n,{get(){return t(n,a)}});return u}let s=[...Object.keys(w),...Object.keys(b)];for(let i of s)if(!(i in e))Object.defineProperty(e,i,{get(){return t(i)}});return e}var x=ue();class ce extends Y{name;commands;globalCommand;matchedCommand;matchedCommandName;rawArgs;args;options;showHelpOnExit;showVersionOnExit;enableDidYouMean=!0;signalHandlersSet=!1;isVerbose=!1;isQuiet=!1;isDebug=!1;isNoInteraction=!1;environment;isDryRun=!1;isForce=!1;useEmoji=!0;theme;isNoCache=!1;constructor(e=""){super();this.name=e,this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.globalCommand=new M(this),this.globalCommand.usage("<command> [options]")}handleSignals(e){if(this.signalHandlersSet)return this;let t=async(s)=>{if(console.log(`
|
|
26
|
+
|
|
27
|
+
Received ${s}, cleaning up...`),e)try{await e()}catch(i){console.error("Error during cleanup:",i)}v.exit(0)};return v.on("SIGINT",()=>t("SIGINT")),v.on("SIGTERM",()=>t("SIGTERM")),this.signalHandlersSet=!0,this}didYouMean(e=!0){return this.enableDidYouMean=e,this}verbose(){return this.globalCommand.option("-v, --verbose","Enable verbose output"),this}quiet(){return this.globalCommand.option("-q, --quiet","Suppress non-essential output"),this}debug(){return this.globalCommand.option("--debug","Enable debug mode with detailed error information"),this}noInteraction(){return this.globalCommand.option("-n, --no-interaction","Do not ask any interactive questions (for CI/CD)"),this}env(){return this.globalCommand.option("--env <environment>","Target environment (e.g., production, staging, local)"),this}dryRun(){return this.globalCommand.option("--dry-run","Preview actions without executing them"),this}force(){return this.globalCommand.option("-f, --force","Skip confirmation prompts"),this}emoji(){return this.globalCommand.option("--no-emoji","Disable emoji in output"),this}themes(){return this.globalCommand.option("--theme <theme>","Color theme (default, dracula, nord, solarized, monokai)"),this}cache(){return this.globalCommand.option("--no-cache","Disable caching"),this}usage(e){return this.globalCommand.usage(e),this}command(e,t,s){if(!s)s={};let i=new ae(e,t||"",s,this);return i.globalCommand=this.globalCommand,this.commands.push(i),i}option(e,t,s){return this.globalCommand.option(e,t,s),this}help(e){return this.globalCommand.option("-h, --help","Display this message"),this.globalCommand.helpCallback=e,this.showHelpOnExit=!0,this}version(e,t="-v, --version"){return this.globalCommand.version(e,t),this.showVersionOnExit=!0,this}example(e){return this.globalCommand.example(e),this}outputHelp(){if(this.matchedCommand)this.matchedCommand.outputHelp();else this.globalCommand.outputHelp()}outputVersion(){this.globalCommand.outputVersion()}setParsedInfo({args:e,options:t},s,i){if(this.args=e,this.options=t,s)this.matchedCommand=s;if(i)this.matchedCommandName=i;return this}unsetMatchedCommand(){this.matchedCommand=void 0,this.matchedCommandName=void 0}showCommandNotFound(e){if(console.log(x.red(`
|
|
28
|
+
\u2717 Command "${e}" not found.
|
|
29
|
+
`)),this.enableDidYouMean){let t=[];for(let i of this.commands){if(i.displayName)t.push(i.displayName);if(i.aliasNames)t.push(...i.aliasNames)}let s=H(e,t);if(s.length>0)console.log(x.yellow("Did you mean one of these?")),s.forEach((i)=>console.log(` ${x.dim("\u2022")} ${this.name} ${i}`)),console.log("")}console.log(x.dim("Run"),`${this.name} --help`,x.dim("to see all available commands")),v.exit(1)}async parse(e=D,t={}){let{run:s=!0,exitOnError:i=!1}=t;if(i)try{return await this.parse(e,{run:s})}catch(n){throw this.handleUsageError(n),n}if(this.rawArgs=e,!this.name)this.name=e[1]?se(e[1]):"cli";let r=!0,a=e.slice(2),u=a[0];if(u&&!u.startsWith("-")){for(let n of this.commands)if(n.isMatched(u)){let l=this.mri(a,n);r=!1;let c={...l,args:l.args.slice(1)};this.setParsedInfo(c,n,u),this.emit(`command:${u}`,n);break}}if(r){for(let n of this.commands)if(n.name===""){r=!1;let l=this.mri(a,n);this.setParsedInfo(l,n),this.emit("command:!",n);break}}if(r){let n=this.mri(e.slice(2));this.setParsedInfo(n)}if(this.options.verbose)this.isVerbose=!0;if(this.options.quiet)this.isQuiet=!0;if(this.options.debug)this.isDebug=!0;if(this.options.noInteraction)this.isNoInteraction=!0;if(this.options.env)this.environment=String(this.options.env);if(this.options.dryRun)this.isDryRun=!0;if(this.options.force)this.isForce=!0;if(this.options.noEmoji!==void 0)this.useEmoji=!this.options.noEmoji;if(this.options.theme)this.theme=String(this.options.theme);if(this.options.noCache!==void 0)this.isNoCache=Boolean(this.options.noCache);if(this.options.help&&this.showHelpOnExit)this.outputHelp(),s=!1,this.unsetMatchedCommand();if(this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null)this.outputVersion(),s=!1,this.unsetMatchedCommand();let o={args:this.args,options:this.options};if(s)await this.runMatchedCommand();if(!this.matchedCommand&&this.args[0]){if(this.emit("command:*"),!(this.listenerCount("command:*")>0))this.showCommandNotFound(this.args[0])}return o}mri(e,t){let s=[...this.globalCommand.options,...t?t.options:[]],i=X(s),r=[],a=e.indexOf("--");if(a>-1)r=e.slice(a+1),e=e.slice(0,a);let u=J(e,i),o={_:u._};for(let m of Object.keys(u))if(m!=="_")o[F(m)]=u[m];let n=o._,l={"--":r},c=t&&t.config.ignoreOptionDefaultValue?t.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,h=Object.create(null);for(let m of s){if(!c&&m.config.default!==void 0)for(let d of m.names)l[d]=m.config.default;if(Array.isArray(m.config.type)){if(h[m.name]===void 0)h[m.name]={shouldTransform:!0,transformFunction:m.config.type[0]}}}for(let m of Object.keys(o))if(m!=="_"){let d=m.split(".");ee(l,d,o[m]),te(l,h)}return{args:n,options:l}}async run(e=D){return this.parse(e,{run:!0,exitOnError:!0})}handleUsageError(e){if(!(!!e&&typeof e==="object"&&e.name==="ClappError"&&e.isUsageError!==!1))return;let i=e,r=i.message??"command-line error",a=this.name?`${this.name}: `:"",u=/--help/.test(r)?"":`
|
|
30
|
+
Run \`${this.name??"cli"} --help\` for usage.`;v.stderr.write(`${a}${r}${u}
|
|
31
|
+
`),v.exit(i.exitCode??2)}async runMatchedCommand(){let{args:e,options:t,matchedCommand:s}=this;if(!s||!s.commandAction)return;s.checkUnknownOptions(),s.checkOptionValue(),s.checkRequiredArgs();let i=[];s.args.forEach((o,n)=>{if(o.variadic)i.push(e.slice(n));else i.push(e[n])}),i.push(t);let r={command:s,args:i,options:t};for(let o of s.beforeHooks)await o(r);let a,u=async()=>{let o=s.commandAction.apply(this,i);if(o instanceof Promise)a=await o;else a=o;return a};if(s.middleware.length>0){let o=0,n=async()=>{if(o<s.middleware.length){let l=s.middleware[o++];await l({...r,next:n})}else await u()};await n()}else await u();for(let o of s.afterHooks)await o(r);return a}removeSignalHandlers(){if(!this.signalHandlersSet)return this;return v.removeAllListeners("SIGINT"),v.removeAllListeners("SIGTERM"),this.signalHandlersSet=!1,this}destroy(){this.removeSignalHandlers(),this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.matchedCommand=void 0,this.matchedCommandName=void 0,this.removeAllListeners()}}class G{cache;enabled;cleanupInterval=null;hits=0;misses=0;constructor(){this.cache=new Map,this.enabled=!0,this.startCleanupInterval()}startCleanupInterval(){if(this.cleanupInterval)return;this.cleanupInterval=setInterval(()=>{this.cleanup()},30000),this.cleanupInterval.unref()}stopCleanup(){if(this.cleanupInterval)clearInterval(this.cleanupInterval),this.cleanupInterval=null}isEnabled(){return this.enabled}get(e){if(!this.enabled){this.misses++;return}let t=this.cache.get(e);if(!t){this.misses++;return}if(Date.now()-t.timestamp>t.ttl){this.cache.delete(e),this.misses++;return}return this.hits++,t.value}set(e,t,s=5000){if(!this.enabled)return;this.cache.set(e,{value:t,timestamp:Date.now(),ttl:s})}has(e){if(!this.enabled)return!1;let t=this.cache.get(e);if(!t)return!1;if(Date.now()-t.timestamp>t.ttl)return this.cache.delete(e),!1;return!0}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}disable(){this.enabled=!1,this.clear()}enable(){this.enabled=!0}stats(){return{size:this.cache.size,enabled:this.enabled,hits:this.hits,misses:this.misses}}resetStats(){this.hits=0,this.misses=0}keys(){return Array.from(this.cache.keys())}cleanup(){let e=Date.now();for(let[t,s]of this.cache.entries())if(e-s.timestamp>s.ttl)this.cache.delete(t)}destroy(){this.stopCleanup(),this.clear(),this.resetStats()}}var it=new G;function he(){if("FORCE_COLOR"in C.env)return C.env.FORCE_COLOR!=="0";if("NO_COLOR"in C.env||C.env.TERM==="dumb")return!1;if(C.platform==="win32")return!0;return W.isatty(1)&&W.isatty(2)}var K=he();function p(e,t){if(!K)return(s)=>s;return(s)=>e+s+t}var me=p("\x1B[0m","\x1B[0m"),de=p("\x1B[31m","\x1B[39m"),fe=p("\x1B[32m","\x1B[39m"),pe=p("\x1B[33m","\x1B[39m"),ge=p("\x1B[34m","\x1B[39m"),$e=p("\x1B[35m","\x1B[39m"),ve=p("\x1B[36m","\x1B[39m"),we=p("\x1B[37m","\x1B[39m"),ye=p("\x1B[90m","\x1B[39m"),be=p("\x1B[1m","\x1B[22m"),xe=p("\x1B[3m","\x1B[23m"),Ce=p("\x1B[4m","\x1B[24m"),Se=p("\x1B[2m","\x1B[22m"),_e=p("\x1B[7m","\x1B[27m"),Ie=p("\x1B[8m","\x1B[28m"),Oe=p("\x1B[9m","\x1B[29m"),Ee=p("\x1B[41m","\x1B[49m"),Be=p("\x1B[42m","\x1B[49m"),Te=p("\x1B[43m","\x1B[49m"),ke=p("\x1B[44m","\x1B[49m"),Ve=p("\x1B[45m","\x1B[49m"),Me=p("\x1B[46m","\x1B[49m"),Ae=p("\x1B[47m","\x1B[49m"),Ne=K,Re={reset:me,red:de,green:fe,yellow:pe,blue:ge,magenta:$e,cyan:ve,white:we,gray:ye,bold:be,italic:xe,underline:Ce,dim:Se,inverse:_e,hidden:Ie,strikethrough:Oe,bgRed:Ee,bgGreen:Be,bgYellow:Te,bgBlue:ke,bgMagenta:Ve,bgCyan:Me,bgWhite:Ae,isColorSupported:Ne},je=Re,De=["up","down","left","right","space","enter","cancel"],ut={actions:new Set(De),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"}};var ct=Le.platform.startsWith("win"),ht=Symbol("clapp:cancel");var We=ie();var f=(e,t)=>We?e:t,mt=f("\u25C6","*"),dt=f("\u25A0","x"),ft=f("\u25B2","x"),pt=f("\u25C7","o"),gt=f("\u250C","T"),Pe=f("\u2502","|"),$t=f("\u2514","\u2014"),vt=f("\u25CF",">"),wt=f("\u25CB"," "),yt=f("\u25FB","[\u2022]"),bt=f("\u25FC","[+]"),xt=f("\u25FB","[ ]"),Ct=f("\u25AA","\u2022"),St=f("\u2500","-"),_t=f("\u256E","+"),It=f("\u251C","+"),Ot=f("\u256F","+"),Et=f("\u25CF","\u2022"),Bt=f("\u25C6","*"),Tt=f("\u25B2","!"),kt=f("\u25A0","x");var Vt={light:f("\u2500","-"),heavy:f("\u2501","="),block:f("\u2588","#")};function Fe(){return`${je.gray(Pe)} `}var Mt=Fe();export{ce as CLI};
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type { RunOptions } from './run';
|
|
2
2
|
export { config, defaultConfig } from './config';
|
|
3
3
|
export * from './format';
|
|
4
|
-
export { lintText, runLint, runLintProgrammatic } from './linter';
|
|
4
|
+
export { fixText, lintText, runLint, runLintProgrammatic } from './linter';
|
|
5
5
|
export { runFormat } from './formatter';
|
|
6
6
|
export { runUnified as run } from './run';
|
|
7
7
|
export * from './types';
|
package/dist/src/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
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-by60fzz0.js";import{M,C,x,E,P}from"../chunk-13r0v0m9.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};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lex `text` once, returning every comment, string, template-body and regex
|
|
3
|
+
* region. See the module comment for what is handled.
|
|
4
|
+
*/
|
|
5
|
+
export declare function lexSource(text: string): LexResult;
|
|
6
|
+
/**
|
|
7
|
+
* `text` with the contents of the chosen region kinds replaced by spaces.
|
|
8
|
+
*
|
|
9
|
+
* Line breaks, delimiters and length are unchanged. With no options only
|
|
10
|
+
* comments are blanked, which is the common need: prose can then never be
|
|
11
|
+
* mistaken for code. A template's `${}` expressions are code and are never
|
|
12
|
+
* blanked.
|
|
13
|
+
*/
|
|
14
|
+
export declare function maskSource(text: string, options?: MaskOptions, lexed?: LexResult): string;
|
|
15
|
+
/** Every comment's contents blanked; everything else as written. */
|
|
16
|
+
export declare function maskComments(text: string): string;
|
|
17
|
+
/** Only code left: comments, strings, template bodies and regex patterns blanked. */
|
|
18
|
+
export declare function maskNonCode(text: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* For each line, whether it begins inside a template-literal body - between
|
|
21
|
+
* a backtick (or the `}` closing a `${}`) and the next backtick or `${`.
|
|
22
|
+
*
|
|
23
|
+
* A line that begins inside a `${}` expression is code, not template text.
|
|
24
|
+
*/
|
|
25
|
+
export declare function lineStartsInTemplate(text: string, lexed?: LexResult): boolean[];
|
|
26
|
+
export declare interface Region {
|
|
27
|
+
kind: RegionKind
|
|
28
|
+
start: number
|
|
29
|
+
end: number
|
|
30
|
+
}
|
|
31
|
+
export declare interface LexResult {
|
|
32
|
+
regions: Region[]
|
|
33
|
+
templates: Array<[number, number]>
|
|
34
|
+
}
|
|
35
|
+
export declare interface MaskOptions {
|
|
36
|
+
comments?: boolean
|
|
37
|
+
strings?: boolean
|
|
38
|
+
templates?: boolean
|
|
39
|
+
regex?: boolean
|
|
40
|
+
}
|
|
41
|
+
/*` or a quote still
|
|
42
|
+
* find them.
|
|
43
|
+
*/
|
|
44
|
+
export type RegionKind = 'comment' | 'string' | 'template' | 'regex';
|
package/dist/src/linter.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import type { LintIssue, LintOptions, PickierConfig } from './types';
|
|
2
2
|
// Programmatic single-text lint with optional cancellation
|
|
3
3
|
export declare function lintText(text: string, cfg: PickierConfig, filePath?: string, signal?: AbortSignal): Promise<LintIssue[]>;
|
|
4
|
+
/**
|
|
5
|
+
* The text `pickier --fix` would write for a file with this content.
|
|
6
|
+
*
|
|
7
|
+
* `runLint` reads and writes files; an editor needs the same fixes applied to
|
|
8
|
+
* an unsaved buffer and handed back as text. This is that, and `runLint`
|
|
9
|
+
* calls it too, so a fix-all in an editor and `pickier --fix` on disk cannot
|
|
10
|
+
* drift apart.
|
|
11
|
+
*/
|
|
12
|
+
export declare function fixText(text: string, cfg: PickierConfig, filePath?: string): string;
|
|
4
13
|
// Programmatic batch lint returning structured result, with optional cancellation
|
|
5
14
|
export declare function runLintProgrammatic(globs: string[], options: LintOptions, signal?: AbortSignal): Promise<{ errors: number, warnings: number, issues: LintIssue[] }>;
|
|
6
15
|
export declare function applyPlugins(filePath: string, content: string, cfg: PickierConfig): Promise<Array<any>> /* PluginLintIssue[] */;
|
|
@@ -9,23 +9,10 @@
|
|
|
9
9
|
* applying lint rules to them produces false positives that fixers will
|
|
10
10
|
* happily turn into broken runtime code.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* character on the logical statement: `/` after operators / punctuation
|
|
18
|
-
* starts a regex; `/` after an identifier or closing bracket is division.
|
|
12
|
+
* This was a scanner of its own, and it got two things wrong that the shared
|
|
13
|
+
* lexer gets right: a regex after a keyword (`return /it's/`) read as
|
|
14
|
+
* division, so its quote opened a string, and a quoted string did not end at
|
|
15
|
+
* the end of its line. Either one left the state inverted for the rest of the
|
|
16
|
+
* file, so the lines *outside* every template were the ones skipped.
|
|
19
17
|
*/
|
|
20
18
|
export declare function computeLineStartsInTemplate(text: string): boolean[];
|
|
21
|
-
/**
|
|
22
|
-
* On a single line, return [start, end] ranges of characters that fall
|
|
23
|
-
* inside a backtick-bounded template literal. If a backtick opens but
|
|
24
|
-
* doesn't close on this line, the range extends to the line's end (it's
|
|
25
|
-
* the first line of a multi-line template).
|
|
26
|
-
*
|
|
27
|
-
* Used by per-line fixers to refuse to rewrite identifiers that fall
|
|
28
|
-
* inside an embedded code blob whose other usages live in the same
|
|
29
|
-
* template string and aren't visible to the syntactic rename.
|
|
30
|
-
*/
|
|
31
|
-
export declare function backtickRangesOnLine(line: string): Array<[number, number]>;
|
|
@@ -1,3 +1,15 @@
|
|
|
1
1
|
import type { RuleModule } from '../../types';
|
|
2
|
+
/*`, `*\/` and
|
|
3
|
+
* `//` delimiters stay, so the scanners that look for them still work; the
|
|
4
|
+
* length and the line breaks are unchanged, so every reported column still
|
|
5
|
+
* points where it did; and a name that appears only in a comment is now
|
|
6
|
+
* correctly not a use, which is what the rule meant all along.
|
|
7
|
+
*
|
|
8
|
+
* Finding the comments is the shared lexer's job ({@link maskComments}): it
|
|
9
|
+
* is the one place that knows a regex ending in `\/` is not a line comment, a
|
|
10
|
+
* template nested in `${}` is not the end of its parent, and a backtick or an
|
|
11
|
+
* apostrophe inside a comment is prose. This used to be a scanner of its own
|
|
12
|
+
* here, and every rule that had one got a different subset of that wrong.
|
|
13
|
+
*/
|
|
2
14
|
export declare function maskCommentText(text: string): string;
|
|
3
15
|
export declare const noUnusedVarsRule: RuleModule;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { RuleModule } from '../../types';
|
|
2
2
|
// Heuristic: flag 'await' only when at top level (brace depth 0),
|
|
3
|
-
// outside of comments/strings/templates, and not part of 'for await'.
|
|
3
|
+
// outside of comments/strings/templates/regexes, and not part of 'for await'.
|
|
4
|
+
//
|
|
5
|
+
// The scan runs over the shared lexer's code-only view of the file. It used to
|
|
6
|
+
// track strings and comments itself, without regex literals: the `/*` inside
|
|
7
|
+
// `/\/?\*\*\/*\*\*$/` opened a block comment, and from there a backtick or an
|
|
8
|
+
// apostrophe in a real comment further down decided the brace depth - so an
|
|
9
|
+
// `await` inside a function was reported as top-level, or a real one missed.
|
|
4
10
|
export declare const noTopLevelAwaitRule: RuleModule;
|
package/package.json
CHANGED
package/dist/chunk-awmb5sg5.js
DELETED
package/dist/chunk-bnbsk67m.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{b as a,c as b,d as c,e as d,f as e,g as f}from"./chunk-tskywgx9.js";import"./chunk-vdbbvx8x.js";import"./chunk-gy6wyx8t.js";import"./chunk-awmb5sg5.js";export{c as applyPlugins,a as lintText,f as runLint,b as runLintProgrammatic,e as scanContent,d as scanContentOptimized};
|