alan2207 / bulletproof-react

🛡️ ⚛️ A simple, scalable, and powerful architecture for building production ready React applications.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ESLint "no-restricted-imports" rule

mauro-ni opened this issue · comments

Hi,
I have a question about the ESLint rule proposed in Project Structure, which is the following:

{
    rules: {
        'no-restricted-imports': [
            'error',
            {
                patterns: ['@/features/*/*'],
            },
        ],

    // ...rest of the configuration
}

This rule aims to limit the import statements to the index file only, using it as the public API of the feature.
This is great, but it is limiting when implementing the feature: if the feature has a complex structure, it is convenient to be able to use absolute imports for its implementation.

Example:

src/features/awesome-feature
|
+-- api
|
+-- components/complex/structure/that/want/to/access/api/Example.jsx
|
...

In Example.jsx it would be better to use

import { query } from "@/features/awesome-feature/api/queries";

instead of

import { query } from "../../../../../../../api/queries";

Is it possible to refine the rule somewhat, so that it allows absolute imports for such use case?

Many thanks,
Mauro