Sitelet https://github.com/import-js/eslint-plugin-import/issues/529
Skip to content

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

Description

@jfmengels

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.

Activity

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

Metadata

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