-
Notifications
You must be signed in to change notification settings - Fork 13
give option to avoid reformatting code or at least respect prettier rc in project root #40
Comments
Can you be specific about which part you are referring to and what you had to comment out? |
So sorry for being so vague, I modified these 2 lines with as minimum impact as possible (though this makes the formatFile function redundant, I didn't want to break anything and then fix it): codemods/lib/global/utils/format-code.js Line 11 in 89429aa
so from this: const formatFile = async (path) => {
try {
const fileContent = await readFile(path, 'utf-8');
// Format the code with prettier
return writeFile(
path, prettier.format(fileContent, {
filepath: path,
})
);
} catch (error) {
logger.warn(`Failed to format code, check ${path}`);
}
}; to this: const formatFile = async (path) => {
try {
const fileContent = await readFile(path, 'utf-8');
// Format the code with prettier
return writeFile(
path, fileContent
// prettier.format(fileContent, {
// filepath: path,
// })
);
} catch (error) {
logger.warn(`Failed to format code, check ${path}`);
}
}; This was causing a lot of undesired results. We tried to use an |
Good point. I'm starting to think we should probably just remove the formatting and leave that up to the end user. I think the format function is only called in one spot so the clean up should be pretty quick. |
@emahuni are you willing to submit a PR to remove the code formatting? If so I can review it and merge it in as I agree with Mark here that we should just get rid of it. |
I have created the pull request |
I didn't remove the prettierrc file, not sure what it is used for, since any edits didn't seem to affect the code formatting I was after. You are free to remove any changes to it or it altogether if you understand why it's there and if it was supposed to work in tandem with the code formatting we are removing. |
There are coding conventions that teams follow that this mod is assuming as THE standard. However, it should be to the engineer what to transform. So give them the option to disable reformatting of code by both disabling prettier completely and/or using prettier .prettierrc.js file... in project root.
I had to fork and comment out the line that formats the code.
The text was updated successfully, but these errors were encountered: