Skip to content

Commit

Permalink
Merge pull request #5 from IT4Change/eslint-typescript-strict
Browse files Browse the repository at this point in the history
fix(backend): eslint typescript strict
  • Loading branch information
ulfgebhardt authored Dec 12, 2023
2 parents c91e996 + 70711fa commit 73f4ab6
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
build/
coverage/
.vuepress/
22 changes: 22 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,28 @@
"promise/no-multiple-resolved": "error"
},
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"tsconfigRootDir": ".",
"project": ["./tsconfig.json", "**/tsconfig.json"],
"ecmaVersion": "latest",
"parser": "@typescript-eslint/parser",
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:@typescript-eslint/strict"
],
"rules": {
// allow explicitly defined dangling promises
"@typescript-eslint/no-floating-promises": ["error", { "ignoreVoid": true }],
"no-void": ["error", { "allowAsStatement": true }]
}
},
{
"files": ["!*.json"],
"plugins": ["prettier"],
Expand Down
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,31 @@ The following endpoints are provided given the right command is executed or all
| [http://localhost:4000/graphql](http://localhost:4000/graphql) | GraphQL API |
| [http://localhost:4000/playground](http://localhost:4000/playground) | GraphQL Playground |

## How to use as part of a project

If you want to use this as part of a larger project, e.g. in conjunction with a frontend also utilizing a boilerplate you cannot use the template mechanic provided by github for this repository.

You can use the following commands to include the whole git history of the boilerplate and be able to update according to changes to this repo using another remote.

```bash
git remote add xxx_boilerplate_backend [email protected]:IT4Change/boilerplate-backend.git
git fetch xxx_boilerplate_backend
git merge -s ours --no-commit --allow-unrelated-histories xxx_boilerplate_backend/master
git read-tree --prefix=xxx/ -u xxx_boilerplate_backend/master
git commit -m "Imported boilerplate_backend as a subtree under xxx/."
```

To update the subtree you can use

```bash
git subtree pull -P xxx/ xxx_boilerplate_backend master
git commit -m "Updated boilerplate_backend in subtree under xxx/."
```

Where `xxx` refers to the folder and product part you want to use the boilerplate in. This assumes that you might need several copies of the frontend boilerplate for you product.

This mechanic was taken from this [source](https://stackoverflow.com/questions/1683531/how-to-import-existing-git-repository-into-another/8396318#8396318)

## Database setup

The project is set up for a `sqlite` database.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"db:reset": "TZ=UTC npx prisma migrate reset --force",
"db:seed": "TZ=UTC npx prisma db seed",
"test:lint": "npm run test:lint:eslint && npm run test:lint:remark",
"test:lint:eslint": "eslint --ext .ts,.tsx,.js,.jsx,.json,.yml,.yaml --max-warnings 0 --ignore-path .gitignore .",
"test:lint:eslint": "eslint --ext .ts,.tsx,.js,.jsx,.json,.yml,.yaml --max-warnings 0 .",
"test:lint:remark": "remark . --quiet --frail",
"test:unit": "TZ=UTC jest --runInBand --forceExit --detectOpenHandles",
"test": "npm run test:lint && npm run test:unit",
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ main()
console.error(e)
throw e
})
.finally(async () => {
await prisma.$disconnect()
.finally(() => {
void prisma.$disconnect()
})
4 changes: 3 additions & 1 deletion src/server/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { startStandaloneServer } from '@apollo/server/standalone'
import { listen } from './server'

jest.mock('@apollo/server/standalone', () => {
const originalModule = jest.requireActual('@apollo/server/standalone')
const originalModule = jest.requireActual<typeof import('@apollo/server/standalone')>(
'@apollo/server/standalone',
)
return {
__esModule: true,
...originalModule,
Expand Down
2 changes: 1 addition & 1 deletion test/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export const deleteAll = async () => {
}

export const disconnect = async () => {
prisma.$disconnect()
await prisma.$disconnect()
}

0 comments on commit 73f4ab6

Please sign in to comment.