https://github.com/tomerh2001/eslint-plugin-th-rules
Custom ESLint rules for improving consistency across projects.
https://github.com/tomerh2001/eslint-plugin-th-rules
eslint eslint-plugin eslint-rule eslint-rules
Last synced: 5 months ago
JSON representation
Custom ESLint rules for improving consistency across projects.
- Host: GitHub
- URL: https://github.com/tomerh2001/eslint-plugin-th-rules
- Owner: tomerh2001
- Created: 2024-02-22T18:04:51.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2026-01-23T18:56:39.000Z (5 months ago)
- Last Synced: 2026-01-24T08:57:39.980Z (5 months ago)
- Topics: eslint, eslint-plugin, eslint-rule, eslint-rules
- Language: TypeScript
- Homepage:
- Size: 4.4 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# eslint-plugin-th-rules
[](https://github.com/semantic-release/semantic-release)
[](https://github.com/xojs/xo)
[](../../actions/workflows/snyk-security.yml)
[](../../actions/workflows/codeql.yml)
[](https://securityscorecards.dev/viewer/?uri=github.com/tomerh2001/eslint-plugin-th-rules)
A set of custom ESLint rules designed to improve code quality, enforce consistency, and introduce development conventions across TypeScript, React, and JavaScript projects.
This plugin provides:
- Custom rules unique to this repository
- Recommended flat configs that bundle th-rules with popular third-party plugins
- Advanced composable config layers for consumers who want fine-grained control
---
# Installation
```bash
npm install --save-dev eslint-plugin-th-rules
```
or
```bash
yarn add -D eslint-plugin-th-rules
```
This plugin requires ESLint Flat Config (ESLint 8.21+).
---
# Usage
The plugin exposes three public recommended configurations.
These are the presets most users should consume.
## Recommended (Full Opinionated)
Includes:
- All th-rules
- External plugins (lodash, n, sonarjs, security)
- Opinionated rule settings for externals
```js
// eslint.config.js
import thRules from "eslint-plugin-th-rules";
export default [
...thRules.configs.recommended
];
```
## Recommended + TypeScript
Recommended plus full strict/stylistic TypeScript configurations.
```js
import thRules from "eslint-plugin-th-rules";
export default [
...thRules.configs.recommendedTypescript
];
```
## Recommended + React
Recommended plus:
- eslint-plugin-react
- eslint-plugin-react-hooks
- JSX Runtime rules
```js
import thRules from "eslint-plugin-th-rules";
export default [
...thRules.configs.recommendedReact
];
```
## Recommended + TypeScript + React
Recommended plus TypeScript and React extensions.
```js
import thRules from "eslint-plugin-th-rules";
export default [
...thRules.configs.recommendedTypescriptReact
];
```
---
# Advanced Composition (Optional)
If you want total control, you may import internal composition layers.
These layers are intentionally not included in `configs`, because they are not presets but building blocks.
```js
import {
coreBase,
externalsBase,
externalsOpinionated,
coreTypescript,
coreReact
} from "eslint-plugin-th-rules";
```
### Only use th-rules
```js
export default [
...coreBase
];
```
### Add external plugins (unstyled)
```js
export default [
...coreBase,
...externalsBase
];
```
### Add external plugins + th-rules opinions
```js
export default [
...coreBase,
...externalsBase,
...externalsOpinionated
];
```
### Add TypeScript or React extensions
```js
export default [
...coreBase,
...externalsBase,
...externalsOpinionated,
...coreTypescript,
...coreReact
];
```
---
# Auto-Generated Rule Documentation
The following section is generated via `eslint-doc-generator`.
Do not edit below this line.
## Rules
πΌ Configurations enabled in.\
β
Set in the `recommended` configuration.\
βοΈ Set in the `recommendedReact` configuration.\
π¦ Set in the `recommendedTypescript` configuration.\
π² Set in the `recommendedTypescriptReact` configuration.\
π§ Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).
| NameΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β | Description | πΌ | π§ |
| :------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------- | :- |
| [no-boolean-coercion](docs/rules/no-boolean-coercion.md) | Disallow Boolean(value) or !!value. Enforce explicit checks: !_.isNil(value) for scalars and !_.isEmpty(value) for strings, arrays, and objects. If the value is already boolean, remove coercion. | β
βοΈ π¦ π² | π§ |
| [no-comments](docs/rules/no-comments.md) | Disallow comments except for specified allowed patterns. | β
βοΈ π¦ π² | π§ |
| [no-default-export](docs/rules/no-default-export.md) | Convert unnamed default exports to named default exports based on the file name. | β
βοΈ π¦ π² | π§ |
| [no-destructuring](docs/rules/no-destructuring.md) | Disallow destructuring that does not meet certain conditions. | β
βοΈ π¦ π² | |
| [no-explicit-nil-compare](docs/rules/no-explicit-nil-compare.md) | Disallow direct comparisons to null or undefined. Use _.isNull(x) / _.isUndefined(x) instead. | β
βοΈ π¦ π² | π§ |
| [prefer-explicit-nil-check](docs/rules/prefer-explicit-nil-check.md) | Disallow implicit truthy/falsy checks in boolean-test positions. Prefer explicit _.isNil(value) or _.isEmpty(value) (depending on the value type). | β
βοΈ π¦ π² | π§ |
| [prefer-is-empty](docs/rules/prefer-is-empty.md) | Require _.isEmpty instead of length comparisons or boolean checks on .length. | β
βοΈ π¦ π² | π§ |
| [schemas-in-schemas-file](docs/rules/schemas-in-schemas-file.md) | Require Zod schema declarations to be placed in a .schemas.ts file. | β
βοΈ π¦ π² | |
| [top-level-functions](docs/rules/top-level-functions.md) | Require all top-level functions to be named regular functions. | β
βοΈ π¦ π² | π§ |
| [types-in-dts](docs/rules/types-in-dts.md) | Require TypeScript type declarations (type/interface/enum) to be placed in .d.ts files. | β
βοΈ π¦ π² | |
---
# License
MIT