From fe24bc79ceab3d89e06fa28ba96f91bf213f9b1c Mon Sep 17 00:00:00 2001 From: Matt Bishop Date: Sat, 7 Jun 2025 10:33:24 -0400 Subject: [PATCH] Holistic local linting with Mega-Linter --- .git-hooks/pre-commit | 18 ++++++++++++------ .gitignore | 3 +++ README.md | 32 ++++++++++++++------------------ 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit index bc661efaee..6a9dbc3714 100755 --- a/.git-hooks/pre-commit +++ b/.git-hooks/pre-commit @@ -1,8 +1,14 @@ -#!/bin/bash +#!/bin/sh -FILES=$(git diff --cached --name-only --diff-filter=ACM "*.cs") -if [ -n "$FILES" ] -then - dotnet format ./bitwarden-server.sln --no-restore --include $FILES - echo "$FILES" | xargs git add +FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g') +[ -z "$FILES" ] && exit 0 + +if npx mega-linter-runner --containername "megalinter-incremental" \ + --flavor formatters --remove-container --fix --env "'APPLY_FIXES=all'" \ + --env "'CLEAR_REPORT_FOLDER=true'" --env "'LOG_LEVEL=warning'" \ + --filesonly $FILES; then + echo "$FILES" | xargs git add + exit 0 fi + +exit 1 diff --git a/.gitignore b/.gitignore index 65157bf4aa..ae49506f35 100644 --- a/.gitignore +++ b/.gitignore @@ -196,6 +196,9 @@ FakesAssemblies/ # Visual Studio 6 workspace options file *.opt +# Lint +megalinter-reports/ + # Other project.lock.json *.jfm diff --git a/README.md b/README.md index c817931c67..9a0f4bfb2a 100644 --- a/README.md +++ b/README.md @@ -16,11 +16,15 @@ The Bitwarden Server project contains the APIs, database, and other core infrast The server project is written in C# using .NET Core with ASP.NET Core. The database is written in T-SQL/SQL Server. The codebase can be developed, built, run, and deployed cross-platform on Windows, macOS, and Linux distributions. -## Developer Documentation +# Contributing -Please refer to the [Server Setup Guide](https://contributing.bitwarden.com/getting-started/server/guide) in the [Contributing Documentation](https://contributing.bitwarden.com/) for build instructions, recommended tooling, code style tips, and lots of other great information to get you started. +Code contributions are welcome! Please commit any pull requests against the `main` branch. Learn more about how to contribute by reading the [Contributing Guidelines](https://contributing.bitwarden.com/contributing/). Check out the [Contributing Documentation](https://contributing.bitwarden.com/) for how to get started with your first contribution. -## Deploy +Security audits and feedback are welcome. Please open an issue or email us privately if the report is sensitive in nature. You can read our security policy in the [`SECURITY.md`](SECURITY.md) file. We also run a program on [HackerOne](https://hackerone.com/bitwarden). + +No grant of any rights in the trademarks, service marks, or logos of Bitwarden is made (except as may be necessary to comply with the notice requirements as applicable), and use of any Bitwarden trademarks must comply with [Bitwarden Trademark Guidelines](https://github.com/bitwarden/server/blob/main/TRADEMARK_GUIDELINES.md). + +# Deploying

@@ -30,9 +34,9 @@ Please refer to the [Server Setup Guide](https://contributing.bitwarden.com/gett You can deploy Bitwarden using Docker containers on Windows, macOS, and Linux distributions. Use the provided PowerShell and Bash scripts to get started quickly. Find all of the Bitwarden images on [GitHub Container Registry](https://github.com/orgs/bitwarden/packages). -Full documentation for deploying Bitwarden with Docker can be found in our help center at: https://help.bitwarden.com/article/install-on-premise/ +Full documentation for deploying Bitwarden with Docker can be found in our help center at: -### Requirements +## Requirements - [Docker](https://www.docker.com/community-edition#/download) - [Docker Compose](https://docs.docker.com/compose/install/) (already included with some Docker installations) @@ -58,22 +62,14 @@ Invoke-RestMethod -OutFile bitwarden.ps1 ` .\bitwarden.ps1 -start ``` -## We're Hiring! +# Developers -Interested in contributing in a big way? Consider joining our team! We're hiring for many positions. Please take a look at our [Careers page](https://bitwarden.com/careers/) to see what opportunities are currently open as well as what it's like to work at Bitwarden. +Please refer to the [Server Setup Guide](https://contributing.bitwarden.com/getting-started/server/guide) in the [Contributing Documentation](https://contributing.bitwarden.com/) for build instructions, recommended tooling, code style tips, and lots of other great information to get you started. -## Contribute +## Hooks -Code contributions are welcome! Please commit any pull requests against the `main` branch. Learn more about how to contribute by reading the [Contributing Guidelines](https://contributing.bitwarden.com/contributing/). Check out the [Contributing Documentation](https://contributing.bitwarden.com/) for how to get started with your first contribution. - -Security audits and feedback are welcome. Please open an issue or email us privately if the report is sensitive in nature. You can read our security policy in the [`SECURITY.md`](SECURITY.md) file. We also run a program on [HackerOne](https://hackerone.com/bitwarden). - -No grant of any rights in the trademarks, service marks, or logos of Bitwarden is made (except as may be necessary to comply with the notice requirements as applicable), and use of any Bitwarden trademarks must comply with [Bitwarden Trademark Guidelines](https://github.com/bitwarden/server/blob/main/TRADEMARK_GUIDELINES.md). - -### Dotnet-format - -Consider installing our git pre-commit hook for automatic formatting. +To gain enhanced functionality such as local linting, install the hooks for this repository: ```bash -git config --local core.hooksPath .git-hooks +git config core.hooksPath .git-hooks ```