From c00d502585087756804067a75d40c4cb5d7088ad Mon Sep 17 00:00:00 2001 From: Will Sheldon <114631109+wssheldon@users.noreply.github.com> Date: Thu, 9 Nov 2023 15:07:34 -0800 Subject: [PATCH 1/2] Add eslint pre-commit and ruff, typos --- .pre-commit-config.yaml | 23 +++++++++++++++-------- src/dispatch/static/dispatch/package.json | 16 ++++++++++++++++ 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c504285f29f3..8b7dc9103909 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,17 +13,24 @@ default_language_version: python: python3.11.2 repos: - # Black - - repo: https://github.com/psf/black - rev: 23.1.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.1.4 hooks: - - id: black + # Run the linter. + # + # When running with --fix, Ruff's lint hook should be placed before Ruff's formatter hook, + # and before Black, isort, and other formatting tools, as Ruff's fix behavior can output code changes that require reformatting. + - id: ruff + args: [--fix] + # Run the formatter. + - id: ruff-format - # Ruff - - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: "v0.0.259" + # Typos + - repo: https://github.com/crate-ci/typos + rev: v1.16.23 hooks: - - id: ruff + - id: typos # Pytest - repo: local diff --git a/src/dispatch/static/dispatch/package.json b/src/dispatch/static/dispatch/package.json index e9fb97662f8a..5ae9e62ee532 100644 --- a/src/dispatch/static/dispatch/package.json +++ b/src/dispatch/static/dispatch/package.json @@ -2,6 +2,22 @@ "name": "dispatch", "version": "0.1.0", "private": true, + "husky": { + "hooks": { + "pre-commit": "lint-staged" + } + }, + "lint-staged": { + "*.{js,jsx,vue,ts,tsx}": [ + "prettier --write", + "eslint --fix", + "git add" + ], + "*.{html,css,less,ejs}": [ + "prettier --write", + "git add" + ] + }, "scripts": { "serve": "cross-env NODE_ENV=dev NODE_OPTIONS='--max-http-header-size=100000' vite", "build": "vite build --out-dir dist", From 463c81695d936a4428be00ed28314a32db5c7e6e Mon Sep 17 00:00:00 2001 From: Will Sheldon <114631109+wssheldon@users.noreply.github.com> Date: Thu, 9 Nov 2023 15:11:11 -0800 Subject: [PATCH 2/2] Add husky --- src/dispatch/static/dispatch/package-lock.json | 16 ++++++++++++++++ src/dispatch/static/dispatch/package.json | 1 + 2 files changed, 17 insertions(+) diff --git a/src/dispatch/static/dispatch/package-lock.json b/src/dispatch/static/dispatch/package-lock.json index 532967e64388..7417e33a1870 100644 --- a/src/dispatch/static/dispatch/package-lock.json +++ b/src/dispatch/static/dispatch/package-lock.json @@ -51,6 +51,7 @@ "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-vue": "^9.7.0", "eslint-plugin-vuetify": "^2.0.5", + "husky": "^8.0.3", "jquery": "^3.6.0", "jwt-decode": "^3.1.2", "prettier": "^2.7.1", @@ -2629,6 +2630,21 @@ "entities": "^4.4.0" } }, + "node_modules/husky": { + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.3.tgz", + "integrity": "sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==", + "dev": true, + "bin": { + "husky": "lib/bin.js" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/typicode" + } + }, "node_modules/ignore": { "version": "5.2.4", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", diff --git a/src/dispatch/static/dispatch/package.json b/src/dispatch/static/dispatch/package.json index 5ae9e62ee532..8fda7ae340d7 100644 --- a/src/dispatch/static/dispatch/package.json +++ b/src/dispatch/static/dispatch/package.json @@ -69,6 +69,7 @@ "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-vue": "^9.7.0", "eslint-plugin-vuetify": "^2.0.5", + "husky": "^8.0.3", "jquery": "^3.6.0", "jwt-decode": "^3.1.2", "prettier": "^2.7.1",