问题标签 [editorconfig]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
410 浏览

editorconfig - EditorConfig 部分继承

假设我有以下 EditorCofig 文件:

这个定义是否意味着 C# 文件的缩进样式空间,或者我是否还需要在[.cs]部分中明确指定indent_style = space

0 投票
1 回答
210 浏览

c# - 如何为 Roslyn 中的 AdhocWorkspace 指定 editorconfig 派生的选项集?

Roslyn 会让我将文件添加到 AdhocWorkspace 并在它们上运行格式化程序,但我不知道如何指定格式化选项。我想.editorconfig从命令行传入的文件中派生它们

adhoc.Options = adhoc.Options.WithChangedOption(...)将让我更改一个选项,但我希望选项来自.editorconfig文件。有没有 API 可以让我这样做?

0 投票
3 回答
1528 浏览

roslyn - 在 Visual Studio 2019 Preview 4 中使用通用 .editorconfig 文件(在 csproj 中导入)的问题

我想简化跨多个项目和团队的代码分析和相关规则。

我们过去通过使用 NuGet 包将分析器导入项目(Microsoft.CodeAnalysis.FxCopAnalyzers 和 StyleCop.Analyzers)并定义一个规则集来定义 VS 如何处理每个规则(错误、警告等)来做到这一点。

我一直在尝试使用通用的 .editorconfig 文件而不是规则集来设置它。问题是,当从共享文件夹导入 .editorconfig 文件时,似乎会忽略如下设置。

为了对此进行测试,我有一个非常简单的场景来说明问题。

.editorconfig 文件如下:

现在这个文件被导入到一个 csproj 中,如下所示:

Build.props 是这样的:

以下代码应该在 CA1062 上触发错误:

但结果是一个警告:

错误列表

现在,如果我更改 .editorconfig 并取消注释第二行:

错误发生了,这意味着null_check_validation_methods正在考虑中。

为什么会dotnet_diagnostic.CA1062.severity = error被忽略?

0 投票
0 回答
122 浏览

c# - Editorconfig - 允许下划线变量

是否可以设置 editorconfig 以允许完整的下划线变量?

例子:

感谢你。

0 投票
1 回答
754 浏览

visual-studio - .net core .editorconfig 警告未显示在 Visual Studio 错误列表中

在我们的 .net 核心项目中,我刚刚添加了一个 .editorconfig 文件(来自使用 Add New Item 到解决方案时可用的 dafault .NET 模板)并将所有严重级别更改为“警告”(以查看我们是否需要就内容达成一致)。但是当我构建时,除了我当前打开的文件之外,没有显示任何警告或错误。该文档使我相信如果我将严重级别设置为警告或错误,我应该从所有构建的文件中看到编译器注释。如何查看解决方案中的所有警告?

https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#severity-levels

如果我使用命令行构建,dotnet build我根本看不到任何警告。

0 投票
0 回答
587 浏览

visual-studio-mac - 为什么我的 .editorconfig 文件被忽略?

我正在使用 Visual Studio for Mac,8.3.4(内部版本 8)

我有一个非常简单的 Visual Studio 解决方案和一个小项目。我完全按照文档创建了我的 .editorconfig 文件,但是当我执行 Edit -> Format -> Format Document 时,我的选项被忽略了。

这是我的 .editorconfig 文件:

这是它在正确位置的证据:

在此处输入图像描述

0 投票
1 回答
1563 浏览

c# - Visual Studio 2019:如何在 .editorconfig 中禁用特定的 CodeAnalysis 消息?

是否可以在 VS 2019 中抑制 CodeAnalysis 消息.editorconfig?这两个选项不起作用:

0 投票
1 回答
3094 浏览

visual-studio - Can Visual Studio use an .editorconfig not in the directory hierarchy?

We have a very large number of solutions spread across a wide number of repositories which do not always share a directory hierarchy in a way that makes it easy for us to update an .editorconfig such that it applies to all projects/solutions in the organization. We currently apply all of our code analysis configuration via an internal NuGet package and I was hoping we could include our organization-wide .editorconfig settings in this way as well?

I tried a quick experiment adding the following to a project to see if linked files would be honored (since we could simply add this to a props file we already have in the NuGet package), but it does not appear to be honored currently.

是否有其他一些 MSBuild 属性或机制我们可以用来更好地促进这一点,而无需将重复文件写入每个解决方案/项目/存储库?

0 投票
1 回答
3287 浏览

visual-studio-2019 - VS2019 .editorconfig 不受尊重

我们正在努力为 javascript/typescript 设置团队标准的缩进样式,并且从所有迹象来看,当我们打开解决方案时,其中的设置.editorconfig没有覆盖用户偏好,如 VS 底部所示

在此处输入图像描述

出于测试目的,我创建了世界上最简单.editorconfig的缩进大小值,并将其添加到解决方案的根文件夹中:

然后,在工具 | 选项 | 文本编辑器 | JavaScript/TypeScript | 制表符,我设置了不同的缩进大小值:

在此处输入图像描述

所以 - 如果.editorconfig真的被使用,任何重新格式化 Typescript 文件的尝试都应该导致每个级别有 27 个缩进空格。没有骰子。

我尝试将文件移动到与我要格式化的 Typescript 文件相同的文件夹中。没有骰子。

我已经验证在工具 | 下选择了“遵循项目编码约定”。选项 | 文本编辑器 | 一般的。我也关掉了。没有骰子。

总是格式化为工具 | 中指定的缩进大小。选项。

有没有我想念的魔法酱?

0 投票
1 回答
8761 浏览

visual-studio - 如何为所有解决方案将 EditorConfig 文件导入 Visual Studio?

如何将代码约定(代码格式设置)从 EditorConfig 文件导入 Visual Studio?

我希望.editorconfig所有解决方案都有一个文件,而不是每个项目一个文件。