mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-01 02:12:36 +02:00
chore: clean up ESLint config, enable a few rules (#6514)
* chore: clean up ESLint config, enable a few rules * enable max-len for comments * fix build
This commit is contained in:
parent
b8ccb869f1
commit
aa446b7a9c
167 changed files with 1157 additions and 960 deletions
|
@ -10,7 +10,9 @@ import type {HandlerEvent, HandlerResponse} from '@netlify/functions';
|
|||
const CookieName = 'DocusaurusPlaygroundName';
|
||||
|
||||
const PlaygroundConfigs = {
|
||||
// codesandbox: 'https://codesandbox.io/s/docusaurus', // Do not use this one, see https://github.com/codesandbox/codesandbox-client/issues/5683#issuecomment-1023252459
|
||||
// Do not use this one, see
|
||||
// https://github.com/codesandbox/codesandbox-client/issues/5683#issuecomment-1023252459
|
||||
// codesandbox: 'https://codesandbox.io/s/docusaurus',
|
||||
codesandbox:
|
||||
'https://codesandbox.io/s/github/facebook/docusaurus/tree/main/examples/classic',
|
||||
|
||||
|
@ -69,14 +71,11 @@ export function readPlaygroundName(
|
|||
: {};
|
||||
const playgroundName: string | undefined = parsedCookie[CookieName];
|
||||
|
||||
if (playgroundName) {
|
||||
if (isValidPlaygroundName(playgroundName)) {
|
||||
return playgroundName;
|
||||
} else {
|
||||
console.error(
|
||||
`playgroundName found in cookie was invalid: ${playgroundName}`,
|
||||
);
|
||||
}
|
||||
if (!isValidPlaygroundName(playgroundName)) {
|
||||
console.error(
|
||||
`playgroundName found in cookie was invalid: ${playgroundName}`,
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
return undefined;
|
||||
return playgroundName;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,6 @@ import type {Handler} from '@netlify/functions';
|
|||
|
||||
import {createPlaygroundResponse} from '../functionUtils/playgroundUtils';
|
||||
|
||||
export const handler: Handler = async function (_event, _context) {
|
||||
export const handler: Handler = async function handler(_event, _context) {
|
||||
return createPlaygroundResponse('codesandbox');
|
||||
};
|
||||
|
|
|
@ -9,6 +9,6 @@ import type {Handler} from '@netlify/functions';
|
|||
|
||||
import {createPlaygroundResponse} from '../functionUtils/playgroundUtils';
|
||||
|
||||
export const handler: Handler = async function (_event, _context) {
|
||||
export const handler: Handler = async function handler(_event, _context) {
|
||||
return createPlaygroundResponse('stackblitz');
|
||||
};
|
||||
|
|
|
@ -26,16 +26,16 @@ async function generateTemplateExample(template) {
|
|||
`generating ${template} template for codesandbox in the examples folder...`,
|
||||
);
|
||||
|
||||
// run the docusaurus script to bootstrap the template in the examples folder
|
||||
// run the docusaurus script to create the template in the examples folder
|
||||
const command = template.endsWith('-typescript')
|
||||
? template.replace('-typescript', ' -- --typescript')
|
||||
: template;
|
||||
shell.exec(
|
||||
// /!\ we use the published init script on purpose,
|
||||
// because using the local init script is too early and could generate upcoming/unavailable config options
|
||||
// remember CodeSandbox templates will use the published version, not the repo version
|
||||
// because using the local init script is too early and could generate
|
||||
// upcoming/unavailable config options. Remember CodeSandbox templates
|
||||
// will use the published version, not the repo version
|
||||
`npm init docusaurus@latest examples/${template} ${command}`,
|
||||
// `node ./packages/docusaurus-init/bin/index.js init examples/${template} ${template}`,
|
||||
);
|
||||
|
||||
// read the content of the package.json
|
||||
|
@ -49,10 +49,10 @@ async function generateTemplateExample(template) {
|
|||
// these example projects are not meant to be published to npm
|
||||
templatePackageJson.private = true;
|
||||
|
||||
// make sure package.json name is not "examples-classic"
|
||||
// the package.json name appear in CodeSandbox UI so let's display a good name!
|
||||
// unfortunately we can't use uppercase or spaces
|
||||
// see also https://github.com/codesandbox/codesandbox-client/pull/5136#issuecomment-763521662
|
||||
// Make sure package.json name is not "examples-classic". The package.json
|
||||
// name appears in CodeSandbox UI so let's display a good name!
|
||||
// Unfortunately we can't use uppercase or spaces... See also
|
||||
// https://github.com/codesandbox/codesandbox-client/pull/5136#issuecomment-763521662
|
||||
templatePackageJson.name =
|
||||
template === 'classic' ? 'docusaurus' : `docusaurus-${template}`;
|
||||
templatePackageJson.description =
|
||||
|
@ -98,12 +98,13 @@ async function generateTemplateExample(template) {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Starters are repositories/branches that only contains a newly initialized Docusaurus site
|
||||
Those are useful for users to inspect (may be more convenient than "examples/classic)
|
||||
Also some tools like Netlify deploy button currently require using the main branch of a dedicated repo
|
||||
See https://github.com/jamstack/jamstack.org/pull/609
|
||||
Button visible here: https://jamstack.org/generators/
|
||||
/**
|
||||
* Starters are repositories/branches that only contains a newly initialized
|
||||
* Docusaurus site. Those are useful for users to inspect (may be more
|
||||
* convenient than "examples/classic) Also some tools like Netlify deploy button
|
||||
* currently require using the main branch of a dedicated repo.
|
||||
* See https://github.com/jamstack/jamstack.org/pull/609
|
||||
* Button visible here: https://jamstack.org/generators/
|
||||
*/
|
||||
function updateStarters() {
|
||||
function forcePushGitSubtree({subfolder, remote, remoteBranch}) {
|
||||
|
|
|
@ -39,7 +39,8 @@ await Promise.all(
|
|||
}),
|
||||
);
|
||||
|
||||
// You should also run optimizt `find website/src/data/showcase -type f -name '*.png'`.
|
||||
// This is not included here because @funboxteam/optimizt doesn't seem to play well with M1
|
||||
// so I had to run this in a Rosetta terminal.
|
||||
// You should also run
|
||||
// optimizt `find website/src/data/showcase -type f -name '*.png'`.
|
||||
// This is not included here because @funboxteam/optimizt doesn't seem to play
|
||||
// well with M1 so I had to run this in a Rosetta terminal.
|
||||
// TODO integrate this as part of the script
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue