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-class-export

v1.0.1

Published

ESLint plugin to enforce class export rules

Readme

eslint-plugin-class-export

npm version License: MIT ESLint

An ESLint plugin that enforces class export rules, allowing you to specify whether classes must have exports and what type of exports are allowed.

Features

ESLint v9 Compatible - Built with flat config support
AST Selector Patterns - High-performance rule implementation
Flexible Configuration - Support for default, named, any, or no exports
Naming Restrictions - Optional validation of export naming patterns
Zero Dependencies - Lightweight and fast
TypeScript Ready - Works with TypeScript via ESLint

Installation

# Recommended: Use pnpm for better performance and strict dependency management
pnpm add --save-dev eslint-plugin-class-export

# Alternative: npm/yarn
npm install --save-dev eslint-plugin-class-export
yarn add --dev eslint-plugin-class-export

Usage

ESLint v9+ (Flat Config) - Recommended

// eslint.config.js
import classExport from 'eslint-plugin-class-export';

export default [
  {
    plugins: {
      'class-export': classExport
    },
    rules: {
      'class-export/class-export': 'error'
    }
  }
];

CommonJS Flat Config

// eslint.config.js
const classExport = require('eslint-plugin-class-export');

module.exports = [
  {
    plugins: {
      'class-export': classExport
    },
    rules: {
      'class-export/class-export': 'error'
    }
  }
];

Legacy ESLint (eslintrc format)

{
  "plugins": ["class-export"],
  "rules": {
    "class-export/class-export": "error"
  }
}

Rule Options

The class-export/class-export rule accepts an options object with the following properties:

  • require (string): Specifies export requirement

    • "default" - Classes must be exported as default export
    • "named" - Classes must be exported as named export
    • "any" - Classes must be exported (default or named)
    • "none" - Classes must not be exported
    • Default: "any"
  • allowedExportNames (array): When using named exports, only class names ending with these suffixes are allowed

    • Default: [] (no restriction)

Examples

Require Default Exports

// eslint.config.js
export default [
  {
    plugins: { 'class-export': classExport },
    rules: {
      'class-export/class-export': ['error', { require: 'default' }]
    }
  }
];

Valid:

export default class UserComponent {}
export default class {}

Invalid:

class UserComponent {} // Missing export
export class UserComponent {} // Named export instead of default

Require Named Exports

// eslint.config.js
export default [
  {
    plugins: { 'class-export': classExport },
    rules: {
      'class-export/class-export': ['error', { require: 'named' }]
    }
  }
];

Valid:

export class UserService {}
class UserModel {}
export { UserModel };

Invalid:

class UserService {} // Missing export
export default class UserService {} // Default export instead of named

Named Exports with Naming Restrictions

// eslint.config.js
export default [
  {
    plugins: { 'class-export': classExport },
    rules: {
      'class-export/class-export': ['error', { 
        require: 'named',
        allowedExportNames: ['Component', 'Service', 'Model']
      }]
    }
  }
];

Valid:

export class UserComponent {}
export class DataService {}
export class UserModel {}

Invalid:

export class UserHelper {} // Name doesn't end with allowed suffixes
export class DataProcessor {} // Name doesn't end with allowed suffixes

Allow Any Export Type

// eslint.config.js
export default [
  {
    plugins: { 'class-export': classExport },
    rules: {
      'class-export/class-export': ['error', { require: 'any' }]
    }
  }
];

Valid:

export default class UserComponent {}
export class UserService {}
class UserModel {}
export { UserModel };

Invalid:

class UserHelper {} // No export

Prohibit All Exports

// eslint.config.js
export default [
  {
    plugins: { 'class-export': classExport },
    rules: {
      'class-export/class-export': ['error', { require: 'none' }]
    }
  }
];

Valid:

class UtilityClass {}
class InternalHelper {}

Invalid:

export default class UtilityClass {} // Has export
export class InternalHelper {} // Has export

Predefined Configurations

Flat Config (ESLint v9+)

import classExport from 'eslint-plugin-class-export';

// Use predefined configs
export default [
  classExport.configs.recommended,        // Classes must be exported (any type)
  classExport.configs['strict-default'], // Classes must be default exported
  classExport.configs['strict-named'],   // Classes must be named exported
  classExport.configs.flexible          // Classes must be exported (any type)
];

Legacy Config (ESLint v8 and below)

{
  "extends": [
    "plugin:class-export/recommended-legacy",
    "plugin:class-export/strict-default-legacy",
    "plugin:class-export/strict-named-legacy",
    "plugin:class-export/flexible-legacy"
  ]
}

Requirements

  • Node.js: >= 12.0.0
  • ESLint: >= 9.0.0 (flat config support)

Contributing

We welcome contributions! Please see CONTRIBUTING.md for development setup, testing guidelines, and release processes.

Author

Created by Ofek Gabay

License

MIT © 2024 Ofek Gabay