Giter Club home page Giter Club logo

prettier-plugin-astro-organize-imports's Introduction

prettier-plugin-astro-organize-imports's People

Contributors

dependabot[bot] avatar neokidev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

risu729

prettier-plugin-astro-organize-imports's Issues

import from <script> tag is moved to the top of the file

---
import A from 'a' 
import B from 'a'
---

<div>test</div>

<script>
import {isOpen} from '../store.ts'
</script>

in case above import from store.ts will be moved to the top of the file, while ideally it should remain inside script tag.

Use case: when using nanostore library inside .astro components.

Error when used with `prettier-plugin-tailwindcss`

[error] src/components/xxx: InvalidDocError: Unexpected doc 'undefined', 
[error] Expected it to be 'string' or 'object'.
[error]     at traverseDoc
[error]     at propagateBreaks
[error]     at printDocToString
[error]     at coreFormat
[error]     at async formatWithCursor
[error]     at async formatFiles
[error]     at async main
[error]     at async Module.run

Organize imports inside <script> tags

At the moment, this plugin successfully organizes imports inside component scripts, but fails to do so in <script> tags.

---
// These are organized
import { foo } from "foo";
import { bar } from "bar";
---

<script>
  // These are not organized
  import { foo } from "foo";
  import { bar } from "bar";
</script>

It would be nice if this plugin could organize both component script imports as well as <script> imports when formatting an .astro file.

When running "Organize imports" manually from VSCode with the cursor positioned inside the <script> section, VSCode organizes the <script> imports instead of the component script imports (messing up the indentation in the process).

Sort Order of paths with same starting string

Input

---
import LogoInverted from '@assets/logo-inverted.svg';
import Logo from '@assets/logo.svg';
---

<Logo />
<LogoInverted />

Expected

---
import Logo from '@assets/logo.svg';
import LogoInverted from '@assets/logo-inverted.svg';
---

<Logo />
<LogoInverted />

Actual

---
import LogoInverted from '@assets/logo-inverted.svg';
import Logo from '@assets/logo.svg';
---

<Logo />
<LogoInverted />

ts import automatically removed

First of all, thanks a lot for creating this!

I'm running into the issue of my import statement being removed, eventhough it is used:

---
import { serialize } from '../scripts/richtext'

interface Props {
  rich: any
  class?: string
}

const { rich, class: className } = Astro.props
---

{
  rich && (
    <section
      class="rich frame-float max-w-3xl"
      set:html={serialize(rich?.root?.children)}
    />
  )
}

When doing this it is not removed:

---
import { serialize } from '../scripts/richtext'

interface Props {
  rich: any
  class?: string
}

const { rich, class: className } = Astro.props

const html = serialize(rich?.root?.children)
---

{
  rich && (
    <section
      class="rich frame-float max-w-3xl"
      set:html={html}
    />
  )
}

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.