Closed KholdStare closed 1 year ago
@blutorange i think you may have looked into this at one time. If so, do you recall what the challenge was?
Any progress on this topic? @IanVS @blutorange @KholdStare
I don't see any mention in npmjs.com/package/firestore-jest-mock about putting code before imports. Technically, imports always run before any of the code in the module, so even if you put code above the imports, it will still run afterwards.
I think the only way to achieve what you want is to use a dynamic import()
statement so that you can run some code beforehand.
Your Environment
Describe the bug
Imports are moved around code even with
// prettier-ignore
. The order relative to other imports is preserved, but code gets shoved below all the imports (or imports get shoved above code, depending on how you look at it). This can pop up when mocking some functionality that another module depends on. For example https://www.npmjs.com/package/firestore-jest-mock requires runningmockGoogleCloudFirestore
before any import of@google-cloud/firestore
. See the@google-cloud/firestore compatibility
section on the package pageTo Reproduce
Expected behavior
Any import line with
// prettier-ignore
should not budge, even relative to code.Screenshots, code sample, etc
As an example from our codebase:
becomes
Contribute to @ianvs/prettier-plugin-sort-imports