Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add biome #48

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .prettierignore

This file was deleted.

12 changes: 0 additions & 12 deletions .prettierrc

This file was deleted.

28 changes: 28 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"$schema": "https://biomejs.dev/schemas/1.7.3/schema.json",
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "tab",
"indentWidth": 2,
"lineEnding": "cr",
"lineWidth": 120,
"attributePosition": "auto",
"ignore": ["**/*.rs", "**/*.yaml"]
},
"organizeImports": { "enabled": true },
"linter": { "enabled": true, "rules": { "recommended": true } },
"javascript": {
"formatter": {
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"trailingComma": "all",
"semicolons": "always",
"arrowParentheses": "always",
"bracketSpacing": true,
"bracketSameLine": false,
"quoteStyle": "double",
"attributePosition": "auto"
}
}
}
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"watch:ui": "nodemon --watch packages/ui/src -e ts --exec 'turbo run build --scope=ui'",
"watch:utils": "nodemon --watch packages/utils/src -e ts --exec 'turbo run build --scope=utils'",
"start": "cd packages/core && pnpm start",
"format": "prettier --write ."
"format": "biome format ./ --write",
"lint": "biome lint ."
},
"contributors": [
{
Expand All @@ -30,13 +31,11 @@
"name": "Rahul Batra"
}
],
"workspaces": [
"./packages/*"
],
"workspaces": ["./packages/*"],
"devDependencies": {
"@biomejs/biome": "^1.7.3",
"@changesets/cli": "2.27.3",
"nodemon": "^3.1.0",
"prettier": "^3.2.5",
"turbo": "^1.13.3",
"vitest": "^1.6.0"
}
Expand Down
5 changes: 1 addition & 4 deletions packages/commands/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
"type": "git",
"url": "https://github.com/solidjs-community/solid-cli"
},
"files": [
"dist",
"types"
],
"files": ["dist", "types"],
"main": "./dist/index.mjs",
"module": "./dist/index.mjs",
"types": "./types/index.d.ts",
Expand Down
7 changes: 5 additions & 2 deletions packages/commands/src/handlers/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ export const handleAdd = async (packages?: string[], forceTransform: boolean = f
if (fileUpdates.length) p.log.message([`${color.cyan("Modify")}`, ...fileUpdates.map((f) => ` - ${f}`)].join("\n"));

if (packageUpdates.length)
p.log.message([`${color.cyan("Install")}`, ...packageUpdates.map((p) => ` - ${p.name}` + (p.dev ? " (dev)" : ""))].join("\n"));
p.log.message(
[`${color.cyan("Install")}`, ...packageUpdates.map((p) => ` - ${p.name}` + (p.dev ? " (dev)" : ""))].join("\n"),
);
if (commandUpdates.length)
p.log.message([`${color.cyan("Run commands")}`, ...commandUpdates.map((p) => ` - ${p}`)].join("\n"));

Expand All @@ -196,7 +198,8 @@ export const handleAdd = async (packages?: string[], forceTransform: boolean = f
if (postInstalls.length === 0) return;

p.log.message(
`${postInstalls.length} ${postInstalls.length === 1 ? "package has" : "packages have"
`${postInstalls.length} ${
postInstalls.length === 1 ? "package has" : "packages have"
} post install steps that need to run.`,
);

Expand Down
135 changes: 70 additions & 65 deletions packages/commands/src/lib/integrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export type Integrations = Record<Supported, IntegrationsValue>;
export const [rootFile, setRootFile] = createSignal<string | undefined>(undefined);

export const integrations: Record<string, IntegrationsValue> = {
"tailwind": {
tailwind: {
installs: ["tailwindcss", "postcss", "autoprefixer"],
postInstall: async () => {
const pM = detectPackageManager();
Expand Down Expand Up @@ -73,7 +73,7 @@ export const integrations: Record<string, IntegrationsValue> = {
await flushQueue();
},
},
"unocss": {
unocss: {
pluginOptions: {
importName: "UnoCss",
importSource: "unocss/vite",
Expand All @@ -88,7 +88,7 @@ export const integrations: Record<string, IntegrationsValue> = {
await insertAtBeginning(path, `import "virtual:uno.css";\n`);
},
},
"vitepwa": {
vitepwa: {
pluginOptions: {
importName: "VitePWA",
importSource: "vite-plugin-pwa",
Expand All @@ -111,7 +111,7 @@ export const integrations: Record<string, IntegrationsValue> = {
await insertAtBeginning(path, `import "solid-devtools";\n`);
},
},
"vitest": {
vitest: {
installs: [],
installsDev: [
"vitest",
Expand All @@ -123,30 +123,32 @@ export const integrations: Record<string, IntegrationsValue> = {
additionalConfig: async () => {
try {
p.log.info("Adding test script to package.json");
let hasStart = false;
manipulateJsonFile("package.json", (packageJson) => {
if (!packageJson.scripts) { packageJson.scripts = {}; }
if (!/\bvitest\b/.test(packageJson.scripts.test || "")) {
packageJson.scripts.test = "vitest";
}
hasStart = packageJson.dependencies["@solidjs/start"]
return packageJson;
});
let hasStart = false;
manipulateJsonFile("package.json", (packageJson) => {
if (!packageJson.scripts) {
packageJson.scripts = {};
}
if (!/\bvitest\b/.test(packageJson.scripts.test || "")) {
packageJson.scripts.test = "vitest";
}
hasStart = packageJson.dependencies["@solidjs/start"];
return packageJson;
});
const hasTs = fileExists("tsconfig.json");
if (hasTs) {
if (hasTs) {
p.log.info("Adding testing types to tsconfig.json");
manipulateJsonFile("tsconfig.json", (tsConfig) => {
if (!tsConfig.compilerOptions) {
tsConfig.compilerOptions = {};
}
tsConfig.compilerOptions.types = [
...new Set([...(tsConfig.compilerOptions.types || []), "vite/client", "@testing-library/jest-dom"]),
];
return tsConfig;
});
manipulateJsonFile("tsconfig.json", (tsConfig) => {
if (!tsConfig.compilerOptions) {
tsConfig.compilerOptions = {};
}
tsConfig.compilerOptions.types = [
...new Set([...(tsConfig.compilerOptions.types || []), "vite/client", "@testing-library/jest-dom"]),
];
return tsConfig;
});
}
if (
hasStart &&
hasStart &&
["ts", "mjs", "cjs", "js"].every(
(suffix) => !fileExists(`vite.config.${suffix}`) && !fileExists(`vitest.config.${suffix}`),
)
Expand All @@ -173,49 +175,52 @@ export default defineConfig({
}
},
},
"tauri-v1.x": {
installs: ["@tauri-apps/cli"],
postInstall: async () => {
try {
let name = "";
manipulateJsonFile("package.json", (packageJson) => {
if (!packageJson.scripts) { packageJson.scripts = {}; }
packageJson.scripts.tauri = "tauri";
name = packageJson.name;
return packageJson;
});
await flushQueue();
const pM = detectPackageManager();
await $`${getRunnerCommand(pM)} tauri init --ci -A ${name} -W ${name} -D ../dist -P http://localhost:3000`;
p.note(`Make sure you have installed all prerequisites: https://tauri.app/v1/guides/getting-started/prerequisites
"tauri-v1.x": {
installs: ["@tauri-apps/cli"],
postInstall: async () => {
try {
let name = "";
manipulateJsonFile("package.json", (packageJson) => {
if (!packageJson.scripts) {
packageJson.scripts = {};
}
packageJson.scripts.tauri = "tauri";
name = packageJson.name;
return packageJson;
});
await flushQueue();
const pM = detectPackageManager();
await $`${getRunnerCommand(pM)} tauri init --ci -A ${name} -W ${name} -D ../dist -P http://localhost:3000`;
p.note(`Make sure you have installed all prerequisites: https://tauri.app/v1/guides/getting-started/prerequisites

Start tauri development with ${color.bold(pM.name)} ${color.bold(pM.runScriptCommand("tauri dev"))}`);
} catch (err) {
console.error(err);
}
},
},
"tauri-v2.x": {
installs: ["@tauri-apps/cli@next"],
postInstall: async () => {
try {
let name = "";
manipulateJsonFile("package.json", (packageJson) => {
if (!packageJson.scripts) { packageJson.scripts = {}; }
packageJson.scripts.tauri = "tauri";
name = packageJson.name;
return packageJson;
})
await flushQueue();
const pM = detectPackageManager();
await $`${getRunnerCommand(pM)} tauri init --ci -A ${name} -W ${name} -D ../dist -P http://localhost:3000`;
p.note(`Make sure you have installed all prerequisites: https://v2.tauri.app/start/prerequisites/
} catch (err) {
console.error(err);
}
},
},
"tauri-v2.x": {
installs: ["@tauri-apps/cli@next"],
postInstall: async () => {
try {
let name = "";
manipulateJsonFile("package.json", (packageJson) => {
if (!packageJson.scripts) {
packageJson.scripts = {};
}
packageJson.scripts.tauri = "tauri";
name = packageJson.name;
return packageJson;
});
await flushQueue();
const pM = detectPackageManager();
await $`${getRunnerCommand(pM)} tauri init --ci -A ${name} -W ${name} -D ../dist -P http://localhost:3000`;
p.note(`Make sure you have installed all prerequisites: https://v2.tauri.app/start/prerequisites/

Start tauri development with ${color.bold(pM.name)} ${color.bold(pM.runScriptCommand("tauri dev"))}`);
} catch (err) {
console.error(err);
}
},
},
} catch (err) {
console.error(err);
}
},
},
};

Loading