Skip to content

Commit

Permalink
Added Biome and Removed Prettier & ESLint (#130)
Browse files Browse the repository at this point in the history
* added biome and removed prettier & eslint

* fixed all biome errors and set noConsolelog off

* Update biome.jsonc

Co-authored-by: Ben <[email protected]>

* Update biome.jsonc

Co-authored-by: Ben <[email protected]>

* updated biome version

---------

Co-authored-by: Ben <[email protected]>
  • Loading branch information
colodenn and NuroDev authored Sep 17, 2024
1 parent 90315f7 commit 28c7415
Show file tree
Hide file tree
Showing 41 changed files with 1,157 additions and 582 deletions.
52 changes: 0 additions & 52 deletions .eslintrc.json

This file was deleted.

5 changes: 0 additions & 5 deletions .prettierrc.json

This file was deleted.

8 changes: 7 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
{
"recommendations": ["oven.bun-vscode", "dbaeumer.vscode-eslint", "redhat.vscode-yaml"]
"recommendations": [
"oven.bun-vscode",
"redhat.vscode-yaml",
"mikestead.dotenv",
"gruntfuggly.todo-tree",
"biomejs.biome"
]
}
12 changes: 11 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
{
"discord.enabled": false,

"editor.formatOnSave": true,
"editor.defaultFormatter": "biomejs.biome",
"editor.rulers": [80, 120],

"javascript.updateImportsOnFileMove.enabled": "always",
"typescript.preferences.importModuleSpecifier": "non-relative"
"typescript.updateImportsOnFileMove.enabled": "always",
"javascript.preferences.importModuleSpecifier": "non-relative",
"typescript.preferences.importModuleSpecifier": "non-relative",

"yaml.schemas": {
"https://json.schemastore.org/github-workflow.json": ".github/workflows/*.yml"
}
}
82 changes: 82 additions & 0 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.1/schema.json",
"files": {
"include": ["./**/*.ts", "./**/*.json"],
"ignore": ["node_modules/", "bun.lockb"]
},
"formatter": {
"enabled": true,

"attributePosition": "multiline",
"indentStyle": "space",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 90
},
"javascript": {
"formatter": {
"enabled": true,
"trailingCommas": "all",
"arrowParentheses": "always",
"attributePosition": "multiline",
"bracketSameLine": true,
"bracketSpacing": true,
"jsxQuoteStyle": "single",
"quoteStyle": "single",
"semicolons": "always"
}
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,

"a11y": { "all": true },
"complexity": { "all": true },
"correctness": {
"noUnusedImports": "warn",
"noUnusedVariables": "warn"
},
"nursery": {
"all": true,
"useSortedClasses": "warn"
},
"performance": {
"all": true,

"noBarrelFile": "off"
},
"security": { "all": true },
"style": {
"all": true,
"noDefaultExport": "off",
"useBlockStatements": "off",
"noNonNullAssertion": "off",
"useConsistentArrayType": {
"level": "warn",
"options": {
"syntax": "generic"
}
},
"useFilenamingConvention": "off",
"useNamingConvention": "off",
"useShorthandArrayType": "off"
},
"suspicious": {
"all": true,
"noConsoleLog": "off",
// Fixing all any type errors is cumbersome. This repo is going to be
// reworked, so we'll just disable this rule for now.
"noExplicitAny": "off"
}
}
},
"organizeImports": {
"enabled": true
},
"vcs": {
"clientKind": "git",
"defaultBranch": "main",
"enabled": true
}
}
Binary file modified bun.lockb
Binary file not shown.
52 changes: 12 additions & 40 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,18 @@
"dev": "bun run build -- --watch",
"build": "tsup",
"test": "bun test",
"lint": "bun run lint:tsc && bun run lint:eslint --",
"lint:eslint": "eslint . --ext .ts --ignore-path .gitignore",
"lint:tsc": "tsc",
"lint": "bun run --bun lint:tsc && bun run --bun lint:biome",
"lint:biome": "biome check",
"lint:tsc": "tsc --pretty",
"prepare": "husky && bun run build",
"prettify": "prettier --write --ignore-unknown \"**/*.{css,js,json,jsx,ts,tsx}\""
"format": "biome format --write"
},
"files": [
"dist"
],
"files": ["dist"],
"repository": "ronin-co/client",
"homepage": "https://ronin.co/docs/typescript-client",
"keywords": [
"ronin",
"client",
"database",
"orm",
"edge",
"serverless"
],
"keywords": ["ronin", "client", "database", "orm", "edge", "serverless"],
"lint-staged": {
"**/*": [
"prettier --ignore-unknown --write",
"eslint --fix --ignore-path .gitignore"
]
"**/*": ["biome check"]
},
"exports": {
".": {
Expand All @@ -57,18 +45,10 @@
},
"typesVersions": {
"*": {
"*": [
"dist/index.d.ts"
],
"types": [
"dist/types/index.d.ts"
],
"schema": [
"dist/schema/index.d.ts"
],
"utils": [
"dist/utils/index.d.ts"
]
"*": ["dist/index.d.ts"],
"types": ["dist/types/index.d.ts"],
"schema": ["dist/schema/index.d.ts"],
"utils": ["dist/utils/index.d.ts"]
}
},
"engines": {
Expand All @@ -88,20 +68,12 @@
"typescript": "5.5.4"
},
"devDependencies": {
"@biomejs/biome": "1.9.1",
"@types/bun": "1.1.6",
"@types/ini": "4.1.1",
"@types/pluralize": "0.0.33",
"@typescript-eslint/eslint-plugin": "7.17.0",
"@typescript-eslint/parser": "7.17.0",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-simple-import-sort": "12.1.1",
"eslint-plugin-spellcheck": "0.0.20",
"eslint-plugin-unused-imports": "4.0.1",
"husky": "9.1.4",
"lint-staged": "15.2.7",
"prettier": "3.3.3",
"tsup": "8.2.3"
}
}
20 changes: 12 additions & 8 deletions src/bin/commands/init.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import childProcess from 'child_process';
import fs from 'fs/promises';
import childProcess from 'node:child_process';
import fs from 'node:fs/promises';
import path from 'node:path';
import util from 'node:util';
import json5 from 'json5';
import ora from 'ora';
import path from 'path';
import util from 'util';

import { exists } from '@/src/bin/utils/file';

const exec = util.promisify(childProcess.exec);

export default async (positionals: string[]) => {
export default async (positionals: Array<string>) => {
const spinner = ora('Initializing project').start();
const lastPositional = positionals[positionals.length - 1];
const spaceHandle = lastPositional === 'init' ? null : lastPositional;
Expand All @@ -20,7 +20,9 @@ export default async (positionals: string[]) => {
}

if (!(await exists('package.json'))) {
spinner.fail('No `package.json` found in the current directory. Please run the command in your project.');
spinner.fail(
'No `package.json` found in the current directory. Please run the command in your project.',
);
process.exit(1);
}

Expand Down Expand Up @@ -58,15 +60,17 @@ export default async (positionals: string[]) => {
const contents = await fs.readFile(tsConfigPath, 'utf-8');
const tsConfig = json5.parse(contents);

if (!tsConfig.compilerOptions.types || !tsConfig.compilerOptions.types.includes(`@ronin/${spaceHandle}`))
if (!tsConfig.compilerOptions.types?.includes(`@ronin/${spaceHandle}`))
Object.assign(tsConfig.compilerOptions, {
types: [...(tsConfig.compilerOptions.types || []), `@ronin/${spaceHandle}`],
});

await fs.writeFile(tsConfigPath, JSON.stringify(tsConfig, null, 2));
} catch (err) {
if (err instanceof Error && err.message.includes('401')) {
spinner.fail(`You are not a member of the "${spaceHandle}" space or the space doesn't exist.`);
spinner.fail(
`You are not a member of the "${spaceHandle}" space or the space doesn't exist.`,
);
process.exit(1);
}
}
Expand Down
12 changes: 8 additions & 4 deletions src/bin/commands/login.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import http from 'node:http';
import getPort from 'get-port';
import http from 'http';
import open from 'open';
import ora from 'ora';

import { storeSession, storeTokenForBun, storeTokenForNPM } from '@/src/bin/utils/session';
import {
storeSession,
storeTokenForBun,
storeTokenForNPM,
} from '@/src/bin/utils/session';

const logIn = async (appToken?: string, exit: boolean = true) => {
const logIn = async (appToken?: string, exit = true) => {
const spinner = ora('Logging in').start();

// If an app token is provided, we don't want to store a session for the CLI,
Expand Down Expand Up @@ -35,7 +39,7 @@ const logIn = async (appToken?: string, exit: boolean = true) => {
initURL.searchParams.set('from', currentHost);

spinner.text = `Please log in using the following URL:\n${initURL.href}`;
spinner.suffixText = `\n`;
spinner.suffixText = '\n';

try {
[sessionToken] = await Promise.all([
Expand Down
Loading

0 comments on commit 28c7415

Please sign in to comment.