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

@lcooper/eslint-config-jest

v2.0.0

Published

Shareable ESLint config for Jest tests

Downloads

31

Readme

@lcooper/eslint-config-jest

npm ci license

An ESlint shareable flat config for Jest testing environments.

Installation

The peer dependency eslint must be installed alongside this package.

install with npm:

npm install -D eslint @lcooper/eslint-config-jest

install with yarn:

yarn add -D eslint @lcooper/eslint-config-jest

Note: This project requires Eslint version >=8.56, and NodeJS version ^18.18.0 || >=20.0.0.

Usage

Add an eslint.config.js config file to your project's root directory. This config is meant to be used in addition to the base @lcooper/eslint-config config or @lcooper/eslint-config-typescript config.

Note: this package exports a single flat config object, so no need for the ... spread syntax when using it.

import baseConfig from '@lcooper/eslint-config';
import jestConfig from '@lcooper/eslint-config-jest';

export default [
    ...baseConfig,
    jestConfig,
];

If your project does not specify "type": "module" in its package.json file, then eslint.config.js must be in CommonJS format:

const baseConfig = require('@lcooper/eslint-config'),
    jestConfig = require('@lcooper/eslint-config-jest');

module.exports = [
    ...baseConfig,
    jestConfig,
];

This project is no longer compatable with the legacy eslintrc format, and requires you use the flat config format. Check out this page for more details about migrating from the eslintrc format to the flat config format.

File Matching

This config is meant to be used on top of a base ESLint configuration. It uses the files field to apply itself only to files matched by the following glob patterns:

  • **/setupTests.?([cm])[jt]s?(x) → Test setup files.
  • **/jest.setup.?([cm])[jt]s?(x) → Test setup files.
  • **/test?(s)/**/*.?([cm])[jt]s?(x) → Directories named test / tests.
  • **/__@(tests|mocks)__/**/*.?([cm])[jt]s?(x) → Directories named __tests__ / __mocks__.
  • **/+(*.)@(spec|test).?([cm])[jt]s?(x) → Files with a .test.* / .spec.* suffix.
  • **/test.?([cm])[jt]s?(x) → Files named test.

Note: the pattern .?([cm])[jt]s?(x) matches the file extensions .js, .mjs, .cjs, .jsx, .ts, .mts, .cts, and .tsx.

Additionally, this config uses the ignores field so that it is not applied to any files matched by **/fixtures/** or **/__fixtures__/**.

If you would like to control what files this config is applied to, you can override the files field and use your own glob patterns in your eslint.config.js file:

import jestConfig from '@lcooper/eslint-config-jest';

export default [
    {
        ...jestConfig,
        files: [
            // ... your globs here ...
        ],
    },
];

Related

This package is intended to enhance one of these base configs:

See also:

License

MIT