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

import-sort-style-delicious

v1.0.2

Published

An import-sort style that lets you configure your sorting along axes useful at Delicious Insights

Downloads

23,710

Readme

import-sort-style-delicious

A style for import-sort that lets you configure imports along axes useful at Delicious Insights.

Options

This can be configured in your project’s package.json (or more precisely, the closest package.json at or above the formatted file’s directory) using subkeys of the deliciousImportSort main key:

| Option | Values | Default | Description | | -------------- | ------------------------- | ---------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | customGroups | Array or String | [] | Lets you split main-order categories in several groups: first the one that wouldn’t match any of your custom groups, then one for each group, in the specified order. Groups are defined by either string prefixes or regexes.If you need a single group, you can drop the surrounding brackets and use a single string or regexp. | | mainOrder | Array of category keys | ['bare', 'absolute', 'relative'] | Bare imports use no local specifier, they’re just for side-effects (there is no from part).Absolute imports target Node-core or node_modules-based modulesRelative imports are “project-local” and start with either ./ or ../.Should you not wish to distinguish between absolute and relative, the 'regular' keyword merges both. | | sortStyle | 'natural' or 'unicde' | 'natural' | Natural ordering uses String#localeCompare, which gives more natural-feeling results (e.g. case is usually folded, and diacritics don’t end up last).Unicode ordering is lexicographical: it follows the codepoint positions in the Unicode table. |

Using this style in VS Code

  1. Start by making sure you have the sort-imports extension installed.
  2. In the project you want to use that into, add the dependency with npm install --save-dev import-sort-style-delicious
  3. Open your VS Code Preferences (either User or Workspace, depending on the scope you want) and look for the "Sort Imports configuration" entry in the Extensions part (or just fuzzy-find it). In the Default-sort-style setting, type delicious (or the whole module name if you prefer), then save your settings.
  4. In your project’s package.json, add whatever custom configuration you would like if the defaults aren’t enough for you (this is usually about custom groups). See below for a short example configuration.
  5. Save your files and behold!

Note that the configuration is re-read on each formatting, intentionally (this takes only a couple milliseconds), so you can tweak it and test (by re-saving your file) easily, without having to reload VS Code’s window or anything.

Updating your codebase in one go

This is a style for the import-sort tool, that offers a CLI you can use once you configured our style through the configuration. You could then just do something like this:

npm install -save-dev import-sort-cli import-sort-parser-babylon import-sort-style-delicious
# Set up your `importSort` config key in `package.json`, if you haven't already, then:
npx import-sort --write

Example custom configuration

Your package.json could go with default main order and sort style, but just define a custom group for Material-UI modules:

"deliciousImportSort": {
  "customGroups": ["@material-ui"]
},

Example output

// Bare modules first (absolutes, then relatives)
import './LoginScreen.styl'

// Absolute modules, except for our custom groups, in natural order.
// When mixing default and named imports, the default import’s local name
// is used.  When only on named imports, the “lowest” local alias is used
// (multiple named imports are sorted too, using the same `sortStyle`).
import autobind from 'autobind-decorator'
import { connect } from 'react-redux'
import DocumentTitle from 'react-document-title'
import { hot } from 'react-hot-loader/root'
import React, { Component } from 'react'

// Absolute modules for our custom groups, using the same in-group
// sorting mechanisms.
import ArrowForward from '@material-ui/icons/ArrowForward'
import Button from '@material-ui/core/Button'
import Card from '@material-ui/core/Card'
import CardActions from '@material-ui/core/CardActions'
import CardContent from '@material-ui/core/CardContent'
import CardHeader from '@material-ui/core/CardHeader'
import Snackbar from '@material-ui/core/Snackbar'
import TextField from '@material-ui/core/TextField'

// Relative modules, using the same in-group sorting mechanisms.
// As we do not have relative modules matching our custom groups,
// there is only one block here.
import { func, LoginStatePropType } from '../shared/prop-types'
import { logIn } from '../reducers/currentUser'
import TogglablePasswordField from './TogglablePasswordField'

Contributing

Did we let something slip? Do you have an awesome extra feature idea? Cool, let us know. Check out our guide to get started.

License

This package is copyright © 2019 Delicious Insights, and made available under the MIT license.