-
-
Notifications
You must be signed in to change notification settings - Fork 30
Description
Hi folks,
thanks for the effort and for these plugins. It looks like prettier-plugin-toml@2.0.5
is not correctly finding *.toml files in some cases.
I checked all the 2.0.x versions, and only the latest (2.0.5) is affected by this issue.
It's interesting that e.g. prettier-plugin-sh
(latest) works fine.
Problem
Prettier can be run from the directory where it is installed (case 1 - the usual case) or from some other directory (case 2).
I case 2, *.toml
files are completely ignored.
Steps to reproduce:
INSTALLATION_DIR=/app/ # dir containing node_modules with prettier and plugins
# case 1
cd $INSTALLATION_DIR
./node_modules/.bin/prettier --plugin=prettier-plugin-toml --check .
# checks *.toml files - as expected :)
# case 2 - run from different folder
# we need absolute path for the plugin, so prettier can find it
TOML_PLUGIN_PATH=$(cd $INSTALLATION_DIR && node -e "console.log(require.resolve('prettier-plugin-toml'))")
cd $INSTALLATION_DIR/..
$INSTALLATION_DIR/node_modules/.bin/prettier \
--plugin=$TOML_PLUGIN_PATH \
--check $INSTALLATION_DIR
# *.toml files are ignored, like they don't exist :(
# other files are processed as usual
Patch on installed package resolving the issue
--- a/node_modules/prettier-plugin-toml/lib/index.cjs
+++ b/node_modules/prettier-plugin-toml/lib/index.cjs
@@ -1,7 +1,5 @@
'use strict';
-Object.defineProperty(exports, '__esModule', { value: true });
-
var taplo = require('@taplo/lib');
const languages = [
@@ -189,4 +187,4 @@ const TomlPlugin = {
options: prettierOptionsDefinitions
};
-exports.default = TomlPlugin;
+module.exports = TomlPlugin;
Looking at the patch, it looks like there is the only occurence of __esModule
in both -toml
and -sh
plugins 🤷
Environment:
node 22.14.0
prettier@3.x.x (I tried 3.0.0 and also the latest)
OS: Mac & Linux
Next Steps
To me it looks like a little thing to be fixed. But in case you suggest I should have a look at it (and create a PR), I would appreciate some guidance. Who knows, maybe changing the default export of TomlPlugin
to named exports would do the trick.