Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ const apifyClient = new ApifyClient({
const result = await apifyClient
.requestQueue('<QUEUE ID>')
.addRequest({
'uniqueKey': 'http://example.com',
'url': 'http://example.com',
'method': 'GET',
uniqueKey: 'http://example.com',
url: 'http://example.com',
method: 'GET',
});

console.log(result);
44 changes: 22 additions & 22 deletions apify-docs-theme/src/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,6 @@ const remarkStringify = require('remark-stringify');
const { unified } = require('unified');
const { visitParents } = require('unist-util-visit-parents');

/**
* Updates the markdown content for better UX and compatibility with Docusaurus v3.
* @param {string} changelog The markdown content.
* @returns {string} The updated markdown content.
*/
function updateChangelog(changelog) {
const pipeline = unified()
.use(remarkParse)
.use(removeGitCliffMarkers)
.use(incrementHeadingLevels)
.use(prettifyPRLinks)
.use(linkifyUserTags)
.use(remarkStringify);

changelog = pipeline.processSync(changelog).toString();
changelog = addFrontmatter(changelog);
changelog = escapeMDXCharacters(changelog);
return changelog;
}

/**
* Bumps the headings levels in the markdown content. This function increases the depth
* of all headings in the content by 1. This is useful when the content is included in
Expand Down Expand Up @@ -60,7 +40,7 @@ const linkifyUserTags = () => (tree) => {

const directParent = parents[parents.length - 1];

if (!match || directParent.type === 'link') return;
if (!match || directParent.type === 'link') return 0;

const nodeIndexInParent = directParent.children.findIndex((x) => x === node);

Expand Down Expand Up @@ -95,7 +75,7 @@ const prettifyPRLinks = () => (tree) => {
const prLinkRegex = /https:\/\/github.com\/[^\s]+\/pull\/(\d+)/g;
const match = prLinkRegex.exec(node.value);

if (!match) return;
if (!match) return 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a hunch this might be why the apify-sdk-python docs build is stalling, as returning an index from the visitor means "continue by visiting my n-th sibling", which, with 0, might potentially cause an infinite loop.

Was this a quick eslint's consistent-return fix, or did you have a deeper reason for this? 😅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this a quick eslint's consistent-return fix, or did you have a deeper reason for this? 😅

Yeah, exactly, feel free to revert that.

Mixed return types are evil, especially in vanilla JS. This is just another proof :D


const directParent = parents[parents.length - 1];
const nodeIndexInParent = directParent.children.findIndex((x) => x === node);
Expand Down Expand Up @@ -148,6 +128,26 @@ function escapeMDXCharacters(changelog) {
});
}

/**
* Updates the markdown content for better UX and compatibility with Docusaurus v3.
* @param {string} changelog The markdown content.
* @returns {string} The updated markdown content.
*/
function updateChangelog(changelog) {
const pipeline = unified()
.use(remarkParse)
.use(removeGitCliffMarkers)
.use(incrementHeadingLevels)
.use(prettifyPRLinks)
.use(linkifyUserTags)
.use(remarkStringify);

changelog = pipeline.processSync(changelog).toString();
changelog = addFrontmatter(changelog);
changelog = escapeMDXCharacters(changelog);
return changelog;
}

module.exports = {
updateChangelog,
};
6 changes: 3 additions & 3 deletions apify-docs-theme/src/roa-loader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ async function getHash(source) {
})).json();

if (!res.data || !res.data.encoded) {
// eslint-disable-next-line no-console
console.error(`Signing failed:' ${inspect(res.error) || 'Unknown error'}`, res);
return 'invalid-token';
}

cache[cacheKey] = res.data.encoded;
await new Promise((resolve) => setTimeout(resolve, 100));
await new Promise((resolve) => {
setTimeout(resolve, 100);
});

return res.data.encoded;
}
Expand Down Expand Up @@ -79,7 +80,6 @@ module.exports = async function (code) {
return { code, hash: 'fast' };
}

// eslint-disable-next-line no-console
console.log(`Signing ${urlToRequest(this.resourcePath)}...`, { working, queue: queue.length });
const codeHash = await encodeAndSign(code);

Expand Down
1 change: 0 additions & 1 deletion apify-docs-theme/src/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ This either means that your Docusaurus setup is misconfigured, or that your GitH
await generateChangelogFromGitHubReleases(pathsToCopyChangelog, `${context.siteConfig.organizationName}/${context.siteConfig.projectName}`);
}
} catch (e) {
// eslint-disable-next-line no-console
console.warn(`Changelog page could not be initialized: ${e.message}`);
}
},
Expand Down
12 changes: 6 additions & 6 deletions apify-docs-theme/src/theme/ColorModeToggle/index.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
// eslint-disable-next-line import/no-extraneous-dependencies
import clsx from 'clsx';
import useIsBrowser from '@docusaurus/useIsBrowser';
import { translate } from '@docusaurus/Translate';
import IconLightMode from '../Icon/LightMode';
import IconDarkMode from '../Icon/DarkMode';
import useIsBrowser from '@docusaurus/useIsBrowser';
import clsx from 'clsx';
import React from 'react';

import styles from './styles.module.css';
import IconDarkMode from '../Icon/DarkMode';
import IconLightMode from '../Icon/LightMode';

function ColorModeToggle({
className,
Expand Down
12 changes: 6 additions & 6 deletions apify-docs-theme/src/theme/DocSidebarItem/Link/index.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
// eslint-disable-next-line import/no-extraneous-dependencies
import clsx from 'clsx';
import isInternalUrl from '@docusaurus/isInternalUrl';
import Link from '@docusaurus/Link';
import { isActiveSidebarItem } from '@docusaurus/plugin-content-docs/client';
import { ThemeClassNames } from '@docusaurus/theme-common';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import { isActiveSidebarItem } from '@docusaurus/plugin-content-docs/client';
import Link from '@docusaurus/Link';
import isInternalUrl from '@docusaurus/isInternalUrl';
import IconExternalLink from '@theme/Icon/ExternalLink';
import clsx from 'clsx';
import React from 'react';

import styles from './styles.module.css';

export default function DocSidebarItemLink({
Expand Down
6 changes: 3 additions & 3 deletions apify-docs-theme/src/theme/Footer/index.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
// eslint-disable-next-line import/no-extraneous-dependencies
import clsx from 'clsx';
import { useThemeConfig } from '@docusaurus/theme-common';
import LinkItem from '@theme/Footer/LinkItem';
import clsx from 'clsx';
import React from 'react';

import styles from './index.module.css';

function FooterLinksColumn({ column }) {
Expand Down
12 changes: 6 additions & 6 deletions apify-docs-theme/src/theme/Layout/index.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import { useLocation } from '@docusaurus/router';
// cannot use any of the theme aliases here as it causes a circular dependency :( ideas welcome
import Layout from '@docusaurus/theme-classic/lib/theme/Layout/index';
import { usePluginData } from '@docusaurus/useGlobalData';
import useBaseUrl from '@docusaurus/useBaseUrl';
import { useLocation } from '@docusaurus/router';
import { usePluginData } from '@docusaurus/useGlobalData';
import React from 'react';

export default function LayoutWrapper(props) {
const { options: { subNavbar } } = usePluginData('@apify/docs-theme');
Expand All @@ -13,9 +13,9 @@ export default function LayoutWrapper(props) {
return (
<div style={{
'--ifm-navbar-height': subNavbar && !currentPath.startsWith('api/v2') ? '123px' : '68px',
'margin': 0,
'padding': 0,
'boxSizing': 'border-box',
margin: 0,
padding: 0,
boxSizing: 'border-box',
}}>
<Layout {...props} />
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import { useThemeConfig } from '@docusaurus/theme-common';
import useBaseUrl from '@docusaurus/useBaseUrl';
import { usePluginData } from '@docusaurus/useGlobalData';
import NavbarItem from '@theme/NavbarItem';
import React from 'react';

function useNavbarItems() {
// TODO temporary casting until ThemeConfig type is improved
Expand Down
31 changes: 15 additions & 16 deletions apify-docs-theme/src/theme/NavbarItem/ComponentTypes.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { useDocsVersion, useLayoutDoc } from '@docusaurus/plugin-content-docs/client';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
import DocSidebarNavbarItem from '@theme/NavbarItem/DocSidebarNavbarItem';
import DocsVersionDropdownNavbarItem from '@theme/NavbarItem/DocsVersionDropdownNavbarItem';
import DocsVersionNavbarItem from '@theme/NavbarItem/DocsVersionNavbarItem';
import DropdownNavbarItem from '@theme/NavbarItem/DropdownNavbarItem';
import HtmlNavbarItem from '@theme/NavbarItem/HtmlNavbarItem';
import LocaleDropdownNavbarItem from '@theme/NavbarItem/LocaleDropdownNavbarItem';
import SearchNavbarItem from '@theme/NavbarItem/SearchNavbarItem';
import HtmlNavbarItem from '@theme/NavbarItem/HtmlNavbarItem';
import DocSidebarNavbarItem from '@theme/NavbarItem/DocSidebarNavbarItem';
import DocsVersionNavbarItem from '@theme/NavbarItem/DocsVersionNavbarItem';
import DocsVersionDropdownNavbarItem from '@theme/NavbarItem/DocsVersionDropdownNavbarItem';
import { useDocsVersion, useLayoutDoc } from '@docusaurus/plugin-content-docs/client';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import React from 'react';

// const versions = require('../../../versions.json');
Expand Down Expand Up @@ -40,7 +40,6 @@ function ApiNavbarItem(ctx) {
let version = {};

try {
// eslint-disable-next-line react-hooks/rules-of-hooks
version = useDocsVersion();
} catch {
version.version = stable;
Expand Down Expand Up @@ -87,15 +86,15 @@ function ApiNavbarItem(ctx) {
}

const ComponentTypes = {
'default': DefaultNavbarItem,
'localeDropdown': LocaleDropdownNavbarItem,
'search': SearchNavbarItem,
'dropdown': DropdownNavbarItem,
'html': HtmlNavbarItem,
default: DefaultNavbarItem,
localeDropdown: LocaleDropdownNavbarItem,
search: SearchNavbarItem,
dropdown: DropdownNavbarItem,
html: HtmlNavbarItem,
'custom-api': ApiNavbarItem,
'doc': DocNavbarItem,
'docSidebar': DocSidebarNavbarItem,
'docsVersion': DocsVersionNavbarItem,
'docsVersionDropdown': DocsVersionDropdownNavbarItem,
doc: DocNavbarItem,
docSidebar: DocSidebarNavbarItem,
docsVersion: DocsVersionNavbarItem,
docsVersionDropdown: DocsVersionDropdownNavbarItem,
};
export default ComponentTypes;
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
// eslint-disable-next-line import/no-extraneous-dependencies
import clsx from 'clsx';
import CodeBlock from '@theme/CodeBlock';
import Link from '@docusaurus/Link';
import CodeBlock from '@theme/CodeBlock';
import clsx from 'clsx';
import React from 'react';

import styles from './RunnableCodeBlock.module.css';

const EXAMPLE_RUNNERS = {
Expand Down
3 changes: 2 additions & 1 deletion apify-docs-theme/src/theme/SearchBar/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { ApifySearch } from '@apify/docs-search-modal';
import BrowserOnly from '@docusaurus/BrowserOnly';
import RouterLink from '@docusaurus/Link';
import { useLocation, useHistory } from '@docusaurus/router';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import React, { useCallback } from 'react';

import { ApifySearch } from '@apify/docs-search-modal';

/**
* Tests whether the given href is pointing to the current docusaurus instance (so we can use the router link).
*/
Expand Down
49 changes: 49 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import react from 'eslint-plugin-react';
import globals from 'globals';

import apify from '@apify/eslint-config';

export default [
{
ignores: ['**/dist', 'node_modules', '.docusaurus', 'build', 'sources/api'],
},
...apify,
{
languageOptions: {
parserOptions: {
project: 'tsconfig.eslint.json',
},
},
},
Comment on lines +11 to +17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not fully sure if this works, in my own project I had to do something like this to define tsconfig for the rules but maybe it works without it anymore
https://github.com/vladfrangu/highlight/blob/7d1a50341d175192e2cf54219d730f8d58407944/eslint.config.js#L19-L27

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i believe it does, without it i get warnings like

Error: Error while loading rule '@typescript-eslint/no-floating-promises': You have used a rule which requires type information, but don't have parserOptions set to generate type information for this file. See https://typescript-eslint.io/getting-started/typed-linting for enabling linting with type information.
Parser: typescript-eslint/parser

and before I've added the sources and examples folders it was complaining about that like

/Users/adamek/htdocs/apify/apify-docs/examples/ts-parallel-scraping/orchestrator/src/main.ts
  0:0  error  Parsing error: "parserOptions.project" has been provided for @typescript-eslint/parser.
The file was not found in any of the provided project(s): examples/ts-parallel-scraping/orchestrator/src/main.ts

/Users/adamek/htdocs/apify/apify-docs/examples/ts-parallel-scraping/scraper/src/main.ts
  0:0  error  Parsing error: "parserOptions.project" has been provided for @typescript-eslint/parser.
The file was not found in any of the provided project(s): examples/ts-parallel-scraping/scraper/src/main.ts

so i guess this is enough (and the CI confirms that)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess its because the apify eslint config is using that plugin

https://github.com/apify/apify-eslint-config/blob/master/index.js#L145

{
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'no-param-reassign': 'off',
'no-void': 'off',
'no-console': 'off',
'import/no-extraneous-dependencies': 'off',
'import/extensions': 'off',
'import/no-default-export': 'off',
},
},
{
files: ['**/*.{js,jsx,mjs,cjs,ts,tsx}'],
plugins: {
react,
},
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
globals: {
...globals.browser,
},
},
rules: {
'react/jsx-uses-react': 'error',
'react/jsx-uses-vars': 'error',
},
},
];
2 changes: 1 addition & 1 deletion examples/ts-parallel-scraping/orchestrator/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface State {
await Actor.init();

const {
parallelRunsCount= 1,
parallelRunsCount = 1,
targetActorId,
targetActorInput = {},
targetActorRunOptions = {},
Expand Down
Loading