简体   繁体   English

Dart linting 排除分析器下的文件夹

[英]Dart linting exclude folders under analyzer

My linting works fine if I add rules and errors but excluding something does not have any effect.如果我添加规则和错误但排除某些内容没有任何效果,我的 linting 工作正常。

Here is my analysis_options.yaml in the project root directory.这是我在项目根目录下的 analysis_options.yaml。

include: package:pedantic/analysis_options.yaml

analyzer:
  exclude:
    - lib/generated/**
    - test/**

  errors:
    ...
    

linter:
  rules:
    ...


My project hierarchy is like this:我的项目层次结构是这样的:

/analysis_options.yaml /analysis_options.yaml
/test/... /测试/...
/lib/generated/... /lib/生成/...

So I would like to ignore linting on test and generated folder under lib.所以我想忽略 lib 下 test 和生成文件夹的 linting。 But somehow it does not但不知何故它没有

I followed the instructions based on the docs: https://dart.dev/guides/language/analysis-options我遵循了基于文档的说明: https://dart.dev/guides/language/analysis-options

Dart version: 2.8.4 Dart 版本:2.8.4
Flutter version: 1.17.5 Flutter版本:1.17.5

In my pubspec.yaml this is under dependencies:在我的 pubspec.yaml 中,这是在依赖项下:

dependencies:
  ...
  pedantic: ^1.8.0
  ...


So how to prevent linting not to check in excluded folders?那么如何防止 linting 不检查排除的文件夹呢?
Thank you for your time and help.感谢您的时间和帮助。

Since linter does not support exclude, and if you exclude your directory from analyzer you won't get any static analysis and will miss errors, what I did was adding an empty analysis_options.yaml inside my test directory.由于 linter 不支持排除,并且如果您从分析器中排除您的目录,您将不会得到任何 static 分析并且会错过错误,我所做的是在我的test目录中添加一个空的analysis_options.yaml That fixed the problem.这解决了问题。

I'm working on a large project, I implemented lint and I can't handle all warnings and errors once so I excluded files and directories just like this我正在做一个大型项目,我实现了 lint,但我一次无法处理所有警告和错误,所以我像这样排除了文件和目录

analyzer:
  exclude:
    - lib/test/**
    - lib/provider/**
    - lib/bloc/activate_entitlement/**
    - lib/models/appconfig.dart
    - lib/bloc/favourite/**

Lint皮棉

dev_dependencies:
  lint: ^1.8.2

It's working fine for me.它对我来说很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM