# import-sort-style-wes

> Wes' personal import-sort style

Latest version **3.0.2** (published 2020-03-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install import-sort-style-wes
pnpm add import-sort-style-wes
yarn add import-sort-style-wes
bun add import-sort-style-wes
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.2 |
| Published | 2020-03-17 |
| First published | 2019-12-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 17 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Wes Souza |
| Maintainers | wessouza |
| Keywords | grouped, import order, import-sort-style, import-sort, import, order, sort |

## Links

- npm: https://www.npmjs.com/package/import-sort-style-wes
- Repository: https://github.com/WesSouza/import-sort-style-wes
- npm.io page: https://npm.io/package/import-sort-style-wes

## Recent versions

- 3.0.2 (latest) — 2020-03-17
- 3.0.1 — 2020-03-17
- 3.0.0 — 2020-02-21
- 2.0.0 — 2020-02-18
- 1.0.1 — 2019-12-26

## README

# import-sort-style-wes

Wes' personal style for [import-sort](https://github.com/renke/import-sort).

## Sorting Example

```js
// Modules without members
import '@scoped/module';
import 'first-module';
import 'second-module';
import '~/local-module';

// Installed and scoped modules
import scoped from '@scoped/thing';
import whatever from 'module-a';
import anything from 'module-b';

// Local resolved modules
import exported from '~/project-root-file';

// Siblings and parents
import things from '../grand-parent';
import name from '../parent';
import sibling from './sibling';
```

## Why `~`?

Not all characters can be used at a module path, because of `npm` registry
rules, and file system constraints. `npm` already uses the `@` prefix to scope
organizations and teams.

Inspired by [Parcel](https://parceljs.org), which resolves `~` to the project
source directory by default, I decided to define `~` as the de facto reference
for all of my packages root source directories.

Some projects prefer to have every folder on the project source as its own
resolve alias. I find this bad especially for use cases like this, where one
would need to read the file system to determine if an import is within
`node_modules` or the project's source folder. Given that these can be
configured in a multitude of ways, I decided to not support that at all.

## Usage

These instrutions use [prettier](https://prettier.io), which is my preferred
method of enforcing import sort order.

```sh
# Install prettier-plugin-import-sort
yarn add -D prettier-plugin-import-sort

# Install import-sort-style-wes
yarn add -D import-sort-style-wes
```

Then add on your root `package.json`:

```json
{
  "importSort": {
    ".js, .jsx": {
      "parser": "babylon",
      "style": "wes"
    },
    ".ts, .tsx": {
      "parser": "typescript",
      "style": "wes"
    }
  }
}
```

## Development

I've used [yarn](https://yarnpkg.com/en/), and
[tsdx](https://github.com/jaredpalmer/tsdx), which provides scaffolding for
TypeScript libraries.

```sh
# Install yarn, if you don't have it
curl -o- -L https://yarnpkg.com/install.sh | bash

# Install dependencies
yarn install

# Build upon changes (development mode)
yarn run dev

# Lint code
yarn run lint

# Test code
yarn run test

# Build code
yarn run build
```

## License

MIT, https://wes.dev/LICENSE.txt

---
_Source: https://npm.io/package/import-sort-style-wes · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
