Skip to content

Rule proposal: Forbid imports with explicit side-effects #529

Closed

Description

IMO, modules that have side-effect just from requiring them are really bad. I would like to see a rule that forbids importing/requiring modules that are not assigned, which implicitly means there is a side-effect or simply not used and therefore useless.

Invalid

import 'dosideeffect';
import './dosideeffect';
require('./dosideeffect');

Valid

import foo from 'bar';

// Explicit effect
import doEffect from './dosideeffect';
doEffect();

As far as rule name goes: no-unnassigned-import, no-side-effect-import, ...? I'm leaning toward the former at the moment, though it doesn't capture the rationale of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions