Skip to content

Commit

Permalink
Merge pull request #84 from jy95/refactorImports
Browse files Browse the repository at this point in the history
Refactor imports
  • Loading branch information
jy95 authored May 14, 2023
2 parents 7b31a26 + f7de798 commit c74eafb
Show file tree
Hide file tree
Showing 73 changed files with 303 additions and 259 deletions.
4 changes: 4 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ module.exports = {
// To deal with annoying css imports that breaks tests
"\\.(css|less)$": "<rootDir>/__mocks__/styleMock.js",
// "@theme-original/(.*)": "<rootDir>/node_modules/@docusaurus/theme-classic/lib/theme/$1/index.js"

// https://huafu.github.io/ts-jest/user/config/#paths-mapping
// If you use “baseUrl” and “paths” options in your tsconfig file, you should make sure the “moduleNameMapper” option in your Jest config is setup accordingly.
"^@theme/(.*)$": "<rootDir>/src/theme/$1",
},
collectCoverageFrom: ["src/theme/JSONSchemaViewer/**/*.{js,ts,jsx,tsx}"],
coveragePathIgnorePatterns: ["!*.d.ts"],
Expand Down
13 changes: 5 additions & 8 deletions src/theme-json-schema.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Plugin config
declare module "docusaurus-json-schema-plugin" {
import type { Plugin } from "@docusaurus/types"
import type { PluginOptions } from "docusaurus-json-schema-plugin/src/index"
import type { PluginOptions } from "docusaurus-json-schema-plugin/src"

export default function themeJSONSchema(
options: PluginOptions
Expand All @@ -10,28 +10,25 @@ declare module "docusaurus-json-schema-plugin" {

// Viewer component
declare module "@theme/JSONSchemaViewer" {
import type { Props } from "docusaurus-json-schema-plugin/src/theme/JSONSchemaViewer/index"
import type { Props } from "@theme/JSONSchemaViewer"

export default function JSONSchemaViewer(props: Props): JSX.Element
}

// Editor component
declare module "@theme/JSONSchemaEditor" {
import type { Props } from "docusaurus-json-schema-plugin/src/theme/JSONSchemaEditor/index"
import type { Props } from "@theme/JSONSchemaEditor"

export default function JSONSchemaEditor(props: Props): JSX.Element
}

// MonacoEditor component
declare module "@theme/MonacoEditor" {
import type { Props } from "docusaurus-json-schema-plugin/src/theme/MonacoEditor/index"
import type { Props } from "@theme/MonacoEditor"

export default function MonacoEditor(props: Props): JSX.Element

export type {
MonacoEditorTypes,
Props,
} from "docusaurus-json-schema-plugin/src/theme/MonacoEditor/index"
export type { MonacoEditorTypes, Props } from "@theme/MonacoEditor"

// Re-export Monaco own interface, in case people want to add custom validation, ...
export * as monaco from "monaco-editor/esm/vs/editor/editor.api"
Expand Down
2 changes: 1 addition & 1 deletion src/theme/JSONSchemaEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import ErrorBoundary from "@docusaurus/ErrorBoundary"
import {
LoadingLabel,
ErrorOccurredLabel,
} from "../JSONSchemaViewer/labels/index"
} from "@theme/JSONSchemaViewer/labels"

import type { JSONSchema as Draft_07 } from "json-schema-typed/draft-07"
import type { EditorWillMount, MonacoEditorProps } from "react-monaco-editor"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react"
import Translate from "@docusaurus/Translate"

import { TypeLabel, FalseLabel } from "../labels/index"
import { TypeLabel, FalseLabel } from "@theme/JSONSchemaViewer/labels"

// When schema has the value "true", it means that it is ALWAYS valid
export default function CreateAlwaysValid(): JSX.Element {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from "react"
import Translate from "@docusaurus/Translate"

import { TypeLabel, TrueLabel } from "../labels/index"
import { useJSVOptionsContext } from "../contexts/index"
import { QualifierMessages } from "../utils/index"
import { CreateDescription } from "./index"
import { TypeLabel, TrueLabel } from "@theme/JSONSchemaViewer/labels"
import { useJSVOptionsContext } from "@theme/JSONSchemaViewer/contexts"
import { QualifierMessages } from "@theme/JSONSchemaViewer/utils"
import { CreateDescription } from "@theme/JSONSchemaViewer/JSONSchemaElements"

import type { JSONSchema } from "../types"
import type { JSONSchema } from "@theme/JSONSchemaViewer/types"

type Props = {
[x: string]: any
Expand Down
10 changes: 5 additions & 5 deletions src/theme/JSONSchemaViewer/JSONSchemaElements/CreateBoolean.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from "react"

import { QualifierMessages } from "../utils/index"
import { QualifierMessages } from "@theme/JSONSchemaViewer/utils"

import { useJSVOptionsContext } from "../contexts/index"
import { useJSVOptionsContext } from "@theme/JSONSchemaViewer/contexts"

import { TypeLabel, BooleanLabel } from "../labels/index"
import { TypeLabel, BooleanLabel } from "@theme/JSONSchemaViewer/labels"

import { CreateDescription } from "./index"
import { CreateDescription } from "@theme/JSONSchemaViewer/JSONSchemaElements"

import type { JSONSchemaNS } from "../types"
import type { JSONSchemaNS } from "@theme/JSONSchemaViewer/types"

type Props = {
[x: string]: any
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react"

import { useJSVOptionsContext } from "../contexts/index"
import { useJSVOptionsContext } from "@theme/JSONSchemaViewer/contexts"

type Props = {
description: string
Expand Down
10 changes: 5 additions & 5 deletions src/theme/JSONSchemaViewer/JSONSchemaElements/CreateInteger.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from "react"

import { QualifierMessages } from "../utils/index"
import { QualifierMessages } from "@theme/JSONSchemaViewer/utils"

import { useJSVOptionsContext } from "../contexts/index"
import { useJSVOptionsContext } from "@theme/JSONSchemaViewer/contexts"

import { TypeLabel, IntegerLabel } from "../labels/index"
import { TypeLabel, IntegerLabel } from "@theme/JSONSchemaViewer/labels"

import { CreateDescription } from "./index"
import { CreateDescription } from "@theme/JSONSchemaViewer/JSONSchemaElements"

import type { JSONSchemaNS } from "../types"
import type { JSONSchemaNS } from "@theme/JSONSchemaViewer/types"

type Props = {
[x: string]: any
Expand Down
10 changes: 5 additions & 5 deletions src/theme/JSONSchemaViewer/JSONSchemaElements/CreateNull.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from "react"

import { QualifierMessages } from "../utils/index"
import { QualifierMessages } from "@theme/JSONSchemaViewer/utils"

import { useJSVOptionsContext } from "../contexts/index"
import { useJSVOptionsContext } from "@theme/JSONSchemaViewer/contexts"

import { TypeLabel, NullLabel } from "../labels/index"
import { TypeLabel, NullLabel } from "@theme/JSONSchemaViewer/labels"

import { CreateDescription } from "./index"
import { CreateDescription } from "@theme/JSONSchemaViewer/JSONSchemaElements"

import type { JSONSchemaNS } from "../types"
import type { JSONSchemaNS } from "@theme/JSONSchemaViewer/types"

type Props = {
[x: string]: any
Expand Down
10 changes: 5 additions & 5 deletions src/theme/JSONSchemaViewer/JSONSchemaElements/CreateNumber.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from "react"

import { QualifierMessages } from "../utils/index"
import { QualifierMessages } from "@theme/JSONSchemaViewer/utils"

import { useJSVOptionsContext } from "../contexts/index"
import { useJSVOptionsContext } from "@theme/JSONSchemaViewer/contexts"

import { TypeLabel, NumberLabel } from "../labels/index"
import { TypeLabel, NumberLabel } from "@theme/JSONSchemaViewer/labels"

import { CreateDescription } from "./index"
import { CreateDescription } from "@theme/JSONSchemaViewer/JSONSchemaElements"

import type { JSONSchemaNS } from "../types"
import type { JSONSchemaNS } from "@theme/JSONSchemaViewer/types"

type Props = {
[x: string]: any
Expand Down
10 changes: 5 additions & 5 deletions src/theme/JSONSchemaViewer/JSONSchemaElements/CreateString.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from "react"

import { QualifierMessages } from "../utils/index"
import { QualifierMessages } from "@theme/JSONSchemaViewer/utils"

import { useJSVOptionsContext } from "../contexts/index"
import { useJSVOptionsContext } from "@theme/JSONSchemaViewer/contexts"

import { TypeLabel, StringLabel } from "../labels/index"
import { TypeLabel, StringLabel } from "@theme/JSONSchemaViewer/labels"

import { CreateDescription } from "./index"
import { CreateDescription } from "@theme/JSONSchemaViewer/JSONSchemaElements"

import type { JSONSchemaNS } from "../types"
import type { JSONSchemaNS } from "@theme/JSONSchemaViewer/types"

type Props = {
[x: string]: any
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import React from "react"

import { DependentRequired, DependentSchemas } from "./index"
import {
DependentRequired,
DependentSchemas,
} from "@theme/JSONSchemaViewer/JSONSchemaElements/SchemaConditional"

import type { JSONSchema } from "../../types"
import type { JSONSchema } from "@theme/JSONSchemaViewer/types"

type Props = {
schema: Exclude<JSONSchema, true | false>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from "react"

import { AllOfSchema } from "../schemaComposition/index"
import { AllOfSchema } from "@theme/JSONSchemaViewer/JSONSchemaElements/schemaComposition"

import type { JSONSchema, JSONSchemaNS } from "../../types"
import type { JSONSchema, JSONSchemaNS } from "@theme/JSONSchemaViewer/types"

type Props = {
schema: Exclude<JSONSchema, true | false>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from "react"

import { AllOfSchema } from "../schemaComposition/index"
import { AllOfSchema } from "@theme/JSONSchemaViewer/JSONSchemaElements/schemaComposition"

import type { JSONSchema, JSONSchemaNS } from "../../types"
import type { JSONSchema, JSONSchemaNS } from "@theme/JSONSchemaViewer/types"

type Props = {
schema: Exclude<JSONSchema, true | false>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import React from "react"
import TabItem from "@theme-original/TabItem"
import Tabs from "@theme-original/Tabs"

import { CreateNodes } from "../../components/index"
import { CreateNodes } from "@theme/JSONSchemaViewer/components"

import { IfLabel, ThenLabel, ElseLabel } from "../../labels/index"
import { IfLabel, ThenLabel, ElseLabel } from "@theme/JSONSchemaViewer/labels"

import type { JSONSchema } from "../../types"
import type { JSONSchema } from "@theme/JSONSchemaViewer/types"

type Props = {
schema: Exclude<JSONSchema, true | false>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export { default as IfElseThen } from "./if-else-then"
export { default as IfElseThen } from "@theme/JSONSchemaViewer/JSONSchemaElements/SchemaConditional/if-else-then"

export { default as DependentRequired } from "./dependentRequired"
export { default as DependentRequired } from "@theme/JSONSchemaViewer/JSONSchemaElements/SchemaConditional/dependentRequired"

export { default as DependentSchemas } from "./dependentSchemas"
export { default as DependentSchemas } from "@theme/JSONSchemaViewer/JSONSchemaElements/SchemaConditional/dependentSchemas"

export { default as Dependencies } from "./dependencies"
export { default as Dependencies } from "@theme/JSONSchemaViewer/JSONSchemaElements/SchemaConditional/dependencies"

// main entry point
export { default as SchemaConditional } from "./schemaConditional"
export { default as SchemaConditional } from "@theme/JSONSchemaViewer/JSONSchemaElements/SchemaConditional/schemaConditional"
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
DependentRequired,
DependentSchemas,
Dependencies,
} from "./index"
import { Collapsible } from "../../components/index"
} from "@theme/JSONSchemaViewer/JSONSchemaElements/SchemaConditional"
import { Collapsible } from "@theme/JSONSchemaViewer/components"

import type { JSONSchema, JSONSchemaNS } from "../../types"
import type { JSONSchema, JSONSchemaNS } from "@theme/JSONSchemaViewer/types"

type Props = {
schema: Exclude<JSONSchema, true | false>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react"
import Translate from "@docusaurus/Translate"

import { CreateEdge } from "../../components/index"
import { CreateEdge } from "@theme/JSONSchemaViewer/components"

import type { JSONSchemaNS } from "../../types"
import type { JSONSchemaNS } from "@theme/JSONSchemaViewer/types"

type Props = {
[x: string]: any
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react"
import Translate from "@docusaurus/Translate"

import { CreateEdge } from "../../components/index"
import { CreateEdge } from "@theme/JSONSchemaViewer/components"

import type { JSONSchemaNS } from "../../types"
import type { JSONSchemaNS } from "@theme/JSONSchemaViewer/types"

type Props = {
[x: string]: any
Expand Down
20 changes: 10 additions & 10 deletions src/theme/JSONSchemaViewer/JSONSchemaElements/array/CreateArray.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import React from "react"

import Items from "./Items"
import Contains from "./Contains"
import PrefixItems from "./PrefixItems"
import AdditionalItems from "./AdditionalItems"
import UnevaluatedItems from "./UnevaluatedItems"
import Items from "@theme/JSONSchemaViewer/JSONSchemaElements/array/Items"
import Contains from "@theme/JSONSchemaViewer/JSONSchemaElements/array/Contains"
import PrefixItems from "@theme/JSONSchemaViewer/JSONSchemaElements/array/PrefixItems"
import AdditionalItems from "@theme/JSONSchemaViewer/JSONSchemaElements/array/AdditionalItems"
import UnevaluatedItems from "@theme/JSONSchemaViewer/JSONSchemaElements/array/UnevaluatedItems"

import { QualifierMessages } from "../../utils/index"
import { QualifierMessages } from "@theme/JSONSchemaViewer/utils"

import { useJSVOptionsContext } from "../../contexts/index"
import { useJSVOptionsContext } from "@theme/JSONSchemaViewer/contexts"

import { ArrayLabel, TypeLabel } from "../../labels/index"
import { ArrayLabel, TypeLabel } from "@theme/JSONSchemaViewer/labels"

import { CreateDescription } from "../index"
import { CreateDescription } from "@theme/JSONSchemaViewer/JSONSchemaElements"

import type { JSONSchemaNS } from "../../types"
import type { JSONSchemaNS } from "@theme/JSONSchemaViewer/types"

type Props = {
schema: JSONSchemaNS.Array
Expand Down
4 changes: 2 additions & 2 deletions src/theme/JSONSchemaViewer/JSONSchemaElements/array/Items.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react"
import Translate from "@docusaurus/Translate"

import { CreateEdge } from "../../components/index"
import { CreateEdge } from "@theme/JSONSchemaViewer/components"

import type { JSONSchemaNS } from "../../types"
import type { JSONSchemaNS } from "@theme/JSONSchemaViewer/types"

type Props = {
[x: string]: any
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react"
import Translate from "@docusaurus/Translate"

import { CreateEdge } from "../../components/index"
import { CreateEdge } from "@theme/JSONSchemaViewer/components"

import type { JSONSchema, JSONSchemaNS } from "../../types"
import type { JSONSchema, JSONSchemaNS } from "@theme/JSONSchemaViewer/types"

type Props = {
[x: string]: any
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react"
import Translate from "@docusaurus/Translate"

import { CreateEdge } from "../../components/index"
import { CreateEdge } from "@theme/JSONSchemaViewer/components"

import type { JSONSchemaNS } from "../../types"
import type { JSONSchemaNS } from "@theme/JSONSchemaViewer/types"

type Props = {
[x: string]: any
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// The main function that will be imported
export { default as CreateArray } from "./CreateArray"
export { default as CreateArray } from "@theme/JSONSchemaViewer/JSONSchemaElements/array/CreateArray"
Loading

0 comments on commit c74eafb

Please sign in to comment.