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

"formatExports": true doesn't sort exports!! #79

Open
georgekrax opened this issue Aug 29, 2022 · 4 comments
Open

"formatExports": true doesn't sort exports!! #79

georgekrax opened this issue Aug 29, 2022 · 4 comments
Labels
duplicate This issue or pull request already exists question Further information is requested

Comments

@georgekrax
Copy link

Describe the bug
When I run the extension in any file of my project, the extension does not sort the export statements! I have enabled the "configuration.formatExports": true, but still nothing changes.

However, it sorts the import statements very well!

To Reproduce

  1. Go to settings.json
  2. Add the following line: "tsImportSorter.configuration.formatExports": true
  3. Go to an index.ts file of yours that exports lots of components or variables, and through the Command Palette run Sort Imports/Exports
  4. See that the export statements remain in the same order, and don't change alphabetically

Expected behavior
I would expect that the export statements are sorted too, by their paths names.

Screenshots

Actual behavior

image

Expected behavior

image

OS (please complete the following information):

  • OS: Windows 11
  • Version: 22H2

VS Code (please complete the following information):

  • Version: 1.70.2

package.json

{
  "name": "next-commerce",
  "version": "0.0.1",
  "license": "MIT",
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "analyze": "BUNDLE_ANALYZE=both next build",
    "lint": "next lint",
    "prettier-fix": "prettier --write .",
    "find:unused": "npx next-unused"
  },
  "sideEffects": false,
  "dependencies": {
    "@chakra-ui/react": "1.8.8",
    "@emotion/react": "11",
    "@emotion/styled": "11",
    "@radix-ui/react-dropdown-menu": "^0.1.6",
    "@react-spring/web": "^9.4.1",
    "@vercel/commerce": "^0.0.1",
    "@vercel/commerce-bigcommerce": "^0.0.1",
    "@vercel/commerce-local": "^0.0.1",
    "autoprefixer": "^10.4.2",
    "body-scroll-lock": "^4.0.0-beta.0",
    "clsx": "^1.1.1",
    "email-validator": "^2.0.4",
    "framer-motion": "6",
    "js-cookie": "^3.0.1",
    "keen-slider": "^6.6.3",
    "lodash.random": "^3.2.0",
    "lodash.throttle": "^4.1.1",
    "next": "^12.0.8",
    "next-themes": "^0.0.15",
    "postcss": "^8.3.5",
    "postcss-nesting": "^8.0.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-fast-marquee": "^1.3.1",
    "react-merge-refs": "^1.1.0",
    "react-use-measure": "^2.1.1",
    "sass": "^1.54.5",
    "tabbable": "^5.2.1",
    "tailwindcss": "^3.0.13"
  },
  "devDependencies": {
    "@next/bundle-analyzer": "^12.0.8",
    "@types/body-scroll-lock": "^3.1.0",
    "@types/js-cookie": "^3.0.1",
    "@types/lodash.random": "^3.2.6",
    "@types/lodash.throttle": "^4.1.6",
    "@types/node": "^18.7.13",
    "@types/react": "^18.0.17",
    "eslint": "^8.6.0",
    "eslint-config-next": "^12.0.8",
    "eslint-config-prettier": "^8.3.0",
    "lint-staged": "^12.1.7",
    "postcss-flexbugs-fixes": "^5.0.2",
    "postcss-preset-env": "^7.2.3",
    "prettier": "^2.7.1",
    "typescript": "4.8.2"
  },
  "lint-staged": {
    "**/*.{js,jsx,ts,tsx}": [
      "eslint",
      "prettier --write",
      "git add"
    ],
    "**/*.{md,mdx,json}": [
      "prettier --write",
      "git add"
    ]
  },
  "next-unused": {
    "alias": {
      "@lib/*": [
        "lib/*"
      ],
      "@styles/*": [
        "styles/*"
      ],
      "@modules/*": [
        "modules/*"
      ],
      "@config/*": [
        "config/*"
      ],
      "@components/*": [
        "components/*"
      ],
      "@utils/*": [
        "utils/*"
      ]
    },
    "debug": true,
    "include": [
      "components",
      "lib",
      "pages"
    ],
    "exclude": [],
    "entrypoints": [
      "pages"
    ]
  }
}

tsconfig.json (if any)

{
  "compilerOptions": {
    "baseUrl": ".",
    "target": "esnext",
    "module": "esnext",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "paths": {
      "@lib/*": ["lib/*"],
      "@utils/*": ["utils/*"],
      "@config/*": ["config/*"],
      "@styles/*": ["styles/*"],
      "@modules/*": ["modules/*"],
      "@components/*": ["components/*"],
      "@commerce": ["../packages/commerce/src"],
      "@commerce/*": ["../packages/commerce/src/*"],
      "@framework": ["..\\packages\\local\\src"],
      "@framework/*": ["..\\packages\\local\\src/*"]
    }
  },
  "include": ["next-env.d.ts", "**/*.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"],
  "exclude": ["node_modules"]
}

.prettierrc/.prettierrc.js/prettier.config.js/.prettierrc.toml (if any)
filename: .prettierrc

{
  "semi": true,
  "trailingComma": "es5",
  "singleQuote": false,
  "printWidth": 100,
  "tabWidth": 2,
  "arrowParens": "avoid",
  "bracketSpacing": true
}
@daidodo daidodo added duplicate This issue or pull request already exists not-an-issue This is not an issue labels Aug 30, 2022
@daidodo
Copy link
Owner

daidodo commented Aug 30, 2022

@georgekrax Thanks for your feedback!

There was a similar issue before (#43):

Details about how exports are formatted can be found #6 (comment). And sorting exports by paths is not supported yet because the requirement isn't clear.

But still, I'm open to suggestions and ideas.

@daidodo daidodo added question Further information is requested and removed not-an-issue This is not an issue labels Aug 30, 2022
@georgekrax
Copy link
Author

@daidodo Oh okay, thanks for the update!

Do you plan to support a "sorting exports" feature?

@daidodo
Copy link
Owner

daidodo commented Aug 31, 2022

Depends on how clear the requirements are.

Exports can be at the front, middle or end of the file. There is no standard about how they should be organised, AFAIK.

@georgekrax
Copy link
Author

Well, that is a reasonable question from your side.

I would use this feature (sorting exports) only on index.ts files, where I export only a chunk of various components/variables/types. Only in that case I would find it useful, as in the pictures above that I have attached. Otherwise, I believe it wouldn't matter to sort them.

settings.json

"editor.codeActionsOnSave": {
    "source.organizeImports": true
}

If I enable the default/automatic sorting imports functionality of VS Code, then it also sorts the exports!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants