Skip to content

calebeby/eslint-config

Repository files navigation

eslint-config-calebeby

Caleb Eby's ESLint Configuration. This exports itself as a "super-plugin" because of a limitation of ESLint.

The way this works is that it requires all of the plugin dependencies, and exports them from this plugin under a prefix.

The plugins that this exposes are:

This also exposes a couple rules from shopify:

To override settings for any of these plugins, you must prefix the configuration with caleb/, because the plugins are exposed through this "super-plugin".

{
  "extends": ["plugin:calebeby/recommended"],
  "rules": {
    "caleb/unicorn/catch-error-name": "off",
    "caleb/@shopify/prefer-early-return": "off"
  }
}

Installation

npm i -D eslint-plugin-caleb eslint prettier

Usage

Add this to your package.json:

{
  "scripts": {
    "check-lint": "eslint . && prettier --check .",
    "lint": "eslint --fix . && prettier --write ."
  },
  "eslintConfig": {
    "extends": ["plugin:caleb/recommended"]
  },
  "prettier": {
    "singleQuote": true,
    "trailingComma": "all",
    "semi": false
  }
}

Configurations

This plugin exposes the following configurations:

  • recommended: This is the main configuration. This exposes base rules, as well as some overrides for .ts/.tsx files
  • react: This adds some settings for React-specific rules
  • preact: This is the same as react, except it excludes rules that are irrelevant for Preact
  • jest: This adds some jest rules for test files, and declares the jest globals in those files

To include these configurations, add the ones you want to your extends array:

["plugin:caleb/recommended", "plugin:caleb/jest"]

Checking on CI

npm run check-lint

Checking Locally

(this will automatically fix many linting issues)

npm run lint