From 051dbe93d9b365dd3f7c6a09fe4cc47c5b752fcf Mon Sep 17 00:00:00 2001 From: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com> Date: Sun, 3 Jan 2021 04:47:41 +0300 Subject: Adds EsLint Adds eslint, eslint rules, and updates the workflow file. Adds a yarn command to run linting. Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com> --- .eslintrc.json | 41 +++++++++++++++++++++++++++++++++++++ .github/workflows/test_and_lint.yml | 15 ++++++++++++-- .gitignore | 3 +++ package.json | 3 ++- 4 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 .eslintrc.json diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..4e55622 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,41 @@ +{ + "env": { + "browser": true, + "es2021": true + }, + "extends": [ + "eslint:recommended", + "plugin:react/recommended", + "plugin:@typescript-eslint/recommended" + ], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaFeatures": { + "jsx": true + }, + "ecmaVersion": 12, + "sourceType": "module" + }, + "plugins": [ + "react", + "@typescript-eslint" + ], + "rules": { + "indent": [ + "error", + 4 + ], + "linebreak-style": [ + "error", + "unix" + ], + "quotes": [ + "error", + "double" + ], + "semi": [ + "error", + "always" + ] + } +} diff --git a/.github/workflows/test_and_lint.yml b/.github/workflows/test_and_lint.yml index e7a0d05..636e181 100644 --- a/.github/workflows/test_and_lint.yml +++ b/.github/workflows/test_and_lint.yml @@ -32,5 +32,16 @@ jobs: - name: Run tests run: yarn test - - + + lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: EgorDm/gha-yarn-node-cache@v1 + + - name: Install dependencies + run: yarn install --dev + + - name: Lint + run: yarn run eslint --ext .ts,.tsx --quiet src/ diff --git a/.gitignore b/.gitignore index 8692cf6..3ac9558 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,9 @@ # testing /coverage +# linting +.eslintcache + # production /build diff --git a/package.json b/package.json index 059077c..641fe19 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ "scripts": { "start": "cross-env NODE_ENV=development webpack serve", "build": "cross-env REACT_APP_SHA=$COMMIT_REF REACT_APP_BRANCH=$BRANCH webpack", - "test": "cross-env jest" + "test": "cross-env jest", + "lint": "cross-env eslint --cache src/" }, "eslintConfig": { "extends": "react-app" -- cgit v1.2.3