question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow no-restricted-imports to restrict sub-paths of imports

See original GitHub issue

The 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:closed
  • Created 7 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
platinumazurecommented, Oct 27, 2016

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.

0reactions
ljharbcommented, Oct 23, 2016

I’ve put up #7433 in hopes that this can be reopened.

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - ESLint: How can I restrict certain paths with "no ...
I found a "no-restricted-imports" rule which is supposed to tackle it, but I can only restrict anything under "@material-ui/core", so "@material ...
Read more >
no-restricted-imports - ESLint - Pluggable JavaScript Linter
This rule allows you to specify imports that you don't want to use in your application. It applies to static imports only, not...
Read more >
eslint-plugin-import - npm
This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, and prevent issues with misspelling of file paths and import ...
Read more >
no-restricted-imports | typescript-eslint
When set to true , the rule will allow Type-Only Imports. Examples of code with the above config: ❌ Incorrect; ✓ Correct. import...
Read more >
eslint-plugin-import | Yarn - Package Manager
This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, and prevent issues with misspelling of file paths and import names.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found