import-js / import-js/eslint-plugin-import
no-restricted-paths/ How to set except zone for the relative paths. Please can you help me 🙏🙏🙏
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 5.9k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
Good day! I have a folder structure:
my-project
|----- src
│ |----- main
| |----- api.1
| |----- ConstService.js
| |----- api.2
| |------ AccountService.js
| |----- components
| |------ ScreenLogin.js
| |------ service
| |------ workers
And I need to restrict the import from './src/main/api.1' to './src/main', but except one zone './src/main/api.2. It means only possible to import the entities from './src/main/api.1' to './src/main/api.2. Means to get the error if import the entities from './src/main/api.1' to './src/main/components', './src/main/service', and './src/main/workers/'.
My rule:
'rules': {
'import/no-restricted-paths': [
'error',
{
'zones': [
{ 'target': './src/main', 'from': './src/main/api.1', 'except': ['./src/main/api.2'] },
],
}
],
},
The linted file is './src/main/components/ScreenLogin.js:
// IN THIS CASE GET THE ERROR NO-RESTRICTED-PATHS:
import { ConstService } from '../api.1'
The linted file is './src/main/api.2/AccountService.js:
// IN THIS CASE I DON'T NEED GET THE ERROR, BUT I HAVE THE ERROR:
import { AccountService } from '../api.1'
Please can you tell me how can I set the exception for './src/main/api.2' in my case. According the documentation: An optional except may be defined for a zone, allowing exception paths that would otherwise violate the related from. What does it means the exception path only can be relative to from zone. Please can you tell which way I can set in my case 🙏🙏🙏
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the no-restricted-paths rule documentation and its handling of zone, target, from, and except paths. Reproduce the two imports from the issue, then trace how relative exception paths are resolved; done means the documented configuration either behaves as requested or the limitation and correct usage are clearly documented, with a regression test if the repository has coverage for this rule.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- eslint, javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100