Skip to content

Commit 3e51c52

Browse files
committedMar 27, 2022
refactor: improve and simplify eslint configuration
Signed-off-by: Vitor Hugo Salgado <[email protected]>
1 parent f0857fd commit 3e51c52

File tree

7 files changed

+43
-26
lines changed

7 files changed

+43
-26
lines changed
 

‎.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
dist/
22
scripts/
33
cmd/
4+
tools/
45

56
*.d.ts

‎.eslintrc.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
module.exports = {
2+
root: true,
23
parser: '@typescript-eslint/parser',
34
plugins: ['@typescript-eslint/eslint-plugin', 'import', 'eslint-plugin-tsdoc'],
4-
extends: ['plugin:@typescript-eslint/recommended', 'prettier'],
5+
extends: ['plugin:@typescript-eslint/recommended'],
56
env: {
67
jest: true,
78
node: true
@@ -11,6 +12,8 @@ module.exports = {
1112
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
1213
'@typescript-eslint/no-dupe-class-members': ['error'],
1314
'@typescript-eslint/no-useless-constructor': ['error'],
14-
'@typescript-eslint/no-inferrable-types': ['off']
15+
'@typescript-eslint/no-inferrable-types': ['off'],
16+
17+
'import/extensions': ['error', 'ignorePackages', { js: 'always', jsx: 'never', ts: 'never', tsx: 'never' }]
1518
}
1619
}

‎Makefile

+16
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,22 @@ down: ## Stop Docker Compose development environment.
1414
clean: ## Clean Docker Compose development environment.
1515
@docker-compose -f ./deployments/dev/docker-compose.yml down --remove-orphans --volumes
1616

17+
.PHONY: test
18+
test:
19+
@npm test
20+
21+
fmt: # Format code
22+
@npm run format
23+
24+
lint: # Run static analysis
25+
@npm run lint
26+
27+
check: # Run all checks for this project
28+
@npm run format:check
29+
@npm run lint
30+
@npm run test
31+
@npm run build
32+
1733
nvm: ## Install Node.js version described on .nvmrc
1834
[ -s "$$HOME/.nvm/nvm.sh" ] && . "$$HOME/.nvm/nvm.sh" && \
1935
nvm install $$(cat .nvmrc) && \

‎package-lock.json

+16-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
"@typescript-eslint/eslint-plugin": "^5.16.0",
5959
"@typescript-eslint/parser": "^5.16.0",
6060
"eslint": "^8.12.0",
61-
"eslint-config-prettier": "^8.5.0",
6261
"eslint-plugin-import": "^2.25.4",
6362
"eslint-plugin-node": "^11.1.0",
6463
"eslint-plugin-tsdoc": "^0.2.14",

‎src/config.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const Config = {
2+
port: parseInt(process.env.PORT || '8080')
3+
}

‎src/index.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
import 'dotenv/config'
99
import { createServer, IncomingMessage, ServerResponse } from 'http'
10-
11-
const Port = parseInt(process.env.PORT || '8080')
10+
import { Config } from './config.js'
1211

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

1817
const server = createServer(requestListener)
1918

20-
server.listen(Port)
19+
server.listen(Config.port)

0 commit comments

Comments
 (0)