Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
docs: autogenerate rules table on website#5116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
d9c310e
5bb667c
47bbca7
ea763f9
0694aee
4e81555
6749355
b85e154
c6ef6b9
29bea86
a27757e
cc3075f
d9900fb
5839647
b4446ae
10d5ea0
1363c4e
004f3e9
01017fe
fc3eadf
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -69,7 +69,8 @@ | ||
"details", | ||
"summary", | ||
"Tabs", | ||
"TabItem", | ||
"RulesTable" | ||
] | ||
}, | ||
// MD034/no-bare-urls - Bare URL used | ||
Large diffs are not rendered by default.
Uh oh!
There was an error while loading.Please reload this page.
Large diffs are not rendered by default.
Uh oh!
There was an error while loading.Please reload this page.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -5,6 +5,7 @@ import type { UserThemeConfig as ThemeCommonConfig } from '@docusaurus/theme-com | ||
import type { UserThemeConfig as AlgoliaThemeConfig } from '@docusaurus/theme-search-algolia'; | ||
import type { Config } from '@docusaurus/types'; | ||
import { rulesMeta } from './rulesMeta'; | ||
import npm2yarnPlugin from '@docusaurus/remark-plugin-npm2yarn'; | ||
import tabsPlugin from 'remark-docusaurus-tabs'; | ||
import { addRuleAttributesList } from './plugins/add-rule-attributes-list'; | ||
@@ -175,6 +176,9 @@ const config: Config = { | ||
projectName: 'typescript-eslint', | ||
clientModules: [require.resolve('./src/clientModules.js')], | ||
presets: [['classic', presetClassicOptions]], | ||
customFields: { | ||
rules: rulesMeta, | ||
}, | ||
JoshuaKGoldberg marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
plugins: [ | ||
require.resolve('./webpack.plugin'), | ||
['@docusaurus/plugin-content-docs', pluginContentDocsOptions], | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import type * as unist from 'unist'; | ||
import type * as mdast from 'mdast'; | ||
import type { Plugin } from 'unified'; | ||
@@ -13,191 +14,25 @@ const addRuleAttributesList: Plugin = () => { | ||
if (rule == null) { | ||
return; | ||
} | ||
bradzacher marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
const parent = root as unist.Parent; | ||
const h2Idx = parent.children.findIndex( | ||
child => child.type === 'heading' &&(child as mdast.Heading).depth === 2, | ||
); | ||
// The actual content will be injected on client side. | ||
const attrNode = { | ||
type: 'jsx', | ||
value: `<rule-attributes name="${file.stem}" />`, | ||
}; | ||
if (h2Idx != null) { | ||
// insert it just before the first h2 in the doc | ||
// this should be just after the rule's description | ||
parent.children.splice(h2Idx, 0,attrNode); | ||
} else { | ||
// failing that, add it to the end | ||
parent.children.push(attrNode); | ||
} | ||
}; | ||
}; | ||
export { addRuleAttributesList }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import * as eslintPlugin from '@typescript-eslint/eslint-plugin'; | ||
export const rulesMeta = Object.entries(eslintPlugin.rules).map( | ||
([name, content]) => ({ | ||
name, | ||
type: content.meta.type, | ||
docs: content.meta.docs, | ||
fixable: content.meta.fixable, | ||
hasSuggestions: content.meta.hasSuggestions, | ||
JoshuaKGoldberg marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
deprecated: content.meta.deprecated, | ||
replacedBy: content.meta.replacedBy, | ||
}), | ||
); | ||
export type RulesMeta = typeof rulesMeta; |
Uh oh!
There was an error while loading.Please reload this page.