Skip to content

Commit b38adc1

Browse files
committed
docs: rule table extract + instructions
1 parent 45bfe07 commit b38adc1

File tree

4 files changed

+122
-23
lines changed

4 files changed

+122
-23
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<script setup lang="ts">
2+
type Rule = { key: string; description: string }
3+
4+
defineProps<{ rules: Rule[] }>()
5+
</script>
6+
7+
<template>
8+
<table>
9+
<colgroup>
10+
<col style="width: 40%" />
11+
<col style="width: 60%" />
12+
</colgroup>
13+
14+
<thead>
15+
<tr>
16+
<th>Rule</th>
17+
<th>Description</th>
18+
</tr>
19+
</thead>
20+
21+
<tbody>
22+
<tr v-for="rule in rules" :key="rule.key">
23+
<td>
24+
<a :href="`/rules/${rule.key}`">{{ rule.key }}</a>
25+
</td>
26+
<td>{{ rule.description }}</td>
27+
</tr>
28+
</tbody>
29+
</table>
30+
</template>
31+
32+
<style scoped>
33+
table {
34+
width: 100%;
35+
display: table;
36+
}
37+
</style>

docs/.vitepress/theme/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1+
import type { EnhanceAppContext } from "vitepress"
12
import theme from "vitepress/theme"
23

4+
import RuleTable from "./components/RuleTable.vue"
5+
36
import "./style.css"
47

5-
export default theme
8+
export default {
9+
extends: theme,
10+
enhanceApp: ({ app }: EnhanceAppContext) => {
11+
app.component("RuleTable", RuleTable)
12+
},
13+
}

docs/rules/index.md

Lines changed: 71 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,79 @@ aside: false
55
<script setup>
66
import { data } from "./index.data"
77

8-
const categories = { recommended: "Recommended", react: "React", scope: "Scope" }
9-
108
const rulesByCategory = (category) => data.filter((rule) => rule.category === category)
119
</script>
1210

1311
# Rules
1412

15-
<template v-for="(title, category) in categories" :key="category">
16-
<h2 :id="category">{{ title }}</h2>
17-
18-
<table>
19-
<thead>
20-
<tr>
21-
<th>Rule</th>
22-
<th>Description</th>
23-
</tr>
24-
</thead>
25-
<tbody>
26-
<tr v-for="rule in rulesByCategory(category)" :key="rule.key">
27-
<td><a :href="`/rules/${rule.key}`">{{rule.key}}</a></td>
28-
<td>{{rule.description}}</td>
29-
</tr>
30-
</tbody>
31-
</table>
32-
</template>
13+
## `recommended`
14+
15+
This preset is recommended for most projects, so we suggest enabling it by default.
16+
17+
::: code-group
18+
19+
```ts [eslint.config.mjs]
20+
import effector from "eslint-plugin-effector" // [!code focus]
21+
22+
const config = [
23+
effector.configs.recommended, // [!code focus]
24+
]
25+
```
26+
27+
:::
28+
29+
<RuleTable :rules='rulesByCategory("recommended")' />
30+
31+
## `patronum`
32+
33+
This preset is recommended for projects that use [`patronum`](https://patronum.effector.dev/).
34+
35+
::: code-group
36+
37+
```ts [eslint.config.mjs]
38+
import effector from "eslint-plugin-effector" // [!code focus]
39+
40+
const config = [
41+
effector.configs.patronum, // [!code focus]
42+
]
43+
```
44+
45+
:::
46+
47+
<RuleTable :rules='rulesByCategory("patronum")' />
48+
49+
## `react`
50+
51+
This preset is recommended for projects that use React with Effector.
52+
53+
::: code-group
54+
55+
```ts [eslint.config.mjs]
56+
import effector from "eslint-plugin-effector" // [!code focus]
57+
58+
const config = [
59+
effector.configs.react, // [!code focus]
60+
]
61+
```
62+
63+
:::
64+
65+
<RuleTable :rules='rulesByCategory("react")' />
66+
67+
## `scope`
68+
69+
This preset is recommended for projects that use [Fork API](https://effector.dev/docs/api/effector/scope).
70+
71+
::: code-group
72+
73+
```ts [eslint.config.mjs]
74+
import effector from "eslint-plugin-effector" // [!code focus]
75+
76+
const config = [
77+
effector.configs.scope, // [!code focus]
78+
]
79+
```
80+
81+
:::
82+
83+
<RuleTable :rules='rulesByCategory("scope")' />

src/ruleset.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ const recommended = {
99
"effector/no-forward": "error",
1010
"effector/no-getState": "error",
1111
"effector/no-guard": "error",
12-
"effector/no-patronum-debug": "warn",
1312
"effector/no-unnecessary-combination": "warn",
1413
"effector/no-unnecessary-duplication": "warn",
1514
"effector/no-useless-methods": "error",
1615
"effector/no-watch": "warn",
1716
} satisfies TSESLint.Linter.RulesRecord
1817

18+
const patronum = {
19+
"effector/no-patronum-debug": "warn",
20+
} satisfies TSESLint.Linter.RulesRecord
21+
1922
const scope = {
2023
"effector/require-pickup-in-persist": "error",
2124
"effector/strict-effect-handlers": "error",
@@ -29,4 +32,4 @@ const react = {
2932

3033
const future = {} satisfies TSESLint.Linter.RulesRecord
3134

32-
export const ruleset = { recommended, scope, react, future }
35+
export const ruleset = { recommended, patronum, scope, react, future }

0 commit comments

Comments
 (0)