phpcs 与 VScode - 如何禁用行长度警告?

ToX*_* 82 4 visual-studio-code phpcs

我正在处理一些遗留代码,VScode 由于一些警告(例如Line exceeds 85 characters, contains 91 characters. 这非常烦人,我想将该限制提高到至少 120 个字符,甚至完全禁用它。我的垂直标尺已经设置为 120。

我如何移动或删除该限制?我一直在到处寻找,但找不到有效的答案......这是我的项目settings.json

{
    "editor.wordWrapColumn": 120
}
Run Code Online (Sandbox Code Playgroud)

小智 5

在 VS Code 中编辑 phpcs 设置并确保“PHP Sniffer: Standard”为空(以便它查找您的自定义规则集文件)。

在项目根目录中创建文件“phpcs.xml”,其中包含如下规则集:

<?xml version="1.0"?>
<ruleset name="MyRuleset">
  <!-- Scan all files in directory -->
  <file>.</file>

  <!-- Ignore Composer dependencies -->
  <exclude-pattern>vendor/</exclude-pattern>

  <!-- Show colors in console -->
  <arg value="-colors"/>

  <!-- Show sniff codes in all reports -->
  <arg value="ns"/>

  <!-- Use PSR-12 as a base -->
  <rule ref="PSR12"/>

  <rule ref="Generic.Files.LineLength.TooLong">
      <severity>0</severity>
  </rule>
</ruleset>
Run Code Online (Sandbox Code Playgroud)