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

Rule proposal: no-restricted-paths #155

Closed
lo1tuma opened this issue Dec 28, 2015 · 4 comments
Closed

Rule proposal: no-restricted-paths #155

lo1tuma opened this issue Dec 28, 2015 · 4 comments

Comments

@lo1tuma
Copy link
Contributor

lo1tuma commented Dec 28, 2015

Given the following folder structure of a project:

my-project
├── client
│   └── foo.js
└── server
    └── bar.js

I want to disallow that any file in the client folder can import any module from the server folder.

The following should be invalid in client/foo.js:

import bar from '../server/bar.js';
@lo1tuma lo1tuma changed the title Rule proposal: no-restricted-imports Rule proposal: no-restricted-import-paths Dec 28, 2015
@lo1tuma lo1tuma changed the title Rule proposal: no-restricted-import-paths Rule proposal: no-restricted-paths Dec 28, 2015
@benmosher
Copy link
Member

Neat!

How would you propose defining the restricted zone?

I can imagine either regex or a path relative to the eslint working directory, but each is fragile for different reasons.

@lo1tuma
Copy link
Contributor Author

lo1tuma commented Dec 29, 2015

For me relative paths to the cwd of ESLint would work. Do you have any specific scenario in mind when relying on the cwd would become a problem?

@benmosher
Copy link
Member

Not specifically, no. And IME ESLint is traditionally run by npm in the root of a package, so that should be fine. Just thinking it through. 😅

@sindresorhus
Copy link

An ESLint consumer (plugin/editor/etc) can define a custom cwd, so you should not depend on process.cwd(). If the set cwd isn't exposed in the plugin context, I would open an issue on ESLint to make it so.

lo1tuma added a commit to lo1tuma/eslint-plugin-import that referenced this issue Jun 6, 2016
lo1tuma added a commit to lo1tuma/eslint-plugin-import that referenced this issue Jun 6, 2016
lo1tuma added a commit to lo1tuma/eslint-plugin-import that referenced this issue Jun 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants