Add multiline-comment-style lint rule and fix violations
Enable multiline-comment-style with starred-block to require JSDoc-style block comments with content on separate lines from the opening delimiter. Auto-fix existing violations across the codebase. Fixes #5899 Co-authored-by: Daniel Imms <Tyriar@users.noreply.github.com>
This commit is contained in:
co-authored by
Daniel Imms
parent
1a67b6f4b3
commit
4ec85e67ba
@@ -43,9 +43,11 @@ export default async function load(fontFamily: string, cacheSize: number): Promi
|
||||
throw new Error('Permission to access local fonts not granted.');
|
||||
}
|
||||
} catch (err: unknown) {
|
||||
// A `TypeError` indicates the 'local-fonts'
|
||||
// permission is not yet implemented, so
|
||||
// only `throw` if this is _not_ the problem.
|
||||
/*
|
||||
* A `TypeError` indicates the 'local-fonts'
|
||||
* permission is not yet implemented, so
|
||||
* only `throw` if this is _not_ the problem.
|
||||
*/
|
||||
if (err instanceof Error && err.name !== 'TypeError') {
|
||||
throw err;
|
||||
}
|
||||
@@ -89,9 +91,11 @@ export default async function load(fontFamily: string, cacheSize: number): Promi
|
||||
|
||||
const fonts = await fontsPromise;
|
||||
for (const family of parse(fontFamily)) {
|
||||
// If we reach one of the generic font families, the font resolution
|
||||
// will end for the browser and we can't determine the specific font
|
||||
// used. Throw.
|
||||
/*
|
||||
* If we reach one of the generic font families, the font resolution
|
||||
* will end for the browser and we can't determine the specific font
|
||||
* used. Throw.
|
||||
*/
|
||||
if (genericFontFamilies.includes(family)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -88,9 +88,11 @@ class FontImpl implements IFont {
|
||||
glyphIds.push(this._font.charToGlyphIndex(char));
|
||||
}
|
||||
|
||||
// If there are no lookup groups, there's no point looking for
|
||||
// replacements. This gives us a minor performance boost for fonts with
|
||||
// no ligatures
|
||||
/*
|
||||
* If there are no lookup groups, there's no point looking for
|
||||
* replacements. This gives us a minor performance boost for fonts with
|
||||
* no ligatures
|
||||
*/
|
||||
if (this._lookupTrees.length === 0) {
|
||||
return {
|
||||
inputGlyphs: glyphIds,
|
||||
@@ -113,8 +115,10 @@ class FontImpl implements IFont {
|
||||
}
|
||||
|
||||
public findLigatureRanges(text: string): [number, number][] {
|
||||
// Short circuit the process if there are no possible ligatures in the
|
||||
// font
|
||||
/*
|
||||
* Short circuit the process if there are no possible ligatures in the
|
||||
* font
|
||||
*/
|
||||
if (this._lookupTrees.length === 0) {
|
||||
return [];
|
||||
}
|
||||
@@ -170,9 +174,11 @@ class FontImpl implements IFont {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// We don't need to do the lastGlyphIndex tracking here because
|
||||
// reverse processing isn't allowed to replace more than one
|
||||
// character at a time.
|
||||
/*
|
||||
* We don't need to do the lastGlyphIndex tracking here because
|
||||
* reverse processing isn't allowed to replace more than one
|
||||
* character at a time.
|
||||
*/
|
||||
for (let i = nextLookup.last - 1; i >= nextLookup.first; i--) {
|
||||
const result = walkTree(lookup.tree, sequence, i, i);
|
||||
if (result) {
|
||||
@@ -224,8 +230,10 @@ class FontImpl implements IFont {
|
||||
for (let j = 0; j < lookups.length; j++) {
|
||||
const lookupIndex = lookups[j];
|
||||
if (lookupIndex >= start) {
|
||||
// Update the lookup information if it's the one we're
|
||||
// storing or earlier than it.
|
||||
/*
|
||||
* Update the lookup information if it's the one we're
|
||||
* storing or earlier than it.
|
||||
*/
|
||||
if (result.index === null || lookupIndex <= result.index) {
|
||||
result.index = lookupIndex;
|
||||
|
||||
|
||||
@@ -32,9 +32,11 @@ export default function mergeTrees(trees: ILookupTree[]): ILookupTree {
|
||||
function mergeSubtree(mainTree: ILookupTree, mergeTree: ILookupTree, mergedEntries: WeakMap<ILookupTreeEntry, Set<ILookupTreeEntry>>): void {
|
||||
// Need to fix this recursively (and handle lookups)
|
||||
for (const [glyphId, value] of Object.entries(mergeTree.individual)) {
|
||||
// The main tree is guaranteed to have no overlaps between the
|
||||
// individual and range values, so if we match an invididual, there
|
||||
// must not be a range
|
||||
/*
|
||||
* The main tree is guaranteed to have no overlaps between the
|
||||
* individual and range values, so if we match an invididual, there
|
||||
* must not be a range
|
||||
*/
|
||||
if (mainTree.individual[glyphId]) {
|
||||
mergeTreeEntry(mainTree.individual[glyphId], value, mergedEntries);
|
||||
} else {
|
||||
@@ -49,13 +51,17 @@ function mergeSubtree(mainTree: ILookupTree, mergeTree: ILookupTree, mergedEntri
|
||||
|
||||
matched = true;
|
||||
|
||||
// If they overlap, we have to split the range and then
|
||||
// merge the overlap
|
||||
/*
|
||||
* If they overlap, we have to split the range and then
|
||||
* merge the overlap
|
||||
*/
|
||||
mainTree.individual[glyphId] = value;
|
||||
mergeTreeEntry(mainTree.individual[glyphId], cloneEntry(entry), mergedEntries);
|
||||
|
||||
// When there's an overlap, we also have to fix up the range
|
||||
// that we had already processed
|
||||
/*
|
||||
* When there's an overlap, we also have to fix up the range
|
||||
* that we had already processed
|
||||
*/
|
||||
mainTree.range.splice(index, 1);
|
||||
for (const glyph of overlap.second) {
|
||||
if (Array.isArray(glyph)) {
|
||||
@@ -76,9 +82,11 @@ function mergeSubtree(mainTree: ILookupTree, mergeTree: ILookupTree, mergedEntri
|
||||
}
|
||||
|
||||
for (const { range, entry } of mergeTree.range) {
|
||||
// Ranges are more complicated, because they can overlap with
|
||||
// multiple things, individual and range alike. We start by
|
||||
// eliminating ranges that are already present in another range
|
||||
/*
|
||||
* Ranges are more complicated, because they can overlap with
|
||||
* multiple things, individual and range alike. We start by
|
||||
* eliminating ranges that are already present in another range
|
||||
*/
|
||||
let remainingRanges: (number | [number, number])[] = [range];
|
||||
|
||||
for (let index = 0; index < mainTree.range.length; index++) {
|
||||
@@ -123,13 +131,17 @@ function mergeSubtree(mainTree: ILookupTree, mergeTree: ILookupTree, mergedEntri
|
||||
continue;
|
||||
}
|
||||
|
||||
// If they overlap, we have to split the range and then
|
||||
// merge the overlap
|
||||
/*
|
||||
* If they overlap, we have to split the range and then
|
||||
* merge the overlap
|
||||
*/
|
||||
mainTree.individual[remainingRange] = cloneEntry(entry);
|
||||
mergeTreeEntry(mainTree.individual[remainingRange], cloneEntry(resultEntry), mergedEntries);
|
||||
|
||||
// When there's an overlap, we also have to fix up the range
|
||||
// that we had already processed
|
||||
/*
|
||||
* When there's an overlap, we also have to fix up the range
|
||||
* that we had already processed
|
||||
*/
|
||||
mainTree.range.splice(index, 1);
|
||||
index--;
|
||||
|
||||
|
||||
@@ -18,14 +18,18 @@ export default function mergeRange(ranges: [number, number][], newRangeStart: nu
|
||||
return ranges;
|
||||
}
|
||||
if (newRangeEnd <= range[1]) {
|
||||
// Case 2: New range is either wholly contained within the
|
||||
// search range or overlaps with the front of it
|
||||
/*
|
||||
* Case 2: New range is either wholly contained within the
|
||||
* search range or overlaps with the front of it
|
||||
*/
|
||||
range[0] = Math.min(newRangeStart, range[0]);
|
||||
return ranges;
|
||||
}
|
||||
if (newRangeStart < range[1]) {
|
||||
// Case 3: New range either wholly contains the search range
|
||||
// or overlaps with the end of it
|
||||
/*
|
||||
* Case 3: New range either wholly contains the search range
|
||||
* or overlaps with the end of it
|
||||
*/
|
||||
range[0] = Math.min(newRangeStart, range[0]);
|
||||
inRange = true;
|
||||
} else {
|
||||
@@ -34,21 +38,27 @@ export default function mergeRange(ranges: [number, number][], newRangeStart: nu
|
||||
}
|
||||
} else {
|
||||
if (newRangeEnd <= range[0]) {
|
||||
// Case 5: New range extends from previous range but doesn't
|
||||
// reach the current one
|
||||
/*
|
||||
* Case 5: New range extends from previous range but doesn't
|
||||
* reach the current one
|
||||
*/
|
||||
ranges[i - 1][1] = newRangeEnd;
|
||||
return ranges;
|
||||
}
|
||||
if (newRangeEnd <= range[1]) {
|
||||
// Case 6: New range extends from prvious range into the
|
||||
// current range
|
||||
/*
|
||||
* Case 6: New range extends from prvious range into the
|
||||
* current range
|
||||
*/
|
||||
ranges[i - 1][1] = Math.max(newRangeEnd, range[1]);
|
||||
ranges.splice(i, 1);
|
||||
inRange = false;
|
||||
return ranges;
|
||||
}
|
||||
// Case 7: New range extends from previous range past the
|
||||
// end of the current range
|
||||
/*
|
||||
* Case 7: New range extends from previous range past the
|
||||
* end of the current range
|
||||
*/
|
||||
ranges.splice(i, 1);
|
||||
i--;
|
||||
}
|
||||
|
||||
@@ -72,8 +72,10 @@ export default function buildTree(table: ChainingContextualSubstitutionTable.IFo
|
||||
);
|
||||
}
|
||||
|
||||
// When we get to the end, all of the entries we've accumulated
|
||||
// should have a lookup defined
|
||||
/*
|
||||
* When we get to the end, all of the entries we've accumulated
|
||||
* should have a lookup defined
|
||||
*/
|
||||
for (const { entry, substitutions } of currentEntries) {
|
||||
entry.lookup = {
|
||||
substitutions,
|
||||
|
||||
@@ -53,8 +53,10 @@ export default function buildTree(table: ChainingContextualSubstitutionTable.IFo
|
||||
);
|
||||
}
|
||||
|
||||
// When we get to the end, all of the entries we've accumulated
|
||||
// should have a lookup defined
|
||||
/*
|
||||
* When we get to the end, all of the entries we've accumulated
|
||||
* should have a lookup defined
|
||||
*/
|
||||
for (const { entry, substitutions } of currentEntries) {
|
||||
entry.lookup = {
|
||||
substitutions,
|
||||
|
||||
@@ -57,8 +57,10 @@ export function processLookaheadPosition(
|
||||
range: []
|
||||
};
|
||||
|
||||
// All glyphs at this position share ONE entry - lookahead just needs to match,
|
||||
// all paths lead to the same result
|
||||
/*
|
||||
* All glyphs at this position share ONE entry - lookahead just needs to match,
|
||||
* all paths lead to the same result
|
||||
*/
|
||||
const sharedEntry: ILookupTreeEntry = {};
|
||||
|
||||
for (const glyph of glyphs) {
|
||||
@@ -100,8 +102,10 @@ export function processBacktrackPosition(
|
||||
range: []
|
||||
};
|
||||
|
||||
// All glyphs at this position share ONE entry - backtrack just needs to match,
|
||||
// all paths lead to the same result
|
||||
/*
|
||||
* All glyphs at this position share ONE entry - backtrack just needs to match,
|
||||
* all paths lead to the same result
|
||||
*/
|
||||
const sharedEntry: ILookupTreeEntry = {};
|
||||
|
||||
for (const glyph of glyphs) {
|
||||
|
||||
@@ -49,8 +49,10 @@ export function getIndividualSubstitutionGlyph(table: SubstitutionTable, glyphId
|
||||
switch (table.substFormat) {
|
||||
// https://docs.microsoft.com/en-us/typography/opentype/spec/gsub#11-single-substitution-format-1
|
||||
case 1:
|
||||
// TODO: determine if there's a rhyme or reason to the 16-bit
|
||||
// wraparound and if it can ever be a different number
|
||||
/*
|
||||
* TODO: determine if there's a rhyme or reason to the 16-bit
|
||||
* wraparound and if it can ever be a different number
|
||||
*/
|
||||
return (glyphId + table.deltaGlyphId) % (2 ** 16);
|
||||
// https://docs.microsoft.com/en-us/typography/opentype/spec/gsub#12-single-substitution-format-2
|
||||
case 2:
|
||||
|
||||
@@ -15,8 +15,10 @@ const enum LoadingState {
|
||||
FAILED
|
||||
}
|
||||
|
||||
// Caches 100K characters worth of ligatures. In practice this works out to
|
||||
// about 650 KB worth of cache, when a moderate number of ligatures are present.
|
||||
/*
|
||||
* Caches 100K characters worth of ligatures. In practice this works out to
|
||||
* about 650 KB worth of cache, when a moderate number of ligatures are present.
|
||||
*/
|
||||
const CACHE_SIZE = 100000;
|
||||
|
||||
/**
|
||||
@@ -46,8 +48,10 @@ export function enableLigatures(term: Terminal, fallbackLigatures: string[] = []
|
||||
|
||||
load(currentCallFontName, CACHE_SIZE)
|
||||
.then(f => {
|
||||
// Another request may have come in while we were waiting, so make
|
||||
// sure our font is still vaild.
|
||||
/*
|
||||
* Another request may have come in while we were waiting, so make
|
||||
* sure our font is still vaild.
|
||||
*/
|
||||
if (currentCallFontName === term.options.fontFamily) {
|
||||
loadingState = LoadingState.LOADED;
|
||||
font = f;
|
||||
@@ -59,8 +63,10 @@ export function enableLigatures(term: Terminal, fallbackLigatures: string[] = []
|
||||
}
|
||||
})
|
||||
.catch(e => {
|
||||
// Another request may have come in while we were waiting, so make
|
||||
// sure our font is still vaild.
|
||||
/*
|
||||
* Another request may have come in while we were waiting, so make
|
||||
* sure our font is still vaild.
|
||||
*/
|
||||
if (currentCallFontName === term.options.fontFamily) {
|
||||
loadingState = LoadingState.FAILED;
|
||||
if (term.options.logLevel === 'debug') {
|
||||
@@ -73,8 +79,10 @@ export function enableLigatures(term: Terminal, fallbackLigatures: string[] = []
|
||||
}
|
||||
|
||||
if (font && loadingState === LoadingState.LOADED) {
|
||||
// We clone the entries to avoid the internal cache of the ligature finder
|
||||
// getting messed up.
|
||||
/*
|
||||
* We clone the entries to avoid the internal cache of the ligature finder
|
||||
* getting messed up.
|
||||
*/
|
||||
return font.findLigatureRanges(text).map<[number, number]>(
|
||||
range => [range[0], range[1]]
|
||||
);
|
||||
|
||||
@@ -27,8 +27,10 @@ export default function parse(family: string): string[] {
|
||||
const families = [];
|
||||
let currentFamily = '';
|
||||
|
||||
// Work through the input character by character until there are none left.
|
||||
// This lexing and parsing in one pass.
|
||||
/*
|
||||
* Work through the input character by character until there are none left.
|
||||
* This lexing and parsing in one pass.
|
||||
*/
|
||||
while (context.offset < context.input.length) {
|
||||
const char = context.input[context.offset++];
|
||||
switch (char) {
|
||||
@@ -152,13 +154,17 @@ function parseUnicode(context: IParseContext): string {
|
||||
while (context.offset < context.input.length) {
|
||||
const char = context.input[context.offset++];
|
||||
if (/\s/.test(char)) {
|
||||
// The first whitespace character after a unicode escape indicates the end
|
||||
// of the escape and is swallowed.
|
||||
/*
|
||||
* The first whitespace character after a unicode escape indicates the end
|
||||
* of the escape and is swallowed.
|
||||
*/
|
||||
return unicodeToString(str);
|
||||
}
|
||||
if (str.length >= 6 || !/[\dA-Fa-f]/.test(char)) {
|
||||
// If the next character is not a valid hex digit or we have reached the
|
||||
// maximum of 6 digits in the escape, terminate the escape.
|
||||
/*
|
||||
* If the next character is not a valid hex digit or we have reached the
|
||||
* maximum of 6 digits in the escape, terminate the escape.
|
||||
*/
|
||||
context.offset--;
|
||||
return unicodeToString(str);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user