From 75d5aa3a77d66c58f2566316fc9534e2d5676f25 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Sat, 24 Oct 2020 00:14:30 +0100 Subject: [PATCH] Tools: Fixed linter errors --- .../MdToHtml/rules/highlight_keywords.ts | 4 ++-- .../MdToHtml/rules/html_image.ts | 4 ++-- .../joplin-renderer/MdToHtml/rules/katex.ts | 22 +++++++++---------- .../lib/joplin-renderer/noteStyle.ts | 2 +- .../lib/joplin-renderer/pathUtils.ts | 2 +- ReactNativeClient/lib/path-utils.ts | 2 +- 6 files changed, 17 insertions(+), 19 deletions(-) diff --git a/ReactNativeClient/lib/joplin-renderer/MdToHtml/rules/highlight_keywords.ts b/ReactNativeClient/lib/joplin-renderer/MdToHtml/rules/highlight_keywords.ts index c33f46bd93..6a80d0ac49 100644 --- a/ReactNativeClient/lib/joplin-renderer/MdToHtml/rules/highlight_keywords.ts +++ b/ReactNativeClient/lib/joplin-renderer/MdToHtml/rules/highlight_keywords.ts @@ -1,6 +1,6 @@ // This plugin is used only on mobile, to highlight search results. -import { RuleOptions } from "lib/joplin-renderer/MdToHtml"; +import { RuleOptions } from 'lib/joplin-renderer/MdToHtml'; const stringUtils = require('../../stringUtils.js'); const md5 = require('md5'); @@ -67,4 +67,4 @@ function plugin(markdownIt:any, ruleOptions:RuleOptions) { export default { plugin, -} +}; diff --git a/ReactNativeClient/lib/joplin-renderer/MdToHtml/rules/html_image.ts b/ReactNativeClient/lib/joplin-renderer/MdToHtml/rules/html_image.ts index 0ebfb20f7a..4bd86be0af 100644 --- a/ReactNativeClient/lib/joplin-renderer/MdToHtml/rules/html_image.ts +++ b/ReactNativeClient/lib/joplin-renderer/MdToHtml/rules/html_image.ts @@ -1,4 +1,4 @@ -import { RuleOptions } from "lib/joplin-renderer/MdToHtml"; +import { RuleOptions } from 'lib/joplin-renderer/MdToHtml'; const htmlUtils = require('../../htmlUtils.js'); const utils = require('../../utils'); @@ -47,4 +47,4 @@ function plugin(markdownIt:any, ruleOptions:RuleOptions) { markdownIt.renderer.rules.html_inline = handleImageTags(htmlInlineDefaultRender); } -export default { plugin } +export default { plugin }; diff --git a/ReactNativeClient/lib/joplin-renderer/MdToHtml/rules/katex.ts b/ReactNativeClient/lib/joplin-renderer/MdToHtml/rules/katex.ts index 9533690b1a..223db9035d 100644 --- a/ReactNativeClient/lib/joplin-renderer/MdToHtml/rules/katex.ts +++ b/ReactNativeClient/lib/joplin-renderer/MdToHtml/rules/katex.ts @@ -1,4 +1,4 @@ -import { RuleOptions } from "lib/joplin-renderer/MdToHtml"; +import { RuleOptions } from 'lib/joplin-renderer/MdToHtml'; let katex = require('katex'); const md5 = require('md5'); @@ -43,14 +43,13 @@ function katexStyle() { // Test if potential opening or closing delimieter // Assumes that there is a "$" at state.src[pos] function isValidDelim(state:any, pos:number) { - let prevChar, - nextChar, - max = state.posMax, - can_open = true, + const max = state.posMax; + + let can_open = true, can_close = true; - prevChar = pos > 0 ? state.src.charCodeAt(pos - 1) : -1; - nextChar = pos + 1 <= max ? state.src.charCodeAt(pos + 1) : -1; + const prevChar = pos > 0 ? state.src.charCodeAt(pos - 1) : -1; + const nextChar = pos + 1 <= max ? state.src.charCodeAt(pos + 1) : -1; // Check non-whitespace conditions for opening and closing, and // check that closing delimeter isn't followed by a number @@ -68,7 +67,7 @@ function isValidDelim(state:any, pos:number) { } function math_inline(state:any, silent:boolean) { - let start, match, token, res, pos; + let match, token, res, pos; if (state.src[state.pos] !== '$') { return false; @@ -87,7 +86,7 @@ function math_inline(state:any, silent:boolean) { // This loop will assume that the first leading backtick can not // be the first character in state.src, which is known since // we have found an opening delimieter already. - start = state.pos + 1; + const start = state.pos + 1; match = start; while ((match = state.src.indexOf('$', match)) !== -1) { // Found potential $, look for escapes, pos will point to @@ -148,7 +147,6 @@ function math_block(state:any, start:number, end:number, silent:boolean) { next, lastPos, found = false, - token, pos = state.bMarks[start] + state.tShift[start], max = state.eMarks[start]; @@ -200,7 +198,7 @@ function math_block(state:any, start:number, end:number, silent:boolean) { state.line = next + 1; - token = state.push('math_block', 'math', 0); + const token = state.push('math_block', 'math', 0); token.block = true; token.content = (firstLine && firstLine.trim() ? `${firstLine}\n` : '') + state.getLines(start + 1, next, state.tShift[start], true) + (lastLine && lastLine.trim() ? lastLine : ''); token.map = [start, state.line]; @@ -233,7 +231,7 @@ export default { // https://github.com/laurent22/joplin/issues/1105 if (!options.context.userData.__katex) options.context.userData.__katex = { macros: {} }; - const katexOptions:any = {} + const katexOptions:any = {}; katexOptions.macros = options.context.userData.__katex.macros; katexOptions.trust = true; diff --git a/ReactNativeClient/lib/joplin-renderer/noteStyle.ts b/ReactNativeClient/lib/joplin-renderer/noteStyle.ts index 1171b4d501..4041b37fb0 100644 --- a/ReactNativeClient/lib/joplin-renderer/noteStyle.ts +++ b/ReactNativeClient/lib/joplin-renderer/noteStyle.ts @@ -363,4 +363,4 @@ export default function(theme:any) { `; return [css]; -}; +} diff --git a/ReactNativeClient/lib/joplin-renderer/pathUtils.ts b/ReactNativeClient/lib/joplin-renderer/pathUtils.ts index b9e33d3dd1..058b4df713 100644 --- a/ReactNativeClient/lib/joplin-renderer/pathUtils.ts +++ b/ReactNativeClient/lib/joplin-renderer/pathUtils.ts @@ -13,7 +13,7 @@ export function basename(path:string) { export function filename(path:string, includeDir:boolean = false):string { if (!path) throw new Error('Path is empty'); - let output = includeDir ? path : basename(path); + const output = includeDir ? path : basename(path); if (output.indexOf('.') < 0) return output; const splitted = output.split('.'); diff --git a/ReactNativeClient/lib/path-utils.ts b/ReactNativeClient/lib/path-utils.ts index d21ae1ce1d..dc283454e8 100644 --- a/ReactNativeClient/lib/path-utils.ts +++ b/ReactNativeClient/lib/path-utils.ts @@ -17,7 +17,7 @@ export function basename(path:string) { export function filename(path:string, includeDir:boolean = false) { if (!path) throw new Error('Path is empty'); - let output = includeDir ? path : basename(path); + const output = includeDir ? path : basename(path); if (output.indexOf('.') < 0) return output; const splitted = output.split('.');