Flutter - Exclude specific linter rule in analysis_options.yaml for a folder

305 Views Asked by At

I have a bigger project with different rules for the linter written down in the analysis_options yaml file. I want to exclude a subset of rules for certain folders.

Example: I want to exclude the hole "lib/application" folder for the rule "prefer_relative_imports"

analyzer:
  exclude:
    - lib/injection.dart

linter:
  rules:
    - discarded_futures
    - prefer_relative_imports

How can i explain a folder location to ignore a subset of rules? Excluding them in each file individually is not practical when there are a large number of files in said folder.

I tried to have multiple analysis_options.yaml files in the corresponding exluding folders to declare rules which needs to be excluded. This has no effect to the linter cause only the file in root directory seems to be noted.

1

There are 1 best solutions below

1
On

Try adding a new analysis_options.yaml file in that directory and customize its analyzer, linter... as you want.