Allow no-restricted-imports to restrict sub-paths of imports
See original GitHub issueThe version of ESLint you are using.
3.3.1
The problem you want to solve.
I have a package that contains some files that are considered to be part of its public API (e.g. “my-package/public/foo.js”) which we consume by importing these files from the package directly (e.g. import foo from 'my-package/public/foo.js';
). This package also contains files that are considered to be private and should not be imported (e.g. “my-package/private/bar.js”). I want to allow people to import the package (import myPackage from 'my-package';
) or from the public directory, but not from the private directory.
Your take on the correct solution to problem.
I originally considered enhancing eslint-plugin-import’s no-restricted-paths rule to allow for packages but there @ljharb and @benmosher suggested enhancing the core no-restricted-imports rule instead.
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (10 by maintainers)
I think we can just accept the PR once we get enough support, so I don’t think we need to reopen this specifically. Please track #7433 if you are interested in this feature.
I’ve put up #7433 in hopes that this can be reopened.