A Strict, Awesome ESLint Config
Megabyte Labs
A configuration managed byESLint configuration for linting TS, JS, JSON, YAML, and TOML
Table of Contents
Overview
This ESLint configuration package includes basically every quality ESLint plugin available. The default settings are meant to enforce strict design patterns among developers who code with TypeScript and JavaScript. It also includes linting rules for JSON, YAML, and TOML. Most of the rules include auto-fix functionality and it even sorts JSON and YAML. You can use this configuration as is or customize it to your liking so you can have your own shared ESLint configuration package!
Requirements
If you are simply including this library in your project, all you need is a recent version of Node.js. Node.js >14.18.0 is sometimes required and is the only version range we actively support. Albeit, it is highly probable that lower versions will work as well depending on the requirements that this project imports.
Developer Requirements
The following versions of Node.js and Python are required for development:
Other versions may work, but only the above versions are supported. Most development dependencies are installed automatically by our Taskfile.yml
set-up (even Node.js and Python). Run bash start.sh
to install Bodega (an improved fork of go-task) and run the initialization sequence. The taskfiles will automatically install dependencies as they are needed, based on what development tasks you are running. For more information, check out the CONTRIBUTING.md or simply run:
npm run help
npm run help
will ensure Bodega is installed and then open an interactive dialog where you can explore and learn about various developer commands.
Usage
To make use of this configuration, you need to first install the configuration in your Node.js project:
npm install --save-dev eslint-config-strict-mode
After that, you need to include a reference to the package in your package.json
:
{
"name": "mynpmpackage",
"version": "0.0.1",
...
"eslintConfig": {
"extends": "eslint-config-strict-mode"
}
}
You can override the settings that are provided by the plugin by including additional rules in your package.json
. For instance, if you wanted to turn off a rule named max-len
, your package.json
would look something like this:
{
"name": "mynpmpackage",
"version": "0.0.1",
...
"eslintConfig": {
"extends": "eslint-config-strict-mode",
"rules": {
"max-len": "off"
}
}
}
Plugins
The following ESLint plugins are included in this configuration:
ESLint Plugin | Description |
---|---|
@typescript-eslint/eslint-plugin |
An ESLint plugin which provides lint rules for TypeScript codebases |
@typescript-eslint/eslint-plugin-tslint |
ESLint plugin that wraps a TSLint configuration and lints the whole source using TSLint |
@typescript-eslint/parser |
An ESLint parser which leverages TypeScript ESTree to allow for ESLint to lint TypeScript source code |
eslint-config-prettier |
Turns off all rules that are unnecessary or might conflict with Prettier |
eslint-formatter-git-log |
Formatter that displays results that include the name of the developer who is responsible for the error |
eslint-formatter-gitlab |
Formatter for GitLab CI that integrates results into merge requests |
eslint-formatter-pretty |
Stylish formatter for terminal results that includes features such as clicking result to open code in editor |
eslint-formatter-summary |
Alternate formatting style for the results that displays a table |
eslint-plugin-angular |
Rules for Angular applications |
eslint-plugin-array-func |
Rules for Array functions and methods |
eslint-plugin-editorconfig |
An ESLint plugin to enforce EditorConfig rules |
eslint-plugin-eslint-comments |
Additional ESLint rules for ESLint directive comments |
eslint-plugin-etc |
More generalcpurpose TypeScript-related ESLint rules |
eslint-plugin-ext |
eslint extended rules |
eslint-plugin-filenames |
ESLint plugin to check filenames |
eslint-plugin-fp |
ESLint rules for functional programming |
eslint-plugin-functional |
ESLint plugin to disable mutation and promote functional programming in JavaScript and TypeScript |
eslint-plugin-import |
ESLint plugin with rules that help validate proper imports |
eslint-plugin-jest |
ESLint plugin for Jest |
eslint-plugin-jest-async |
ESLint rules for Jest to detect improper test assertions for asynchronous actions |
eslint-plugin-jest-dom |
Lint DOM API performance |
eslint-plugin-jest-formatting |
Linting rules for ESLint realted to code style formatting |
eslint-plugin-jsdoc |
Rules that enforce comments written in JSDoc syntax |
eslint-plugin-json-schema-validator |
ESLint plugin that validates data using JSON Schema Validator |
eslint-plugin-jsonc |
ESLint plugin for JSON, JSONC and JSON5 files |
eslint-plugin-no-constructor-bind |
Prefer class arrow functions to binding in the constructor |
eslint-plugin-no-explicit-type-exports |
A plugin to guard against exporting imported types |
eslint-plugin-no-secrets |
An ESLint plugin to find strings that might be secrets or credentials |
eslint-plugin-no-unsanitized |
Custom ESLint rule to disallows unsafe innerHTML, outerHTML, insertAdjacentHTML and alike |
eslint-plugin-no-use-extend-native |
ESLint plugin to prevent use of extended native objects |
eslint-plugin-node |
Additional ESLint's rules for Node.js |
eslint-plugin-optimize-regex |
Optimize regex literals |
eslint-plugin-prefer-arrow |
ESLint plugin to prefer arrow functions |
eslint-plugin-prettier |
ESLint plugin to prefer arrow functions |
eslint-plugin-promise |
Enforce best practices for JavaScript promises |
eslint-plugin-regexp |
ESLint plugin for finding RegExp mistakes and RegExp style guide violations |
eslint-plugin-rxjs |
ESLint rules for RxJS |
eslint-plugin-security |
ESLint rules for Node Security |
eslint-plugin-sonarjs |
SonarJS rules for ESLint |
eslint-plugin-sort-class-members |
ESLint rule for enforcing consistent ES6 class member order |
eslint-plugin-sort-keys-fix |
Fork of eslint rule that sorts keys in objects with autofix enabled |
eslint-plugin-switch-case |
Switch-case-specific linting rules for ESLint |
eslint-plugin-toml |
ESLint plugin provides linting rules for TOML |
eslint-plugin-tsdoc |
This ESLint plugin provides a rule for validating that TypeScript doc comments conform to the TSDoc specification |
eslint-plugin-typescript-sort-keys |
A linter plugin to require sorting interface and string enum keys |
eslint-plugin-unicorn |
Various awesome ESLint rules |
eslint-plugin-unused-imports |
Package to seperate no-unused-vars and no-unused-imports for ESLint as well as providing an autofixer for the latter |
eslint-plugin-woke |
ESLint plugin to promote diversity and inclusion in codebases by restricting the presence of certain potentially offensive keywords |
eslint-plugin-yml |
ESLint plugin provides linting rules for YAML |
Most of the items in the chart above are plugins used for extending the core functionality of ESLint. These all start off with eslint-plugin-
. However, there are a few items that begin with eslint-formatter-
. These allow you to change the format that ESLint reports with. You can, for instance, run the following to change the format of the results:
eslint --format pretty --fix .
Contributing
Contributions, issues, and feature requests are welcome! Feel free to check the issues page. If you would like to contribute, please take a look at the contributing guide.
Sponsorship
Dear Awesome Person,
I create open source projects out of love. Although I have a job, shelter, and as much fast food as I can handle, it would still be pretty cool to be appreciated by the community for something I have spent a lot of time and money on. Please consider sponsoring me! Who knows? Maybe I will be able to quit my job and publish open source full time.
Sincerely,
Brian Zalewski
Affiliates
Below you will find a list of services we leverage that offer special incentives for signing up for their services through our special links:
License
Copyright © 2020-2021 Megabyte LLC. This project is MIT licensed.