Skip to content

Commit ecbce9f

Browse files
authored
feat: add support for flat config (#479)
1 parent 4dfc8a7 commit ecbce9f

18 files changed

+277
-111
lines changed

β€Ž.eslint-doc-generatorrc.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/** @type {import('eslint-doc-generator').GenerateOptions} */
2+
module.exports = {
3+
configEmoji: [
4+
['recommended', 'βœ…'],
5+
['flat/recommended', 'βœ…'],
6+
],
7+
postprocess: (doc) => {
8+
return doc.replace(/βœ…\s*βœ…/gu, 'βœ…')
9+
},
10+
}

β€ŽREADME.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,23 @@ Then configure the rules you want to use under the rules section.
6868

6969
or start with the recommended rule set:
7070

71-
```json
72-
{
73-
"extends": ["plugin:promise/recommended"]
74-
}
75-
```
71+
- `eslint.config.js`:
72+
73+
```js
74+
import pluginPromise from 'eslint-plugin-promise'
75+
export default [
76+
// ...
77+
pluginPromise.configs['flat/recommended'],
78+
]
79+
```
80+
81+
- `.eslintrc.*`:
82+
83+
```json
84+
{
85+
"extends": ["plugin:promise/recommended"]
86+
}
87+
```
7688

7789
## Rules
7890

@@ -81,9 +93,9 @@ or start with the recommended rule set:
8193
πŸ’Ό Configurations enabled in.\
8294
⚠️ Configurations set to warn in.\
8395
🚫 Configurations disabled in.\
96+
βœ… Set in the `flat/recommended` configuration.\
8497
βœ… Set in the `recommended` configuration.\
85-
πŸ”§ Automatically fixable by the
86-
[`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).
98+
πŸ”§ Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).
8799

88100
| NameΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  | Description | πŸ’Ό | ⚠️ | 🚫 | πŸ”§ |
89101
| :------------------------------------------------------------------- | :------------------------------------------------------------------------------------- | :-- | :-- | :-- | :-- |

β€Ž__tests__/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,11 @@
33
test('can require index file', () => {
44
expect(require('../index')).toBeInstanceOf(Object)
55
})
6+
7+
test('rule set', () => {
8+
const plugin = require('../index')
9+
expect(plugin.configs.recommended.rules).toEqual(
10+
plugin.configs['flat/recommended'].rules
11+
)
12+
expect(plugin.configs['flat/recommended'].plugins.promise).toBe(plugin)
13+
})

β€Ždocs/rules/always-return.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Require returning inside each `then()` to create readable and reusable Promise chains (`promise/always-return`)
22

3-
πŸ’Ό This rule is enabled in the βœ… `recommended` config.
3+
πŸ’Ό This rule is enabled in the following configs: βœ… `flat/recommended`, βœ…
4+
`recommended`.
45

56
<!-- end auto-generated rule header -->
67

β€Ždocs/rules/avoid-new.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Disallow creating `new` promises outside of utility libs (use [pify][] instead) (`promise/avoid-new`)
22

3-
🚫 This rule is _disabled_ in the βœ… `recommended` config.
3+
🚫 This rule is _disabled_ in the following configs: βœ… `flat/recommended`, βœ…
4+
`recommended`.
45

56
<!-- end auto-generated rule header -->
67

β€Ždocs/rules/catch-or-return.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Enforce the use of `catch()` on un-returned promises (`promise/catch-or-return`)
22

3-
πŸ’Ό This rule is enabled in the βœ… `recommended` config.
3+
πŸ’Ό This rule is enabled in the following configs: βœ… `flat/recommended`, βœ…
4+
`recommended`.
45

56
<!-- end auto-generated rule header -->
67

β€Ždocs/rules/no-callback-in-promise.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Disallow calling `cb()` inside of a `then()` (use [nodeify][] instead) (`promise/no-callback-in-promise`)
22

3-
⚠️ This rule _warns_ in the βœ… `recommended` config.
3+
⚠️ This rule _warns_ in the following configs: βœ… `flat/recommended`, βœ…
4+
`recommended`.
45

56
<!-- end auto-generated rule header -->
67

β€Ždocs/rules/no-native.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Require creating a `Promise` constructor before using it in an ES5 environment (`promise/no-native`)
22

3-
🚫 This rule is _disabled_ in the βœ… `recommended` config.
3+
🚫 This rule is _disabled_ in the following configs: βœ… `flat/recommended`, βœ…
4+
`recommended`.
45

56
<!-- end auto-generated rule header -->
67

β€Ždocs/rules/no-nesting.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Disallow nested `then()` or `catch()` statements (`promise/no-nesting`)
22

3-
⚠️ This rule _warns_ in the βœ… `recommended` config.
3+
⚠️ This rule _warns_ in the following configs: βœ… `flat/recommended`, βœ…
4+
`recommended`.
45

56
<!-- end auto-generated rule header -->
67

β€Ždocs/rules/no-new-statics.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Disallow calling `new` on a Promise static method (`promise/no-new-statics`)
22

3-
πŸ’Ό This rule is enabled in the βœ… `recommended` config.
3+
πŸ’Ό This rule is enabled in the following configs: βœ… `flat/recommended`, βœ…
4+
`recommended`.
45

56
πŸ”§ This rule is automatically fixable by the
67
[`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

0 commit comments

Comments
Β (0)