Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dart linting exclude folders under analyzer

Tags:

yaml

lint

dart

My linting works fine if I add rules and errors but excluding something does not have any effect.

Here is my analysis_options.yaml in the project root directory.

include: package:pedantic/analysis_options.yaml

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

  errors:
    ...
    

linter:
  rules:
    ...


My project hierarchy is like this:

/analysis_options.yaml
/test/...
/lib/generated/...

So I would like to ignore linting on test and generated folder under lib. But somehow it does not

I followed the instructions based on the docs: https://dart.dev/guides/language/analysis-options

Dart version: 2.8.4
Flutter version: 1.17.5

In my pubspec.yaml this is under dependencies:

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


So how to prevent linting not to check in excluded folders?
Thank you for your time and help.

like image 594
Ricky Avatar asked Jul 19 '20 16:07

Ricky


1 Answers

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. That fixed the problem.

like image 84
Amir_P Avatar answered Sep 24 '22 00:09

Amir_P