Skip to content

Commit

Permalink
Fix lint issues following eslint prettier update
Browse files Browse the repository at this point in the history
  • Loading branch information
jhildenbiddle committed May 23, 2024
1 parent b84a60b commit cf532d8
Show file tree
Hide file tree
Showing 52 changed files with 227 additions and 220 deletions.
2 changes: 1 addition & 1 deletion build/cover.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ let cover = read(file, 'utf8').toString();
console.log('Replace version number in cover page...');
cover = cover.replace(
/<small>(\S+)?<\/small>/g,
/* html */ `<small>${version}</small>`
/* html */ `<small>${version}</small>`,
);
write(file, cover);
14 changes: 7 additions & 7 deletions build/emoji.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const filePaths = {
'src',
'core',
'render',
'emoji-data.js'
'emoji-data.js',
),
};

Expand All @@ -26,7 +26,7 @@ async function getEmojiData() {

// Remove base URL from emoji URLs
Object.entries(data).forEach(
([key, value]) => (data[key] = value.replace(baseURL, ''))
([key, value]) => (data[key] = value.replace(baseURL, '')),
);

console.info(`- Retrieved ${Object.keys(data).length} emoji entries`);
Expand All @@ -41,7 +41,7 @@ function writeEmojiPage(emojiData) {
const isExistingPage = fs.existsSync(filePaths.emojiMarkdown);
const emojiPage =
(isExistingPage && fs.readFileSync(filePaths.emojiMarkdown, 'utf8')) ||
`<!-- START -->\n\n<!-- END -->`;
'<!-- START -->\n\n<!-- END -->';
const emojiRegEx = /(<!--\s*START.*-->\n)([\s\S]*)(\n<!--\s*END.*-->)/;
const emojiMatch = emojiPage.match(emojiRegEx);
const emojiMarkdownStart = emojiMatch[1].trim();
Expand All @@ -51,20 +51,20 @@ function writeEmojiPage(emojiData) {
.reduce(
(preVal, curVal) =>
(preVal += `:${curVal}: ` + '`' + `:${curVal}:` + '`' + '\n\n'),
''
'',
)
.trim();

if (emojiMarkdown !== newEmojiMarkdown) {
const newEmojiPage = emojiPage.replace(
emojiMatch[0],
`${emojiMarkdownStart}\n\n${newEmojiMarkdown}\n\n${emojiMarkdownEnd}`
`${emojiMarkdownStart}\n\n${newEmojiMarkdown}\n\n${emojiMarkdownEnd}`,
);

fs.writeFileSync(filePaths.emojiMarkdown, newEmojiPage);

console.info(
`- ${!isExistingPage ? 'Created' : 'Updated'}: ${filePaths.emojiMarkdown}`
`- ${!isExistingPage ? 'Created' : 'Updated'}: ${filePaths.emojiMarkdown}`,
);
} else {
console.info(`- No changes: ${filePaths.emojiMarkdown}`);
Expand All @@ -86,7 +86,7 @@ function writeEmojiJS(emojiData) {
fs.writeFileSync(filePaths.emojiJS, newEmojiJS);

console.info(
`- ${!isExistingPage ? 'Created' : 'Updated'}: ${filePaths.emojiJS}`
`- ${!isExistingPage ? 'Created' : 'Updated'}: ${filePaths.emojiJS}`,
);
} else {
console.info(`- No changes: ${filePaths.emojiJS}`);
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
2 changes: 1 addition & 1 deletion docs/markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ window.$docsify = {
return /* html */ `
<div class="mermaid">${mermaid.render(
'mermaid-svg-' + num++,
code
code,
)}</div>
`;
}
Expand Down
6 changes: 3 additions & 3 deletions docs/pwa.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,19 @@ self.addEventListener('fetch', event => {
.then(resp => resp || fetched)
.catch(_ => {
/* eat any errors */
})
}),
);

// Update the cache with the version we fetched (only for ok status)
event.waitUntil(
Promise.all([fetchedCopy, caches.open(RUNTIME)])
.then(
([response, cache]) =>
response.ok && cache.put(event.request, response)
response.ok && cache.put(event.request, response),
)
.catch(_ => {
/* eat any errors */
})
}),
);
}
});
Expand Down
2 changes: 1 addition & 1 deletion middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default async function middleware(request) {
const indexHTML = await fetch(indexURL).then(res => res.text());
const previewHTML = rewriteRules.reduce(
(html, rule) => html.replace(rule.match, rule.replace),
indexHTML
indexHTML,
);

return new Response(previewHTML, {
Expand Down
2 changes: 1 addition & 1 deletion playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const config = {
testDir: './test/e2e',
timeout: 30 * 1000,
workers: process.env.CI ? 1 : undefined, // No parallel tests on CI
forbidOnly: !!process.env.CI, // Fail on CI if test.only in source
forbidOnly: Boolean(process.env.CI), // Fail on CI if test.only in source

// Output
outputDir: './_playwright-results/', // screenshots, videos, traces, etc.
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const pluginConfigs = pluginPaths.map(pluginPath => {
// =============================================================================
const currentYear = new Date().getFullYear();
const { homepage, license, version } = JSON.parse(
await fs.readFile(path.join(import.meta.dirname, 'package.json'), 'utf8')
await fs.readFile(path.join(import.meta.dirname, 'package.json'), 'utf8'),
);
const baseConfig = {
output: {
Expand Down
6 changes: 3 additions & 3 deletions src/core/Docsify.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ import { Lifecycle } from './init/lifecycle.js';

/** @typedef {new (...args: any[]) => any} Constructor */

// eslint-disable-next-line new-cap
export class Docsify extends Fetch(
// eslint-disable-next-line new-cap
Events(Render(VirtualRoutes(Router(Lifecycle(Object)))))
Events(Render(VirtualRoutes(Router(Lifecycle(Object))))),
) {
config = config(this);

Expand All @@ -37,6 +35,8 @@ export class Docsify extends Fetch(
} catch (err) {
if (this.config.catchPluginErrors) {
const errTitle = 'Docsify plugin error';

// eslint-disable-next-line no-console
console.error(errTitle, err);
} else {
throw err;
Expand Down
10 changes: 6 additions & 4 deletions src/core/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export default function (vm) {
set themeColor(value) {
if (value) {
this.__themeColor = value;

// eslint-disable-next-line no-console
console.warn(
stripIndent(`
$docsify.themeColor is deprecated. Use a --theme-color property in your style sheet. Example:
Expand All @@ -57,15 +59,15 @@ export default function (vm) {
--theme-color: deeppink;
}
</style>
`).trim()
`).trim(),
);
}
},
},

typeof window.$docsify === 'function'
? window.$docsify(vm)
: window.$docsify
: window.$docsify,
);

// Merge default and user-specified key bindings
Expand All @@ -86,14 +88,14 @@ export default function (vm) {
},
},
// User-specified
config.keyBindings
config.keyBindings,
);
}

const script =
currentScript ||
Array.from(document.getElementsByTagName('script')).filter(n =>
/docsify\./.test(n.src)
/docsify\./.test(n.src),
)[0];

if (script) {
Expand Down
30 changes: 15 additions & 15 deletions src/core/event/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function Events(Base) {
if (topMargin) {
document.documentElement.style.setProperty(
'scroll-padding-top',
`${topMargin}px`
`${topMargin}px`,
);
}

Expand Down Expand Up @@ -93,7 +93,7 @@ export function Events(Base) {
a.compareDocumentPosition(b) &
Node.DOCUMENT_POSITION_FOLLOWING
? -1
: 1
: 1,
)[0]
: // Get first and only item in set.
// May be undefined if no headings are in view.
Expand All @@ -115,7 +115,7 @@ export function Events(Base) {
},
{
rootMargin: '0% 0% -50% 0%', // Top half of viewport
}
},
);

headingElms.forEach(elm => {
Expand Down Expand Up @@ -172,7 +172,7 @@ export function Events(Base) {
// Handle keyboard events
dom.on('keydown', e => {
const isTextEntry = document.activeElement.matches(
'input, select, textarea'
'input, select, textarea',
);

if (isTextEntry) {
Expand All @@ -192,9 +192,9 @@ export function Events(Base) {
(modifierKeys.includes(k) && e[k + 'Key']) ||
e.key === k || // Ex: " ", "a"
e.code.toLowerCase() === k || // "space"
e.code.toLowerCase() === `key${k}` // "keya"
)
)
e.code.toLowerCase() === `key${k}`, // "keya"
),
),
);

matchingConfigs.forEach(({ callback }) => {
Expand Down Expand Up @@ -262,7 +262,7 @@ export function Events(Base) {
dom.on(
dom.body,
'click',
() => dom.body.classList.contains('close') && toggle()
() => dom.body.classList.contains('close') && toggle(),
);
}

Expand Down Expand Up @@ -297,7 +297,7 @@ export function Events(Base) {
onRender() {
const currentPath = this.router.toURL(this.router.getCurrentPath());
const currentTitle = dom.find(
`.sidebar a[href='${currentPath}']`
`.sidebar a[href='${currentPath}']`,
)?.innerText;

// Update page title
Expand Down Expand Up @@ -327,7 +327,7 @@ export function Events(Base) {
// Anchor link
if (query.id) {
const headingElm = dom.find(
`.markdown-section :where(h1, h2, h3, h4, h5)[id="${query.id}"]`
`.markdown-section :where(h1, h2, h3, h4, h5)[id="${query.id}"]`,
);

if (headingElm) {
Expand Down Expand Up @@ -402,7 +402,7 @@ export function Events(Base) {
.find(
a =>
href.includes(a.getAttribute('href')) ||
href.includes(decodeURI(a.getAttribute('href')))
href.includes(decodeURI(a.getAttribute('href'))),
);
const oldActive = dom.find(navElm, 'li.active');

Expand Down Expand Up @@ -434,7 +434,7 @@ export function Events(Base) {
const newActive = dom
.find(
sidebar,
`a[href="${href}"], a[href="${decodeURIComponent(href)}"]`
`a[href="${href}"], a[href="${decodeURIComponent(href)}"]`,
)
?.closest('li');

Expand Down Expand Up @@ -467,7 +467,7 @@ export function Events(Base) {
const newPage = dom
.find(
sidebar,
`a[href="${path}"], a[href="${decodeURIComponent(path)}"]`
`a[href="${path}"], a[href="${decodeURIComponent(path)}"]`,
)
?.closest('li');

Expand Down Expand Up @@ -496,7 +496,7 @@ export function Events(Base) {
document.addEventListener(
'scrollend',
() => (this.#isScrolling = false),
{ once: true }
{ once: true },
);
}
// Browsers w/o native scrollend event support (Safari)
Expand All @@ -515,7 +515,7 @@ export function Events(Base) {
document.addEventListener('scroll', callback, false);
}
},
{ once: true }
{ once: true },
);
}
};
Expand Down
Loading

0 comments on commit cf532d8

Please sign in to comment.