Skip to content

Commit

Permalink
refactor: improve and simplify eslint configuration
Browse files Browse the repository at this point in the history
Signed-off-by: Vitor Hugo Salgado <vsalgadopb@gmail.com>
  • Loading branch information
vitorsalgado committed Mar 27, 2022
1 parent f0857fd commit 3e51c52
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 26 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
dist/
scripts/
cmd/
tools/

*.d.ts
7 changes: 5 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint/eslint-plugin', 'import', 'eslint-plugin-tsdoc'],
extends: ['plugin:@typescript-eslint/recommended', 'prettier'],
extends: ['plugin:@typescript-eslint/recommended'],
env: {
jest: true,
node: true
Expand All @@ -11,6 +12,8 @@ module.exports = {
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'@typescript-eslint/no-dupe-class-members': ['error'],
'@typescript-eslint/no-useless-constructor': ['error'],
'@typescript-eslint/no-inferrable-types': ['off']
'@typescript-eslint/no-inferrable-types': ['off'],

'import/extensions': ['error', 'ignorePackages', { js: 'always', jsx: 'never', ts: 'never', tsx: 'never' }]
}
}
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@ down: ## Stop Docker Compose development environment.
clean: ## Clean Docker Compose development environment.
@docker-compose -f ./deployments/dev/docker-compose.yml down --remove-orphans --volumes

.PHONY: test
test:
@npm test

fmt: # Format code
@npm run format

lint: # Run static analysis
@npm run lint

check: # Run all checks for this project
@npm run format:check
@npm run lint
@npm run test
@npm run build

nvm: ## Install Node.js version described on .nvmrc
[ -s "$$HOME/.nvm/nvm.sh" ] && . "$$HOME/.nvm/nvm.sh" && \
nvm install $$(cat .nvmrc) && \
Expand Down
36 changes: 16 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
"@typescript-eslint/eslint-plugin": "^5.16.0",
"@typescript-eslint/parser": "^5.16.0",
"eslint": "^8.12.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-tsdoc": "^0.2.14",
Expand Down
3 changes: 3 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const Config = {
port: parseInt(process.env.PORT || '8080')
}
5 changes: 2 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

import 'dotenv/config'
import { createServer, IncomingMessage, ServerResponse } from 'http'

const Port = parseInt(process.env.PORT || '8080')
import { Config } from './config.js'

const requestListener = (request: IncomingMessage, response: ServerResponse) => {
response.writeHead(200)
Expand All @@ -17,4 +16,4 @@ const requestListener = (request: IncomingMessage, response: ServerResponse) =>

const server = createServer(requestListener)

server.listen(Port)
server.listen(Config.port)

0 comments on commit 3e51c52

Please sign in to comment.