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

string-enum ignores comments #44

Open
havenchyk opened this issue Oct 20, 2021 · 6 comments
Open

string-enum ignores comments #44

havenchyk opened this issue Oct 20, 2021 · 6 comments

Comments

@havenchyk
Copy link

I noticed that string-enum rule ignores comments, so if you have comments on the right like

enum Events {
  MyEvent2 = 'My Event 2' // my event 2
  MyEvent1 = 'My Event 1' // my event 1

will become

enum Events {
  MyEvent1 = 'My Event 1' // my event 2
  MyEvent2 = 'My Event 2' // my event 1

which is wrong

Do you want to accept a PR for it?

@infctr
Copy link
Owner

infctr commented Oct 20, 2021

@havenchyk
Will appreciate a PR

@RodrigoMural
Copy link

RodrigoMural commented Feb 18, 2022

I'm noticing the same thing with function props, is the PR in place?

@BenJackGill
Copy link

BenJackGill commented Sep 29, 2023

I'm noticing the same thing with interfaces.

The comment does not move with the property.

For example, we start with this interface that has unsorted keys.

interface Foo {
    zoo: number;
    bar: number; // I am a comment for the "bar" property
}

Using the autofix it will be incorrectly formatted to this. Note that the interfaces keys are now correctly sorted but the comment did not move so it is now in the wrong spot.

interface Foo {
    bar: number;
    zoo: number; // I am a comment for the "bar" property
}

I was expecting this to happen. The interface keys are correctly sorted and the comment has moved also.

interface Foo {
    bar: number; // I am a comment for the "bar" property
    zoo: number;
}

@ChrisWiles
Copy link

yeah, unfortunately this is a deal breaker for many people

@BenJackGill
Copy link

I keep coming up against this problem for comments on Interfaces. @havenchyk did your PR go anywhere?

@BenJackGill
Copy link

I am now using the amazing eslint-plugin-perfectionist for the same purpose.

It has alphabetical or natural sorting. Sorts everything; Interfaces, Objects, ect. Handles comments and more gracefully. Also very configurable to your exact needs.

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

5 participants