Skip to content

Commit

Permalink
chore(*): add linter
Browse files Browse the repository at this point in the history
  • Loading branch information
garrappachc committed Dec 28, 2023
1 parent dc0e361 commit df630fb
Show file tree
Hide file tree
Showing 11 changed files with 1,025 additions and 25 deletions.
32 changes: 32 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module.exports = {
root: true,
plugins: ['@typescript-eslint'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended-type-checked',
'plugin:@typescript-eslint/stylistic-type-checked',
'plugin:prettier/recommended',
],
env: {
node: true,
},
parser: '@typescript-eslint/parser',
parserOptions: {
project: true,
tsconfigRootDir: __dirname,
},
ignorePatterns: ['dist'],
overrides: [
{
files: ['./**/*.test.ts'],
rules: {
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/unbound-method': 'off',
},
},
{
files: ['./**/*.cjs'],
extends: ['plugin:@typescript-eslint/disable-type-checked'],
},
],
};
38 changes: 38 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: lint

on:
push:
branches:
- 'master'
- '*.*.*'
- 'renovate/**'
tags:
- '*.*.*'
pull_request:
branches:
- 'master'
merge_group:

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- name: Setup Node.js
uses: actions/setup-node@v4
with:
cache: pnpm

- name: Install dependencies
run: pnpm install

- name: Lint
run: pnpm lint
2 changes: 1 addition & 1 deletion examples/create-reservation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ const reserveServer = async () => {
console.log(`reservation created: ${reservation.id}`);
};

reserveServer();
reserveServer().catch(error => console.error(error));
2 changes: 1 addition & 1 deletion examples/fetch-reservation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ if (!reservationId) {
throw new Error('no reservation id provided');
}

fetchReservation(reservationId);
fetchReservation(reservationId).catch(error => console.error(error));
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"types": "dist/src/index.d.ts",
"scripts": {
"build": "tsc --project tsconfig.build.json",
"test": "vitest"
"test": "vitest",
"format": "prettier --write .",
"lint": "eslint ."
},
"keywords": [
"serveme",
Expand All @@ -19,6 +21,10 @@
"license": "MIT",
"devDependencies": {
"@types/node": "^20.10.5",
"@typescript-eslint/eslint-plugin": "^6.16.0",
"@typescript-eslint/parser": "^6.16.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.2",
"prettier": "^3.1.1",
"typescript": "^5.3.3",
"vitest": "^1.1.0"
Expand Down
Loading

0 comments on commit df630fb

Please sign in to comment.