-
-
Notifications
You must be signed in to change notification settings - Fork 64
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
feature request: read configuration from file #69
Comments
Most likely the configuration file would have the following structure:
So in dprint I could provide the following functionality: // pseudocode...
use dprint_core::{resolve_global_config};
use dprint_plugin_typescript::{resolve_config};
let mut config_map: HashMap<String, String> = ...; // parse json to string key/value pairs
// assume exists for this example... probably want something better than re-deserializing this
// from a string...
let typescript_config_map = deserialize_to_hash_map(config_map.remove("typescript").unwrap());
// get the global config
let global_config_result = resolve_global_config(&config_map);
for diagnostic in global_config_result.diagnostics {
// includes stuff like excess properties and such
}
// resolve the typescript config
let config_result = resolve_config(&global_config_result.config, &typescript_config_map);
for diagnostic in config_result.diagnostics {
// do something...
}
// now format with config_result.config... The This will get slightly easier once I have the plugin infrastructure in place. Other Config File Formats I don't want to have multiple ways of reading configuration in dprint and since I'm running this from node (deno in the future :)) I am just going to keep loading the config in JavaScript for now. That might change in the future though. So I'd recommend creating a config file specifically for deno, read that into key value pairs, then use the api above that I will add soon. Perhaps then one day I could adopt that back in here. Does that sound good? Overall, I wouldn't mind adding the code for reading a json configuration file to dprint, but I don't think I'd use it. By the way, just ignore the |
Yes, that's perfect!
Sure! |
@bartomieju released in See here for docs and an example: https://docs.rs/dprint-plugin-typescript/0.3.0-alpha.5/dprint_plugin_typescript/configuration/fn.resolve_config.html Note that all the configuration related stuff has been moved to a Also, in the future this api will be easier to use... this is just stepping stones to the final plugin formatter. Good luck and let me know if you need anything else for this! :) |
Given incredible configuration options dprint has it would be highly desirable to be able to load configuration from a file (probably JSON, or JSONC). I guess using
serde
is the way to go in this case.I'm sure @dsherret already thought about it, but opening the issue for tracking purposes.
The text was updated successfully, but these errors were encountered: