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

v3.0.0-beta.1

Published

Base eslint config for use in JavaScript projects at Cengage

Downloads

127

Readme

eslint-config-cengage

This is a shared eslint configuration for JavaScript projects across Cengage.

Usage

Non-React projects

  • Install eslint-config-cengage with: npm i -D eslint-config-cengage
  • Install peer dependencies:
npm i --save-dev \
    "eslint-config-cengage@^2.0.0" \
    "babel-eslint@^10.1.0" \
    "eslint@^7.9.0" \
    "eslint-plugin-import@^2.22.0" \  
    "eslint-plugin-jest@^24.0.2" \
    "eslint-config-prettier@^7.0.0"\
    "eslint-plugin-unicorn@^22.0.0" \
  • Create .eslintrc file in the project root with the following content
{
  "extends": "cengage"
}

This is a base configuration. You should extend this as needed with project specific options, such as env entries or specific plugins for your test framework.

React projects

  • Install eslint-config-cengage with: npm i -D eslint-config-cengage
  • Install peer dependencies:
npm i --save-dev \
    "eslint-config-cengage@^2.0.0" \ 
    "babel-eslint@^10.1.0" \
    "eslint@^7.9.0" \
    "eslint-plugin-import@^2.22.0" \  
    "eslint-plugin-jest@^24.0.2" \
    "eslint-plugin-jsx-a11y@^6.3.1" \
    "eslint-config-prettier@^7.0.0"\
    "eslint-plugin-react@^7.21.0" \
    "eslint-plugin-react-hooks@^4.1.2" \   
    "eslint-plugin-unicorn@^22.0.0" \
  • Create .eslintrc file in the project root with the following content (adjusting for the appropriate version of React):
{
  "extends": "cengage/react",
  "settings": {
    "react": {
      "version": "16.4"
    }
  }
}

This is a base configuration. You should extend this as needed with project specific options, such as env entries for your test framework.

TypeScript support

To enable typescript support, add the following dependencies to your project.

npm i --save-dev \
    "eslint-config-prettier@^7.0.0"\
    "@typescript-eslint/eslint-plugin@^4.2.0" \
    "@typescript-eslint/parser@^4.2.0" \
    "typescript@^3.9.4"

The default cengage installation will automatically override the configuration for any *.ts or *.tsx files.

Lightweight Base

If even the default cengage configuration forces too many rules, you can choose to extend cengage/base which adds a minimal amount of rules with no overides for neither jest nor typescript and will force you to manually almost all the rules that are needed. This is not recommended.

  • Install eslint-config-cengage with: npm i -D eslint-config-cengage
  • Install peer dependencies:
npm i --save-dev \
  "eslint-config-cengage@^2.0.0" \ 
  "eslint@^7.9.0" \
  "eslint-plugin-import@^2.22.0" \
  "eslint-config-prettier@^7.0.0"\
  "eslint-plugin-unicorn@^22.0.0" \
  • Create .eslintrc file in the project root with the following content
{
  "extends": "cengage/base"
}

Config Rules and Settings

Rules

Default

The default config specifies rules by extending the eslint:recommended rule set.

React

The React config builds on the default settings, so it enforces the eslint:recommended rules and adds some more.

eslint-plugin-react

plugin:react/recommended

eslint-plugin-jsx-a11y

plugin:jsx-a11y/recommended

Rule overrides

The React config also overrides a couple of these rules.

  • To avoid unnecessary refactoring work as these rules are adopted, the react/boolean-prop-naming and react/prop-types rules have been downgraded to warnings. These should be addressed so they can be set to errors in future updates, but can be addressed when time permits.
  • jsx-a11y/heading-has-content is currently turned off to work around an issue. This issue has been addressed in #437 but has not been released yet. Once updates are available, this rule will be enabled by removing the override.
rules: {
  'react/boolean-prop-naming': 1,
  'react/prop-types': 1,
  'jsx-a11y/heading-has-content': 0
}

Environments

eslint environments provide pre-defined globals for specific environments. The shared defaults include browser and node. Your project config should specify any additional environments needed (see Additional Environments below).

Local configuration

This plugin enforces the stylistic preferences defined in your project's Prettier config via eslint. This is the only place that eslint should be enforcing stylistic rules.

Additional Environments

There are options for test frameworks that should be included for your framework(s). Learn more here: Specifying environments

Additional rules

Your team may choose to enforce additional rules, on your project(s) as long as you follow these guidelines:

  1. Your rules can be more strict, but not reduce the strictness of any of the existing rules. In cases where a rule from this config is causing too much friction, you may temporarily override that rule and discuss with UI architecture if that rule should be changed in the standard, if the exception can be made for your project, or if you need to address that in your codebase.
  2. Your rules do not conflict with any of the standard rules or automated formatting.
  3. You are prepared to remove these rules if they conflict with standard rules in future updates.
  4. Do not add rules that enforce stylistic options. Code format should be handled via Prettier. The eslint-config-prettier dependency is used to disable the rules that would conflict with prettier.

This is subjective, so not listed as a guideline:

Consider the value and tradeoffs before adding overly restrictive rules to your team's ESLint config. Your added rules should not cause more friction than value.

Project Structure

Exposed configs

  • index.js - default configuration for any JS project
  • react.js - React specific configuration. Builds on the

Shared settings

  • lib/default.js contains the common defaults used for both React and non-React configs.

Contributing

These settings are a starting point. Adjustments can be made if we find that new rules are needed or some rule is causing too much friction for a particular team. Ideally, we'll land on a standard set of rules that is acceptable to all teams, understanding that some personal preferences will need to be put aside in the interest of standardization.