Skip to content

Commit

Permalink
feat: biome & node test runner
Browse files Browse the repository at this point in the history
  • Loading branch information
PoProstuWitold committed Jul 22, 2024
1 parent a678bfb commit 1233667
Show file tree
Hide file tree
Showing 13 changed files with 753 additions and 4,896 deletions.
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

23 changes: 0 additions & 23 deletions .eslintrc.json

This file was deleted.

13 changes: 0 additions & 13 deletions .prettierrc

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 PoProstuWitold
Copyright (c) 2022-2024 PoProstuWitold

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

Basic template for robust development of TypeScript apps with:

- [pNpm](https://pnpm.io/) - Fast, disk space efficient package manager
- [TypeScript](https://www.typescriptlang.org/) - JavaScript with syntax for types
- [ESM Modules](https://nodejs.org/api/esm.html)
- [Jest](https://jestjs.io/) - delightful JavaScript Testing
- [GitHub Actions](https://github.com/features/actions) - automated workflows
- [Prettier](https://prettier.io/) - opinionated code formatter
- [Eslint](https://eslint.org/) - Find and fix problems in your code
- Common scripts (eg. build, test, etc.)
- [Node.js] - Latest LTS version of Node. Currently it's **LTS/Iron** (v20).
- [pnpm](https://pnpm.io/) - Fast, disk space efficient package manager.
- [TypeScript](https://www.typescriptlang.org/) - JavaScript with syntax for types.
- [ESM Modules](https://nodejs.org/api/esm.html) - modern JavaScript modules.
- [Built-in Node Test Runner](https://nodejs.org/api/test.html) - native Node.js API for running tests.
- [Biome](https://github.com/biomejs/biome) - toolchain for linting and formatting with ``biome.json`` config file.
- [GitHub Actions](https://github.com/features/actions) - automated workflows.

## Available Scripts

- `start`
- `start:watch`
- `clean`
- `lint`
- `prettier`
- `format`
- `check` (combined `lint` and `format`)
- `prebuild`
- `build`
- `build:watch`
Expand Down
7 changes: 5 additions & 2 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import { describe, it } from 'node:test'
import { strictEqual } from 'node:assert'

import { getPetByKind, myPets } from '../src/main'
import { PetKind } from '../src/types'

describe('Pets Functions', () => {
describe('When providing', () => {
describe('dog kind', () => {
it('should return array of length 2', async () => {
expect(getPetByKind(PetKind.Dog, myPets)).toHaveLength(2)
strictEqual(getPetByKind(PetKind.Dog, myPets).length, 2)
})
})
describe('cat kind', () => {
it('should return array of length 1', async () => {
expect(getPetByKind(PetKind.Cat, myPets)).toHaveLength(1)
strictEqual(getPetByKind(PetKind.Cat, myPets).length, 1)
})
})
})
Expand Down
41 changes: 41 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"formatter": {
"enabled": true,
"formatWithErrors": false,
"ignore": [],
"attributePosition": "auto",
"indentStyle": "tab",
"indentWidth": 4,
"lineWidth": 80,
"lineEnding": "lf"
},
"javascript": {
"formatter": {
"arrowParentheses": "always",
"bracketSameLine": false,
"bracketSpacing": true,
"jsxQuoteStyle": "single",
"quoteProperties": "asNeeded",
"semicolons": "asNeeded",
"trailingCommas": "none",
"quoteStyle": "single"
}
},
"json": {
"formatter": {
"trailingCommas": "none",
"indentWidth": 4,
"indentStyle": "tab"
}
}
}
10 changes: 0 additions & 10 deletions jest.config.ts

This file was deleted.

44 changes: 17 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
{
"name": "node-ts-boilerplate",
"version": "1.0.0",
"version": "2.0.0",
"author": "PoProstuWitold",
"description": "Basic template for robust development of TypeScript apps",
"main": "build/src/main.js",
"homepage": "https://github.com/PoProstuWitold/node-ts-template",
"engines": {
"node": ">=20.x"
"node": ">=20.x",
"pnpm": ">=9.x"
},
"packageManager": "^pnpm@8.3.0",
"scripts": {
"start": "node build/src/main.js",
"start:watch": "NODE_ENV='development' nodemon --exec ts-node src/main.ts",
"start:watch": "NODE_ENV='development' node --watch --import tsx src/main.ts",
"clean": "rimraf coverage build tmp",
"lint": "eslint . --ext .ts",
"prettier": "prettier --config .prettierrc --write .",
"prebuild": "npm run lint",
"lint": "pnpm biome lint --write ./src",
"format": "pnpm biome format --write ./src",
"check": "pnpm biome check --write ./src",
"prebuild": "pnpm run check",
"build": "tsc -p tsconfig.json",
"build:watch": "tsc -w -p tsconfig.json",
"build:release": "npm run clean && tsc -p tsconfig.release.json",
"test": "jest",
"test:watch": "jest --watch"
"build:watch": "NODE_ENV='development' tsc -w -p tsconfig.json",
"build:release": "pnpm run clean && tsc -p tsconfig.release.json",
"test": "node --import tsx --test __tests__/*.test.ts",
"test:watch": "NODE_ENV='development' node --watch --import tsx --test __tests__/*.test.ts"
},
"keywords": [
"TypeScript",
Expand All @@ -30,21 +31,10 @@
],
"license": "MIT",
"devDependencies": {
"@types/jest": "^29.5.12",
"@types/node": "^20.11.20",
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.0.2",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jest": "^27.9.0",
"jest": "^29.7.0",
"nodemon": "^3.1.0",
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"ts-node-dev": "^2.0.0",
"tsutils": "^3.21.0",
"typescript": "^5.3.3"
"@biomejs/biome": "^1.8.3",
"@types/node": "^20.14.11",
"rimraf": "^6.0.1",
"tsx": "^4.16.2",
"typescript": "^5.5.3"
}
}
Loading

0 comments on commit 1233667

Please sign in to comment.