diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..9b1577f --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,33 @@ +{ + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": 12, + "sourceType": "module" + }, + "plugins": [ + "@typescript-eslint" + ], + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended" + ], + "overrides": [ + { + "files": [ + "src/**/*.js", + "src/**/*.ts" + ] + } + ], + "rules": { + "@typescript-eslint/no-unused-vars": "error", + "@typescript-eslint/consistent-type-definitions": [ + "error", + "type" + ] + }, + "env": { + "node": true, + "es2021": true + } +} diff --git a/.github/workflows/linter.yaml b/.github/workflows/linter.yaml new file mode 100644 index 0000000..41509b8 --- /dev/null +++ b/.github/workflows/linter.yaml @@ -0,0 +1,21 @@ +name: linter +on: + pull_request: + +jobs: + eslint: + runs-on: ubuntu-latest + steps: + - name: checkout code + uses: actions/checkout@v4 + + - name: setup node + uses: actions/setup-node@v4 + with: + node-version: "20.x" + + - name: install dependencies + run: npm install + + - name: run eslint + run: npm run lint diff --git a/eslintrc.json b/eslintrc.json deleted file mode 100644 index eb34483..0000000 --- a/eslintrc.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": 12, - "sourceType": "module" - }, - "plugins": ["@typescript-eslint"], - "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"], - "rules": { - "@typescript-eslint/no-unused-vars": "error", - "@typescript-eslint/consistent-type-definitions": ["error", "type"] - }, - "env": { - "browser": true, - "es2021": true - } -} diff --git a/package.json b/package.json index d76bb81..242ee7d 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "lint": "eslint --ignore-path .eslintignore --ext .js,.ts", + "lint": "eslint src --ignore-path .eslintignore --ext .js,.ts", "start": "ts-node src/index.ts" }, "repository": {