diff --git a/.eslintrc b/.eslintrc index fa72f8e78..bd3b419ad 100644 --- a/.eslintrc +++ b/.eslintrc @@ -10,12 +10,6 @@ "files": "packages/*/test/**/*", "rules": {"func-names": "off"} }, - { - "files": ["packages/*/index.js", "packages/*/scripts/**/*.js", "test/*.js"], - "parserOptions": { - "sourceType": "script" - } - }, { "files": [ "packages/appium/support.js", @@ -27,9 +21,17 @@ } }, { - "files": ["./test/setup.js", "./**/scripts/**/*.js", "./packages/*/index.js"], + "files": [ + "./test/setup.js", + "./**/scripts/**/*.js", + "./packages/*/index.js", + "./packages/docutils/bin/appium-docs.js" + ], "rules": { "@typescript-eslint/no-var-requires": "off" + }, + "parserOptions": { + "sourceType": "script" } }, { diff --git a/packages/docutils/lib/builder/nav.ts b/packages/docutils/lib/builder/nav.ts index 6a9962d43..630e77223 100644 --- a/packages/docutils/lib/builder/nav.ts +++ b/packages/docutils/lib/builder/nav.ts @@ -75,6 +75,7 @@ export function parseNav(nav: MkDocsYmlNav): ParsedNavData[] { const queue: QueueItem[] = [{entries, keypath: ''}]; while (queue.length) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const {entries, keypath} = queue.shift()!; for (const [key, item] of entries) { if (_.isString(item)) { @@ -153,6 +154,7 @@ function getRootHeaderKeypath(headerItems: ParsedNavData[], header: string) { // these are the parts of the keypath of the first item, which will contain the header string. it // dosn't matter whether we pick the first one or any one; they will all contain the same root // keypath by definition. + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const rootHeaderKeypathParts = _.toPath(_.first(headerItems)!.keypath); // this is the keypath up to the header string, inclusive. diff --git a/packages/docutils/lib/fs.ts b/packages/docutils/lib/fs.ts index 67aa33a59..f0a164999 100644 --- a/packages/docutils/lib/fs.ts +++ b/packages/docutils/lib/fs.ts @@ -3,28 +3,26 @@ * @module */ -import findUp from 'find-up'; -import YAML from 'yaml'; -import readPkg, {NormalizedPackageJson, PackageJson} from 'read-pkg'; -import path from 'node:path'; -import {JsonValue} from 'type-fest'; import {fs} from '@appium/support'; +import findUp from 'find-up'; import * as JSON5 from 'json5'; import _ from 'lodash'; +import path from 'node:path'; import _pkgDir from 'pkg-dir'; -import {getLogger} from './logger'; +import readPkg, {NormalizedPackageJson, PackageJson} from 'read-pkg'; +import {JsonValue} from 'type-fest'; import {Application, TypeDocReader} from 'typedoc'; +import YAML from 'yaml'; import { - NAME_TYPEDOC_JSON, NAME_MKDOCS_YML, - NAME_PACKAGE_JSON, - NAME_MKDOCS, NAME_NPM, + NAME_PACKAGE_JSON, NAME_PYTHON, - NAME_MIKE, NAME_TYPEDOC, + NAME_TYPEDOC_JSON, } from './constants'; import {DocutilsError} from './error'; +import {getLogger} from './logger'; import {MkDocsYml} from './model'; const log = getLogger('fs'); diff --git a/packages/docutils/lib/logger.ts b/packages/docutils/lib/logger.ts index 8338ceceb..fd90dfc77 100644 --- a/packages/docutils/lib/logger.ts +++ b/packages/docutils/lib/logger.ts @@ -6,20 +6,19 @@ * @module */ -import figures from 'figures'; -import logSymbols from 'log-symbols'; -import chalk, {ForegroundColor, BackgroundColor} from 'chalk'; +import chalk, {type BackgroundColor, type ForegroundColor} from 'chalk'; import consola, { - logType as LogType, - ConsolaReporterLogObject, + type Consola, + type ConsolaReporterLogObject, FancyReporter, - FancyReporterOptions, - Consola, - ConsolaOptions, - LogLevel, + type FancyReporterOptions, + type LogLevel, + type logType as LogType, } from 'consola'; -import {DEFAULT_LOG_LEVEL, LogLevelMap} from './constants'; +import figures from 'figures'; import _ from 'lodash'; +import logSymbols from 'log-symbols'; +import {DEFAULT_LOG_LEVEL, LogLevelMap} from './constants'; /** * This is a reporter for `consola` which uses some extra/custom icons and colors. diff --git a/packages/docutils/lib/util.ts b/packages/docutils/lib/util.ts index b56144756..41d84265e 100644 --- a/packages/docutils/lib/util.ts +++ b/packages/docutils/lib/util.ts @@ -6,7 +6,6 @@ import _ from 'lodash'; import {SpawnOptions, spawn} from 'node:child_process'; import path from 'node:path'; -import type {SubProcess} from 'teen_process'; /** * Computes a relative path, prepending `./` @@ -26,7 +25,7 @@ export function stopwatch(id: string) { const start = Date.now(); stopwatch.cache.set(id, start); return () => { - const result = Date.now() - stopwatch.cache.get(id)!; + const result = Date.now() - (stopwatch.cache.get(id) ?? 0); stopwatch.cache.delete(id); return result; };