# @mattcampbell/eslint-config

> A very opinionated ESLint and Prettier config.

Latest version **0.8.63** (published 2022-04-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install @mattcampbell/eslint-config
pnpm add @mattcampbell/eslint-config
yarn add @mattcampbell/eslint-config
bun add @mattcampbell/eslint-config
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.8.63 |
| Published | 2022-04-01 |
| First published | 2022-01-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=14.0.0 |
| Dependencies | 23 |
| Unpacked size | 32.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Matt Campbell |
| Maintainers | mattcampbell |
| Keywords | eslint, prettier, config |

## Links

- npm: https://www.npmjs.com/package/@mattcampbell/eslint-config
- Repository: https://github.com/mrmattrc/eslint-config
- Homepage: https://github.com/mrmattrc/eslint-config#readme
- Issues: https://github.com/mrmattrc/eslint-config/issues
- npm.io page: https://npm.io/package/@mattcampbell/eslint-config

## Dependencies (23)

- [prettier](https://npm.io/package/prettier.md) ^2.6.1
- [eslint-config-next](https://npm.io/package/eslint-config-next.md) 12.1.4
- [eslint-plugin-jest](https://npm.io/package/eslint-plugin-jest.md) ^26.1.3
- [eslint-plugin-react](https://npm.io/package/eslint-plugin-react.md) ^7.29.4
- [eslint-plugin-import](https://npm.io/package/eslint-plugin-import.md) ^2.25.4
- [eslint-plugin-cypress](https://npm.io/package/eslint-plugin-cypress.md) ^2.12.1
- [eslint-plugin-promise](https://npm.io/package/eslint-plugin-promise.md) ^6.0.0
- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) ^0.13.0
- [eslint-plugin-svelte3](https://npm.io/package/eslint-plugin-svelte3.md) ^3.4.1
- [eslint-plugin-unicorn](https://npm.io/package/eslint-plugin-unicorn.md) ^41.0.1
- [eslint-config-prettier](https://npm.io/package/eslint-config-prettier.md) ^8.5.0
- [eslint-plugin-jsx-a11y](https://npm.io/package/eslint-plugin-jsx-a11y.md) ^6.5.1
- [eslint-plugin-prettier](https://npm.io/package/eslint-plugin-prettier.md) ^4.0.0
- [@remix-run/eslint-config](https://npm.io/package/@remix-run/eslint-config.md) ^1.3.4
- [eslint-plugin-no-secrets](https://npm.io/package/eslint-plugin-no-secrets.md) ^0.8.9
- [@typescript-eslint/parser](https://npm.io/package/@typescript-eslint/parser.md) ^5.17.0
- [eslint-plugin-deprecation](https://npm.io/package/eslint-plugin-deprecation.md) ^1.3.2
- [eslint-plugin-react-hooks](https://npm.io/package/eslint-plugin-react-hooks.md) 4.4.0
- [eslint-plugin-chai-friendly](https://npm.io/package/eslint-plugin-chai-friendly.md) ^0.7.2
- [eslint-plugin-unused-imports](https://npm.io/package/eslint-plugin-unused-imports.md) ^2.0.0
- [eslint-plugin-eslint-comments](https://npm.io/package/eslint-plugin-eslint-comments.md) ^3.2.0
- [eslint-plugin-testing-library](https://npm.io/package/eslint-plugin-testing-library.md) ^5.2.0
- [@typescript-eslint/eslint-plugin](https://npm.io/package/@typescript-eslint/eslint-plugin.md) ^5.17.0

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@pandacss/eslint-plugin](https://npm.io/package/@pandacss/eslint-plugin.md) — 18.7K weekly downloads

## Recent versions

- 0.8.63 (latest) — 2022-04-01
- 0.8.62 — 2022-03-31
- 0.8.61 — 2022-03-31
- 0.8.60 — 2022-03-31
- 0.8.59 — 2022-03-31
- 0.8.58 — 2022-03-28
- 0.8.57 — 2022-03-28
- 0.8.56 — 2022-02-26
- 0.8.54 — 2022-01-24
- 0.8.53 — 2022-01-12
- 0.8.52 — 2022-01-12
- 0.8.51 — 2022-01-10
- 0.8.50 — 2022-01-10
- 0.8.49 — 2022-01-10
- 0.8.48 — 2022-01-10
- … 21 more at https://npm.io/package/@mattcampbell/eslint-config/versions

## README

[![npm version](https://badge.fury.io/js/@mattcampbell%2Feslint-config.svg)](https://badge.fury.io/js/@mattcampbell%2Feslint-config)

# eslint-config

A highly opinionated ESLint config. This config is designed to provide consistent behavior, enforce best practices, and minimize potential issues and errors. Because it is so opinionated, there will likely be a lot of errors when adding to an existing project. I recommend running the lint script to see what issues it finds and trying to fix as many of the issues as possible. However, there will definitely be cases where it is not worth the time or effort to fix various issues. When that happens, you can override any rule by adding it to your `.eslintrc` config.

## Getting started

Install `eslint @mattcampbell/eslint-config` (and `eslint-config-next` if using Next.js).

```bash
npm i -D eslint eslint-config-next @mattcampbell/eslint-config
```

Then create a `.eslintrc` file in the root of your project with

```json
{
    "extends": ["@mattcampbell/eslint-config/next"],
}
```
If you receive this error:
> "`Parsing error: Cannot read file '/users/mattcampbell/sites/skills-genome-project/tsconfig.json'.`"

You will need to specify the tsconfig.json in the `.eslintrc` file.

```json
{
    "parserOptions": {
      "project": ["./tsconfig.json"]
    }
}
```

### Running the linter

Add these scripts to your `package.json` file:

```json
"scripts": {
    "check-types": "tsc --noEmit --pretty",
    "eslint": "TIMING=1 eslint \"**/*.{js,jsx,ts,tsx}\" --quiet",
    "lint": "TIMING=1 eslint \"**/*.{js,jsx,ts,tsx}\" --quiet && npm run check-types",
    "lint:fix": "TIMING=1 eslint \"**/*.{js,jsx,ts,tsx}\" --quiet --fix && npm run check-types && npm run prettier",
    "prettier": "prettier --write ."
},
```

Then run `npm run lint` or run `npm run lint:fix` to fix all fixable issues.

### Versions

-   **CLI**: use `@mattcampbell/eslint-config/cli`
-   **Cypress**: use `@mattcampbell/eslint-config/cypress`
-   **Firebase Functions**: use `@mattcampbell/eslint-config/firebase-functions`
-   **Jest**: use `@mattcampbell/eslint-config/jest`
-   **Next**: use `@mattcampbell/eslint-config/next`
-   **React**: use `@mattcampbell/eslint-config/react`
-   **Svelte**: use `@mattcampbell/eslint-config/svelte`

When using a more specific config, the base config is not needed. For instance, with Next.js, this is all that's required:

```json
{
    "extends": ["@mattcampbell/eslint-config/next"]
}
```

## Integration with VS Code (recommended)

This is the easiest way to ensure ESLint is run every time you save a file, and that VS Code lints as you type, pointing out errors in real-time.

1. Create a new file `.vscode/settings.json`
2. Add this to the file:

```json
{
    "editor.codeActionsOnSave": {
      "source.fixAll.eslint": true
    },
    "eslint.run": "onType"
}
```

> **Note**: when you first open the repo with this ESLint configuration, it can take up to a minute for VS Code to start linting. You'll still be able to edit files in the meantime.

## Use with Prettier

This config has Prettier built-in. If you use Prettier with your code editor or use a `.prettierrc` file, there will likely be conflicts. It's best to remove any `.prettierrc` files you may have and disable Prettier in your code editor.

> **Rationale**: this ESLint config is highly opinionated and is a living config. As best practices evolve, this config will evolve. Since Prettier is 100% fixable, that means that your code will always follow this config and therefore always follow best practices. If you override the formatting with Prettier, you forgo any future updates in regard to Prettier formatting.

**Note**: If using the Svelte config, you need to setup Prettier manually. This is because the plugin `prettier-plugin-svelte` (which is needed to parse Svelte) [does not work with ESLint](https://github.com/sveltejs/prettier-plugin-svelte/issues/57).

## Use without TypeScript

Currently, all the configs require TypeScript. Vanilla JS is currently not supported.

## What rules are enabled?

In short, this config runs 500+ rules (and counting). Luckily, the source code is easy to read, so you should not have an issue reading the rules there.

## I found a bug, what do I do?

If you found a bug or rule conflicts, [submit an issue on GitHub](https://github.com/mrmattrc/eslint-config/issues).

---
_Source: https://npm.io/package/@mattcampbell/eslint-config · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
