Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/blurfx/eslint-plugin-no-utility-type
ESLint plugin to disallow TypeScript utility types
https://github.com/blurfx/eslint-plugin-no-utility-type
eslint eslint-plugin types typescript typescript-eslint
Last synced: 24 days ago
JSON representation
ESLint plugin to disallow TypeScript utility types
- Host: GitHub
- URL: https://github.com/blurfx/eslint-plugin-no-utility-type
- Owner: blurfx
- License: mit
- Created: 2023-04-29T16:35:25.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-29T16:54:22.000Z (almost 2 years ago)
- Last Synced: 2024-12-22T16:37:40.348Z (about 2 months ago)
- Topics: eslint, eslint-plugin, types, typescript, typescript-eslint
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/eslint-plugin-no-utility-type
- Size: 48.8 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# eslint-plugin-no-utility-type
eslint-plugin-no-utility-type is an eslint plugin that prevents the use of utility types for concrete types.
## Installation
```sh
npm install -D eslint-plugin-no-utility-type
# or
yarn add -D eslint-plugin-no-utility-type
# or
pnpm add -D eslint-plugin-no-utility-type
```## Usage
Add the `no-utility-type` plugin to your `.eslintrc`, and add the `no-utility-type/disallow` rule.
By default, the `Omit`, `Exclude`, `Pick`, and `Extract` types are not allowed.
```json
{
"plugins": ["no-utility-type"],
"rules": {
"no-utility-type/disallow": "error"
}
}
```Use the `types` option to manually set the types to disallow.
```json
{
"plugins": ["no-utility-type"],
"rules": {
"no-utility-type/disallow": [
"error",
{
"types": ["Omit", "Exclude", "Record"]
}
]
}
}
```You CANNOT set a type that is not a TypeScript built-in type., in which case the linter will report an error.
For example:
```ts
// eslint error: User-defined type 'MyRecord' should be allowed
type myRecord = MyRecord;
``````json
{
"plugins": ["no-utility-type"],
"rules": {
"no-utility-type/disallow": [
"error",
{
"types": ["Omit", "Exclude", "MyRecord"]
}
]
}
}
```