Giter Club home page Giter Club logo

prettier-plugin-curly's Issues

๐Ÿ›  Tooling: Migrate to create-typescript-app@1

Bug Report Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have pulled the latest main branch of the repository.
  • I have searched for related issues and found none that matched my issue.

Overview

Tracking JoshuaKGoldberg/create-typescript-app#734 in this repository.

Additional Info

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

๐Ÿ› Bug: comments are removed on prettier run

Bug Report Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have pulled the latest main branch of the repository.
  • I have searched for related issues and found none that matched my issue.

Expected

"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('')
}

Actual

I get

if(document.body) {
  document.body.append('')
}

Additional Info

Same with block comments: /* comment */

๐Ÿ› Bug: else branch with function call is not curlified

Bug Report Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have pulled the latest main branch of the repository.
  • I have searched for related issues and found none that matched my issue.

Expected

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');
}

Actual

let foo = new Set<string>();
if ('bar') {
} else foo.add('I am at the wrong position');

๐Ÿ› Bug: prettier-plugin-curly crashes on nested if statements

Bug Report Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have pulled the latest main branch of the repository.
  • I have searched for related issues and found none that matched my issue.

Expected

I expected to be able to run pnpm format with prettier-plugin-curly on literate-ts.

Actual

$ 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;

Additional Info

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.

๐Ÿ› Bug: prettier plugin collision

Bug Report Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have pulled the latest main branch of the repository.
  • I have searched for related issues and found none that matched my issue.

Expected

Works fine with other prettier plugins like prettier-plugin-organize-imports.

Actual

Can not use this with prettier-plugin-organize-imports.

Additional Info

Maybe the reason is you are overriding preprocess?

babel: {
...babel.parsers.babel,
preprocess,
},
typescript: {
...typescript.parsers.typescript,
preprocess,

Some links may be useful

๐Ÿ› Bug: cannot parse code includes syntax errors

Bug Report Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have pulled the latest main branch of the repository.
  • I have searched for related issues and found none that matched my issue.

Expected

Should parse and format

const a =1
const a=1

Actual

Cannot parse and breaks formatting

Additional Info

We should use prettier's parser. import from prettier/parser-babel

PR later

๐Ÿ› Bug: Replaces ; (empty statement) with {} (block statement)

Bug Report Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have pulled the latest main branch of the repository.
  • I have searched for related issues and found none that matched my issue.

Expected

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

Actual

It gets changed to:

for (; i < lines.length && lines[i] !== until; i++) {}

Additional Info

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! ๐Ÿ˜„

๐Ÿ› Bug: comments are duplicated on prettier run

Bug Report Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have pulled the latest main branch of the repository.
  • I have searched for related issues and found none that matched my issue.

Expected

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

Actual

Formatting results in:

//pre comment

//pre comment
if (true) {
    //pre branch comment
    console.log('hurray');
}
//post comment
//post comment

Additional Info

ref #179

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.