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 🙏

© 2026 – Pkg Stats / Ryan Hefner

eslint-plugin-required-exports

v0.2.0

Published

ESLint plugin that enforces exports of declarations like const, type, interface, class, enum

Readme

eslint-plugin-required-exports

An ESLint plugin that enforces exports for top-level declarations like const, function, class, interface, type, and enum.

Installation

npm install --save-dev eslint-plugin-required-exports
# or
pnpm add -D eslint-plugin-required-exports
# or
yarn add -D eslint-plugin-required-exports

Usage

ESLint 9 (Flat Config)

import requiredExports from 'eslint-plugin-required-exports';

export default [
  {
    plugins: {
      'required-exports': requiredExports,
    },
    rules: {
      'required-exports/required-exports': 'error',
    },
  },
  // or use the recommended config
  requiredExports.configs.recommended,
];

Legacy ESLint Config

{
  "plugins": ["required-exports"],
  "rules": {
    "required-exports/required-exports": "error"
  }
}

Rule: required-exports

This rule enforces that top-level declarations must be exported.

❌ Examples of incorrect code

const myConstant = 42;
function myFunction() {}
class MyClass {}
interface MyInterface {}
type MyType = string;
enum MyEnum { A, B }

✅ Examples of correct code

export const myConstant = 42;
export function myFunction() {}
export class MyClass {}
export interface MyInterface {}
export type MyType = string;
export enum MyEnum { A, B }

// Or using export statements
const myConstant = 42;
export { myConstant };

// Private identifiers are ignored by default
const _privateConstant = 42;
function _privateFunction() {}

Options

The rule accepts an options object with the following properties:

{
  variable?: boolean;   // default: true
  function?: boolean;   // default: true
  class?: boolean;      // default: true
  interface?: boolean;  // default: true
  type?: boolean;       // default: true
  enum?: boolean;       // default: true
  ignorePrivate?: boolean; // default: true
}

Examples

// Only check functions and classes
{
  "required-exports/required-exports": ["error", {
    "variable": false,
    "function": true,
    "class": true,
    "interface": false,
    "type": false,
    "enum": false
  }]
}

// Don't ignore private identifiers
{
  "required-exports/required-exports": ["error", {
    "ignorePrivate": false
  }]
}

Auto-fix

This rule supports auto-fixing. It will automatically add the export keyword to declarations that are missing it.

Development

# Install dependencies
pnpm install

# Build the project
pnpm build

# Run tests
pnpm test

# Run tests in watch mode
pnpm test:watch

# Create a release
pnpm release

Release Setup

To create releases, you'll need to configure environment variables:

  1. Copy the example environment file:

    cp .env.example .env
  2. Fill in your tokens in .env:

    # GitHub Personal Access Token for releases
    GITHUB_TOKEN=ghp_your_token_here
    
    # NPM Token for publishing
    NPM_TOKEN=npm_your_token_here
    
    # Git configuration
    GIT_USER_NAME="Your Name"
    GIT_USER_EMAIL="[email protected]"
  3. Create tokens:

  4. Run release commands:

    # Dry run to test the release process
    pnpm release:dry
    
    # Create an actual release
    pnpm release

License

MIT