All packages are in alpha and currently being tested and worked upon and are not stable.
This repository provides a modular ESLint configuration. It provides opinionated defaults for TypeScript projects with a few different (optional) flavours.
If you want to use this configuration or even just parts of it as a base for your own configuration, the configuration is modular, and you can install just parts of it to construct your own configuration, too.
Attention: This configuration is written in ESLint's flat configuration style. You can read more about it in the ESLint documentation.
- TypeScript configuration
- Based on
eslint-config-airbnb
andeslint-config-airbnb-typescript
- Uses
eslint-plugin-import
andeslint-plugin-unicorn
- Based on
- Opinionated configuration
- Modular configuration split in
bases
,addons
andoverrides
.- Bases provide the core configuration.
- Addons provide appropriate plugins and common-sense rules.
For example,
eslint-config-addon-jest
provides the Jest plugin, automatically applies globals for Node.js, and makes sure dev dependency in*.test.[ext]
files are allowed! - Overrides provide rules for specific files.
For example,
eslint-config-override-development-files
allows imports of dev dependencies in the project root.
eslint-config-addon-prettier
(Prettier)eslint-config-addon-react
(React.js)eslint-config-addon-next
(Next.js)eslint-config-addon-jest
(Jest)eslint-config-addon-testing-library-react
(@testing-library/react)eslint-config-addon-vitest
(Vitest)
eslint-config-base-base
eslint-config-base-typescript
eslint-config-base-unicorn
(eslint-plugin-unicorn)eslint-config-base-import
(eslint-plugin-import)
eslint-config-override-development-files
(Files in the project root)eslint-config-override-index-files
(index.ext
files)
npm install --save-dev @nightgrey/eslint-config
eslint.config.js
import nightgreyEslintConfig from '@nightgrey/eslint-config';
import globals from 'globals';
/** @type {import('eslint').Linter.FlatConfig} */
const configuration = {
// Your own configuration goes here, after the base configuration.
// Important: You have to set your own language options depending on your project.
// This code here assumes a Node.js project with ES2021 globals and TypeScript.
// For more information, see https://eslint.org/docs/user-guide/configuring/language-options
languageOptions: {
parserOptions: {
ecmaVersion: 'latest',
project: './tsconfig.json',
},
globals: {
...globals.node,
...globals.es2021,
},
},
};
// Then, make sure to export the configuration array and to spread `nightgreyEslintConfig` first!
/** @type {Array<import('eslint').Linter.FlatConfig>} */
export default [...nightgreyEslintConfig, configuration];
To use addons or overrides, you have to install them as dependencies and add them to your configuration.
This is a configuration with all addons and overrides installed.
eslint.config.js
import eslintConfigGrey from '@nightgrey/eslint-config';
import { prettierAddon } from '@nightgrey/eslint-config-addon-prettier';
import { reactAddon } from '@nightgrey/eslint-config-addon-react';
import { nextAddon } from '@nightgrey/eslint-config-addon-next';
import { jestAddon } from '@nightgrey/eslint-config-addon-jest';
import { vitestAddon } from '@nightgrey/eslint-config-addon-vitest';
import { developmentFilesOverrides } from '@nightgrey/eslint-config-override-development-files';
import { indexFilesOverrides } from '@nightgrey/eslint-config-override-index-files';
import { testingLibraryReactAddon } from '@nightgrey/eslint-config-addon-testing-library-react';
import globals from 'globals';
/** @type {import('eslint').Linter.FlatConfig} */
const configuration = {
// Your own configuration goes here.
// See `Getting started` above for an example.
};
// Order:
// 1. Bases (or eslintConfigGrey)
// 2. Addons
// 3. Your configuration
// 4. Overrides
// Always last: Prettier addon
/** @type {Array<import('eslint').Linter.FlatConfig>} */
export default [
// Bases
...eslintConfigGrey,
// Addons
reactAddon,
nextAddon,
jestAddon,
testingLibraryReactAddon,
// Your configuration
configuration,
// Overrides have to be added after addons and your own configuration.
developmentFilesOverrides,
indexFilesOverrides,
// Important: It is recommended to add the prettier addon last.
prettierAddon,
];
- Add better tests
- Add documentation for each package
- Add presets
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
Distributed under the MIT License. See LICENSE.txt
for more information.