mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-04 03:42:34 +02:00
chore: tighten ESLint config (#6931)
* chore: tighten ESLint config * more refactor * refactor push * fix
This commit is contained in:
parent
f70ddf7e69
commit
cc0bceab9c
54 changed files with 177 additions and 193 deletions
|
@ -162,7 +162,7 @@ export default async function mdxLoader(
|
|||
|
||||
// MDX partials are MDX files starting with _ or in a folder starting with _
|
||||
// Partial are not expected to have associated metadata files or front matter
|
||||
const isMDXPartial = options.isMDXPartial && options.isMDXPartial(filePath);
|
||||
const isMDXPartial = options.isMDXPartial?.(filePath);
|
||||
if (isMDXPartial && hasFrontMatter) {
|
||||
const errorMessage = `Docusaurus MDX partial files should not contain FrontMatter.
|
||||
Those partial files use the _ prefix as a convention by default, but this is configurable.
|
||||
|
|
|
@ -76,7 +76,7 @@ export default function plugin(options: PluginOptions = {}): Transformer {
|
|||
return (root) => {
|
||||
const headings: TOCItem[] = [];
|
||||
|
||||
visit(root, 'heading', (child: Heading, _index, parent) => {
|
||||
visit(root, 'heading', (child: Heading, index, parent) => {
|
||||
const value = toString(child);
|
||||
|
||||
// depth:1 headings are titles and not included in the TOC
|
||||
|
@ -93,7 +93,7 @@ export default function plugin(options: PluginOptions = {}): Transformer {
|
|||
const {children} = root as Parent<Literal>;
|
||||
const targetIndex = getOrCreateExistingTargetIndex(children, name);
|
||||
|
||||
if (headings && headings.length) {
|
||||
if (headings.length) {
|
||||
children[targetIndex]!.value = `export const ${name} = ${stringifyObject(
|
||||
headings,
|
||||
)};`;
|
||||
|
|
|
@ -17,7 +17,7 @@ import type {Code, Parent} from 'mdast';
|
|||
// See https://github.com/facebook/docusaurus/pull/4278
|
||||
export default function plugin(this: Processor): Transformer {
|
||||
return (root) => {
|
||||
visit(root, 'code', (node: Code, _index, parent) => {
|
||||
visit(root, 'code', (node: Code, index, parent) => {
|
||||
if (node.lang === 'mdx-code-block') {
|
||||
const newChildren = (this.parse(node.value) as Parent).children;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue