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

eslint-config-foxkit-react

v1.0.3

Published

ESlint 9 compatible Configurations for React and Preact

Downloads

129

Readme

eslint-config-foxkit-react

This package contains opinionated base configs for React/Preact development with ESLint.

See also eslint-config-foxkit for our JavaScript/TypeScript base configs.

Installation

Install with your package manager of choice:

pnpm add --save-dev eslint-config-foxkit-react [email protected] react

Note: You can also install ESlint v9, but this version may not yet be supported by other Foxkit configs.

Usage with Flat Configuration System

Add a Flat Config in your project like this:

import foxkitReact from "eslint-config-foxkit-react/configs/index.js";

export default [foxkitReact.jsx, foxkitReact.react];

You may also add other configs on top, such as prettier, as well as your own overrides.

Usage in CommonJS projects

If your project does not set "type": "module" in package.json your config will be CommonJS instead (unless explicitly named "eslint.config.mjs"). If this is the case use require("eslint-config-foxkit/configs") instead.

const foxkitReact = require("eslint-config-foxkit-react/configs");

module.exports = [foxkitReact.jsx, foxkitReact.react];

Usage with Preact

The base configuration is also available for Preact, adding a few more rules to ensure compatibilty:

import foxkitReact from "eslint-config-foxkit-react/configs/index.js";

export default [foxkitReact.jsx, foxkitReact.preact];

Usage with other base configurations

Alternatively you can access the rulesets by importing from eslint-config-foxkit-react/rules. If you are already using a base config like from your project's framework you may want to add a customized config object with our rules as well as the required plugins like this:

const reactPlugin = require("eslint-plugin-react");
const globals = require("globals");
const reactRules = require("../rules/react");

export default [
  // your other base configs here,
  {
    plugins: { react: reactPlugin },
    rules: { ...reactRules },
    settings: {
      react: { version: "detect" }
    }
  }
  // more configs here as needed
];

Note: This does not yet configure eslint-plugin-jsx-a11y and eslint-plugin-react-hooks which are included in our base configuration!

Usage with new JSX Runtime

If your project uses the new JSX transform from React 17 or a framework that similarly does no longer require React to be imported at the top of each file you need to include the "jsx-runtime" config of the eslint-plugin-react plugin like this:

import reactPlugin from "eslint-plugin-react";
import foxkitReact from "eslint-config-foxkit-react/configs/index.js";

export default [
  foxkitReact.jsx,
  foxkitReact.react,
  reactPlugin.configs["jsx-runtime"]
];

Usage with the Legacy Configuration System

Simply add "foxkit-react" (or "foxkit-react/preact" if you are using Preact) to your extends array in your .eslintrc.cjs file:

module.exports = {
  extends: ["foxkit-react"]
};

Note: Should you need to add a file extension you will need to adjust jsx override and "react/jsx-filename-extension" rule:

const foxkitReactOverrides = require("eslint-config-foxkit-react/legacy/overrides");
const foxkitJSX = foxkitReactOverrides.jsx;
foxkitJSX.files.push("**/*.astro"); // example adding .astro files

module.exports = {
  extends: ["foxkit-react"],
  overrides: [foxkitJSX], // re-insert patched version of the override
  rules: {
    "react/jsx-filename-extension": [
      "error",
      { extensions: [".jsx", ".tsx", ".astro"] }
    ]
  }
};

Note for VSCode

As of right now the ESLint plugin available for VSCode has experimental support for Flat Config hidden behind a setting. In your project simply create a .vscode directory with a settings.json file with the following content (or add to it if you already have one):

{
  "eslint.experimental.useFlatConfig": true
}

This enables the setting on a workspace-level, so when switching between projects the setting remains disabled for projects using the old config system. Also note that the .mjs and .cjs extensions may not get picked up correctly, so your config file should always be called eslint.config.js.