Skip to content

Rule proposal: no-dir-import #1624

@IvanGoncharov

Description

@IvanGoncharov

We plan to support ESM modules for the next release of graphql-js and as part of this effort, we need to have full paths inside imports.
I tried to switch to full paths and enable extensions rule, but this created a lot of problems with different tooling, so our current approach is to have full paths but without extensions.
It means we need to add /index to all directory imports see this PR for more details:
graphql/graphql-js#2368

Additionally, I wrote custom ESLint rule to enforce this approach:
https://github.com/graphql/graphql-js/blob/master/resources/eslint-rules/no-dir-import.js

I think other maintainers will have similar challenges trying to release ESM build, so do you think it something that should be included in this plugin?

P.S. At the moment I don't have time to polish this rule (add docs and tests), so if anyone wants to work on PR, please feel free to reuse code that I wrote for graphql-js:
https://github.com/graphql/graphql-js/blob/master/resources/eslint-rules/no-dir-import.js

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions