Skip to content

Commit

Permalink
feat: initial realease
Browse files Browse the repository at this point in the history
  • Loading branch information
ifiokjr committed Mar 14, 2020
0 parents commit 467bf9f
Show file tree
Hide file tree
Showing 11 changed files with 10,303 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [ifiokjr]
11 changes: 11 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Description

<!-- Describe your changes in detail and reference any issues it addresses-->

## Checklist

<!-- Go over all the following points, and put an `x` in all the boxes that apply. -->

- [ ] My code follows the code style of this project and `yarn lint --fix` runs successfully.
- [ ] I have updated the documentation where necessary.
- [ ] New code is unit tested and all current tests pass when running `yarn test` .
95 changes: 95 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Node CI

on: [push]

env:
CI: true

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x, 12.x]

steps:
- uses: actions/checkout@v1

- name: get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v1
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: setup node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: audit dependencies
run: yarn audit

- name: install dependencies
run: yarn --pure-lockfile

- name: lint files
run: yarn lint

- name: typecheck project
run: yarn tsc --noEmit

- name: run unit tests
run: yarn test --coverage

- name: build project
run: yarn build

- name: upload build artifact
uses: actions/upload-artifact@v1
if: matrix.node-version == '12.x'
with:
name: build
path: dist/

release:
needs: [build]
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

- name: get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v1
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: setup node.js
uses: actions/setup-node@v1
with:
node-version: 12

- name: install dependencies
run: yarn --pure-lockfile

- name: download build artifact
uses: actions/download-artifact@v1
with:
name: build
path: dist/

- name: release with semantic release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: yarn semantic-release
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.log
.DS_Store
node_modules
dist
coverage
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Ifiok Jr.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
155 changes: 155 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
# prettier-plugin-sorted

[![GitHub Actions Build Status](https://github.com/ifiokjr/prettier-plugin-sorted/workflows/Node%20CI/badge.svg)](https://github.com/ifiokjr/prettier-plugin-sorted/actions?query=workflow%3A%22Node+CI%22)
[![Version][version]][npm]
[![Weekly Downloads][downloads-badge]][npm]
[![Typed Codebase][typescript]](./src/index.ts)
![MIT License][license]
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

<br />

> An elegant prettier plugin for sorting your imports. It automatically checks you typescript tsconfig configuration and sorts aliases by default.
<br />

## Table of Contents

- [prettier-plugin-sorted](#prettier-plugin-sorted)
- [Table of Contents](#table-of-contents)
- [Usage](#usage)
- [Setup](#setup)
- [Versioning](#versioning)
- [License](#license)
- [Contributors](#contributors)
- [Acknowledgements](#acknowledgements)

## Usage

`prettier-plugin-sorted` is a [`prettier`](https://prettier.io) plugin for automatically sorting all you JavaScript and TypeScript imports. It uses `import-sort` and allows for a zero configuration setup which should be sufficient for most setups.

Sort the modules in the following order.

- Imports with no members are left unsorted at the top of the file. These tend to have side effects and their order is important. `import 'tolu';`
- Node module imports. `import { join } from 'path';`
- Absolute module imports (but not aliased). `import main from 'main';`
- Aliased imports taken from the `tsconfig.json` and `extraAliases` setting, but excluding `ignoredAliases`.
- Relative module imports.
- Bottom imports, which are set in the settings object as `bottomAliases`. These group together absolute paths with relative, placing the absolute paths above the relative.

An example is shown below.

```ts
// Imports with no members are left unsorted since they may have side effects.
import 'dotenv';
import './my-side-effect';
import 'firebase/auth';

// Built in node module imports come next
import { join } from 'path';

// Absolute imports
import Awesome from 'awesome-package';
import { B, C } from 'bcde';

// Aliased imports
import MyAlias from '@my-alias';
import { Simple } from 'simple';

// Relative imports
import { DeepRelative } from '../../deep/relative';
import Relative from './relative';

// Bottom imports
import Bottom from '@bottom';
import { relativeBottom } from './relative/bottom';
```

<br />

### Setup

First, install the plugin and the required parser:

```bash
npm install --save-dev prettier-plugin-sorted prettier
```

Or if you're using Yarn.

```bash
yarn add -D prettier-plugin-sorted prettier
```

Add the plugin to your `prettier` configuration.

`.prettierrc.json`

```json
{
"plugins": ["prettier-plugin-sorted"]
}
```

Or inside your project's `package.json` file.

```json
{
"prettier": {
"plugins": ["prettier-plugin-sorted"]
}
}
```

If you would like to customise the setup you can add the `importSort` field to you `package.json` file. A better explanation on what each configuration option does is available [**here**](https://github.com/ifiokjr/import-sort-style-custom#options).

```json5
"importSort": {
".js, jsx, .ts, .tsx": {
"options": {
"cacheStrategy": "directory",
"wildcardAtStart": false,
"extraAliases": [],
"ignoredAliases": [],
"bottomAliases": []
}
}
}
```

<br />

## Versioning

This project uses [SemVer](http://semver.org/) for versioning. For the versions available, see the
[tags on this repository](https://github.com/ifiokjr/prettier-plugin-sorted/tags).

<br />

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details

<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->

## Contributors

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

<!-- markdownlint-enable -->
<!-- prettier-ignore-end -->

[version]: https://flat.badgen.net/npm/v/prettier-plugin-sorted
[npm]: https://npmjs.com/package/prettier-plugin-sorted
[license]: https://flat.badgen.net/badge/license/MIT/purple
[size]: https://bundlephobia.com/result?p=#prettier-plugin-sorted
[size-badge]: https://flat.badgen.net/bundlephobia/minzip/prettier-plugin-sorted
[typescript]: https://flat.badgen.net/badge/icon/TypeScript/?icon=typescript&label&labelColor=blue&color=555555
[downloads-badge]: https://badgen.net/npm/dw/prettier-plugin-sorted/red?icon=npm

## Acknowledgements

- This plugin builds on the good work of [`prettier-plugin-import-sort`](https://github.com/ggascoigne/prettier-plugin-import-sort/blob/master/src/index.js) with a sharper focus on typescript projects.

0 comments on commit 467bf9f

Please sign in to comment.