mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-06 04:42:40 +02:00
refactor: remove sub-eslintrc, fix more lint errors (#7530)
This commit is contained in:
parent
f443e992b9
commit
9023b7740c
20 changed files with 129 additions and 92 deletions
|
@ -0,0 +1,9 @@
|
|||
foo
|
||||
|
||||
`bar`
|
||||
|
||||
```js
|
||||
baz
|
||||
```
|
||||
|
||||
export const toc = 1;
|
|
@ -1,5 +1,18 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`toc remark plugin does not overwrite TOC var if no TOC 1`] = `
|
||||
"foo
|
||||
|
||||
\`bar\`
|
||||
|
||||
\`\`\`js
|
||||
baz
|
||||
\`\`\`
|
||||
|
||||
export const toc = 1;
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`toc remark plugin escapes inline code 1`] = `
|
||||
"export const toc = [
|
||||
{
|
||||
|
|
|
@ -30,6 +30,14 @@ describe('toc remark plugin', () => {
|
|||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
// A very implicit API: we allow users to hand-write the toc variable. It will
|
||||
// get overwritten in most cases, but until we find a better way, better keep
|
||||
// supporting this
|
||||
it('does not overwrite TOC var if no TOC', async () => {
|
||||
const result = await processFixture('no-heading-with-toc-export');
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('works on non text phrasing content', async () => {
|
||||
const result = await processFixture('non-text-content');
|
||||
expect(result).toMatchSnapshot();
|
||||
|
|
|
@ -89,8 +89,10 @@ export default function plugin(): Transformer {
|
|||
const {children} = root as Parent<Literal>;
|
||||
const targetIndex = getOrCreateExistingTargetIndex(children);
|
||||
|
||||
children[targetIndex]!.value = `export const ${name} = ${stringifyObject(
|
||||
headings,
|
||||
)};`;
|
||||
if (headings.length) {
|
||||
children[targetIndex]!.value = `export const ${name} = ${stringifyObject(
|
||||
headings,
|
||||
)};`;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue