ultracite 5.2.9 → 5.2.11
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/index.d.ts +36 -0
- package/dist/index.js +24 -24
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,37 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { trpcServer, TrpcCliMeta } from 'trpc-cli';
|
|
3
|
+
|
|
4
|
+
declare const router: trpcServer.TRPCBuiltRouter<{
|
|
5
|
+
ctx: object;
|
|
6
|
+
meta: TrpcCliMeta;
|
|
7
|
+
errorShape: trpcServer.TRPCDefaultErrorShape;
|
|
8
|
+
transformer: false;
|
|
9
|
+
}, trpcServer.TRPCDecorateCreateRouterOptions<{
|
|
10
|
+
init: trpcServer.TRPCMutationProcedure<{
|
|
11
|
+
input: {
|
|
12
|
+
pm?: "npm" | "yarn" | "pnpm" | "bun" | "deno" | undefined;
|
|
13
|
+
editors?: ("vscode" | "zed")[] | undefined;
|
|
14
|
+
rules?: ("zed" | "vscode-copilot" | "cursor" | "windsurf" | "claude" | "codex" | "kiro" | "cline" | "amp" | "aider" | "firebase-studio" | "open-hands" | "gemini-cli" | "junie" | "augmentcode" | "kilo-code" | "goose")[] | undefined;
|
|
15
|
+
integrations?: ("husky" | "lefthook" | "lint-staged")[] | undefined;
|
|
16
|
+
removePrettier?: boolean | undefined;
|
|
17
|
+
removeEslint?: boolean | undefined;
|
|
18
|
+
skipInstall?: boolean | undefined;
|
|
19
|
+
};
|
|
20
|
+
output: void;
|
|
21
|
+
meta: TrpcCliMeta;
|
|
22
|
+
}>;
|
|
23
|
+
lint: trpcServer.TRPCQueryProcedure<{
|
|
24
|
+
input: string[] | undefined;
|
|
25
|
+
output: void;
|
|
26
|
+
meta: TrpcCliMeta;
|
|
27
|
+
}>;
|
|
28
|
+
format: trpcServer.TRPCMutationProcedure<{
|
|
29
|
+
input: [string[] | undefined, {
|
|
30
|
+
unsafe?: boolean | undefined;
|
|
31
|
+
}];
|
|
32
|
+
output: void;
|
|
33
|
+
meta: TrpcCliMeta;
|
|
34
|
+
}>;
|
|
35
|
+
}>>;
|
|
36
|
+
|
|
37
|
+
export { router };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
2
|
+
var W=Object.defineProperty;var He=Object.getOwnPropertyDescriptor;var Ke=Object.getOwnPropertyNames;var Xe=Object.prototype.hasOwnProperty;var q=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,s)=>(typeof require<"u"?require:t)[s]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),se=e=>t=>{var s=e[t];if(s)return s();throw new Error("Module not found in bundle: "+t)};var D=(e,t)=>()=>(e&&(t=e(e=0)),t);var B=(e,t)=>{for(var s in t)W(e,s,{get:t[s],enumerable:!0})},Ye=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ke(t))!Xe.call(e,o)&&o!==s&&W(e,o,{get:()=>t[o],enumerable:!(n=He(t,o))||n.enumerable});return e};var G=e=>Ye(W({},"__esModule",{value:!0}),e);import{access as Qe,readFile as ne,writeFile as et}from"fs/promises";import{parse as tt}from"jsonc-parser";var a,g,oe,j,st,nt,M,p=D(()=>{"use strict";a=async e=>{try{return await Qe(e),!0}catch{return!1}},g=async()=>{if(await a("pnpm-workspace.yaml"))return!0;try{let e=tt(await ne("package.json","utf-8"));return e?!!e.workspaces||!!e.workspace:!1}catch{return!1}},oe=`
|
|
3
3
|
888 888 888 88888888888 8888888b. d8888 .d8888b. 8888888 88888888888 8888888888
|
|
4
4
|
888 888 888 888 888 Y88b d88888 d88P Y88b 888 888 888
|
|
5
5
|
888 888 888 888 888 888 d88P888 888 888 888 888 888
|
|
@@ -8,10 +8,10 @@ var L=Object.defineProperty;var Be=Object.getOwnPropertyDescriptor;var Ge=Object
|
|
|
8
8
|
888 888 888 888 888 T88b d88P 888 888 888 888 888 888
|
|
9
9
|
Y88b. .d88P 888 888 888 T88b d8888888888 Y88b d88P 888 888 888
|
|
10
10
|
"Y88888P" 88888888 888 888 T88b d88P 888 "Y8888P" 8888888 888 8888888888
|
|
11
|
-
`,
|
|
12
|
-
${s}`)}}});var
|
|
11
|
+
`,j=async({dependencies:e,devDependencies:t})=>{let s=await ne("package.json","utf8"),n=JSON.parse(s),o={...n,devDependencies:{...n.devDependencies,...t},dependencies:{...n.dependencies,...e}};await et("package.json",JSON.stringify(o,null,2))},st=/[ $(){}[\]&|;<>!"'`*?#~]/,nt=/'/g,M=e=>e.map(t=>st.test(t)?`'${t.replace(nt,"'\\''")}' `:t)});var Se={};B(Se,{husky:()=>v});import{mkdir as xt,readFile as Dt,writeFile as Ce}from"fs/promises";import{addDevDependency as jt,dlxCommand as Pe}from"nypm";var O,v,H=D(()=>{"use strict";p();O="./.husky/pre-commit",v={exists:()=>a(O),install:async e=>{await jt("husky",{packageManager:e,workspace:await g()})},create:async e=>{await xt(".husky",{recursive:!0});let t=Pe(e,"ultracite",{args:["format"],short:e==="npm"});await Ce(O,t)},update:async e=>{let t=await Dt(O,"utf-8"),s=Pe(e,"ultracite",{args:["format"],short:e==="npm"});await Ce(O,`${t}
|
|
12
|
+
${s}`)}}});var Ne={};B(Ne,{lefthook:()=>k});import{execSync as Ct}from"child_process";import{readFile as Pt,writeFile as S}from"fs/promises";import{addDevDependency as St,dlxCommand as Me}from"nypm";var Rt,Mt,Ae,y,Re,k,K=D(()=>{"use strict";p();Rt=/(pre-commit:\s*\n\s*jobs:\s*\n)/,Mt=/(pre-commit:\s*\n)/,Ae=e=>Me(e,"ultracite",{args:["format"],short:e==="npm"}),y="./lefthook.yml",Re=e=>`pre-commit:
|
|
13
13
|
jobs:
|
|
14
|
-
- run: ${
|
|
14
|
+
- run: ${Ae(e)}
|
|
15
15
|
glob:
|
|
16
16
|
- "*.js"
|
|
17
17
|
- "*.jsx"
|
|
@@ -21,7 +21,7 @@ ${s}`)}}});var Re={};q(Re,{lefthook:()=>k});import{execSync as xt}from"child_pro
|
|
|
21
21
|
- "*.jsonc"
|
|
22
22
|
- "*.css"
|
|
23
23
|
stage_fixed: true
|
|
24
|
-
`,k={exists:()=>a(y),install:async e=>{await
|
|
24
|
+
`,k={exists:()=>a(y),install:async e=>{await St("lefthook",{packageManager:e,workspace:await g()});let t=Me(e,"lefthook",{args:["install"],short:e==="npm"});Ct(t)},create:async e=>{let t=Re(e);await S(y,t)},update:async e=>{let t=await Pt(y,"utf-8"),s=Ae(e),n=Re(e);if(t.includes(s))return;if(t.startsWith("# EXAMPLE USAGE:")){await S(y,n);return}if(t.includes("pre-commit:"))if(t.includes("jobs:")){let i=` - run: ${s}
|
|
25
25
|
glob:
|
|
26
26
|
- "*.js"
|
|
27
27
|
- "*.jsx"
|
|
@@ -30,7 +30,7 @@ ${s}`)}}});var Re={};q(Re,{lefthook:()=>k});import{execSync as xt}from"child_pro
|
|
|
30
30
|
- "*.json"
|
|
31
31
|
- "*.jsonc"
|
|
32
32
|
- "*.css"
|
|
33
|
-
stage_fixed: true`,r=t.replace(
|
|
33
|
+
stage_fixed: true`,r=t.replace(Rt,`$1${i}
|
|
34
34
|
`);await S(y,r)}else{let i=` jobs:
|
|
35
35
|
- run: ${s}
|
|
36
36
|
glob:
|
|
@@ -41,15 +41,15 @@ ${s}`)}}});var Re={};q(Re,{lefthook:()=>k});import{execSync as xt}from"child_pro
|
|
|
41
41
|
- "*.json"
|
|
42
42
|
- "*.jsonc"
|
|
43
43
|
- "*.css"
|
|
44
|
-
stage_fixed: true`,r=t.replace(
|
|
44
|
+
stage_fixed: true`,r=t.replace(Mt,`$1${i}
|
|
45
45
|
`);await S(y,r)}else await S(y,`${t}
|
|
46
|
-
${n}`)}}});var
|
|
47
|
-
`).filter(i=>i.trim()&&!i.trim().startsWith("#")),s={},n=null,o=[];for(let i of t){let r=
|
|
46
|
+
${n}`)}}});var At,X=D(()=>{At=se({"./husky.ts":()=>(H(),G(Se)),"./lefthook.ts":()=>(K(),G(Ne)),"./lint-staged.ts":()=>(Y(),G(Fe))})});var Fe={};B(Fe,{lintStaged:()=>x});import{readFile as $,writeFile as w}from"fs/promises";import{pathToFileURL as Nt}from"url";import R from"deepmerge";import{parse as Q}from"jsonc-parser";import{addDevDependency as Ft,dlxCommand as It}from"nypm";var h,Ie,Ut,Et,Ot,$t,Tt,Jt,_t,zt,Lt,Z,Wt,x,Y=D(()=>{"use strict";p();X();h=e=>({"*.{js,jsx,ts,tsx,json,jsonc,css,scss,md,mdx}":[It(e,"ultracite",{args:["format"],short:e==="npm"})]}),Ie=["./package.json","./.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"],Ut=(e,t,s,n)=>{let o=e.trim();if(o.includes(":")&&!o.startsWith("-")){s&&n.length>0&&(t[s]=n);let[i,...r]=o.split(":"),c=r.join(":").trim(),l=i.trim().replace(/['"]/g,"");return c&&c!==""?(c.startsWith("[")&&c.endsWith("]")?t[l]=c.slice(1,-1).split(",").map(u=>u.trim().replace(/['"]/g,"")):t[l]=c.replace(/['"]/g,""),{newCurrentKey:null,newCurrentArray:[]}):{newCurrentKey:l,newCurrentArray:[]}}if(o.startsWith("-")&&s){let i=[...n,o.slice(1).trim().replace(/['"]/g,"")];return{newCurrentKey:s,newCurrentArray:i}}return{newCurrentKey:s,newCurrentArray:n}},Et=e=>{let t=e.split(`
|
|
47
|
+
`).filter(i=>i.trim()&&!i.trim().startsWith("#")),s={},n=null,o=[];for(let i of t){let r=Ut(i,s,n,o);n=r.newCurrentKey,o=r.newCurrentArray}return n&&o.length>0&&(s[n]=o),s},Ot=e=>{let t="";for(let[s,n]of Object.entries(e))if(Array.isArray(n)){t+=`${s}:
|
|
48
48
|
`;for(let o of n)t+=` - '${o}'
|
|
49
49
|
`}else t+=`${s}: '${n}'
|
|
50
|
-
`;return t}
|
|
51
|
-
`;await w(e,r)},
|
|
52
|
-
`;await w(e,o)},Y=async e=>{await w(".lintstagedrc.json",JSON.stringify(h(e),null,2))},zt=async(e,t)=>{if(e==="./package.json"){await Et(t);return}if(e.endsWith(".json")||e==="./.lintstagedrc"){await Ot(e,t);return}if(e.endsWith(".yaml")||e.endsWith(".yml")){await $t(e,t);return}let s=await It();if(e.endsWith(".mjs")||e.endsWith(".js")&&s){try{await Jt(e,t)}catch{await Y(t)}return}if(e.endsWith(".cjs")||e.endsWith(".js")&&!s)try{await Tt(e,t)}catch{await Y(t)}},x={exists:async()=>{for(let e of Ae)if(await a(e))return!0;return!1},install:async e=>{await Mt("lint-staged",{packageManager:e,workspace:await g()})},create:async e=>{await w(".lintstagedrc.json",JSON.stringify(h(e),null,2))},update:async e=>{let t=null;for(let s of Ae)if(await a(s)){t=s;break}if(!t){await Y(e);return}await zt(t,e)}}});import{createCli as ws,trpcServer as bs}from"trpc-cli";import u from"zod";var f={name:"ultracite",description:"The AI-ready formatter that helps you write and generate code faster.",version:"5.2.8",type:"module",bin:{ultracite:"dist/index.js"},files:["biome.jsonc","dist"],scripts:{build:"tsup",test:"vitest run","test:coverage":"vitest --coverage"},main:"./biome.jsonc",author:"Hayden Bleasel <hello@haydenbleasel.com>",bugs:{url:"https://github.com/haydenbleasel/ultracite/issues"},homepage:"https://github.com/haydenbleasel/ultracite#readme",keywords:["ultracite","biome","linter","formatter","fixer"],license:"MIT",publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},repository:{type:"git",url:"git+https://github.com/haydenbleasel/ultracite.git"},devDependencies:{"@auto-it/all-contributors":"^11.3.0","@auto-it/first-time-contributor":"^11.3.0","@biomejs/biome":"2.2.2","@types/node":"^24.3.0","@vitest/coverage-v8":"3.2.4",tsup:"^8.5.0"},dependencies:{"@clack/prompts":"^0.11.0",deepmerge:"^4.3.1","jsonc-parser":"^3.3.1",nypm:"^0.6.1","trpc-cli":"^0.10.2",vitest:"^3.2.4",zod:"^4.1.5"},packageManager:"pnpm@10.15.0"};import{execSync as Xe}from"child_process";import Ye from"process";var se=(e,t={})=>{try{let s=e.length>0?e.map(o=>`"${o}"`).join(" "):"./",n=t.unsafe?" --unsafe":"";Xe(`npx @biomejs/biome check --write${n} ${s}`,{stdio:"inherit"})}catch(s){let n=s instanceof Error?s.message:"Unknown error";console.error("Failed to run Ultracite:",n),Ye.exit(1)}};import{execSync as Ze}from"child_process";import Qe from"process";var ne=e=>{try{let t=e.length>0?e.map(s=>`"${s}"`).join(" "):"./";Ze(`npx @biomejs/biome check ${t}`,{stdio:"inherit"})}catch(t){let s=t instanceof Error?t.message:"Unknown error";console.error("Failed to run Ultracite:",s),Qe.exit(1)}};import{packageManagers as et}from"nypm";var j={packageManagers:et.map(e=>e.name),editorConfigs:["vscode","zed"],editorRules:["vscode-copilot","cursor","windsurf","zed","claude","codex","kiro","cline","amp","aider","firebase-studio","open-hands","gemini-cli","junie","augmentcode","kilo-code","goose"],integrations:["husky","lefthook","lint-staged"]};import _e from"process";import{intro as os,log as T,multiselect as z,spinner as m}from"@clack/prompts";import{addDevDependency as is,detectPackageManager as as}from"nypm";import{readFile as ot,writeFile as ae}from"fs/promises";import it from"deepmerge";import{parse as at}from"jsonc-parser";p();var rt=f.devDependencies["@biomejs/biome"],re={$schema:`https://biomejs.dev/schemas/${rt}/schema.json`,extends:["ultracite"]},G=async()=>await a("./biome.json")?"./biome.json":"./biome.jsonc",M={exists:async()=>{let e=await G();return a(e)},create:async()=>{let e=await G();return ae(e,JSON.stringify(re,null,2))},update:async()=>{let e=await G(),t=await ot(e,"utf-8"),n=at(t)||{},o=n.extends&&Array.isArray(n.extends)?n.extends:[];o.includes("ultracite")||(n.extends=[...o,"ultracite"]);let i={$schema:re.$schema},r=it(n,i);await ae(e,JSON.stringify(r,null,2))}};p();import{mkdir as ct,readFile as lt,writeFile as ce}from"fs/promises";import dt from"deepmerge";import{parse as ut}from"jsonc-parser";var le={"editor.defaultFormatter":"esbenp.prettier-vscode","[javascript]":{"editor.defaultFormatter":"biomejs.biome"},"[typescript]":{"editor.defaultFormatter":"biomejs.biome"},"[javascriptreact]":{"editor.defaultFormatter":"biomejs.biome"},"[typescriptreact]":{"editor.defaultFormatter":"biomejs.biome"},"[json]":{"editor.defaultFormatter":"biomejs.biome"},"[jsonc]":{"editor.defaultFormatter":"biomejs.biome"},"[css]":{"editor.defaultFormatter":"biomejs.biome"},"[graphql]":{"editor.defaultFormatter":"biomejs.biome"},"typescript.tsdk":"node_modules/typescript/lib","editor.formatOnSave":!0,"editor.formatOnPaste":!0,"emmet.showExpandedAbbreviation":"never","editor.codeActionsOnSave":{"source.fixAll.biome":"explicit","source.organizeImports.biome":"explicit"}},A="./.vscode/settings.json",N={exists:()=>a(A),create:async()=>{await ct(".vscode",{recursive:!0}),await ce(A,JSON.stringify(le,null,2))},update:async()=>{let e=await lt(A,"utf-8"),s=ut(e)||{},n=dt(s,le);await ce(A,JSON.stringify(n,null,2))}};p();import{mkdir as pt,readFile as mt,writeFile as de}from"fs/promises";import ft from"deepmerge";import{parse as gt}from"jsonc-parser";var ue={formatter:"language_server",format_on_save:"on",languages:{JavaScript:{formatter:{language_server:{name:"biome"}},code_actions_on_format:{"source.fixAll.biome":!0,"source.organizeImports.biome":!0}},TypeScript:{formatter:{language_server:{name:"biome"}},code_actions_on_format:{"source.fixAll.biome":!0,"source.organizeImports.biome":!0}},JSX:{formatter:{language_server:{name:"biome"}},code_actions_on_format:{"source.fixAll.biome":!0,"source.organizeImports.biome":!0}},TSX:{formatter:{language_server:{name:"biome"}},code_actions_on_format:{"source.fixAll.biome":!0,"source.organizeImports.biome":!0}}},lsp:{"typescript-language-server":{settings:{typescript:{preferences:{includePackageJsonAutoImports:"on"}}}}}},F="./.zed/settings.json",U={exists:()=>a(F),create:async()=>{await pt(".zed",{recursive:!0}),await de(F,JSON.stringify(ue,null,2))},update:async()=>{let e=await mt(F,"utf-8"),s=gt(e)||{},n=ft(s,ue);await de(F,JSON.stringify(n,null,2))}};import{mkdir as ht,readFile as yt,writeFile as I}from"fs/promises";import{dirname as wt}from"path";var pe=["Don't use `accessKey` attribute on any HTML element.",'Don\'t set `aria-hidden="true"` on focusable elements.',"Don't add ARIA roles, states, and properties to elements that don't support them.","Don't use distracting elements like `<marquee>` or `<blink>`.","Only use the `scope` prop on `<th>` elements.","Don't assign non-interactive ARIA roles to interactive HTML elements.","Make sure label elements have text content and are associated with an input.","Don't assign interactive ARIA roles to non-interactive HTML elements.","Don't assign `tabIndex` to non-interactive HTML elements.","Don't use positive integers for `tabIndex` property.",`Don't include "image", "picture", or "photo" in img alt prop.`,"Don't use explicit role property that's the same as the implicit/default role.","Make static elements with click handlers use a valid role attribute.","Always include a `title` element for SVG elements.","Give all elements requiring alt text meaningful information for screen readers.","Make sure anchors have content that's accessible to screen readers.","Assign `tabIndex` to non-interactive HTML elements with `aria-activedescendant`.","Include all required ARIA attributes for elements with ARIA roles.","Make sure ARIA properties are valid for the element's supported roles.","Always include a `type` attribute for button elements.","Make elements with interactive roles and handlers focusable.","Give heading elements content that's accessible to screen readers (not hidden with `aria-hidden`).","Always include a `lang` attribute on the html element.","Always include a `title` attribute for iframe elements.","Accompany `onClick` with at least one of: `onKeyUp`, `onKeyDown`, or `onKeyPress`.","Accompany `onMouseOver`/`onMouseOut` with `onFocus`/`onBlur`.","Include caption tracks for audio and video elements.","Use semantic elements instead of role attributes in JSX.","Make sure all anchors are valid and navigable.","Ensure all ARIA properties (`aria-*`) are valid.","Use valid, non-abstract ARIA roles for elements with ARIA roles.","Use valid ARIA state and property values.","Use valid values for the `autocomplete` attribute on input elements.","Use correct ISO language/country codes for the `lang` attribute."],me=["Don't use consecutive spaces in regular expression literals.","Don't use the `arguments` object.","Don't use primitive type aliases or misleading types.","Don't use the comma operator.","Don't use empty type parameters in type aliases and interfaces.","Don't write functions that exceed a given Cognitive Complexity score.","Don't nest describe() blocks too deeply in test files.","Don't use unnecessary boolean casts.","Don't use unnecessary callbacks with flatMap.","Use for...of statements instead of Array.forEach.","Don't create classes that only have static members (like a static namespace).","Don't use this and super in static contexts.","Don't use unnecessary catch clauses.","Don't use unnecessary constructors.","Don't use unnecessary continue statements.","Don't export empty modules that don't change anything.","Don't use unnecessary escape sequences in regular expression literals.","Don't use unnecessary fragments.","Don't use unnecessary labels.","Don't use unnecessary nested block statements.","Don't rename imports, exports, and destructured assignments to the same name.","Don't use unnecessary string or template literal concatenation.","Don't use String.raw in template literals when there are no escape sequences.","Don't use useless case statements in switch statements.","Don't use ternary operators when simpler alternatives exist.","Don't use useless `this` aliasing.","Don't use any or unknown as type constraints.","Don't initialize variables to undefined.","Don't use the void operators (they're not familiar).","Use arrow functions instead of function expressions.","Use Date.now() to get milliseconds since the Unix Epoch.","Use .flatMap() instead of map().flat() when possible.","Use literal property access instead of computed property access.","Don't use parseInt() or Number.parseInt() when binary, octal, or hexadecimal literals work.","Use concise optional chaining instead of chained logical expressions.","Use regular expression literals instead of the RegExp constructor when possible.","Don't use number literal object member names that aren't base 10 or use underscore separators.","Remove redundant terms from logical expressions.","Use while loops instead of for loops when you don't need initializer and update expressions.","Don't pass children as props.","Don't reassign const variables.","Don't use constant expressions in conditions.","Don't use `Math.min` and `Math.max` to clamp values when the result is constant.","Don't return a value from a constructor.","Don't use empty character classes in regular expression literals.","Don't use empty destructuring patterns.","Don't call global object properties as functions.","Don't declare functions and vars that are accessible outside their block.","Make sure builtins are correctly instantiated.","Don't use super() incorrectly inside classes. Also check that super() is called in classes that extend other constructors.","Don't use variables and function parameters before they're declared.","Don't use 8 and 9 escape sequences in string literals.","Don't use literal numbers that lose precision."],fe=["Don't use the return value of React.render.","Make sure all dependencies are correctly specified in React hooks.","Make sure all React hooks are called from the top level of component functions.","Don't forget key props in iterators and collection literals.","Don't destructure props inside JSX components in Solid projects.","Don't define React components inside other components.","Don't use event handlers on non-interactive elements.","Don't assign to React component props.","Don't use both `children` and `dangerouslySetInnerHTML` props on the same element.","Don't use dangerous JSX props.","Don't use Array index in keys.","Don't insert comments as text nodes.","Don't assign JSX properties multiple times.","Don't add extra closing tags for components without children.","Use `<>...</>` instead of `<Fragment>...</Fragment>`.",'Watch out for possible "wrong" semicolons inside JSX elements.'],ge=["Don't assign a value to itself.","Don't return a value from a setter.","Don't compare expressions that modify string case with non-compliant values.","Don't use lexical declarations in switch clauses.","Don't use variables that haven't been declared in the document.","Don't write unreachable code.","Make sure super() is called exactly once on every code path in a class constructor before this is accessed if the class has a superclass.","Don't use control flow statements in finally blocks.","Don't use optional chaining where undefined values aren't allowed.","Don't have unused function parameters.","Don't have unused imports.","Don't have unused labels.","Don't have unused private class members.","Don't have unused variables.","Make sure void (self-closing) elements don't have children.","Don't return a value from a function with the return type 'void'","Use isNaN() when checking for NaN.",'Make sure "for" loop update clauses move the counter in the right direction.',"Make sure typeof expressions are compared to valid values.","Make sure generator functions contain yield.","Don't use await inside loops.","Don't use bitwise operators.","Don't use expressions where the operation doesn't change the value.","Make sure Promise-like statements are handled appropriately.","Don't use __dirname and __filename in the global scope.","Prevent import cycles.","Don't use configured elements.","Don't hardcode sensitive data like API keys and tokens.","Don't let variable declarations shadow variables from outer scopes.","Don't use the TypeScript directive @ts-ignore.","Prevent duplicate polyfills from Polyfill.io.","Don't use useless backreferences in regular expressions that always match empty strings.","Don't use unnecessary escapes in string literals.","Don't use useless undefined.","Make sure getters and setters for the same property are next to each other in class and object definitions.","Make sure object literals are declared consistently (defaults to explicit definitions).","Use static Response methods instead of new Response() constructor when possible.","Make sure switch-case statements are exhaustive.","Make sure the `preconnect` attribute is used when using Google Fonts.","Use `Array#{indexOf,lastIndexOf}()` instead of `Array#{findIndex,findLastIndex}()` when looking for the index of an item.","Make sure iterable callbacks return consistent values.",'Use `with { type: "json" }` for JSON module imports.',"Use numeric separators in numeric literals.","Use object spread instead of `Object.assign()` when constructing new objects.","Always use the radix argument when using `parseInt()`.","Make sure JSDoc comment lines start with a single asterisk, except for the first one.","Include a description parameter for `Symbol()`.","Don't use spread (`...`) syntax on accumulators.","Don't use the `delete` operator.","Don't access namespace imports dynamically.","Don't use namespace imports.","Declare regex literals at the top level.",'Don\'t use `target="_blank"` without `rel="noopener"`.'],he=["Don't use TypeScript enums.","Don't export imported variables.","Don't add type annotations to variables, parameters, and class properties that are initialized with literal expressions.","Don't use TypeScript namespaces.","Don't use non-null assertions with the `!` postfix operator.","Don't use parameter properties in class constructors.","Don't use user-defined types.","Use `as const` instead of literal types and type annotations.","Use either `T[]` or `Array<T>` consistently.","Initialize each enum member value explicitly.","Use `export type` for types.","Use `import type` for types.","Make sure all enum members are literal values.","Don't use TypeScript const enum.","Don't declare empty interfaces.","Don't let variables evolve into any type through reassignments.","Don't use the any type.","Don't misuse the non-null assertion operator (!) in TypeScript files.","Don't use implicit any type on variable declarations.","Don't merge interfaces and classes unsafely.","Don't use overload signatures that aren't next to each other.","Use the namespace keyword instead of the module keyword to declare TypeScript namespaces."],ye=["Don't use global `eval()`.","Don't use callbacks in asynchronous tests and hooks.","Don't use negation in `if` statements that have `else` clauses.","Don't use nested ternary expressions.","Don't reassign function parameters.","This rule lets you specify global variable names you don't want to use in your application.","Don't use specified modules when loaded by import or require.","Don't use constants whose value is the upper-case version of their name.","Use `String.slice()` instead of `String.substr()` and `String.substring()`.","Don't use template literals if you don't need interpolation or special-character handling.","Don't use `else` blocks when the `if` block breaks early.","Don't use yoda expressions.","Don't use Array constructors.","Use `at()` instead of integer index access.","Follow curly brace conventions.","Use `else if` instead of nested `if` statements in `else` clauses.","Use single `if` statements instead of nested `if` clauses.","Use `new` for all builtins except `String`, `Number`, and `Boolean`.","Use consistent accessibility modifiers on class properties and methods.","Use `const` declarations for variables that are only assigned once.","Put default function parameters and optional function parameters last.","Include a `default` clause in switch statements.","Use the `**` operator instead of `Math.pow`.","Use `for-of` loops when you need the index to extract an item from the iterated array.","Use `node:assert/strict` over `node:assert`.","Use the `node:` protocol for Node.js builtin modules.","Use Number properties instead of global ones.","Use assignment operator shorthand where possible.","Use function types instead of object types with call signatures.","Use template literals over string concatenation.","Use `new` when throwing an error.","Don't throw non-Error values.","Use `String.trimStart()` and `String.trimEnd()` over `String.trimLeft()` and `String.trimRight()`.","Use standard constants instead of approximated literals.","Don't assign values in expressions.","Don't use async functions as Promise executors.","Don't reassign exceptions in catch clauses.","Don't reassign class members.","Don't compare against -0.","Don't use labeled statements that aren't loops.","Don't use void type outside of generic or return types.","Don't use console.","Don't use control characters and escape sequences that match control characters in regular expression literals.","Don't use debugger.","Don't assign directly to document.cookie.","Use `===` and `!==`.","Don't use duplicate case labels.","Don't use duplicate class members.","Don't use duplicate conditions in if-else-if chains.","Don't use two keys with the same name inside objects.","Don't use duplicate function parameter names.","Don't have duplicate hooks in describe blocks.","Don't use empty block statements and static blocks.","Don't let switch clauses fall through.","Don't reassign function declarations.","Don't allow assignments to native objects and read-only global variables.","Use Number.isFinite instead of global isFinite.","Use Number.isNaN instead of global isNaN.","Don't assign to imported bindings.","Don't use irregular whitespace characters.","Don't use labels that share a name with a variable.","Don't use characters made with multiple code points in character class syntax.","Make sure to use new and constructor properly.","Don't use shorthand assign when the variable appears on both sides.","Don't use octal escape sequences in string literals.","Don't use Object.prototype builtins directly.","Don't redeclare variables, functions, classes, and types in the same scope.",`Don't have redundant "use strict".`,"Don't compare things where both sides are exactly the same.","Don't let identifiers shadow restricted names.","Don't use sparse arrays (arrays with holes).","Don't use template literal placeholder syntax in regular strings.","Don't use the then property.","Don't use unsafe negation.","Don't use var.","Don't use with statements in non-strict contexts.","Make sure async functions actually use await.","Make sure default clauses in switch statements come last.","Make sure to pass a message value when creating a built-in error.","Make sure get methods always return a value.","Use a recommended display strategy with Google Fonts.","Make sure for-in loops include an if statement.","Use Array.isArray() instead of instanceof Array.","Make sure to use the digits argument with Number#toFixed().",'Make sure to use the "use strict" directive in script files.'],we=["Don't use `<img>` elements in Next.js projects.","Don't use `<head>` elements in Next.js projects.","Don't import next/document outside of pages/_document.jsx in Next.js projects.","Don't use the next/head module in pages/_document.js on Next.js projects."],be=["Don't use export or module.exports in test files.","Don't use focused tests.","Make sure the assertion function, like expect, is placed inside an it() function call.","Don't use disabled tests."],Ys=[...pe,...me,...fe,...ge,...he,...ye,...we,...be],P=`# Project Context
|
|
50
|
+
`;return t},$t=async()=>{try{let e=Q(await $("./package.json","utf-8"));return e?e.type==="module":!1}catch{return!1}},Tt=async e=>{let t=Q(await $("./package.json","utf-8"));t&&(t["lint-staged"]?t["lint-staged"]=R(t["lint-staged"],h(e)):t["lint-staged"]=h(e),await w("./package.json",JSON.stringify(t,null,2)))},Jt=async(e,t)=>{let s=await $(e,"utf-8"),n=Q(s);if(!n)return;let o=R(n,h(t));await w(e,JSON.stringify(o,null,2))},_t=async(e,t)=>{let s=await $(e,"utf-8"),n=Et(s);if(!n)return;let o=R(n,h(t));await w(e,Ot(o))},zt=async(e,t)=>{let o=(await import(Nt(e).href)).default||{},i=R(o,h(t)),r=`export default ${JSON.stringify(i,null,2)};
|
|
51
|
+
`;await w(e,r)},Lt=async(e,t)=>{delete q.cache[q.resolve(`./${e}`)];let s=At(`./${e}`),n=R(s,h(t)),o=`module.exports = ${JSON.stringify(n,null,2)};
|
|
52
|
+
`;await w(e,o)},Z=async e=>{await w(".lintstagedrc.json",JSON.stringify(h(e),null,2))},Wt=async(e,t)=>{if(e==="./package.json"){await Tt(t);return}if(e.endsWith(".json")||e==="./.lintstagedrc"){await Jt(e,t);return}if(e.endsWith(".yaml")||e.endsWith(".yml")){await _t(e,t);return}let s=await $t();if(e.endsWith(".mjs")||e.endsWith(".js")&&s){try{await zt(e,t)}catch{await Z(t)}return}if(e.endsWith(".cjs")||e.endsWith(".js")&&!s)try{await Lt(e,t)}catch{await Z(t)}},x={exists:async()=>{for(let e of Ie)if(await a(e))return!0;return!1},install:async e=>{await Ft("lint-staged",{packageManager:e,workspace:await g()})},create:async e=>{await w(".lintstagedrc.json",JSON.stringify(h(e),null,2))},update:async e=>{let t=null;for(let s of Ie)if(await a(s)){t=s;break}if(!t){await Z(e);return}await Wt(t,e)}}});import{createCli as ks,trpcServer as xs}from"trpc-cli";import d from"zod";var f={name:"ultracite",description:"The AI-ready formatter that helps you write and generate code faster.",version:"5.2.10",type:"module",bin:{ultracite:"dist/index.js"},files:["biome.jsonc","dist"],scripts:{build:"tsup",test:"vitest run","test:coverage":"vitest --coverage"},main:"./biome.jsonc",author:"Hayden Bleasel <hello@haydenbleasel.com>",bugs:{url:"https://github.com/haydenbleasel/ultracite/issues"},homepage:"https://github.com/haydenbleasel/ultracite#readme",keywords:["ultracite","biome","linter","formatter","fixer"],license:"MIT",publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},repository:{type:"git",url:"git+https://github.com/haydenbleasel/ultracite.git"},devDependencies:{"@auto-it/all-contributors":"^11.3.0","@auto-it/first-time-contributor":"^11.3.0","@biomejs/biome":"2.2.2","@types/node":"^24.3.0","@vitest/coverage-v8":"3.2.4",tsup:"^8.5.0"},dependencies:{"@clack/prompts":"^0.11.0",deepmerge:"^4.3.1","jsonc-parser":"^3.3.1",nypm:"^0.6.1","trpc-cli":"^0.10.2",vitest:"^3.2.4",zod:"^4.1.5"},packageManager:"pnpm@10.15.0"};p();import{spawnSync as ot}from"child_process";import ie from"process";var ae=(e,t={})=>{let s=["@biomejs/biome","check","--write"];t.unsafe&&s.push("--unsafe"),e.length>0?s.push(...M(e)):s.push("./");let n=s.join(" "),o=ot(n,{stdio:"inherit",shell:!0});o.error&&(console.error("Failed to run Ultracite:",o.error.message),ie.exit(1)),o.status!==0&&ie.exit(o.status??1)};p();import{spawnSync as it}from"child_process";import re from"process";var ce=e=>{let t=["@biomejs/biome","check"];e.length>0?t.push(...M(e)):t.push("./");let s=t.join(" "),n=it(s,{stdio:"inherit",shell:!0});n.error&&(console.error("Failed to run Ultracite:",n.error.message),re.exit(1)),n.status!==0&&re.exit(n.status??1)};import{packageManagers as at}from"nypm";var C={packageManagers:at.map(e=>e.name),editorConfigs:["vscode","zed"],editorRules:["vscode-copilot","cursor","windsurf","zed","claude","codex","kiro","cline","amp","aider","firebase-studio","open-hands","gemini-cli","junie","augmentcode","kilo-code","goose"],integrations:["husky","lefthook","lint-staged"]};import qe from"process";import{intro as rs,log as _,multiselect as z,spinner as m}from"@clack/prompts";import{addDevDependency as cs,detectPackageManager as ls}from"nypm";import{readFile as rt,writeFile as le}from"fs/promises";import ct from"deepmerge";import{parse as lt}from"jsonc-parser";p();var ut=f.devDependencies["@biomejs/biome"],ue={$schema:`https://biomejs.dev/schemas/${ut}/schema.json`,extends:["ultracite"]},V=async()=>await a("./biome.json")?"./biome.json":"./biome.jsonc",A={exists:async()=>{let e=await V();return a(e)},create:async()=>{let e=await V();return le(e,JSON.stringify(ue,null,2))},update:async()=>{let e=await V(),t=await rt(e,"utf-8"),n=lt(t)||{},o=n.extends&&Array.isArray(n.extends)?n.extends:[];o.includes("ultracite")||(n.extends=[...o,"ultracite"]);let i={$schema:ue.$schema},r=ct(n,i);await le(e,JSON.stringify(r,null,2))}};p();import{mkdir as dt,readFile as pt,writeFile as de}from"fs/promises";import mt from"deepmerge";import{parse as ft}from"jsonc-parser";var pe={"editor.defaultFormatter":"esbenp.prettier-vscode","[javascript]":{"editor.defaultFormatter":"biomejs.biome"},"[typescript]":{"editor.defaultFormatter":"biomejs.biome"},"[javascriptreact]":{"editor.defaultFormatter":"biomejs.biome"},"[typescriptreact]":{"editor.defaultFormatter":"biomejs.biome"},"[json]":{"editor.defaultFormatter":"biomejs.biome"},"[jsonc]":{"editor.defaultFormatter":"biomejs.biome"},"[css]":{"editor.defaultFormatter":"biomejs.biome"},"[graphql]":{"editor.defaultFormatter":"biomejs.biome"},"typescript.tsdk":"node_modules/typescript/lib","editor.formatOnSave":!0,"editor.formatOnPaste":!0,"emmet.showExpandedAbbreviation":"never","editor.codeActionsOnSave":{"source.fixAll.biome":"explicit","source.organizeImports.biome":"explicit"}},N="./.vscode/settings.json",F={exists:()=>a(N),create:async()=>{await dt(".vscode",{recursive:!0}),await de(N,JSON.stringify(pe,null,2))},update:async()=>{let e=await pt(N,"utf-8"),s=ft(e)||{},n=mt(s,pe);await de(N,JSON.stringify(n,null,2))}};p();import{mkdir as gt,readFile as ht,writeFile as me}from"fs/promises";import yt from"deepmerge";import{parse as wt}from"jsonc-parser";var fe={formatter:"language_server",format_on_save:"on",languages:{JavaScript:{formatter:{language_server:{name:"biome"}},code_actions_on_format:{"source.fixAll.biome":!0,"source.organizeImports.biome":!0}},TypeScript:{formatter:{language_server:{name:"biome"}},code_actions_on_format:{"source.fixAll.biome":!0,"source.organizeImports.biome":!0}},JSX:{formatter:{language_server:{name:"biome"}},code_actions_on_format:{"source.fixAll.biome":!0,"source.organizeImports.biome":!0}},TSX:{formatter:{language_server:{name:"biome"}},code_actions_on_format:{"source.fixAll.biome":!0,"source.organizeImports.biome":!0}}},lsp:{"typescript-language-server":{settings:{typescript:{preferences:{includePackageJsonAutoImports:"on"}}}}}},I="./.zed/settings.json",U={exists:()=>a(I),create:async()=>{await gt(".zed",{recursive:!0}),await me(I,JSON.stringify(fe,null,2))},update:async()=>{let e=await ht(I,"utf-8"),s=wt(e)||{},n=yt(s,fe);await me(I,JSON.stringify(n,null,2))}};import{mkdir as bt,readFile as vt,writeFile as E}from"fs/promises";import{dirname as kt}from"path";var ge=["Don't use `accessKey` attribute on any HTML element.",'Don\'t set `aria-hidden="true"` on focusable elements.',"Don't add ARIA roles, states, and properties to elements that don't support them.","Don't use distracting elements like `<marquee>` or `<blink>`.","Only use the `scope` prop on `<th>` elements.","Don't assign non-interactive ARIA roles to interactive HTML elements.","Make sure label elements have text content and are associated with an input.","Don't assign interactive ARIA roles to non-interactive HTML elements.","Don't assign `tabIndex` to non-interactive HTML elements.","Don't use positive integers for `tabIndex` property.",`Don't include "image", "picture", or "photo" in img alt prop.`,"Don't use explicit role property that's the same as the implicit/default role.","Make static elements with click handlers use a valid role attribute.","Always include a `title` element for SVG elements.","Give all elements requiring alt text meaningful information for screen readers.","Make sure anchors have content that's accessible to screen readers.","Assign `tabIndex` to non-interactive HTML elements with `aria-activedescendant`.","Include all required ARIA attributes for elements with ARIA roles.","Make sure ARIA properties are valid for the element's supported roles.","Always include a `type` attribute for button elements.","Make elements with interactive roles and handlers focusable.","Give heading elements content that's accessible to screen readers (not hidden with `aria-hidden`).","Always include a `lang` attribute on the html element.","Always include a `title` attribute for iframe elements.","Accompany `onClick` with at least one of: `onKeyUp`, `onKeyDown`, or `onKeyPress`.","Accompany `onMouseOver`/`onMouseOut` with `onFocus`/`onBlur`.","Include caption tracks for audio and video elements.","Use semantic elements instead of role attributes in JSX.","Make sure all anchors are valid and navigable.","Ensure all ARIA properties (`aria-*`) are valid.","Use valid, non-abstract ARIA roles for elements with ARIA roles.","Use valid ARIA state and property values.","Use valid values for the `autocomplete` attribute on input elements.","Use correct ISO language/country codes for the `lang` attribute."],he=["Don't use consecutive spaces in regular expression literals.","Don't use the `arguments` object.","Don't use primitive type aliases or misleading types.","Don't use the comma operator.","Don't use empty type parameters in type aliases and interfaces.","Don't write functions that exceed a given Cognitive Complexity score.","Don't nest describe() blocks too deeply in test files.","Don't use unnecessary boolean casts.","Don't use unnecessary callbacks with flatMap.","Use for...of statements instead of Array.forEach.","Don't create classes that only have static members (like a static namespace).","Don't use this and super in static contexts.","Don't use unnecessary catch clauses.","Don't use unnecessary constructors.","Don't use unnecessary continue statements.","Don't export empty modules that don't change anything.","Don't use unnecessary escape sequences in regular expression literals.","Don't use unnecessary fragments.","Don't use unnecessary labels.","Don't use unnecessary nested block statements.","Don't rename imports, exports, and destructured assignments to the same name.","Don't use unnecessary string or template literal concatenation.","Don't use String.raw in template literals when there are no escape sequences.","Don't use useless case statements in switch statements.","Don't use ternary operators when simpler alternatives exist.","Don't use useless `this` aliasing.","Don't use any or unknown as type constraints.","Don't initialize variables to undefined.","Don't use the void operators (they're not familiar).","Use arrow functions instead of function expressions.","Use Date.now() to get milliseconds since the Unix Epoch.","Use .flatMap() instead of map().flat() when possible.","Use literal property access instead of computed property access.","Don't use parseInt() or Number.parseInt() when binary, octal, or hexadecimal literals work.","Use concise optional chaining instead of chained logical expressions.","Use regular expression literals instead of the RegExp constructor when possible.","Don't use number literal object member names that aren't base 10 or use underscore separators.","Remove redundant terms from logical expressions.","Use while loops instead of for loops when you don't need initializer and update expressions.","Don't pass children as props.","Don't reassign const variables.","Don't use constant expressions in conditions.","Don't use `Math.min` and `Math.max` to clamp values when the result is constant.","Don't return a value from a constructor.","Don't use empty character classes in regular expression literals.","Don't use empty destructuring patterns.","Don't call global object properties as functions.","Don't declare functions and vars that are accessible outside their block.","Make sure builtins are correctly instantiated.","Don't use super() incorrectly inside classes. Also check that super() is called in classes that extend other constructors.","Don't use variables and function parameters before they're declared.","Don't use 8 and 9 escape sequences in string literals.","Don't use literal numbers that lose precision."],ye=["Don't use the return value of React.render.","Make sure all dependencies are correctly specified in React hooks.","Make sure all React hooks are called from the top level of component functions.","Don't forget key props in iterators and collection literals.","Don't destructure props inside JSX components in Solid projects.","Don't define React components inside other components.","Don't use event handlers on non-interactive elements.","Don't assign to React component props.","Don't use both `children` and `dangerouslySetInnerHTML` props on the same element.","Don't use dangerous JSX props.","Don't use Array index in keys.","Don't insert comments as text nodes.","Don't assign JSX properties multiple times.","Don't add extra closing tags for components without children.","Use `<>...</>` instead of `<Fragment>...</Fragment>`.",'Watch out for possible "wrong" semicolons inside JSX elements.'],we=["Don't assign a value to itself.","Don't return a value from a setter.","Don't compare expressions that modify string case with non-compliant values.","Don't use lexical declarations in switch clauses.","Don't use variables that haven't been declared in the document.","Don't write unreachable code.","Make sure super() is called exactly once on every code path in a class constructor before this is accessed if the class has a superclass.","Don't use control flow statements in finally blocks.","Don't use optional chaining where undefined values aren't allowed.","Don't have unused function parameters.","Don't have unused imports.","Don't have unused labels.","Don't have unused private class members.","Don't have unused variables.","Make sure void (self-closing) elements don't have children.","Don't return a value from a function with the return type 'void'","Use isNaN() when checking for NaN.",'Make sure "for" loop update clauses move the counter in the right direction.',"Make sure typeof expressions are compared to valid values.","Make sure generator functions contain yield.","Don't use await inside loops.","Don't use bitwise operators.","Don't use expressions where the operation doesn't change the value.","Make sure Promise-like statements are handled appropriately.","Don't use __dirname and __filename in the global scope.","Prevent import cycles.","Don't use configured elements.","Don't hardcode sensitive data like API keys and tokens.","Don't let variable declarations shadow variables from outer scopes.","Don't use the TypeScript directive @ts-ignore.","Prevent duplicate polyfills from Polyfill.io.","Don't use useless backreferences in regular expressions that always match empty strings.","Don't use unnecessary escapes in string literals.","Don't use useless undefined.","Make sure getters and setters for the same property are next to each other in class and object definitions.","Make sure object literals are declared consistently (defaults to explicit definitions).","Use static Response methods instead of new Response() constructor when possible.","Make sure switch-case statements are exhaustive.","Make sure the `preconnect` attribute is used when using Google Fonts.","Use `Array#{indexOf,lastIndexOf}()` instead of `Array#{findIndex,findLastIndex}()` when looking for the index of an item.","Make sure iterable callbacks return consistent values.",'Use `with { type: "json" }` for JSON module imports.',"Use numeric separators in numeric literals.","Use object spread instead of `Object.assign()` when constructing new objects.","Always use the radix argument when using `parseInt()`.","Make sure JSDoc comment lines start with a single asterisk, except for the first one.","Include a description parameter for `Symbol()`.","Don't use spread (`...`) syntax on accumulators.","Don't use the `delete` operator.","Don't access namespace imports dynamically.","Don't use namespace imports.","Declare regex literals at the top level.",'Don\'t use `target="_blank"` without `rel="noopener"`.'],be=["Don't use TypeScript enums.","Don't export imported variables.","Don't add type annotations to variables, parameters, and class properties that are initialized with literal expressions.","Don't use TypeScript namespaces.","Don't use non-null assertions with the `!` postfix operator.","Don't use parameter properties in class constructors.","Don't use user-defined types.","Use `as const` instead of literal types and type annotations.","Use either `T[]` or `Array<T>` consistently.","Initialize each enum member value explicitly.","Use `export type` for types.","Use `import type` for types.","Make sure all enum members are literal values.","Don't use TypeScript const enum.","Don't declare empty interfaces.","Don't let variables evolve into any type through reassignments.","Don't use the any type.","Don't misuse the non-null assertion operator (!) in TypeScript files.","Don't use implicit any type on variable declarations.","Don't merge interfaces and classes unsafely.","Don't use overload signatures that aren't next to each other.","Use the namespace keyword instead of the module keyword to declare TypeScript namespaces."],ve=["Don't use global `eval()`.","Don't use callbacks in asynchronous tests and hooks.","Don't use negation in `if` statements that have `else` clauses.","Don't use nested ternary expressions.","Don't reassign function parameters.","This rule lets you specify global variable names you don't want to use in your application.","Don't use specified modules when loaded by import or require.","Don't use constants whose value is the upper-case version of their name.","Use `String.slice()` instead of `String.substr()` and `String.substring()`.","Don't use template literals if you don't need interpolation or special-character handling.","Don't use `else` blocks when the `if` block breaks early.","Don't use yoda expressions.","Don't use Array constructors.","Use `at()` instead of integer index access.","Follow curly brace conventions.","Use `else if` instead of nested `if` statements in `else` clauses.","Use single `if` statements instead of nested `if` clauses.","Use `new` for all builtins except `String`, `Number`, and `Boolean`.","Use consistent accessibility modifiers on class properties and methods.","Use `const` declarations for variables that are only assigned once.","Put default function parameters and optional function parameters last.","Include a `default` clause in switch statements.","Use the `**` operator instead of `Math.pow`.","Use `for-of` loops when you need the index to extract an item from the iterated array.","Use `node:assert/strict` over `node:assert`.","Use the `node:` protocol for Node.js builtin modules.","Use Number properties instead of global ones.","Use assignment operator shorthand where possible.","Use function types instead of object types with call signatures.","Use template literals over string concatenation.","Use `new` when throwing an error.","Don't throw non-Error values.","Use `String.trimStart()` and `String.trimEnd()` over `String.trimLeft()` and `String.trimRight()`.","Use standard constants instead of approximated literals.","Don't assign values in expressions.","Don't use async functions as Promise executors.","Don't reassign exceptions in catch clauses.","Don't reassign class members.","Don't compare against -0.","Don't use labeled statements that aren't loops.","Don't use void type outside of generic or return types.","Don't use console.","Don't use control characters and escape sequences that match control characters in regular expression literals.","Don't use debugger.","Don't assign directly to document.cookie.","Use `===` and `!==`.","Don't use duplicate case labels.","Don't use duplicate class members.","Don't use duplicate conditions in if-else-if chains.","Don't use two keys with the same name inside objects.","Don't use duplicate function parameter names.","Don't have duplicate hooks in describe blocks.","Don't use empty block statements and static blocks.","Don't let switch clauses fall through.","Don't reassign function declarations.","Don't allow assignments to native objects and read-only global variables.","Use Number.isFinite instead of global isFinite.","Use Number.isNaN instead of global isNaN.","Don't assign to imported bindings.","Don't use irregular whitespace characters.","Don't use labels that share a name with a variable.","Don't use characters made with multiple code points in character class syntax.","Make sure to use new and constructor properly.","Don't use shorthand assign when the variable appears on both sides.","Don't use octal escape sequences in string literals.","Don't use Object.prototype builtins directly.","Don't redeclare variables, functions, classes, and types in the same scope.",`Don't have redundant "use strict".`,"Don't compare things where both sides are exactly the same.","Don't let identifiers shadow restricted names.","Don't use sparse arrays (arrays with holes).","Don't use template literal placeholder syntax in regular strings.","Don't use the then property.","Don't use unsafe negation.","Don't use var.","Don't use with statements in non-strict contexts.","Make sure async functions actually use await.","Make sure default clauses in switch statements come last.","Make sure to pass a message value when creating a built-in error.","Make sure get methods always return a value.","Use a recommended display strategy with Google Fonts.","Make sure for-in loops include an if statement.","Use Array.isArray() instead of instanceof Array.","Make sure to use the digits argument with Number#toFixed().",'Make sure to use the "use strict" directive in script files.'],ke=["Don't use `<img>` elements in Next.js projects.","Don't use `<head>` elements in Next.js projects.","Don't import next/document outside of pages/_document.jsx in Next.js projects.","Don't use the next/head module in pages/_document.js on Next.js projects."],xe=["Don't use export or module.exports in test files.","Don't use focused tests.","Make sure the assertion function, like expect, is placed inside an it() function call.","Don't use disabled tests."],sn=[...ge,...he,...ye,...we,...be,...ve,...ke,...xe],P=`# Project Context
|
|
53
53
|
Ultracite enforces strict type safety, accessibility standards, and consistent code quality for JavaScript/TypeScript projects using Biome's lightning-fast formatter and linter.
|
|
54
54
|
|
|
55
55
|
## Key Principles
|
|
@@ -67,35 +67,35 @@ Ultracite enforces strict type safety, accessibility standards, and consistent c
|
|
|
67
67
|
## Rules
|
|
68
68
|
|
|
69
69
|
### Accessibility (a11y)
|
|
70
|
-
${
|
|
70
|
+
${ge.map(e=>`- ${e}`).join(`
|
|
71
71
|
`)}
|
|
72
72
|
|
|
73
73
|
### Code Complexity and Quality
|
|
74
|
-
${
|
|
74
|
+
${he.map(e=>`- ${e}`).join(`
|
|
75
75
|
`)}
|
|
76
76
|
|
|
77
77
|
### React and JSX Best Practices
|
|
78
|
-
${
|
|
78
|
+
${ye.map(e=>`- ${e}`).join(`
|
|
79
79
|
`)}
|
|
80
80
|
|
|
81
81
|
### Correctness and Safety
|
|
82
|
-
${
|
|
82
|
+
${we.map(e=>`- ${e}`).join(`
|
|
83
83
|
`)}
|
|
84
84
|
|
|
85
85
|
### TypeScript Best Practices
|
|
86
|
-
${
|
|
86
|
+
${be.map(e=>`- ${e}`).join(`
|
|
87
87
|
`)}
|
|
88
88
|
|
|
89
89
|
### Style and Consistency
|
|
90
|
-
${
|
|
90
|
+
${ve.map(e=>`- ${e}`).join(`
|
|
91
91
|
`)}
|
|
92
92
|
|
|
93
93
|
### Next.js Specific Rules
|
|
94
|
-
${
|
|
94
|
+
${ke.map(e=>`- ${e}`).join(`
|
|
95
95
|
`)}
|
|
96
96
|
|
|
97
97
|
### Testing Best Practices
|
|
98
|
-
${
|
|
98
|
+
${xe.map(e=>`- ${e}`).join(`
|
|
99
99
|
`)}
|
|
100
100
|
|
|
101
101
|
## Common Tasks
|
|
@@ -120,14 +120,14 @@ try {
|
|
|
120
120
|
} catch (e) {
|
|
121
121
|
console.log(e);
|
|
122
122
|
}
|
|
123
|
-
\`\`\``;var
|
|
123
|
+
\`\`\``;var De={"vscode-copilot":{path:"./.github/copilot-instructions.md",header:`---
|
|
124
124
|
applyTo: "**/*.{ts,tsx,js,jsx}"
|
|
125
125
|
---`,appendMode:!0},cursor:{path:"./.cursor/rules/ultracite.mdc",header:`---
|
|
126
126
|
description: Ultracite Rules - AI-Ready Formatter and Linter
|
|
127
127
|
globs: "**/*.{ts,tsx,js,jsx}"
|
|
128
128
|
alwaysApply: true
|
|
129
|
-
---`},windsurf:{path:"./.windsurf/rules/ultracite.md"},zed:{path:"./.rules",appendMode:!0},claude:{path:"./.claude/CLAUDE.md",appendMode:!0},codex:{path:"./AGENTS.md",appendMode:!0},kiro:{path:"./.kiro/steering/ultracite.md"},cline:{path:"./.clinerules",appendMode:!0},amp:{path:"./AGENT.md",appendMode:!0},aider:{path:"./ultracite.md"},"firebase-studio":{path:"./.idx/airules.md",appendMode:!0},"open-hands":{path:"./.openhands/microagents/repo.md",appendMode:!0},"gemini-cli":{path:"./GEMINI.md",appendMode:!0},junie:{path:"./.junie/guidelines.md",appendMode:!0},augmentcode:{path:"./.augment/rules/ultracite.md"},"kilo-code":{path:"./.kilocode/rules/ultracite.md"},goose:{path:"./.goosehints",appendMode:!0}};p();var
|
|
129
|
+
---`},windsurf:{path:"./.windsurf/rules/ultracite.md"},zed:{path:"./.rules",appendMode:!0},claude:{path:"./.claude/CLAUDE.md",appendMode:!0},codex:{path:"./AGENTS.md",appendMode:!0},kiro:{path:"./.kiro/steering/ultracite.md"},cline:{path:"./.clinerules",appendMode:!0},amp:{path:"./AGENT.md",appendMode:!0},aider:{path:"./ultracite.md"},"firebase-studio":{path:"./.idx/airules.md",appendMode:!0},"open-hands":{path:"./.openhands/microagents/repo.md",appendMode:!0},"gemini-cli":{path:"./GEMINI.md",appendMode:!0},junie:{path:"./.junie/guidelines.md",appendMode:!0},augmentcode:{path:"./.augment/rules/ultracite.md"},"kilo-code":{path:"./.kilocode/rules/ultracite.md"},goose:{path:"./.goosehints",appendMode:!0}};p();var je=e=>{let t=De[e],s=t.header?`${t.header}
|
|
130
130
|
|
|
131
|
-
${P}`:P,n=async()=>{let o=
|
|
131
|
+
${P}`:P,n=async()=>{let o=kt(t.path);if(o!=="."){let i=o.startsWith("./")?o.slice(2):o;await bt(i,{recursive:!0})}};return{exists:()=>a(t.path),create:async()=>{await n(),await E(t.path,s)},update:async()=>{if(await n(),t.appendMode){if(!await a(t.path)){await E(t.path,s);return}let o=await vt(t.path,"utf-8");if(o.includes(P.trim()))return;await E(t.path,`${o}
|
|
132
132
|
|
|
133
|
-
${P}`)}else await I(t.path,s)}}};V();H();X();p();import{readFile as Ne,unlink as _t,writeFile as Lt}from"fs/promises";import{parse as Fe}from"jsonc-parser";import{removeDependency as Wt}from"nypm";var Ue=[".eslintrc",".eslintrc.js",".eslintrc.json",".eslintrc.yml",".eslintrc.yaml",".eslintrc.config.js","eslint.config.js","eslint.config.mjs","eslint.config.cjs",".eslintignore"],Ie=async()=>{try{let e=await Ne("package.json","utf-8"),t=Fe(e);if(!t||typeof t!="object")return[];let s=t.dependencies||{},n=t.devDependencies||{},o={...s,...n};return Object.keys(o).filter(i=>i.startsWith("eslint")||i.startsWith("@eslint/")||i==="@typescript-eslint/parser"||i==="@typescript-eslint/eslint-plugin")}catch{return[]}},qt=async(e,t)=>{if(t.length!==0)try{for(let s of t)await Wt(s,{packageManager:e})}catch{}},Bt=async()=>{let e=[];for(let t of Ue)if(await a(t))try{await _t(t),e.push(t)}catch{}return e},Gt=async()=>{let e="./.vscode/settings.json";if(!await a(e))return!1;try{let t=await Ne(e,"utf-8"),s=Fe(t);if(!s||typeof s!="object")return!1;let n=!1,o={...s},i=["eslint.enable","eslint.format.enable","eslint.validate","eslint.workingDirectories","eslint.codeAction.showDocumentation","eslint.run","eslint.autoFixOnSave","eslint.quiet","eslint.packageManager","eslint.options","eslint.trace.server"];for(let r of i)r in o&&(delete o[r],n=!0);if("editor.codeActionsOnSave"in o){let r=o["editor.codeActionsOnSave"];if(r&&typeof r=="object"){let c=["source.fixAll.eslint","source.organizeImports.eslint"];for(let l of c)l in r&&(delete r[l],n=!0);Object.keys(r).length===0&&delete o["editor.codeActionsOnSave"]}}return n?(await Lt(e,JSON.stringify(o,null,2)),!0):!1}catch{return!1}},Vt=async()=>{if((await Ie()).length>0)return!0;for(let t of Ue)if(await a(t))return!0;return!1},Q={hasESLint:Vt,remove:async e=>{let t=await Ie();qt(e,t);let s=await Bt(),n=await Gt();return{packagesRemoved:t,filesRemoved:s,vsCodeCleaned:n}}};p();import{readFile as Ee,unlink as Ht,writeFile as Kt}from"fs/promises";import{parse as Oe}from"jsonc-parser";import{removeDependency as Xt}from"nypm";var $e=[".prettierrc",".prettierrc.js",".prettierrc.json",".prettierrc.yml",".prettierrc.yaml",".prettierrc.config.js","prettier.config.js","prettier.config.mjs",".prettierignore"],Je=async()=>{try{let e=await Ee("package.json","utf-8"),t=Oe(e);if(!t||typeof t!="object")return[];let s=t.dependencies||{},n=t.devDependencies||{},o={...s,...n};return Object.keys(o).filter(i=>i.startsWith("prettier")||i==="eslint-config-prettier"||i==="eslint-plugin-prettier")}catch{return[]}},Yt=async(e,t)=>{if(t.length!==0)try{for(let s of t)await Xt(s,{packageManager:e})}catch{}},Zt=async()=>{let e=[];for(let t of $e)if(await a(t))try{await Ht(t),e.push(t)}catch{}return e},Qt=async()=>{let e="./.vscode/settings.json";if(!await a(e))return!1;try{let t=await Ee(e,"utf-8"),s=Oe(t);if(!s||typeof s!="object")return!1;let n=!1,o={...s},i=["editor.defaultFormatter","prettier.enable","prettier.requireConfig","prettier.configPath","prettier.printWidth","prettier.tabWidth","prettier.useTabs","prettier.semi","prettier.singleQuote","prettier.quoteProps","prettier.trailingComma","prettier.bracketSpacing","prettier.arrowParens","prettier.endOfLine"];for(let c of i)c in o&&(c==="editor.defaultFormatter"&&o[c]==="esbenp.prettier-vscode"||c!=="editor.defaultFormatter")&&(delete o[c],n=!0);let r=Object.keys(o).filter(c=>c.startsWith("[")&&c.includes("javascript"));for(let c of r){let l=o[c];l&&typeof l=="object"&&"editor.defaultFormatter"in l&&l["editor.defaultFormatter"]==="esbenp.prettier-vscode"&&(delete l["editor.defaultFormatter"],n=!0,Object.keys(l).length===0&&delete o[c])}return n?(await Kt(e,JSON.stringify(o,null,2)),!0):!1}catch{return!1}},es=async()=>{if((await Je()).length>0)return!0;for(let t of $e)if(await a(t))return!0;return!1},ee={hasPrettier:es,remove:async e=>{let t=await Je();Yt(e,t);let s=await Zt(),n=await Qt();return{packagesRemoved:t,filesRemoved:s,vsCodeCleaned:n}}};p();import{readFile as ts,writeFile as Te}from"fs/promises";import ss from"deepmerge";import{parse as ns}from"jsonc-parser";var ze={compilerOptions:{strictNullChecks:!0}},$="./tsconfig.json",J={exists:()=>a($),create:()=>Te($,JSON.stringify(ze,null,2)),update:async()=>{let e=await ts($,"utf-8"),s=ns(e)||{},n=ss(s,ze);await Te($,JSON.stringify(n,null,2))}};p();var Le=f.devDependencies["@biomejs/biome"],We=f.version,rs=async(e,t=!0)=>{let s=m();s.start("Installing dependencies...");let n=[`ultracite@${We}`,`@biomejs/biome@${Le}`];if(t)for(let o of n)await is(o,{packageManager:e,workspace:await g()});else await C({devDependencies:{"@biomejs/biome":Le,ultracite:We}});s.stop("Dependencies installed.")},cs=async()=>{let e=m();if(e.start("Checking for tsconfig.json..."),await J.exists()){e.message("tsconfig.json found, updating..."),await J.update(),e.stop("tsconfig.json updated.");return}e.message("tsconfig.json not found, creating..."),await J.create(),e.stop("tsconfig.json created.")},ls=async()=>{let e=m();if(e.start("Checking for .vscode/settings.json..."),await N.exists()){e.message("settings.json found, updating..."),await N.update(),e.stop("settings.json updated.");return}e.message("settings.json not found, creating..."),await N.create(),e.stop("settings.json created.")},ds=async()=>{let e=m();if(e.start("Checking for .zed/settings.json..."),await U.exists()){e.message("settings.json found, updating..."),await U.update(),e.stop("settings.json updated.");return}e.message("settings.json not found, creating..."),await U.create(),e.stop("settings.json created.")},us=async()=>{let e=m();if(e.start("Checking for Biome configuration..."),await M.exists()){e.message("Biome configuration found, updating..."),await M.update(),e.stop("Biome configuration updated.");return}e.message("Biome configuration not found, creating..."),await M.create(),e.stop("Biome configuration created.")},ps=async(e,t=!0)=>{let s=m();if(s.start("Initializing pre-commit hooks..."),s.message("Installing Husky..."),t?await v.install(e):await C({devDependencies:{husky:"latest"}}),await v.exists()){s.message("Pre-commit hook found, updating..."),await v.update(e),s.stop("Pre-commit hook updated.");return}s.message("Pre-commit hook not found, creating..."),await v.create(e),s.stop("Pre-commit hook created.")},ms=async(e,t=!0)=>{let s=m();if(s.start("Initializing lefthook..."),s.message("Installing lefthook..."),t?await k.install(e):await C({devDependencies:{lefthook:"latest"}}),await k.exists()){s.message("lefthook.yml found, updating..."),await k.update(e),s.stop("lefthook.yml updated.");return}s.message("lefthook.yml not found, creating..."),await k.create(e),s.stop("lefthook.yml created.")},fs=async(e,t=!0)=>{let s=m();if(s.start("Initializing lint-staged..."),s.message("Installing lint-staged..."),t?await x.install(e):await C({devDependencies:{"lint-staged":"latest"}}),await x.exists()){s.message("lint-staged found, updating..."),await x.update(e),s.stop("lint-staged updated.");return}s.message("lint-staged not found, creating..."),await x.create(e),s.stop("lint-staged created.")},gs=async(e,t)=>{let s=m();s.start(`Checking for ${t}...`);let n=ke(e);if(await n.exists()){s.message(`${t} found, updating...`),await n.update(),s.stop(`${t} updated.`);return}s.message(`${t} not found, creating...`),await n.create(),s.stop(`${t} created.`)},hs=async e=>{let t=m();t.start("Removing Prettier dependencies and configuration...");try{let s=await ee.remove(e);s.packagesRemoved.length>0&&t.message(`Removed Prettier packages: ${s.packagesRemoved.join(", ")}`),s.filesRemoved.length>0&&t.message(`Removed config files: ${s.filesRemoved.join(", ")}`),s.vsCodeCleaned&&t.message("Cleaned VS Code settings"),t.stop("Prettier removed successfully.")}catch{t.stop("Failed to remove Prettier completely, but continuing...")}},ys=async e=>{let t=m();t.start("Removing ESLint dependencies and configuration...");try{let s=await Q.remove(e);s.packagesRemoved.length>0&&t.message(`Removed ESLint packages: ${s.packagesRemoved.join(", ")}`),s.filesRemoved.length>0&&t.message(`Removed config files: ${s.filesRemoved.join(", ")}`),s.vsCodeCleaned&&t.message("Cleaned VS Code settings"),t.stop("ESLint removed successfully.")}catch{t.stop("Failed to remove ESLint completely, but continuing...")}},qe=async e=>{os(ie);try{let t=e??{},{pm:s}=t;if(!s){let d=await as(_e.cwd());if(!d)throw new Error("No package manager specified or detected");if(d.warnings)for(let b of d.warnings)T.warn(b);T.info(`Detected lockfile, using ${d.name}`),s=d.name}let n=t.removePrettier,o=t.removeEslint;if(n===void 0||o===void 0){let d=[];if(n===void 0&&await ee.hasPrettier()&&d.push({label:"Remove Prettier (dependencies, config files, VS Code settings)",value:"prettier"}),o===void 0&&await Q.hasESLint()&&d.push({label:"Remove ESLint (dependencies, config files, VS Code settings)",value:"eslint"}),d.length>0){let b=await z({message:"Remove existing formatters/linters (recommended for clean migration)?",options:d,required:!1});n===void 0&&(n=b.includes("prettier")),o===void 0&&(o=b.includes("eslint"))}}let i=t.editors;i||(i=await z({message:"Which editors do you want to configure (recommended)?",options:[{label:"VSCode / Cursor / Windsurf",value:"vscode"},{label:"Zed",value:"zed"}],required:!1}));let r=t.rules,c={"vscode-copilot":"GitHub Copilot (VSCode)",cursor:"Cursor",windsurf:"Windsurf",zed:"Zed",claude:"Claude Code",codex:"OpenAI Codex / Jules / OpenCode",kiro:"Kiro IDE",cline:"Cline",amp:"AMP",aider:"Aider","firebase-studio":"Firebase Studio","open-hands":"Open Hands","gemini-cli":"Gemini CLI",junie:"Junie",augmentcode:"Augment Code","kilo-code":"Kilo Code",goose:"Codename Goose"};r||(r=await z({message:"Which editor rules do you want to enable (optional)?",options:Object.entries(c).map(([d,b])=>({value:d,label:b})),required:!1}));let l=t.integrations;l===void 0&&(t.pm||t.editors||t.rules||t.removePrettier!==void 0||t.removeEslint!==void 0?l=[]:l=await z({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:"lint-staged"}],required:!1})),n&&await hs(s),o&&await ys(s),await rs(s,!t.skipInstall),await cs(),await us(),i?.includes("vscode")&&await ls(),i?.includes("zed")&&await ds();for(let d of r??[])await gs(d,c[d]);l?.includes("husky")&&await ps(s,!t.skipInstall),l?.includes("lefthook")&&await ms(s,!t.skipInstall),l?.includes("lint-staged")&&await fs(s,!t.skipInstall),T.success("Successfully initialized Ultracite configuration!")}catch(t){let s=t instanceof Error?t.message:"Unknown error";T.error(`Failed to initialize Ultracite configuration: ${s}`),_e.exit(1)}};var _=bs.initTRPC.meta().create(),vs=_.router({init:_.procedure.meta({description:"Initialize Ultracite in the current directory"}).input(u.object({pm:u.enum(j.packageManagers).optional().describe("Package manager to use"),editors:u.array(u.enum(j.editorConfigs)).optional().describe("Editors to configure"),rules:u.array(u.enum(j.editorRules)).optional().describe("Editor rules to enable"),integrations:u.array(u.enum(j.integrations)).optional().describe("Additional integrations to enable"),removePrettier:u.boolean().optional().describe("Remove Prettier dependencies and configuration"),removeEslint:u.boolean().optional().describe("Remove ESLint dependencies and configuration"),skipInstall:u.boolean().default(!1).describe("Skip installing dependencies")})).mutation(async({input:e})=>{await qe(e)}),lint:_.procedure.meta({description:"Run Biome linter without fixing files"}).input(u.array(u.string()).optional().default([]).describe("specific files to lint")).query(({input:e})=>{ne(e)}),format:_.procedure.meta({description:"Run Biome linter and fixes files"}).input(u.tuple([u.array(u.string()).optional().default([]).describe("specific files to format"),u.object({unsafe:u.boolean().optional().describe("apply unsafe fixes")})])).mutation(({input:e})=>{let[t,s]=e;se(t,{unsafe:s.unsafe})})}),ks=ws({router:vs,name:f.name,version:f.version,description:f.description});process.env.VITEST||ks.run();
|
|
133
|
+
${P}`)}else await E(t.path,s)}}};H();K();Y();p();import{readFile as Ue,unlink as qt,writeFile as Bt}from"fs/promises";import{parse as Ee}from"jsonc-parser";import{removeDependency as Gt}from"nypm";var Oe=[".eslintrc",".eslintrc.js",".eslintrc.json",".eslintrc.yml",".eslintrc.yaml",".eslintrc.config.js","eslint.config.js","eslint.config.mjs","eslint.config.cjs",".eslintignore"],$e=async()=>{try{let e=await Ue("package.json","utf-8"),t=Ee(e);if(!t||typeof t!="object")return[];let s=t.dependencies||{},n=t.devDependencies||{},o={...s,...n};return Object.keys(o).filter(i=>i.startsWith("eslint")||i.startsWith("@eslint/")||i==="@typescript-eslint/parser"||i==="@typescript-eslint/eslint-plugin")}catch{return[]}},Vt=async(e,t)=>{if(t.length!==0)try{for(let s of t)await Gt(s,{packageManager:e})}catch{}},Ht=async()=>{let e=[];for(let t of Oe)if(await a(t))try{await qt(t),e.push(t)}catch{}return e},Kt=async()=>{let e="./.vscode/settings.json";if(!await a(e))return!1;try{let t=await Ue(e,"utf-8"),s=Ee(t);if(!s||typeof s!="object")return!1;let n=!1,o={...s},i=["eslint.enable","eslint.format.enable","eslint.validate","eslint.workingDirectories","eslint.codeAction.showDocumentation","eslint.run","eslint.autoFixOnSave","eslint.quiet","eslint.packageManager","eslint.options","eslint.trace.server"];for(let r of i)r in o&&(delete o[r],n=!0);if("editor.codeActionsOnSave"in o){let r=o["editor.codeActionsOnSave"];if(r&&typeof r=="object"){let c=["source.fixAll.eslint","source.organizeImports.eslint"];for(let l of c)l in r&&(delete r[l],n=!0);Object.keys(r).length===0&&delete o["editor.codeActionsOnSave"]}}return n?(await Bt(e,JSON.stringify(o,null,2)),!0):!1}catch{return!1}},Xt=async()=>{if((await $e()).length>0)return!0;for(let t of Oe)if(await a(t))return!0;return!1},ee={hasESLint:Xt,remove:async e=>{let t=await $e();Vt(e,t);let s=await Ht(),n=await Kt();return{packagesRemoved:t,filesRemoved:s,vsCodeCleaned:n}}};p();import{readFile as Te,unlink as Yt,writeFile as Zt}from"fs/promises";import{parse as Je}from"jsonc-parser";import{removeDependency as Qt}from"nypm";var _e=[".prettierrc",".prettierrc.js",".prettierrc.json",".prettierrc.yml",".prettierrc.yaml",".prettierrc.config.js","prettier.config.js","prettier.config.mjs",".prettierignore"],ze=async()=>{try{let e=await Te("package.json","utf-8"),t=Je(e);if(!t||typeof t!="object")return[];let s=t.dependencies||{},n=t.devDependencies||{},o={...s,...n};return Object.keys(o).filter(i=>i.startsWith("prettier")||i==="eslint-config-prettier"||i==="eslint-plugin-prettier")}catch{return[]}},es=async(e,t)=>{if(t.length!==0)try{for(let s of t)await Qt(s,{packageManager:e})}catch{}},ts=async()=>{let e=[];for(let t of _e)if(await a(t))try{await Yt(t),e.push(t)}catch{}return e},ss=async()=>{let e="./.vscode/settings.json";if(!await a(e))return!1;try{let t=await Te(e,"utf-8"),s=Je(t);if(!s||typeof s!="object")return!1;let n=!1,o={...s},i=["editor.defaultFormatter","prettier.enable","prettier.requireConfig","prettier.configPath","prettier.printWidth","prettier.tabWidth","prettier.useTabs","prettier.semi","prettier.singleQuote","prettier.quoteProps","prettier.trailingComma","prettier.bracketSpacing","prettier.arrowParens","prettier.endOfLine"];for(let c of i)c in o&&(c==="editor.defaultFormatter"&&o[c]==="esbenp.prettier-vscode"||c!=="editor.defaultFormatter")&&(delete o[c],n=!0);let r=Object.keys(o).filter(c=>c.startsWith("[")&&c.includes("javascript"));for(let c of r){let l=o[c];l&&typeof l=="object"&&"editor.defaultFormatter"in l&&l["editor.defaultFormatter"]==="esbenp.prettier-vscode"&&(delete l["editor.defaultFormatter"],n=!0,Object.keys(l).length===0&&delete o[c])}return n?(await Zt(e,JSON.stringify(o,null,2)),!0):!1}catch{return!1}},ns=async()=>{if((await ze()).length>0)return!0;for(let t of _e)if(await a(t))return!0;return!1},te={hasPrettier:ns,remove:async e=>{let t=await ze();es(e,t);let s=await ts(),n=await ss();return{packagesRemoved:t,filesRemoved:s,vsCodeCleaned:n}}};p();import{readFile as os,writeFile as Le}from"fs/promises";import is from"deepmerge";import{parse as as}from"jsonc-parser";var We={compilerOptions:{strictNullChecks:!0}},T="./tsconfig.json",J={exists:()=>a(T),create:()=>Le(T,JSON.stringify(We,null,2)),update:async()=>{let e=await os(T,"utf-8"),s=as(e)||{},n=is(s,We);await Le(T,JSON.stringify(n,null,2))}};p();var Be=f.devDependencies["@biomejs/biome"],Ge=f.version,us=async(e,t=!0)=>{let s=m();s.start("Installing dependencies...");let n=[`ultracite@${Ge}`,`@biomejs/biome@${Be}`];if(t)for(let o of n)await cs(o,{packageManager:e,workspace:await g()});else await j({devDependencies:{"@biomejs/biome":Be,ultracite:Ge}});s.stop("Dependencies installed.")},ds=async()=>{let e=m();if(e.start("Checking for tsconfig.json..."),await J.exists()){e.message("tsconfig.json found, updating..."),await J.update(),e.stop("tsconfig.json updated.");return}e.message("tsconfig.json not found, creating..."),await J.create(),e.stop("tsconfig.json created.")},ps=async()=>{let e=m();if(e.start("Checking for .vscode/settings.json..."),await F.exists()){e.message("settings.json found, updating..."),await F.update(),e.stop("settings.json updated.");return}e.message("settings.json not found, creating..."),await F.create(),e.stop("settings.json created.")},ms=async()=>{let e=m();if(e.start("Checking for .zed/settings.json..."),await U.exists()){e.message("settings.json found, updating..."),await U.update(),e.stop("settings.json updated.");return}e.message("settings.json not found, creating..."),await U.create(),e.stop("settings.json created.")},fs=async()=>{let e=m();if(e.start("Checking for Biome configuration..."),await A.exists()){e.message("Biome configuration found, updating..."),await A.update(),e.stop("Biome configuration updated.");return}e.message("Biome configuration not found, creating..."),await A.create(),e.stop("Biome configuration created.")},gs=async(e,t=!0)=>{let s=m();if(s.start("Initializing pre-commit hooks..."),s.message("Installing Husky..."),t?await v.install(e):await j({devDependencies:{husky:"latest"}}),await v.exists()){s.message("Pre-commit hook found, updating..."),await v.update(e),s.stop("Pre-commit hook updated.");return}s.message("Pre-commit hook not found, creating..."),await v.create(e),s.stop("Pre-commit hook created.")},hs=async(e,t=!0)=>{let s=m();if(s.start("Initializing lefthook..."),s.message("Installing lefthook..."),t?await k.install(e):await j({devDependencies:{lefthook:"latest"}}),await k.exists()){s.message("lefthook.yml found, updating..."),await k.update(e),s.stop("lefthook.yml updated.");return}s.message("lefthook.yml not found, creating..."),await k.create(e),s.stop("lefthook.yml created.")},ys=async(e,t=!0)=>{let s=m();if(s.start("Initializing lint-staged..."),s.message("Installing lint-staged..."),t?await x.install(e):await j({devDependencies:{"lint-staged":"latest"}}),await x.exists()){s.message("lint-staged found, updating..."),await x.update(e),s.stop("lint-staged updated.");return}s.message("lint-staged not found, creating..."),await x.create(e),s.stop("lint-staged created.")},ws=async(e,t)=>{let s=m();s.start(`Checking for ${t}...`);let n=je(e);if(await n.exists()){s.message(`${t} found, updating...`),await n.update(),s.stop(`${t} updated.`);return}s.message(`${t} not found, creating...`),await n.create(),s.stop(`${t} created.`)},bs=async e=>{let t=m();t.start("Removing Prettier dependencies and configuration...");try{let s=await te.remove(e);s.packagesRemoved.length>0&&t.message(`Removed Prettier packages: ${s.packagesRemoved.join(", ")}`),s.filesRemoved.length>0&&t.message(`Removed config files: ${s.filesRemoved.join(", ")}`),s.vsCodeCleaned&&t.message("Cleaned VS Code settings"),t.stop("Prettier removed successfully.")}catch{t.stop("Failed to remove Prettier completely, but continuing...")}},vs=async e=>{let t=m();t.start("Removing ESLint dependencies and configuration...");try{let s=await ee.remove(e);s.packagesRemoved.length>0&&t.message(`Removed ESLint packages: ${s.packagesRemoved.join(", ")}`),s.filesRemoved.length>0&&t.message(`Removed config files: ${s.filesRemoved.join(", ")}`),s.vsCodeCleaned&&t.message("Cleaned VS Code settings"),t.stop("ESLint removed successfully.")}catch{t.stop("Failed to remove ESLint completely, but continuing...")}},Ve=async e=>{rs(oe);try{let t=e??{},{pm:s}=t;if(!s){let u=await ls(qe.cwd());if(!u)throw new Error("No package manager specified or detected");if(u.warnings)for(let b of u.warnings)_.warn(b);_.info(`Detected lockfile, using ${u.name}`),s=u.name}let n=t.removePrettier,o=t.removeEslint;if(n===void 0||o===void 0){let u=[];if(n===void 0&&await te.hasPrettier()&&u.push({label:"Remove Prettier (dependencies, config files, VS Code settings)",value:"prettier"}),o===void 0&&await ee.hasESLint()&&u.push({label:"Remove ESLint (dependencies, config files, VS Code settings)",value:"eslint"}),u.length>0){let b=await z({message:"Remove existing formatters/linters (recommended for clean migration)?",options:u,required:!1});n===void 0&&(n=b.includes("prettier")),o===void 0&&(o=b.includes("eslint"))}}let i=t.editors;i||(i=await z({message:"Which editors do you want to configure (recommended)?",options:[{label:"VSCode / Cursor / Windsurf",value:"vscode"},{label:"Zed",value:"zed"}],required:!1}));let r=t.rules,c={"vscode-copilot":"GitHub Copilot (VSCode)",cursor:"Cursor",windsurf:"Windsurf",zed:"Zed",claude:"Claude Code",codex:"OpenAI Codex / Jules / OpenCode",kiro:"Kiro IDE",cline:"Cline",amp:"AMP",aider:"Aider","firebase-studio":"Firebase Studio","open-hands":"Open Hands","gemini-cli":"Gemini CLI",junie:"Junie",augmentcode:"Augment Code","kilo-code":"Kilo Code",goose:"Codename Goose"};r||(r=await z({message:"Which editor rules do you want to enable (optional)?",options:Object.entries(c).map(([u,b])=>({value:u,label:b})),required:!1}));let l=t.integrations;l===void 0&&(t.pm||t.editors||t.rules||t.removePrettier!==void 0||t.removeEslint!==void 0?l=[]:l=await z({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:"lint-staged"}],required:!1})),n&&await bs(s),o&&await vs(s),await us(s,!t.skipInstall),await ds(),await fs(),i?.includes("vscode")&&await ps(),i?.includes("zed")&&await ms();for(let u of r??[])await ws(u,c[u]);l?.includes("husky")&&await gs(s,!t.skipInstall),l?.includes("lefthook")&&await hs(s,!t.skipInstall),l?.includes("lint-staged")&&await ys(s,!t.skipInstall),_.success("Successfully initialized Ultracite configuration!")}catch(t){let s=t instanceof Error?t.message:"Unknown error";_.error(`Failed to initialize Ultracite configuration: ${s}`),qe.exit(1)}};var L=xs.initTRPC.meta().create(),Ds=L.router({init:L.procedure.meta({description:"Initialize Ultracite in the current directory"}).input(d.object({pm:d.enum(C.packageManagers).optional().describe("Package manager to use"),editors:d.array(d.enum(C.editorConfigs)).optional().describe("Editors to configure"),rules:d.array(d.enum(C.editorRules)).optional().describe("Editor rules to enable"),integrations:d.array(d.enum(C.integrations)).optional().describe("Additional integrations to enable"),removePrettier:d.boolean().optional().describe("Remove Prettier dependencies and configuration"),removeEslint:d.boolean().optional().describe("Remove ESLint dependencies and configuration"),skipInstall:d.boolean().default(!1).describe("Skip installing dependencies")})).mutation(async({input:e})=>{await Ve(e)}),lint:L.procedure.meta({description:"Run Biome linter without fixing files"}).input(d.array(d.string()).optional().default([]).describe("specific files to lint")).query(({input:e})=>{ce(e)}),format:L.procedure.meta({description:"Run Biome linter and fixes files"}).input(d.tuple([d.array(d.string()).optional().default([]).describe("specific files to format"),d.object({unsafe:d.boolean().optional().describe("apply unsafe fixes")})])).mutation(({input:e})=>{let[t,s]=e;ae(t,{unsafe:s.unsafe})})}),js=ks({router:Ds,name:f.name,version:f.version,description:f.description});process.env.VITEST||js.run();export{Ds as router};
|