This is an automated email from the ASF dual-hosted git repository. gerben pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-annotator.git
commit 65cafd1a460e3f1aad9df99b6f35a44456d4067e Author: Gerben <[email protected]> AuthorDate: Sat Jun 5 18:30:03 2021 +0200 Run linter --- packages/dom/src/owner-document.ts | 6 ++---- packages/dom/src/range/match.ts | 5 +++-- packages/dom/src/text-position/describe.ts | 4 ++-- packages/dom/src/text-quote/describe.ts | 2 +- packages/dom/src/to-range.ts | 4 ++-- packages/dom/test/css/describe.test.ts | 21 ++++++++++++--------- packages/dom/test/css/match-cases.ts | 13 +++---------- packages/dom/test/css/match.test.ts | 2 +- 8 files changed, 26 insertions(+), 31 deletions(-) diff --git a/packages/dom/src/owner-document.ts b/packages/dom/src/owner-document.ts index fe7818a..102a7de 100644 --- a/packages/dom/src/owner-document.ts +++ b/packages/dom/src/owner-document.ts @@ -24,13 +24,11 @@ * @param nodeOrRange the node or range for which to get the owner document. */ export function ownerDocument(nodeOrRange: Node | Range): Document { - const node = isRange(nodeOrRange) - ? nodeOrRange.startContainer - : nodeOrRange; + const node = isRange(nodeOrRange) ? nodeOrRange.startContainer : nodeOrRange; // node.ownerDocument is null iff node is itself a Document. return node.ownerDocument ?? (node as Document); } function isRange(nodeOrRange: Node | Range): nodeOrRange is Range { - return ('startContainer' in nodeOrRange); + return 'startContainer' in nodeOrRange; } diff --git a/packages/dom/src/range/match.ts b/packages/dom/src/range/match.ts index 6ffece3..d6891c6 100644 --- a/packages/dom/src/range/match.ts +++ b/packages/dom/src/range/match.ts @@ -93,8 +93,9 @@ import { cartesian } from './cartesian'; * @public */ export function makeCreateRangeSelectorMatcher( - createMatcher: <T extends Selector, TMatch extends Node | Range>(selector: T) - => Matcher<Node | Range, TMatch>, + createMatcher: <T extends Selector, TMatch extends Node | Range>( + selector: T, + ) => Matcher<Node | Range, TMatch>, ): (selector: RangeSelector) => Matcher<Node | Range, Range> { return function createRangeSelectorMatcher(selector) { const startMatcher = createMatcher(selector.startSelector); diff --git a/packages/dom/src/text-position/describe.ts b/packages/dom/src/text-position/describe.ts index 6e9566b..ce33312 100644 --- a/packages/dom/src/text-position/describe.ts +++ b/packages/dom/src/text-position/describe.ts @@ -21,8 +21,8 @@ import type { TextPositionSelector } from '@apache-annotator/selector'; import { describeTextPosition as abstractDescribeTextPosition } from '@apache-annotator/selector'; import { ownerDocument } from '../owner-document'; -import { toRange } from '../to-range'; import { TextNodeChunker } from '../text-node-chunker'; +import { toRange } from '../to-range'; /** * Returns a {@link TextPositionSelector} that points at the target text within @@ -59,7 +59,7 @@ export async function describeTextPosition( range: Range, scope?: Node | Range, ): Promise<TextPositionSelector> { - scope = toRange(scope ?? ownerDocument(range)) + scope = toRange(scope ?? ownerDocument(range)); const textChunks = new TextNodeChunker(scope); if (textChunks.currentChunk === null) diff --git a/packages/dom/src/text-quote/describe.ts b/packages/dom/src/text-quote/describe.ts index f5be4b9..727fa40 100644 --- a/packages/dom/src/text-quote/describe.ts +++ b/packages/dom/src/text-quote/describe.ts @@ -24,8 +24,8 @@ import type { } from '@apache-annotator/selector'; import { describeTextQuote as abstractDescribeTextQuote } from '@apache-annotator/selector'; import { ownerDocument } from '../owner-document'; -import { toRange } from '../to-range'; import { TextNodeChunker } from '../text-node-chunker'; +import { toRange } from '../to-range'; /** * Returns a {@link TextQuoteSelector} that unambiguously describes the given diff --git a/packages/dom/src/to-range.ts b/packages/dom/src/to-range.ts index fd62543..d4cc3d5 100644 --- a/packages/dom/src/to-range.ts +++ b/packages/dom/src/to-range.ts @@ -18,7 +18,7 @@ * under the License. */ -import { ownerDocument } from "./owner-document"; +import { ownerDocument } from './owner-document'; /** * Returns a range that exactly selects the contents of the given node. @@ -41,5 +41,5 @@ export function toRange(nodeOrRange: Node | Range): Range { } function isRange(nodeOrRange: Node | Range): nodeOrRange is Range { - return ('startContainer' in nodeOrRange); + return 'startContainer' in nodeOrRange; } diff --git a/packages/dom/test/css/describe.test.ts b/packages/dom/test/css/describe.test.ts index 17d1ce9..711c9ce 100644 --- a/packages/dom/test/css/describe.test.ts +++ b/packages/dom/test/css/describe.test.ts @@ -20,8 +20,8 @@ import { assert } from 'chai'; import { describeCss } from '../../src/css'; -import { testCases } from './match-cases'; import { evaluateXPath } from '../utils'; +import { testCases } from './match-cases'; const domParser = new DOMParser(); @@ -32,21 +32,24 @@ describe('describeCss', () => { )) { for (let i = 0; i < expected.length; i++) { const elementXPath = expected[i]; - it(`case: '${name}' (${i+1}/${expected.length})`, async () => { + it(`case: '${name}' (${i + 1}/${expected.length})`, async () => { const doc = domParser.parseFromString(html, 'text/html'); const element = evaluateXPath(doc, elementXPath) as HTMLElement; const scopeElement = scopeXPath - ? evaluateXPath(doc, scopeXPath) as HTMLElement + ? (evaluateXPath(doc, scopeXPath) as HTMLElement) : undefined; - const cssSelector = await describeCss( - element, - scopeElement, - ); + const cssSelector = await describeCss(element, scopeElement); // We do not require a specific value for the selector, just // that it uniquely matches the same element again. - const matchingElements = (scopeElement ?? doc).querySelectorAll(cssSelector.value); - assert.equal(matchingElements.length, 1, 'Expected a selector with a single match'); + const matchingElements = (scopeElement ?? doc).querySelectorAll( + cssSelector.value, + ); + assert.equal( + matchingElements.length, + 1, + 'Expected a selector with a single match', + ); assert.equal(matchingElements[0], element); }); } diff --git a/packages/dom/test/css/match-cases.ts b/packages/dom/test/css/match-cases.ts index 26fbe03..1cf28b9 100644 --- a/packages/dom/test/css/match-cases.ts +++ b/packages/dom/test/css/match-cases.ts @@ -28,7 +28,7 @@ export const testCases: { expected: string[]; }; } = { - 'simple': { + simple: { html: '<b>lorem <i>ipsum</i> dolor <i>amet</i> yada <i>yada</i></b>', selector: { type: 'CssSelector', @@ -42,11 +42,7 @@ export const testCases: { type: 'CssSelector', value: 'i', }, - expected: [ - '//b/i[1]', - '//b/i[2]', - '//b/i[3]', - ], + expected: ['//b/i[1]', '//b/i[2]', '//b/i[3]'], }, 'with scope': { html: '<b>lorem <i>ipsum</i> dolor <u><i>amet</i> yada <i>yada</i></u></b>', @@ -55,9 +51,6 @@ export const testCases: { value: 'i', }, scopeXPath: '//u', - expected: [ - '//u/i[1]', - '//u/i[2]', - ], + expected: ['//u/i[1]', '//u/i[2]'], }, }; diff --git a/packages/dom/test/css/match.test.ts b/packages/dom/test/css/match.test.ts index 2c5d682..ad39b42 100644 --- a/packages/dom/test/css/match.test.ts +++ b/packages/dom/test/css/match.test.ts @@ -21,8 +21,8 @@ import { assert } from 'chai'; import type { CssSelector } from '@apache-annotator/selector'; import { createCssSelectorMatcher } from '../../src/css'; -import { testCases } from './match-cases'; import { evaluateXPath } from '../utils'; +import { testCases } from './match-cases'; const domParser = new DOMParser();
