I'm a web developer.
- ๐จโ๐ป My projects are available at https://portfolio.neoki.me
- ๐ง My tech blog for Japanese is available at https://techblog.neoki.me
- ๐ My articles for Japanese are available at https://zenn.dev/ot07
A Prettier plugin for formatting imports in Astro files
Home Page: https://www.npmjs.com/package/prettier-plugin-astro-organize-imports
License: MIT License
I'm a web developer.
---
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] 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
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).
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 />
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}
/>
)
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.