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

Allow plugin to run if prettier config is missing #1436

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rdimartino
Copy link
Contributor

If there is no prettier config in a project, but the plugin is specified in the CLI invocation of prettier, the plugin raises with an difficult to understand error message:

❯ npx prettier --plugin=@prettier/plugin-ruby --check .
Checking formatting...
script.rb
[error] script.rb: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received null
[error]     at Object.dirname (node:path:1279:5)
[error]     at spawnServer (file:///private/tmp/foo/node_modules/@prettier/plugin-ruby/src/plugin.js:79:24)
[error]     at async parse (file:///private/tmp/foo/node_modules/@prettier/plugin-ruby/src/plugin.js:154:27)
[error]     at async parse4 (file:///private/tmp/foo/node_modules/prettier/index.mjs:22117:11)
[error]     at async coreFormat (file:///private/tmp/foo/node_modules/prettier/index.mjs:22607:7)
[error]     at async formatWithCursor (file:///private/tmp/foo/node_modules/prettier/index.mjs:22809:14)
[error]     at async formatFiles (file:///private/tmp/foo/node_modules/prettier/internal/cli.mjs:6673:18)
[error]     at async main (file:///private/tmp/foo/node_modules/prettier/internal/cli.mjs:7081:5)
[error]     at async Module.run (file:///private/tmp/foo/node_modules/prettier/internal/cli.mjs:7027:5)

This allows the plugin to run anyway. Is that a problem? Should a clearer error be thrown here instead?

Notably, opts.filepath seems to always be defined AFAICT

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

Successfully merging this pull request may close these issues.

1 participant