Skip to content
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

Formatting code will make it unreadable #1926

Open
zanminkian opened this issue Jul 25, 2023 · 0 comments
Open

Formatting code will make it unreadable #1926

zanminkian opened this issue Jul 25, 2023 · 0 comments

Comments

@zanminkian
Copy link

What version of this package are you using?
17.1.0

What operating system, Node.js, and npm version?
node16
pnpm8

What happened?

export function foo (num) {
  if (typeof num !== 'number') throw new Error('Type wrong')
  if (num > 0)
    return 'great than 0'
  else if (num < 0)
    return 'less than 0'
  else
    return 'equal to 0'
}

Formatting code above will make the code become hard to read.

export function foo (num) {
  if (typeof num !== 'number') throw new Error('Type wrong')
  if (num > 0) { return 'great than 0' } else if (num < 0) { return 'less than 0' } else { return 'equal to 0' }
}

What did you expect to happen?
I hope this tool format the code into:

export function foo (num) {
  if (typeof num !== 'number') throw new Error('Type wrong')
  if (num > 0) {
    return 'great than 0'
  } else if (num < 0) {
    return 'less than 0'
  } else {
    return 'equal to 0'
  }
}

Are you willing to submit a pull request to fix this bug?
Yes.
Modifying "brace-style": ["error", "1tbs", { "allowSingleLine": true }], to "brace-style": ["error", "1tbs", { "allowSingleLine": false }], will fix this bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant