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

@api3/eslint-plugin-commons

v3.0.0

Published

> ESLint configurations used across API3 projects.

Downloads

2,331

Readme

eslint-plugin-commons

ESLint configurations used across API3 projects.

The modules consists of multiple ESLint configurations supporting wide variety of targets:

  • universal - Linting rules for universal (both FE and BE) JS/TS code (with the emphasis on TS).
  • react - Linting rules for React code.
  • next-js - Linting rules for Next.js code.
  • jest - Linting rules for Jest tests. Note, that these rules are only applied for JS/TS files with *.test.* extensions.

Getting started

  1. Create an .eslintrc.js configuration file in the repo root.
  2. Extend the desired configuration(s).
  3. Specify the parserOptions.project option with the path to the tsconfig.json file(s).
  4. Install eslint (which is a peer dependency of this module) as dev dependencies.

For example:

module.exports = {
  extends: ['plugin:@api3/eslint-plugin-commons/universal', 'plugin:@api3/eslint-plugin-commons/jest'],
  parserOptions: {
    // We focus primarily on TS and for that we need to specify the TS configs which is project specific. The following
    // is a common monorepo setup (root config and a config for each package).
    project: ['./tsconfig.json', './packages/*/tsconfig.json'],
  },
};

Linting commands

We recommend using the following linting commands inside package.json scripts:

{
  "eslint:check": "eslint --report-unused-disable-directives --cache --ext js,ts,tsx,jsx . --max-warnings 0",
  "eslint:fix": "pnpm run eslint:check --fix"
}

The --cache parameter makes ESLint create a .eslintcache file in the root of the project. This file should be put to .gitignore.

Rules

The configurations are a collection of various rulesets and the config is quite strict. In general there are rules that:

  • Have a fixer (import ordering)
  • Simplify code (combine two nested ifs)
  • Make code more consistent (make return void pattern be split on two lines)
  • Fix outdated stuff (avoid ! ts operator when not necessary)
  • Avoid vulnerabilities and errors (Number.parseInt without radix)

Tip: Some rules do have fixer with multiple variants of the fixes. You need to use the IDE to prompt the fixes and choose the one you want.

Overriding rules

To override a rule, you can use the rules section key in your .eslintrc.js file. For example:

{
  rules: {
    'check-file/folder-naming-convention': 'off', // Turns of the kebab-case convention for folder names.
    'unicorn/filename-case': 'off' // Turns of the kebab-case convention for filenames.
    'import/no-default-export': 'off', // Turns off the rule that disallows default exports.
    'import/prefer-default-export': 'error' // Turns on the rule that prefers default exports.
  }
}

For developers

This sections is intended for developers of this repo.

Release

  1. Run pnpm version [major|minor|patch] by choosing the appropriate version bump.
  2. Push the changes to the main, either directly or via a pull request.
  3. The CI will register a new version and handle the release process.