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

Latest commit

 

History

History
51 lines (28 loc) · 845 Bytes

avoid-top-level-members-in-tests.mdx

File metadata and controls

51 lines (28 loc) · 845 Bytes

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

Warns when a public top-level member (expect the entrypoint) is declared inside a test file.

It helps reduce code bloat and find unused declarations in test files.

::: note

If you want to set exclude config for this rule, the default ['/**', '!test/**'] will be overriden.

:::

Example {#example}

Bad:

final public = 1; // LINT

void function() {} // LINT

class Class {} // LINT

mixin Mixin {} // LINT

extension Extension on String {} // LINT

enum Enum { first, second } // LINT

typedef Public = String; // LINT

Good:

final _private = 2;

void _function() {}

class _Class {}

mixin _Mixin {}

extension _Extension on String {}

enum _Enum { first, second }

typedef _Private = String;