From cad65502f29de49ae45db65c122222cb6030e1cc Mon Sep 17 00:00:00 2001 From: Uiolee <22849383+uiolee@users.noreply.github.com> Date: Wed, 1 Nov 2023 00:20:42 +0800 Subject: [PATCH] chore: update eslint and CI (#532) * update eslint * babel-eslint has been deprecated * ci: update lint --- .eslintrc.json | 13 ++++++----- .github/workflows/lint.yml | 23 +++++++++++++++++++ .travis.yml | 3 --- package.json | 11 ++++----- .../webextension-plain/.eslintrc | 2 +- .../webextension-with-webpack/.eslintrc | 2 +- 6 files changed, 37 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/lint.yml delete mode 100644 .travis.yml diff --git a/.eslintrc.json b/.eslintrc.json index 22a593cb..e371120e 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,22 +1,23 @@ { "root": true, "parserOptions": { - "ecmaVersion": 2017 + "ecmaVersion": "latest" }, "env": { "browser": true, - "es6": true, + "es2021": true, + "node": true, "webextensions": true }, "globals": { "globalThis": false }, - "extends": [ - "eslint:recommended" - ], + "extends": ["eslint:recommended"], + "overrides": [], + "rules": { "no-console": 0, - "no-unused-vars": ["warn", { "vars": "all", "args": "after-used" } ], + "no-unused-vars": ["warn", { "vars": "all", "args": "after-used" }], "no-undef": ["warn"], "no-proto": ["error"], "prefer-arrow-callback": ["warn"], diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..59035b7b --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,23 @@ +name: lint +on: + pull_request: + paths: + - "**.js" + +jobs: + eslint: + name: eslint + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + + steps: + - uses: actions/checkout@v4 + + - uses: reviewdog/action-eslint@v1 + with: + reporter: github-pr-review + eslint_flags: "." + filter_mode: "file" + fail_on_error: true diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6892e2f8..00000000 --- a/.travis.yml +++ /dev/null @@ -1,3 +0,0 @@ -language: node_js -node_js: stable -sudo: false diff --git a/package.json b/package.json index a47007c4..54df96d1 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "version": "1.0.0", "description": "Example Firefox add-ons created using the WebExtensions API", "devDependencies": { - "eslint": "^4.4.1" + "@babel/eslint-parser": "^7.22.11", + "eslint": "^8.48.0" }, "repository": { "type": "git", @@ -12,7 +13,8 @@ }, "scripts": { "test": "eslint .", - "lint": "eslint ." + "lint": "eslint .", + "lint:fix": "eslint . --fix" }, "license": "MIT", "bugs": { @@ -25,8 +27,5 @@ "firefox", "mozilla" ], - "homepage": "https://developer.mozilla.org/Add-ons/WebExtensions/Examples", - "dependencies": { - "babel-eslint": "^7.2.3" - } + "homepage": "https://developer.mozilla.org/Add-ons/WebExtensions/Examples" } diff --git a/store-collected-images/webextension-plain/.eslintrc b/store-collected-images/webextension-plain/.eslintrc index f0310c8d..6b126708 100644 --- a/store-collected-images/webextension-plain/.eslintrc +++ b/store-collected-images/webextension-plain/.eslintrc @@ -1,3 +1,3 @@ { - "parser": "babel-eslint" + "parser": "@babel/eslint-parser" } \ No newline at end of file diff --git a/store-collected-images/webextension-with-webpack/.eslintrc b/store-collected-images/webextension-with-webpack/.eslintrc index 1adf9764..6c7d7299 100644 --- a/store-collected-images/webextension-with-webpack/.eslintrc +++ b/store-collected-images/webextension-with-webpack/.eslintrc @@ -1,5 +1,5 @@ { - "parser": "babel-eslint", + "parser": "@babel/eslint-parser", "env": { "commonjs": true }