ultracite 7.9.2 → 7.9.3
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/config/eslint/core/rules/n.mjs +1 -0
- package/config/oxlint/core/index.mjs +3 -241
- package/config/oxlint/js-plugins/index.d.mts +5 -0
- package/config/oxlint/js-plugins/index.mjs +474 -0
- package/config/oxlint/next/index.mjs +0 -27
- package/config/oxlint/react/index.mjs +6 -158
- package/config/oxlint/tanstack/index.mjs +0 -26
- package/dist/index.js +45 -45
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createRequire as xb}from"node:module";var
|
|
3
|
-
`)},d0=/^[a-z][a-z0-9-]*$/u,S=(b)=>{if(!d0.test(b))throw Error(`Invalid framework name "${b}": must match ${d0}`);return b},q=["biome.json","biome.jsonc",".biome.json",".biome.jsonc"],M=["eslint.config.mjs","eslint.config.js","eslint.config.cjs","eslint.config.ts","eslint.config.mts","eslint.config.cts"],D0=[".eslintrc",".eslintrc.json",".eslintrc.js",".eslintrc.cjs",".eslintrc.yaml",".eslintrc.yml"],C=[".prettierrc.mjs","prettier.config.mjs",".prettierrc.mts","prettier.config.mts",".prettierrc.cjs","prettier.config.cjs",".prettierrc.cts","prettier.config.cts",".prettierrc.js","prettier.config.js",".prettierrc.ts","prettier.config.ts",".prettierrc",".prettierrc.json",".prettierrc.json5",".prettierrc.yml",".prettierrc.yaml",".prettierrc.toml"],i=[".stylelintrc.mjs","stylelint.config.mjs",".stylelintrc.cjs","stylelint.config.cjs",".stylelintrc.js","stylelint.config.js",".stylelintrc",".stylelintrc.json",".stylelintrc.yml",".stylelintrc.yaml"],g1=[".oxlintrc.json","oxlint.config.ts"],N0=["oxfmt.config.ts"],kb={"@angular/core":["angular"],"@builder.io/qwik":["qwik"],"@nestjs/core":["nestjs"],"@qwik.dev/core":["qwik"],"@remix-run/node":["remix"],"@remix-run/react":["react","remix"],"@tanstack/react-query":["react","tanstack"],"@tanstack/react-router":["react","tanstack"],"@tanstack/react-start":["react","tanstack"],astro:["astro"],jest:["jest"],next:["react","next"],nuxt:["vue"],react:["react"],"react-router":["react","remix"],"solid-js":["solid"],svelte:["svelte"],vitest:["vitest"],vue:["vue"]},J0=(b)=>{if(!b)return[];return[...Object.keys(b.dependencies??{}),...Object.keys(b.devDependencies??{}),...Object.keys(b.peerDependencies??{})]},sb=async(b)=>{let y=new Set,$=b?.workspaces;if(Array.isArray($))for(let G of $)y.add(G);else if($&&typeof $==="object"){let{packages:G}=$;if(Array.isArray(G)){for(let v of G)if(typeof v==="string")y.add(v)}}if(H(i1))try{let G=await Pb(i1,"utf-8"),v=lb.parse(G);if(Array.isArray(v?.packages)){for(let U of v.packages)if(typeof U==="string")y.add(U)}}catch{}return[...y]},L0=async()=>{let b=new Set;try{let y=await s(),$=new Set(J0(y)),G=await sb(y);if(G.length>0){let v=await Mb(G.map((Q)=>`${Q.replace(/\/+$/u,"")}/package.json`),{absolute:!1,ignore:["**/node_modules/**"]}),U=await Promise.all(v.map((Q)=>s(Q)));for(let Q of U)for(let W of J0(Q))$.add(W)}for(let v of $){let U=kb[v];if(U)for(let Q of U)b.add(Q)}}catch{}return[...b]},t=(b=C1.cwd())=>{let y=b;while(!0){for(let G of q)if(H(D.join(y,G)))return"biome";for(let G of M)if(H(D.join(y,G)))return"eslint";for(let G of g1)if(H(D.join(y,G)))return"oxlint";let $=D.dirname(y);if($===y)break;y=$}return null};var Cb=(b,y)=>{let $=["check","--no-errors-on-unmatched",...y];if(b.length>0)$.push(...b);else $.push("./");let G=j("biome",$,{stdio:"inherit"});d("Biome",G)},ib=(b,y)=>{let $=[...y,...b.length>0?b:["."]],G=j("eslint",$,{stdio:"inherit"});d("ESLint",G)},tb=(b,y)=>{let $=["--check",...y,...b.length>0?b:["."]],G=j("prettier",$,{stdio:"inherit"});d("Prettier",G)},gb=(b,y)=>{let $=x1(b);if($.length===0)return;let G=[...y,"--allow-empty-input",...$],v=j("stylelint",G,{stdio:"inherit"});d("Stylelint",v)},ab=(b,y)=>{let $=[...y,...b.length>0?b:["."]],G=j("oxlint",$,{stdio:"inherit"});d("Oxlint",G)},eb=(b,y)=>{let $=["--check",...y,...b.length>0?b:["."]],G=j("oxfmt",$,{stdio:"inherit"});d("oxfmt",G)},x0=(b=[],y=[])=>{let $=t(),G=L1(b);if(!$)throw Error("No linter configuration found. Run `ultracite init` to set up a linter.");switch($){case"eslint":{n([()=>tb(G,[]),()=>ib(G,y),()=>gb(G,[])]);break}case"oxlint":{n([()=>eb(G,[]),()=>ab(G,y)]);break}default:Cb(G,y)}};import{existsSync as m,readFileSync as m1}from"node:fs";import _ from"node:path";import F from"node:process";import{intro as by,log as I,outro as R1,spinner as yy}from"@clack/prompts";import{parse as $y}from"jsonc-parser";var U1="Biome configuration",Q1="ESLint configuration",a1="Prettier configuration",e1="Stylelint configuration",W1="Oxlint configuration",Z1="oxfmt configuration",z1="Ultracite dependency",b0="Conflicting tools",I1="Doctor complete",g=(b,y)=>{let $=j(b,["--version"],{encoding:"utf-8"});if($.status===0&&$.stdout)return{message:`${b} is installed (${String($.stdout).trim()})`,name:`${b} installation`,status:"pass"};return{message:`${b} is not installed${y?"":" (optional)"}`,name:`${b} installation`,status:y?"fail":"warn"}},Gy=()=>{let b=null,y=null;for(let $ of q){let G=_.join(F.cwd(),$);if(m(G)){b=G,y=$;break}}if(!b)return{message:`No Biome config file found (expected one of: ${q.join(", ")})`,name:U1,status:"fail"};try{let $=m1(b,"utf-8"),G=$y($);if(Array.isArray(G?.extends)&&G.extends.includes("ultracite/biome/core"))return{message:`${y} extends ultracite/biome/core`,name:U1,status:"pass"};return{message:`${y} exists but doesn't extend ultracite/biome/core`,name:U1,status:"warn"}}catch{return{message:`Could not parse ${y} file`,name:U1,status:"fail"}}},vy=()=>{let b=null;for(let y of M){let $=_.join(F.cwd(),y);if(m($)){b=$;break}}if(!b)return{message:"No eslint.config.* file found",name:Q1,status:"fail"};try{if(m1(b,"utf-8").includes("ultracite/eslint"))return{message:"eslint.config.* imports ultracite/eslint",name:Q1,status:"pass"};return{message:"eslint.config.* exists but doesn't import ultracite/eslint",name:Q1,status:"warn"}}catch{return{message:"Could not read eslint.config.* file",name:Q1,status:"fail"}}},Uy=()=>{for(let b of C)if(m(_.join(F.cwd(),b)))return{message:`Prettier configuration found (${b})`,name:a1,status:"pass"};return{message:"No Prettier configuration found",name:a1,status:"fail"}},Qy=()=>{for(let b of i)if(m(_.join(F.cwd(),b)))return{message:`Stylelint configuration found (${b})`,name:e1,status:"pass"};return{message:"No Stylelint configuration found",name:e1,status:"warn"}},Wy=()=>{let b=_.join(F.cwd(),"oxlint.config.ts");if(!m(b))return{message:"No oxlint.config.ts file found",name:W1,status:"fail"};try{if(m1(b,"utf-8").includes("ultracite/oxlint/"))return{message:"oxlint.config.ts extends ultracite oxlint config",name:W1,status:"pass"};return{message:"oxlint.config.ts exists but doesn't extend ultracite config",name:W1,status:"warn"}}catch{return{message:"Could not read oxlint.config.ts file",name:W1,status:"fail"}}},Zy=()=>{let b=_.join(F.cwd(),"oxfmt.config.ts");if(!m(b))return{message:"No oxfmt.config.ts file found",name:Z1,status:"fail"};try{if(m1(b,"utf-8").includes("ultracite/oxfmt"))return{message:"oxfmt.config.ts extends ultracite oxfmt config",name:Z1,status:"pass"};return{message:"oxfmt.config.ts exists but doesn't extend ultracite config",name:Z1,status:"warn"}}catch{return{message:"Could not read oxfmt.config.ts file",name:Z1,status:"fail"}}},zy=()=>{let b=_.join(F.cwd(),"package.json");if(!m(b))return{message:"No package.json found",name:z1,status:"warn"};let y=p(b);if(!y)return{message:"Could not parse package.json",name:z1,status:"warn"};let $=y.dependencies?.ultracite||y.devDependencies?.ultracite||y.peerDependencies?.ultracite;if($)return{message:`Ultracite is in package.json (${$})`,name:z1,status:"pass"};return{message:"Ultracite not found in package.json dependencies",name:z1,status:"warn"}},Yy=(b)=>{let y=[];if(b!=="eslint"){if([".prettierrc",".prettierrc.js",".prettierrc.cjs",".prettierrc.mjs",".prettierrc.json",".prettierrc.yaml",".prettierrc.yml","prettier.config.js","prettier.config.mjs","prettier.config.cjs"].some((v)=>m(_.join(F.cwd(),v))))y.push("Prettier")}if([".eslintrc",".eslintrc.js",".eslintrc.cjs",".eslintrc.mjs",".eslintrc.json",".eslintrc.yaml",".eslintrc.yml"].some((G)=>m(_.join(F.cwd(),G))))y.push("ESLint (legacy config)");if(y.length>0)return{message:`Found potentially conflicting tools: ${y.join(", ")}`,name:b0,status:"warn"};return{message:"No conflicting formatting/linting tools found",name:b0,status:"pass"}},Hy=(b)=>{let y=[];switch(b){case"biome":{y.push({fn:()=>g("biome",!0),name:"Biome installation"},{fn:Gy,name:U1});break}case"eslint":{y.push({fn:()=>g("eslint",!0),name:"ESLint installation"},{fn:vy,name:Q1},{fn:()=>g("prettier",!0),name:"Prettier installation"},{fn:Uy,name:a1},{fn:()=>g("stylelint",!1),name:"Stylelint installation"},{fn:Qy,name:e1});break}case"oxlint":{y.push({fn:()=>g("oxlint",!0),name:"Oxlint installation"},{fn:Wy,name:W1},{fn:()=>g("oxfmt",!0),name:"oxfmt installation"},{fn:Zy,name:Z1});break}default:break}return y.push({fn:zy,name:z1},{fn:()=>Yy(b),name:b0}),y},S0=()=>{by(`Ultracite v${z.version} Doctor`);let b=t();if(!b)throw I.error("No linter configuration found. Run `ultracite init` to set up a linter."),R1(I1),Error("Doctor checks failed");I.info(`Detected linter: ${b}`);let y=yy();y.start("Running diagnostics...");let G=Hy(b).map(({fn:W})=>W());y.stop("Diagnostics complete.");for(let W of G)if(W.status==="pass")I.success(W.message);else if(W.status==="warn")I.warn(W.message);else I.error(W.message);let v=G.filter((W)=>W.status==="pass").length,U=G.filter((W)=>W.status==="fail").length,Q=G.filter((W)=>W.status==="warn").length;if(I.info(`Summary: ${v} passed, ${Q} warnings, ${U} failed`),U>0)throw I.error("Some checks failed. Run 'ultracite init' to fix issues."),R1(I1),Error("Doctor checks failed");if(Q>0){I.warn("Some optional improvements available. Run 'ultracite init' to configure."),R1(I1);return}I.success("Everything looks good!"),R1(I1)};var oy=(b,y)=>{let $=["check","--write","--no-errors-on-unmatched",...y];if(b.length>0)$.push(...b);else $.push("./");let G=j("biome",$,{stdio:"inherit"});d("Biome",G)},Vy=(b,y)=>{let $=["--fix",...y,...b.length>0?b:["."]],G=j("eslint",$,{stdio:"inherit"});d("ESLint",G)},By=(b,y)=>{let $=["--write",...y,...b.length>0?b:["."]],G=j("prettier",$,{stdio:"inherit"});d("Prettier",G)},Xy=(b,y)=>{let $=x1(b);if($.length===0)return;let G=["--fix",...y,"--allow-empty-input",...$],v=j("stylelint",G,{stdio:"inherit"});d("Stylelint",v)},jy=(b,y)=>{let $=y.includes("--unsafe"),G=y.filter((Q)=>Q!=="--unsafe"),v=[$?"--fix-dangerously":"--fix",...G,...b.length>0?b:["."]],U=j("oxlint",v,{stdio:"inherit"});d("Oxlint",U)},Ky=(b,y)=>{let $=["--write",...y,...b.length>0?b:["."]],G=j("oxfmt",$,{stdio:"inherit"});d("oxfmt",G)},R0=(b,y=[])=>{let $=t(),G=L1(b);if(!$)throw Error("No linter configuration found. Run `ultracite init` to set up a linter.");switch($){case"eslint":{n([()=>By(G,[]),()=>Vy(G,y),()=>Xy(G,[])]);break}case"oxlint":{n([()=>Ky(G,[]),()=>jy(G,y)]);break}default:oy(G,y)}};import c2 from"node:process";import{cancel as y1,intro as q2,isCancel as $1,log as d1,multiselect as J1,select as P2,spinner as w}from"@clack/prompts";import{addDevDependency as f2,detectPackageManager as M2}from"nypm";import{readFile as Ay}from"node:fs/promises";import{dlxCommand as wy}from"nypm";var y0=(b,y)=>`# Ultracite Code Standards
|
|
2
|
+
import{createRequire as xb}from"node:module";var Nb=xb(import.meta.url);import o1 from"node:process";import{Command as Z$}from"commander";var z={name:"ultracite",version:"7.9.3",description:"The AI-ready formatter that helps you write and generate code faster.",keywords:["biome","fixer","formatter","linter","ultracite"],homepage:"https://www.ultracite.ai/",bugs:{url:"https://github.com/haydenbleasel/ultracite/issues"},license:"MIT",author:"Hayden Bleasel <hello@haydenbleasel.com>",repository:{type:"git",url:"git+https://github.com/haydenbleasel/ultracite.git"},bin:{ultracite:"dist/index.js"},files:["config","dist","README.md"],type:"module",exports:{"./biome/*":"./config/biome/*/biome.jsonc","./eslint/*":"./config/eslint/*/eslint.config.mjs","./oxlint/*":{types:"./config/oxlint/*/index.d.mts",default:"./config/oxlint/*/index.mjs"},"./oxfmt":{types:"./config/oxfmt/index.d.mts",default:"./config/oxfmt/index.mjs"},"./prettier":"./config/prettier/prettier.config.mjs","./stylelint":"./config/stylelint/stylelint.config.mjs"},publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},scripts:{prebuild:"bun run scripts/generate-dts.ts",build:"tsgo --noEmit && bun run build.ts",test:"bun test","test:coverage":"bun test --coverage",bench:"bun run benchmarks/cli.bench.ts",types:"tsgo --noEmit"},dependencies:{"@clack/prompts":"^1.5.1","@typescript-eslint/utils":"^8.62.1",commander:"^15.0.0","cross-spawn":"^7.0.6",deepmerge:"^4.3.1",glob:"^13.0.6","jsonc-parser":"^3.3.1",nypm:"^0.6.6",yaml:"^2.9.0",zod:"^4.4.3"},devDependencies:{"@angular-eslint/eslint-plugin":"^22.0.0","@biomejs/biome":"2.5.2","@darraghor/eslint-plugin-nestjs-typed":"^7.2.5","@eslint/js":"^10.0.0","@next/eslint-plugin-next":"^16.2.10","@tanstack/eslint-plugin-query":"^5.101.2","@tanstack/eslint-plugin-router":"^1.162.0","@tanstack/eslint-plugin-start":"^0.1.0","@types/bun":"^1.3.14","@types/cross-spawn":"^6.0.6","@types/node":"^25.9.2","@typescript-eslint/eslint-plugin":"^8.62.1","@typescript-eslint/parser":"^8.62.1","@vitest/eslint-plugin":"^1.6.21",eslint:"^10.0.0","eslint-config-prettier":"^10.1.8","eslint-import-resolver-typescript":"^4.4.5","eslint-plugin-astro":"^2.1.1","eslint-plugin-compat":"^7.0.2","eslint-plugin-cypress":"^6.4.2","eslint-plugin-github":"6.0.0","eslint-plugin-html":"^8.1.4","eslint-plugin-import-x":"^4.17.1","eslint-plugin-jest":"^29.15.4","eslint-plugin-jsdoc":"^63.0.11","eslint-plugin-jsx-a11y":"^6.10.2","eslint-plugin-n":"^18.2.1","eslint-plugin-prettier":"^5.5.6","eslint-plugin-promise":"^7.3.0","eslint-plugin-qwik":"^1.20.0","eslint-plugin-react":"^7.37.5","eslint-plugin-react-doctor":"^0.7.1","eslint-plugin-react-hooks":"^7.1.1","eslint-plugin-remix":"^1.1.1","eslint-plugin-solid":"^0.14.5","eslint-plugin-sonarjs":"^4.1.0","eslint-plugin-storybook":"^10.4.6","eslint-plugin-svelte":"^3.20.0","eslint-plugin-unicorn":"^70.0.0","eslint-plugin-unused-imports":"^4.4.1","eslint-plugin-vue":"^10.9.2",globals:"^17.7.0",oxlint:"^1.73.0","oxlint-plugin-react-doctor":"^0.7.1","prettier-plugin-astro":"^0.14.1","prettier-plugin-svelte":"^4.1.0","prettier-plugin-tailwindcss":"^0.8.0",storybook:"^10.4.6","stylelint-config-idiomatic-order":"^10.0.0","stylelint-config-standard":"^40.0.0","stylelint-prettier":"^5.0.3"},peerDependencies:{oxfmt:">=0.1.0",oxlint:"^1.0.0"},peerDependenciesMeta:{oxfmt:{optional:!0},oxlint:{optional:!0}},packageManager:"bun@1.3.14"};import{existsSync as Lb}from"node:fs";import Rb from"node:path";var Ib=(b,y,$)=>{let G=$?.indexOf(b)??-1;if(!$||G===-1)return y;return $.slice(G+1)},N1=(b)=>b.map((y)=>y.startsWith("-")?`./${y}`:y),l1="**/*.{css,scss,sass,less}",Fb=[".css",".scss",".sass",".less"],_b=(b)=>{let y=b.toLowerCase();return Fb.some(($)=>y.endsWith($))},S1=(b)=>{if(b.length===0)return[l1];let y=[];for(let $ of b){if(_b($)){y.push($);continue}if(Rb.extname($)===""){let G=$.replace(/\/+$/u,"");y.push(G==="."||G===""?l1:`${G}/${l1}`)}}return y},C1=({commandName:b,parsedArgs:y,pathExists:$=Lb,rawArgs:G})=>{let v=Ib(b,y,G),U=v.indexOf("--");if(U!==-1)return{files:v.slice(U+1),passthrough:v.slice(0,U)};let Q=[],W=[];for(let X of v){if(X.startsWith("-")&&!$(X)){W.push(X);continue}Q.push(X)}return{files:Q,passthrough:W}};import{sync as mb}from"cross-spawn";class r extends Error{commandName;exitCode;name="LinterExitError";constructor(b,y){super(`${b} exited with code ${y}`);this.commandName=b,this.exitCode=y}}var w=(b,y,$)=>mb(b,y,{...$,shell:!1}),D=(b,y)=>{if(y.error)throw Error(`Failed to run ${b}: ${y.error.message}`);if(y.status===null)throw Error(`${b} was killed by signal ${y.signal??"unknown"}`);if(y.status!==0)throw new r(b,y.status)},l=(b)=>{let y=null;for(let $ of b)try{$()}catch(G){if(G instanceof r){y??=G;continue}throw G}if(y)throw new r(y.commandName,y.exitCode)};import{accessSync as qb,lstatSync as A0,mkdirSync as Eb,realpathSync as J0}from"node:fs";import{readFile as Mb,writeFile as pb}from"node:fs/promises";import o from"node:path";import n1 from"node:process";import{glob as cb}from"glob";import fb from"yaml";import{readFileSync as hb}from"node:fs";import{readFile as Ob}from"node:fs/promises";import{parse as j0}from"jsonc-parser";import{z as B}from"zod";var Tb=B.looseObject({dependencies:B.record(B.string(),B.string()).optional(),devDependencies:B.record(B.string(),B.string()).optional(),"lint-staged":B.unknown().optional(),name:B.string().optional(),peerDependencies:B.record(B.string(),B.string()).optional(),prettier:B.unknown().optional(),scripts:B.record(B.string(),B.string()).optional(),stylelint:B.unknown().optional(),type:B.string().optional(),version:B.string().optional(),workspace:B.unknown().optional(),workspaces:B.union([B.array(B.string()),B.record(B.string(),B.unknown())]).optional()}),C=(b)=>{let y=j0(b),$=Tb.safeParse(y);return $.success?$.data:void 0},E=(b="package.json")=>{try{let y=hb(b,"utf-8");return C(y)}catch{return}},s=async(b="package.json")=>{try{let y=await Ob(b,"utf-8");return C(y)}catch{return}},w0=B.looseObject({extends:B.array(B.string()).optional()}),K0=B.looseObject({compilerOptions:B.looseObject({strict:B.boolean().optional(),strictNullChecks:B.boolean().optional()}).optional()}),L1=(b,y)=>{let $=j0(b),G=y.safeParse($);return G.success?G.data:void 0};var i1="pnpm-workspace.yaml",H=(b)=>{try{return qb(b),!0}catch{return!1}},M=()=>{if(H(i1))return!0;let b=E();if(!b)return!1;return!!b.workspaces||!!b.workspace},S=(b)=>{let y=o.dirname(b);if(y!=="."){let $=y.startsWith("./")?y.slice(2):y;Eb($,{recursive:!0})}},s1=(b,y)=>{let $=o.relative(y,b);return $===""||!$.startsWith("..")&&!o.isAbsolute($)},t1=(b)=>typeof J0==="function"?J0(b):o.resolve(b),Pb=(b)=>{let y=b;while(!0)try{return t1(y)}catch($){if($.code!=="ENOENT")throw $;let G=o.dirname(y);if(G===y)return o.resolve(y);y=G}},kb=(b)=>{let y=t1(n1.cwd()),$=o.resolve(n1.cwd(),b);if(!s1($,y))throw Error(`Refusing to write outside project: ${b}`);let G=o.dirname($),v=Pb(G);if(!s1(v,y))throw Error(`Refusing to write through directory outside project: ${b}`);try{if((typeof A0==="function"?A0($):void 0)?.isSymbolicLink())throw Error(`Refusing to write through symbolic link: ${b}`);let Q=t1($);if(!s1(Q,y))throw Error(`Refusing to write outside project: ${b}`)}catch(U){if(U.code==="ENOENT")return;throw U}},Z=async(b,y)=>{kb(b),S(b),await pb(b,y)},N=async({dependencies:b,devDependencies:y,scripts:$,type:G})=>{let v=await s();if(!v)throw Error("Failed to parse package.json: file is missing or invalid");let U={...v};if(G)U.type=G;if(v.devDependencies||y)U.devDependencies={...v.devDependencies,...y};if(v.dependencies||b)U.dependencies={...v.dependencies,...b};if(v.scripts||$)U.scripts={...v.scripts,...$};await Z("package.json",`${JSON.stringify(U,null,2)}
|
|
3
|
+
`)},u0=/^[a-z][a-z0-9-]*$/u,L=(b)=>{if(!u0.test(b))throw Error(`Invalid framework name "${b}": must match ${u0}`);return b},p=["biome.json","biome.jsonc",".biome.json",".biome.jsonc"],P=["eslint.config.mjs","eslint.config.js","eslint.config.cjs","eslint.config.ts","eslint.config.mts","eslint.config.cts"],d0=[".eslintrc",".eslintrc.json",".eslintrc.js",".eslintrc.cjs",".eslintrc.yaml",".eslintrc.yml"],n=[".prettierrc.mjs","prettier.config.mjs",".prettierrc.mts","prettier.config.mts",".prettierrc.cjs","prettier.config.cjs",".prettierrc.cts","prettier.config.cts",".prettierrc.js","prettier.config.js",".prettierrc.ts","prettier.config.ts",".prettierrc",".prettierrc.json",".prettierrc.json5",".prettierrc.yml",".prettierrc.yaml",".prettierrc.toml"],i=[".stylelintrc.mjs","stylelint.config.mjs",".stylelintrc.cjs","stylelint.config.cjs",".stylelintrc.js","stylelint.config.js",".stylelintrc",".stylelintrc.json",".stylelintrc.yml",".stylelintrc.yaml"],g1=[".oxlintrc.json","oxlint.config.ts"],o0=["oxfmt.config.ts"],rb={"@angular/core":["angular"],"@builder.io/qwik":["qwik"],"@nestjs/core":["nestjs"],"@qwik.dev/core":["qwik"],"@remix-run/node":["remix"],"@remix-run/react":["react","remix"],"@tanstack/react-query":["react","tanstack"],"@tanstack/react-router":["react","tanstack"],"@tanstack/react-start":["react","tanstack"],astro:["astro"],jest:["jest"],next:["react","next"],nuxt:["vue"],react:["react"],"react-router":["react","remix"],"solid-js":["solid"],svelte:["svelte"],vitest:["vitest"],vue:["vue"]},D0=(b)=>{if(!b)return[];return[...Object.keys(b.dependencies??{}),...Object.keys(b.devDependencies??{}),...Object.keys(b.peerDependencies??{})]},lb=async(b)=>{let y=new Set,$=b?.workspaces;if(Array.isArray($))for(let G of $)y.add(G);else if($&&typeof $==="object"){let{packages:G}=$;if(Array.isArray(G)){for(let v of G)if(typeof v==="string")y.add(v)}}if(H(i1))try{let G=await Mb(i1,"utf-8"),v=fb.parse(G);if(Array.isArray(v?.packages)){for(let U of v.packages)if(typeof U==="string")y.add(U)}}catch{}return[...y]},x0=async()=>{let b=new Set;try{let y=await s(),$=new Set(D0(y)),G=await lb(y);if(G.length>0){let v=await cb(G.map((Q)=>`${Q.replace(/\/+$/u,"")}/package.json`),{absolute:!1,ignore:["**/node_modules/**"]}),U=await Promise.all(v.map((Q)=>s(Q)));for(let Q of U)for(let W of D0(Q))$.add(W)}for(let v of $){let U=rb[v];if(U)for(let Q of U)b.add(Q)}}catch{}return[...b]},t=(b=n1.cwd())=>{let y=b;while(!0){for(let G of p)if(H(o.join(y,G)))return"biome";for(let G of P)if(H(o.join(y,G)))return"eslint";for(let G of g1)if(H(o.join(y,G)))return"oxlint";let $=o.dirname(y);if($===y)break;y=$}return null};var Cb=(b,y)=>{let $=["check","--no-errors-on-unmatched",...y];if(b.length>0)$.push(...b);else $.push("./");let G=w("biome",$,{stdio:"inherit"});D("Biome",G)},sb=(b,y)=>{let $=[...y,...b.length>0?b:["."]],G=w("eslint",$,{stdio:"inherit"});D("ESLint",G)},nb=(b,y)=>{let $=["--check",...y,...b.length>0?b:["."]],G=w("prettier",$,{stdio:"inherit"});D("Prettier",G)},ib=(b,y)=>{let $=S1(b);if($.length===0)return;let G=[...y,"--allow-empty-input",...$],v=w("stylelint",G,{stdio:"inherit"});D("Stylelint",v)},tb=(b,y)=>{let $=[...y,...b.length>0?b:["."]],G=w("oxlint",$,{stdio:"inherit"});D("Oxlint",G)},gb=(b,y)=>{let $=["--check",...y,...b.length>0?b:["."]],G=w("oxfmt",$,{stdio:"inherit"});D("oxfmt",G)},N0=(b=[],y=[])=>{let $=t(),G=N1(b);if(!$)throw Error("No linter configuration found. Run `ultracite init` to set up a linter.");switch($){case"eslint":{l([()=>nb(G,[]),()=>sb(G,y),()=>ib(G,[])]);break}case"oxlint":{l([()=>gb(G,[]),()=>tb(G,y)]);break}default:Cb(G,y)}};import{existsSync as F,readFileSync as F1}from"node:fs";import _ from"node:path";import m from"node:process";import{intro as ab,log as I,outro as R1,spinner as eb}from"@clack/prompts";import{parse as by}from"jsonc-parser";var U1="Biome configuration",Q1="ESLint configuration",a1="Prettier configuration",e1="Stylelint configuration",W1="Oxlint configuration",Z1="oxfmt configuration",z1="Ultracite dependency",b0="Conflicting tools",I1="Doctor complete",g=(b,y)=>{let $=w(b,["--version"],{encoding:"utf-8"});if($.status===0&&$.stdout)return{message:`${b} is installed (${String($.stdout).trim()})`,name:`${b} installation`,status:"pass"};return{message:`${b} is not installed${y?"":" (optional)"}`,name:`${b} installation`,status:y?"fail":"warn"}},yy=()=>{let b=null,y=null;for(let $ of p){let G=_.join(m.cwd(),$);if(F(G)){b=G,y=$;break}}if(!b)return{message:`No Biome config file found (expected one of: ${p.join(", ")})`,name:U1,status:"fail"};try{let $=F1(b,"utf-8"),G=by($);if(Array.isArray(G?.extends)&&G.extends.includes("ultracite/biome/core"))return{message:`${y} extends ultracite/biome/core`,name:U1,status:"pass"};return{message:`${y} exists but doesn't extend ultracite/biome/core`,name:U1,status:"warn"}}catch{return{message:`Could not parse ${y} file`,name:U1,status:"fail"}}},$y=()=>{let b=null;for(let y of P){let $=_.join(m.cwd(),y);if(F($)){b=$;break}}if(!b)return{message:"No eslint.config.* file found",name:Q1,status:"fail"};try{if(F1(b,"utf-8").includes("ultracite/eslint"))return{message:"eslint.config.* imports ultracite/eslint",name:Q1,status:"pass"};return{message:"eslint.config.* exists but doesn't import ultracite/eslint",name:Q1,status:"warn"}}catch{return{message:"Could not read eslint.config.* file",name:Q1,status:"fail"}}},Gy=()=>{for(let b of n)if(F(_.join(m.cwd(),b)))return{message:`Prettier configuration found (${b})`,name:a1,status:"pass"};return{message:"No Prettier configuration found",name:a1,status:"fail"}},vy=()=>{for(let b of i)if(F(_.join(m.cwd(),b)))return{message:`Stylelint configuration found (${b})`,name:e1,status:"pass"};return{message:"No Stylelint configuration found",name:e1,status:"warn"}},Uy=()=>{let b=_.join(m.cwd(),"oxlint.config.ts");if(!F(b))return{message:"No oxlint.config.ts file found",name:W1,status:"fail"};try{if(F1(b,"utf-8").includes("ultracite/oxlint/"))return{message:"oxlint.config.ts extends ultracite oxlint config",name:W1,status:"pass"};return{message:"oxlint.config.ts exists but doesn't extend ultracite config",name:W1,status:"warn"}}catch{return{message:"Could not read oxlint.config.ts file",name:W1,status:"fail"}}},Qy=()=>{let b=_.join(m.cwd(),"oxfmt.config.ts");if(!F(b))return{message:"No oxfmt.config.ts file found",name:Z1,status:"fail"};try{if(F1(b,"utf-8").includes("ultracite/oxfmt"))return{message:"oxfmt.config.ts extends ultracite oxfmt config",name:Z1,status:"pass"};return{message:"oxfmt.config.ts exists but doesn't extend ultracite config",name:Z1,status:"warn"}}catch{return{message:"Could not read oxfmt.config.ts file",name:Z1,status:"fail"}}},Wy=()=>{let b=_.join(m.cwd(),"package.json");if(!F(b))return{message:"No package.json found",name:z1,status:"warn"};let y=E(b);if(!y)return{message:"Could not parse package.json",name:z1,status:"warn"};let $=y.dependencies?.ultracite||y.devDependencies?.ultracite||y.peerDependencies?.ultracite;if($)return{message:`Ultracite is in package.json (${$})`,name:z1,status:"pass"};return{message:"Ultracite not found in package.json dependencies",name:z1,status:"warn"}},Zy=(b)=>{let y=[];if(b!=="eslint"){if([".prettierrc",".prettierrc.js",".prettierrc.cjs",".prettierrc.mjs",".prettierrc.json",".prettierrc.yaml",".prettierrc.yml","prettier.config.js","prettier.config.mjs","prettier.config.cjs"].some((v)=>F(_.join(m.cwd(),v))))y.push("Prettier")}if([".eslintrc",".eslintrc.js",".eslintrc.cjs",".eslintrc.mjs",".eslintrc.json",".eslintrc.yaml",".eslintrc.yml"].some((G)=>F(_.join(m.cwd(),G))))y.push("ESLint (legacy config)");if(y.length>0)return{message:`Found potentially conflicting tools: ${y.join(", ")}`,name:b0,status:"warn"};return{message:"No conflicting formatting/linting tools found",name:b0,status:"pass"}},zy=(b)=>{let y=[];switch(b){case"biome":{y.push({fn:()=>g("biome",!0),name:"Biome installation"},{fn:yy,name:U1});break}case"eslint":{y.push({fn:()=>g("eslint",!0),name:"ESLint installation"},{fn:$y,name:Q1},{fn:()=>g("prettier",!0),name:"Prettier installation"},{fn:Gy,name:a1},{fn:()=>g("stylelint",!1),name:"Stylelint installation"},{fn:vy,name:e1});break}case"oxlint":{y.push({fn:()=>g("oxlint",!0),name:"Oxlint installation"},{fn:Uy,name:W1},{fn:()=>g("oxfmt",!0),name:"oxfmt installation"},{fn:Qy,name:Z1});break}default:break}return y.push({fn:Wy,name:z1},{fn:()=>Zy(b),name:b0}),y},S0=()=>{ab(`Ultracite v${z.version} Doctor`);let b=t();if(!b)throw I.error("No linter configuration found. Run `ultracite init` to set up a linter."),R1(I1),Error("Doctor checks failed");I.info(`Detected linter: ${b}`);let y=eb();y.start("Running diagnostics...");let G=zy(b).map(({fn:W})=>W());y.stop("Diagnostics complete.");for(let W of G)if(W.status==="pass")I.success(W.message);else if(W.status==="warn")I.warn(W.message);else I.error(W.message);let v=G.filter((W)=>W.status==="pass").length,U=G.filter((W)=>W.status==="fail").length,Q=G.filter((W)=>W.status==="warn").length;if(I.info(`Summary: ${v} passed, ${Q} warnings, ${U} failed`),U>0)throw I.error("Some checks failed. Run 'ultracite init' to fix issues."),R1(I1),Error("Doctor checks failed");if(Q>0){I.warn("Some optional improvements available. Run 'ultracite init' to configure."),R1(I1);return}I.success("Everything looks good!"),R1(I1)};var Yy=(b,y)=>{let $=["check","--write","--no-errors-on-unmatched",...y];if(b.length>0)$.push(...b);else $.push("./");let G=w("biome",$,{stdio:"inherit"});D("Biome",G)},Hy=(b,y)=>{let $=["--fix",...y,...b.length>0?b:["."]],G=w("eslint",$,{stdio:"inherit"});D("ESLint",G)},Xy=(b,y)=>{let $=["--write",...y,...b.length>0?b:["."]],G=w("prettier",$,{stdio:"inherit"});D("Prettier",G)},By=(b,y)=>{let $=S1(b);if($.length===0)return;let G=["--fix",...y,"--allow-empty-input",...$],v=w("stylelint",G,{stdio:"inherit"});D("Stylelint",v)},Vy=(b,y)=>{let $=y.includes("--unsafe"),G=y.filter((Q)=>Q!=="--unsafe"),v=[$?"--fix-dangerously":"--fix",...G,...b.length>0?b:["."]],U=w("oxlint",v,{stdio:"inherit"});D("Oxlint",U)},jy=(b,y)=>{let $=["--write",...y,...b.length>0?b:["."]],G=w("oxfmt",$,{stdio:"inherit"});D("oxfmt",G)},L0=(b,y=[])=>{let $=t(),G=N1(b);if(!$)throw Error("No linter configuration found. Run `ultracite init` to set up a linter.");switch($){case"eslint":{l([()=>Xy(G,[]),()=>Hy(G,y),()=>By(G,[])]);break}case"oxlint":{l([()=>jy(G,[]),()=>Vy(G,y)]);break}default:Yy(G,y)}};import E2 from"node:process";import{cancel as y1,intro as M2,isCancel as $1,log as D1,multiselect as d1,select as p2,spinner as J}from"@clack/prompts";import{addDevDependency as c2,detectPackageManager as f2}from"nypm";import{readFile as wy}from"node:fs/promises";import{dlxCommand as Ky}from"nypm";var y0=(b,y)=>`# Ultracite Code Standards
|
|
4
4
|
|
|
5
5
|
This project uses **Ultracite**, a zero-config preset that enforces strict code quality standards through automated formatting and linting.
|
|
6
6
|
|
|
@@ -123,19 +123,19 @@ ${y}'s linter will catch most issues automatically. Focus your attention on:
|
|
|
123
123
|
---
|
|
124
124
|
|
|
125
125
|
Most formatting and common issues are automatically fixed by ${y}. Run \`${b} ultracite fix\` before committing to ensure compliance.
|
|
126
|
-
`;var
|
|
126
|
+
`;var k=[{config:{appendMode:!0,path:".claude/CLAUDE.md"},hooks:{getContent:(b)=>({hooks:{PostToolUse:[{hooks:[{command:b,type:"command"}],matcher:"Write|Edit"}]}}),path:".claude/settings.json"},id:"claude",name:"Claude Code"},{config:{appendMode:!0,path:"AGENTS.md"},id:"codex",name:"Codex"},{config:{appendMode:!0,path:"AGENTS.md"},id:"jules",name:"Jules"},{config:{appendMode:!0,path:"replit.md"},id:"replit",name:"Replit Agent"},{config:{appendMode:!0,path:"AGENTS.md"},id:"devin",name:"Devin"},{config:{appendMode:!0,path:"AGENTS.md"},id:"lovable",name:"Lovable"},{config:{appendMode:!0,path:"AGENTS.md"},id:"zencoder",name:"Zencoder"},{config:{appendMode:!0,path:"AGENTS.md"},id:"ona",name:"Ona"},{config:{appendMode:!0,path:"AGENTS.md"},id:"openclaw",name:"OpenClaw"},{config:{appendMode:!0,path:"AGENTS.md"},id:"continue",name:"Continue"},{config:{appendMode:!0,path:"AGENTS.md"},id:"snowflake-cortex",name:"Snowflake Cortex"},{config:{appendMode:!0,path:"AGENTS.md"},id:"deepagents",name:"Deepagents"},{config:{appendMode:!0,path:"AGENTS.md"},id:"qoder",name:"Qoder"},{config:{appendMode:!0,path:"AGENTS.md"},id:"kimi-cli",name:"Kimi CLI"},{config:{appendMode:!0,path:"AGENTS.md"},id:"mcpjam",name:"MCPJam"},{config:{appendMode:!0,path:"AGENTS.md"},id:"mux",name:"Mux"},{config:{appendMode:!0,path:"AGENTS.md"},id:"pi",name:"Pi"},{config:{appendMode:!0,path:"AGENTS.md"},id:"adal",name:"AdaL"},{config:{appendMode:!0,path:"AGENTS.md"},hooks:{getContent:(b)=>({hooks:{PostToolUse:[{command:b,type:"command"}]}}),path:".github/hooks/ultracite.json"},id:"copilot",name:"GitHub Copilot"},{config:{appendMode:!0,path:"AGENTS.md"},id:"cline",name:"Cline"},{config:{appendMode:!0,path:"AGENTS.md"},id:"amp",name:"AMP"},{config:{path:"ultracite.md"},id:"aider",name:"Aider"},{config:{appendMode:!0,path:"AGENTS.md"},id:"firebase-studio",name:"Firebase Studio"},{config:{appendMode:!0,path:"AGENTS.md"},id:"open-hands",name:"OpenHands"},{config:{appendMode:!0,path:"GEMINI.md"},id:"gemini",name:"Gemini"},{config:{appendMode:!0,path:"AGENTS.md"},id:"junie",name:"Junie"},{config:{appendMode:!0,path:"AGENTS.md"},id:"augmentcode",name:"Augment Code"},{config:{appendMode:!0,path:"AGENTS.md"},id:"bob",name:"IBM Bob"},{config:{appendMode:!0,path:"AGENTS.md"},id:"kilo-code",name:"Kilo Code"},{config:{appendMode:!0,path:"AGENTS.md"},id:"goose",name:"Goose"},{config:{appendMode:!0,path:".roo/rules/ultracite.md"},id:"roo-code",name:"Roo Code"},{config:{appendMode:!0,path:"AGENTS.md"},id:"warp",name:"Warp"},{config:{appendMode:!0,path:"AGENTS.md"},id:"droid",name:"Droid"},{config:{appendMode:!0,path:"AGENTS.md"},id:"opencode",name:"OpenCode"},{config:{appendMode:!0,path:"AGENTS.md"},id:"crush",name:"Crush"},{config:{appendMode:!0,path:"AGENTS.md"},id:"qwen",name:"Qwen Code"},{config:{appendMode:!0,path:".amazonq/rules/ultracite.md"},id:"amazon-q-cli",name:"Amazon Q CLI"},{config:{path:"firebender.json"},id:"firebender",name:"Firebender"},{config:{appendMode:!0,path:"AGENTS.md"},id:"cursor-cli",name:"Cursor CLI"},{config:{appendMode:!0,path:"AGENTS.md"},id:"mistral-vibe",name:"Mistral Vibe"},{config:{appendMode:!0,path:"AGENTS.md"},id:"vercel",name:"Vercel Agent"}];var _1=[{id:"biome",name:"Biome",vscodeExtensionId:"biomejs.biome"},{id:"eslint",name:"ESLint + Prettier + Stylelint",vscodeExtensionId:"dbaeumer.vscode-eslint"},{id:"oxlint",name:"Oxlint + Oxfmt",vscodeExtensionId:"oxc.oxc-vscode"}];var R0=(b)=>b.replace(/ Code$/u,"").replace(/ Agent$/u,""),Ay=(b,y)=>{if(b==="AGENTS.md"&&y.length>1){let G=y.slice(0,3),v=y.length>G.length?", and more":"";return`Universal (creates ${b} for ${G.join(", ")}${v})`}let[$]=y;return`${$} (creates ${b})`},I0=()=>{let b=new Map;for(let $ of k){let G=b.get($.config.path)??[];G.push($),b.set($.config.path,G)}return[...b.entries()].map(([$,G])=>{let[v]=G,U=G.map((W)=>R0(W.name)),Q=$==="AGENTS.md"&&G.length>1;return{agentIds:G.map((W)=>W.id),displayName:Q?"Universal":R0(v.name),id:Q?"universal":v.id,path:$,promptLabel:Ay($,U),representativeAgentId:v.id}}).toSorted(($,G)=>{if($.path==="AGENTS.md")return-1;if(G.path==="AGENTS.md")return 1;return 0})},F0=(b,y,$)=>{let G=k.find((X)=>X.id===b);if(!G)throw Error(`Agent "${b}" not found`);let v=_1.find((X)=>X.id===$);if(!v)throw Error(`Provider "${$}" not found`);let U=Ky(y,""),Q=y0(U,v.name),W=G.config.header?`${G.config.header}
|
|
127
127
|
|
|
128
|
-
${Q}`:Q;return{create:async()=>{
|
|
128
|
+
${Q}`:Q;return{create:async()=>{S(G.config.path),await Z(G.config.path,W)},exists:()=>H(G.config.path),update:async()=>{S(G.config.path);let X=H(G.config.path);if(!(G.config.appendMode&&X)){await Z(G.config.path,W);return}let V=await wy(G.config.path,"utf-8");if(V.includes(Q.trim()))return;await Z(G.config.path,`${V}
|
|
129
129
|
|
|
130
|
-
${Q}`)}}};import a from"deepmerge";var
|
|
131
|
-
`)},exists:()=>H($.config.path),extension:$.config.extensionCommand?(v)=>{let[U,...Q]=$.config.extensionCommand.split(" ");return
|
|
132
|
-
`);return}let U=await
|
|
133
|
-
`)}}};var
|
|
134
|
-
`);return}let K=await
|
|
135
|
-
`)}};return{create:async()=>{
|
|
136
|
-
`)},exists:()=>H(G.hooks.path),update:async()=>{
|
|
130
|
+
${Q}`)}}};import a from"deepmerge";var m1={"editor.defaultFormatter":"esbenp.prettier-vscode","editor.formatOnPaste":!0,"editor.formatOnSave":!0,"emmet.showExpandedAbbreviation":"never","js/ts.tsdk.path":"node_modules/typescript/lib","js/ts.tsdk.promptToUseWorkspaceVersion":!0},Jy="astro-build.astro-vscode",d="biomejs.biome",A="oxc.oxc-vscode",h="code --install-extension",O=".vscode/settings.json",uy={"[css]":{"editor.defaultFormatter":d},"[graphql]":{"editor.defaultFormatter":d},"[html]":{"editor.defaultFormatter":d},"[javascript]":{"editor.defaultFormatter":d},"[javascriptreact]":{"editor.defaultFormatter":d},"[json]":{"editor.defaultFormatter":d},"[jsonc]":{"editor.defaultFormatter":d},"[markdown]":{"editor.defaultFormatter":d},"[mdx]":{"editor.defaultFormatter":d},"[svelte]":{"editor.defaultFormatter":d},"[typescript]":{"editor.defaultFormatter":d},"[typescriptreact]":{"editor.defaultFormatter":d},"[vue]":{"editor.defaultFormatter":d},"[yaml]":{"editor.defaultFormatter":d},"editor.codeActionsOnSave":{"source.fixAll.biome":"explicit","source.organizeImports.biome":"explicit"}},Dy={"[astro]":{"editor.defaultFormatter":Jy},"[css]":{"editor.defaultFormatter":A},"[graphql]":{"editor.defaultFormatter":A},"[handlebars]":{"editor.defaultFormatter":A},"[html]":{"editor.defaultFormatter":A},"[javascript]":{"editor.defaultFormatter":A},"[javascriptreact]":{"editor.defaultFormatter":A},"[json]":{"editor.defaultFormatter":A},"[jsonc]":{"editor.defaultFormatter":A},"[less]":{"editor.defaultFormatter":A},"[markdown]":{"editor.defaultFormatter":A},"[scss]":{"editor.defaultFormatter":A},"[typescript]":{"editor.defaultFormatter":A},"[typescriptreact]":{"editor.defaultFormatter":A},"[vue-html]":{"editor.defaultFormatter":A},"[vue]":{"editor.defaultFormatter":A},"[yaml]":{"editor.defaultFormatter":A},"editor.codeActionsOnSave":{"source.fixAll.oxc":"explicit"}},dy={"editor.codeActionsOnSave":{"source.fixAll.eslint":"explicit","source.organizeImports":"explicit"}},T=(b="biome")=>{switch(b){case"biome":return a(m1,uy);case"eslint":return a(m1,dy);case"oxlint":return a(m1,Dy);default:return m1}},h1={format_on_save:"on",formatter:"language_server",lsp:{"typescript-language-server":{settings:{typescript:{preferences:{includePackageJsonAutoImports:"on"}}}}}},oy={languages:{JavaScript:{code_actions_on_format:{"source.fixAll.biome":!0,"source.organizeImports.biome":!0},formatter:{language_server:{name:"biome"}}},TSX:{code_actions_on_format:{"source.fixAll.biome":!0,"source.organizeImports.biome":!0},formatter:{language_server:{name:"biome"}}},TypeScript:{code_actions_on_format:{"source.fixAll.biome":!0,"source.organizeImports.biome":!0},formatter:{language_server:{name:"biome"}}}}},xy={languages:{JavaScript:{code_actions_on_format:{"source.fixAll.eslint":!0,"source.organizeImports.eslint":!0},formatter:{language_server:{name:"eslint"}}},TSX:{code_actions_on_format:{"source.fixAll.eslint":!0,"source.organizeImports.eslint":!0},formatter:{language_server:{name:"eslint"}}},TypeScript:{code_actions_on_format:{"source.fixAll.eslint":!0,"source.organizeImports.eslint":!0},formatter:{language_server:{name:"eslint"}}}}},Ny={languages:{JavaScript:{code_actions_on_format:{"source.fixAll.oxc":!0,"source.organizeImports.oxc":!0},formatter:{language_server:{name:"oxfmt"}}},TSX:{code_actions_on_format:{"source.fixAll.oxc":!0,"source.organizeImports.oxc":!0},formatter:{language_server:{name:"oxfmt"}}},TypeScript:{code_actions_on_format:{"source.fixAll.oxc":!0,"source.organizeImports.oxc":!0},formatter:{language_server:{name:"oxfmt"}}}},lsp:{oxfmt:{initialization_options:{settings:{configPath:null,flags:{},"fmt.configPath":null,"fmt.experimental":!0,run:"onSave",typeAware:!1,unusedDisableDirectives:!1}}},oxlint:{initialization_options:{settings:{disableNestedConfig:!1,fixKind:"safe_fix",run:"onType",typeAware:!0,unusedDisableDirectives:"deny"}}}}},Sy=(b="biome")=>{switch(b){case"biome":return a(h1,oy);case"eslint":return a(h1,xy);case"oxlint":return a(h1,Ny);default:return h1}},c=[{config:{extensionCommand:h,getContent:T,path:O},id:"vscode",name:"Visual Studio Code"},{config:{extensionCommand:h,getContent:T,path:O},hooks:{getContent:(b)=>({hooks:{afterFileEdit:[{command:b}]},version:1}),path:".cursor/hooks.json"},id:"cursor",name:"Cursor"},{config:{extensionCommand:h,getContent:T,path:O},hooks:{getContent:(b)=>({hooks:{post_write_code:[{command:b,show_output:!0}]}}),path:".windsurf/hooks.json"},id:"windsurf",name:"Windsurf"},{config:{extensionCommand:h,getContent:T,path:O},hooks:{getContent:(b)=>({hooks:{PostToolUse:[{hooks:[{command:b,timeout:20,type:"command"}],matcher:"Write|Edit"}]}}),path:".codebuddy/settings.json"},id:"codebuddy",name:"CodeBuddy"},{config:{extensionCommand:h,getContent:T,path:O},id:"antigravity",name:"Antigravity"},{config:{extensionCommand:h,getContent:T,path:O},id:"bob",name:"IBM Bob"},{config:{extensionCommand:h,getContent:T,path:O},id:"kiro",name:"Kiro"},{config:{extensionCommand:h,getContent:T,path:O},id:"trae",name:"Trae"},{config:{extensionCommand:h,getContent:T,path:O},id:"void",name:"Void"},{config:{getContent:Sy,path:".zed/settings.json"},id:"zed",name:"Zed"}];var Ly=(b)=>Boolean(b.hooks),Ry=(b)=>Boolean(b.hooks),Iy=()=>c.flatMap((b)=>Ly(b)?[{hooks:b.hooks,id:b.id,name:b.name}]:[]),Fy=()=>k.flatMap((b)=>Ry(b)?[{hooks:b.hooks,id:b.id,name:b.name}]:[]),Y1=[...Iy(),...Fy()];import{readFile as _y}from"node:fs/promises";import{sync as my}from"cross-spawn";import hy from"deepmerge";import{parse as Oy}from"jsonc-parser";var _0=(b,y="biome")=>{let $=c.find((v)=>v.id===b);if(!$)throw Error(`Editor "${b}" not found`);let G=$.config.getContent(y);return{create:async()=>{S($.config.path),await Z($.config.path,`${JSON.stringify(G,null,2)}
|
|
131
|
+
`)},exists:()=>H($.config.path),extension:$.config.extensionCommand?(v)=>{let[U,...Q]=$.config.extensionCommand.split(" ");return my(U,[...Q,v],{stdio:"pipe"})}:void 0,update:async()=>{if(S($.config.path),!H($.config.path)){await Z($.config.path,`${JSON.stringify(G,null,2)}
|
|
132
|
+
`);return}let U=await _y($.config.path,"utf-8"),W=Oy(U)||{},X=hy(W,G);await Z($.config.path,`${JSON.stringify(X,null,2)}
|
|
133
|
+
`)}}};var Ty=(b,y)=>{if(y.length>1){let G=y.slice(0,3),v=y.length>G.length?", and more":"";return`Universal (creates ${b} for ${G.join(", ")}${v})`}let[$]=y;return`${$} (creates ${b})`},m0=()=>{let b=new Map;for(let $ of c){let G=b.get($.config.path)??[];G.push($),b.set($.config.path,G)}return[...b.entries()].map(([$,G])=>{let[v]=G,U=G.map((W)=>W.name),Q=G.length>1;return{displayName:Q?"Universal":v.name,editorIds:G.map((W)=>W.id),id:Q?"universal":v.id,path:$,promptLabel:Ty($,U),representativeEditorId:v.id}}).toSorted(($,G)=>{if($.id==="universal")return-1;if(G.id==="universal")return 1;return 0})};import{readFile as Ey}from"node:fs/promises";import My from"deepmerge";import{parse as py}from"jsonc-parser";import{runScriptCommand as cy}from"nypm";var h0=["npm","yarn","pnpm","bun","deno"],qy=(b)=>h0.includes(b),H1=(b)=>{if(qy(b))return b;throw Error(`Unsupported package manager "${b}". Supported package managers: ${h0.join(", ")}.`)},O0=(b)=>{let y=H1(b.name);return{...b,command:y,name:y}};var fy=(b)=>typeof b==="object"&&b!==null&&!Array.isArray(b),Py=(b,y=[])=>{let $=H1(b),G=$==="npm"&&y.length>0?["--",...y]:y;return cy($,"fix",{args:G})},T0=(b,y,$="biome")=>{let G=Y1.find((V)=>V.id===b);if(!G)throw Error(`Hook integration "${b}" not found`);let U=Py(y,$==="biome"?["--skip=correctness/noUnusedImports"]:[]),Q=G.hooks.getContent(U),W=(V)=>{let K=JSON.stringify(V);return K.includes("ultracite")||K.includes(U)},X=async()=>{if(!H(G.hooks.path)){await Z(G.hooks.path,`${JSON.stringify(Q,null,2)}
|
|
134
|
+
`);return}let K=await Ey(G.hooks.path,"utf-8"),x=py(K),u=fy(x)?x:{};if(!W(u)){let R=My(u,Q);await Z(G.hooks.path,`${JSON.stringify(R,null,2)}
|
|
135
|
+
`)}};return{create:async()=>{S(G.hooks.path),await Z(G.hooks.path,`${JSON.stringify(Q,null,2)}
|
|
136
|
+
`)},exists:()=>H(G.hooks.path),update:async()=>{S(G.hooks.path),await X()}}};import{mkdir as ky,readFile as ry}from"node:fs/promises";import{addDevDependency as ly,dlxCommand as X1}from"nypm";var q0=(b)=>`#!/bin/sh
|
|
137
137
|
${b}
|
|
138
|
-
`,
|
|
138
|
+
`,E0=(b)=>`#!/bin/sh
|
|
139
139
|
# Check if there are any staged files
|
|
140
140
|
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACMR)
|
|
141
141
|
if [ -z "$STAGED_FILES" ]; then
|
|
@@ -160,18 +160,18 @@ if [ $FORMAT_EXIT_CODE -ne 0 ]; then
|
|
|
160
160
|
fi
|
|
161
161
|
|
|
162
162
|
echo "✨ Files formatted by Ultracite"
|
|
163
|
-
`,
|
|
164
|
-
${b}${
|
|
165
|
-
`)},exists:()=>H(
|
|
166
|
-
`),U=v.indexOf(G0),Q=
|
|
167
|
-
`),
|
|
168
|
-
`).replace(/^\n+/u,"").replace(/\n+$/u,""),
|
|
163
|
+
`,B1="./.husky/pre-commit",G0="# ultracite",M0="# ultracite end",$0=(b)=>`${G0}
|
|
164
|
+
${b}${M0}`,Cy=(b,y)=>{let $=b.indexOf(M0,y+1);if($!==-1)return $+1;let G=b.findIndex((v,U)=>U>y&&v.includes("Files formatted by Ultracite"));if(G!==-1)return G+1;return b.length},e={create:async(b,y=!1)=>{await ky(".husky",{recursive:!0});let $;if(y){let G=X1(b,"lint-staged",{short:b==="npm"});$=q0(G)}else{let G=X1(b,"ultracite",{args:["fix"],short:b==="npm"});$=E0(G)}await Z(B1,`${$0($)}
|
|
165
|
+
`)},exists:()=>H(B1),init:(b)=>{let[y,...$]=X1(b,"husky",{args:["init"]}).split(" "),G=w(y,$,{stdio:"pipe"});if(G.error||G.status!==null&&G.status!==0);},install:async(b)=>{await ly("husky",{corepack:!1,packageManager:b,silent:!0,workspace:M()&&b.name!=="npm"}),await N({scripts:{prepare:"husky"}})},update:async(b,y=!1)=>{let $=await ry(B1,"utf-8"),G;if(y){let v=X1(b,"lint-staged",{short:b==="npm"});G=q0(v)}else{let v=X1(b,"ultracite",{args:["fix"],short:b==="npm"});G=E0(v)}if($.includes(G0)){let v=$.split(`
|
|
166
|
+
`),U=v.indexOf(G0),Q=Cy(v,U),W=v.slice(0,U).join(`
|
|
167
|
+
`),X=v.slice(Q).join(`
|
|
168
|
+
`).replace(/^\n+/u,"").replace(/\n+$/u,""),V=[W,$0(G),X].filter((K)=>K!=="");await Z(B1,`${V.join(`
|
|
169
169
|
`)}
|
|
170
|
-
`)}else{let v=$.replace(/\n+$/u,"");await Z(
|
|
170
|
+
`)}else{let v=$.replace(/\n+$/u,"");await Z(B1,`${v}
|
|
171
171
|
${$0(G)}
|
|
172
|
-
`)}}};import{execSync as
|
|
172
|
+
`)}}};import{execSync as sy}from"node:child_process";import{readFile as ny}from"node:fs/promises";import{addDevDependency as iy,dlxCommand as c0}from"nypm";var ty=/(?<preCommitJobs>pre-commit:\s*\n\s*jobs:\s*\n)/u,gy=/(?<preCommit>pre-commit:\s*\n)/u,f0=(b)=>c0(b,"ultracite",{args:["fix"],short:b==="npm"}),b1="./lefthook.yml",p0=(b)=>`pre-commit:
|
|
173
173
|
jobs:
|
|
174
|
-
- run: ${
|
|
174
|
+
- run: ${f0(b)}
|
|
175
175
|
glob:
|
|
176
176
|
- "**/*.js"
|
|
177
177
|
- "**/*.jsx"
|
|
@@ -181,7 +181,7 @@ ${$0(G)}
|
|
|
181
181
|
- "**/*.jsonc"
|
|
182
182
|
- "**/*.css"
|
|
183
183
|
stage_fixed: true
|
|
184
|
-
`,
|
|
184
|
+
`,V1={create:async(b)=>{let y=p0(b);await Z(b1,y)},exists:()=>H(b1),install:async(b)=>{await iy("lefthook",{corepack:!1,packageManager:b,silent:!0,workspace:M()&&b.name!=="npm"}),await N({scripts:{prepare:"lefthook install"}});let y=c0(b.name,"lefthook",{args:["install"],short:b.name==="npm"});try{sy(y,{stdio:"pipe"})}catch{}},update:async(b)=>{let y=await ny(b1,"utf-8"),$=f0(b),G=p0(b);if(y.includes($))return;if(y.startsWith("# EXAMPLE USAGE:")){await Z(b1,G);return}if(y.includes("pre-commit:")){let U;if(y.includes("jobs:")){let Q=` - run: ${$}
|
|
185
185
|
glob:
|
|
186
186
|
- "**/*.js"
|
|
187
187
|
- "**/*.jsx"
|
|
@@ -190,7 +190,7 @@ ${$0(G)}
|
|
|
190
190
|
- "**/*.json"
|
|
191
191
|
- "**/*.jsonc"
|
|
192
192
|
- "**/*.css"
|
|
193
|
-
stage_fixed: true`;U=y.replace(
|
|
193
|
+
stage_fixed: true`;U=y.replace(ty,`$<preCommitJobs>${Q}
|
|
194
194
|
`)}else{let Q=` jobs:
|
|
195
195
|
- run: ${$}
|
|
196
196
|
glob:
|
|
@@ -201,24 +201,24 @@ ${$0(G)}
|
|
|
201
201
|
- "**/*.json"
|
|
202
202
|
- "**/*.jsonc"
|
|
203
203
|
- "**/*.css"
|
|
204
|
-
stage_fixed: true`;U=y.replace(
|
|
204
|
+
stage_fixed: true`;U=y.replace(gy,`$<preCommit>${Q}
|
|
205
205
|
`)}await Z(b1,U)}else await Z(b1,`${y}
|
|
206
|
-
${G}`)}};import{readFile as
|
|
207
|
-
`)},
|
|
208
|
-
`)},
|
|
209
|
-
`;await Z(b,Q)},
|
|
206
|
+
${G}`)}};import{readFile as j1}from"node:fs/promises";import{pathToFileURL as l0}from"node:url";import w1 from"deepmerge";import{parse as ay}from"jsonc-parser";import{addDevDependency as ey,dlxCommand as b2}from"nypm";import P0 from"yaml";var O1="./package.json",f=(b)=>({"*.{js,jsx,ts,tsx,json,jsonc,css,scss,md,mdx}":[b2(b,"ultracite",{args:["fix"],short:b==="npm"})]}),k0=["./.lintstagedrc.json","./.lintstagedrc.js","./.lintstagedrc.cjs","./.lintstagedrc.mjs","./lint-staged.config.js","./lint-staged.config.cjs","./lint-staged.config.mjs","./.lintstagedrc.yaml","./.lintstagedrc.yml","./.lintstagedrc"],K1=(b)=>JSON.stringify(b).includes("ultracite"),r0=async()=>{try{let b=await j1(O1,"utf-8");return C(b)?.["lint-staged"]}catch{return}},y2=async()=>{try{let b=await j1(O1,"utf-8");return C(b)?.type==="module"}catch{return!1}},$2=async(b)=>{let y=await j1(O1,"utf-8"),$=C(y);if(!$)return;if(K1($["lint-staged"]))return;$["lint-staged"]=$["lint-staged"]?w1($["lint-staged"],f(b)):f(b),await Z(O1,`${JSON.stringify($,null,2)}
|
|
207
|
+
`)},G2=async(b,y)=>{let $=await j1(b,"utf-8"),G=ay($);if(!G)return;if(K1(G))return;let v=w1(G,f(y));await Z(b,`${JSON.stringify(v,null,2)}
|
|
208
|
+
`)},v2=(b)=>b.replaceAll(/^(?<key>[*?{[][^\n:]*):(?<rest>.*)$/gmu,(y,$,G)=>`'${$}':${G}`),U2=async(b,y)=>{let $=await j1(b,"utf-8"),G=v2($),v;try{v=P0.parse(G)}catch{return}if(!v)return;if(K1(v))return;let U=w1(v,f(y));await Z(b,P0.stringify(U))},Q2=async(b,y)=>{let v=(await import(l0(b).href)).default||{};if(K1(v))return;let U=w1(v,f(y)),Q=`export default ${JSON.stringify(U,null,2)};
|
|
209
|
+
`;await Z(b,Q)},W2=async(b,y)=>{let G=await import(`${l0(b).href}?t=${Date.now()}`),v=G.default||G;if(K1(v))return;let U=w1(v,f(y)),Q=`module.exports = ${JSON.stringify(U,null,2)};
|
|
210
210
|
`;await Z(b,Q)},v0=async(b)=>{await Z(".lintstagedrc.json",`${JSON.stringify(f(b),null,2)}
|
|
211
|
-
`)},
|
|
212
|
-
`)},exists:async()=>{if(await
|
|
211
|
+
`)},Z2=async(b,y)=>{if(b.endsWith(".json")||b==="./.lintstagedrc"){await G2(b,y);return}if(b.endsWith(".yaml")||b.endsWith(".yml")){await U2(b,y);return}let $=await y2();if(b.endsWith(".mjs")||b.endsWith(".js")&&$){try{await Q2(b,y)}catch{await v0(y)}return}if(b.endsWith(".cjs")||b.endsWith(".js")&&!$)try{await W2(b,y)}catch{await v0(y)}},A1={create:async(b)=>{await Z(".lintstagedrc.json",`${JSON.stringify(f(b),null,2)}
|
|
212
|
+
`)},exists:async()=>{if(await r0())return!0;return k0.some((b)=>H(b))},install:async(b)=>{await ey("lint-staged",{corepack:!1,packageManager:b,silent:!0,workspace:M()&&b.name!=="npm"})},update:async(b)=>{if(await r0()){await $2(b);return}let y=k0.find(($)=>H($));if(!y){await v0(b);return}await Z2(y,b)}};import{readFile as z2}from"node:fs/promises";import{dlxCommand as Y2}from"nypm";var J1="./.pre-commit-config.yaml",H2=/^repos:\s*\n/mu,C0=(b)=>Y2(b,"ultracite",{args:["fix"],short:b==="npm"}),X2=(b)=>`repos:
|
|
213
213
|
- repo: local
|
|
214
214
|
hooks:
|
|
215
215
|
- id: ultracite
|
|
216
216
|
name: ultracite
|
|
217
|
-
entry: ${
|
|
217
|
+
entry: ${C0(b)}
|
|
218
218
|
language: system
|
|
219
219
|
types_or: [javascript, jsx, ts, tsx, json, css]
|
|
220
220
|
pass_filenames: false
|
|
221
|
-
`,T1={create:async(b)=>{let y=
|
|
221
|
+
`,T1={create:async(b)=>{let y=X2(b);await Z(J1,y)},exists:()=>H(J1),update:async(b)=>{let y=await z2(J1,"utf-8"),$=C0(b);if(y.includes("id: ultracite"))return;let G=` - repo: local
|
|
222
222
|
hooks:
|
|
223
223
|
- id: ultracite
|
|
224
224
|
name: ultracite
|
|
@@ -226,38 +226,38 @@ ${G}`)}};import{readFile as X1}from"node:fs/promises";import{pathToFileURL as k0
|
|
|
226
226
|
language: system
|
|
227
227
|
types_or: [javascript, jsx, ts, tsx, json, css]
|
|
228
228
|
pass_filenames: false
|
|
229
|
-
`;if(y.includes("repos:")){let v=y.replace(
|
|
230
|
-
${G}`);await Z(
|
|
229
|
+
`;if(y.includes("repos:")){let v=y.replace(H2,`repos:
|
|
230
|
+
${G}`);await Z(J1,v)}else await Z(J1,`${y}
|
|
231
231
|
repos:
|
|
232
|
-
${G}`)}};import{readFile as B2}from"node:fs/promises";import
|
|
233
|
-
`)},exists:()=>{let b=U0();return H(b)},update:async(b)=>{let y=U0(),$=await B2(y,"utf-8"),v=
|
|
234
|
-
`)}};var
|
|
232
|
+
${G}`)}};import{readFile as B2}from"node:fs/promises";import V2 from"deepmerge";var Q0="ultracite/biome/core",s0={$schema:"./node_modules/@biomejs/biome/configuration_schema.json",extends:[Q0]},j2=/^ultracite\/(?!biome\/)(?<rest>.+)$/u,U0=()=>{for(let b of p)if(H(`./${b}`))return`./${b}`;return"./biome.jsonc"},q1={create:(b)=>{let y=U0(),$=[Q0];if(b?.typeAware)$.push("ultracite/biome/type-aware");if(b?.frameworks&&b.frameworks.length>0)for(let v of b.frameworks){let U=L(v);$.push(`ultracite/biome/${U}`)}let G={...s0,extends:$};return Z(y,`${JSON.stringify(G,null,2)}
|
|
233
|
+
`)},exists:()=>{let b=U0();return H(b)},update:async(b)=>{let y=U0(),$=await B2(y,"utf-8"),v=L1($,w0)||{},Q=(v.extends??[]).map((u)=>{let R=j2.exec(u);return R?`ultracite/biome/${R[1]}`:u}),W=[...new Set(Q)],X=new Set(W),V=(u)=>{if(!X.has(u))X.add(u),W.push(u)};if(V(Q0),b?.typeAware)V("ultracite/biome/type-aware");if(b?.frameworks&&b.frameworks.length>0)for(let u of b.frameworks)V(`ultracite/biome/${L(u)}`);v.extends=W;let K={$schema:s0.$schema},x=V2(v,K);await Z(y,`${JSON.stringify(x,null,2)}
|
|
234
|
+
`)}};var w2=P.map((b)=>`./${b}`),n0="./eslint.config.mjs",i0=()=>{for(let b of w2)if(H(b))return b;return null},t0=(b)=>{let y=['import core from "ultracite/eslint/core";'],$=["...core"];if(b?.frameworks&&b.frameworks.length>0)for(let G of b.frameworks){let v=L(G);y.push(`import ${v} from "ultracite/eslint/${v}";`),$.push(`...${v}`)}return`${y.join(`
|
|
235
235
|
`)}
|
|
236
236
|
|
|
237
237
|
export default [
|
|
238
238
|
${$.join(`,
|
|
239
239
|
`)},
|
|
240
240
|
];
|
|
241
|
-
`},
|
|
241
|
+
`},E1={create:async(b)=>{let y=t0(b);await Z(n0,y)},exists:()=>{return i0()!==null},update:async(b)=>{let y=t0(b);await Z(i0()??n0,y)}};var W0="./oxfmt.config.ts",g0=`import { defineConfig } from "oxfmt";
|
|
242
242
|
import ultracite from "ultracite/oxfmt";
|
|
243
243
|
|
|
244
244
|
export default defineConfig({
|
|
245
245
|
...ultracite,
|
|
246
246
|
});
|
|
247
|
-
`,
|
|
248
|
-
`),$=b.map((G)=>
|
|
247
|
+
`,M1={create:async()=>await Z(W0,g0),exists:()=>H(W0),update:async()=>await Z(W0,g0)};import{readFile as K2}from"node:fs/promises";var p1="./oxlint.config.ts",u1=(b)=>`ultracite/oxlint/${b}`,a0=(b)=>{let y=b.split("/").pop()??b;return y==="core"?"core":y},e0=(b)=>{let y=['import { defineConfig } from "oxlint";',...b.map((G)=>`import ${a0(G)} from "${G}";`)].join(`
|
|
248
|
+
`),$=b.map((G)=>a0(G)).join(", ");return`${y}
|
|
249
249
|
|
|
250
250
|
export default defineConfig({
|
|
251
251
|
extends: [${$}],
|
|
252
252
|
ignorePatterns: core.ignorePatterns,
|
|
253
253
|
});
|
|
254
|
-
`},
|
|
254
|
+
`},c1={create:async(b)=>{let y=[u1("core")];if(b?.frameworks&&b.frameworks.length>0)for(let $ of b.frameworks){let G=L($);y.push(u1(G))}return await Z(p1,e0(y))},exists:()=>H(p1),update:async(b)=>{let y=await K2(p1,"utf-8"),$=[],G=y.matchAll(/import \w+ from ["'](?<source>[^"']+)["']/gu);for(let Q of G)if(Q[1].startsWith("ultracite/oxlint/"))$.push(Q[1].replace(/\/index\.[tj]s$/u,""));if($.length===0){let Q=y.match(/extends:\s*\[(?<body>[\s\S]*?)\]/u);if(Q?.[1]){let W=Q[1].matchAll(/"(?<value>[^"]+)"/gu);for(let X of W){let V=X[1].replace(/^\.\/node_modules\/ultracite\/config\/oxlint\//u,"ultracite/oxlint/");$.push(V)}}}if($.length===0&&y.includes("ultracite/oxlint"))console.warn("Warning: could not parse existing extends from oxlint.config.ts. The file will be regenerated.");let v=(Q)=>$.some((W)=>W===u1(Q)),U=[...$];if(!v("core"))U.push(u1("core"));if(b?.frameworks&&b.frameworks.length>0)for(let Q of b.frameworks){let W=L(Q);if(!v(W))U.push(u1(W))}await Z(p1,e0(U))}};var z0="./package.json",A2=n.map((b)=>`./${b}`),Z0="./prettier.config.mjs",J2=()=>{return E(z0)?.prettier!==void 0},bb=()=>{if(J2())return z0;for(let b of A2)if(H(b))return b;return null},yb={astro:"prettier-plugin-astro",svelte:"prettier-plugin-svelte"},$b=(b)=>{let y=[];if(b?.frameworks)for(let $ of b.frameworks){let G=L($);if(G in yb)y.push(yb[G])}return y.push("prettier-plugin-tailwindcss"),`import config from "ultracite/prettier";
|
|
255
255
|
|
|
256
256
|
export default {
|
|
257
257
|
...config,
|
|
258
258
|
plugins: [${y.map(($)=>`"${$}"`).join(", ")}],
|
|
259
259
|
};
|
|
260
|
-
`},f1={create:async(b)=>{let y
|
|
261
|
-
`,
|
|
262
|
-
`);return}let v=
|
|
263
|
-
`),!0},C2=async(b,y=!1)=>{let $=w();if(!y)$.start("Checking for stale linter configuration...");let G=new Set;if(b!=="biome")for(let W of q)G.add(W);if(b!=="eslint"){for(let W of M)G.add(W);for(let W of C)G.add(W);for(let W of i)G.add(W)}for(let W of D0)G.add(W);if(b!=="oxlint"){for(let W of g1)G.add(W);for(let W of N0)G.add(W)}let[v,U]=await Promise.all([Promise.all([...G].map((W)=>k2(W))),s2(b)]),Q=v.some(Boolean)||U;if(!y)$.stop(Q?"Stale linter configuration migrated.":"No stale linter configuration found.")},i2=async(b,y="biome",$=!0,G=!1,v=!1,U=["react"])=>{let Q=w();if(!G)Q.start("Installing dependencies...");let W=[`ultracite@${B0}`];if(y==="biome")W.push(`@biomejs/biome@${Bb}`);if(y==="eslint")W.push(...Object.entries(Kb(U)).map(([B,K])=>`${B}@${K}`));if(y==="oxlint"){if(W.push("oxlint@latest","oxfmt@latest",...Object.entries(X0).map(([B,K])=>`${B}@${K}`),...Object.entries(Ab(U)).map(([B,K])=>`${B}@${K}`)),v)W.push("oxlint-tsgolint@latest")}let o={check:"ultracite check",fix:"ultracite fix"};if($)await f2(W,{corepack:!1,packageManager:b,silent:!0,workspace:c()&&b.name!=="npm"}),await L({scripts:o});else{let B=r2(y,v,U);await L({devDependencies:B,scripts:o})}if(!G)Q.stop("Dependencies installed.")},t2=async(b=!1)=>{let y=w();if(!b)y.start("Checking for tsconfig.json files...");if(await o0.exists()){if(!b)y.message("Found tsconfig.json files, updating with strictNullChecks...");if(await o0.update(),!b)y.stop("tsconfig.json files updated.");return}if(!b)y.stop("No tsconfig.json files found, skipping.")},wb=async(b,y="biome",$=!1)=>{let G=P.find((Q)=>Q.id===b);if(!G)throw Error(`Editor "${b}" not found`);let v=F0(b,y),U=w();if(!$)U.start(`Checking for ${G.config.path}...`);if(await v.exists()){if(!$)U.message(`${G.config.path} found, updating...`);if(await v.update(),!$)U.stop(`${G.config.path} updated.`);return}if(!$)U.message(`${G.config.path} not found, creating...`);if(await v.create(),v.extension){let Q=_1.find((W)=>W.id===y)?.vscodeExtensionId;if(!Q)throw Error(`Linter extension not found for ${y}`);if(!$)U.message(`Installing ${Q} extension...`);try{if(v.extension(Q).status===0){if(!$)U.stop(`${G.config.path} created and ${Q} extension installed.`);return}}catch{}if(!$)U.stop(`${G.config.path} created. Install ${Q} extension manually.`);return}if(!$)if(b==="zed")U.stop(`${G.config.path} created. Install the Biome extension: https://biomejs.dev/reference/zed/`);else U.stop(`${G.config.path} created.`)},g2=async(b,y=!1,$=!1)=>{let G=w();if(!y)G.start("Checking for Biome configuration...");if(await E1.exists()){if(!y)G.message("Biome configuration found, updating...");if(await E1.update({frameworks:b,typeAware:$}),!y)G.stop("Biome configuration updated.");return}if(!y)G.message("Biome configuration not found, creating...");if(await E1.create({frameworks:b,typeAware:$}),!y)G.stop("Biome configuration created.")},a2=async(b,y=!1)=>{let $=w();if(!y)$.start("Checking for ESLint configuration...");if(await p1.exists()){if(!y)$.message("ESLint configuration found, updating...");if(await p1.update({frameworks:b}),!y)$.stop("ESLint configuration updated.");return}if(!y)$.message("ESLint configuration not found, creating...");if(await p1.create({frameworks:b}),!y)$.stop("ESLint configuration created.")},e2=async(b,y=!1)=>{let $=w();if(!y)$.start("Checking for Oxlint configuration...");if(await P1.exists()){if(!y)$.message("Oxlint configuration found, updating...");if(await P1.update({frameworks:b}),!y)$.stop("Oxlint configuration updated.");return}if(!y)$.message("Oxlint configuration not found, creating...");if(await P1.create({frameworks:b}),!y)$.stop("Oxlint configuration created.")},b$=async(b,y=!1)=>{let $=w();if(!y)$.start("Checking for Prettier configuration...");if(await f1.exists()){if(!y)$.message("Prettier configuration found, updating...");if(await f1.update({frameworks:b}),!y)$.stop("Prettier configuration updated.");return}if(!y)$.message("Prettier configuration not found, creating...");if(await f1.create({frameworks:b}),!y)$.stop("Prettier configuration created.")},y$=async(b=!1)=>{let y=w();if(!b)y.start("Checking for Stylelint configuration...");if(await M1.exists()){if(!b)y.message("Stylelint configuration found, updating...");if(await M1.update(),!b)y.stop("Stylelint configuration updated.");return}if(!b)y.message("Stylelint configuration not found, creating...");if(await M1.create(),!b)y.stop("Stylelint configuration created.")},$$=async(b=!1)=>{let y=w();if(!b)y.start("Checking for oxfmt configuration...");if(await c1.exists()){if(!b)y.message("oxfmt configuration found, updating...");if(await c1.update(),!b)y.stop("oxfmt configuration updated.");return}if(!b)y.message("oxfmt configuration not found, creating...");if(await c1.create(),!b)y.stop("oxfmt configuration created.")},G$=async(b,y=!0,$=!1,G=!1)=>{let v=w();if(!$)v.start("Initializing pre-commit hooks..."),v.message("Installing Husky...");if(await(y?e.install(b):L({devDependencies:{husky:"latest"},scripts:{prepare:"husky"}})),!$)v.message("Initializing Husky...");if(e.init(b.name),await e.exists()){if(!$)v.message("Pre-commit hook found, updating...");if(await e.update(b.name,G),!$)v.stop("Pre-commit hook updated.");return}if(!$)v.message("Pre-commit hook not found, creating...");if(await e.create(b.name,G),!$)v.stop("Pre-commit hook created.")},v$=async(b,y=!0,$=!1)=>{let G=w();if(!$)G.start("Initializing lefthook..."),G.message("Installing lefthook...");if(await(y?B1.install(b):L({devDependencies:{lefthook:"latest"}})),await B1.exists()){if(!$)G.message("lefthook.yml found, updating...");if(await B1.update(b.name),!$)G.stop("lefthook.yml updated.");return}if(!$)G.message("lefthook.yml not found, creating...");if(await B1.create(b.name),!$)G.stop("lefthook.yml created.")},U$=async(b,y=!0,$=!1)=>{let G=w();if(!$)G.start("Initializing lint-staged..."),G.message("Installing lint-staged...");if(await(y?A1.install(b):L({devDependencies:{"lint-staged":"latest"}})),await A1.exists()){if(!$)G.message("lint-staged found, updating...");if(await A1.update(b.name),!$)G.stop("lint-staged updated.");return}if(!$)G.message("lint-staged not found, creating...");if(await A1.create(b.name),!$)G.stop("lint-staged created.")},Q$=async(b,y=!1)=>{let $=w();if(!y)$.start("Initializing pre-commit...");if(await T1.exists()){if(!y)$.message(".pre-commit-config.yaml found, updating...");if(await T1.update(b),!y)$.stop(".pre-commit-config.yaml updated.");return}if(!y)$.message(".pre-commit-config.yaml not found, creating...");if(await T1.create(b),!y)$.stop(".pre-commit-config.yaml created.")},ub=async(b,y,$,G,v=!1)=>{let U=w();if(!v)U.start(`Checking for ${y}...`);let Q=_0(b,$,G);if(await Q.exists()){if(!v)U.message(`${y} found, updating...`);if(await Q.update(),!v)U.stop(`${y} updated.`);return}if(!v)U.message(`${y} not found, creating...`);if(await Q.create(),!v)U.stop(`${y} created.`)},W$=async(b,y,$,G=!1)=>{let v=`${b.displayName} (${b.path})`;await ub(b.representativeAgentId,v,y,$,G)},Z$=async(b,y="biome",$=!1)=>{await wb(b.representativeEditorId,y,$)},z$=async(b,y,$="biome",G=!1)=>{let v=w(),U=Y1.find((W)=>W.id===b)?.name??b;if(!G)v.start(`Checking for ${U} hooks...`);let Q=E0(b,y,$);if(await Q.exists()){if(!G)v.message(`${U} hooks found, updating...`);if(await Q.update(),!G)v.stop(`${U} hooks updated.`);return}if(!G)v.message(`${U} hooks not found, creating...`);if(await Q.create(),!G)v.stop(`${U} hooks created.`)},db=async(b)=>{let y=b??{},$=y.quiet??!1;if(!$)q2(`Ultracite v${B0} Initialization`);try{let G,v;if(y.pm)G=H1(y.pm),v={command:G,name:G};else{let Y=await M2(c2.cwd());if(!Y)throw Error("No package manager specified or detected");if(!$&&Y.warnings)for(let X of Y.warnings)d1.warn(X);if(!$)d1.info(`Detected lockfile, using ${Y.name}`);v=T0(Y),G=v.name}let{linter:U}=y;if(U===void 0)if($||y.pm||y.editors||y.agents||y.hooks||y.integrations!==void 0||y.frameworks!==void 0)U="biome";else{let X=await P2({message:"Which linter do you want to use?",options:[{label:"Biome (Recommended)",value:"biome"},{label:"ESLint + Prettier + Stylelint",value:"eslint"},{label:"Oxlint + Oxfmt",value:"oxlint"}]});if($1(X)){y1(G1);return}U=X}let{frameworks:Q}=y;if(Q===void 0)if($||y.pm||y.editors||y.agents||y.hooks||y.integrations!==void 0)Q=[];else{let X=await L0(),N1=await J1({initialValues:X,message:"Which frameworks are you using (optional)?",options:[{label:"React",value:"react"},{label:"Next.js",value:"next"},{label:"Solid",value:"solid"},{label:"Vue",value:"vue"},{label:"Svelte",value:"svelte"},{label:"Qwik",value:"qwik"},{label:"Angular",value:"angular"},{label:"Remix / React Router (file-route conventions)",value:"remix"},{label:"TanStack (Query, Router, Start)",value:"tanstack"},{label:"Astro",value:"astro"},{label:"NestJS",value:"nestjs"},{label:"Jest",value:"jest"},{label:"Vitest / Bun",value:"vitest"}],required:!1});if($1(N1)){y1(G1);return}Q=N1}let W=y.editors,o=[],B=h0(),K=B.find((Y)=>Y.id==="universal");if(!W){if(!$){let Y=await J1({message:"Which editors do you want to configure (recommended)?",options:B.map((X)=>({label:X.promptLabel,value:X.id})),required:!1});if($1(Y)){y1(G1);return}o=B.filter((X)=>Y.includes(X.id))}W=[]}else if(W.includes("universal")&&K){o=[K];let Y=new Set(K.editorIds);W=W.filter((X)=>X!=="universal"&&!Y.has(X))}let{agents:N}=y,u=[],{hooks:R}=y,l1=m0(),r1=l1.find((Y)=>Y.id==="universal"),Db=Object.fromEntries(l.map((Y)=>[Y.id,Y.name]));if(!N)if($)N=[];else{let Y=await J1({message:"Which agent files do you want to add (optional)?",options:l1.map((X)=>({label:X.promptLabel,value:X.id})),required:!1});if($1(Y)){y1(G1);return}u=l1.filter((X)=>Y.includes(X.id))}else if(N.includes("universal")&&r1){u=[r1];let Y=new Set(r1.agentIds);N=N.filter((X)=>X!=="universal"&&!Y.has(X))}let Nb=Object.fromEntries(Y1.map((Y)=>[Y.id,Y.name]));if(!R)if($)R=[];else{let Y=await J1({message:"Which agent hooks do you want to enable (optional)?",options:Object.entries(Nb).map(([X,N1])=>({label:N1,value:X})),required:!1});if($1(Y)){y1(G1);return}R=Y}let{integrations:E}=y;if(E===void 0)if($||y.pm||y.editors||y.agents||y.hooks)E=[];else{let X=await J1({message:"Would you like any of the following (optional)?",options:[{label:"Husky pre-commit hook",value:"husky"},{label:"Lefthook pre-commit hook",value:"lefthook"},{label:"Lint-staged",value:V0},{label:"pre-commit (Python framework)",value:"pre-commit"}],required:!1});if($1(X)){y1(G1);return}E=X}if(await i2(v,U,!y.skipInstall,$,y["type-aware"],Q),await t2($),await C2(U,$),U==="biome")await g2(Q,$,y["type-aware"]);if(U==="eslint")await a2(Q,$),await b$(Q,$),await y$($);if(U==="oxlint")await L({type:"module"}),await e2(Q,$),await $$($);if(await Promise.all(o.map((Y)=>Z$(Y,U,$))),await Promise.all((W??[]).map((Y)=>wb(Y,U,$))),await Promise.all(u.map((Y)=>W$(Y,G,U,$))),await Promise.all((N??[]).map((Y)=>ub(Y,Db[Y],G,U,$))),await Promise.all((R??[]).map((Y)=>z$(Y,G,U,$))),E?.includes("husky")){let Y=E?.includes(V0)??!1;await G$(v,!y.skipInstall,$,Y)}if(E?.includes("lefthook"))await v$(v,!y.skipInstall,$);if(E?.includes(V0))await U$(v,!y.skipInstall,$);if(E?.includes("pre-commit"))await Q$(G,$);if(!$)d1.success("Successfully initialized Ultracite!");let Lb=await Yb({packageManager:G,quiet:$,shouldInstall:y.installSkill});if(!$&&!Lb)d1.info(`You can install the Ultracite skill later with \`${zb(G)}\`.`)}catch(G){let v=G instanceof Error?G.message:"Unknown error";if(!$)d1.error(`Failed to initialize Ultracite configuration: ${v}`);throw G}};var v1=new Y$,Jb=(b)=>b.parent?.rawArgs;v1.name("ultracite").version(z.version,"-v, --version").description(z.description);v1.command("init").description("Initialize Ultracite in the current directory").option("--pm <pm>","Package manager to use").option("--linter <linter>","Linter to use").option("--editors <editors...>","Editors to configure (use universal for .vscode/settings.json)").option("--agents <agents...>","Agents to enable (use universal for AGENTS.md)").option("--hooks <hooks...>","Hooks to enable").option("--frameworks <frameworks...>","Frameworks being used").option("--integrations <integrations...>","Integrations to enable").option("--install-skill","Install the reusable Ultracite skill after setup").option("--type-aware","Enable type-aware linting (enables project/scanner rules)").option("--skip-install","Skip installing dependencies").option("--quiet","Suppress interactive prompts").action(async(b)=>{await db({agents:b.agents,editors:b.editors,frameworks:b.frameworks,hooks:b.hooks,installSkill:b.installSkill,integrations:b.integrations,linter:b.linter,pm:b.pm,quiet:b.quiet??(D1.env.CI==="true"||D1.env.CI==="1"),skipInstall:b.skipInstall,"type-aware":b.typeAware})});v1.command("check").argument("[files...]","Files to check").description("Run linter without fixing files. Unknown options are passed to the underlying linter.").allowUnknownOption().action(async(b,y,$)=>{let{files:G,passthrough:v}=k1({commandName:"check",parsedArgs:b,rawArgs:Jb($)});await x0(G,v)});v1.command("fix").argument("[files...]","Files to fix").description("Run linter and fix files. Unknown options are passed to the underlying linter.").allowUnknownOption().action(async(b,y,$)=>{let{files:G,passthrough:v}=k1({commandName:"fix",parsedArgs:b,rawArgs:Jb($)});await R0(G,v)});v1.command("doctor").description("Verify your Ultracite setup").action(async()=>{await S0()});if(!D1.env.TEST)try{await v1.parseAsync()}catch(b){if(b instanceof r)D1.exit(b.exitCode);if(b instanceof Error&&b.message==="Doctor checks failed")D1.exit(1);throw b}export{v1 as program};
|
|
260
|
+
`},f1={create:async(b)=>{let y=$b(b);await Z(Z0,y)},exists:()=>{return bb()!==null},update:async(b)=>{let y=$b(b),$=bb();await Z($===z0?Z0:$??Z0,y)}};var H0="./package.json",u2=i.map((b)=>`./${b}`),Y0="./stylelint.config.mjs",D2=()=>{return E(H0)?.stylelint!==void 0},Gb=()=>{if(D2())return H0;for(let b of u2)if(H(b))return b;return null},vb=()=>`export { default } from "ultracite/stylelint";
|
|
261
|
+
`,P1={create:async()=>{let b=vb();await Z(Y0,b)},exists:()=>{return Gb()!==null},update:async()=>{let b=vb(),y=Gb();await Z(y===H0?Y0:y??Y0,b)}};import{isCancel as d2,select as o2,spinner as x2}from"@clack/prompts";import{dlxCommand as Qb}from"nypm";var N2="haydenbleasel/ultracite",S2="ultracite",Wb=(b)=>Qb(b,"skills",{args:["add",N2],short:b==="npm"}),L2=(b,y=!1)=>Qb(b,"skills",{args:y?["list","-g","--json"]:["list","--json"],short:b==="npm"}),Ub=(b,y=!1)=>{let $=L2(b,y),[G,...v]=$.split(" "),U=w(G,v,{encoding:"utf-8",stdio:"pipe"});if(U.error||U.status!==0||!U.stdout)return!1;try{return JSON.parse(typeof U.stdout==="string"?U.stdout:U.stdout.toString("utf-8")).some((W)=>W.name===S2)}catch{return!1}},R2=(b)=>Ub(b)||Ub(b,!0),I2=async()=>{let b=await o2({message:"Do you want to install the Ultracite skill?",options:[{label:"Yes, install it",value:"install"},{label:"No, I'll do it later",value:"skip"}]});return!d2(b)&&b==="install"},Zb=(b)=>Wb(b),zb=async({packageManager:b,quiet:y=!1,shouldInstall:$})=>{if($===void 0&&!y&&R2(b))return!0;if(!($??(!y&&await I2())))return!1;let v=Wb(b),[U,...Q]=v.split(" "),W=x2();if(!y)W.start("Installing the Ultracite skill...");let X=w(U,Q,{stdio:"pipe"}),V=!X.error&&X.status===0;if(!y)W.stop(V?"Ultracite skill installed.":"Couldn't install the Ultracite skill automatically.");return V};import{readFile as F2}from"node:fs/promises";import{log as _2}from"@clack/prompts";import{glob as m2}from"glob";import{applyEdits as h2,modify as O2}from"jsonc-parser";var Yb=async()=>{try{return await m2("**/tsconfig*.json",{absolute:!1,ignore:["**/node_modules/**","**/dist/**","**/build/**","**/.next/**"]})}catch{return[]}},T2=(b)=>{if(!b?.compilerOptions)return!1;if(b.compilerOptions.strict===!0)return!0;return b.compilerOptions.strictNullChecks===!0},q2=async(b)=>{try{let y=await F2(b,"utf-8"),$=L1(y,K0);if(T2($))return;if($===void 0){await Z(b,`${JSON.stringify({compilerOptions:{strictNullChecks:!0}},null,2)}
|
|
262
|
+
`);return}let v=O2(y,["compilerOptions","strictNullChecks"],!0,{formattingOptions:{insertSpaces:!0,tabSize:2}}),U=h2(y,v);await Z(b,U)}catch(y){_2.warn(`Failed to update ${b}: ${y instanceof Error?y.message:y}`)}},X0={exists:async()=>{return(await Yb()).length>0},update:async()=>{let b=await Yb();if(b.length===0)return;await Promise.all(b.map((y)=>q2(y)))}};var Bb=z.devDependencies["@biomejs/biome"],V0=z.version,G1="Operation cancelled.",B0="lint-staged",Hb="^10.0.0",Vb={"@eslint/js":Hb,"@typescript-eslint/eslint-plugin":z.devDependencies["@typescript-eslint/eslint-plugin"],"@typescript-eslint/parser":z.devDependencies["@typescript-eslint/parser"],eslint:Hb,"eslint-config-prettier":z.devDependencies["eslint-config-prettier"],"eslint-import-resolver-typescript":z.devDependencies["eslint-import-resolver-typescript"],"eslint-plugin-compat":z.devDependencies["eslint-plugin-compat"],"eslint-plugin-cypress":z.devDependencies["eslint-plugin-cypress"],"eslint-plugin-github":z.devDependencies["eslint-plugin-github"],"eslint-plugin-html":z.devDependencies["eslint-plugin-html"],"eslint-plugin-import-x":z.devDependencies["eslint-plugin-import-x"],"eslint-plugin-jsdoc":z.devDependencies["eslint-plugin-jsdoc"],"eslint-plugin-n":z.devDependencies["eslint-plugin-n"],"eslint-plugin-prettier":z.devDependencies["eslint-plugin-prettier"],"eslint-plugin-promise":z.devDependencies["eslint-plugin-promise"],"eslint-plugin-sonarjs":z.devDependencies["eslint-plugin-sonarjs"],"eslint-plugin-storybook":z.devDependencies["eslint-plugin-storybook"],"eslint-plugin-unicorn":z.devDependencies["eslint-plugin-unicorn"],"eslint-plugin-unused-imports":z.devDependencies["eslint-plugin-unused-imports"],globals:z.devDependencies.globals,prettier:"latest","prettier-plugin-tailwindcss":z.devDependencies["prettier-plugin-tailwindcss"],storybook:z.devDependencies.storybook,stylelint:"latest","stylelint-config-idiomatic-order":z.devDependencies["stylelint-config-idiomatic-order"],"stylelint-config-standard":z.devDependencies["stylelint-config-standard"],"stylelint-prettier":z.devDependencies["stylelint-prettier"]},jb={angular:{"@angular-eslint/eslint-plugin":"latest"},astro:{"eslint-plugin-astro":z.devDependencies["eslint-plugin-astro"],"prettier-plugin-astro":z.devDependencies["prettier-plugin-astro"]},jest:{"eslint-plugin-jest":z.devDependencies["eslint-plugin-jest"]},next:{"@next/eslint-plugin-next":z.devDependencies["@next/eslint-plugin-next"],"eslint-plugin-react-doctor":z.devDependencies["eslint-plugin-react-doctor"]},qwik:{"eslint-plugin-qwik":z.devDependencies["eslint-plugin-qwik"]},react:{"eslint-plugin-jsx-a11y":z.devDependencies["eslint-plugin-jsx-a11y"],"eslint-plugin-react":z.devDependencies["eslint-plugin-react"],"eslint-plugin-react-doctor":z.devDependencies["eslint-plugin-react-doctor"],"eslint-plugin-react-hooks":z.devDependencies["eslint-plugin-react-hooks"]},remix:{"eslint-plugin-remix":z.devDependencies["eslint-plugin-remix"]},solid:{"eslint-plugin-solid":z.devDependencies["eslint-plugin-solid"]},svelte:{"eslint-plugin-svelte":z.devDependencies["eslint-plugin-svelte"],"prettier-plugin-svelte":z.devDependencies["prettier-plugin-svelte"]},tanstack:{"@tanstack/eslint-plugin-query":z.devDependencies["@tanstack/eslint-plugin-query"],"@tanstack/eslint-plugin-router":z.devDependencies["@tanstack/eslint-plugin-router"],"@tanstack/eslint-plugin-start":z.devDependencies["@tanstack/eslint-plugin-start"],"eslint-plugin-react-doctor":z.devDependencies["eslint-plugin-react-doctor"]},vitest:{"@vitest/eslint-plugin":z.devDependencies["@vitest/eslint-plugin"]},vue:{"eslint-plugin-vue":z.devDependencies["eslint-plugin-vue"]}},wb=(b)=>{let y={...Vb};for(let $ of b)Object.assign(y,jb[$]);return y},P2=(b,y,$)=>{let G={ultracite:V0};if(b==="biome")G["@biomejs/biome"]=Bb;if(b==="eslint")Object.assign(G,wb($));if(b==="oxlint"){if(G.oxlint="latest",G.oxfmt="latest",y)G["oxlint-tsgolint"]="latest"}return G},k2=new Set([...Object.keys(Vb),...Object.values(jb).flatMap((b)=>Object.keys(b??{}))]),Xb={biome:new Set(["@biomejs/biome"]),eslint:k2,oxlint:new Set(["oxfmt","oxlint","oxlint-plugin-react-doctor","oxlint-tsgolint"])},r2=async(b)=>{let y=b.startsWith("./")?b:`./${b}`;if(!H(y))return!1;let{rm:$}=await import("node:fs/promises");return await $(y,{force:!0}),!0},l2=async(b)=>{let y=await s();if(!y)return!1;let $=new Set;for(let[U,Q]of Object.entries(Xb))if(U!==b)for(let W of Q)$.add(W);for(let U of Xb[b])$.delete(U);let G=!1,v={...y};for(let U of["dependencies","devDependencies","peerDependencies"]){let Q=v[U];if(!Q)continue;let W=Object.entries(Q),X=W.filter(([K])=>!$.has(K));if(X.length!==W.length)G=!0;let V=Object.fromEntries(X);v[U]=V}if("prettier"in v)delete v.prettier,G=!0;if("stylelint"in v)delete v.stylelint,G=!0;if(!G)return!1;return await Z("package.json",`${JSON.stringify(v,null,2)}
|
|
263
|
+
`),!0},C2=async(b,y=!1)=>{let $=J();if(!y)$.start("Checking for stale linter configuration...");let G=new Set;if(b!=="biome")for(let W of p)G.add(W);if(b!=="eslint"){for(let W of P)G.add(W);for(let W of n)G.add(W);for(let W of i)G.add(W)}for(let W of d0)G.add(W);if(b!=="oxlint"){for(let W of g1)G.add(W);for(let W of o0)G.add(W)}let[v,U]=await Promise.all([Promise.all([...G].map((W)=>r2(W))),l2(b)]),Q=v.some(Boolean)||U;if(!y)$.stop(Q?"Stale linter configuration migrated.":"No stale linter configuration found.")},s2=async(b,y="biome",$=!0,G=!1,v=!1,U=["react"])=>{let Q=J();if(!G)Q.start("Installing dependencies...");let W=[`ultracite@${V0}`];if(y==="biome")W.push(`@biomejs/biome@${Bb}`);if(y==="eslint")W.push(...Object.entries(wb(U)).map(([V,K])=>`${V}@${K}`));if(y==="oxlint"){if(W.push("oxlint@latest","oxfmt@latest"),v)W.push("oxlint-tsgolint@latest")}let X={check:"ultracite check",fix:"ultracite fix"};if($)await c2(W,{corepack:!1,packageManager:b,silent:!0,workspace:M()&&b.name!=="npm"}),await N({scripts:X});else{let V=P2(y,v,U);await N({devDependencies:V,scripts:X})}if(!G)Q.stop("Dependencies installed.")},n2=async(b=!1)=>{let y=J();if(!b)y.start("Checking for tsconfig.json files...");if(await X0.exists()){if(!b)y.message("Found tsconfig.json files, updating with strictNullChecks...");if(await X0.update(),!b)y.stop("tsconfig.json files updated.");return}if(!b)y.stop("No tsconfig.json files found, skipping.")},Kb=async(b,y="biome",$=!1)=>{let G=c.find((Q)=>Q.id===b);if(!G)throw Error(`Editor "${b}" not found`);let v=_0(b,y),U=J();if(!$)U.start(`Checking for ${G.config.path}...`);if(await v.exists()){if(!$)U.message(`${G.config.path} found, updating...`);if(await v.update(),!$)U.stop(`${G.config.path} updated.`);return}if(!$)U.message(`${G.config.path} not found, creating...`);if(await v.create(),v.extension){let Q=_1.find((W)=>W.id===y)?.vscodeExtensionId;if(!Q)throw Error(`Linter extension not found for ${y}`);if(!$)U.message(`Installing ${Q} extension...`);try{if(v.extension(Q).status===0){if(!$)U.stop(`${G.config.path} created and ${Q} extension installed.`);return}}catch{}if(!$)U.stop(`${G.config.path} created. Install ${Q} extension manually.`);return}if(!$)if(b==="zed")U.stop(`${G.config.path} created. Install the Biome extension: https://biomejs.dev/reference/zed/`);else U.stop(`${G.config.path} created.`)},i2=async(b,y=!1,$=!1)=>{let G=J();if(!y)G.start("Checking for Biome configuration...");if(await q1.exists()){if(!y)G.message("Biome configuration found, updating...");if(await q1.update({frameworks:b,typeAware:$}),!y)G.stop("Biome configuration updated.");return}if(!y)G.message("Biome configuration not found, creating...");if(await q1.create({frameworks:b,typeAware:$}),!y)G.stop("Biome configuration created.")},t2=async(b,y=!1)=>{let $=J();if(!y)$.start("Checking for ESLint configuration...");if(await E1.exists()){if(!y)$.message("ESLint configuration found, updating...");if(await E1.update({frameworks:b}),!y)$.stop("ESLint configuration updated.");return}if(!y)$.message("ESLint configuration not found, creating...");if(await E1.create({frameworks:b}),!y)$.stop("ESLint configuration created.")},g2=async(b,y=!1)=>{let $=J();if(!y)$.start("Checking for Oxlint configuration...");if(await c1.exists()){if(!y)$.message("Oxlint configuration found, updating...");if(await c1.update({frameworks:b}),!y)$.stop("Oxlint configuration updated.");return}if(!y)$.message("Oxlint configuration not found, creating...");if(await c1.create({frameworks:b}),!y)$.stop("Oxlint configuration created.")},a2=async(b,y=!1)=>{let $=J();if(!y)$.start("Checking for Prettier configuration...");if(await f1.exists()){if(!y)$.message("Prettier configuration found, updating...");if(await f1.update({frameworks:b}),!y)$.stop("Prettier configuration updated.");return}if(!y)$.message("Prettier configuration not found, creating...");if(await f1.create({frameworks:b}),!y)$.stop("Prettier configuration created.")},e2=async(b=!1)=>{let y=J();if(!b)y.start("Checking for Stylelint configuration...");if(await P1.exists()){if(!b)y.message("Stylelint configuration found, updating...");if(await P1.update(),!b)y.stop("Stylelint configuration updated.");return}if(!b)y.message("Stylelint configuration not found, creating...");if(await P1.create(),!b)y.stop("Stylelint configuration created.")},b$=async(b=!1)=>{let y=J();if(!b)y.start("Checking for oxfmt configuration...");if(await M1.exists()){if(!b)y.message("oxfmt configuration found, updating...");if(await M1.update(),!b)y.stop("oxfmt configuration updated.");return}if(!b)y.message("oxfmt configuration not found, creating...");if(await M1.create(),!b)y.stop("oxfmt configuration created.")},y$=async(b,y=!0,$=!1,G=!1)=>{let v=J();if(!$)v.start("Initializing pre-commit hooks..."),v.message("Installing Husky...");if(await(y?e.install(b):N({devDependencies:{husky:"latest"},scripts:{prepare:"husky"}})),!$)v.message("Initializing Husky...");if(e.init(b.name),await e.exists()){if(!$)v.message("Pre-commit hook found, updating...");if(await e.update(b.name,G),!$)v.stop("Pre-commit hook updated.");return}if(!$)v.message("Pre-commit hook not found, creating...");if(await e.create(b.name,G),!$)v.stop("Pre-commit hook created.")},$$=async(b,y=!0,$=!1)=>{let G=J();if(!$)G.start("Initializing lefthook..."),G.message("Installing lefthook...");if(await(y?V1.install(b):N({devDependencies:{lefthook:"latest"}})),await V1.exists()){if(!$)G.message("lefthook.yml found, updating...");if(await V1.update(b.name),!$)G.stop("lefthook.yml updated.");return}if(!$)G.message("lefthook.yml not found, creating...");if(await V1.create(b.name),!$)G.stop("lefthook.yml created.")},G$=async(b,y=!0,$=!1)=>{let G=J();if(!$)G.start("Initializing lint-staged..."),G.message("Installing lint-staged...");if(await(y?A1.install(b):N({devDependencies:{"lint-staged":"latest"}})),await A1.exists()){if(!$)G.message("lint-staged found, updating...");if(await A1.update(b.name),!$)G.stop("lint-staged updated.");return}if(!$)G.message("lint-staged not found, creating...");if(await A1.create(b.name),!$)G.stop("lint-staged created.")},v$=async(b,y=!1)=>{let $=J();if(!y)$.start("Initializing pre-commit...");if(await T1.exists()){if(!y)$.message(".pre-commit-config.yaml found, updating...");if(await T1.update(b),!y)$.stop(".pre-commit-config.yaml updated.");return}if(!y)$.message(".pre-commit-config.yaml not found, creating...");if(await T1.create(b),!y)$.stop(".pre-commit-config.yaml created.")},Ab=async(b,y,$,G,v=!1)=>{let U=J();if(!v)U.start(`Checking for ${y}...`);let Q=F0(b,$,G);if(await Q.exists()){if(!v)U.message(`${y} found, updating...`);if(await Q.update(),!v)U.stop(`${y} updated.`);return}if(!v)U.message(`${y} not found, creating...`);if(await Q.create(),!v)U.stop(`${y} created.`)},U$=async(b,y,$,G=!1)=>{let v=`${b.displayName} (${b.path})`;await Ab(b.representativeAgentId,v,y,$,G)},Q$=async(b,y="biome",$=!1)=>{await Kb(b.representativeEditorId,y,$)},W$=async(b,y,$="biome",G=!1)=>{let v=J(),U=Y1.find((W)=>W.id===b)?.name??b;if(!G)v.start(`Checking for ${U} hooks...`);let Q=T0(b,y,$);if(await Q.exists()){if(!G)v.message(`${U} hooks found, updating...`);if(await Q.update(),!G)v.stop(`${U} hooks updated.`);return}if(!G)v.message(`${U} hooks not found, creating...`);if(await Q.create(),!G)v.stop(`${U} hooks created.`)},Jb=async(b)=>{let y=b??{},$=y.quiet??!1;if(!$)M2(`Ultracite v${V0} Initialization`);try{let G,v;if(y.pm)G=H1(y.pm),v={command:G,name:G};else{let Y=await f2(E2.cwd());if(!Y)throw Error("No package manager specified or detected");if(!$&&Y.warnings)for(let j of Y.warnings)D1.warn(j);if(!$)D1.info(`Detected lockfile, using ${Y.name}`);v=O0(Y),G=v.name}let{linter:U}=y;if(U===void 0)if($||y.pm||y.editors||y.agents||y.hooks||y.integrations!==void 0||y.frameworks!==void 0)U="biome";else{let j=await p2({message:"Which linter do you want to use?",options:[{label:"Biome (Recommended)",value:"biome"},{label:"ESLint + Prettier + Stylelint",value:"eslint"},{label:"Oxlint + Oxfmt",value:"oxlint"}]});if($1(j)){y1(G1);return}U=j}let{frameworks:Q}=y;if(Q===void 0)if($||y.pm||y.editors||y.agents||y.hooks||y.integrations!==void 0)Q=[];else{let j=await x0(),x1=await d1({initialValues:j,message:"Which frameworks are you using (optional)?",options:[{label:"React",value:"react"},{label:"Next.js",value:"next"},{label:"Solid",value:"solid"},{label:"Vue",value:"vue"},{label:"Svelte",value:"svelte"},{label:"Qwik",value:"qwik"},{label:"Angular",value:"angular"},{label:"Remix / React Router (file-route conventions)",value:"remix"},{label:"TanStack (Query, Router, Start)",value:"tanstack"},{label:"Astro",value:"astro"},{label:"NestJS",value:"nestjs"},{label:"Jest",value:"jest"},{label:"Vitest / Bun",value:"vitest"}],required:!1});if($1(x1)){y1(G1);return}Q=x1}let W=y.editors,X=[],V=m0(),K=V.find((Y)=>Y.id==="universal");if(!W){if(!$){let Y=await d1({message:"Which editors do you want to configure (recommended)?",options:V.map((j)=>({label:j.promptLabel,value:j.id})),required:!1});if($1(Y)){y1(G1);return}X=V.filter((j)=>Y.includes(j.id))}W=[]}else if(W.includes("universal")&&K){X=[K];let Y=new Set(K.editorIds);W=W.filter((j)=>j!=="universal"&&!Y.has(j))}let{agents:x}=y,u=[],{hooks:R}=y,k1=I0(),r1=k1.find((Y)=>Y.id==="universal"),Db=Object.fromEntries(k.map((Y)=>[Y.id,Y.name]));if(!x)if($)x=[];else{let Y=await d1({message:"Which agent files do you want to add (optional)?",options:k1.map((j)=>({label:j.promptLabel,value:j.id})),required:!1});if($1(Y)){y1(G1);return}u=k1.filter((j)=>Y.includes(j.id))}else if(x.includes("universal")&&r1){u=[r1];let Y=new Set(r1.agentIds);x=x.filter((j)=>j!=="universal"&&!Y.has(j))}let db=Object.fromEntries(Y1.map((Y)=>[Y.id,Y.name]));if(!R)if($)R=[];else{let Y=await d1({message:"Which agent hooks do you want to enable (optional)?",options:Object.entries(db).map(([j,x1])=>({label:x1,value:j})),required:!1});if($1(Y)){y1(G1);return}R=Y}let{integrations:q}=y;if(q===void 0)if($||y.pm||y.editors||y.agents||y.hooks)q=[];else{let j=await d1({message:"Would you like any of the following (optional)?",options:[{label:"Husky pre-commit hook",value:"husky"},{label:"Lefthook pre-commit hook",value:"lefthook"},{label:"Lint-staged",value:B0},{label:"pre-commit (Python framework)",value:"pre-commit"}],required:!1});if($1(j)){y1(G1);return}q=j}if(await s2(v,U,!y.skipInstall,$,y["type-aware"],Q),await n2($),await C2(U,$),U==="biome")await i2(Q,$,y["type-aware"]);if(U==="eslint")await t2(Q,$),await a2(Q,$),await e2($);if(U==="oxlint")await N({type:"module"}),await g2(Q,$),await b$($);if(await Promise.all(X.map((Y)=>Q$(Y,U,$))),await Promise.all((W??[]).map((Y)=>Kb(Y,U,$))),await Promise.all(u.map((Y)=>U$(Y,G,U,$))),await Promise.all((x??[]).map((Y)=>Ab(Y,Db[Y],G,U,$))),await Promise.all((R??[]).map((Y)=>W$(Y,G,U,$))),q?.includes("husky")){let Y=q?.includes(B0)??!1;await y$(v,!y.skipInstall,$,Y)}if(q?.includes("lefthook"))await $$(v,!y.skipInstall,$);if(q?.includes(B0))await G$(v,!y.skipInstall,$);if(q?.includes("pre-commit"))await v$(G,$);if(!$)D1.success("Successfully initialized Ultracite!");let ob=await zb({packageManager:G,quiet:$,shouldInstall:y.installSkill});if(!$&&!ob)D1.info(`You can install the Ultracite skill later with \`${Zb(G)}\`.`)}catch(G){let v=G instanceof Error?G.message:"Unknown error";if(!$)D1.error(`Failed to initialize Ultracite configuration: ${v}`);throw G}};var v1=new Z$,ub=(b)=>b.parent?.rawArgs;v1.name("ultracite").version(z.version,"-v, --version").description(z.description);v1.command("init").description("Initialize Ultracite in the current directory").option("--pm <pm>","Package manager to use").option("--linter <linter>","Linter to use").option("--editors <editors...>","Editors to configure (use universal for .vscode/settings.json)").option("--agents <agents...>","Agents to enable (use universal for AGENTS.md)").option("--hooks <hooks...>","Hooks to enable").option("--frameworks <frameworks...>","Frameworks being used").option("--integrations <integrations...>","Integrations to enable").option("--install-skill","Install the reusable Ultracite skill after setup").option("--type-aware","Enable type-aware linting (enables project/scanner rules)").option("--skip-install","Skip installing dependencies").option("--quiet","Suppress interactive prompts").action(async(b)=>{await Jb({agents:b.agents,editors:b.editors,frameworks:b.frameworks,hooks:b.hooks,installSkill:b.installSkill,integrations:b.integrations,linter:b.linter,pm:b.pm,quiet:b.quiet??(o1.env.CI==="true"||o1.env.CI==="1"),skipInstall:b.skipInstall,"type-aware":b.typeAware})});v1.command("check").argument("[files...]","Files to check").description("Run linter without fixing files. Unknown options are passed to the underlying linter.").allowUnknownOption().action(async(b,y,$)=>{let{files:G,passthrough:v}=C1({commandName:"check",parsedArgs:b,rawArgs:ub($)});await N0(G,v)});v1.command("fix").argument("[files...]","Files to fix").description("Run linter and fix files. Unknown options are passed to the underlying linter.").allowUnknownOption().action(async(b,y,$)=>{let{files:G,passthrough:v}=C1({commandName:"fix",parsedArgs:b,rawArgs:ub($)});await L0(G,v)});v1.command("doctor").description("Verify your Ultracite setup").action(async()=>{await S0()});if(!o1.env.TEST)try{await v1.parseAsync()}catch(b){if(b instanceof r)o1.exit(b.exitCode);if(b instanceof Error&&b.message==="Doctor checks failed")o1.exit(1);throw b}export{v1 as program};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ultracite",
|
|
3
|
-
"version": "7.9.
|
|
3
|
+
"version": "7.9.3",
|
|
4
4
|
"description": "The AI-ready formatter that helps you write and generate code faster.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"biome",
|
|
@@ -109,11 +109,12 @@
|
|
|
109
109
|
"eslint-plugin-unused-imports": "^4.4.1",
|
|
110
110
|
"eslint-plugin-vue": "^10.9.2",
|
|
111
111
|
"globals": "^17.7.0",
|
|
112
|
-
"oxlint": "^1.
|
|
112
|
+
"oxlint": "^1.73.0",
|
|
113
113
|
"oxlint-plugin-react-doctor": "^0.7.1",
|
|
114
114
|
"prettier-plugin-astro": "^0.14.1",
|
|
115
115
|
"prettier-plugin-svelte": "^4.1.0",
|
|
116
116
|
"prettier-plugin-tailwindcss": "^0.8.0",
|
|
117
|
+
"storybook": "^10.4.6",
|
|
117
118
|
"stylelint-config-idiomatic-order": "^10.0.0",
|
|
118
119
|
"stylelint-config-standard": "^40.0.0",
|
|
119
120
|
"stylelint-prettier": "^5.0.3"
|