如何解决使用 Github Action 验证 .editorconfig 文件
我想确保我的 Github 存储库中的任何拉取请求都遵循 .editorconfig(ASp.NET Core 5 C# 项目)中定义的规则。我发现 https://github.com/github/super-linter 使用 lint 代码,
---
###########################
###########################
## Linter GitHub Actions ##
###########################
###########################
name: Lint Code Base
#
# Documentation:
# https://help.github.com/en/articles/workflow-Syntax-for-github-actions
#
#############################
# Start the job on all push #
#############################
on:
push:
branches-ignore: [main]
# Remove the line above to run when pushing to main
pull_request:
branches: [main]
###############
# Set the Job #
###############
jobs:
build:
# Name the Job
name: Lint Code Base
# Set the agent to run on
runs-on: ubuntu-latest
##################
# Load all steps #
##################
steps:
##########################
# Checkout the code base #
##########################
- name: Checkout Code
uses: actions/checkout@v2
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0
################################
# Run Linter against codebase #
################################
- name: Lint Code Base
uses: github/super-linter@v4
env:
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
它成功了,但我没有看到它正在验证 Github 存储库根目录中的 .editorconfig 规则?我错过了什么吗?
解决方法
检查 Super Linter Github Action 中的 Environment Variables,EDITORCONFIG_FILE_NAME 文件的默认值为 .ecrc
。
因此,如果您的文件名为 .editorconfig
,则您必须将其添加到操作参数列表中,如下所示:
- name: Lint Code Base
uses: github/super-linter@v4
env:
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
EDITORCONFIG_FILE_NAME: .editorconfig
识别此文件后,Super Linter 操作将使用 editorconfig-checker 存储库对其进行检查。
编辑:根据注释,超级 linter 使用的 dotnet-format
也自动使用 .editorconf
文件。如果你想使用这个 linter 检查它,不需要设置 EDITORCONFIG_FILE_NAME。仅设置 VALIDATE_CSHARP: true
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。