diff options
author | Jeremy Davis <jeremy.davis@sonarsource.com> | 2021-09-17 16:29:12 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2021-09-30 20:03:00 +0000 |
commit | 18582f55e72704e61c331467e90de7b023d0b46c (patch) | |
tree | 98baf9a40895b0fedb19f5d739e55ea2592f385b /server/sonar-web/src/main/js/apps/documentation | |
parent | 62b21006de51a5b15819e70f4a0943ab983d2b68 (diff) | |
download | sonarqube-18582f55e72704e61c331467e90de7b023d0b46c.tar.gz sonarqube-18582f55e72704e61c331467e90de7b023d0b46c.zip |
[NO-JIRA] use esbuild for sonar-web
Diffstat (limited to 'server/sonar-web/src/main/js/apps/documentation')
8 files changed, 40 insertions, 45 deletions
diff --git a/server/sonar-web/src/main/js/apps/documentation/__tests__/pages-test.ts b/server/sonar-web/src/main/js/apps/documentation/__tests__/pages-test.ts index 7e61f661cc4..48b136593c8 100644 --- a/server/sonar-web/src/main/js/apps/documentation/__tests__/pages-test.ts +++ b/server/sonar-web/src/main/js/apps/documentation/__tests__/pages-test.ts @@ -21,17 +21,16 @@ import { filterContent, ParsedContent } from '../../../helpers/markdown'; import { mockDocumentationMarkdown } from '../../../helpers/testMocks'; -jest.mock('remark', () => ({ - default: () => ({ - parse: jest.fn().mockReturnValue({}) - }) +jest.mock('remark', () => () => ({ + parse: jest.fn().mockReturnValue({}) })); -jest.mock('unist-util-visit', () => ({ - default: (_: any, cb: (node: { type: string; value: string }) => void) => { +jest.mock( + 'unist-util-visit', + () => (_: any, cb: (node: { type: string; value: string }) => void) => { cb({ type: 'text', value: 'Text content' }); } -})); +); jest.mock('../../../helpers/markdown', () => { const markdown = jest.requireActual('../../../helpers/markdown'); diff --git a/server/sonar-web/src/main/js/apps/documentation/components/MenuBlock.tsx b/server/sonar-web/src/main/js/apps/documentation/components/MenuBlock.tsx index fb51d62654e..4891f947dc3 100644 --- a/server/sonar-web/src/main/js/apps/documentation/components/MenuBlock.tsx +++ b/server/sonar-web/src/main/js/apps/documentation/components/MenuBlock.tsx @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import { DocNavigationItem, DocsNavigationBlock } from 'Docs/@types/types'; import * as React from 'react'; import { ButtonLink } from '../../../components/controls/buttons'; diff --git a/server/sonar-web/src/main/js/apps/documentation/components/MenuItem.tsx b/server/sonar-web/src/main/js/apps/documentation/components/MenuItem.tsx index a68d1ba07c8..86ea670c415 100644 --- a/server/sonar-web/src/main/js/apps/documentation/components/MenuItem.tsx +++ b/server/sonar-web/src/main/js/apps/documentation/components/MenuItem.tsx @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { Link } from 'react-router'; import { testPathAgainstUrl } from '../navTreeUtils'; diff --git a/server/sonar-web/src/main/js/apps/documentation/components/SearchResultEntry.tsx b/server/sonar-web/src/main/js/apps/documentation/components/SearchResultEntry.tsx index 22ee12b8cad..ae85ebc33fb 100644 --- a/server/sonar-web/src/main/js/apps/documentation/components/SearchResultEntry.tsx +++ b/server/sonar-web/src/main/js/apps/documentation/components/SearchResultEntry.tsx @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import * as classNames from 'classnames'; +import classNames from 'classnames'; import * as React from 'react'; import { Link } from 'react-router'; import { cutWords, DocumentationEntry, highlightMarks } from '../utils'; diff --git a/server/sonar-web/src/main/js/apps/documentation/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/documentation/components/__tests__/App-test.tsx index 1c18bcb3437..5c2bb59ac31 100644 --- a/server/sonar-web/src/main/js/apps/documentation/components/__tests__/App-test.tsx +++ b/server/sonar-web/src/main/js/apps/documentation/components/__tests__/App-test.tsx @@ -28,28 +28,26 @@ import App from '../App'; jest.mock('../../../../components/common/ScreenPositionHelper'); -jest.mock('Docs/../static/SonarQubeNavigationTree.json', () => ({ - default: [ - { - title: 'SonarQube', - children: [ - '/lorem/ipsum/', - '/analysis/languages/csharp/', - { - title: 'Child category', - children: [ - '/lorem/ipsum/dolor', - { - title: 'Grandchild category', - children: ['/lorem/ipsum/sit'] - }, - '/lorem/ipsum/amet' - ] - } - ] - } - ] -})); +jest.mock('Docs/../static/SonarQubeNavigationTree.json', () => [ + { + title: 'SonarQube', + children: [ + '/lorem/ipsum/', + '/analysis/languages/csharp/', + { + title: 'Child category', + children: [ + '/lorem/ipsum/dolor', + { + title: 'Grandchild category', + children: ['/lorem/ipsum/sit'] + }, + '/lorem/ipsum/amet' + ] + } + ] + } +]); jest.mock('../../../../helpers/pages', () => ({ addSideBarClass: jest.fn(), @@ -70,14 +68,12 @@ jest.mock('../../../../helpers/request', () => { jest.mock('../../pages', () => { const { mockDocumentationEntry } = jest.requireActual('../../../../helpers/testMocks'); - return { - default: jest - .fn() - .mockReturnValue([ - mockDocumentationEntry(), - mockDocumentationEntry({ url: '/analysis/languages/csharp/' }) - ]) - }; + return jest + .fn() + .mockReturnValue([ + mockDocumentationEntry(), + mockDocumentationEntry({ url: '/analysis/languages/csharp/' }) + ]); }); jest.mock('../../../../api/plugins', () => ({ diff --git a/server/sonar-web/src/main/js/apps/documentation/components/__tests__/SearchResults-test.tsx b/server/sonar-web/src/main/js/apps/documentation/components/__tests__/SearchResults-test.tsx index 88d5acffaa3..cb15ab5066d 100644 --- a/server/sonar-web/src/main/js/apps/documentation/components/__tests__/SearchResults-test.tsx +++ b/server/sonar-web/src/main/js/apps/documentation/components/__tests__/SearchResults-test.tsx @@ -22,8 +22,8 @@ import lunr from 'lunr'; import * as React from 'react'; import SearchResults from '../SearchResults'; -jest.mock('lunr', () => ({ - default: jest.fn(() => ({ +jest.mock('lunr', () => + jest.fn(() => ({ search: jest.fn(() => [ { ref: 'lorem/origin', @@ -61,7 +61,7 @@ jest.mock('lunr', () => ({ } ]) })) -})); +); function createPage(title: string, relativeName: string, text = '') { return { relativeName, url: '/' + relativeName, title, navTitle: undefined, text, content: text }; diff --git a/server/sonar-web/src/main/js/apps/documentation/documentation.directory-loader.js b/server/sonar-web/src/main/js/apps/documentation/documentation.directory-loader.js index 77d077b7ff9..1e09ae66170 100644 --- a/server/sonar-web/src/main/js/apps/documentation/documentation.directory-loader.js +++ b/server/sonar-web/src/main/js/apps/documentation/documentation.directory-loader.js @@ -20,5 +20,5 @@ const path = require('path'); module.exports = { - root: path.resolve(__dirname, '../../../../../../sonar-docs/src/pages') + placeholder: true // doesn't matter, this is replaced by esbuild }; diff --git a/server/sonar-web/src/main/js/apps/documentation/pages.ts b/server/sonar-web/src/main/js/apps/documentation/pages.ts index e083f2b3dd9..47a77d52f74 100644 --- a/server/sonar-web/src/main/js/apps/documentation/pages.ts +++ b/server/sonar-web/src/main/js/apps/documentation/pages.ts @@ -20,7 +20,7 @@ import remark from 'remark'; import visit from 'unist-util-visit'; import { filterContent, ParsedContent, separateFrontMatter } from '../../helpers/markdown'; -import * as Docs from './documentation.directory-loader'; +import Docs from './documentation.directory-loader'; import { DocumentationEntry, DocumentationEntryScope } from './utils'; export default function getPages( |