Skip to content

Commit

Permalink
add/configure eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
elmarx committed May 18, 2024
1 parent 46d7d92 commit adeb384
Show file tree
Hide file tree
Showing 8 changed files with 2,177 additions and 94 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
- name: test if all files have been formatted with prettier
run: npx prettier -c src/**/*.ts

- name: linting/static code analysis
run: npx eslint src

- name: run tests
run: npx jest

Expand Down
1 change: 1 addition & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ci:
npm ci
npm run tsc
npm run prettier
npm run eslint
# currently no tests…
npm run test

Expand Down
45 changes: 45 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const eslint = require("@eslint/js");
const tseslint = require("typescript-eslint");
const eslintConfigPrettier = require("eslint-config-prettier");

module.exports = tseslint.config(
{
ignores: ["eslint.config.js"],
},
eslint.configs.recommended,
eslintConfigPrettier,
...tseslint.configs.recommendedTypeChecked,
{
languageOptions: {
parserOptions: {
project: true,
tsconfigRootDir: __dirname,
},
},
rules: {
// emulate TS behaviour (if noUnusedLocals and noUnusedParameters are enabled): https://typescript-eslint.io/rules/no-unused-vars/#benefits-over-typescript
"@typescript-eslint/no-unused-vars": [
"error",
{
args: "all",
argsIgnorePattern: "^_",
caughtErrors: "all",
caughtErrorsIgnorePattern: "^_",
destructuredArrayIgnorePattern: "^_",
varsIgnorePattern: "^_",
ignoreRestSiblings: true,
},
],
// to use promises in express (and catch rejecting promises!) we use express-promise-router, it allows promises,
// but does not define the type correctly: https://github.com/express-promise-router/express-promise-router/issues/230
"@typescript-eslint/no-misused-promises": [
"error",
{
checksVoidReturn: {
arguments: false,
},
},
],
},
},
);
Loading

0 comments on commit adeb384

Please sign in to comment.