Git Product home page Git Product logo

sort-js-object's People

Contributors

debens avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

cemysf

sort-js-object's Issues

feature request(s): sort on save

hi there! this extension is pretty much exactly what i'm looking for to sort my react-native StyleSheet objects, but i'd love to see the addition of sort on save so that i don't have to select the object that needs sorting and hit the hotkey. i think this is possible for my use-case, because my styles are in their own isolated file (styles.js), which only exports the return of the StyleSheet.create() method. an example of a file i'd like to use this with is below:

import { StyleSheet } from 'react-native';

export default StyleSheet.create({
    foo: {
        textAlign: 'center',
        position: 'absolute',
        left: 0,
        right: 0,
        top: 0,
        bottom: 0,
        flexDirection: 'row',
        alignItems: 'center',
        fontSize: 16,
    },
    bar: {
        textAlign: 'center',
        backgroundColor: '#f00',
    },
});

once saved, the extension would auto-sort/save to have the file look like below:

import { StyleSheet } from 'react-native';

export default StyleSheet.create({
    bar: {
        backgroundColor: '#f00',
        textAlign: 'center',
    },
    foo: {
        alignItems: 'center',
        bottom: 0,
        flexDirection: 'row',
        fontSize: 16,
        left: 0,
        position: 'absolute',
        right: 0,
        textAlign: 'center',
        top: 0,
    },
});

i would love to be able to use this extension on these styles.js files only, and be able to have the extension know i'm on this specific filename+extension and to look for the object within the StyleSheet.create() method and run it's sort when i save the file. i'm not versed in vscode extension creation and your extension has ~ 90% of what i'm looking for, so i'd love to see this get implemented! i'd be willing to test anything at a moment's notice, since this is something myself and my team are clamoring for! thanks so much again!

Feature request: keep trailing commas and maintain line placement of spread objects

Thanks for the great extension! Here are a couple of feature requests. Curious about feasibility and would happily contribute to get these in!

I think the trailing commas one is self-explanatory. Would be great if this was configurable.

For the line placement of spread objects, my issue is that

const myObject = {
  key1: {
    ...someOtherObject,
    a: 1
  }
}

turns into

const myObject = {
  key1: { ...someOtherObject,
    a: 1
  }
}

when ideally it would stay the same, with the spread object on its own line.

[BUG] Fails to run every single time

Description

Every time I try to run, either via hotkey or command, I get the following error:
Failed to parse text: $OBJ

Example

Failed to parse text: { h: 1080, w: 1920, }

Environment

macOS Big Sur 11.6 (20G165)
VSC 1.62.0

Unable to sort highlighted selection, only entire file

First, thanks a ton for creating this extension. Ive been looking for something like it for awhile...

I'm unable to sort the highlighted selection for this object... Even if I place it in it's own file, select the object, and alt + s it returns the Please make sure your selected text is a JS object error. Only if I sort the entire file with ctrl + alt + s does it sort properly. The object is similar to this:

const myObject = {
  foo: (bar) => ({
    ...bar,
    a: true,
  }),
  bazz: (buzz) => ({
    ...buzz,
    b: false,
  })
}

Any insight would be greatly appreciated

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.