refactor: Use ===

This commit is contained in:
syuilo 2020-04-04 08:46:54 +09:00
parent fef5ec874b
commit d4a630902d
39 changed files with 69 additions and 69 deletions

View file

@ -13,7 +13,7 @@ export function fromHtml(html: string, hashtagNames?: string[]): string {
return text.trim();
function getText(node: any): string {
if (node.nodeName == '#text') return node.value;
if (node.nodeName === '#text') return node.value;
if (node.childNodes) {
return node.childNodes.map((n: any) => getText(n)).join('');
@ -34,8 +34,8 @@ export function fromHtml(html: string, hashtagNames?: string[]): string {
case 'a':
const txt = getText(node);
const rel = node.attrs.find((x: any) => x.name == 'rel');
const href = node.attrs.find((x: any) => x.name == 'href');
const rel = node.attrs.find((x: any) => x.name === 'rel');
const href = node.attrs.find((x: any) => x.name === 'href');
// ハッシュタグ
if (hashtagNames && href && hashtagNames.map(x => x.toLowerCase()).includes(txt.toLowerCase())) {
@ -44,12 +44,12 @@ export function fromHtml(html: string, hashtagNames?: string[]): string {
} else if (txt.startsWith('@') && !(rel && rel.value.match(/^me /))) {
const part = txt.split('@');
if (part.length == 2) {
if (part.length === 2) {
//#region ホスト名部分が省略されているので復元する
const acct = `${txt}@${(new URL(href.value)).hostname}`;
text += acct;
//#endregion
} else if (part.length == 3) {
} else if (part.length === 3) {
text += txt;
}
// その他

View file

@ -31,7 +31,7 @@ export const mfmLanguage = P.createLanguage({
r.center,
),
startOfLine: () => P((input, i) => {
if (i == 0 || input[i] == '\n' || input[i - 1] == '\n') {
if (i === 0 || input[i] === '\n' || input[i - 1] === '\n') {
return P.makeSuccess(i, null);
} else {
return P.makeFailure(i, 'not newline');
@ -50,7 +50,7 @@ export const mfmLanguage = P.createLanguage({
if (!text.match(/^>[\s\S]+?/)) return P.makeFailure(i, 'not a quote');
const quote = takeWhile(line => line.startsWith('>'), text.split('\n'));
const qInner = quote.join('\n').replace(/^>/gm, '').replace(/^ /gm, '');
if (qInner == '') return P.makeFailure(i, 'not a quote');
if (qInner === '') return P.makeFailure(i, 'not a quote');
const contents = r.root.tryParse(qInner);
return P.makeSuccess(i + quote.join('\n').length + 1, createTree('quote', contents, {}));
})),

View file

@ -4,7 +4,7 @@ import { MfmForest, MfmTree } from './prelude';
import { createTree, createLeaf } from '../prelude/tree';
function isEmptyTextTree(t: MfmTree): boolean {
return t.node.type == 'text' && t.node.props.text === '';
return t.node.type === 'text' && t.node.props.text === '';
}
function concatTextTrees(ts: MfmForest): MfmTree {

View file

@ -3,7 +3,7 @@ import { MfmForest } from './prelude';
import { normalize } from './normalize';
export function parse(source: string | null): MfmForest | null {
if (source == null || source == '') {
if (source == null || source === '') {
return null;
}
@ -11,7 +11,7 @@ export function parse(source: string | null): MfmForest | null {
}
export function parsePlain(source: string | null): MfmForest | null {
if (source == null || source == '') {
if (source == null || source === '') {
return null;
}