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 🙏

© 2025 – Pkg Stats / Ryan Hefner

eslint-plugin-enforce-children

v1.1.0

Published

An ESLint plugin to enforce custom parent/child constraints in JSX.

Readme

eslint-plugin-enforce-children

Enforce certain parent/child constraints in JSX, defined via user config.

NPM registry License

Install

  1. If you haven’t already, install ESLint:
npm install --save eslint
  1. Install the plugin:
npm install --save eslint-plugin-enforce-children

Usage

  1. Add parent-child to your ESLint configuration. For example, if you use an .eslintrc.json file:
{
  "plugins": ["enforce-children"],
  "rules": {
    "enforce-children/enforce-children": [
      "error",
      {
        "rules": {
          // Each key is a parent component, and the array is the list of allowed children.
          "Grid": ["Row"],
          "Row": ["Col"],
          // etc.
        }
      }
    ]
  }
}
  1. Configure the rule: Pass an object with a rules property to define which child components are allowed under specific parents. The rule’s configuration expects a structure like this:
{
  "rules": {
    "Grid": ["Row"],
    "Row": ["Col"],
    // ...
  }
}
  • Key: The name of the parent JSX component.
  • Value: An array of allowed child JSX component names.
  1. Lint your code: Run ESLint, and it will report any invalid children.

Setup

  • Rule Name: enforce-children/enforce-children
  • Type: problem
  • Description: Ensures that only specified child components appear within certain parent components.

Options

| Option | Description | Type | Required | | -----------------| ----------------------------------------------------------------------------------------------------------------------------| -------------| -------- | | rules | An object whose keys are parent component names and values are arrays of allowed children |Object | yes |

Examples

Valid Given a configuration:

{
  "rules": {
    "Grid": ["GridItem"]
  }
}

This is valid:

function App() {
  return (
    <Grid>
        <Row>
            <Col size={2} offset={2}>
                <div style={style}>Col-2 offset-2</div>
            </Col>
            <Col size={6} offset={0}>
                <div style={style}>Col-6 offset-0</div>
            </Col>
        </Row>
  
        <Row>
            <Col size={5} offset={2}>
                <div style={style}>Col-5 offset-2</div>
            </Col>
            <Col size={3} offset={0}>
                <div style={style}>Col-3 offset-0</div>
            </Col>
        </Row>
    </Grid>
  );
}

Invalid With the same configuration above:

function App() {
  return (
    <Grid>
      <Col size={3} offset={0}> {/* ❌ Only these children (Row) are allowed inside <Grid>. Found <Col>. */}
        <div>Col-3 offset-0</div>
      </Col>  
    </Grid>
  );
}

How It Works

  1. The rule checks each JSXElement node.
  2. It identifies the parent component name (e.g., Grid).
  3. It looks up the array of allowed children from your user-defined config (e.g., [ "Row"] ).
  4. It checks each JSX child to see if it is in the allowed list.
  5. If not, it reports an error.

License

MIT Licensed © 2025 Hamik25