npx prettier --write --tab-width 2 "**/*.ts"
to format the code in 2 spaces, but it also makes other changes like changing single quotes by double quotes...I was a graphic designer in a previous career and have some knowledge around typography and design. Is there any way prettier could format based off consistency within the file / block as opposed to line by line. So instead of some lines being broken, it finds consistency with previous lines.
So you end up with this:
const foo = ({ polo }) => {
const functionOne = () => myArray.map(item => (item.something === polo))
const functionTwo = () => myArrayWithLongerName.map(item => (item.somethingElse === polo))
const functionThree = () => myArrayWithLongerName.map(item => (item.somethingElse === polo))
return [ ...functionOne, ...functionTwo, ...functionThree ]
}
or this:
const foo = ({ polo }) => {
const functionOne = () => myArray.map(
item => (item.something === polo)
)
const functionTwo = () => myArrayWithLongerName.map(
item => (item.somethingElse === polo)
)
const functionThree = () => myArrayWithLongerName.map(
item => (item.somethingElse === polo)
)
return [ ...functionOne, ...functionTwo, ...functionThree ]
}
instead of this:
const foo = ({ polo }) => {
const functionOne = () => myArray.map(item => (item.something === polo))
const functionTwo = () => myArrayWithLongerName.map(
item => (item.somethingElse === polo)
)
const functionThree = () => myArrayWithLongerName.map(
item => (item.somethingElse === polo)
)
return [ ...functionOne, ...functionTwo, ...functionThree ]
}
Shouldn't prettier avoid formatting <pre> content? It doesn't seem to be doing that though.
npx prettier --no-config file.xml
and it outputs
<root
xmlns="urn:schemas-upnp-org:device-1-0"
xmlns:r="urn:restful-tv-org:schemas:upnp-dd"
>
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<device>
<deviceType>urn:schemas-upnp-org:device:tvdevice:1</deviceType>
<friendlyName>harman/kardon</friendlyName>
<manufacturer> </manufacturer>
<modelName>BDS</modelName>
<UDN>uuid:a72dec90-f668-11de-8000-001c5022d4ad</UDN>
</device>
</root>