npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

eslint-plugin-import-curly

v1.0.2

Published

import curly

Downloads

6

Readme

eslint-plugin-import-curly

import curly

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-import-curly:

npm install eslint-plugin-import-curly --save-dev

Usage

Add import-curly to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": ["import-curly"]
}

RULE import-curly/newline

options

| name | type | default | description | |-------|--------|---------|------------------------------------------------------| | count | number | 3 | If it exceeds count, each attribute will be wrapped. |

{
  "rules": {
    "import-curly/newline": [
      "error",
      {
        "count": 4
      }
    ]
  }
}

valid

import A from 'C'
import * as A from 'C'
// count defalut 3
import {A, B} from 'C'
import {
  A as AA,
  B
} from 'C'
import A, {
  AA as AAA,
  B as BB,
  C,
} from 'D'
import {
  A as AA,
  B,
} from 'C'
import A, {
  AA as AAA,
  B as BB,
  C,
} from 'D'

invalid

// invalid
import {
  A as AA,B, C} from 'C'

// ||
// \/

// valid
import {
  A as AA,
  B,
  C
} from 'C'

// invalid
import {
  A as AA,B, 
  C,
} from 'C'

// ||
// \/

// valid, Commas will be preserved
import {
  A as AA,
  B,
  C,
} from 'C'

RULE import-curly/sort-params

options

| name | type | default | enum | description | |--------------|---------|-------------------|--------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------| | typeLocation | string | ignore | ignore,first,last | ignore: ignore 'type' location, first: 'type' is at the front, last: 'type' is at the end | | orderBy | string | alphabeticalOrder | alphabeticalOrder,letterNumber | alphabeticalOrder: order by alpha, letterNumber: order by letter number. when order by letterNumber, if the letterNumber is the same, order by alpha | | sortBy | string | aec | aec,desc | aec: sort in ascending order, desc: sort in descending order | | ignoreCase | boolean | true | | true: ignore case, false: don't ignore case |

{
  "rules": {
    "import-curly/sort-params": "error",
    "import-curly/sort-params": [
      "error",
      {
        "typeLocation": "first",
        "orderBy": "letterNumber",
        "sortBy": "desc",
        "ignoreCase": false
      }
    ]
  }
}

default options

{
  "rules": {
    "import-curly/sort-params": "error",
    "import-curly/sort-params": [
      "error",
      {
        "typeLocation": "ignore",
        "orderBy": "alphabeticalOrder",
        "sortBy": "aec",
        "ignoreCase": true
      }
    ]
  }
}

valid

import type {a,b,c,d} from 'a'
import {A,B,C,D} from 'a'
import type {a,B,c,D} from 'a'
import {A,b,c,D} from 'a'
import {type a,b,type c,d} from 'a'
import {a,type b,c,default as d} from 'a'

invalid

// invalid
import {type A,type c,d,B} from 'a'
// ||
// \/
// valid
import {type A,B,type c,d} from 'a'


// invalid, ignore type, compare with 'default'
import {c,default as d,type b,a} from 'a'
// ||
// \/
// valid
import {a,type b,c,default as d} from 'a'

typeLocation first

{
  "rules": {
    "import-curly/sort-params": [
      "error",
      {
        "typeLocation": "first"
      }
    ],
    "import-curly/sort-params": [
      "error",
      {
        "typeLocation": "first",
        "orderBy": "alphabeticalOrder",
        "sortBy": "aec",
        "ignoreCase": true
      }
    ]
  }
}

valid

// type first
import {type B,type c,A, d} from 'a'
import {type b,type d,a,c} from 'a'

invalid

// invalid, compare with 'default'
import {c,a,default as d,type b} from 'a'
// ||
// \/
// valid
import {type b,a,c,default as d} from 'a'

orderBy letterNumber

{
  "rules": {
    "import-curly/sort-params": [
      "error",
      {
        "orderBy": "letterNumber"
      }
    ],
    "import-curly/sort-params": [
      "error",
      {
        "typeLocation": "ignore",
        "orderBy": "letterNumber",
        "sortBy": "aec",
        "ignoreCase": true
      }
    ]
  }
}

valid

import {a, ba, bb, ccc} from 'a'
import {a, ba, bb, bbb} from 'a'

invalid

// invalid bb ba letterNumber is the same, should order by alpha
import {a, bb, ba} from 'a'
// ||
// \/
// valid
import {a, ba, bb} from 'a'

orderBy alphabeticalOrder and sortBy desc

{
  "rules": {
    "import-curly/sort-params": [
      "error",
      {
        "sortBy": "desc"
      }
    ],
    "import-curly/sort-params": [
      "error",
      {
        "typeLocation": "ignore",
        "orderBy": "alphabeticalOrder",
        "sortBy": "desc",
        "ignoreCase": true
      }
    ]
  }
}

valid

import {d, c, b, a} from 'a'

orderBy letterNumber and sortBy desc

{
  "rules": {
    "import-curly/sort-params": [
      "error",
      {
        "orderBy": "letterNumber",
        "sortBy": "desc"
      }
    ],
    "import-curly/sort-params": [
      "error",
      {
        "typeLocation": "ignore",
        "orderBy": "letterNumber",
        "sortBy": "desc",
        "ignoreCase": true
      }
    ]
  }
}

valid

import {aaa, cc, aa, d} from 'a'

ignoreCase false

{
  "rules": {
    "import-curly/sort-params": [
      "error",
      {
        "ignoreCase": false
      }
    ],
    "import-curly/sort-params": [
      "error",
      {
        "typeLocation": "ignore",
        "orderBy": "alphabeticalOrder",
        "sortBy": "aec",
        "ignoreCase": false
      }
    ]
  }
}

valid

import {A, B, C, a, b, c} from 'a'
import {A, B, C, a, b, c, default as d} from 'a'