mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-13 00:57:53 +02:00
ESLintify Part 1 (#837)
* ESLint-ify * Allow empty try/catch * Escape regexp
This commit is contained in:
parent
128dbfca0a
commit
e8e3f42685
44 changed files with 466 additions and 555 deletions
|
@ -96,7 +96,7 @@ files.forEach(file => {
|
|||
|
||||
// returns the version to use for a document based on its id and
|
||||
// what the requested version is
|
||||
function docVersion(id, req_version) {
|
||||
function docVersion(id, reqVersion) {
|
||||
if (!available[id]) {
|
||||
return null;
|
||||
}
|
||||
|
@ -104,13 +104,10 @@ function docVersion(id, req_version) {
|
|||
// is found, then check if that version has an available file to use
|
||||
let requestedFound = false;
|
||||
for (let i = 0; i < versions.length; i++) {
|
||||
if (versions[i] === req_version) {
|
||||
if (versions[i] === reqVersion) {
|
||||
requestedFound = true;
|
||||
}
|
||||
if (!requestedFound) {
|
||||
continue;
|
||||
}
|
||||
if (available[id].has(versions[i])) {
|
||||
if (requestedFound && available[id].has(versions[i])) {
|
||||
return versions[i];
|
||||
}
|
||||
}
|
||||
|
@ -243,18 +240,16 @@ function docData() {
|
|||
}
|
||||
|
||||
// return the version of the sidebar to use given a requested version
|
||||
function sidebarVersion(req_version) {
|
||||
function sidebarVersion(reqVersion) {
|
||||
// iterate through versions until a version less than or equal to the requested
|
||||
// is found, then check if that version has an available file to use
|
||||
let requestedFound = false;
|
||||
for (let i = 0; i < versions.length; i++) {
|
||||
if (versions[i] === req_version) {
|
||||
if (versions[i] === reqVersion) {
|
||||
requestedFound = true;
|
||||
}
|
||||
if (!requestedFound) {
|
||||
continue;
|
||||
}
|
||||
if (
|
||||
requestedFound &&
|
||||
fs.existsSync(
|
||||
CWD + '/versioned_sidebars/version-' + versions[i] + '-sidebars.json'
|
||||
)
|
||||
|
@ -263,7 +258,7 @@ function sidebarVersion(req_version) {
|
|||
}
|
||||
}
|
||||
throw new Error(
|
||||
`No sidebar file available to use for version ${req_version}. Verify that 'version-${req_version}-sidebars.json' exists.`
|
||||
`No sidebar file available to use for version ${reqVersion}. Verify that 'version-${reqVersion}-sidebars.json' exists.`
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue