Skip to content

remcohaszing/eslint

Repository files navigation

@remcohaszing/eslint

A strict ESLint configuration

build status codecov npm prettier

This is a strict shareable ESLint configuration. All ESLint core rules and a variety of ESLint plugins have been carefully considered. Overrides are used to apply rules based on context.

Table of Contents

Installation

Install @remcohaszing/eslint using npm.

npm install --save-dev \
  eslint \
  @remcohaszing/eslint \
  prettier

Configuration

First configure Prettier. For example, create a .editorconfig with the following content:

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 100
trim_trailing_whitespace = true

And create a .prettierrc.yaml with the following content:

proseWrap: always
singleQuote: true
trailingComma: all

Next, create eslint.config.js with the following content:

export { default } from '@remcohaszing/eslint'

TypeScript

This configuration enabled ESLint for TypeScript automatically.

Some rules from @typescript-eslint/eslint-plugin require TypeScript type checking features to be enabled. Unfortunately, this makes ESLint slow. Enabling these rules is recommended for small projects only. To enable this, add the following to eslint.config.js:

import config, { typechecking } from '@remcohaszing/eslint'

export default [...config, ...typechecking]

Markdown

Code blocks in Markdown are linted by default using @eslint/markdown. The type checking rules from @typescript-eslint/eslint-plugin don’t work with markdown code blocks.

prettier/prettier is disabled, because it doesn’t play nice with eslint-plugin-markdown.

Some other rules have been turned off, because these rules may conflict with the purpose of the documentation.

Disabling rules

Rules can be disabled by adding an extra ESLint configuration item to the configuration array. For example:

import config from '@remcohaszing/eslint'

export default [
  ...config,
  {
    rules: {
      'no-console': 'off'
    }
  }
]

Ignored files

By default ESLint ignores node_modules/ and all dotfiles. This ESLint configuration also ignores the patterns from .gitignore.

Warnings

All ESLint that are turned on will trigger error, not warnings. The notable exceptions is @typescript-eslint/no-deprecated.

This is to allow a smooth migration if a dependency decides to deprecate an API. To turn make warnings cause ESLint to exit with exit code 1, run:

eslint

Compatibility

This project requires Node.js 22 or greater.

License

MIT © Remco Haszing