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

@ferdaber/eslint-plugin-sorting

v0.1.0

Published

My own ESLint plugin containing custom lint rules for our code.

Downloads

3

Readme

ESLint plugin for sorting

My own ESLint plugin containing custom lint rules for our code.

Installation

NPM

npm install -D @ferdaber/eslint-plugin-sorting

Yarn

yarn add -D @ferdaber/eslint-plugin-sorting

In your .eslintrc file, add the following:

{
  "plugins": ["@ferdaber/sorting"],
  "rules": {
    "@ferdaber/sorting/rule-name": "error"
  }
}

Rules

sort-imports 🔧

Enforces all import declarations to be sorted in the following order:

  1. Side effect imports
  2. External imports
  3. Internal imports
  4. Static asset imports

Enforces all import specifiers to be sorted alphabetically, as well.

Options

The rule accepts an object with its properties as:

  • declarationSort (default: 'import'): 'import' | 'source'
  • fix (default: false): boolean

Default option settings are:

{
  "@ferdaber/sorting/sort-imports": [
    "error",
    {
      "declarationSort": "import",
      "fix": false
    }
  ]
}

Example

Example of incorrect code for this rule:

import MySvg from './svgs/my-svg.svg'
import React from 'react'
import { moduleB, moduleC } from 'my-module'

Example of correct code for this rule:

import 'side-effects-only'

import PropTypes from 'prop-types'
import React from 'react'
import { Router } from 'react-router'

import App from './my-app-wrapper'
import * as routes from 'my-app-routes'

import Icon from 'react-icons/md/icon.svg'
import SomeImage from '../images.png'

declarationSort

Changes the sorting strategy for import declarations based on their source ('source') vs. on their imported names ('import').

Example of incorrect code for this rule with the default { "declarationSort": "source" } option:

import module1 from 'module-b'
import module2 from 'module-a'

Example of correct code for this rule with the default { "declarationSort": "source" } option:

import module2 from 'module-a'
import module1 from 'module-b'

Example of incorrect code for this rule with the { "declarationSort": "import" } option:

import moduleB from 'module-a'
import * as moduleD from 'module-d'
import moduleA, { moduleC } from 'module-c'

Example of correct code for this rule with the { "declarationSort": "import" } option:

import moduleA, { moduleC } from 'module-c'
import moduleB from 'module-a'
import * as moduleD from 'module-d'

sort-object-keys 🔧

Enforces all object literal keys to be in alphabetical order.

Options

The rule accepts an object with its properties as:

  • fix (default: false): boolean

Default option settings are:

{
  "@ferdaber/sorting/sort-object-keys": [
    "error",
    {
      "fix": false
    }
  ]
}

Example

Example of incorrect code for this rule:

const a = 'a'

const foo = {
  b: 'b',
  a,
}
const A = 'a'
const B = 'b'

const foo = {
  [`${B}A`]: 'ba',
  [B]: b,
  [A]: a,
}

Example of correct code for this rule:

const A = 'a'
const B = 'b'

const foo = {
  a: 'a',
  A,
  [B]: b,
  [`${B}A`]: 'ba',
}

sort-pattern-keys 🔧

Enforces all object destructuring patterns to have alphabetical keys.

Options

The rule accepts an object with its properties as:

  • fix (default: false): boolean

Default option settings are:

{
  "@ferdaber/sorting/sort-pattern-keys": [
    "error",
    {
      "fix": false
    }
  ]
}

Example

Example of incorrect code for this rule:

const Component = ({ hidden, className }) => null
const { hidden, className = '' } = this.props

Example of correct code for this rule:

const Component = ({ className, hidden = false }) => null