From 02c9d1c70462c893e9637167700593db4444ef2b Mon Sep 17 00:00:00 2001 From: JoannaaKL Date: Thu, 16 Feb 2023 14:33:03 +0100 Subject: [PATCH] Don't disable lint errors (#2436) * Update lint.yml Don't ignore the formatting errors * Add formatting made by @cory-miller * Use dotnet format * Format only modified files * Add instruction to contribute.md * Use git status instead of git diff --- .github/workflows/lint.yml | 1 - docs/contribute.md | 8 ++++++++ src/dev.sh | 11 ++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9df0fcc08..b35bee3c7 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -18,7 +18,6 @@ jobs: uses: github/super-linter@v4 env: DEFAULT_BRANCH: ${{ github.base_ref }} - DISABLE_ERRORS: true EDITORCONFIG_FILE_NAME: .editorconfig LINTER_RULES_PATH: /src/ VALIDATE_ALL_CODEBASE: false diff --git a/docs/contribute.md b/docs/contribute.md index 70ec61154..a350b846b 100644 --- a/docs/contribute.md +++ b/docs/contribute.md @@ -158,3 +158,11 @@ cat (Runner/Worker)_TIMESTAMP.log # view your log file We use the .NET Foundation and CoreCLR style guidelines [located here]( https://github.com/dotnet/corefx/blob/master/Documentation/coding-guidelines/coding-style.md) + +### Format C# Code + +To format both staged and unstaged .cs files +``` +cd ./src +./dev.(cmd|sh) format +``` \ No newline at end of file diff --git a/src/dev.sh b/src/dev.sh index fed033d38..6ed5462a7 100755 --- a/src/dev.sh +++ b/src/dev.sh @@ -203,6 +203,13 @@ function runtest () dotnet msbuild -t:test -p:PackageRuntime="${RUNTIME_ID}" -p:BUILDCONFIG="${BUILD_CONFIG}" -p:RunnerVersion="${RUNNER_VERSION}" ./dir.proj || failed "failed tests" } +function format() +{ + heading "Formatting..." + files="$(git status -s "*.cs" | awk '{print $2}' | tr '\n' ' ')" + dotnet format ${SCRIPT_DIR}/ActionsRunner.sln --exclude / --include $files || failed "failed formatting" +} + function package () { if [ ! -d "${LAYOUT_DIR}/bin" ]; then @@ -360,7 +367,9 @@ case $DEV_CMD in "l") layout;; "package") package;; "p") package;; - *) echo "Invalid cmd. Use build(b), test(t), layout(l) or package(p)";; + "format") format;; + "f") format;; + *) echo "Invalid cmd. Use build(b), test(t), layout(l), package(p), or format(f)";; esac popd