Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kitnato/eslint-config-succinct

Strict & opinionated ESLint config for React+Typescript projects.
https://github.com/kitnato/eslint-config-succinct

eslint eslint-plugin typescript

Last synced: 28 days ago
JSON representation

Strict & opinionated ESLint config for React+Typescript projects.

Awesome Lists containing this project

README

        

# eslint-config-succinct

An [ESLint](https://eslint.org/) configuration library for projects based on React 18+ with Typescript 5+.

## Purpose

This is an **opinionated** ESLint configuration that enforces consistent usage of ES6 & [strict](https://typescript-eslint.io/linting/configs/#strict) TypeScript non-OOP paradigms, as well as stylistic rules. It encourages adherence to functional-programming & accessibility best practices and restricts certain language features that are prone to anti-patterns.

> NB: Not be used alongside [Prettier](https://prettier.io/), since this config includes [@stylistic/eslint-plugin](https://eslint.style/) which supersedes its rules.

## Particularities

Notable linting rules include:

- `class` declarations are disallowed (encouraging the use of pure functions).
- `default` exports are disallowed (named exports keep imports consistent).
- `interface` declarations are disallowed (avoids [declaration merging](https://www.typescriptlang.org/docs/handbook/declaration-merging.html#merging-interfaces) - use `type` instead).
- `enum` declarations are disallowed (use string [unions](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types) instead).
- Object keys, union types, imports and component props are sorted in case-insensitive alphabetical order.
- Unused variables in object spreads or function arguments can be denoted by prefixing with a "_".
- Semicolons are not used, instead relying on [ASI](https://262.ecma-international.org/7.0/#sec-rules-of-automatic-semicolon-insertion).
- Enforces use of tab characters instead of spaces for indentation. This [article](https://www.alpharithms.com/tabs-vs-spaces-the-timeless-debate-581511) lays out the debate, with pros and cons.

## Installation

First, install this package alongside `eslint`:

```sh
npm install -D @kitnato/eslint-config-succinct eslint
```

Next, create the `.eslintrc.json` configuration file at the root of your project:

```json
{
"extends": "@kitnato/eslint-config-succinct",
}
```

Remember to [set](https://eslint.org/docs/latest/user-guide/configuring/ignoring-code) here any `ignorePatterns` if you require them beyond the standard `build` and `dist` folders, along with any other config overrides you may desire.

## Usage

Once installed, you can run any `eslint` command.

You may also define scripts that will lint, fix and format your files to help automate your workflow.

For example, in your `package.json`, add the following under `scripts`:

```json
"scripts": {
"lint-code": "eslint --fix --ext .ts,.tsx .",
}
```

## IDE setup

### VS Code

If you use Microsoft VS Code, you can add the following snippet at the top of your `.vscode/settings.json` to automatically run the linter and fix all issues whenever a file is saved.

```json
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
"eslint.format.enable": true,
```

## License

This work is licensed under the [GNU General Public License version 3](https://www.gnu.org/licenses/gpl-3.0.en.html).