You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Problems:
- The new rule document (generated by `npm run new`) was unclear about which part is the header and which part is the body.
- In `tools/update-docs.ts`, when generating notes and adding them to the header section:
- The process is too much like cutting and pasting manually on the string, it reduces the readability
- The code for producing the new header (with notes included) is quite fragmented and long
- Includes legacy/redundant code `header.replace(/\$/g, "$$$$")`
- Inefficient code, it creates two new items for the notes then `join()` it with `'\n'` later to create the trailing `'\n\n'`
```ts
if (notes.length >= 1) {
notes.push("", "")
}
...
const header = `\n${title}\n\n${notes.join("\n")}`
```
### This PR:
- Create renderRuleHeader function and a RuleDocHeader type to clarify the structure of the header. Then applies this to both the generation and update tools for the detailed rule Markdown files
```ts
type RuleDocHeader = {
ruleId: string
description: string
notes: string[]
}
const header = renderRuleHeader({ ruleId, description, notes })
```
- Make it clear there are `\n\n` between each part of the header in the `renderRuleHeader` function
`- ⚠️ This rule was **deprecated** and replaced by ${formatItems(
66
+
replacedRules,
67
+
)}.`,
68
+
)
69
+
}else{
70
+
notes.push("- ⚠️ This rule was **deprecated**.")
71
+
}
72
+
}elseif(recommended){
73
+
if(recommended==="base"){
74
+
notes.push(
75
+
'- ⚙ This rule is included in `"plugin:astro/base"` and `"plugin:astro/recommended"`.',
76
+
)
77
+
}else{
78
+
notes.push('- ⚙ This rule is included in `"plugin:astro/recommended"`.')
79
+
}
80
+
}
81
+
if(fixable){
82
+
notes.push(
83
+
"- 🔧 The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.",
84
+
)
85
+
}
86
+
if(hasSuggestions){
87
+
notes.push(
88
+
"- 💡 Some problems reported by this rule are manually fixable by editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).",
89
+
)
90
+
}
91
+
if(isNew){
92
+
notes.push(
93
+
`- ❗ <badge text="This rule has not been released yet." vertical="middle" type="error"> **_This rule has not been released yet._** </badge>`,
`- ⚠️ This rule was **deprecated** and replaced by ${formatItems(
93
-
replacedRules,
94
-
)}.`,
95
-
)
96
-
}else{
97
-
notes.push("- ⚠️ This rule was **deprecated**.")
98
-
}
99
-
}elseif(recommended){
100
-
if(recommended==="base"){
101
-
notes.push(
102
-
'- ⚙ This rule is included in `"plugin:astro/base"` and `"plugin:astro/recommended"`.',
103
-
)
104
-
}else{
105
-
notes.push(
106
-
'- ⚙ This rule is included in `"plugin:astro/recommended"`.',
107
-
)
108
-
}
109
-
}
110
-
if(fixable){
111
-
notes.push(
112
-
"- 🔧 The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.",
113
-
)
114
-
}
115
-
if(hasSuggestions){
116
-
notes.push(
117
-
"- 💡 Some problems reported by this rule are manually fixable by editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).",
118
-
)
119
-
}
120
-
if(!this.since){
121
-
notes.unshift(
122
-
`- ❗ <badge text="This rule has not been released yet." vertical="middle" type="error"> **_This rule has not been released yet._** </badge>`,
0 commit comments