Skip to content

Commit 05c2c4b

Browse files
committed
Fix ESLint errors
1 parent a8ef929 commit 05c2c4b

24 files changed

+40
-36
lines changed

.eslintrc.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ module.exports = {
3838
'no-return-assign': ['error'],
3939
'no-self-compare': ['error'],
4040
'no-shadow-restricted-names': ['error'],
41-
'no-shadow': ['warn'],
41+
'no-shadow': [
42+
'error',
43+
{
44+
allow: ['Events', 'Fetch', 'Lifecycle', 'Render', 'Router'],
45+
},
46+
],
4247
'no-unused-vars': ['error', { args: 'none' }],
4348
'no-useless-call': ['error'],
4449
'no-useless-escape': ['warn'],

src/core/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { merge, hyphenate, isPrimitive, hasOwn } from './util/core';
33
const currentScript = document.currentScript;
44

55
/** @param {import('./Docsify').Docsify} vm */
6-
export default function(vm) {
6+
export default function (vm) {
77
const config = merge(
88
{
99
el: '#app',

src/core/fetch/ajax.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const cache = {};
1313
*/
1414
export function get(url, hasBar = false, headers = {}) {
1515
const xhr = new XMLHttpRequest();
16-
const on = function() {
16+
const on = function () {
1717
xhr.addEventListener.apply(xhr, arguments);
1818
};
1919

@@ -33,7 +33,7 @@ export function get(url, hasBar = false, headers = {}) {
3333
xhr.send();
3434

3535
return {
36-
then: function(success, error = noop) {
36+
then: function (success, error = noop) {
3737
if (hasBar) {
3838
const id = setInterval(
3939
_ =>

src/core/fetch/index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,9 @@ export function Fetch(Base) {
152152
if (path) {
153153
path = this.router.getFile(root + path);
154154
this.coverIsHTML = /\.html$/g.test(path);
155-
get(
156-
path + stringifyQuery(query, ['id']),
157-
false,
158-
requestHeaders
159-
).then(text => this._renderCover(text, coverOnly));
155+
get(path + stringifyQuery(query, ['id']), false, requestHeaders).then(
156+
text => this._renderCover(text, coverOnly)
157+
);
160158
} else {
161159
this._renderCover(null, coverOnly);
162160
}

src/core/global-api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { get } from './fetch/ajax';
1010
// major release. We'll tell people to get everything from the DOCSIFY global
1111
// when using the global build, but we'll highly recommend for them to import
1212
// from the ESM build (f.e. lib/docsify.esm.js and lib/docsify.min.esm.js).
13-
export default function() {
13+
export default function () {
1414
window.Docsify = {
1515
util,
1616
dom,

src/core/init/lifecycle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function Lifecycle(Base) {
3030
callHook(hookName, data, next = noop) {
3131
const queue = this._hooks[hookName];
3232

33-
const step = function(index) {
33+
const step = function (index) {
3434
const hookFn = queue[index];
3535

3636
if (index >= queue.length) {

src/core/render/compiler.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ const compileMedia = {
2828
},
2929
iframe(url, title) {
3030
return {
31-
html: `<iframe src="${url}" ${title ||
32-
'width=100% height=400'}></iframe>`,
31+
html: `<iframe src="${url}" ${
32+
title || 'width=100% height=400'
33+
}></iframe>`,
3334
};
3435
},
3536
video(url, title) {
@@ -204,7 +205,7 @@ export class Compiler {
204205
* @param {Number} level Type of heading (h<level> tag)
205206
* @returns {String} Heading element
206207
*/
207-
origin.heading = renderer.heading = function(text, level) {
208+
origin.heading = renderer.heading = function (text, level) {
208209
let { str, config } = getAndRemoveConfig(text);
209210
const nextToc = { level, title: removeAtag(str) };
210211

src/core/render/compiler/code.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Prism from 'prismjs';
33
import 'prismjs/components/prism-markup-templating';
44

55
export const highlightCodeCompiler = ({ renderer }) =>
6-
(renderer.code = function(code, lang = 'markup') {
6+
(renderer.code = function (code, lang = 'markup') {
77
const langOrMarkup = Prism.languages[lang] || Prism.languages.markup;
88
const text = Prism.highlight(
99
code.replace(/@DOCSIFY_QM@/g, '`'),

src/core/render/embed.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function walkFetchEmbed({ embedTokens, compile, fetch }, cb) {
1515

1616
while ((token = embedTokens[step++])) {
1717
// eslint-disable-next-line no-shadow
18-
const next = (function(token) {
18+
const next = (function (token) {
1919
return text => {
2020
let embedToken;
2121
if (text) {

src/core/render/emojify.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ export function emojify(text) {
1515
.replace(/<(pre|template|code)[^>]*?>[\s\S]+?<\/(pre|template|code)>/g, m =>
1616
m.replace(/:/g, '__colon__')
1717
)
18-
.replace(/:([a-z0-9_\-\+]+?):/g, (inBrowser && window.emojify) || replace)
18+
.replace(/:([a-z0-9_\-+]+?):/g, (inBrowser && window.emojify) || replace)
1919
.replace(/__colon__/g, ':');
2020
}

src/core/render/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ function renderMain(html) {
174174
// This provides a global store for all Vue instances that receive
175175
// vueGlobalOptions as their configuration.
176176
if (vueGlobalData) {
177-
vueConfig.data = function() {
177+
vueConfig.data = function () {
178178
return vueGlobalData;
179179
};
180180
}

src/core/render/progressbar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function init() {
1717
/**
1818
* Render progress bar
1919
*/
20-
export default function({ loaded, total, step }) {
20+
export default function ({ loaded, total, step }) {
2121
let num;
2222

2323
!barEl && init();

src/core/render/slugify.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ export function slugify(str) {
3232
return slug;
3333
}
3434

35-
slugify.clear = function() {
35+
slugify.clear = function () {
3636
cache = {};
3737
};

src/core/router/util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function parseQuery(query) {
1313
}
1414

1515
// Simple parse
16-
query.split('&').forEach(function(param) {
16+
query.split('&').forEach(function (param) {
1717
const parts = param.replace(/\+/g, ' ').split('=');
1818

1919
res[parts[0]] = parts[1] && decode(parts[1]);

src/core/util/core.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
export function cached(fn) {
88
const cache = Object.create(null);
9-
return function(str) {
9+
return function (str) {
1010
const key = isPrimitive(str) ? str : JSON.stringify(str);
1111
const hit = cache[key];
1212
return hit || (cache[key] = fn(str));
@@ -29,7 +29,7 @@ export const hasOwn = Object.prototype.hasOwnProperty;
2929
*/
3030
export const merge =
3131
Object.assign ||
32-
function(to) {
32+
function (to) {
3333
for (let i = 1; i < arguments.length; i++) {
3434
const from = Object(arguments[i]);
3535

src/core/util/env.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const isMobile = inBrowser && document.body.clientWidth <= 600;
77
*/
88
export const supportsPushState =
99
inBrowser &&
10-
(function() {
10+
(function () {
1111
// Borrowed wholesale from https://github.com/defunkt/jquery-pjax
1212
return (
1313
window.history &&

src/core/util/polyfill/css-vars.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function replaceVar(block, color) {
88
);
99
}
1010

11-
export default function(color) {
11+
export default function (color) {
1212
// Variable support
1313
if (window.CSS && window.CSS.supports && window.CSS.supports('(--v:red)')) {
1414
return;

src/plugins/disqus.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function install(hook, vm) {
3939
if (typeof window.DISQUS !== 'undefined') {
4040
window.DISQUS.reset({
4141
reload: true,
42-
config: function() {
42+
config: function () {
4343
this.page.url = location.origin + '/-' + vm.route.path;
4444
this.page.identifier = vm.route.path;
4545
this.page.title = document.title;

src/plugins/external-script.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function handleExternalScript() {
1818
}
1919
}
2020

21-
const install = function(hook) {
21+
const install = function (hook) {
2222
hook.doneEach(handleExternalScript);
2323
};
2424

src/plugins/front-matter/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import parser from './parser';
22

3-
const install = function(hook, vm) {
3+
const install = function (hook, vm) {
44
// Used to remove front matter from embedded pages if installed.
55
vm.config.frontMatter = {};
66
vm.config.frontMatter.installed = true;
7-
vm.config.frontMatter.parseMarkdown = function(content) {
7+
vm.config.frontMatter.parseMarkdown = function (content) {
88
const { body } = parser(content);
99
return body;
1010
};

src/plugins/ga.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function init(id) {
1111
appendScript();
1212
window.ga =
1313
window.ga ||
14-
function() {
14+
function () {
1515
(window.ga.q = window.ga.q || []).push(arguments);
1616
};
1717

@@ -28,7 +28,7 @@ function collect() {
2828
window.ga('send', 'pageview');
2929
}
3030

31-
const install = function(hook) {
31+
const install = function (hook) {
3232
if (!$docsify.ga) {
3333
console.error('[Docsify] ga is required.');
3434
return;

src/plugins/matomo.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function init(options) {
99
window._paq = window._paq || [];
1010
window._paq.push(['trackPageView']);
1111
window._paq.push(['enableLinkTracking']);
12-
setTimeout(function() {
12+
setTimeout(function () {
1313
appendScript(options);
1414
window._paq.push(['setTrackerUrl', options.host + '/matomo.php']);
1515
window._paq.push(['setSiteId', String(options.id)]);
@@ -26,7 +26,7 @@ function collect() {
2626
window._paq.push(['trackPageView']);
2727
}
2828

29-
const install = function(hook) {
29+
const install = function (hook) {
3030
if (!$docsify.matomo) {
3131
// eslint-disable-next-line no-console
3232
console.error('[Docsify] matomo is required.');

src/plugins/search/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const CONFIG = {
1313
pathNamespaces: undefined,
1414
};
1515

16-
const install = function(hook, vm) {
16+
const install = function (hook, vm) {
1717
const { util } = Docsify;
1818
const opts = vm.config.search || CONFIG;
1919

src/plugins/search/search.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function getTableData(token) {
5858
if (!token.text && token.type === 'table') {
5959
token.cells.unshift(token.header);
6060
token.text = token.cells
61-
.map(function(rows) {
61+
.map(function (rows) {
6262
return rows.join(' | ');
6363
})
6464
.join(' |\n ');
@@ -85,7 +85,7 @@ export function genIndex(path, content = '', router, depth) {
8585
let slug;
8686
let title = '';
8787

88-
tokens.forEach(function(token, tokenIndex) {
88+
tokens.forEach(function (token, tokenIndex) {
8989
if (token.type === 'heading' && token.depth <= depth) {
9090
const { str, config } = getAndRemoveConfig(token.text);
9191

0 commit comments

Comments
 (0)