Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "forbid" option for import/no-internal-modules #1842

Closed
guillaumewuip opened this issue Jul 1, 2020 · 1 comment
Closed

Add "forbid" option for import/no-internal-modules #1842

guillaumewuip opened this issue Jul 1, 2020 · 1 comment

Comments

@guillaumewuip
Copy link
Contributor

guillaumewuip commented Jul 1, 2020

I would like to use import/no-internal-modules to allow all imports except some rules.

For example, given

import React from 'react';
import { Toolbar } from 'reakit/Toolbar';

import { thing } from '../dir2/subdir';
import { somethingElse } from '../dir2/subdir/file';

I would like to allow everything except reakit/Toolbar and dir2/subdir/*.
Because this should work for the full codebase (lot of node_modules dependencies, complex directory tree), I prefer maintaining an exclusion list of what is forbidden than an inclusion list of what is allowed.

Would you accept a PR to add a forbid option to import/no-internal-modules to be used like below ?

{
  ...
  "rules": {
    "import/no-internal-modules": [ "error", {
      "forbid": [ "reakit/Toolbar", "*/dir2/subdir/*" ]
    } ]
  }
}
@ljharb
Copy link
Member

ljharb commented Jul 3, 2020

As long as forbid and allow are mutually exclusive, that seems like a reasonable semver-minor PR.

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

No branches or pull requests

2 participants