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

Feature: sort items shared a same length after sort by line-length #429

Open
2 tasks done
ntnyq opened this issue Dec 22, 2024 · 6 comments · May be fixed by #457
Open
2 tasks done

Feature: sort items shared a same length after sort by line-length #429

ntnyq opened this issue Dec 22, 2024 · 6 comments · May be fixed by #457
Labels
enhancement New feature or request

Comments

@ntnyq
Copy link

ntnyq commented Dec 22, 2024

What rule do you want to change?

any rule

Describe the problem

I checked docs of sort-exports and didn't found any option to make it possible to sort items shared a same length to a certain order after sort by line-length.

May be we should add a new option?

Code example

export * from './sortAttrs'
export * from './prefixIds'
export * from './cleanupIds'
export * from './mergePaths'
export * from './removeDesc'
export * from './reusePaths'
export * from './removeTitle'
export * from './mergeStyles'
export * from './removeXMLNS'
export * from './removeXlink'
export * from './removeAttrs'
export * from './inlineStyles'
export * from './cleanupAttrs'
export * from './minifyStyles'
export * from './convertColors'
export * from './presetDefault'
export * from './removeDoctype'
export * from './removeViewBox'
export * from './removeComments'
export * from './removeMetadata'
export * from './collapseGroups'
export * from './removeUnusedNS'
export * from './removeEmptyText'
export * from './convertPathData'
export * from './removeDimensions'
export * from './convertTransform'
export * from './sortDefsChildren'
export * from './removeEmptyAttrs'
export * from './removeHiddenElems'
export * from './removeUselessDefs'
export * from './removeXMLProcInst'
export * from './removeStyleElement'
export * from './removeRasterImages'
export * from './convertShapeToPath'
export * from './removeEditorsNSData'
export * from './convertStyleToAttrs'
export * from './removeEditorsNSData'
export * from './removeScriptElement'
export * from './cleanupListOfValues'
export * from './removeElementsByAttr'
export * from './cleanupNumericValues'
export * from './removeOffCanvasPaths'
export * from './moveElemsAttrsToGroup'
export * from './moveGroupAttrsToElems'
export * from './removeDeprecatedAttrs'
export * from './removeEmptyContainers'
export * from './convertEllipseToCircle'
export * from './addClassesToSVGElement'
export * from './convertOneStopGradients'
export * from './cleanupEnableBackground'
export * from './removeUnknownsAndDefaults'
export * from './addAttributesToSVGElement'
export * from './removeUselessStrokeAndFill'
export * from './removeAttributesBySelector'
export * from './removeNonInheritableGroupAttrs'

Additional comments

No response

Validations

  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
@ntnyq ntnyq added the enhancement New feature or request label Dec 22, 2024
@ntnyq ntnyq changed the title How can I sort items shared a same length after sort by line-length Feature: sort items shared a same length after sort by line-length Dec 22, 2024
@hugop95
Copy link
Contributor

hugop95 commented Dec 22, 2024

The current behavior is to allow the user to place same-length items in the order that they want, I think that we should keep that by default.

I don't think that there is a need to add a complex fallback sorting behavior for items with the same length. I assume that most use cases would be to sort items of the same length alphabetically?

@ntnyq
Copy link
Author

ntnyq commented Dec 22, 2024

Yeah, I prefer to sort same length items alphabetically too. But currently the plugin just leave it as it is.

@hugop95
Copy link
Contributor

hugop95 commented Dec 23, 2024

I'll see what's the best way to integrate such an option.

@hugop95
Copy link
Contributor

hugop95 commented Jan 12, 2025

Still trying to find the best way to implement this.

Requirement: fallback configuration must handle at least:

  • type setting.
  • order setting.

Possible solutions:

  • Add a fallbackConfiguration: { order, type } option. Con: not very explicit at what it's doing.
  • Allow users to do
{
  sort: [
    {
      type: 'line-length',
      order: 'desc'
    },
    {
      type: 'alphabetical',
      order: 'asc'
    },
  ]
}

Con: distinct from the existing type and order attributes.

  • Allow users to do
{
  type: ['line-length', 'alphabetical'],
  order: ['desc', 'asc']
}

Pros: Explicit.
Con: primary and fallback configurations are mixed into the same attributes.

@ntnyq
Copy link
Author

ntnyq commented Jan 16, 2025

I prefer the fallbackConfiguration way since this option is an optional enhancement only for sort type is set to line-length.

And maybe we should find a more semantic option name for it.

@hugop95
Copy link
Contributor

hugop95 commented Jan 17, 2025

this option is an optional enhancement only for sort type is set to line-length.

This feature is also a hard requirement for Feature: sort-modules in order of use #434
. It is possible that users might want to sort by

order of use > line-length > alphabetical.

In which case, we should be able to handle a list of fallback configurations.

@hugop95 hugop95 linked a pull request Jan 31, 2025 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants