Skip to content

Repository files navigation

Envy Labs ESLint configuration

Opinionated linting configuration used across Envy Labs projects. Valid for JavaScript or TypeScript projects. Ships with bundled TypeScript type declarations, so editors and eslint.config.ts get full type support out of the box.

How to use

  1. Install the dependency
npm add -D eslint-config-envylabs
  1. Add it to your eslint.config.js:
import eslintConfigEnvylabs from "eslint-config-envylabs";

export default [
  // If you're using JavaScript
  ...eslintConfigEnvylabs.js,
  // ...or if you're using TypeScript. The TypeScript config includes the
  // JavaScript one, so you don't need to include both in that case.
  ...eslintConfigEnvylabs.ts,
  {
    // Your config here
  },
];

Also, you can use the full config, which includes the js, ts and very opinionated Envy Labs configs:

import eslintConfigEnvylabs from "eslint-config-envylabs";

export default [
  ...eslintConfigEnvylabs.full,
  {
    // Your config here
  },
];
  1. Add a project-local Prettier config
npm add -D prettier
// prettier.config.js
export { default } from "eslint-config-envylabs/prettier";

This step is not optional, and this package will warn until you do it. Prettier resolves its options twice in a project like yours, and the two resolvers only agree when a config file exists:

  • ESLint, through eslint-plugin-prettier, resolves your Prettier config and otherwise falls back to the defaults of the Prettier version you installed.
  • Your editor's Prettier integration falls back to its own settings when no config file resolves. The VS Code extension, for instance, applies every prettier.* VS Code setting in that case -- including any you or a previous workspace set globally, and defaults frozen at whatever version of the extension you happen to have installed.

Without the file, format-on-save writes code that prettier/prettier then warns about -- most visibly as trailing commas being added and removed on every save. Sharing the config file above makes both sides read the same values, and pins them against future changes to Prettier's own defaults.

If you would rather keep the check quiet, turn the rule off in your eslint.config.js (formatting will still drift):

{
  rules: { "envylabs/prettier-config-required": "off" },
}

For belt and suspenders, tell VS Code to never format without a config file:

// .vscode/settings.json
{
  "prettier.requireConfig": true
}

What it does

About

ESLint configuration for Envy Labs projects

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages