refactor: fix a lot of errors in type-aware linting (#7477)

This commit is contained in:
Joshua Chen 2022-05-24 15:40:26 +08:00 committed by GitHub
parent 222bf3c091
commit bf1513a3e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
120 changed files with 407 additions and 364 deletions

View file

@ -90,13 +90,15 @@ exports[`translateLoadedContent returns translated loaded content 1`] = `
{
"description": "doc1 description",
"editUrl": "any",
"frontMatter": {
"sidebar_label": "doc1 title",
},
"id": "doc1",
"lastUpdatedAt": 0,
"lastUpdatedBy": "any",
"next": undefined,
"permalink": "any",
"previous": undefined,
"sidebar_label": "doc1 title",
"slug": "any",
"source": "any",
"title": "doc1 title",
@ -106,13 +108,15 @@ exports[`translateLoadedContent returns translated loaded content 1`] = `
{
"description": "doc2 description",
"editUrl": "any",
"frontMatter": {
"sidebar_label": "doc2 title",
},
"id": "doc2",
"lastUpdatedAt": 0,
"lastUpdatedBy": "any",
"next": undefined,
"permalink": "any",
"previous": undefined,
"sidebar_label": "doc2 title",
"slug": "any",
"source": "any",
"title": "doc2 title",
@ -122,13 +126,15 @@ exports[`translateLoadedContent returns translated loaded content 1`] = `
{
"description": "doc3 description",
"editUrl": "any",
"frontMatter": {
"sidebar_label": "doc3 title",
},
"id": "doc3",
"lastUpdatedAt": 0,
"lastUpdatedBy": "any",
"next": undefined,
"permalink": "any",
"previous": undefined,
"sidebar_label": "doc3 title",
"slug": "any",
"source": "any",
"title": "doc3 title",
@ -138,13 +144,15 @@ exports[`translateLoadedContent returns translated loaded content 1`] = `
{
"description": "doc4 description",
"editUrl": "any",
"frontMatter": {
"sidebar_label": "doc4 title",
},
"id": "doc4",
"lastUpdatedAt": 0,
"lastUpdatedBy": "any",
"next": undefined,
"permalink": "any",
"previous": undefined,
"sidebar_label": "doc4 title",
"slug": "any",
"source": "any",
"title": "doc4 title",
@ -154,13 +162,15 @@ exports[`translateLoadedContent returns translated loaded content 1`] = `
{
"description": "doc5 description",
"editUrl": "any",
"frontMatter": {
"sidebar_label": "doc5 title",
},
"id": "doc5",
"lastUpdatedAt": 0,
"lastUpdatedBy": "any",
"next": undefined,
"permalink": "any",
"previous": undefined,
"sidebar_label": "doc5 title",
"slug": "any",
"source": "any",
"title": "doc5 title",
@ -232,13 +242,15 @@ exports[`translateLoadedContent returns translated loaded content 1`] = `
{
"description": "doc1 description",
"editUrl": "any",
"frontMatter": {
"sidebar_label": "doc1 title",
},
"id": "doc1",
"lastUpdatedAt": 0,
"lastUpdatedBy": "any",
"next": undefined,
"permalink": "any",
"previous": undefined,
"sidebar_label": "doc1 title",
"slug": "any",
"source": "any",
"title": "doc1 title",
@ -248,13 +260,15 @@ exports[`translateLoadedContent returns translated loaded content 1`] = `
{
"description": "doc2 description",
"editUrl": "any",
"frontMatter": {
"sidebar_label": "doc2 title",
},
"id": "doc2",
"lastUpdatedAt": 0,
"lastUpdatedBy": "any",
"next": undefined,
"permalink": "any",
"previous": undefined,
"sidebar_label": "doc2 title",
"slug": "any",
"source": "any",
"title": "doc2 title",
@ -264,13 +278,15 @@ exports[`translateLoadedContent returns translated loaded content 1`] = `
{
"description": "doc3 description",
"editUrl": "any",
"frontMatter": {
"sidebar_label": "doc3 title",
},
"id": "doc3",
"lastUpdatedAt": 0,
"lastUpdatedBy": "any",
"next": undefined,
"permalink": "any",
"previous": undefined,
"sidebar_label": "doc3 title",
"slug": "any",
"source": "any",
"title": "doc3 title",
@ -280,13 +296,15 @@ exports[`translateLoadedContent returns translated loaded content 1`] = `
{
"description": "doc4 description",
"editUrl": "any",
"frontMatter": {
"sidebar_label": "doc4 title",
},
"id": "doc4",
"lastUpdatedAt": 0,
"lastUpdatedBy": "any",
"next": undefined,
"permalink": "any",
"previous": undefined,
"sidebar_label": "doc4 title",
"slug": "any",
"source": "any",
"title": "doc4 title",
@ -296,13 +314,15 @@ exports[`translateLoadedContent returns translated loaded content 1`] = `
{
"description": "doc5 description",
"editUrl": "any",
"frontMatter": {
"sidebar_label": "doc5 title",
},
"id": "doc5",
"lastUpdatedAt": 0,
"lastUpdatedBy": "any",
"next": undefined,
"permalink": "any",
"previous": undefined,
"sidebar_label": "doc5 title",
"slug": "any",
"source": "any",
"title": "doc5 title",
@ -374,13 +394,15 @@ exports[`translateLoadedContent returns translated loaded content 1`] = `
{
"description": "doc1 description",
"editUrl": "any",
"frontMatter": {
"sidebar_label": "doc1 title",
},
"id": "doc1",
"lastUpdatedAt": 0,
"lastUpdatedBy": "any",
"next": undefined,
"permalink": "any",
"previous": undefined,
"sidebar_label": "doc1 title",
"slug": "any",
"source": "any",
"title": "doc1 title",
@ -390,13 +412,15 @@ exports[`translateLoadedContent returns translated loaded content 1`] = `
{
"description": "doc2 description",
"editUrl": "any",
"frontMatter": {
"sidebar_label": "doc2 title",
},
"id": "doc2",
"lastUpdatedAt": 0,
"lastUpdatedBy": "any",
"next": undefined,
"permalink": "any",
"previous": undefined,
"sidebar_label": "doc2 title",
"slug": "any",
"source": "any",
"title": "doc2 title",
@ -406,13 +430,15 @@ exports[`translateLoadedContent returns translated loaded content 1`] = `
{
"description": "doc3 description",
"editUrl": "any",
"frontMatter": {
"sidebar_label": "doc3 title",
},
"id": "doc3",
"lastUpdatedAt": 0,
"lastUpdatedBy": "any",
"next": undefined,
"permalink": "any",
"previous": undefined,
"sidebar_label": "doc3 title",
"slug": "any",
"source": "any",
"title": "doc3 title",
@ -422,13 +448,15 @@ exports[`translateLoadedContent returns translated loaded content 1`] = `
{
"description": "doc4 description",
"editUrl": "any",
"frontMatter": {
"sidebar_label": "doc4 title",
},
"id": "doc4",
"lastUpdatedAt": 0,
"lastUpdatedBy": "any",
"next": undefined,
"permalink": "any",
"previous": undefined,
"sidebar_label": "doc4 title",
"slug": "any",
"source": "any",
"title": "doc4 title",
@ -438,13 +466,15 @@ exports[`translateLoadedContent returns translated loaded content 1`] = `
{
"description": "doc5 description",
"editUrl": "any",
"frontMatter": {
"sidebar_label": "doc5 title",
},
"id": "doc5",
"lastUpdatedAt": 0,
"lastUpdatedBy": "any",
"next": undefined,
"permalink": "any",
"previous": undefined,
"sidebar_label": "doc5 title",
"slug": "any",
"source": "any",
"title": "doc5 title",

View file

@ -119,7 +119,7 @@ function createTestUtils({
async function testSlug(docFileSource: string, expectedPermalink: string) {
const docFile = await readDoc(docFileSource);
const metadata = await processDocMetadata({
const metadata = processDocMetadata({
docFile,
versionMetadata,
context,

View file

@ -54,9 +54,9 @@ const createFakeActions = (contentDir: string) => {
addRoute: (config: RouteConfig) => {
routeConfigs.push(config);
},
createData: async (name: string, content: unknown) => {
createData: (name: string, content: unknown) => {
dataContainer[name] = content;
return path.join(contentDir, name);
return Promise.resolve(path.join(contentDir, name));
},
setGlobalData: (data: unknown) => {
globalDataContainer.pluginName = {pluginId: data};

View file

@ -31,11 +31,11 @@ const defaultOptions = {
};
describe('normalizeDocsPluginOptions', () => {
it('returns default options for undefined user options', async () => {
it('returns default options for undefined user options', () => {
expect(testValidate({})).toEqual(defaultOptions);
});
it('accepts correctly defined user options', async () => {
it('accepts correctly defined user options', () => {
const userOptions = {
path: 'my-docs', // Path to data on filesystem, relative to site dir.
routeBasePath: 'my-docs', // URL Route.
@ -83,7 +83,7 @@ describe('normalizeDocsPluginOptions', () => {
});
});
it('accepts correctly defined remark and rehype plugin options', async () => {
it('accepts correctly defined remark and rehype plugin options', () => {
const userOptions = {
beforeDefaultRemarkPlugins: [],
beforeDefaultRehypePlugins: [markdownPluginsFunctionStub],
@ -100,7 +100,7 @@ describe('normalizeDocsPluginOptions', () => {
});
});
it('accepts admonitions false', async () => {
it('accepts admonitions false', () => {
const admonitionsFalse = {
admonitions: false,
};
@ -110,7 +110,7 @@ describe('normalizeDocsPluginOptions', () => {
});
});
it('rejects admonitions true', async () => {
it('rejects admonitions true', () => {
const admonitionsTrue = {
admonitions: true,
};

View file

@ -30,7 +30,9 @@ function createSampleDoc(doc: Pick<DocMetadata, 'id'>): DocMetadata {
unversionedId: 'any',
version: 'any',
title: `${doc.id} title`,
sidebar_label: `${doc.id} title`,
frontMatter: {
sidebar_label: `${doc.id} title`,
},
description: `${doc.id} description`,
...doc,
};
@ -136,7 +138,7 @@ function getSampleTranslationFilesTranslated() {
}
describe('getLoadedContentTranslationFiles', () => {
it('returns translation files', async () => {
it('returns translation files', () => {
expect(getSampleTranslationFiles()).toMatchSnapshot();
});
});