From ae846d198d92bd902505861827d913958a3aa75a Mon Sep 17 00:00:00 2001 From: Jannis R Date: Sun, 3 Apr 2022 14:15:36 +0200 Subject: [PATCH] =?UTF-8?q?add=20linter=20=F0=9F=92=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.json | 17 +++++++++++++++++ .github/workflows/docker-image.yml | 1 + api.js | 4 ++-- package.json | 2 ++ 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 .eslintrc.json diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..1d44c69 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,17 @@ +{ + "extends": "eslint:recommended", + "env": { + "commonjs": true, + "es6": true, + "node": true + }, + "parserOptions": { + "ecmaVersion": 2018 + }, + "ignorePatterns": [ + "node_modules" + ], + "rules": { + "no-unused-vars": "off" + } +} diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index ae28707..39aa8b8 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -15,6 +15,7 @@ jobs: with: node-version: 16.x - run: npm install + - run: npm run lint - run: npm test build-and-publish: name: build & publish Docker image diff --git a/api.js b/api.js index 3dd138b..c9b2af9 100644 --- a/api.js +++ b/api.js @@ -64,8 +64,8 @@ const modifyRoutes = (routes, hafas, config) => { } const config = { - hostname: process.env.HOSTNAME || 'localhost', - port: process.env.PORT ? parseInt(process.env.PORT) : 3000, + hostname: process.env.HOSTNAME || 'localhost', + port: process.env.PORT ? parseInt(process.env.PORT) : 3000, name: pkg.name, description: pkg.description, homepage: pkg.homepage, diff --git a/package.json b/package.json index 153769b..227c025 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "devDependencies": { "@derhuerst/technical-docs-cli": "^1.1.0", "axios": "^0.26.1", + "eslint": "^8.12.0", "get-port": "^5.1.1", "pino-pretty": "^4.0.0", "tap-min": "^2.0.0", @@ -46,6 +47,7 @@ "docs": "node api-docs.js >docs/api.md && build-technical-doc --syntax-stylesheet-url /syntax.css docs/index.html && build-technical-doc --syntax-stylesheet-url /syntax.css docs/getting-started.html && build-technical-doc --syntax-stylesheet-url /syntax.css docs/api.html && build-technical-doc --syntax-stylesheet github >docs/syntax.css", "build": "npm run docs", "start": "node index.js", + "lint": "eslint .", "test": "node test.js | tap-min" } }