Skip to content

Commit

Permalink
Shared Linters (#288)
Browse files Browse the repository at this point in the history
* feat: update to node 20 lts

* feat: add shared linters

* fix: rollback changes in docs due refactor

* fix: fix running tests on api

* fix: fix issue with starting api in dev mode

* feat: add ts-node config for tsconfig file

* fix: fix issue with importting

* feat: add .gitignore to eslint-config-custom package

* feat: update pnpm lock file to use ts

* feat: update to node v20 in web dockerfile

* fix: remove code for testing
  • Loading branch information
fruneen authored Mar 27, 2024
1 parent ce5b07e commit eb4c503
Show file tree
Hide file tree
Showing 200 changed files with 4,422 additions and 5,421 deletions.
5 changes: 0 additions & 5 deletions .vscode/settings.json

This file was deleted.

29 changes: 27 additions & 2 deletions template/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,27 @@
node_modules
*/**/node_modules
# dependencies
/node_modules

# testing
/coverage

# production
/dist

# edtiors
.idea
.vscode

# misc
.DS_Store
.dev
.turbo
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# typescript
*.tsbuildinfo
28 changes: 24 additions & 4 deletions template/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
# dependencies
/node_modules

# testing
/coverage

# production
/dist

# edtiors
.idea
.turbo
.vscode

# misc
.DS_Store
.dev
/node_modules
dist
coverage
.turbo
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# typescript
*.tsbuildinfo
5 changes: 0 additions & 5 deletions template/.vscode/settings.json

This file was deleted.

24 changes: 23 additions & 1 deletion template/apps/api/.dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
node_modules
# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/dist

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# typescript
*.tsbuildinfo
25 changes: 23 additions & 2 deletions template/apps/api/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
node_modules/*
jest.config.ts
# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/dist

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# typescript
*.tsbuildinfo
60 changes: 2 additions & 58 deletions template/apps/api/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,5 @@
const { resolve } = require("path");

module.exports = {
root: true,
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint", "import", "tsc"],
extends: [
"airbnb-typescript/base",
"plugin:@typescript-eslint/recommended",
],
env: {
node: true,
},
parserOptions: {
ecmaVersion: 13,
sourceType: "module",
project: "./tsconfig.json",
// use tsconfig relative to eslintrc file for IDE
tsconfigRootDir: __dirname,
},
rules: {
'tsc/config': [2, {
configFile: resolve(__dirname, './tsconfig.json')
}],
'arrow-body-style': 0,
'no-underscore-dangle': 0,
'function-paren-newline': 1,
'import/no-extraneous-dependencies': ['error', {
devDependencies: [
'**/*.spec.{js,ts}',
'**/*.builder.{js,ts}',
],
}],
'max-len': ['warn', {
code: 120,
ignoreStrings: true,
ignoreUrls: true,
ignoreTemplateLiterals: true,
}],
},
settings: {
"import/resolver": {
"node": {
"moduleDirectory": [
"src",
"node_modules"
]
}
}
},
ignorePatterns: [
// ignore this file
".eslintrc.js",
// never lint node modules
"node_modules",
// ignore prod_node_modules copied in Docker
"prod_node_modules",
// ignore output build files
"dist"
],
extends: ['custom/node'],
ignorePatterns: ['jest.config.js'],
};
28 changes: 23 additions & 5 deletions template/apps/api/.gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
node_modules
# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/dist

# misc
.DS_Store
npm-debug.log
.idea
.vscode
./dist
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
.env
.env.*
!.env.example

# typescript
*.tsbuildinfo
23 changes: 23 additions & 0 deletions template/apps/api/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/dist

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# typescript
*.tsbuildinfo
1 change: 1 addition & 0 deletions template/apps/api/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"prettier-config-custom"
6 changes: 3 additions & 3 deletions template/apps/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# BUILDER - Stage 1
FROM node:18-alpine AS builder
FROM node:20-alpine AS builder
WORKDIR /app
# Check /~https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk update && apk add --no-cache libc6-compat
Expand All @@ -8,7 +8,7 @@ COPY . .
RUN turbo prune --scope=api --docker

# INSTALLER - Stage 2
FROM node:18-alpine AS installer
FROM node:20-alpine AS installer
WORKDIR /app
# Check /~https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk update && apk add --no-cache libc6-compat
Expand All @@ -29,7 +29,7 @@ FROM installer AS development
CMD pnpm turbo run dev --scope=api

# RUNNER - Stage 4
FROM node:18-alpine AS runner
FROM node:20-alpine AS runner
WORKDIR /app
# Check /~https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk update && apk add --no-cache libc6-compat
Expand Down
6 changes: 3 additions & 3 deletions template/apps/api/Dockerfile.migrator
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# BUILDER - Stage 1
FROM node:18-alpine AS builder
FROM node:20-alpine AS builder
WORKDIR /app
# Check /~https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk update && apk add --no-cache libc6-compat
Expand All @@ -8,7 +8,7 @@ COPY . .
RUN turbo prune --scope=api --docker

# INSTALLER - Stage 2
FROM node:18-alpine AS installer
FROM node:20-alpine AS installer
WORKDIR /app
# Check /~https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk update && apk add --no-cache libc6-compat
Expand All @@ -29,7 +29,7 @@ FROM installer AS development
CMD pnpm turbo run api#migrate-dev --scope=api

# RUNNER - Stage 4
FROM node:18-alpine AS runner
FROM node:20-alpine AS runner
WORKDIR /app
# Check /~https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk update && apk add --no-cache libc6-compat
Expand Down
6 changes: 3 additions & 3 deletions template/apps/api/Dockerfile.scheduler
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# BUILDER - Stage 1
FROM node:18-alpine AS builder
FROM node:20-alpine AS builder
WORKDIR /app
# Check /~https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk update && apk add --no-cache libc6-compat
Expand All @@ -8,7 +8,7 @@ COPY . .
RUN turbo prune --scope=api --docker

# INSTALLER - Stage 2
FROM node:18-alpine AS installer
FROM node:20-alpine AS installer
WORKDIR /app
# Check /~https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk update && apk add --no-cache libc6-compat
Expand All @@ -29,7 +29,7 @@ FROM installer AS development
CMD pnpm turbo run dev --scope=api

# RUNNER - Stage 4
FROM node:18-alpine AS runner
FROM node:20-alpine AS runner
WORKDIR /app
# Check /~https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk update && apk add --no-cache libc6-compat
Expand Down
14 changes: 6 additions & 8 deletions template/apps/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@ docker-compose up --build

To start the project not in the docker container just run: `npm run dev`. This command will start the application on port `3001` and will automatically restart whenever you change any file in `./src` directory.


### Important notes

You need to set ```APP_ENV``` variable in build args in a place where you deploy application. It is responsible for the config file from ```environment``` folder that will be taken when building your application

You need to set `APP_ENV` variable in build args in a place where you deploy application. It is responsible for the config file from `environment` folder that will be taken when building your application

| APP_ENV | File |
| ------------- | ------------- |
| development | development.json |
| staging | staging.json |
| production | production.json |
| APP_ENV | File |
| ----------- | ---------------- |
| development | development.json |
| staging | staging.json |
| production | production.json |
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import type { JestConfigWithTsJest } from 'ts-jest';

const config: JestConfigWithTsJest = {
/** @type {import('jest').Config} */
const config = {
preset: '@shelf/jest-mongodb',
verbose: true,
testEnvironment: 'node',
testMatch: [
'**/?(*.)+(spec.ts)',
],
testMatch: ['**/?(*.)+(spec.ts)'],
transform: {
'^.+\\.(ts)$': 'ts-jest',
},
Expand All @@ -17,4 +14,4 @@ const config: JestConfigWithTsJest = {
testTimeout: 10000,
};

export default config;
module.exports = config;
Loading

0 comments on commit eb4c503

Please sign in to comment.