Skip to main content

avoid-banned-exports

effort: 4m
configurable
has auto-fix
teams+

Warns against declaring banned exports.

note

This rule requires configuration in order to highlight any issues.

⚙️ Config

Set entries (default is empty) to configure the list of entries for exports to ban.

Each entry is an object with 5 fields (paths, exclude-paths, deny, message and severity):

  • Set paths (can be a regular expression, optional) to configure the list of paths the entry will apply to. If unset, applies to all files.
  • Set exclude-paths (can be a regular expression, optional) to configure the list of paths the entry will not apply to.
  • Set deny (can be a regular expression) to configure the list of exports to ban.
  • Set message to configure a user-facing message for each issue created from this config entry.
  • Set severity (optional) to override default severity for the given entry.
analysis_options.yaml
dart_code_metrics:
rules:
- avoid-banned-exports:
entries:
- paths: ['some/folder/.*\.dart', 'another/folder/.*\.dart']
deny: ['package:flutter/material.dart']
message: 'Do not reexport Flutter Material Design library!'
severity: error
warning

For Windows devices, ensure that the paths config works with Windows path separators.

Example

❌ Bad:

// LINT: This export is not allowed
// (Do not reexport Flutter Material Design library!).
export 'package:flutter/material.dart';

✅ Good:

// Correct, no banned exports in the listed folders