From a868121bffcf623a3a0623c0b22eb820e43b5fc9 Mon Sep 17 00:00:00 2001 From: Nick Jackson Date: Thu, 21 Mar 2024 14:51:33 +0000 Subject: [PATCH 1/4] Add sample pre-commit configuration [pre-commit](https://pre-commit.com/) is a cross-language framework for managing pre-commit hooks. This sample file sets up some very basic checks to enforce things like no trailing whitespace, and the last line in a file being blank. --- .pre-commit-config.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..fd16ba2 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,10 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files From 84712bdd943bae948409a3150d7a512eb0bb1ce2 Mon Sep 17 00:00:00 2001 From: Nick Jackson Date: Thu, 21 Mar 2024 14:51:33 +0000 Subject: [PATCH 2/4] Add prettier hook to pre-commit --- .pre-commit-config.yaml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fd16ba2..61ed064 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,10 +1,17 @@ # See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks repos: -- repo: https://github.com/pre-commit/pre-commit-hooks + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v3.2.0 hooks: - - id: trailing-whitespace - - id: end-of-file-fixer - - id: check-yaml - - id: check-added-large-files + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-json + - id: check-added-large-files + + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v3.1.0 + hooks: + - id: prettier + types_or: [scss, yaml, markdown, javascript] From 275c7fdf174c4641bc0184349685ddbfcc6ba3b4 Mon Sep 17 00:00:00 2001 From: Nick Jackson Date: Thu, 21 Mar 2024 14:51:33 +0000 Subject: [PATCH 3/4] Apply automated fixes from pre-commit --- .dockerignore | 2 +- .github/workflows/dotnet.yml | 27 +++++++++---------- .../Pages/Error.cshtml | 2 +- .../Pages/Error.cshtml.cs | 2 +- .../Pages/Index.cshtml.cs | 2 +- .../Pages/Privacy.cshtml | 2 +- .../Pages/Privacy.cshtml.cs | 2 +- .../Pages/Shared/_Layout.cshtml | 2 +- .../Shared/_ValidationScriptsPartial.cshtml | 2 +- .../Pages/_ViewImports.cshtml | 2 +- .../Pages/_ViewStart.cshtml | 2 +- src/Dfsseta.ApplyForLanding/Program.cs | 2 +- .../wwwroot/css/site.css | 2 +- 13 files changed, 25 insertions(+), 26 deletions(-) diff --git a/.dockerignore b/.dockerignore index cd967fc..656a822 100644 --- a/.dockerignore +++ b/.dockerignore @@ -22,4 +22,4 @@ **/secrets.dev.yaml **/values.dev.yaml LICENSE -README.md \ No newline at end of file +README.md diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 0bfc8aa..a4fa8e3 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -5,24 +5,23 @@ name: .NET on: push: - branches: [ "main" ] + branches: ["main"] pull_request: - branches: [ "main" ] + branches: ["main"] jobs: build: - runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Setup .NET - uses: actions/setup-dotnet@v3 - with: - dotnet-version: 8.0.x - - name: Restore dependencies - run: dotnet restore - - name: Build - run: dotnet build --no-restore - - name: Test - run: dotnet test --no-build --verbosity normal + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 8.0.x + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore + - name: Test + run: dotnet test --no-build --verbosity normal diff --git a/src/Dfsseta.ApplyForLanding/Pages/Error.cshtml b/src/Dfsseta.ApplyForLanding/Pages/Error.cshtml index b5105b6..6f92b95 100644 --- a/src/Dfsseta.ApplyForLanding/Pages/Error.cshtml +++ b/src/Dfsseta.ApplyForLanding/Pages/Error.cshtml @@ -23,4 +23,4 @@ It can result in displaying sensitive information from exceptions to end users. For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development and restarting the app. -

\ No newline at end of file +

diff --git a/src/Dfsseta.ApplyForLanding/Pages/Error.cshtml.cs b/src/Dfsseta.ApplyForLanding/Pages/Error.cshtml.cs index 8c5577c..1927b7d 100644 --- a/src/Dfsseta.ApplyForLanding/Pages/Error.cshtml.cs +++ b/src/Dfsseta.ApplyForLanding/Pages/Error.cshtml.cs @@ -23,4 +23,4 @@ public void OnGet() { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; } -} \ No newline at end of file +} diff --git a/src/Dfsseta.ApplyForLanding/Pages/Index.cshtml.cs b/src/Dfsseta.ApplyForLanding/Pages/Index.cshtml.cs index bc04300..751c68d 100644 --- a/src/Dfsseta.ApplyForLanding/Pages/Index.cshtml.cs +++ b/src/Dfsseta.ApplyForLanding/Pages/Index.cshtml.cs @@ -15,6 +15,6 @@ public IndexModel(ILogger logger) public void OnGet() { - + } } diff --git a/src/Dfsseta.ApplyForLanding/Pages/Privacy.cshtml b/src/Dfsseta.ApplyForLanding/Pages/Privacy.cshtml index a92998a..46ba966 100644 --- a/src/Dfsseta.ApplyForLanding/Pages/Privacy.cshtml +++ b/src/Dfsseta.ApplyForLanding/Pages/Privacy.cshtml @@ -5,4 +5,4 @@ }

@ViewData["Title"]

-

Use this page to detail your site's privacy policy.

\ No newline at end of file +

Use this page to detail your site's privacy policy.

diff --git a/src/Dfsseta.ApplyForLanding/Pages/Privacy.cshtml.cs b/src/Dfsseta.ApplyForLanding/Pages/Privacy.cshtml.cs index aad45c2..24e157a 100644 --- a/src/Dfsseta.ApplyForLanding/Pages/Privacy.cshtml.cs +++ b/src/Dfsseta.ApplyForLanding/Pages/Privacy.cshtml.cs @@ -15,4 +15,4 @@ public PrivacyModel(ILogger logger) public void OnGet() { } -} \ No newline at end of file +} diff --git a/src/Dfsseta.ApplyForLanding/Pages/Shared/_Layout.cshtml b/src/Dfsseta.ApplyForLanding/Pages/Shared/_Layout.cshtml index e1970cc..d709182 100644 --- a/src/Dfsseta.ApplyForLanding/Pages/Shared/_Layout.cshtml +++ b/src/Dfsseta.ApplyForLanding/Pages/Shared/_Layout.cshtml @@ -48,4 +48,4 @@ @await RenderSectionAsync("Scripts", required: false) - \ No newline at end of file + diff --git a/src/Dfsseta.ApplyForLanding/Pages/Shared/_ValidationScriptsPartial.cshtml b/src/Dfsseta.ApplyForLanding/Pages/Shared/_ValidationScriptsPartial.cshtml index 660f00c..5a16d80 100644 --- a/src/Dfsseta.ApplyForLanding/Pages/Shared/_ValidationScriptsPartial.cshtml +++ b/src/Dfsseta.ApplyForLanding/Pages/Shared/_ValidationScriptsPartial.cshtml @@ -1,2 +1,2 @@  - \ No newline at end of file + diff --git a/src/Dfsseta.ApplyForLanding/Pages/_ViewImports.cshtml b/src/Dfsseta.ApplyForLanding/Pages/_ViewImports.cshtml index 9ecc6c5..dd20ff2 100644 --- a/src/Dfsseta.ApplyForLanding/Pages/_ViewImports.cshtml +++ b/src/Dfsseta.ApplyForLanding/Pages/_ViewImports.cshtml @@ -1,3 +1,3 @@ @using Dfsseta.ApplyForLanding @namespace Dfsseta.ApplyForLanding.Pages -@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers \ No newline at end of file +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/src/Dfsseta.ApplyForLanding/Pages/_ViewStart.cshtml b/src/Dfsseta.ApplyForLanding/Pages/_ViewStart.cshtml index 1af6e49..a5f1004 100644 --- a/src/Dfsseta.ApplyForLanding/Pages/_ViewStart.cshtml +++ b/src/Dfsseta.ApplyForLanding/Pages/_ViewStart.cshtml @@ -1,3 +1,3 @@ @{ Layout = "_Layout"; -} \ No newline at end of file +} diff --git a/src/Dfsseta.ApplyForLanding/Program.cs b/src/Dfsseta.ApplyForLanding/Program.cs index 4bea680..bc275e4 100644 --- a/src/Dfsseta.ApplyForLanding/Program.cs +++ b/src/Dfsseta.ApplyForLanding/Program.cs @@ -22,4 +22,4 @@ app.MapRazorPages(); -app.Run(); \ No newline at end of file +app.Run(); diff --git a/src/Dfsseta.ApplyForLanding/wwwroot/css/site.css b/src/Dfsseta.ApplyForLanding/wwwroot/css/site.css index f8d98fc..b71897b 100644 --- a/src/Dfsseta.ApplyForLanding/wwwroot/css/site.css +++ b/src/Dfsseta.ApplyForLanding/wwwroot/css/site.css @@ -19,4 +19,4 @@ html { body { margin-bottom: 60px; -} \ No newline at end of file +} From a2fdd3fa3b2f4489325c2afd182e5d4f0da50a77 Mon Sep 17 00:00:00 2001 From: Nick Jackson Date: Thu, 21 Mar 2024 14:51:33 +0000 Subject: [PATCH 4/4] Add dotnet-format to pre-commit --- .pre-commit-config.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 61ed064..e3c12fd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,3 +15,8 @@ repos: hooks: - id: prettier types_or: [scss, yaml, markdown, javascript] + + - repo: https://github.com/dotnet/format + rev: v8.0.453106 + hooks: + - id: dotnet-format