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

fix: Linting + Env #25

Merged
merged 9 commits into from
Jul 1, 2024
Merged
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: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"access": "public",
"baseBranch": "main",
"changedFilePatterns": ["src/**", "template/**"],
"changelog": ["@changesets/changelog-github", { "repo": "OllieJT/create-sva" }],
"changelog": ["@changesets/changelog-github", { "repo": "olliejt/create-sva" }],
"commit": false,
"fixed": [],
"ignore": ["@sva/web"],
Expand Down
5 changes: 5 additions & 0 deletions .changeset/tender-emus-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-sva": patch
---

Bump dependencies
5 changes: 5 additions & 0 deletions cli/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
packageExtensions:
[email protected]:
dependencies:
"#ansi-styles": npm:[email protected]
"#supports-color": npm:[email protected]
69 changes: 65 additions & 4 deletions cli/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,67 @@
/** @type {import('eslint').Linter.FlatConfig[]} */
export default [
import js from "@eslint/js";
import prettier from "eslint-config-prettier";
import svelte from "eslint-plugin-svelte";
import globals from "globals";
import ts from "typescript-eslint";

export default ts.config(
js.configs.recommended,
...ts.configs.recommended,
...svelte.configs["flat/recommended"],
prettier,
...svelte.configs["flat/prettier"],
{
ignores: ['dist', 'template/**/*'],
languageOptions: {
globals: {
...globals.browser,
...globals.node,
},
},
},
];
{
files: ["**/*.svelte", "**/*.svelte.ts"],
languageOptions: {
parserOptions: {
parser: ts.parser,
},
},
},
{
rules: {
"@typescript-eslint/no-explicit-any": "error",

"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
destructuredArrayIgnorePattern: "^_",
},
],

"@typescript-eslint/no-confusing-void-expression": "off",
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/prefer-nullish-coalescing": "off",
"@typescript-eslint/no-namespace": "off",
},
},
{
files: ["./template/**/*"],
...ts.configs.disableTypeChecked,
},
{
ignores: [
".DS_Store",
"node_modules",
"/build",
"**/.svelte-kit",
"dist/",
"/package",
".env",
".env.*",
"!.env.example",
"pnpm-lock.yaml",
"package-lock.json",
"yarn.lock",
],
},
);
4 changes: 2 additions & 2 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@
"devDependencies": {
"@types/fs-extra": "^11.0.4",
"@types/gradient-string": "^1.1.6",
"@types/node": "^20.12.12",
"@types/node": "^20.14.9",
"prettier": "^3.3.2",
"prettier-plugin-svelte": "^3.2.5",
"prettier-plugin-tailwindcss": "^0.6.5",
"tailwindcss": "^3.4.4",
"tsup": "^8.1.0",
"type-fest": "^4.20.1",
"typescript": "^5.4.5"
"typescript": "^5.5.3"
}
}
2 changes: 1 addition & 1 deletion cli/src/data/get-cli-version.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PKG_ROOT } from "$src/data/constants.js";
import fs from "fs-extra";
import path from "path";
import { PackageJson } from "type-fest";
import type { PackageJson } from "type-fest";

export function get_cli_version() {
const package_json_path = path.join(PKG_ROOT, "package.json");
Expand Down
2 changes: 1 addition & 1 deletion cli/src/data/options.adapter-solution.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ClackOption } from "$src/data/types.js";
import type { ClackOption } from "$src/data/types.js";

export const adapter_solutions = ["node", "vercel", "netlify", "cloudflare", "auto"] as const;
export type AdapterSolution = (typeof adapter_solutions)[number];
Expand Down
2 changes: 1 addition & 1 deletion cli/src/data/options.auth-solution.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ClackOption } from "$src/data/types.js";
import type { ClackOption } from "$src/data/types.js";

// FEAT: Add Auth.JS support
// FEAT: Add Supabase.Auth
Expand Down
2 changes: 1 addition & 1 deletion cli/src/data/options.css-solution.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ClackOption } from "$src/data/types.js";
import type { ClackOption } from "$src/data/types.js";

export const css_solutions = ["none", "tailwind", "shadcn", "bits_ui"] as const;
export type CssSolution = (typeof css_solutions)[number];
Expand Down
2 changes: 1 addition & 1 deletion cli/src/data/options.database-solution.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ClackOption } from "$src/data/types.js";
import type { ClackOption } from "$src/data/types.js";

// FEAT: Add Supabase.DB support
export const database_solutions = ["mysql", "sqlite", "postgres"] as const;
Expand Down
2 changes: 1 addition & 1 deletion cli/src/data/options.dev-tool-solutions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ClackOption } from "$src/data/types.js";
import type { ClackOption } from "$src/data/types.js";

export const dev_tool_solutions = ["none", "husky", "vscode"] as const;
export type DevToolSolution = (typeof dev_tool_solutions)[number];
Expand Down
10 changes: 5 additions & 5 deletions cli/src/data/options.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { AdapterSolution } from "$src/data/options.adapter-solution.js";
import { AuthSolution } from "$src/data/options.auth-solution.js";
import { CssSolution } from "$src/data/options.css-solution.js";
import { DatabaseSolution } from "$src/data/options.database-solution.js";
import { DevToolSolution } from "$src/data/options.dev-tool-solutions.js";
import type { AdapterSolution } from "$src/data/options.adapter-solution.js";
import type { AuthSolution } from "$src/data/options.auth-solution.js";
import type { CssSolution } from "$src/data/options.css-solution.js";
import type { DatabaseSolution } from "$src/data/options.database-solution.js";
import type { DevToolSolution } from "$src/data/options.dev-tool-solutions.js";
export * from "$src/data/options.adapter-solution.js";
export * from "$src/data/options.auth-solution.js";
export * from "$src/data/options.css-solution.js";
Expand Down
2 changes: 1 addition & 1 deletion cli/src/helper/create-project.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { get_user_pkg_manager } from "$src/data/get-user-pkg-manager.js";
import { install_packages } from "$src/helper/install-packages.js";
import { scaffold_project } from "$src/helper/scaffold-project.js";
import { InstallerOptions, PkgInstallerMap } from "$src/installers/installer.js";
import type { InstallerOptions, PkgInstallerMap } from "$src/installers/installer.js";
import path from "path";

type Options = Omit<InstallerOptions, "project_dir" | "pkg_manager"> & {
Expand Down
6 changes: 3 additions & 3 deletions cli/src/helper/initialize-git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const is_git_installed = (dir: string): boolean => {
try {
execSync("git --version", { cwd: dir });
return true;
} catch (_e) {
} catch {
return false;
}
};
Expand All @@ -30,7 +30,7 @@ const is_inside_git_repo = async (dir: string): Promise<boolean> => {
stdout: "ignore",
});
return true;
} catch (_e) {
} catch {
// Else, it will throw a git-error and we return false
return false;
}
Expand Down Expand Up @@ -120,7 +120,7 @@ export const initialize_git = async ({ project_dir }: { project_dir: string }) =
spinner.succeed(
`${chalk.green("Successfully initialized and staged")} ${chalk.green.bold("git")}\n`,
);
} catch (error) {
} catch {
// Safeguard, should be unreachable
spinner.fail(
`${chalk.bold.red("Failed:")} could not initialize git. Update git to the latest version!\n`,
Expand Down
2 changes: 1 addition & 1 deletion cli/src/helper/initialize-husky.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const initialize_husky = async ({ project_dir }: { project_dir: string })
fs.writeFileSync(husky_hook, husky_hook_content);

spinner.succeed(`${chalk.green("Successfully initialized")} ${chalk.green.bold("husky")}\n`);
} catch (error) {
} catch {
// Safeguard, should be unreachable
spinner.fail(`${chalk.bold.red("Failed:")} could not initialize hucky.\n`);
}
Expand Down
2 changes: 1 addition & 1 deletion cli/src/helper/install-dependencies.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PackageManager, get_user_pkg_manager } from "$src/data/get-user-pkg-manager.js";
import { get_user_pkg_manager, type PackageManager } from "$src/data/get-user-pkg-manager.js";
import { logger } from "$src/utility/logger.js";
import chalk from "chalk";
import { execa, type StdoutStderrOption } from "execa";
Expand Down
2 changes: 1 addition & 1 deletion cli/src/helper/install-packages.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InstallerOptions, PkgInstallerMap } from "$src/installers/installer.js";
import type { InstallerOptions, PkgInstallerMap } from "$src/installers/installer.js";
import { logger } from "$src/utility/logger.js";
import chalk from "chalk";
import ora from "ora";
Expand Down
4 changes: 2 additions & 2 deletions cli/src/helper/render-next-steps.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DEFAULT_APP_NAME } from "$src/data/constants.js";
import { get_user_pkg_manager } from "$src/data/get-user-pkg-manager.js";
import { InstallerOptions } from "$src/installers/installer.js";
import type { InstallerOptions } from "$src/installers/installer.js";
import { logger } from "$src/utility/logger.js";

// This logs the next steps that the user should take in order to advance the project
Expand All @@ -12,7 +12,7 @@ export const render_next_steps = async ({
const pkg_manager = get_user_pkg_manager();

logger.info("Next steps:");
project_name !== "." && logger.info(` cd ${project_name}`);
if (project_name !== ".") logger.info(` cd ${project_name}`);
if (no_install) {
// To reflect yarn's default behavior of installing packages when no additional args provided
if (pkg_manager === "yarn") {
Expand Down
2 changes: 1 addition & 1 deletion cli/src/helper/scaffold-project.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PKG_ROOT } from "$src/data/constants.js";
import { InstallerOptions } from "$src/installers/installer.js";
import type { InstallerOptions } from "$src/installers/installer.js";
import { logger } from "$src/utility/logger.js";
import * as p from "@clack/prompts";
import chalk from "chalk";
Expand Down
8 changes: 4 additions & 4 deletions cli/src/installers/installer.drizzle.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PKG_ROOT } from "$src/data/constants.js";
import { DatabaseSolution } from "$src/data/options.js";
import { AvailableDependencies } from "$src/installers/dependency-version-map.js";
import type { DatabaseSolution } from "$src/data/options.js";
import type { AvailableDependencies } from "$src/installers/dependency-version-map.js";
import { type Installer } from "$src/installers/installer.js";
import { add_env_variable } from "$src/utility/add-env_variable.js";
import { add_pkg_dependency } from "$src/utility/add-pkg-dependency.js";
Expand Down Expand Up @@ -64,7 +64,7 @@ export const drizzle_installer: Installer = ({ packages, project_dir, database_s

const config_src = path.join(source, `config/drizzle-config-${database_solution}.ts`);
const config_dest = path.join(project_dir, "drizzle.config.ts");
let config_content = fs.readFileSync(config_src, "utf-8");
const config_content = fs.readFileSync(config_src, "utf-8");

// Setup schema files

Expand All @@ -74,7 +74,7 @@ export const drizzle_installer: Installer = ({ packages, project_dir, database_s
`src/lib/server/schema-${database_solution}${schema_suffix}.ts`,
);
const schema_dest = path.join(dest_server, "schema.ts");
let schema_content = fs.readFileSync(schema_src, "utf-8");
const schema_content = fs.readFileSync(schema_src, "utf-8");

// Setup client files

Expand Down
2 changes: 1 addition & 1 deletion cli/src/installers/installer.husky.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Installer } from "$src/installers/installer.js";
import type { Installer } from "$src/installers/installer.js";
import { add_pkg_dependency } from "$src/utility/add-pkg-dependency.js";
import { update_pkg_json } from "$src/utility/update-pkg-json.js";

Expand Down
4 changes: 2 additions & 2 deletions cli/src/installers/installer.tailwind.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { PKG_ROOT } from "$src/data/constants.js";
import { Installer } from "$src/installers/installer.js";
import type { Installer } from "$src/installers/installer.js";
import { add_pkg_dependency } from "$src/utility/add-pkg-dependency.js";
import fs from "fs-extra";
import path from "path";
import { Config as PrettierConfig } from "prettier";
import { type Config as PrettierConfig } from "prettier";

export const tailwind_installer: Installer = ({ project_dir }) => {
add_pkg_dependency({
Expand Down
4 changes: 2 additions & 2 deletions cli/src/installers/installer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PackageManager } from "$src/data/get-user-pkg-manager.js";
import { AvailablePackages, DatabaseSolution } from "$src/data/options.js";
import type { PackageManager } from "$src/data/get-user-pkg-manager.js";
import type { AvailablePackages, DatabaseSolution } from "$src/data/options.js";
import { adapter_auto_installer } from "$src/installers/installer.adapter-auto.js";
import { adapter_cloudflare_installer } from "$src/installers/installer.adapter-cloudflare.js";
import { adapter_netlify_installer } from "$src/installers/installer.adapter-netlify.js";
Expand Down
2 changes: 1 addition & 1 deletion cli/src/installers/installer.vscode.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Installer } from "$src/installers/installer.js";
import type { Installer } from "$src/installers/installer.js";
import fs from "fs-extra";
import merge from "just-merge";
import path from "path";
Expand Down
4 changes: 2 additions & 2 deletions cli/src/questionaire.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { CLI_DESCRIPTION, CLI_NAME, DEFAULT_APP_NAME } from "$src/data/constants.js";
import { get_user_pkg_manager } from "$src/data/get-user-pkg-manager.js";
import {
AvailablePackages,
DatabaseSolution,
adapter_options,
auth_options,
css_options,
database_options,
dev_tool_options,
type AvailablePackages,
type DatabaseSolution,
} from "$src/data/options.js";
import { logger } from "$src/utility/logger.js";
import { validate_app_name } from "$src/utility/validate-app-name.js";
Expand Down
2 changes: 1 addition & 1 deletion cli/src/utility/add-pkg-dependency.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
AvailableDependencies,
type AvailableDependencies,
dependency_version_map,
} from "$src/installers/dependency-version-map.js";
import { update_pkg_json } from "$src/utility/update-pkg-json.js";
Expand Down
2 changes: 1 addition & 1 deletion cli/tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Config } from "tailwindcss";
import type { Config } from "tailwindcss";

export default {
darkMode: ["class"],
Expand Down
4 changes: 1 addition & 3 deletions cli/template/base/src/lib/sva/layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@
</div>

<style lang="postcss">
:global(body) {
background-color: theme(colors.slate.950);
}
:global(#sva-layout) {
background-color: theme(colors.slate.950);
--sva-color-1: #8537d1;
--sva-color-2: #be3793;
--sva-color-3: #e7445f;
Expand Down
4 changes: 4 additions & 0 deletions cli/template/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import js from "@eslint/js";
import ts from "typescript-eslint";

export default ts.config(js.configs.recommended, ...ts.configs.disableTypeChecked, {});
3 changes: 2 additions & 1 deletion cli/tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"extends": "./tsconfig.json",
"include": ["src", "template", "tsup.config.ts", "prettier.config.mjs"]
"include": ["src", "template", "tsup.config.ts", "prettier.config.mjs"],
"exclude": ["./template/**/*"]
}
Loading