Skip to content

Removed linter warnings #820

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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: 1 addition & 1 deletion src/components/CodeEmbed/frame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export const CodeFrame = (props: CodeFrameProps) => {
return;
}
})();
}, [props.jsCode, mounted]);
}, [props.jsCode, mounted,p5ScriptTag]);

return (
<div
Expand Down
50 changes: 26 additions & 24 deletions src/components/SearchProvider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,7 @@ const SearchProvider = ({
const [results, setResults] = useState<SearchResult[]>([]);

// Flattens the search index data
const flattenData = (data: FuseResult<SearchResult>) => {
const flatData: SearchResult[] = [];
let flatId = 0;
Object.entries(data).forEach(([category, entries]) => {
Object.entries(entries).forEach(([title, docDetails]) => {
// Since we are generating these links with Javascript and the
// middleware doesn't prefix the locale automatically, we need to
// do it manually here.
const relativeUrl =
currentLocale === defaultLocale
? docDetails.relativeUrl
: `/${currentLocale}${docDetails.relativeUrl}`;
docDetails.relativeUrl = relativeUrl;
flatData.push({
id: flatId++,
category: category.replace("-fallback", ""),
title,
...docDetails,
});
});
});

return flatData;
};


// Read the search term from query params on first load
useEffect(() => {
Expand All @@ -80,6 +57,31 @@ const SearchProvider = ({
}

if (!searchTerm) return;

const flattenData = (data: FuseResult<SearchResult>) => {
Copy link
Member

Choose a reason for hiding this comment

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

Could you explain why this one had to be moved, please?

Copy link
Author

Choose a reason for hiding this comment

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

image

@ksen0 this was done to fix this warning

const flatData: SearchResult[] = [];
let flatId = 0;
Object.entries(data).forEach(([category, entries]) => {
Object.entries(entries).forEach(([title, docDetails]) => {
// Since we are generating these links with Javascript and the
// middleware doesn't prefix the locale automatically, we need to
// do it manually here.
const relativeUrl =
currentLocale === defaultLocale
? docDetails.relativeUrl
: `/${currentLocale}${docDetails.relativeUrl}`;
docDetails.relativeUrl = relativeUrl;
flatData.push({
id: flatId++,
category: category.replace("-fallback", ""),
title,
...docDetails,
});
});
});

return flatData;
};

let flatData;

Expand Down
2 changes: 1 addition & 1 deletion src/pages/_utils-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const rewriteRelativeLink = (url: string): string => {
!updatedUrl.endsWith('/') &&
!/(\.\w+)$/.exec(updatedUrl) &&
!updatedUrl.includes('?') &&
!/#([\w\-]+)$/.exec(updatedUrl)
!/#([\w-]+)$/.exec(updatedUrl)
) {
updatedUrl += '/';
}
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/branchTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ currentEnv = currentEnv
.split('\n')
.filter((line: string) => !line.startsWith('P5_') && !line.startsWith('PUBLIC_P5_'))
.join('\n')
writeFileSync(envFilePath, currentEnv + '\n' + envVars.join('\n'));
writeFileSync(envFilePath, `${currentEnv }\n${ envVars.join('\n')}`);

// First delete the existing cloned p5 to make sure we clone fresh
const parsedP5Path = path.join(__dirname, "./parsers/in/p5.js/");
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/builders/contribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@ const moveContentDirectory = async (
const buildContributorDocs = async () => {
console.log("Building contributor docs...");

let latestRelease = p5Version;
let latestRelease:string = p5Version;
if (/^\d+\.\d+\.\d+$/.exec(latestRelease)) {
latestRelease = 'v' + latestRelease;
latestRelease = `v${ latestRelease}`;
}

await cloneLibraryRepo(clonedRepoPath, docsRepoUrl, latestRelease);
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/builders/reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ const correctRelativeLinksInDescription = (description: string | undefined) => {
!href.endsWith('/') &&
!/(\.\w+)$/.exec(href) &&
!href.includes('?') &&
!/#([\w\-]+)$/.exec(href)
!/#([\w-]+)$/.exec(href)
) {
href += '/';
}
Expand Down
10 changes: 5 additions & 5 deletions src/scripts/parsers/reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ const parsersOutPath = path.join(__dirname, "out");
*/
export const parseLibraryReference =
async (): Promise<ParsedLibraryReference | null> => {
let latestRelease = p5Version;
let latestRelease:string = p5Version;
if (/^\d+\.\d+\.\d+$/.exec(latestRelease)) {
latestRelease = 'v' + latestRelease;
latestRelease = `v${ latestRelease}`;
}

const useExternalP5Sound = !!process.env.P5_REPO_BRANCH ||
Expand All @@ -44,7 +44,7 @@ export const parseLibraryReference =
// If we're using a custom build of p5 instead of a public release, create
// a build and copy it to the specified path
if (process.env.PUBLIC_P5_LIBRARY_PATH) {
await createP5Build('p5.js', '../../../public' + process.env.PUBLIC_P5_LIBRARY_PATH);
await createP5Build('p5.js', `../../../public${ process.env.PUBLIC_P5_LIBRARY_PATH}`);
}

// Copy the reference output so we can process it
Expand All @@ -67,7 +67,7 @@ export const parseLibraryReference =

// Fix p5.sound classes
for (const key in soundData.classes) {
const newName = 'p5.' + soundData.classes[key].name;
const newName = `p5.${ soundData.classes[key].name}`;
const updated = {
...soundData.classes[key],
name: newName,
Expand All @@ -76,7 +76,7 @@ export const parseLibraryReference =
delete soundData.classes[key];
}
for (const item of soundData.classitems) {
item.class = 'p5.' + item.class;
item.class = `p5.${ item.class}`;
}

result = await combineYuidocData(
Expand Down
6 changes: 3 additions & 3 deletions src/scripts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { fileURLToPath } from "url";
import { rewriteRelativeLink } from "../pages/_utils-node";
import { p5Version } from "../globals/p5-version";

let latestRelease = p5Version;
let latestRelease:string = p5Version;
// If the latest release is a version number (e.g. 1.10.0) without a 'v'
// prefix, add the v prefix
if (/^\d+\.\d+\.\d+$/.exec(latestRelease)) {
latestRelease = 'v' + latestRelease;
latestRelease = `v${latestRelease}`;
}

export const p5RepoUrl = "https://github.com/processing/p5.js.git";
Expand Down Expand Up @@ -295,7 +295,7 @@ export const rewriteRelativeMdLinks = (markdownText: string): string => {
* 1. Text for the link
* 2. Link url (but not the .md extension at the end)
*/
const regexPattern: RegExp = /(\!?)\[([^\]]+)\]\(([^\)]+)\)/g;
const regexPattern: RegExp = /(!?)\[([^\]]+)\]\(([^)]+)\)/g;
return markdownText.replace(regexPattern, (match, img, linkText, url: string) => {
// Don't convert images
if (img) return match;
Expand Down
Loading