Skip to content

Commit

Permalink
Merge pull request #9 from atlp-rwanda/feat-eslint-precommit-hook-187…
Browse files Browse the repository at this point in the history
…419039

#187454781 Configure eslint and git pre-commit
  • Loading branch information
leandreAlly authored Apr 22, 2024
2 parents 8c57472 + 74adf58 commit 22a9f66
Show file tree
Hide file tree
Showing 36 changed files with 11,539 additions and 8,216 deletions.
102 changes: 51 additions & 51 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
# This workflow will install node dependencies, run tests and report coverage
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: build

on:
push:
branches:
- feat-test-CI-implementation-187419042
- "*"
- develop

pull_request:
branches:
- develop

jobs:
test:
runs-on: ubuntu-latest

env:
DB_TEST_URL: ${{ secrets.DB_TEST_URL }}
DEV_MODE: ${{ secrets.DEV_MODE }}
DB_HOSTED_MODE: ${{ secrets.DB_HOSTED_MODE }}

strategy:
matrix:
node-version: ["20.x"]

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- name: Install dependencies
run: npm install

- name: Run tests and build test coverage
run: npm run test:ci

- name: Test & publish code climate coverage
uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageCommand: npm run test:ci
debug: true
coverageLocations: |
${{github.workspace}}/*.lcov:lcov
# This workflow will install node dependencies, run tests and report coverage
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: build

on:
push:
branches:
- feat-test-CI-implementation-187419042
- "*"
- develop

pull_request:
branches:
- develop

jobs:
test:
runs-on: ubuntu-latest

env:
DB_TEST_URL: ${{ secrets.DB_TEST_URL }}
DEV_MODE: ${{ secrets.DEV_MODE }}
DB_HOSTED_MODE: ${{ secrets.DB_HOSTED_MODE }}

strategy:
matrix:
node-version: ["20.x"]

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- name: Install dependencies
run: npm install

- name: Run tests and build test coverage
run: npm run test:ci

- name: Test & publish code climate coverage
uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageCommand: npm run test:ci
debug: true
coverageLocations: |
${{github.workspace}}/*.lcov:lcov
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run precommit
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"semi": true,
"tabWidth": 2,
"useTabs": true
}
8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"pkief.material-icon-theme",
"ritwickdey.liveserver"
]
}
51 changes: 51 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const eslint = require("@eslint/js");
const tseslint = require("typescript-eslint");

module.exports = tseslint.config(
{
ignores: ["**/__test__", "**/*.json"],
},
eslint.configs.recommended,
...tseslint.configs.recommended,
{
languageOptions: {
parserOptions: {
project: true,
ecmaVersion: 2020,
},
},
},
{
files: ["*.ts", "*.js"],
...tseslint.configs.disableTypeChecked,
},
{
files: ["*.test *.js"],
rules: {
"@typescript-eslint/no-unused-vars": 0,
"@typescript-eslint/no-unsafe-call": 0,
languageOptions: {
globals: {
it: "readonly",
describe: "readonly",
},
},
},
},
{
rules: {
semi: "error",
"@typescript-eslint/no-unused-vars": 2,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-var-requires": 0,
"no-shadow": [2, { allow: ["req", "res", "err"] }],
"new-cap": 0,
"one-var-declaration-per-line": 0,
"consistent-return": 0,
"no-param-reassign": 0,
"comma-dangle": 0,
"no-undef": 0,
curly: ["error", "multi-line"],
},
},
);
4 changes: 2 additions & 2 deletions jest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import dotenv from "dotenv";
dotenv.config();
import dotenv from "dotenv";
dotenv.config();
Loading

0 comments on commit 22a9f66

Please sign in to comment.