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-reactfc

v1.0.0

Published

An ESLint plugin to enforce the order of hooks, methods, and rendering logic inside React functional components.

Readme

eslint-plugin-reactfc

An ESLint plugin that enforces the order of hooks, methods, and rendering logic inside React functional components.

What does this plugin do?

This plugin enforces a consistent order for code blocks inside React functional components. It helps maintain readability and best practices by ensuring that hooks, variables, methods, effects, and rendering logic always appear in a predictable order.

Enforced Order

  1. useState hooks (state management)
  2. Custom hook calls
  3. Other variables or computed values
  4. Methods (functions inside the component)
  5. useEffect hooks (side effects)
  6. Conditional rendering logic (if applicable)
  7. JSX return (rendered output)

Installation

npm install --save-dev eslint-plugin-reactfc

Usage

Add the following to your .eslintrc.js or .eslintrc.json:

{
  "plugins": ["reactfc"],
  "rules": {
    "reactfc/order": "warn"
  }
}

Rule Details

This rule checks the order of code blocks inside React functional components. The expected order is:

  1. useState hooks
  2. Custom hooks (functions starting with use except useState/useEffect)
  3. Variables and computed values
  4. Methods (function declarations or function expressions assigned to variables)
  5. useEffect hooks
  6. Conditional rendering (if statements that return JSX)
  7. The final return statement with JSX

If any block is out of order, a warning or error will be reported.

Example

Correct:

function MyComponent() {
  const [count, setCount] = useState(0); // 1. useState
  const data = useMyCustomHook();        // 2. custom hook
  const doubled = count * 2;             // 3. computed value
  const handleClick = () => {};          // 4. method
  useEffect(() => {}, [count]);          // 5. useEffect
  if (!data) return null;                // 6. conditional rendering
  return <div>{doubled}</div>;           // 7. JSX return
}

Incorrect:

function MyComponent() {
  const data = useMyCustomHook();
  const [count, setCount] = useState(0); // useState should come first
  const doubled = count * 2;
  useEffect(() => {}, [count]);
  const handleClick = () => {}; // method should come before useEffect
  if (!data) return null;
  return <div>{doubled}</div>;
}

Development & Testing

  • All rules are in index.js.
  • Tests are in order-rule.test.js and use Jest and ESLint's RuleTester.
  • To run tests:
npm test

Contributing

Feel free to open issues or pull requests for bug fixes, new features, or improvements.

License

MIT