joshuakgoldberg / prettier-plugin-curly Goto Github PK
View Code? Open in Web Editor NEWPrettier plugin to enforce consistent brace style for all control statements. ๐ฅ
License: MIT License
Prettier plugin to enforce consistent brace style for all control statements. ๐ฅ
License: MIT License
main
branch of the repository.Tracking JoshuaKGoldberg/create-typescript-app#734 in this repository.
npx create-typescript-app --mode migrate --author JoshuaKGoldberg --description "Prettier plugin to enforce consistent brace style for all control statements. ๐งน" --email [email protected] --funding JoshuaKGoldberg --owner JoshuaKGoldberg --repository prettier-plugin-curly --title prettier-plugin-curly
main
branch of the repository.if (2) 1
else 2
Is being printed as ...
if (2) { 1;
else 1; }
No response
main
branch of the repository."prettier-plugin-curly": "0.1.3":
This code...
if(document.body)
//Important comment which will be lost!
document.body.append('')
should be transformed to
if(document.body) {
//Important comment which will be lost!
document.body.append('')
}
I get
if(document.body) {
document.body.append('')
}
Same with block comments: /* comment */
main
branch of the repository.Input:
let foo = new Set<string>();
if ('bar') {
} else
foo.add('I am at the wrong position');
expected output
let foo = new Set<string>();
if ('bar') {
} else {
foo.add('I am at the wrong position');
}
let foo = new Set<string>();
if ('bar') {
} else foo.add('I am at the wrong position');
main
branch of the repository.I expected to be able to run pnpm format
with prettier-plugin-curly
on literate-ts.
$ npx prettier src/ts-checker.ts
src/ts-checker.ts
[error] src/ts-checker.ts: SyntaxError: ',' expected. (85:5)
[error] 83 | const start = m.index + 1;
[error] 84 | const end = start + m[1].length;
[error] > 85 | errors.push({line: lastCodeLine, start, end, message});
[error] | ^
[error] 86 | }
[error] 87 | });
[error] 88 | return errors;
Here's the file in question, no syntax errors in sight:
https://github.com/danvk/literate-ts/blob/5d04101f895285d838cb4cdccadc8941c86b0771/src/ts-checker.ts#L85
This was quite confusing because there's nothing in the error message indicating that the error is coming from prettier-plugin-curly
, rather than prettier itself.
main
branch of the repository.Works fine with other prettier plugins like prettier-plugin-organize-imports
.
Can not use this with prettier-plugin-organize-imports
.
Maybe the reason is you are overriding preprocess
?
prettier-plugin-curly/src/index.ts
Lines 8 to 14 in c56f274
Some links may be useful
prettier-plugin-tailwindcss
.main
branch of the repository.A PR was already opened in #28.
No response
main
branch of the repository.Should parse and format
const a =1
const a=1
Cannot parse and breaks formatting
We should use prettier's parser. import from prettier/parser-babel
PR later
main
branch of the repository.Given code like:
for (; i < lines.length && lines[i] !== until; i++);
I'd expect no changes, as the ;
indicates the for
's body is an intentionally empty statement
It gets changed to:
for (; i < lines.length && lines[i] !== until; i++) {}
Seen when verifying #309 works on @danvk's https://github.com/danvk/literate-ts/blob/5d04101f895285d838cb4cdccadc8941c86b0771/src/ts-checker.ts#L85 as referenced by #284.
Thanks again @danvk for using the plugin & filing the issue! ๐
main
branch of the repository.Comments should survive "as they are"
//pre comment
if (true)
//pre branch comment
console.log('hurray')
//post comment
should get
//pre comment
if (true) {
//pre branch comment
console.log('hurray')
}
//post comment
Formatting results in:
//pre comment
//pre comment
if (true) {
//pre branch comment
console.log('hurray');
}
//post comment
//post comment
ref #179
main
branch of the repository.No error in console when installing packages including this package.
Remove this line -
prettier-plugin-curly/package.json
Line 15 in 1c2616f
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.