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

v3.2.1

Published

Standard ESLint configurations for Ackama projects.

Downloads

1,106

Readme

Ackama ESLint Configuration

Standard ESLint configurations for Ackama projects.

Basic Setup

Install this package & the required plugins:

npm install --save-dev eslint-config-ackama @types/eslint eslint eslint-plugin-eslint-comments eslint-plugin-import eslint-plugin-node eslint-plugin-prettier prettier

Add an .eslintrc.js to your repo that extends from this config:

/** @type {import('eslint').Linter.Config} */
const config = {
  extends: ['ackama']
};

module.exports = config;

You'll want to tell ESLint about the environment you're working in using the env toplevel property.

To reduce potential errors, the configurations provided by this package deliberately avoid enabling or disabling any envs without good reason, opting to set only the es2017 env, since the majority of projects should be using ES2017 or higher.

These are the three most common envs you'll want to use:

  • node for NodeJS apps
  • browser for browser apps
  • commonjs for browser apps that are bundled using a bundler such as webpack

You can also add a lint script to the scripts property in your apps package.json to make it easier for developers to run eslint against the app:

{
  "scripts": {
    "lint": "eslint . --ext js,jsx,ts,tsx"
  }
}

This can be called via npm run lint or yarn run lint, depending on the package manager you're using.

Additional Configs

In addition to the ackama config (which pulls in index.js) for vanilla Javascript, this config package ships with a number of other configs for linting specific packages and frameworks.

You can use these by extending them by their names in the same way as the base config, except you must prefix them with ackama/. You will also be required to install any extra plugins and dependencies these configs require that are not required for the base config.

Below is a complete list of the configs provided, and their dependencies:

  • ackama
    • eslint-plugin-eslint-comments
    • eslint-plugin-prettier
    • eslint-plugin-import
    • eslint-plugin-node
  • ackama/@typescript-eslint
    • @typescript-eslint/parser
    • @typescript-eslint/eslint-plugin
    • eslint-plugin-prettier
  • ackama/flowtype
    • @babel/eslint-parser
    • eslint-plugin-flowtype
    • eslint-plugin-prettier
  • ackama/jest
    • eslint-plugin-jest
    • eslint-plugin-jest-formatting
  • ackama/react
    • eslint-plugin-prettier
    • eslint-plugin-react
    • eslint-plugin-react-hooks
    • eslint-plugin-jsx-a11y

Ignoring files

Often there are files and folders that you don't want ESLint to check. While the base config already setups ignores for common folders, including node_modules, vendor, coverage, lib, out, and a few more, unique projects might need to ignore additional folders, or inversely might want to un-ignore a preset ignore.

This can be done using the ignorePatterns toplevel property, which is an array that accepts .gitignore glob-like strings:

/** @type {import('eslint').Linter.Config} */
const config = {
  ignorePatterns: ['!public/', 'tmp/']
};

module.exports = config;

Typical complete example

Here's what a typical .eslintrc.js would look like for a TypeScript project that uses jest & react:

/** @type {import('eslint').Linter.Config} */
const config = {
  root: true,
  parser: '@typescript-eslint/parser',
  parserOptions: {
    project: 'tsconfig.json',
    ecmaVersion: 2019,
    sourceType: 'module'
  },
  env: { commonjs: true },
  extends: ['ackama', 'ackama/@typescript-eslint', 'ackama/react'],
  ignorePatterns: ['coverage', 'lib', 'infra'],
  overrides: [
    {
      files: ['test/**'],
      extends: ['ackama/jest'],
      rules: { 'jest/prefer-expect-assertions': 'off' }
    }
  ],
  rules: {}
};

module.exports = config;

Note the use of overrides to target specific files for the ackama/jest config. This is not a requirement, but can help reduce the changes of false positives.

Notes & Considerations

While the majority of rules enabled by these configurations are sound, a few have edge cases or are potentially not as suitable as initially hoped.

Some of these edge cases are already well-known, and may have possible fixes in the future; the details of these rules are documented below.

In general, we are more acceptance of rules that don't catch everything than rules that report too many false positives.

React: Lint custom hooks that accept a dependency array

If you create a custom hook for a project that takes a dependency array, you can have react-hooks/exhaustive-deps lint it in the same manner as core hooks by passing it the name of your custom hook via its additionalHooks option:

{
  "rules": {
    "react-hooks/exhaustive-deps": ["warn", { "additionalHooks": "useHook" }]
  }
}

Note that this option expects a RegExp string.

Versioning

Versioning is modeled after semantic versioning; however, since these configurations are for a code quality tool meaning just about every change to a config is likely going to result in a new error in at least one of our codebases (and so arguably be a breaking change), we consider general configuration changes to be minor features, and release them as such.

In addition to this covering changes like enabling a new rule and adjusting the configuration of an already-enabled rule, this also includes updating to new major versions of a plugin which might have removed or renamed rules used in our configs.

We specify which versions of plugins is expected by our configs as optional peer dependencies, meaning your package manager should warn you if a minor version of our package requires a related plugin to be updated for compatibility.

Major versions are generally reserved for when we're making a significant number of changes, which can be common with new major versions of ESLint that have significant breaking changes that require the surrounding ecosystem to release new major versions.

Releasing

Releases are handled using semantically.

Contributing

This repo uses convectional commits to enable semantic releases & changelog generation.

When making a PR, Semantic Pull Request will check if the PR will trigger a release, based on the title & commits in the PR.

This is done via a status check, which will pass if a release would be triggered by merging. You are can merge regardless of if this status check passes or not.

Please keep in mind that if you're denoting a release via the PRs title, you will have to squashed. SPR will inform you if you should merge or squash.