Skip to content

Commit

Permalink
Migrate from ESLint & Prettier to BiomeJs
Browse files Browse the repository at this point in the history
  • Loading branch information
yeoffrey committed Jul 26, 2024
1 parent 0fe23dd commit 0600fa9
Show file tree
Hide file tree
Showing 253 changed files with 4,165 additions and 4,236 deletions.
88 changes: 0 additions & 88 deletions .eslintrc

This file was deleted.

2 changes: 0 additions & 2 deletions .prettierignore

This file was deleted.

5 changes: 0 additions & 5 deletions .prettierrc

This file was deleted.

24 changes: 24 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"files": {
"include": ["src/**/*.ts", "test/**/*.ts"]
},
"formatter": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"suspicious": {
"noExplicitAny": "off"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"indentWidth": 2
}
}
}
17 changes: 7 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,28 @@
"node": ">=14.0.0"
},
"devDependencies": {
"@biomejs/biome": "1.8.3",
"@rollup/plugin-typescript": "^11.1.6",
"@types/expect": "^24.3.0",
"@types/lodash": "^4.14.144",
"@types/node": "^18.7.14",
"@typescript-eslint/eslint-plugin": "^7.1.1",
"@typescript-eslint/parser": "^7.1.1",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"lodash": "^4.17.15",
"np": "^10.0.0",
"prettier": "^3.2.5",
"rollup": "^4.12.1",
"typescript": "^4.8.3",
"vitest": "^1.6.0"
},
"scripts": {
"build": "rm -rf ./{dist} && rollup --config ./rollup.config.js",
"clean": "rm -rf ./{dist,node_modules}",
"fix": "npm run fix:eslint && npm run fix:prettier",
"fix:eslint": "npm run lint:eslint --fix",
"fix:prettier": "prettier '**/*.{js,json,ts}' --write",
"lint": "npm run lint:eslint && npm run lint:prettier",
"lint:eslint": "eslint '{src,test}/*.{js,ts}'",
"lint:prettier": "prettier '**/*.{js,json,ts}' --check",
"fix": "npx @biomejs/biome check --write .",
"fix:lint": "npx @biomejs/biome lint --write .",
"fix:format": "npx @biomejs/biome format --write .",
"lint": "npx @biomejs/biome check .",
"lint:lint": "npx @biomejs/biome lint .",
"lint:format": "npx @biomejs/biome format .",
"release": "npm run build && npm run lint && np",
"test": "npm run build && npm run test:types && npm run test:vitest",
"test:types": "tsc --noEmit && tsc --project ./test/tsconfig.json --noEmit",
Expand Down
62 changes: 31 additions & 31 deletions src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
*/

export type Failure = {
value: any
key: any
type: string
refinement: string | undefined
message: string
explanation?: string
branch: Array<any>
path: Array<any>
}
value: any;
key: any;
type: string;
refinement: string | undefined;
message: string;
explanation?: string;
branch: Array<any>;
path: Array<any>;
};

/**
* `StructError` objects are thrown (or returned) when validation fails.
Expand All @@ -23,27 +23,27 @@ export type Failure = {
*/

export class StructError extends TypeError {
value: any
key!: any
type!: string
refinement!: string | undefined
path!: Array<any>
branch!: Array<any>
failures: () => Array<Failure>;
[x: string]: any
value: any;
key!: any;
type!: string;
refinement!: string | undefined;
path!: Array<any>;
branch!: Array<any>;
failures: () => Array<Failure>;
[x: string]: any;

constructor(failure: Failure, failures: () => Generator<Failure>) {
let cached: Array<Failure> | undefined
const { message, explanation, ...rest } = failure
const { path } = failure
const msg =
path.length === 0 ? message : `At path: ${path.join('.')} -- ${message}`
super(explanation ?? msg)
if (explanation != null) this.cause = msg
Object.assign(this, rest)
this.name = this.constructor.name
this.failures = () => {
return (cached ??= [failure, ...failures()])
}
}
constructor(failure: Failure, failures: () => Generator<Failure>) {
let cached: Array<Failure> | undefined;
const { message, explanation, ...rest } = failure;
const { path } = failure;
const msg =
path.length === 0 ? message : `At path: ${path.join('.')} -- ${message}`;
super(explanation ?? msg);
if (explanation != null) this.cause = msg;
Object.assign(this, rest);
this.name = this.constructor.name;
this.failures = () => {
return (cached ??= [failure, ...failures()]);
};
}
}
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export * from './error.js'
export * from './struct.js'
export * from './structs/coercions.js'
export * from './structs/refinements.js'
export * from './structs/types.js'
export * from './structs/utilities.js'
export * from './error.js';
export * from './struct.js';
export * from './structs/coercions.js';
export * from './structs/refinements.js';
export * from './structs/types.js';
export * from './structs/utilities.js';
Loading

0 comments on commit 0600fa9

Please sign in to comment.