Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit 87b27f1

Browse files
authored
feat: add eslint-plugin-promise (#162)
1 parent 694223a commit 87b27f1

23 files changed

+415
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"eslint-plugin-n": "~15.6.0",
7373
"eslint-plugin-node": "~11.1.0",
7474
"eslint-plugin-prettier": "~4.2.1",
75+
"eslint-plugin-promise": "~6.1.1",
7576
"eslint-plugin-sonarjs": "~0.17.0",
7677
"eslint-plugin-spellcheck": "~0.0.20",
7778
"eslint-plugin-unicorn": "~45.0.2",

pnpm-lock.yaml

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/generate-rule-files/src/plugins-map.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import eslintPluginJSDoc from 'eslint-plugin-jsdoc';
77
import eslintPluginJsonc from 'eslint-plugin-jsonc';
88
import * as eslintPluginMdx from 'eslint-plugin-mdx';
99
// @ts-expect-error
10+
import eslintPluginPromise from 'eslint-plugin-promise';
11+
// @ts-expect-error
1012
import eslintPluginNode from 'eslint-plugin-node';
1113
// @ts-expect-error
1214
import eslintPluginN from 'eslint-plugin-n';
@@ -72,6 +74,10 @@ export const PLUGIN_REGISTRY: Readonly<Record<string, Plugin>> = {
7274
name: 'Node',
7375
rules: (eslintPluginNode as Plugin).rules,
7476
},
77+
promise: {
78+
name: 'Promise',
79+
rules: (eslintPluginPromise as Plugin).rules,
80+
},
7581
sonarjs: {
7682
name: 'SonarJS',
7783
prefix: 'sonarjs',
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* Eslint promise extensions.
3+
*
4+
* @see [Eslint promise extensions](https://github.com/eslint-community/eslint-plugin-promise#usage)
5+
*/
6+
export type PromiseExtensions = 'plugin:promise/recommended';

src/config/extends/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type { MdxExtensions } from './eslint-plugin-mdx';
77
import type { NExtensions } from './eslint-plugin-n';
88
import type { NodeExtensions } from './eslint-plugin-node';
99
import type { PrettierExtensions } from './eslint-plugin-prettier';
10+
import type { PromiseExtensions } from './eslint-plugin-promise';
1011
import type { SonarjsExtensions } from './eslint-plugin-sonarjs';
1112
import type { UnicornExtensions } from './eslint-plugin-unicorn';
1213
import type { VueExtensions } from './eslint-plugin-vue';
@@ -27,6 +28,7 @@ export type KnownExtensions = LiteralUnion<
2728
| NExtensions
2829
| NodeExtensions
2930
| PrettierExtensions
31+
| PromiseExtensions
3032
| SonarjsExtensions
3133
| TypescriptEslintExtensions
3234
| UnicornExtensions

src/config/plugin.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export type Plugin = LiteralUnion<
99
| 'jsdoc'
1010
| 'mdx'
1111
| 'prettier'
12+
| 'promise'
1213
| 'sonarjs'
1314
| 'spellcheck'
1415
| 'unicorn'

src/rules/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { JSDocRules } from './jsdoc';
55
import type { JsoncRules } from './jsonc';
66
import type { NRules } from './n';
77
import type { NodeRules } from './node';
8+
import type { PromiseRules } from './promise';
89
import type { RuleConfig } from './rule-config';
910
import type { SonarJSRules } from './sonarjs';
1011
import type { SpellcheckRules } from './spellcheck';
@@ -27,6 +28,7 @@ export type Rules = Partial<
2728
JsoncRules &
2829
NodeRules &
2930
NRules &
31+
PromiseRules &
3032
SonarJSRules &
3133
SpellcheckRules &
3234
TypeScriptRules &

src/rules/promise/always-return.d.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Option.
5+
*/
6+
export interface AlwaysReturnOption {
7+
ignoreLastCallback?: boolean;
8+
}
9+
10+
/**
11+
* Options.
12+
*/
13+
export type AlwaysReturnOptions = [AlwaysReturnOption?];
14+
15+
/**
16+
*
17+
* @see [always-return](https://github.com/eslint-community/eslint-plugin-promise/blob/main/docs/rules/always-return.md)
18+
*/
19+
export type AlwaysReturnRuleConfig = RuleConfig<AlwaysReturnOptions>;
20+
21+
/**
22+
*
23+
* @see [always-return](https://github.com/eslint-community/eslint-plugin-promise/blob/main/docs/rules/always-return.md)
24+
*/
25+
export interface AlwaysReturnRule {
26+
/**
27+
*
28+
* @see [always-return](https://github.com/eslint-community/eslint-plugin-promise/blob/main/docs/rules/always-return.md)
29+
*/
30+
'promise/always-return': AlwaysReturnRuleConfig;
31+
}

src/rules/promise/avoid-new.d.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
*
5+
* @see [avoid-new](https://github.com/eslint-community/eslint-plugin-promise/blob/main/docs/rules/avoid-new.md)
6+
*/
7+
export type AvoidNewRuleConfig = RuleConfig<[]>;
8+
9+
/**
10+
*
11+
* @see [avoid-new](https://github.com/eslint-community/eslint-plugin-promise/blob/main/docs/rules/avoid-new.md)
12+
*/
13+
export interface AvoidNewRule {
14+
/**
15+
*
16+
* @see [avoid-new](https://github.com/eslint-community/eslint-plugin-promise/blob/main/docs/rules/avoid-new.md)
17+
*/
18+
'promise/avoid-new': AvoidNewRuleConfig;
19+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Option.
5+
*/
6+
export interface CatchOrReturnOption {
7+
allowFinally?: boolean;
8+
allowThen?: boolean;
9+
terminationMethod?: string | string[];
10+
}
11+
12+
/**
13+
* Options.
14+
*/
15+
export type CatchOrReturnOptions = [CatchOrReturnOption?];
16+
17+
/**
18+
*
19+
* @see [catch-or-return](https://github.com/eslint-community/eslint-plugin-promise/blob/main/docs/rules/catch-or-return.md)
20+
*/
21+
export type CatchOrReturnRuleConfig = RuleConfig<CatchOrReturnOptions>;
22+
23+
/**
24+
*
25+
* @see [catch-or-return](https://github.com/eslint-community/eslint-plugin-promise/blob/main/docs/rules/catch-or-return.md)
26+
*/
27+
export interface CatchOrReturnRule {
28+
/**
29+
*
30+
* @see [catch-or-return](https://github.com/eslint-community/eslint-plugin-promise/blob/main/docs/rules/catch-or-return.md)
31+
*/
32+
'promise/catch-or-return': CatchOrReturnRuleConfig;
33+
}

0 commit comments

Comments
 (0)