-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
feat(sh): add pragma support #378
base: master
Are you sure you want to change the base?
feat(sh): add pragma support #378
Conversation
🦋 Changeset detectedLatest commit: c91daca The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@JounQin Hey, I'm sorry, I've tried to get that changeset file generated but I'm having trouble. I get through the prompt asking for what release needs to happen and to summarize the changes, but after confirming it crashes with: 🦋 error Error: Cannot find module '/workspaces/un-ts-prettier-plugins/node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/prettier-plugin-pkg/lib/index.cjs'
🦋 error at createEsmNotFoundErr (node:internal/modules/cjs/loader:1055:15)
🦋 error at finalizeEsmResolution (node:internal/modules/cjs/loader:1048:15)
🦋 error at resolveExports (node:internal/modules/cjs/loader:556:14)
🦋 error at Function.Module._findPath (node:internal/modules/cjs/loader:596:31)
🦋 error at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1014:27)
🦋 error at Function.Module._load (node:internal/modules/cjs/loader:873:27)
🦋 error at Module.require (node:internal/modules/cjs/loader:1100:19)
🦋 error at require (node:internal/modules/cjs/helpers:119:18)
🦋 error at /workspaces/un-ts-prettier-plugins/node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@1stg/prettier-config/base.js:20:5
🦋 error at Array.map (<anonymous>) {
🦋 error code: 'MODULE_NOT_FOUND',
🦋 error path: '/workspaces/un-ts-prettier-plugins/node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/prettier-plugin-pkg/package.json'
🦋 error } This happens both through I'm not too familiar with the tooling (PNPM and Changeset), so I would appreciate it if you could let me know what I did wrong here! |
bc1493c
to
6a3e2a9
Compare
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
6a3e2a9
to
c213e86
Compare
c213e86
to
c91daca
Compare
@JounQin Thanks for your patience, this should now be ready for workflows and review! For posterity, I needed to:
It would probably be a good idea to document (4) somewhere, but I think the changes here are sufficient for this PR and the docs update can come later. Let me know if you need anything else. Thanks again! |
Closes #377
The approach I took differs from that described in the related ticket. As I started working and read Prettier's plugin API and implementation, I realized we don't have access to all of the options required to instantiate the parser until after the pragma check has happened. Without that, we couldn't cache or memoize and using the actual Parser would mean every file would need to be parsed twice.
So this takes a regex-based approach to just chomp off the top of a file until it comes across non-comment content, scanning for the pragma along the way.