From 38d2eea5f8b57f70a4b5bdebd6bdeae8c395d822 Mon Sep 17 00:00:00 2001 From: Elijah Okello Date: Wed, 14 Feb 2024 11:37:21 +0300 Subject: [PATCH] #1870 fix pre commit errors (#1884) * fix: fix for precommit errors * fix: migrated .eslintrc.js to eslint.config.js flat config * fix: added dependencies and added support for globals in eslint.config.js * fix: set ecmaVersion to latest --- .eslintrc.js | 22 ---------------------- .pre-commit-config.yaml | 8 ++++++-- eslint.config.js | 28 ++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 24 deletions(-) delete mode 100644 .eslintrc.js create mode 100644 eslint.config.js diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index b0c799d88..000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,22 +0,0 @@ -module.exports = { - root: true, - "env": { - "browser": true, - "es6": true, - node: true, - }, - "extends": "eslint:recommended", - "parserOptions": { - "ecmaVersion": 6, - "sourceType": "module" - }, - "rules": { - "curly": ["error", "all"], - "dot-notation": "error", - "eqeqeq": "error", - "no-eval": "error", - "no-var": "error", - "prefer-const": "error", - "semi": "error" - } -}; diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 23d879f71..116a58560 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,7 +14,7 @@ repos: hooks: - id: doc8 - repo: https://github.com/adamchainz/django-upgrade - rev: 1.15.0 + rev: 1.16.0 hooks: - id: django-upgrade args: [--target-version, "3.2"] @@ -32,9 +32,13 @@ repos: args: - --trailing-comma=es5 - repo: https://github.com/pre-commit/mirrors-eslint - rev: v8.56.0 + rev: v9.0.0-beta.0 hooks: - id: eslint + additional_dependencies: + - "eslint@v9.0.0-beta.0" + - "@eslint/js@v9.0.0-beta.0" + - "globals" files: \.js?$ types: [file] args: diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 000000000..0b4d0e49e --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,28 @@ +const js = require("@eslint/js"); +const globals = require("globals"); + +module.exports = [ + js.configs.recommended, + { + files: ["**/*.js"], + languageOptions:{ + ecmaVersion: "latest", + sourceType: "module", + globals: { + ...globals.browser, + ...globals.node + } + } + }, + { + rules: { + "curly": ["error", "all"], + "dot-notation": "error", + "eqeqeq": "error", + "no-eval": "error", + "no-var": "error", + "prefer-const": "error", + "semi": "error" + } + } +];