Skip to content

Commit 467bf9f

Browse files
committed
feat: initial realease
0 parents  commit 467bf9f

File tree

11 files changed

+10303
-0
lines changed

11 files changed

+10303
-0
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: [ifiokjr]

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## Description
2+
3+
<!-- Describe your changes in detail and reference any issues it addresses-->
4+
5+
## Checklist
6+
7+
<!-- Go over all the following points, and put an `x` in all the boxes that apply. -->
8+
9+
- [ ] My code follows the code style of this project and `yarn lint --fix` runs successfully.
10+
- [ ] I have updated the documentation where necessary.
11+
- [ ] New code is unit tested and all current tests pass when running `yarn test` .

.github/workflows/ci.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Node CI
2+
3+
on: [push]
4+
5+
env:
6+
CI: true
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
strategy:
13+
matrix:
14+
node-version: [10.x, 12.x]
15+
16+
steps:
17+
- uses: actions/checkout@v1
18+
19+
- name: get yarn cache
20+
id: yarn-cache
21+
run: echo "::set-output name=dir::$(yarn cache dir)"
22+
23+
- uses: actions/cache@v1
24+
with:
25+
path: ${{ steps.yarn-cache.outputs.dir }}
26+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
27+
restore-keys: |
28+
${{ runner.os }}-yarn-
29+
- name: setup node.js ${{ matrix.node-version }}
30+
uses: actions/setup-node@v1
31+
with:
32+
node-version: ${{ matrix.node-version }}
33+
34+
- name: audit dependencies
35+
run: yarn audit
36+
37+
- name: install dependencies
38+
run: yarn --pure-lockfile
39+
40+
- name: lint files
41+
run: yarn lint
42+
43+
- name: typecheck project
44+
run: yarn tsc --noEmit
45+
46+
- name: run unit tests
47+
run: yarn test --coverage
48+
49+
- name: build project
50+
run: yarn build
51+
52+
- name: upload build artifact
53+
uses: actions/upload-artifact@v1
54+
if: matrix.node-version == '12.x'
55+
with:
56+
name: build
57+
path: dist/
58+
59+
release:
60+
needs: [build]
61+
if: github.ref == 'refs/heads/master'
62+
runs-on: ubuntu-latest
63+
steps:
64+
- uses: actions/checkout@v1
65+
66+
- name: get yarn cache
67+
id: yarn-cache
68+
run: echo "::set-output name=dir::$(yarn cache dir)"
69+
70+
- uses: actions/cache@v1
71+
with:
72+
path: ${{ steps.yarn-cache.outputs.dir }}
73+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
74+
restore-keys: |
75+
${{ runner.os }}-yarn-
76+
77+
- name: setup node.js
78+
uses: actions/setup-node@v1
79+
with:
80+
node-version: 12
81+
82+
- name: install dependencies
83+
run: yarn --pure-lockfile
84+
85+
- name: download build artifact
86+
uses: actions/download-artifact@v1
87+
with:
88+
name: build
89+
path: dist/
90+
91+
- name: release with semantic release
92+
env:
93+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
95+
run: yarn semantic-release

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*.log
2+
.DS_Store
3+
node_modules
4+
dist
5+
coverage

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Ifiok Jr.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# prettier-plugin-sorted
2+
3+
[![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)
4+
[![Version][version]][npm]
5+
[![Weekly Downloads][downloads-badge]][npm]
6+
[![Typed Codebase][typescript]](./src/index.ts)
7+
![MIT License][license]
8+
[![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)
9+
10+
<br />
11+
12+
> An elegant prettier plugin for sorting your imports. It automatically checks you typescript tsconfig configuration and sorts aliases by default.
13+
14+
<br />
15+
16+
## Table of Contents
17+
18+
- [prettier-plugin-sorted](#prettier-plugin-sorted)
19+
- [Table of Contents](#table-of-contents)
20+
- [Usage](#usage)
21+
- [Setup](#setup)
22+
- [Versioning](#versioning)
23+
- [License](#license)
24+
- [Contributors](#contributors)
25+
- [Acknowledgements](#acknowledgements)
26+
27+
## Usage
28+
29+
`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.
30+
31+
Sort the modules in the following order.
32+
33+
- 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';`
34+
- Node module imports. `import { join } from 'path';`
35+
- Absolute module imports (but not aliased). `import main from 'main';`
36+
- Aliased imports taken from the `tsconfig.json` and `extraAliases` setting, but excluding `ignoredAliases`.
37+
- Relative module imports.
38+
- 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.
39+
40+
An example is shown below.
41+
42+
```ts
43+
// Imports with no members are left unsorted since they may have side effects.
44+
import 'dotenv';
45+
import './my-side-effect';
46+
import 'firebase/auth';
47+
48+
// Built in node module imports come next
49+
import { join } from 'path';
50+
51+
// Absolute imports
52+
import Awesome from 'awesome-package';
53+
import { B, C } from 'bcde';
54+
55+
// Aliased imports
56+
import MyAlias from '@my-alias';
57+
import { Simple } from 'simple';
58+
59+
// Relative imports
60+
import { DeepRelative } from '../../deep/relative';
61+
import Relative from './relative';
62+
63+
// Bottom imports
64+
import Bottom from '@bottom';
65+
import { relativeBottom } from './relative/bottom';
66+
```
67+
68+
<br />
69+
70+
### Setup
71+
72+
First, install the plugin and the required parser:
73+
74+
```bash
75+
npm install --save-dev prettier-plugin-sorted prettier
76+
```
77+
78+
Or if you're using Yarn.
79+
80+
```bash
81+
yarn add -D prettier-plugin-sorted prettier
82+
```
83+
84+
Add the plugin to your `prettier` configuration.
85+
86+
`.prettierrc.json`
87+
88+
```json
89+
{
90+
"plugins": ["prettier-plugin-sorted"]
91+
}
92+
```
93+
94+
Or inside your project's `package.json` file.
95+
96+
```json
97+
{
98+
"prettier": {
99+
"plugins": ["prettier-plugin-sorted"]
100+
}
101+
}
102+
```
103+
104+
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).
105+
106+
```json5
107+
"importSort": {
108+
".js, jsx, .ts, .tsx": {
109+
"options": {
110+
"cacheStrategy": "directory",
111+
"wildcardAtStart": false,
112+
"extraAliases": [],
113+
"ignoredAliases": [],
114+
"bottomAliases": []
115+
}
116+
}
117+
}
118+
```
119+
120+
<br />
121+
122+
## Versioning
123+
124+
This project uses [SemVer](http://semver.org/) for versioning. For the versions available, see the
125+
[tags on this repository](https://github.com/ifiokjr/prettier-plugin-sorted/tags).
126+
127+
<br />
128+
129+
## License
130+
131+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details
132+
133+
<!-- prettier-ignore-start -->
134+
<!-- markdownlint-disable -->
135+
136+
## Contributors
137+
138+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
139+
140+
<!-- ALL-CONTRIBUTORS-LIST:END -->
141+
142+
<!-- markdownlint-enable -->
143+
<!-- prettier-ignore-end -->
144+
145+
[version]: https://flat.badgen.net/npm/v/prettier-plugin-sorted
146+
[npm]: https://npmjs.com/package/prettier-plugin-sorted
147+
[license]: https://flat.badgen.net/badge/license/MIT/purple
148+
[size]: https://bundlephobia.com/result?p=#prettier-plugin-sorted
149+
[size-badge]: https://flat.badgen.net/bundlephobia/minzip/prettier-plugin-sorted
150+
[typescript]: https://flat.badgen.net/badge/icon/TypeScript/?icon=typescript&label&labelColor=blue&color=555555
151+
[downloads-badge]: https://badgen.net/npm/dw/prettier-plugin-sorted/red?icon=npm
152+
153+
## Acknowledgements
154+
155+
- 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 commit comments

Comments
 (0)