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

Disallow incorrect component import #24

Open
Aztriltus opened this issue Jun 28, 2023 · 1 comment
Open

Disallow incorrect component import #24

Aztriltus opened this issue Jun 28, 2023 · 1 comment

Comments

@Aztriltus
Copy link
Owner

Aztriltus commented Jun 28, 2023

Maybe we can disallow this via eslint config

import { AwesomeComponent } from "@/components/AwesomeComponent/AwesomeComponent

by configuring in the ESLint configuration with the following rule:

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

    // ...rest of the configuration
}
@sushanyadav
Copy link
Collaborator

sushanyadav commented Jan 24, 2024

The pattern @/common/components/*/* might unintentionally prevent nested components or items which we probably don't want. To address this, we need to ensure that at the end of the path, we don't repeat the component or item name.

There might be few potential solution that are worth exploring:

  • a complex pattern that checks the above
  • custom eslint rule
  • disallow vscode to autocomplete such repetitions. (not quite sure if its possible)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants