https://github.com/printfn/eslint-no-promise-combinators
ESLint plugin to disallow promise combinator functions `.then()`, `.catch()` and `.finally()`
https://github.com/printfn/eslint-no-promise-combinators
async eslint eslint-plugin eslint-rules promises
Last synced: 3 months ago
JSON representation
ESLint plugin to disallow promise combinator functions `.then()`, `.catch()` and `.finally()`
- Host: GitHub
- URL: https://github.com/printfn/eslint-no-promise-combinators
- Owner: printfn
- License: mit
- Created: 2024-11-16T09:21:49.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-11-17T00:07:05.000Z (7 months ago)
- Last Synced: 2025-01-18T07:12:59.351Z (5 months ago)
- Topics: async, eslint, eslint-plugin, eslint-rules, promises
- Language: TypeScript
- Homepage:
- Size: 24.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# eslint-no-promise-combinators
This adds an eslint rule to disallow the promise combinator functions `.then()`,
`.catch()` and `.finally()`.Instead of writing:
```typescript
checkMail()
.then(mail => {
console.log(mail);
})
.catch(err => {
console.error(err);
})
.finally(() => {
console.log('Experiment completed');
});
```You should write:
```typescript
try {
const mail = await checkMail();
console.log(mail);
} catch (err: unknown) {
console.error(err);
} finally {
console.log('Experiment completed');
}
```## Usage
Install this package:
```sh
npm install -D eslint-no-promise-combinators
```Then add this to your `eslint.config.ts` file:
```typescript
import { noPromiseCombinators } from 'eslint-no-promise-combinators';export default tseslint.config(
{
plugins: {
'no-promise-combinators': noPromiseCombinators,
},
rules: {
'no-promise-combinators/no-promise-combinators': 'error',
},
},
);
```