[英]Define a linter rule for flutter and dart
As you know there are some pre-defined rules for linter, but I wonder how can I define a custom linter rule for flutter and dart?如您所知,linter 有一些预定义的规则,但我想知道如何为 flutter 和 dart 定义自定义的 linter 规则?
You would need to write a plugin for the analysis server, but the docs caution:您需要为分析服务器编写一个插件,但文档警告:
Note: The plugin support is not currently available for general use.
注意:插件支持目前不适用于一般用途。
Just in case you want to ignore that, look at the analyzer docs at: https://pub.dev/packages/analyzer_plugin and the linter docs at: https://github.com/dart-lang/linter/blob/master/doc/WritingLints.MD万一您想忽略它,请查看分析器文档: https://pub.dev/packages/analyzer_plugin和 linter 文档: https://github.com/dart-lang/linter/blob/master /doc/WritingLints.MD
You need to add the analyzer package to your dependencies and then make a analysis_options.yaml
file in the root of your project.您需要将分析器package 添加到您的依赖项中,然后在项目的根目录中创建一个
analysis_options.yaml
文件。 in there you can import other analyzer rules like effective_dart or add the ones that you need from the lint rule list .在那里,您可以导入其他分析器规则,例如Effective_dart或从lint 规则列表中添加您需要的规则。
Here is an example for analysis_options.yaml
:这是
analysis_options.yaml
的示例:
linter:
rules:
- camel_case_types
- empty_constructor_bodies
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.