diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index e69de29..0000000 diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index d697e2f..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "env": { - "browser": true, - "commonjs": true, - "es6": true, - "jquery": true, - "webextensions": true - }, - "extends": "eslint:recommended", - "parserOptions": { - "ecmaVersion": 2020 - }, - "rules": { - "comma-dangle": [ - "error", - { - "arrays": "always-multiline", - "exports": "always-multiline", - "functions": "only-multiline", - "imports": "always-multiline", - "objects": "always-multiline" - } - ], - "indent": [ - "error", - 4, - { - "SwitchCase": 1 - } - ], - "linebreak-style": [ - "error", - "unix" - ], - "no-console": [ - "off" - ], - "no-restricted-syntax": [ - "error", - "ForInStatement" - ], - "no-unused-vars": [ - "error", - { - "args": "all", - "argsIgnorePattern": "^_[^_]", - "varsIgnorePattern": "^_[^_]" - } - ], - "no-var": "error", - "prefer-const": "warn", - "quotes": [ - "warn", - "double" - ], - "semi": [ - "warn", - "always" - ] - } -} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 0736dad..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Build - -on: - pull_request: - push: - schedule: - - cron: 0 0 * * 0 # weekly - -jobs: - Build: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: - - ubuntu-20.04 - node-version: - - 16.x - steps: - - name: Set up Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - uses: actions/checkout@v2 - - run: npm install - - run: npm run test - - run: npm run lint diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000..5c34a23 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,17 @@ +name: Build + +on: + pull_request: + push: + +jobs: + Build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v3 + - uses: pre-commit/action@v3.0.0 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..2fcb184 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,26 @@ +repos: + + - repo: local + hooks: + + - id: eslint + name: eslint + entry: eslint + language: node + types_or: + - javascript + additional_dependencies: + - "@eslint/js@8.54.0" + - "@stylistic/eslint-plugin-js@1.4.0" + - eslint@8.54.0 + - globals@13.23.0 + + - id: web-ext lint + name: web-ext lint + entry: web-ext lint + language: node + types_or: + - javascript + pass_filenames: false + additional_dependencies: + - web-ext@7.8.0 diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..01877ab --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,88 @@ +const globals = require("globals"); +const js = require("@eslint/js"); +const stylistic = require("@stylistic/eslint-plugin-js"); + +module.exports = [ + { + ignores: [ + "base64.js", + "browser-polyfill.js", + ], + languageOptions: { + globals: { + ...globals.browser, + ...globals.commonjs, + ...globals.es6, + ...globals.jquery, + ...globals.webextensions, + }, + parserOptions: { + ecmaVersion: 2020, + }, + }, + plugins: { + stylistic: stylistic, + }, + rules:{ + ...js.configs.recommended.rules, + "no-restricted-syntax": [ + "error", + "ForInStatement", + ], + "no-unused-vars": [ + "error", + { + "args": "all", + "argsIgnorePattern": "^_[^_]", + "varsIgnorePattern": "^_[^_]", + }, + ], + "no-var": "error", + "prefer-const": "error", + "stylistic/array-bracket-newline": [ + "error", + "consistent", + ], + "stylistic/array-bracket-spacing": [ + "error", + "never", + ], + "stylistic/comma-dangle": [ + "error", + { + "arrays": "always-multiline", + "exports": "always-multiline", + "functions": "only-multiline", + "imports": "always-multiline", + "objects": "always-multiline", + }, + ], + "stylistic/indent": [ + "error", + 4, + { + "SwitchCase": 1, + }, + ], + "stylistic/linebreak-style": [ + "error", + "unix", + ], + "stylistic/no-console": [ + "off", + ], + "stylistic/object-curly-spacing": [ + "error", + "never", + ], + "stylistic/quotes": [ + "error", + "double", + ], + "stylistic/semi": [ + "error", + "always", + ], + }, + }, +]; diff --git a/package.json b/package.json index 3cc7708..61d9700 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,10 @@ { "author": "Sebastian Blask", "devDependencies": { - "eslint": "8.9.x", - "web-ext": "6.7.x" + "@eslint/js": "^8.54.0", + "@stylistic/eslint-plugin-js": "^1.4.0", + "eslint": "^8.54.0", + "web-ext": "^7.8.0" }, "license": "MIT", "name": "donotclosebrowserwithlasttab", @@ -26,8 +28,7 @@ "readme": "cat README.md | sed -r 's/\\[.+\\]\\((.+)\\)/\\1/' | sed -r '/\\[/{ N; s/\\[.+\\]\\((.+)\\)/\\n\\1/ }' | sed -r '/```/,/```/d' | vim -", "release": "VERSION=$(jq --raw-output '.version' manifest.json); hub release create $(for file in *$VERSION*.zip; do echo \" -a ${file} \"; done) -m $VERSION $VERSION", "start": "GTK_THEME=Greybird web-ext run --verbose --firefox firefox", - "start:nightly": "GTK_THEME=Greybird web-ext run --verbose --firefox firefox-trunk", - "test": "web-ext lint" + "start:nightly": "GTK_THEME=Greybird web-ext run --verbose --firefox firefox-trunk" }, "title": "Do not close browser with last tab", "version": "1.0.0"