Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

Latest commit

 

History

History
41 lines (30 loc) · 1.02 KB

avoid-banned-imports.mdx

File metadata and controls

41 lines (30 loc) · 1.02 KB

import RuleDetails from '@site/src/components/RuleDetails';

Configure some imports that you want to ban.

Example {#example}

With the configuration in the example below, here are some bad/good examples.

❌ Bad:

import "package:flutter/material.dart";
import "package:flutter_bloc/flutter_bloc.dart";

✅ Good:

// No restricted imports in listed folders.

⚙️ Config example {#config-example}

The paths and deny both support regular expressions.

dart_code_metrics:
  ...
  rules:
    ...
    - avoid-banned-imports:
        entries:
        - paths: ["some/folder/.*\.dart", "another/folder/.*\.dart"]
          deny: ["package:flutter/material.dart"]
          message: "Do not import Flutter Material Design library, we should not depend on it!"
        - paths: ["core/.*\.dart"]
          deny: ["package:flutter_bloc/flutter_bloc.dart"]
          message: 'State management should be not used inside "core" folder.'