Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: azat-io/eslint-plugin-perfectionist
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.3.0
Choose a base ref
...
head repository: azat-io/eslint-plugin-perfectionist
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.4.0
Choose a head ref
  • 2 commits
  • 5 files changed
  • 1 contributor

Commits on Nov 16, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    32dbef8 View commit details
  2. build: publish v2.4.0

    azat-io committed Nov 16, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    azat-io Azat S.
    Copy the full SHA
    0597a12 View commit details
Showing with 29 additions and 4 deletions.
  1. +12 −0 changelog.md
  2. +3 −0 docs/rules/sort-imports.md
  3. +1 −1 package.json
  4. +5 −0 rules/sort-imports.ts
  5. +8 −3 test/sort-imports.test.ts
12 changes: 12 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# Changelog


## v2.4.0

[compare changes](https://github.com/azat-io/eslint-plugin-perfectionist/compare/v2.3.0...v2.4.0)

### 🚀 Features

- Add side-effect-style import group ([32dbef8](https://github.com/azat-io/eslint-plugin-perfectionist/commit/32dbef8))

### ❤️ Contributors

- Azat S. ([@azat-io](http://github.com/azat-io))

## v2.3.0

[compare changes](https://github.com/azat-io/eslint-plugin-perfectionist/compare/v2.2.0...v2.3.0)
3 changes: 3 additions & 0 deletions docs/rules/sort-imports.md
Original file line number Diff line number Diff line change
@@ -99,6 +99,7 @@ type Group =
| 'parent'
| 'sibling'
| 'side-effect'
| 'side-effect-style'
| 'index'
| 'object'
| 'style'
@@ -170,6 +171,8 @@ import formatNumber from '../utils/format-number'
import config from './config'
// 'side-effect' - Side effect imports
import './set-production-env.js'
// side-effect-style - Side effect style imports
import './styles.scss'
// 'index' - Main file from the current directory
import main from '.'
// 'object' - TypeScript object-imports
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "eslint-plugin-perfectionist",
"description": "ESLint plugin for sorting various data such as objects, imports, types, enums, JSX props, etc.",
"version": "2.3.0",
"version": "2.4.0",
"homepage": "https://eslint-plugin-perfectionist.azat.io",
"repository": "https://github.com/azat-io/eslint-plugin-perfectionist",
"author": "Azat S. <to@azat.io>",
5 changes: 5 additions & 0 deletions rules/sort-imports.ts
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@ export enum NewlinesBetweenValue {
}

type Group<T extends string[]> =
| 'side-effect-style'
| 'external-type'
| 'internal-type'
| 'builtin-type'
@@ -308,6 +309,10 @@ export default createEslintRule<Options<string[]>, MESSAGE_ID>({
if (node.type === 'ImportDeclaration') {
setCustomGroups(options['custom-groups'].value, node.source.value)

if (isSideEffectImport(node) && isStyle(node.source.value)) {
defineGroup('side-effect-style')
}

if (isSideEffectImport(node)) {
defineGroup('side-effect')
}
11 changes: 8 additions & 3 deletions test/sort-imports.test.ts
Original file line number Diff line number Diff line change
@@ -3736,10 +3736,12 @@ describe(RULE_NAME, () => {
import { useClient } from '~/hooks/useClient'
import '~/css/globals.css'
import '~/data'
`,
options: [
{
groups: ['internal', 'side-effect'],
groups: ['internal', 'side-effect-style', 'side-effect'],
},
],
},
@@ -3748,24 +3750,27 @@ describe(RULE_NAME, () => {
{
code: dedent`
import { useClient } from '~/hooks/useClient'
import '~/data'
import '~/css/globals.css'
`,
output: dedent`
import { useClient } from '~/hooks/useClient'
import '~/css/globals.css'
import '~/data'
`,
options: [
{
groups: ['internal', 'side-effect'],
groups: ['internal', 'side-effect-style', 'side-effect'],
},
],
errors: [
{
messageId: 'missedSpacingBetweenImports',
data: {
left: '~/hooks/useClient',
right: '~/css/globals.css',
right: '~/data',
},
},
],