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

feat: add config option to place operators at the beginning of line #14475

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

magdalipka
Copy link

@magdalipka magdalipka commented Mar 9, 2023

Description

Added config option to place operators at the beginning of line #3806 .

Defaut option is at the end of line for backward compatibility. User can place operatorPosition: "beginning" to place operators at the beginning of line.

Checklist

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

@17LingShan
Copy link

hey, I am new here. I just use prettier@3.0.1 which is the latest version on npm in 7/8/2023. but my code can't be format when I write the .prettierrc.js like this:

module.exports = {
  operatorPosition: 'beginning',
  tabWidth: 2, 
  printWidth: 80, 
  useTabs: false, 
  semi: false, 
  arrowParens: 'avoid',
  singleQuote: true, 
  bracketSpacing: true,
  bracketSameLine: true,
  trailingComma: 'none', 
  operatorPosition: 'beginning',
  overrides: [
    {
      files: '*.json',
      options: {
        printWidth: 140
      }
    }
  ]
}

and my eslint has already set the content:

module.exports = {
...
  rules: {
...
    'operator-linebreak': [2, 'before']
...
  },
...
}

my code still like this:

     let a =
        12312323 +
        324213324 +
        12324324324 +
        312312312111111111111 +
        11111111111111111111 +
        11111111111111111111111111111 +
        1

operatorPosition is not work, is my mistake or a bug?

@magdalipka
Copy link
Author

@12ling

hey, I am new here. I just use prettier@3.0.1 which is the latest version on npm in 7/8/2023.

This option has not been merged, you would need to use https://www.npmjs.com/package/@btmills/prettier.

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

Successfully merging this pull request may close these issues.

None yet

2 participants