SoominHan / import-sorter

MIT License
87 stars 28 forks source link

add numberOfEmptyLinesBeforeGroup #75

Open leopen-hu opened 3 years ago

leopen-hu commented 3 years ago

we have numberOfEmptyLinesAfterGroup but it works not well. if the group match no import item.for example:

//rules
"importSorter.sortConfiguration.customOrderingRules.rules": [
    {
      "type": "importMember",
      "regex": "^$",
      "orderLevel": 5,
      "disableSort": true
    },
    {
      "regex": "^[^.@]",
      "orderLevel": 10
    },
    {
      "regex": "^[@]",
      "orderLevel": 15
    },
    {
      "regex": "^[.]",
      "orderLevel": 30,
      "numberOfEmptyLinesAfterGroup": 1 // this may not work because of no matched import
    },

    {
      "regex": "^[.scss]",
      "orderLevel": 40,
      "numberOfEmptyLinesBeforeGroup": 1 // this will always be work
    }
  ]

// import items
import React, { FC } from 'react'
import { Article } from '@/lib/types/article'

import styles from './article.module.scss'