From b65d0982f7c6b8b84ebfe8e336bf38f9cc21a60a Mon Sep 17 00:00:00 2001 From: Arafat Zahan Date: Mon, 14 Oct 2024 21:13:47 +0600 Subject: [PATCH 1/2] Add script for linting. --- .eslintrc.js | 5 ----- .nvmrc | 1 + package.json | 5 +++-- src/types/react-native-globals.d.ts | 2 +- 4 files changed, 5 insertions(+), 8 deletions(-) create mode 100644 .nvmrc diff --git a/.eslintrc.js b/.eslintrc.js index e654650..d2b91fc 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,9 +1,4 @@ module.exports = { root: true, extends: 'react-app', - rules: { - 'prettier/prettier': 0, - '@typescript-eslint/no-unused-vars': 0, - 'no-trailing-spaces': 0, - }, }; diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..8fdd954 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +22 \ No newline at end of file diff --git a/package.json b/package.json index 28271e6..8e29c13 100644 --- a/package.json +++ b/package.json @@ -35,8 +35,9 @@ } }, "scripts": { - "test": "vitest", - "prepare": "rm -rf ./dist/* && tsc -p tsconfig.build.json" + "lint": "eslint . --ext .ts,.tsx", + "prepare": "rm -rf ./dist/* && tsc -p tsconfig.build.json", + "test": "vitest" }, "devDependencies": { "@babel/plugin-proposal-private-property-in-object": "7.21.11", diff --git a/src/types/react-native-globals.d.ts b/src/types/react-native-globals.d.ts index 02dd7f1..b867229 100644 --- a/src/types/react-native-globals.d.ts +++ b/src/types/react-native-globals.d.ts @@ -1 +1 @@ -const __DEV__: boolean; +declare const __DEV__: boolean; From 3103bcba73980b680ac9ad699be113e569d12123 Mon Sep 17 00:00:00 2001 From: Arafat Zahan Date: Mon, 14 Oct 2024 21:39:37 +0600 Subject: [PATCH 2/2] Add github workflow for lint, type chdck and tests. --- .github/workflows/lint.yml | 49 ++++++++++++++++++++++++++++++++++++++ package.json | 3 ++- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..adb9cf4 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,49 @@ +name: Code Linting, Type Checking and Tests + +on: + push: + branches: + - develop + paths: + - '.github/workflows/lint.yml' + - '**.js' + - '**.json' + - '**.ts' + - '**.tsx' + pull_request: + branches: + - develop + paths: + - '.github/workflows/lint.yml' + - '**.js' + - '**.json' + - '**.ts' + - '**.tsx' + types: + - opened + - reopened + - synchronize + +concurrency: + group: lint-${{ github.ref }} + cancel-in-progress: true + +jobs: + lint: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Node + uses: actions/setup-node@v3 + with: + cache: 'yarn' + - name: Install dependencies + run: yarn + - name: Run ESLint + run: yarn lint + - name: Run TypeScript Compiler (TSC) + run: yarn type-check + - name: Run Tests + run: yarn test diff --git a/package.json b/package.json index 8e29c13..d5109c4 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "scripts": { "lint": "eslint . --ext .ts,.tsx", "prepare": "rm -rf ./dist/* && tsc -p tsconfig.build.json", - "test": "vitest" + "test": "vitest", + "type-check": "tsc" }, "devDependencies": { "@babel/plugin-proposal-private-property-in-object": "7.21.11",