【问题标题】:How to customize linter rules?如何自定义 linter 规则?
【发布时间】:2022-11-16 05:05:12
【问题描述】:

我正在尝试禁用以下规则执行:

  • 使用 lowerCamelCase 命名非常量标识符。
void apply_procedure() {}

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    要在整个项目中禁用它,请在analysis_options.yaml中添加以下内容:

    linter:
      rules:
        - non_constant_identifier_names: false
    

    或者在方法签名上方添加以下行,如下所示:

    // ignore: non_constant_identifier_names
    void apply_procedure() {}
    

    如果你想在整个文件中禁用它,或者只在该文件中禁用它,或者将它的添加到特定文件的顶部:

    // ignore_for_file: non_constant_identifier_names
    

    【讨论】: