This is an automated email from the ASF dual-hosted git repository. gerben pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/incubator-annotator.git
commit 991ad5f98d7d1c8bc4864d24558084b8b6761c10 Author: Gerben <[email protected]> AuthorDate: Wed Jul 14 22:10:16 2021 +0200 Please linter --- .eslintrc.js | 1 - packages/dom/src/range/match.ts | 4 +-- .../dom/test/highlight-text/highlight-text.test.ts | 10 ++----- packages/dom/test/text-quote/describe.test.ts | 2 +- packages/dom/test/text-quote/match.test.ts | 2 +- packages/dom/test/utils.ts | 35 ++++++++++------------ 6 files changed, 21 insertions(+), 33 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index ec1ae7d..6bc3766 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -106,7 +106,6 @@ module.exports = { ecmaVersion: 2020, project: ['./tsconfig.test.json', './packages/*/tsconfig.json'], tsconfigRootDir: __dirname, - EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true, }, plugins: ['@typescript-eslint'], rules: { diff --git a/packages/dom/src/range/match.ts b/packages/dom/src/range/match.ts index d6891c6..8bc535d 100644 --- a/packages/dom/src/range/match.ts +++ b/packages/dom/src/range/match.ts @@ -36,7 +36,7 @@ import { cartesian } from './cartesian'; * The function is curried, taking first the `createMatcher` function, then the * selector, and then the scope. * - * As there may be multiple matches for the start & end selectors, the resulting + * As there may be multiple matches for the start & end selectors, the resulting * matcher will return an (async) iterable, that produces a match for each * possible pair of matches of the nested selectors (except those where its end * would precede its start). *(Note that this behaviour is a rather free @@ -114,7 +114,7 @@ export function makeCreateRangeSelectorMatcher( const result = ownerDocument(scope).createRange(); result.setStart(start.startContainer, start.startOffset); // Note that a RangeSelector’s match *excludes* the endSelector’s match, - // hence we take the end’s startContainer & startOffset. + // hence we take the end’s startContainer & startOffset. result.setEnd(end.startContainer, end.startOffset); if (!result.collapsed) yield result; diff --git a/packages/dom/test/highlight-text/highlight-text.test.ts b/packages/dom/test/highlight-text/highlight-text.test.ts index b194419..6b42785 100644 --- a/packages/dom/test/highlight-text/highlight-text.test.ts +++ b/packages/dom/test/highlight-text/highlight-text.test.ts @@ -188,10 +188,7 @@ describe('highlightText', () => { const doc = domParser.parseFromString(inputHtml, 'text/html'); const removeHighlights1 = highlightText(hydrateRange(range, doc)); - const removeHighlights2 = highlightText( - hydrateRange(range2, doc), - 'mark2', - ); + const removeHighlights2 = highlightText(hydrateRange(range2, doc), 'mark2'); assert.equal(doc.body.innerHTML, expectedHtml); removeHighlights1(); @@ -205,10 +202,7 @@ describe('highlightText', () => { const doc = domParser.parseFromString(inputHtml, 'text/html'); const removeHighlights1 = highlightText(hydrateRange(range, doc)); - const removeHighlights2 = highlightText( - hydrateRange(range2, doc), - 'mark2', - ); + const removeHighlights2 = highlightText(hydrateRange(range2, doc), 'mark2'); assert.equal(doc.body.innerHTML, expectedHtml); removeHighlights2(); diff --git a/packages/dom/test/text-quote/describe.test.ts b/packages/dom/test/text-quote/describe.test.ts index ac48ed2..97f21eb 100644 --- a/packages/dom/test/text-quote/describe.test.ts +++ b/packages/dom/test/text-quote/describe.test.ts @@ -119,7 +119,7 @@ describe('describeTextQuote', () => { }); it('works if range does not contain Text nodes', async () => { - const html = `<b>Try quoting this image: <img/> — would that work?</b>` + const html = `<b>Try quoting this image: <img/> — would that work?</b>`; const doc = domParser.parseFromString(html, 'text/html'); const range = document.createRange(); range.selectNode(evaluateXPath(doc, '//img')); diff --git a/packages/dom/test/text-quote/match.test.ts b/packages/dom/test/text-quote/match.test.ts index c9429a4..69d827e 100644 --- a/packages/dom/test/text-quote/match.test.ts +++ b/packages/dom/test/text-quote/match.test.ts @@ -189,7 +189,7 @@ async function testMatcher( scope: Node | Range, selector: TextQuoteSelector, expected: RangeInfo[], - mutateDom: boolean = false, + mutateDom = false, ) { const matcher = createTextQuoteSelectorMatcher(selector); let count = 0; diff --git a/packages/dom/test/utils.ts b/packages/dom/test/utils.ts index 5a3f183..a391074 100644 --- a/packages/dom/test/utils.ts +++ b/packages/dom/test/utils.ts @@ -60,10 +60,7 @@ export function hydrateRange(rangeInfo: RangeInfo, doc: Document): Range { return range; } -export function assertRangeEquals( - match: Range, - expected: RangeInfo, -) { +export function assertRangeEquals(match: Range, expected: RangeInfo): void { const doc = ownerDocument(match); if (expected === undefined) { assert.fail(`Unexpected match: ${prettyRange(match)}`); @@ -72,10 +69,7 @@ export function assertRangeEquals( doc, expected.startContainerXPath, ); - const expectedEndContainer = evaluateXPath( - doc, - expected.endContainerXPath, - ); + const expectedEndContainer = evaluateXPath(doc, expected.endContainerXPath); assert( match.startContainer === expectedStartContainer, `unexpected start container: ${prettyNodeName(match.startContainer)}; ` + @@ -83,8 +77,7 @@ export function assertRangeEquals( ); assert.equal(match.startOffset, expected.startOffset); assert( - match.endContainer === - evaluateXPath(doc, expected.endContainerXPath), + match.endContainer === evaluateXPath(doc, expected.endContainerXPath), `unexpected end container: ${prettyNodeName(match.endContainer)}; ` + `expected ${prettyNodeName(expectedEndContainer)}`, ); @@ -105,19 +98,21 @@ function prettyNodeName(node: Node) { } function prettyRange(range: Range): string { - let s = 'Range(' + let s = 'Range('; if ( - range.startContainer.nodeType === Node.TEXT_NODE - && range.startContainer.parentNode - ) s += prettyNodeName(range.startContainer.parentNode) + ' → '; - s += prettyNodeName(range.startContainer) + ' : ' + range.startOffset; + range.startContainer.nodeType === Node.TEXT_NODE && + range.startContainer.parentNode + ) + s += prettyNodeName(range.startContainer.parentNode) + ' → '; + s += prettyNodeName(range.startContainer) + `: ${range.startOffset}`; if (range.endContainer !== range.startContainer) { - s += ' … ' + s += ' … '; if ( - range.endContainer.nodeType === Node.TEXT_NODE - && range.endContainer.parentNode - && range.endContainer.parentNode !== range.startContainer.parentNode - ) s += prettyNodeName(range.endContainer.parentNode) + ' → '; + range.endContainer.nodeType === Node.TEXT_NODE && + range.endContainer.parentNode && + range.endContainer.parentNode !== range.startContainer.parentNode + ) + s += prettyNodeName(range.endContainer.parentNode) + ' → '; s += prettyNodeName(range.endContainer) + ' : '; } else { s += '…';
