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
Unreliable order of plugins listed under options.plugins #5
Comments
Plugins have not been wired back at the moment, it's maybe the main thing missing. For use cases like yours it should be easy to get them to work, but for dynamically defined plugins, like via |
@ArnaudBarre In the latest alpha plugins should be supported, unless you pre-instantiate them in a |
Nope not working for me with
My config in {
"prettier": {
"xmlWhitespaceSensitivity": "ignore",
"plugins": [
"@arnaud-barre/prettier-plugin-sort-imports",
"@prettier/plugin-xml",
"prettier-plugin-prisma"
]
},
} |
Ah sorry it looks like I had only implemented it when configured entirely through the CLI, there are a bunch of extra things to take care of for your use case. |
@ArnaudBarre could you check if alpha8 fixed all the issues for you? |
So now it works for SVG/prisma, but the new CLI makes {
"parsers": {
"acorn": {
"astFormat": "estree"
},
"espree": {
"astFormat": "estree"
}
}
}, I don't think this is part of the plugin API and I don't mind updating my hacky code, just wanting to let you know in case it might be an unwanted change |
Do you get a "Non-string plugin specifiers are not supported yet" error if you just don't change your configuration at all? |
Nope I get |
So it's probably an error 🤔 I'm not sure I'm understanding the scenario exactly though, does the previous repro that you made reproduce this? |
You should be able to reproduce the issue by running the latest version with https://github.com/ArnaudBarre/prettier-plugin-sort-imports on a simple TS file. |
I've taken a closer look at this last error you hit, I think I would basically classify it as user error, because here you are making the assumption that the first plugin is going to be a specific one, basically, while that seems an implementation detail with no specific guarantees, so you shouldn't rely on that. I see a couple of other projects potentially making the same assumptions, but presumably most users would be unaffected. There could be more to this potentially, Prettier internally seems to use a function for generating a sort of single merged plugin which points to all the built-in plugins, and that's what you are referencing with that |
Ah it's basically a performance optimization that Prettier is doing, to lazy-load built-in plugins as needed, which I actually wanted to do also but didn't know how to do it. I guess I can implement that and that should also accidentally fix your use case. |
@fabiospampinato — I personally would think that assuming I would however expect that plugins are in a linear order. If you wanted to say “instead of accessing Eg. let esTreePlugin = options.plugins.findFirst((plugin)->{
return plugin.estree != nil
}
… |
closing as this commmit kinda accidentally fixes this, by loading built-in plugins ~exactly like the stable CLI does it. I'll take a look at #5 and I'll try to push another release 🙂 |
@ArnaudBarre As soon as somebody is able to release |
Yeah no problem, thanks for your work! |
I have my configuration in my package.json with
"plugins": ["@prettier/plugin-xml"]
and the CLI errorssrc/icons/trash.svg: UndefinedParserError: No parser could be inferred for file
The text was updated successfully, but these errors were encountered: