Skip to content

Existing rules 📐

We have several rules already defined in the plugin. You can create some rule too, take a look in our section about contributions.

Forbidden Dependencies Rule

Deprecated - Only available before v2.0.0

The DoNotWithRule specifies that a set of file should not depend on certain files. For example:

// your-project-root/eagle_eye_config.json
{
  "filePattern": "*viewmodel.dart",
  "doNotWithPatterns": ["*_screen.dart"]
},

The Forbidden Dependencies Rule specifies that a set of file should not depend on certain files. For example:

// your-project-root/eagle_eye_config.json
{
  "filePattern": "*viewmodel.dart",
  "forbiddenDependencies": ["*_screen.dart"]
},

In this case, all files that has the suffix viewmodel.dart should not depend on any file whose name includes ‘_screen.dart’.

Exclusive Dependencies Rule

Deprecated - Only available before v2.0.0

The JustWithRule specifies that some files should depend on certain files. For example:

// your-project-root/eagle_eye_config.json
{
  "filePattern": "*repository.dart",
  "justWithPatterns": ["*_datasources.dart"]
},

The Exclusive Dependencies Rule specifies that some files should depend only on certain files. An import is allowed when it matches any of the listed patterns, and a file that imports nothing is also allowed. For example:

// your-project-root/eagle_eye_config.json
{
  "filePattern": "*repository.dart",
  "exclusiveDependencies": ["*_datasources.dart"]
},

In this case, the our repositories should depend only on data sources.

You can also list several allowed patterns:

// your-project-root/eagle_eye_config.json
{
  "filePattern": "*screen.dart",
  "exclusiveDependencies": ["*_viewmodel.dart", "*_widget.dart"]
},

In this case, screens may depend on view models, on widgets, on both, or on nothing — but never on anything else.

Dependencies Allowed Rule

Deprecated - Only available before v2.0.0

The NoDependencyRule ensures that some files should remain free of any dependencies. For example:

  {
    "filePattern": "*util.dart",
    "noDependsEnabled": true
  },

The Dependencies Allowed Rule ensures that some files should remain free of any dependencies. For example:

  {
    "filePattern": "*util.dart",
    "dependenciesAllowed": false
  },

In this case, the all utils should be free of any internal dependencies.