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

@shigen/eslint-plugin

v0.12.1

Published

General purpose plugin for ESLint

Downloads

12

Readme

@shigen/eslint-plugin

General purpose ESLint plugin

NPM Version

Configurable ESLint rules for issues not -- or not sufficiently -- covered by ESLint core rules.

Install

npm install --save-dev @shigen/eslint-plugin

Usage

In your .eslintrc:

{
	"plugins": ["@shigen"],
	"rules": {
		"@shigen/group-imports": "error"
	}
}

Rules

@shigen/group-imports

Requires imports to be grouped and groups to be separated by a new line. This rule is partially auto-fixable. It is currently not capable to move an import that is preceded by non-import statements, including comments.

The following configuration options can be set:

interface ModuleClassConfiguration {
	class: 'node' | 'external' | 'relative' | 'absolute';
	types?: 'include' | 'exclude' | 'only';
}

interface ModulePathConfiguration {
	path: string;
	types?: 'include' | 'exclude' | 'only';
}

type ModuleConfiguration = string | ModulePathConfiguration | ModuleClassConfiguration;

type Configuration = Array<ModuleConfiguration | ModuleConfiguration[]>;

where ModuleConfiguration can be a path pattern or an object.
If it's an object, path can be a path pattern and class can be one of the following:

  • node: All node builtin packages like fs and path, with or without the node: protocol prefix.
  • external: All other declared dependencies, e.g. lodash, react, etc.
  • relative: All relative imports.
  • absolute: All absolute imports, never seen a project use these, but it's possible.

Path patterns are matched with the minimatch library with the matchBase option set. The property types is only relevant for TypeScript's type imports and defaults to 'include'. If you want type and value imports to be in separate groups you need to explicitly declare them with 'only' and 'exclude'.

Nested arrays allow packages to be treated as a single group, e.g.

[
	[{ "class": "node" }, { "class": "external" }],
	["@my-scope", "my-package"],
	{ "class": "relative" }
]

Explicitly declared packages and scopes have precedence over the predefined class tokens. Unused tokens are in an implicit additional group.

The default configuration is:

[
	{ "class": "node" },
	{ "class": "external" },
	{ "class": "absolute" },
	{ "class": "relative" }
]

@shigen/sort-imports

Requires import groups to be sorted by module first and then by specifier. Auto-fixable!

The following configuration options can be set:

interface Configuration {
	specifier?: 'source' | 'rename';
	locales?: string[];
	sensitivity?: 'base' | 'accent' | 'case' | 'variant';
	ignorePunctuation?: boolean;
	numeric?: boolean;
	caseFirst?: 'upper' | 'lower' | 'false';
	caseGroups?: boolean;
	sortExports?: boolean;
	typesInGroup?: 'ignore' | 'top' | 'bottom' | 'above-value' | 'below-value';
	inlineTypes?: 'ignore' | 'start' | 'end';
}
  • specifier: Determines specifier priority, e.g. in import { foo as bar } from 'baz' foo is 'source' and bar is 'rename'.
  • caseGroups: When true, import names need to be grouped by case before sorting.
  • sortExports: Whether to sort deferred export groups, i.e. all statements that export from another module.
  • typesInGroup: Where to place type imports/exports in groups with mixed type and value imports/exports. TypeScript only!
  • inlineTypes: Where to place inline type imports/exports with mixed type and value imports/exports. TypeScript only!

For all other possible settings, see String#localeCompare.

The default configuration is:

{
	"specifier": "source",
	"locales": ["en-US"],
	"sensitivity": "variant",
	"ignorePunctuation": false,
	"numeric": true,
	"caseFirst": "lower",
	"caseGroups": false,
	"sortExports": true,
	"typesInGroup": "ignore",
	"inlineTypes": "ignore"
}