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

Control over comment line indentation #663

Open
jasonkuhrt opened this issue Sep 17, 2024 · 0 comments
Open

Control over comment line indentation #663

jasonkuhrt opened this issue Sep 17, 2024 · 0 comments

Comments

@jasonkuhrt
Copy link

When working with Twoslash there is a special syntax for highlighting text (not whole lines but segments within) https://twoslash.netlify.app/refs/notations#highlighting. My issue with dprint right now is that it makes the Twoslash notation difficult to use.

Here is an example where I'm hitting friction:

// dprint-ignore
const atlas = Atlas
  .create({
    output: {
      envelope: {
        errors: {
          execution: false,
          other: false, // default
        }
      },
    },
  })
  .anyware(({ encode: _ }) => {
    throw new Error(`Something went wrong.`)
  //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  })

Notice that I have to resort to disabling dprint for most of the code to get the highlighting effect I want. Not ideal and I'd like a more localized solution.

Here are some ideas:

Firstly: add a rule e.g. comment-line-indentation-start firstly to control this formatting which the following ideas rely on.

  1. Allow a module-level directive that disables the comment line formatting. E.g. // dprint-ignore comment-line-indentation-start. I don't want to apply this rule to the whole codebase.

  2. Allow a project-wide rule but constricted by a glob e.g.:

    {
      rule: 'comment-line-indentation-start',
      files: './examples/**/*',
    },
    
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

No branches or pull requests

1 participant