refactor: ensure all types are using index signature instead of Record (#6995)

* refactor: ensure all types are using index signature instead of Record

* kick CI
This commit is contained in:
Joshua Chen 2022-03-25 18:06:30 +08:00 committed by GitHub
parent e8800b9d49
commit 87592bca03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
99 changed files with 339 additions and 307 deletions

View file

@ -0,0 +1,11 @@
```bash npm2yarn
npm install --global docusaurus
```
```bash npm2yarn
npm install --save docusaurus-plugin-name
```
```bash npm2yarn
npm run build
```

View file

@ -48,6 +48,21 @@ import TabItem from '@theme/TabItem';
"
`;
exports[`npm2yarn plugin does not work when language is not set 1`] = `
"\`\`\`npm2yarn
npm install --save docusaurus-plugin-name
\`\`\`
\`\`\`bash
npm install --save docusaurus-plugin-name
\`\`\`
\`\`\`shell
npm install --save docusaurus-plugin-name
\`\`\`
"
`;
exports[`npm2yarn plugin works on installation file 1`] = `
"import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
@ -98,17 +113,29 @@ yarn add docusaurus-plugin-name
"
`;
exports[`npm2yarn plugin works when language is not set 1`] = `
"\`\`\`npm2yarn
npm install --save docusaurus-plugin-name
\`\`\`
exports[`npm2yarn plugin works with sync option 1`] = `
"import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
## Installing a plugin
A plugin is usually a npm package, so you install them like other npm packages using npm.
<Tabs groupId=\\"npm2yarn\\">
<TabItem value=\\"npm\\">
\`\`\`bash
npm install --save docusaurus-plugin-name
\`\`\`
\`\`\`shell
npm install --save docusaurus-plugin-name
</TabItem>
<TabItem value=\\"yarn\\" label=\\"Yarn\\">
\`\`\`bash
yarn add docusaurus-plugin-name
\`\`\`
</TabItem>
</Tabs>
"
`;

View file

@ -16,10 +16,7 @@ import mdx from 'remark-mdx';
const processFixture = async (name: string, options?: {sync?: boolean}) => {
const filePath = path.join(__dirname, '__fixtures__', `${name}.md`);
const file = await vfile.read(filePath);
const result = await remark()
.use(mdx)
.use(npm2yarn, {...options, filePath})
.process(file);
const result = await remark().use(mdx).use(npm2yarn, options).process(file);
return result.toString();
};
@ -37,7 +34,13 @@ describe('npm2yarn plugin', () => {
expect(result).toMatchSnapshot();
});
it('works when language is not set', async () => {
it('works with sync option', async () => {
const result = await processFixture('plugin', {sync: true});
expect(result).toMatchSnapshot();
});
it('does not work when language is not set', async () => {
const result = await processFixture('syntax-not-properly-set');
expect(result).toMatchSnapshot();