Skip to content

Commit

Permalink
refactor: updates boilerplate
Browse files Browse the repository at this point in the history
  changes env variable
  removes .eslintignore and updates .eslintrc.cjs
  removes eslint-config-standard-with-typescript, eslint-plugin-import, eslint-plugin-n and eslint-plugin-promise
  removes nodemon and changes ts-node to ts-node-dev
  updates lintstaged scripts
  adds nvmrc
  updates jest config
  adds jest setup file
  updates versions of dependencies, updates scripts and adds new meta tags to package.json
  updates tsconfig.json
  updates ci.yml (adds cache, updates versions and adds new steps)
  updates husky pre-commit
  adds new vscode settings
  fixes base path in alias-config
  moves sum.test.ts to tests folder
  • Loading branch information
diasjoaovitor committed Sep 10, 2024
1 parent 38f974d commit 1603eae
Show file tree
Hide file tree
Showing 17 changed files with 2,074 additions and 4,687 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1 @@
PORT=
MY_SECRET_KEY=
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

14 changes: 2 additions & 12 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,8 @@ module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'standard-with-typescript',
'prettier'
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
rules: {
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/strict-boolean-expressions': 'off',
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'@typescript-eslint/no-unsafe-argument': 'off'
}
ignorePatterns: ['dist', '.eslintrc.cjs', 'node_modules'],
parser: '@typescript-eslint/parser'
}
24 changes: 18 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,39 @@
name: ci
on: [pull_request]

on: [pull_request, push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 'lts/iron'
cache: 'npm'

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ runner.tool_cache }}/npm
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm i
run: npm ci

- name: Linting
run: npm run lint

- name: Testing
run: npm run test:ci
run: npm run test

- name: Clean build folder
run: rm -rf dist

- name: Build
run: npm run build
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no-install lint-staged
17 changes: 12 additions & 5 deletions .lintstagedrc.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
module.exports = {
'*.{js,ts}': filenames => [
`npx prettier --write ${filenames.join(' ')} --writeclear`,
`npx eslint --fix --ext .ts .`,
`npm run test -- --findRelatedTests ${filenames.join(' ')} --passWithNoTests`
const path = require('path')

const buildCommand = (filenames) => {
const files = filenames.map((f) => path.relative(process.cwd(), f))
return [
`npx prettier --write ${files.join(' --file ')}`,
`npx eslint --fix ${files.join(' ')} --report-unused-disable-directives --max-warnings 0`,
`npx jest --runInBand --findRelatedTests ${filenames.join(' ')} --passWithNoTests`
]
}

module.exports = {
'*.{js,ts}': [buildCommand]
}
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/iron
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"editor.formatOnSave": true
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"files.autoSave": "off",
"git.autofetch": true,
"typescript.tsdk": "node_modules/typescript/lib"
}
Loading

0 comments on commit 1603eae

Please sign in to comment.