Skip to content

Commit ec82cdf

Browse files
Merge branch 'v6' into pr354
2 parents 8b1f2ba + e663d1d commit ec82cdf

File tree

98 files changed

+2498
-2686
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+2498
-2686
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title: ''
66
assignees: ''
77
---
88

9-
<!-- PLEASE READ THIS:
9+
<!-- PLEASE READ THIS:
1010
- If you are not sure is a bug, OPEN a DISCUSSION, if is a legitimate bug, is easy to create a bug from a discussion.
1111
- Empty reports won't be considered and eventually be closed by a bot.
1212
- Include debugging notes will help to fix it faster.
@@ -18,11 +18,10 @@ assignees: ''
1818
-->
1919

2020
**Your Environment**
21-
22-
- **Prettier version**: 2.x.x
23-
- **node version**: [12.x.x, 14.x.x]
24-
- **package manager**: [npm@7, pnpm@6, yarn@2]
25-
- **IDE**: [VScode, Webstorm, CLI]
21+
* **Prettier version**: 2.x.x
22+
* **node version**: [12.x.x, 14.x.x]
23+
* **package manager**: [npm@7, pnpm@6, yarn@2]
24+
* **IDE**: [VScode, Webstorm, CLI]
2625

2726
**Describe the bug**
2827

@@ -55,7 +54,7 @@ Be aware, the lack of reproducible steps the issue might cause your ticket to be
5554

5655
**Contribute to @trivago/prettier-plugin-sort-imports**
5756

58-
- [ ] I'm willing to fix this bug 🥇
57+
- [ ] I'm willing to fix this bug 🥇
5958

6059
<!--
6160

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
blank_issues_enabled: false
22
contact_links:
3-
- name: Question 🤷🏻‍♂️
4-
url: https://github.com/trivago/prettier-plugin-sort-imports/discussions/new?category=q-a
5-
about: 🆕 Open a new Q&A discussion 🙏
3+
- name: Question 🤷🏻‍♂️
4+
url: https://github.com/trivago/prettier-plugin-sort-imports/discussions/new?category=q-a
5+
about: 🆕 Open a new Q&A discussion 🙏

.github/ISSUE_TEMPLATE/feature.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ A clear and concise description of what you want to happen.
2323
A clear and concise description of any alternative solutions or features you've considered.
2424

2525
**Additional context**
26-
Add any other context or screenshots about the feature request here.
26+
Add any other context or screenshots about the feature request here.

.github/workflows/ci.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
name: ci
22
on: [push, pull_request]
33
jobs:
4-
build:
5-
runs-on: ubuntu-latest
6-
strategy:
7-
matrix:
8-
node: [18.x, 20.x, 22.x]
9-
steps:
10-
- uses: actions/checkout@v4
11-
- uses: actions/setup-node@v4
12-
with:
13-
node-version: ${{ matrix.node }}
14-
- run: yarn --immutable
15-
- run: yarn test
4+
build:
5+
runs-on: ubuntu-latest
6+
strategy:
7+
matrix:
8+
node: [18.x, 20.x, 22.x]
9+
steps:
10+
- uses: actions/checkout@v4
11+
- uses: actions/setup-node@v4
12+
with:
13+
node-version: ${{ matrix.node }}
14+
- run: yarn --immutable
15+
- run: yarn test

.github/workflows/codeql-analysis.yml

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9,62 +9,62 @@
99
# the `language` matrix defined below to confirm you have the correct set of
1010
# supported CodeQL languages.
1111
#
12-
name: 'CodeQL'
12+
name: "CodeQL"
1313

1414
on:
15-
push:
16-
branches: [master]
17-
pull_request:
18-
# The branches below must be a subset of the branches above
19-
branches: [master]
20-
schedule:
21-
- cron: '37 7 * * 0'
15+
push:
16+
branches: [ master ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ master ]
20+
schedule:
21+
- cron: '37 7 * * 0'
2222

2323
jobs:
24-
analyze:
25-
name: Analyze
26-
runs-on: ubuntu-latest
27-
permissions:
28-
actions: read
29-
contents: read
30-
security-events: write
24+
analyze:
25+
name: Analyze
26+
runs-on: ubuntu-latest
27+
permissions:
28+
actions: read
29+
contents: read
30+
security-events: write
3131

32-
strategy:
33-
fail-fast: false
34-
matrix:
35-
language: ['javascript']
36-
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37-
# Learn more about CodeQL language support at https://git.io/codeql-language-support
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
language: [ 'javascript' ]
36+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37+
# Learn more about CodeQL language support at https://git.io/codeql-language-support
3838

39-
steps:
40-
- name: Checkout repository
41-
uses: actions/checkout@v2
39+
steps:
40+
- name: Checkout repository
41+
uses: actions/checkout@v2
4242

43-
# Initializes the CodeQL tools for scanning.
44-
- name: Initialize CodeQL
45-
uses: github/codeql-action/init@v1
46-
with:
47-
languages: ${{ matrix.language }}
48-
# If you wish to specify custom queries, you can do so here or in a config file.
49-
# By default, queries listed here will override any specified in a config file.
50-
# Prefix the list here with "+" to use these queries and those in the config file.
51-
# queries: ./path/to/local/query, your-org/your-repo/queries@main
43+
# Initializes the CodeQL tools for scanning.
44+
- name: Initialize CodeQL
45+
uses: github/codeql-action/init@v1
46+
with:
47+
languages: ${{ matrix.language }}
48+
# If you wish to specify custom queries, you can do so here or in a config file.
49+
# By default, queries listed here will override any specified in a config file.
50+
# Prefix the list here with "+" to use these queries and those in the config file.
51+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
5252

53-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
54-
# If this step fails, then you should remove it and run the build manually (see below)
55-
- name: Autobuild
56-
uses: github/codeql-action/autobuild@v1
53+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
54+
# If this step fails, then you should remove it and run the build manually (see below)
55+
- name: Autobuild
56+
uses: github/codeql-action/autobuild@v1
5757

58-
# ℹ️ Command-line programs to run using the OS shell.
59-
# 📚 https://git.io/JvXDl
58+
# ℹ️ Command-line programs to run using the OS shell.
59+
# 📚 https://git.io/JvXDl
6060

61-
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
62-
# and modify them (or add more) to build your code if your project
63-
# uses a compiled language
61+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
62+
# and modify them (or add more) to build your code if your project
63+
# uses a compiled language
6464

65-
#- run: |
66-
# make bootstrap
67-
# make release
65+
#- run: |
66+
# make bootstrap
67+
# make release
6868

69-
- name: Perform CodeQL Analysis
70-
uses: github/codeql-action/analyze@v1
69+
- name: Perform CodeQL Analysis
70+
uses: github/codeql-action/analyze@v1

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
tests/
22
lib/
3+
examples/
4+
.github/
5+
docs/
6+
*.md

.prettierrc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"printWidth": 80,
3+
"tabWidth": 4,
4+
"trailingComma": "all",
5+
"singleQuote": true,
6+
"bracketSameLine": true,
7+
"semi": true,
8+
"importOrder": ["^[./]"],
9+
"importOrderSeparation": true,
10+
"importOrderSortSpecifiers": true,
11+
"plugins": [
12+
"prettier-plugin-ember-template-tag",
13+
"prettier-plugin-svelte",
14+
"./lib/src/index.js"
15+
]
16+
}

README.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import React, {
1515
KeyboardEvent,
1616
} from 'react';
1717
import { logger } from '@core/logger';
18-
import { reduce, debounce } from 'lodash';
18+
import { reduce, debounce } from 'lodash-es';
1919
import { Message } from '../Message';
2020
import { createServer } from '@server/node';
2121
import { Alert } from '@ui/Alert';
@@ -28,7 +28,7 @@ import { createConnection } from '@server/database';
2828
### Output
2929

3030
```javascript
31-
import { debounce, reduce } from 'lodash';
31+
import { debounce, reduce } from 'lodash-es';
3232
import React, {
3333
ChangeEvent,
3434
FC,
@@ -52,18 +52,24 @@ import { add, filter, repeat } from '../utils';
5252

5353
### Install
5454

55-
npm
55+
using npm
5656

5757
```shell script
5858
npm install --save-dev @trivago/prettier-plugin-sort-imports
5959
```
6060

61-
or, using yarn
61+
using yarn
6262

6363
```shell script
6464
yarn add --dev @trivago/prettier-plugin-sort-imports
6565
```
6666

67+
using pnpm
68+
69+
```shell script
70+
pnpm add -D @trivago/prettier-plugin-sort-imports
71+
```
72+
6773
**Note: If you are migrating from v2.x.x to v3.x.x, [Please Read Migration Guidelines](./docs/MIGRATION.md)**
6874

6975
**Note: If formatting `.vue` sfc files please install `@vue/compiler-sfc` if not in your dependency tree - this normally is within Vue projects.**
@@ -126,6 +132,9 @@ between sorted import declarations group. The separation takes place according t
126132
"importOrderSeparation": true,
127133
```
128134

135+
If this option is enabled and `<SEPARATOR>` is used in the `importOrder` array, the plugin
136+
will ONLY add newlines at those locations and at the end of the imports.
137+
129138
#### `importOrderSortSpecifiers`
130139

131140
**type**: `boolean`
@@ -270,11 +279,13 @@ Having some trouble or an issue ? You can check [FAQ / Troubleshooting section](
270279
| ---------------------- | ------------------------ | ------------------------------------------------ |
271280
| JS with ES Modules | ✅ Everything | - |
272281
| NodeJS with ES Modules | ✅ Everything | - |
282+
| Angular | ✅ Everything | Supported through `importOrderParserPlugins` API |
283+
| Ember | ✅ Everything | `prettier-plugin-ember-template-tag` is required |
273284
| React | ✅ Everything | - |
274285
| Solid | ✅ Everything | - |
275-
| Angular | ✅ Everything | Supported through `importOrderParserPlugins` API |
276-
| Vue | ✅ Everything | `@vue/compiler-sfc` is required |
277286
| Svelte | ✅ Everything | `prettier-plugin-svelte` is required |
287+
| Vue | ✅ Everything | `@vue/compiler-sfc` is required |
288+
278289

279290
### Used by
280291

docs/DEBUG.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,31 @@
11
## Debugging
22

3-
---
3+
----
44

55
### How to run example in the repository ?
6-
76
```shell
87
yarn run example examples/example.ts --config .prettierrc
98
```
109

1110
### How to debug the plugin using node `debugger` ?
12-
1311
You can set a `debugger` anywhere in the code and then use following command:
14-
1512
```shell
1613
yarn run compile && node --inspect-brk ./node_modules/.bin/prettier --config .prettierrc --plugin lib/src/index.js examples/example.ts
1714
```
1815

1916
### How to debug the unit test using `debugger` ?
20-
2117
You can set a `debugger` anywhere in the code and then use following command:
2218

2319
```shell
24-
node --inspect-brk ./node_modules/.bin/jest -i
20+
node --inspect-brk ./node_modules/.bin/jest -i
2521
```
26-
2722
Or, to debug a single unit test file
28-
2923
```shell
3024
node --inspect-brk ./node_modules/.bin/jest -i <name-or-relative-path-of-the-file-file>
3125
```
3226

3327
### How to run prettier in any codebase using the plugin ?
34-
3528
First, install the `@trivago/prettier-plugin-sort-imports` and then use following command:
36-
3729
```shell
3830
./node_modules/.bin/prettier --write '**/*.{ts,tsx,js}'
39-
```
31+
```

0 commit comments

Comments
 (0)