Created
February 4, 2026 12:35
-
-
Save bollwyvl/f177e9e8fe3c01f572e892f5698b807c to your computer and use it in GitHub Desktop.
This file has been truncated, but you can view the full file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/.prettierrc b/.prettierrc | |
| index b0a179d48c..cbcb3ee94b 100644 | |
| --- a/.prettierrc | |
| +++ b/.prettierrc | |
| @@ -1,5 +1,6 @@ | |
| { | |
| "singleQuote": true, | |
| "trailingComma": "none", | |
| - "arrowParens": "avoid" | |
| + "arrowParens": "avoid", | |
| + "printWidth": 88 | |
| } | |
| diff --git a/builder/src/build.ts b/builder/src/build.ts | |
| index e4eaa69ffb..57bc4752a2 100644 | |
| --- a/builder/src/build.ts | |
| +++ b/builder/src/build.ts | |
| @@ -109,9 +109,7 @@ export namespace Build { | |
| * | |
| * @ Returns An array of lab extension config data. | |
| */ | |
| - export function ensureAssets( | |
| - options: IEnsureOptions | |
| - ): rspack.Configuration[] { | |
| + export function ensureAssets(options: IEnsureOptions): rspack.Configuration[] { | |
| const { | |
| output, | |
| schemaOutput = output, | |
| @@ -126,15 +124,11 @@ export namespace Build { | |
| let cssImports: string[] = []; | |
| packageNames.forEach(name => { | |
| - packagePaths.push( | |
| - path.dirname(require.resolve(path.join(name, 'package.json'))) | |
| - ); | |
| + packagePaths.push(path.dirname(require.resolve(path.join(name, 'package.json')))); | |
| }); | |
| packagePaths.forEach(packagePath => { | |
| - const packageDataPath = require.resolve( | |
| - path.join(packagePath, 'package.json') | |
| - ); | |
| + const packageDataPath = require.resolve(path.join(packagePath, 'package.json')); | |
| const packageDir = path.dirname(packageDataPath); | |
| const data = fs.readJSONSync(packageDataPath); | |
| const name = data.name; | |
| @@ -152,9 +146,7 @@ export namespace Build { | |
| // Handle schemas. | |
| if (schemaDir) { | |
| - const schemas = glob.sync( | |
| - path.join(path.join(packageDir, schemaDir), '*') | |
| - ); | |
| + const schemas = glob.sync(path.join(path.join(packageDir, schemaDir), '*')); | |
| const destination = path.join(schemaOutput, 'schemas', name); | |
| // Remove the existing directory if necessary. | |
| diff --git a/builder/src/extensionConfig.ts b/builder/src/extensionConfig.ts | |
| index cc7e91a5ef..710d7c46f6 100644 | |
| --- a/builder/src/extensionConfig.ts | |
| +++ b/builder/src/extensionConfig.ts | |
| @@ -123,10 +123,7 @@ function generateConfig({ | |
| // Convert `bundled` to `import` | |
| if (sharedPackages[pkg].bundled === false) { | |
| sharedPackages[pkg].import = false; | |
| - } else if ( | |
| - sharedPackages[pkg].bundled === true && | |
| - shared[pkg]?.import === false | |
| - ) { | |
| + } else if (sharedPackages[pkg].bundled === true && shared[pkg]?.import === false) { | |
| // We can't delete a key in the merge, so we have to delete it in the source | |
| delete shared[pkg].import; | |
| } | |
| diff --git a/builder/src/webpack-plugins.ts b/builder/src/webpack-plugins.ts | |
| index 319fde4c89..84f32628e0 100644 | |
| --- a/builder/src/webpack-plugins.ts | |
| +++ b/builder/src/webpack-plugins.ts | |
| @@ -98,13 +98,7 @@ export namespace WPPlugin { | |
| dirTimestamps.set(path, IGNORE_TIME_ENTRY); | |
| } | |
| - callback( | |
| - err, | |
| - fileTimestamps, | |
| - dirTimestamps, | |
| - changedFiles, | |
| - removedFiles | |
| - ); | |
| + callback(err, fileTimestamps, dirTimestamps, changedFiles, removedFiles); | |
| }, | |
| callbackUndelayed | |
| ); | |
| @@ -167,13 +161,10 @@ export namespace WPPlugin { | |
| apply(compiler: rspack.Compiler): void { | |
| const options = this.options; | |
| - compiler.hooks.run.tap( | |
| - 'NowatchDuplicatePackageCheckerPlugin', | |
| - compiler => { | |
| - const p = new DuplicatePackageCheckerPlugin(options); | |
| - p.apply(compiler); | |
| - } | |
| - ); | |
| + compiler.hooks.run.tap('NowatchDuplicatePackageCheckerPlugin', compiler => { | |
| + const p = new DuplicatePackageCheckerPlugin(options); | |
| + p.apply(compiler); | |
| + }); | |
| } | |
| options: DuplicatePackageCheckerPlugin.Options; | |
| diff --git a/buildutils/src/bump-js-major.ts b/buildutils/src/bump-js-major.ts | |
| index fe70bac9bf..7d2d1a75b5 100644 | |
| --- a/buildutils/src/bump-js-major.ts | |
| +++ b/buildutils/src/bump-js-major.ts | |
| @@ -84,9 +84,7 @@ commander | |
| } else if (pyVersion.includes('rc')) { | |
| preId = 'rc'; | |
| } else { | |
| - throw new Error( | |
| - 'Cannot bump JS packages until we switch to prerelease mode' | |
| - ); | |
| + throw new Error('Cannot bump JS packages until we switch to prerelease mode'); | |
| } | |
| const pkgs = Array.from(toBump).join(','); | |
| let cmd = `lerna version premajor --preid=${preId} --force-publish=${pkgs} --no-push`; | |
| diff --git a/buildutils/src/ensure-package.ts b/buildutils/src/ensure-package.ts | |
| index 36c718085c..dce322a3fb 100644 | |
| --- a/buildutils/src/ensure-package.ts | |
| +++ b/buildutils/src/ensure-package.ts | |
| @@ -54,9 +54,7 @@ const ICON_CSS_CLASSES_TEMPLATE = ` | |
| * | |
| * @returns A list of changes that were made to ensure the package. | |
| */ | |
| -export async function ensurePackage( | |
| - options: IEnsurePackageOptions | |
| -): Promise<string[]> { | |
| +export async function ensurePackage(options: IEnsurePackageOptions): Promise<string[]> { | |
| const { data, pkgPath } = options; | |
| const deps: { [key: string]: string } = data.dependencies || {}; | |
| const devDeps: { [key: string]: string } = data.devDependencies || {}; | |
| @@ -71,9 +69,7 @@ export async function ensurePackage( | |
| const backwardVersions = options.backwardVersions ?? {}; | |
| const isPrivate = data.private == true; | |
| - const hasBackwardCompatibilities = Object.keys(backwardVersions).includes( | |
| - data.name | |
| - ); | |
| + const hasBackwardCompatibilities = Object.keys(backwardVersions).includes(data.name); | |
| // Verify dependencies are consistent. | |
| let promises = Object.keys(deps).map(async name => { | |
| @@ -102,8 +98,7 @@ export async function ensurePackage( | |
| backwardVersions[data.name][name] | |
| } || ${seenDeps[name]}` | |
| ); | |
| - deps[name] = | |
| - `${backwardVersions[data.name][name]} || ${seenDeps[name]}`; | |
| + deps[name] = `${backwardVersions[data.name][name]} || ${seenDeps[name]}`; | |
| } else { | |
| messages.push(`Updated dependency: ${name}@${seenDeps[name]}`); | |
| deps[name] = seenDeps[name]; | |
| @@ -195,15 +190,9 @@ export async function ensurePackage( | |
| }); | |
| // Make sure we are not importing CSS in a core package. | |
| - if ( | |
| - data.name.indexOf('example') === -1 && | |
| - data.name !== '@jupyterlab/codemirror' | |
| - ) { | |
| + if (data.name.indexOf('example') === -1 && data.name !== '@jupyterlab/codemirror') { | |
| imports.forEach(importStr => { | |
| - if ( | |
| - importStr.indexOf('.css') !== -1 && | |
| - importStr.indexOf('.raw.css') === -1 | |
| - ) { | |
| + if (importStr.indexOf('.css') !== -1 && importStr.indexOf('.raw.css') === -1) { | |
| messages.push( | |
| 'CSS imports are not allowed source files unless using `.raw.css` extension' | |
| ); | |
| @@ -244,10 +233,7 @@ export async function ensurePackage( | |
| await Promise.all(promises); | |
| if (usesTS) { | |
| - if ( | |
| - cssImports.length > 0 || | |
| - fs.existsSync(path.join(pkgPath, 'style/base.css')) | |
| - ) { | |
| + if (cssImports.length > 0 || fs.existsSync(path.join(pkgPath, 'style/base.css'))) { | |
| const funcName = 'ensurePackage'; | |
| // Template the CSS index file. | |
| @@ -409,9 +395,7 @@ export async function ensurePackage( | |
| // Ensure that the `schema` directories match what is in the `package.json` | |
| const schemaDir = data.jupyterlab && data.jupyterlab.schemaDir; | |
| - const schemas = glob.sync( | |
| - path.join(pkgPath, schemaDir || 'schema', '*.json') | |
| - ); | |
| + const schemas = glob.sync(path.join(pkgPath, schemaDir || 'schema', '*.json')); | |
| if (schemaDir && !schemas.length && pkgPath.indexOf('examples') == -1) { | |
| messages.push(`No schemas found in ${path.join(pkgPath, schemaDir)}.`); | |
| } else if (!schemaDir && schemas.length) { | |
| @@ -488,9 +472,7 @@ export async function ensurePackage( | |
| // Ensure that sideEffects are declared, and that any styles are covered | |
| if (styles.length > 0 && !isPrivate) { | |
| if (data.sideEffects === undefined) { | |
| - messages.push( | |
| - `Side effects not declared in ${pkgPath}, and styles are present.` | |
| - ); | |
| + messages.push(`Side effects not declared in ${pkgPath}, and styles are present.`); | |
| } else if (data.sideEffects === false) { | |
| messages.push(`Style files not included in sideEffects in ${pkgPath}`); | |
| } else if (data.sideEffects !== true) { | |
| @@ -536,8 +518,7 @@ export async function ensurePackage( | |
| return files; | |
| } | |
| const absolute = path.join(dirname, fpath); | |
| - if (fs.statSync(absolute).isDirectory()) | |
| - return recurseDir(absolute, files); | |
| + if (fs.statSync(absolute).isDirectory()) return recurseDir(absolute, files); | |
| else return files.push(absolute); | |
| }); | |
| return files; | |
| @@ -597,9 +578,7 @@ export async function ensurePackage( | |
| }); | |
| anySourceMatch = anySourceMatch || found; | |
| if (!found) { | |
| - missingSourceMessages.push( | |
| - `Source file ${basepath} not included in files` | |
| - ); | |
| + missingSourceMessages.push(`Source file ${basepath} not included in files`); | |
| } | |
| }); | |
| if (srcFiles.length && !anySourceMatch) { | |
| @@ -729,10 +708,7 @@ export async function ensureUiComponents( | |
| const _labiconConstructions: string[] = []; | |
| svgPaths.forEach(svgPath => { | |
| const svgName = utils.stem(svgPath); | |
| - const svgImportPath = path | |
| - .relative(iconSrcDir, svgPath) | |
| - .split(path.sep) | |
| - .join('/'); | |
| + const svgImportPath = path.relative(iconSrcDir, svgPath).split(path.sep).join('/'); | |
| const svgstrRef = utils.camelCase(svgName) + 'Svgstr'; | |
| const iconRef = utils.camelCase(svgName) + 'Icon'; | |
| @@ -763,9 +739,7 @@ export async function ensureUiComponents( | |
| HEADER_TEMPLATE + ICON_IMPORTS_TEMPLATE, | |
| { funcName, svgImportStatements, labiconConstructions } | |
| ); | |
| - messages.push( | |
| - ...(await ensureFile(iconImportsPath, iconImportsContents, false)) | |
| - ); | |
| + messages.push(...(await ensureFile(iconImportsPath, iconImportsContents, false))); | |
| /* support for deprecated icon CSS classes */ | |
| const iconCSSDir = path.join(pkgPath, 'style'); | |
| @@ -784,9 +758,7 @@ export async function ensureUiComponents( | |
| .split(path.sep) | |
| .join('/')}');` | |
| ); | |
| - _iconCSSDeclarations.push( | |
| - `.${className} {background-image: var(--${urlName})}` | |
| - ); | |
| + _iconCSSDeclarations.push(`.${className} {background-image: var(--${urlName})}`); | |
| }); | |
| // sort the statements and then join them | |
| @@ -799,9 +771,7 @@ export async function ensureUiComponents( | |
| HEADER_TEMPLATE + ICON_CSS_CLASSES_TEMPLATE, | |
| { funcName, iconCSSUrls, iconCSSDeclarations } | |
| ); | |
| - messages.push( | |
| - ...(await ensureFile(iconCSSClassesPath, iconCSSClassesContent)) | |
| - ); | |
| + messages.push(...(await ensureFile(iconCSSClassesPath, iconCSSClassesContent))); | |
| return messages; | |
| } | |
| diff --git a/buildutils/src/ensure-repo.ts b/buildutils/src/ensure-repo.ts | |
| index a9fa86b022..76ebd60d63 100644 | |
| --- a/buildutils/src/ensure-repo.ts | |
| +++ b/buildutils/src/ensure-repo.ts | |
| @@ -322,10 +322,7 @@ function ensureBranch(): string[] { | |
| const confPath = 'docs/source/conf.py'; | |
| const oldConfData = fs.readFileSync(confPath, 'utf-8'); | |
| const confTest = new RegExp('"github_version": "(.*)"'); | |
| - const newConfData = oldConfData.replace( | |
| - confTest, | |
| - `"github_version": "${target}"` | |
| - ); | |
| + const newConfData = oldConfData.replace(confTest, `"github_version": "${target}"`); | |
| if (newConfData !== oldConfData) { | |
| messages.push(`Overwriting ${confPath}`); | |
| fs.writeFileSync(confPath, newConfData, 'utf-8'); | |
| @@ -524,10 +521,7 @@ function ensureCorePackage(corePackage: any, corePaths: string[]) { | |
| coreData.forEach(data => { | |
| if (data.dependencies) { | |
| Object.entries(data.dependencies).forEach(([dep, version]) => { | |
| - if ( | |
| - singletonPackages.includes(dep) && | |
| - !(dep in corePackage.resolutions) | |
| - ) { | |
| + if (singletonPackages.includes(dep) && !(dep in corePackage.resolutions)) { | |
| corePackage.resolutions[dep] = version; | |
| } | |
| }); | |
| diff --git a/buildutils/src/local-repository.ts b/buildutils/src/local-repository.ts | |
| index 4e37a784d9..9a14392048 100644 | |
| --- a/buildutils/src/local-repository.ts | |
| +++ b/buildutils/src/local-repository.ts | |
| @@ -34,11 +34,7 @@ async function startLocalRegistry(out_dir: string, port = DEFAULT_PORT) { | |
| let prev_npm = utils.run('npm config get registry', { stdio: 'pipe' }, true); | |
| let prev_jlpm = ''; | |
| try { | |
| - prev_jlpm = utils.run( | |
| - 'jlpm config get npmRegistryServer', | |
| - { stdio: 'pipe' }, | |
| - true | |
| - ); | |
| + prev_jlpm = utils.run('jlpm config get npmRegistryServer', { stdio: 'pipe' }, true); | |
| } catch (e) { | |
| // Do nothing | |
| } | |
| @@ -142,12 +138,7 @@ packages: | |
| // Set registry to local registry | |
| const local_registry = `http://0.0.0.0:${port}`; | |
| - child_process.execFileSync('npm', [ | |
| - 'config', | |
| - 'set', | |
| - 'registry', | |
| - local_registry | |
| - ]); | |
| + child_process.execFileSync('npm', ['config', 'set', 'registry', local_registry]); | |
| try { | |
| child_process.execFileSync('jlpm', [ | |
| 'config', | |
| @@ -255,9 +246,7 @@ async function stopLocalRegistry(out_dir: string) { | |
| child_process.execSync(`npm config rm registry`); | |
| } | |
| if (data.prev_jlpm) { | |
| - child_process.execSync( | |
| - `jlpm config set npmRegistryServer ${data.prev_jlpm}` | |
| - ); | |
| + child_process.execSync(`jlpm config set npmRegistryServer ${data.prev_jlpm}`); | |
| child_process.execSync(`jlpm config unset unsafeHttpWhitelist`); | |
| } else { | |
| try { | |
| diff --git a/buildutils/src/update-dependency.ts b/buildutils/src/update-dependency.ts | |
| index 7441cd1601..f8ea12f360 100755 | |
| --- a/buildutils/src/update-dependency.ts | |
| +++ b/buildutils/src/update-dependency.ts | |
| @@ -30,18 +30,14 @@ const SEMVER_RANGE = /^(~|\^|=|<|>|<=|>=)?([\w\-.]*)$/; | |
| * is either a semver range indicator (one of `~, ^, >, <, =, >=, <=`), or is | |
| * not given (in which case the current specifier range prefix is used). | |
| */ | |
| -async function getSpecifier( | |
| - currentSpecifier: string, | |
| - suggestedSpecifier: string | |
| -) { | |
| +async function getSpecifier(currentSpecifier: string, suggestedSpecifier: string) { | |
| if (semver.validRange(suggestedSpecifier)) { | |
| return suggestedSpecifier; | |
| } | |
| // The suggested specifier is not a valid range, so we assume it | |
| // references a tag | |
| - let [, suggestedSigil, suggestedTag] = | |
| - suggestedSpecifier.match(SEMVER_RANGE) ?? []; | |
| + let [, suggestedSigil, suggestedTag] = suggestedSpecifier.match(SEMVER_RANGE) ?? []; | |
| if (!suggestedTag) { | |
| throw Error(`Invalid version specifier: ${suggestedSpecifier}`); | |
| @@ -62,9 +58,7 @@ async function getSpecifier( | |
| const match = currentSpecifier.match(SEMVER_RANGE); | |
| if (match === null) { | |
| - throw Error( | |
| - `Current version range is not recognized: ${currentSpecifier}` | |
| - ); | |
| + throw Error(`Current version range is not recognized: ${currentSpecifier}`); | |
| } | |
| suggestedSigil = [...alternativeSpecifiers, match[1]].join(' || '); | |
| } | |
| @@ -83,9 +77,7 @@ async function getIndividualVersion(pkg: string, specifier: string) { | |
| const { version } = await packageJson(pkg, { version: match[2] }); | |
| specifier = `${match[1] ?? ''}${version}`; | |
| if (semver.validRange(specifier) === null) { | |
| - throw Error( | |
| - `Could not find valid version range for ${pkg}: ${specifier}` | |
| - ); | |
| + throw Error(`Could not find valid version range for ${pkg}: ${specifier}`); | |
| } | |
| } | |
| return specifier; | |
| @@ -183,12 +175,7 @@ async function handlePackage( | |
| if (typeof name === 'string') { | |
| const dep = name; | |
| if (dep in deps) { | |
| - const { updated, log } = await handleDependency( | |
| - deps, | |
| - dep, | |
| - specifier, | |
| - minimal | |
| - ); | |
| + const { updated, log } = await handleDependency(deps, dep, specifier, minimal); | |
| if (updated) { | |
| fileUpdated = true; | |
| } | |
| @@ -235,23 +222,21 @@ commander | |
| .option('--path <path>', 'Path to package or monorepo to update') | |
| .option('--minimal', 'only update if the change is substantial') | |
| .arguments('<package> [versionspec]') | |
| - .action( | |
| - async (name: string | RegExp, version: string = '^latest', args: any) => { | |
| - const basePath = path.resolve(args.path || '.'); | |
| - const pkg = args.regex ? new RegExp(name) : name; | |
| - | |
| - if (args.lerna) { | |
| - const paths = utils.getLernaPaths(basePath).sort(); | |
| - | |
| - // We use a loop instead of Promise.all so that the output is in | |
| - // alphabetical order. | |
| - for (const pkgPath of paths) { | |
| - await handlePackage(pkg, version, pkgPath, args.dryRun, args.minimal); | |
| - } | |
| + .action(async (name: string | RegExp, version: string = '^latest', args: any) => { | |
| + const basePath = path.resolve(args.path || '.'); | |
| + const pkg = args.regex ? new RegExp(name) : name; | |
| + | |
| + if (args.lerna) { | |
| + const paths = utils.getLernaPaths(basePath).sort(); | |
| + | |
| + // We use a loop instead of Promise.all so that the output is in | |
| + // alphabetical order. | |
| + for (const pkgPath of paths) { | |
| + await handlePackage(pkg, version, pkgPath, args.dryRun, args.minimal); | |
| } | |
| - await handlePackage(pkg, version, basePath, args.dryRun, args.minimal); | |
| } | |
| - ); | |
| + await handlePackage(pkg, version, basePath, args.dryRun, args.minimal); | |
| + }); | |
| commander.on('--help', function () { | |
| console.debug(` | |
| diff --git a/buildutils/src/update-staging-lock.ts b/buildutils/src/update-staging-lock.ts | |
| index 7a227175b1..4371bb3248 100644 | |
| --- a/buildutils/src/update-staging-lock.ts | |
| +++ b/buildutils/src/update-staging-lock.ts | |
| @@ -139,9 +139,7 @@ function upgradeSelectedPackages( | |
| function extractNameFromDescriptor(name: string): string { | |
| const descriptor = structUtils.parseDescriptor(name.split(',')[0].trim()); | |
| - return descriptor.scope | |
| - ? `@${descriptor.scope}/${descriptor.name}` | |
| - : descriptor.name; | |
| + return descriptor.scope ? `@${descriptor.scope}/${descriptor.name}` : descriptor.name; | |
| } | |
| function loadPackages(lockFile: string): Record<string, YarnEntry> { | |
| diff --git a/buildutils/src/utils.ts b/buildutils/src/utils.ts | |
| index d6b14fb232..68fa8b5d57 100644 | |
| --- a/buildutils/src/utils.ts | |
| +++ b/buildutils/src/utils.ts | |
| @@ -48,9 +48,7 @@ export function getLernaPaths(basePath = '.'): string[] { | |
| } | |
| } catch (e) { | |
| if (e.code === 'MODULE_NOT_FOUND') { | |
| - throw new Error( | |
| - `No yarn workspace / lerna package list found in ${basePath}` | |
| - ); | |
| + throw new Error(`No yarn workspace / lerna package list found in ${basePath}`); | |
| } | |
| throw e; | |
| } | |
| @@ -74,9 +72,7 @@ export function getCorePaths(): string[] { | |
| // Git versioned only files - so we check for package.json | |
| // to ensure a package really exists and is not a ghost from | |
| // another branch | |
| - .filter(packagePath => | |
| - fs.existsSync(path.join(packagePath, 'package.json')) | |
| - ) | |
| + .filter(packagePath => fs.existsSync(path.join(packagePath, 'package.json'))) | |
| ); | |
| } | |
| @@ -89,10 +85,7 @@ export function getCorePaths(): string[] { | |
| * | |
| * @returns Whether the file has changed. | |
| */ | |
| -export function writePackageData( | |
| - pkgJsonPath: string, | |
| - data: Record<any, any> | |
| -): boolean { | |
| +export function writePackageData(pkgJsonPath: string, data: Record<any, any>): boolean { | |
| const text = JSON.stringify(sortPackageJson(data), null, 2) + '\n'; | |
| const orig = fs.readFileSync(pkgJsonPath, 'utf8').split('\r\n').join('\n'); | |
| if (text !== orig) { | |
| @@ -116,10 +109,7 @@ export function readJSONFile(filePath: string): any { | |
| /** | |
| * Write a json file. | |
| */ | |
| -export function writeJSONFile( | |
| - filePath: string, | |
| - data: Record<any, any> | |
| -): boolean { | |
| +export function writeJSONFile(filePath: string, data: Record<any, any>): boolean { | |
| function sortObjByKey(value: any): any { | |
| // https://stackoverflow.com/a/35810961 | |
| return typeof value === 'object' | |
| @@ -177,8 +167,7 @@ export function fromTemplate( | |
| options: { autoindent?: boolean; end?: string } = {} | |
| ): string { | |
| // default options values | |
| - const autoindent = | |
| - options.autoindent === undefined ? true : options.autoindent; | |
| + const autoindent = options.autoindent === undefined ? true : options.autoindent; | |
| const end = options.end === undefined ? '\n' : options.end; | |
| Object.keys(subs).forEach(key => { | |
| @@ -222,9 +211,7 @@ export function getPythonVersion(): string { | |
| * Get the current version of a package | |
| */ | |
| export function getJSVersion(pkg: string): string { | |
| - const filePath = path.resolve( | |
| - path.join('.', 'packages', pkg, 'package.json') | |
| - ); | |
| + const filePath = path.resolve(path.join('.', 'packages', pkg, 'package.json')); | |
| const data = readJSONFile(filePath); | |
| return data.version; | |
| } | |
| diff --git a/dev_mode/bootstrap.js b/dev_mode/bootstrap.js | |
| index 5a44157bd4..82e34bb1aa 100644 | |
| --- a/dev_mode/bootstrap.js | |
| +++ b/dev_mode/bootstrap.js | |
| @@ -76,10 +76,7 @@ void (async function bootstrap() { | |
| let labExtensionUrl = getOption('fullLabextensionsUrl'); | |
| const extensions = await Promise.allSettled( | |
| extension_data.map(async data => { | |
| - await loadComponent( | |
| - `${labExtensionUrl}/${data.name}/${data.load}`, | |
| - data.name | |
| - ); | |
| + await loadComponent(`${labExtensionUrl}/${data.name}/${data.load}`, data.name); | |
| }) | |
| ); | |
| diff --git a/dev_mode/webpack.config.js b/dev_mode/webpack.config.js | |
| index 9814fbaadc..377ca19871 100644 | |
| --- a/dev_mode/webpack.config.js | |
| +++ b/dev_mode/webpack.config.js | |
| @@ -12,8 +12,7 @@ const Handlebars = require('handlebars'); | |
| const HtmlWebpackPlugin = require('html-webpack-plugin'); | |
| const rspack = require('@rspack/core'); | |
| const merge = require('webpack-merge').default; | |
| -const BundleAnalyzerPlugin = | |
| - require('webpack-bundle-analyzer').BundleAnalyzerPlugin; | |
| +const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; | |
| const baseConfig = require('@jupyterlab/builder/lib/webpack.config.base'); | |
| const { ModuleFederationPlugin } = rspack.container; | |
| @@ -61,10 +60,7 @@ fs.copySync('./bootstrap.js', entryPoint); | |
| fs.copySync('./package.json', path.join(buildDir, 'package.json')); | |
| if (outputDir !== buildDir) { | |
| - fs.copySync( | |
| - path.join(outputDir, 'style.js'), | |
| - path.join(buildDir, 'style.js') | |
| - ); | |
| + fs.copySync(path.join(outputDir, 'style.js'), path.join(buildDir, 'style.js')); | |
| } | |
| // Set up variables for the watch mode ignore plugins | |
| @@ -250,9 +246,7 @@ const plugins = [ | |
| verbose: true, | |
| exclude(instance) { | |
| // ignore known duplicates | |
| - return ['domelementtype', 'hash-base', 'inherits'].includes( | |
| - instance.name | |
| - ); | |
| + return ['domelementtype', 'hash-base', 'inherits'].includes(instance.name); | |
| } | |
| }), | |
| new HtmlWebpackPlugin({ | |
| diff --git a/dev_mode/webpack.prod.config.js b/dev_mode/webpack.prod.config.js | |
| index 025b532242..56350089a1 100644 | |
| --- a/dev_mode/webpack.prod.config.js | |
| +++ b/dev_mode/webpack.prod.config.js | |
| @@ -20,8 +20,7 @@ config[0] = merge(config[0], { | |
| }, | |
| plugins: [ | |
| new WPPlugin.JSONLicenseWebpackPlugin({ | |
| - excludedPackageTest: packageName => | |
| - packageName === '@jupyterlab/application-top' | |
| + excludedPackageTest: packageName => packageName === '@jupyterlab/application-top' | |
| }) | |
| ] | |
| }); | |
| diff --git a/dev_mode/webpack.prod.minimize.config.js b/dev_mode/webpack.prod.minimize.config.js | |
| index f0af63f0ca..cc87634a06 100644 | |
| --- a/dev_mode/webpack.prod.minimize.config.js | |
| +++ b/dev_mode/webpack.prod.minimize.config.js | |
| @@ -20,8 +20,7 @@ config[0] = merge(config[0], { | |
| }, | |
| plugins: [ | |
| new WPPlugin.JSONLicenseWebpackPlugin({ | |
| - excludedPackageTest: packageName => | |
| - packageName === '@jupyterlab/application-top' | |
| + excludedPackageTest: packageName => packageName === '@jupyterlab/application-top' | |
| }) | |
| ] | |
| }); | |
| diff --git a/docs/source/developer/patterns.md b/docs/source/developer/patterns.md | |
| index b7449da671..824dd14444 100644 | |
| --- a/docs/source/developer/patterns.md | |
| +++ b/docs/source/developer/patterns.md | |
| @@ -94,17 +94,13 @@ We use Promises for asynchronous function calls, and a shim for browsers that do | |
| To allow hot-swapping the Jupyter Server in custom applications based of JupyterLab components, the request URL should be composed using the base URL from the {ts:interface}`services.ServerConnection.ISettings` instance derived from the service manager, passed down via class constructors as needed. The {ts:function}`coreutils.PageConfig.getBaseUrl` should not be used directly. The following snippets demonstrate the best practice: | |
| ```typescript | |
| -import { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { ServerConnection } from '@jupyterlab/services'; | |
| import { URLExt } from '@jupyterlab/coreutils'; | |
| export class MyAPIClient { | |
| constructor(options: MyAPIClient.IOptions = {}) { | |
| - this._serverSettings = | |
| - options.serverSettings ?? ServerConnection.makeSettings(); | |
| + this._serverSettings = options.serverSettings ?? ServerConnection.makeSettings(); | |
| } | |
| get apiURL() { | |
| // If URL needs to be exposed, use a getter to allow hot-swapping | |
| @@ -113,11 +109,7 @@ export class MyAPIClient { | |
| } | |
| async fetch() { | |
| const { makeRequest } = ServerConnection; | |
| - const response: Response = await makeRequest( | |
| - this.apiURL, | |
| - {}, | |
| - this._serverSettings | |
| - ); | |
| + const response: Response = await makeRequest(this.apiURL, {}, this._serverSettings); | |
| // Do something with the response | |
| console.log(response); | |
| diff --git a/docs/source/extension/extension_dev.md b/docs/source/extension/extension_dev.md | |
| index 07a7a9d760..272413af06 100644 | |
| --- a/docs/source/extension/extension_dev.md | |
| +++ b/docs/source/extension/extension_dev.md | |
| @@ -246,10 +246,7 @@ import { | |
| } from '@jupyterlab/services'; | |
| class CustomContents extends ContentsManager { | |
| - async get( | |
| - path: string, | |
| - options?: Contents.IFetchOptions | |
| - ): Promise<Contents.IModel> { | |
| + async get(path: string, options?: Contents.IFetchOptions): Promise<Contents.IModel> { | |
| console.log('CustomContents.get', path); | |
| return super.get(path, options); | |
| } | |
| diff --git a/docs/source/extension/extension_points.md b/docs/source/extension/extension_points.md | |
| index fc740899f0..97d1d6bc56 100644 | |
| --- a/docs/source/extension/extension_points.md | |
| +++ b/docs/source/extension/extension_points.md | |
| @@ -253,10 +253,7 @@ browser supports overriding the behavior of this item. | |
| ```typescript | |
| import { IFileBrowserFactory } from '@jupyterlab/filebrowser'; | |
| -import { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| const shareFile: JupyterFrontEndPlugin<void> = { | |
| activate: activateShareFile, | |
| @@ -265,10 +262,7 @@ const shareFile: JupyterFrontEndPlugin<void> = { | |
| autoStart: true | |
| }; | |
| -function activateShareFile( | |
| - app: JupyterFrontEnd, | |
| - factory: IFileBrowserFactory | |
| -): void { | |
| +function activateShareFile(app: JupyterFrontEnd, factory: IFileBrowserFactory): void { | |
| const { commands } = app; | |
| const { tracker } = factory; | |
| @@ -913,10 +907,7 @@ class MyProvider implements ICompletionProvider { | |
| return true; | |
| } | |
| - async fetch( | |
| - request: CompletionHandler.IRequest, | |
| - context: ICompletionContext | |
| - ) { | |
| + async fetch(request: CompletionHandler.IRequest, context: ICompletionContext) { | |
| return { | |
| start: request.offset, | |
| end: request.offset, | |
| @@ -929,10 +920,7 @@ const plugin: JupyterFrontEndPlugin<void> = { | |
| id: 'my-completer-extension:provider', | |
| autoStart: true, | |
| requires: [ICompletionProviderManager], | |
| - activate: ( | |
| - app: JupyterFrontEnd, | |
| - manager: ICompletionProviderManager | |
| - ): void => { | |
| + activate: (app: JupyterFrontEnd, manager: ICompletionProviderManager): void => { | |
| const provider = new MyProvider(); | |
| manager.registerProvider(provider); | |
| } | |
| @@ -967,10 +955,7 @@ class MyInlineProvider implements IInlineCompletionProvider { | |
| readonly identifier = 'my-provider'; | |
| readonly name = 'My provider'; | |
| - async fetch( | |
| - request: CompletionHandler.IRequest, | |
| - context: IInlineCompletionContext | |
| - ) { | |
| + async fetch(request: CompletionHandler.IRequest, context: IInlineCompletionContext) { | |
| return { | |
| items: [{ insertText: 'suggestion 1' }, { insertText: 'suggestion 2' }] | |
| }; | |
| @@ -981,10 +966,7 @@ const plugin: JupyterFrontEndPlugin<void> = { | |
| id: 'my-completer-extension:inline-provider', | |
| autoStart: true, | |
| requires: [ICompletionProviderManager], | |
| - activate: ( | |
| - app: JupyterFrontEnd, | |
| - manager: ICompletionProviderManager | |
| - ): void => { | |
| + activate: (app: JupyterFrontEnd, manager: ICompletionProviderManager): void => { | |
| const provider = new MyInlineProvider(); | |
| manager.registerInlineProvider(provider); | |
| } | |
| @@ -1172,9 +1154,7 @@ const renamePlugin: JupyterFrontEndPlugin<void> = { | |
| const ext = EditorView.domEventHandlers({ | |
| dblclick: (e, view) => { | |
| const range = ceEditor.getSelection(); | |
| - const res = connection.clientRequests[ | |
| - 'textDocument/rename' | |
| - ].request({ | |
| + const res = connection.clientRequests['textDocument/rename'].request({ | |
| newName: 'test', | |
| position: { | |
| line: range.start.line, | |
| @@ -1256,11 +1236,7 @@ const customDrivePlugin: JupyterFrontEndPlugin<void> = { | |
| To use a content provider, first register it on a drive (or multiple drives): | |
| ```typescript | |
| -import { | |
| - Contents, | |
| - ContentsManager, | |
| - RestContentProvider | |
| -} from '@jupyterlab/services'; | |
| +import { Contents, ContentsManager, RestContentProvider } from '@jupyterlab/services'; | |
| interface IMyContentChunk { | |
| /** URL allowing to fetch the content chunk */ | |
| @@ -1323,10 +1299,7 @@ const customContentProviderPlugin: JupyterFrontEndPlugin<void> = { | |
| and then create and register a widget factory which will understand how to make use of your custom content provider: | |
| ```typescript | |
| -class ExampleWidgetFactory extends ABCWidgetFactory< | |
| - ExampleDocWidget, | |
| - ExampleDocModel | |
| -> { | |
| +class ExampleWidgetFactory extends ABCWidgetFactory<ExampleDocWidget, ExampleDocModel> { | |
| protected createNewWidget( | |
| context: DocumentRegistry.IContext<ExampleDocModel> | |
| ): ExampleDocWidget { | |
| diff --git a/docs/source/extension/notebook.md b/docs/source/extension/notebook.md | |
| index 47873b9262..f90e267ca0 100644 | |
| --- a/docs/source/extension/notebook.md | |
| +++ b/docs/source/extension/notebook.md | |
| @@ -252,10 +252,7 @@ import { IDisposable, DisposableDelegate } from '@lumino/disposable'; | |
| import { Widget } from '@lumino/widgets'; | |
| -import { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { DocumentRegistry } from '@jupyterlab/docregistry'; | |
| diff --git a/docs/source/user/workspaces.md b/docs/source/user/workspaces.md | |
| index a37f3640a2..58d865d62d 100644 | |
| --- a/docs/source/user/workspaces.md | |
| +++ b/docs/source/user/workspaces.md | |
| @@ -104,8 +104,7 @@ void restorer.restore(tracker, { | |
| path: widget.context.path, | |
| factory: Private.factoryNameProperty.get(widget) | |
| }), | |
| - name: widget => | |
| - `${widget.context.path}:${Private.factoryNameProperty.get(widget)}` | |
| + name: widget => `${widget.context.path}:${Private.factoryNameProperty.get(widget)}` | |
| }); | |
| ``` | |
| diff --git a/docs/typedoc-custom.css b/docs/typedoc-custom.css | |
| index 71b3d2eeaf..229dca147c 100644 | |
| --- a/docs/typedoc-custom.css | |
| +++ b/docs/typedoc-custom.css | |
| @@ -24,8 +24,8 @@ header.tsd-page-toolbar .title { | |
| --favicon-size: 16px; | |
| } | |
| #tsd-toolbar-links a[href='https://jupyter.org'] { | |
| - background: url(../../_static/jupyter_logo.svg) left center / | |
| - var(--favicon-size) no-repeat; | |
| + background: url(../../_static/jupyter_logo.svg) left center / var(--favicon-size) | |
| + no-repeat; | |
| color: transparent; | |
| font-size: 0; | |
| min-width: var(--favicon-size); | |
| diff --git a/examples/cell/src/index.ts b/examples/cell/src/index.ts | |
| index 4d9290c850..1f063a38f2 100644 | |
| --- a/examples/cell/src/index.ts | |
| +++ b/examples/cell/src/index.ts | |
| @@ -46,11 +46,7 @@ import { | |
| RenderMimeRegistry | |
| } from '@jupyterlab/rendermime'; | |
| -import { | |
| - KernelManager, | |
| - KernelSpecManager, | |
| - SessionManager | |
| -} from '@jupyterlab/services'; | |
| +import { KernelManager, KernelSpecManager, SessionManager } from '@jupyterlab/services'; | |
| import type { IYText } from '@jupyter/ydoc'; | |
| @@ -139,9 +135,7 @@ function main(): void { | |
| const lang = info.language_info; | |
| const mimeTypes = mimeService.getMimeTypeByLanguage(lang); | |
| const mimeType = | |
| - Array.isArray(mimeTypes) && mimeTypes.length !== 0 | |
| - ? mimeTypes[0] | |
| - : mimeTypes; | |
| + Array.isArray(mimeTypes) && mimeTypes.length !== 0 ? mimeTypes[0] : mimeTypes; | |
| cellWidget.model.mimeType = mimeType; | |
| }); | |
| }); | |
| @@ -203,10 +197,7 @@ function main(): void { | |
| tooltip: 'Restart the kernel' | |
| }) | |
| ); | |
| - toolbar.addItem( | |
| - 'name', | |
| - AppToolbar.createKernelNameItem(sessionContext, dialogs) | |
| - ); | |
| + toolbar.addItem('name', AppToolbar.createKernelNameItem(sessionContext, dialogs)); | |
| toolbar.addItem('status', AppToolbar.createKernelStatusItem(sessionContext)); | |
| // Lay out the widgets. | |
| diff --git a/examples/federated/core_package/bootstrap.js b/examples/federated/core_package/bootstrap.js | |
| index 7b2029755b..e5f6a79f37 100644 | |
| --- a/examples/federated/core_package/bootstrap.js | |
| +++ b/examples/federated/core_package/bootstrap.js | |
| @@ -76,10 +76,7 @@ void (async function bootstrap() { | |
| let labExtensionUrl = getOption('fullLabextensionsUrl'); | |
| const extensions = await Promise.allSettled( | |
| extension_data.map(async data => { | |
| - await loadComponent( | |
| - `${labExtensionUrl}/${data.name}/${data.load}`, | |
| - data.name | |
| - ); | |
| + await loadComponent(`${labExtensionUrl}/${data.name}/${data.load}`, data.name); | |
| }) | |
| ); | |
| diff --git a/examples/federated/core_package/rspack.config.js b/examples/federated/core_package/rspack.config.js | |
| index a69638800c..954598e868 100644 | |
| --- a/examples/federated/core_package/rspack.config.js | |
| +++ b/examples/federated/core_package/rspack.config.js | |
| @@ -56,9 +56,7 @@ const extensionAssetConfig = Build.ensureAssets({ | |
| }); | |
| // Create the entry point and other assets in build directory. | |
| -const template = Handlebars.compile( | |
| - fs.readFileSync('index.template.js').toString() | |
| -); | |
| +const template = Handlebars.compile(fs.readFileSync('index.template.js').toString()); | |
| fs.writeFileSync( | |
| path.join(buildDir, 'index.js'), | |
| template({ extensions, mimeExtensions }) | |
| @@ -97,10 +95,9 @@ function createShared(packageData) { | |
| const extraShared = []; | |
| for (let pkg of extensionPackages) { | |
| let pkgShared = {}; | |
| - let { | |
| - dependencies = {}, | |
| - jupyterlab: { sharedPackages = {} } = {} | |
| - } = require(`${pkg}/package.json`); | |
| + let { dependencies = {}, jupyterlab: { sharedPackages = {} } = {} } = require( | |
| + `${pkg}/package.json` | |
| + ); | |
| for (let [dep, requiredVersion] of Object.entries(dependencies)) { | |
| if (!shared[dep]) { | |
| pkgShared[dep] = { requiredVersion }; | |
| diff --git a/examples/federated/md_package/index.js b/examples/federated/md_package/index.js | |
| index 65fd9480ce..aebcc9a75e 100644 | |
| --- a/examples/federated/md_package/index.js | |
| +++ b/examples/federated/md_package/index.js | |
| @@ -8,10 +8,7 @@ import { | |
| MarkdownViewer, | |
| MarkdownViewerFactory | |
| } from '@jupyterlab/markdownviewer'; | |
| -import { | |
| - IRenderMimeRegistry, | |
| - markdownRendererFactory | |
| -} from '@jupyterlab/rendermime'; | |
| +import { IRenderMimeRegistry, markdownRendererFactory } from '@jupyterlab/rendermime'; | |
| import { ISettingRegistry } from '@jupyterlab/settingregistry'; | |
| import { PathExt } from '@jupyterlab/coreutils'; | |
| import { IMiddleToken } from '@jupyterlab/example-federated-middle'; | |
| @@ -35,12 +32,7 @@ const plugin = { | |
| activate, | |
| id: '@jupyterlab/example-federated-md:plugin', | |
| provides: IMarkdownViewerTracker, | |
| - requires: [ | |
| - ILayoutRestorer, | |
| - IRenderMimeRegistry, | |
| - ISettingRegistry, | |
| - IMiddleToken | |
| - ], | |
| + requires: [ILayoutRestorer, IRenderMimeRegistry, ISettingRegistry, IMiddleToken], | |
| autoStart: true | |
| }; | |
| /** | |
| @@ -61,10 +53,7 @@ function activate(app, restorer, rendermime, settingRegistry, middleToken) { | |
| function updateWidget(widget) { | |
| Object.keys(config).forEach(k => { | |
| let _a; | |
| - widget.setOption( | |
| - k, | |
| - (_a = config[k]) !== null && _a !== void 0 ? _a : null | |
| - ); | |
| + widget.setOption(k, (_a = config[k]) !== null && _a !== void 0 ? _a : null); | |
| }); | |
| } | |
| /** | |
| @@ -143,9 +132,7 @@ function activate(app, restorer, rendermime, settingRegistry, middleToken) { | |
| }, | |
| isVisible: () => { | |
| const widget = tracker.currentWidget; | |
| - return ( | |
| - (widget && PathExt.extname(widget.context.path) === '.md') || false | |
| - ); | |
| + return (widget && PathExt.extname(widget.context.path) === '.md') || false; | |
| }, | |
| label: 'Show Markdown Editor' | |
| }); | |
| diff --git a/examples/filebrowser/src/index.ts b/examples/filebrowser/src/index.ts | |
| index 1067876898..ccf867f382 100644 | |
| --- a/examples/filebrowser/src/index.ts | |
| +++ b/examples/filebrowser/src/index.ts | |
| @@ -50,10 +50,7 @@ async function main(): Promise<void> { | |
| }); | |
| } | |
| -function createApp( | |
| - manager: ServiceManager.IManager, | |
| - translator?: ITranslator | |
| -): void { | |
| +function createApp(manager: ServiceManager.IManager, translator?: ITranslator): void { | |
| translator = translator || nullTranslator; | |
| const trans = translator.load('jupyterlab'); | |
| diff --git a/examples/notebook/src/commands.ts b/examples/notebook/src/commands.ts | |
| index 6ae60396cf..4825b8eb47 100644 | |
| --- a/examples/notebook/src/commands.ts | |
| +++ b/examples/notebook/src/commands.ts | |
| @@ -8,10 +8,7 @@ | |
| */ | |
| import type { ISessionContextDialogs } from '@jupyterlab/apputils'; | |
| import type { CompletionHandler } from '@jupyterlab/completer'; | |
| -import { | |
| - SearchDocumentModel, | |
| - SearchDocumentView | |
| -} from '@jupyterlab/documentsearch'; | |
| +import { SearchDocumentModel, SearchDocumentView } from '@jupyterlab/documentsearch'; | |
| import type { NotebookPanel } from '@jupyterlab/notebook'; | |
| import { NotebookActions, NotebookSearchProvider } from '@jupyterlab/notebook'; | |
| import type { ISettingRegistry } from '@jupyterlab/settingregistry'; | |
| @@ -182,20 +179,17 @@ export const setupCommands = ( | |
| label: args => (args.toolbar ? '' : 'Interrupt'), | |
| caption: 'Interrupt the kernel', | |
| icon: args => (args.toolbar ? stopIcon : undefined), | |
| - execute: async () => | |
| - nbWidget.context.sessionContext.session?.kernel?.interrupt() | |
| + execute: async () => nbWidget.context.sessionContext.session?.kernel?.interrupt() | |
| }); | |
| commands.addCommand(COMMAND_IDS.restart, { | |
| label: args => (args.toolbar ? '' : 'Restart Kernel'), | |
| caption: 'Restart the kernel', | |
| icon: args => (args.toolbar ? refreshIcon : undefined), | |
| - execute: () => | |
| - sessionContextDialogs.restart(nbWidget.context.sessionContext) | |
| + execute: () => sessionContextDialogs.restart(nbWidget.context.sessionContext) | |
| }); | |
| commands.addCommand(COMMAND_IDS.switchKernel, { | |
| label: 'Switch Kernel', | |
| - execute: () => | |
| - sessionContextDialogs.selectKernel(nbWidget.context.sessionContext) | |
| + execute: () => sessionContextDialogs.selectKernel(nbWidget.context.sessionContext) | |
| }); | |
| commands.addCommand(COMMAND_IDS.runAndAdvance, { | |
| label: args => (args.toolbar ? '' : 'Run and Advance'), | |
| @@ -331,18 +325,16 @@ export const setupCommands = ( | |
| caption: 'Restart the kernl, then re-run the whole notebook', | |
| icon: args => (args.toolbar ? fastForwardIcon : undefined), | |
| execute: () => { | |
| - void sessionContextDialogs | |
| - .restart(nbWidget.sessionContext) | |
| - .then(restarted => { | |
| - if (restarted) { | |
| - void NotebookActions.runAll( | |
| - nbWidget.content, | |
| - nbWidget.sessionContext, | |
| - sessionContextDialogs | |
| - ); | |
| - } | |
| - return restarted; | |
| - }); | |
| + void sessionContextDialogs.restart(nbWidget.sessionContext).then(restarted => { | |
| + if (restarted) { | |
| + void NotebookActions.runAll( | |
| + nbWidget.content, | |
| + nbWidget.sessionContext, | |
| + sessionContextDialogs | |
| + ); | |
| + } | |
| + return restarted; | |
| + }); | |
| } | |
| }); | |
| diff --git a/examples/notebook/src/index.ts b/examples/notebook/src/index.ts | |
| index 15f8dd4d59..4b29ccc78b 100644 | |
| --- a/examples/notebook/src/index.ts | |
| +++ b/examples/notebook/src/index.ts | |
| @@ -220,8 +220,7 @@ function createApp(manager: ServiceManager.IManager): void { | |
| const palette = new CommandPalette({ commands }); | |
| palette.addClass('notebookCommandPalette'); | |
| - const editor = | |
| - nbWidget.content.activeCell && nbWidget.content.activeCell.editor; | |
| + const editor = nbWidget.content.activeCell && nbWidget.content.activeCell.editor; | |
| const model = new CompleterModel(); | |
| const completer = new Completer({ editor, model }); | |
| const sessionContext = nbWidget.context.sessionContext; | |
| diff --git a/galata/README.md b/galata/README.md | |
| index ce4f3f1477..87c1a1c96c 100644 | |
| --- a/galata/README.md | |
| +++ b/galata/README.md | |
| @@ -45,9 +45,7 @@ test.describe('Notebook Tests', () => { | |
| await page.waitForSelector(`[role="main"] >> text=${fileName}`) | |
| ).toBeTruthy(); | |
| - expect(await page.contents.fileExists(`${tmpPath}/${fileName}`)).toEqual( | |
| - true | |
| - ); | |
| + expect(await page.contents.fileExists(`${tmpPath}/${fileName}`)).toEqual(true); | |
| }); | |
| }); | |
| ``` | |
| @@ -258,12 +256,9 @@ You can add a listener that will be triggered when a JupyterLab dialog is shown: | |
| ```typescript | |
| await page.evaluate(() => { | |
| - window.galata.on( | |
| - 'notification', | |
| - (notification: Notification.INotification) => { | |
| - // Use the notification | |
| - } | |
| - ); | |
| + window.galata.on('notification', (notification: Notification.INotification) => { | |
| + // Use the notification | |
| + }); | |
| }); | |
| ``` | |
| diff --git a/galata/extension/src/global.ts b/galata/extension/src/global.ts | |
| index 77f160d759..e2bac75798 100644 | |
| --- a/galata/extension/src/global.ts | |
| +++ b/galata/extension/src/global.ts | |
| @@ -111,10 +111,7 @@ export class GalataInpage implements IGalataInpage { | |
| this.listeners.delete(listener); | |
| }) | |
| .catch(reason => { | |
| - console.log( | |
| - `Failed to disconnect listener for '${event}' event.`, | |
| - reason | |
| - ); | |
| + console.log(`Failed to disconnect listener for '${event}' event.`, reason); | |
| }); | |
| } | |
| } | |
| @@ -169,9 +166,7 @@ export class GalataInpage implements IGalataInpage { | |
| } | |
| }) | |
| .catch(reason => { | |
| - console.error( | |
| - `Failed to add listener to JupyterLab dialog event:\n${reason}` | |
| - ); | |
| + console.error(`Failed to add listener to JupyterLab dialog event:\n${reason}`); | |
| }); | |
| } | |
| @@ -424,8 +419,7 @@ export class GalataInpage implements IGalataInpage { | |
| } | |
| } | |
| } else if (nb.model.cells.get(cellIndex)?.type === 'code') { | |
| - (nb.model.cells.get(cellIndex) as CodeCellModel).executionCount = | |
| - null; | |
| + (nb.model.cells.get(cellIndex) as CodeCellModel).executionCount = null; | |
| } | |
| } | |
| } | |
| @@ -614,9 +608,7 @@ export class GalataInpage implements IGalataInpage { | |
| * | |
| * @param callback Callback | |
| */ | |
| - async runActiveNotebookCellByCell( | |
| - callback?: INotebookRunCallback | |
| - ): Promise<void> { | |
| + async runActiveNotebookCellByCell(callback?: INotebookRunCallback): Promise<void> { | |
| const nbPanel = this._app.shell.currentWidget as NotebookPanel; | |
| const notebook = nbPanel.content; | |
| if (!notebook.widgets) { | |
| diff --git a/galata/extension/src/index.ts b/galata/extension/src/index.ts | |
| index bf6eabc20a..f076b8b88e 100644 | |
| --- a/galata/extension/src/index.ts | |
| +++ b/galata/extension/src/index.ts | |
| @@ -1,10 +1,7 @@ | |
| // Copyright (c) Jupyter Development Team. | |
| // Distributed under the terms of the Modified BSD License. | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { Dialog, Notification } from '@jupyterlab/apputils'; | |
| import { GalataInpage } from './global'; | |
| import type { IGalataHelpers } from './tokens'; | |
| diff --git a/galata/playwright-benchmark.config.js b/galata/playwright-benchmark.config.js | |
| index 2565a93fc1..91433d329d 100644 | |
| --- a/galata/playwright-benchmark.config.js | |
| +++ b/galata/playwright-benchmark.config.js | |
| @@ -13,10 +13,7 @@ module.exports = { | |
| ], | |
| reporter: [ | |
| [process.env.CI ? 'dot' : 'list'], | |
| - [ | |
| - '@jupyterlab/galata/lib/benchmarkReporter', | |
| - { outputFile: 'lab-benchmark.json' } | |
| - ] | |
| + ['@jupyterlab/galata/lib/benchmarkReporter', { outputFile: 'lab-benchmark.json' }] | |
| ], | |
| use: { | |
| ...baseConfig.use, | |
| diff --git a/galata/src/benchmarkReporter.ts b/galata/src/benchmarkReporter.ts | |
| index aaf0661df7..60fe76fdee 100644 | |
| --- a/galata/src/benchmarkReporter.ts | |
| +++ b/galata/src/benchmarkReporter.ts | |
| @@ -347,14 +347,12 @@ class BenchmarkReporter implements Reporter { | |
| this._expectedReference = | |
| process.env['BENCHMARK_EXPECTED_REFERENCE'] ?? | |
| benchmark.DEFAULT_EXPECTED_REFERENCE; | |
| - this._reference = | |
| - process.env['BENCHMARK_REFERENCE'] ?? benchmark.DEFAULT_REFERENCE; | |
| + this._reference = process.env['BENCHMARK_REFERENCE'] ?? benchmark.DEFAULT_REFERENCE; | |
| this._buildVegaLiteGraph = | |
| options.vegaLiteConfigFactory ?? this.defaultVegaLiteConfigFactory; | |
| - this._buildTextReport = | |
| - options.textReportFactory ?? this.defaultTextReportFactory; | |
| + this._buildTextReport = options.textReportFactory ?? this.defaultTextReportFactory; | |
| } | |
| /** | |
| @@ -463,10 +461,7 @@ class BenchmarkReporter implements Reporter { | |
| // - Create report | |
| const [reportContentString, reportExtension] = | |
| await this._buildTextReport(allData); | |
| - const reportFile = path.resolve( | |
| - outputDir, | |
| - `${baseName}.${reportExtension}` | |
| - ); | |
| + const reportFile = path.resolve(outputDir, `${baseName}.${reportExtension}`); | |
| fs.writeFileSync(reportFile, reportContentString, 'utf-8'); | |
| // Generate graph file and image | |
| @@ -506,17 +501,11 @@ class BenchmarkReporter implements Reporter { | |
| // - Groupby (test, browser, reference | project, file) | |
| const reportExtension = 'md'; | |
| - const groups = new Map< | |
| - string, | |
| - Map<string, Map<string, Map<string, number[]>>> | |
| - >(); | |
| + const groups = new Map<string, Map<string, Map<string, Map<string, number[]>>>>(); | |
| allData.forEach(d => { | |
| if (!groups.has(d.test)) { | |
| - groups.set( | |
| - d.test, | |
| - new Map<string, Map<string, Map<string, number[]>>>() | |
| - ); | |
| + groups.set(d.test, new Map<string, Map<string, Map<string, number[]>>>()); | |
| } | |
| const testGroup = groups.get(d.test)!; | |
| diff --git a/galata/src/benchmarkVLTpl.ts b/galata/src/benchmarkVLTpl.ts | |
| index 2e2b8c9b2b..327ad1ba38 100644 | |
| --- a/galata/src/benchmarkVLTpl.ts | |
| +++ b/galata/src/benchmarkVLTpl.ts | |
| @@ -23,10 +23,7 @@ const GENERAL_CONFIG = { | |
| * @param comparison Field name to compare | |
| * @returns The specification | |
| */ | |
| -function configPerFile( | |
| - tests: string[], | |
| - comparison: string | |
| -): Record<string, any> { | |
| +function configPerFile(tests: string[], comparison: string): Record<string, any> { | |
| return { | |
| vconcat: tests.map(t => { | |
| return { | |
| diff --git a/galata/src/contents.ts b/galata/src/contents.ts | |
| index ad7294e430..74575886f8 100644 | |
| --- a/galata/src/contents.ts | |
| +++ b/galata/src/contents.ts | |
| @@ -185,10 +185,7 @@ export class ContentsHelper { | |
| data | |
| }); | |
| } catch (error) { | |
| - console.error( | |
| - `Failed to upload content to server ${destinationPath}`, | |
| - error | |
| - ); | |
| + console.error(`Failed to upload content to server ${destinationPath}`, error); | |
| } | |
| const succeeded = response?.status() === 201; | |
| @@ -209,10 +206,7 @@ export class ContentsHelper { | |
| * @param destinationPath Destination filepath | |
| * @returns Whether the action succeeded or not. | |
| */ | |
| - async uploadFile( | |
| - sourcePath: string, | |
| - destinationPath?: string | |
| - ): Promise<boolean> { | |
| + async uploadFile(sourcePath: string, destinationPath?: string): Promise<boolean> { | |
| return this.uploadContent( | |
| Utils.base64EncodeFile(sourcePath), | |
| 'base64', | |
| diff --git a/galata/src/fixtures.ts b/galata/src/fixtures.ts | |
| index 82b94e061f..7a6e94ca35 100644 | |
| --- a/galata/src/fixtures.ts | |
| +++ b/galata/src/fixtures.ts | |
| @@ -298,11 +298,7 @@ export const test: TestType< | |
| await use(terminals); | |
| if (terminals.size > 0) { | |
| - await galata.Mock.clearRunners( | |
| - request, | |
| - [...terminals.keys()], | |
| - 'terminals' | |
| - ); | |
| + await galata.Mock.clearRunners(request, [...terminals.keys()], 'terminals'); | |
| } | |
| }, | |
| /** | |
| @@ -313,9 +309,7 @@ export const test: TestType< | |
| */ | |
| tmpPath: async ({ request, serverFiles }, use, testInfo) => { | |
| // Remove appended retry part for reproducibility | |
| - const testFolder = path | |
| - .basename(testInfo.outputDir) | |
| - .replace(/-retry\d+$/i, ''); | |
| + const testFolder = path.basename(testInfo.outputDir).replace(/-retry\d+$/i, ''); | |
| const contents = new ContentsHelper(request); | |
| @@ -345,10 +339,7 @@ export const test: TestType< | |
| * @param helpers JupyterLab helpers | |
| */ | |
| waitForApplication: async ({ baseURL }, use) => { | |
| - const waitIsReady = async ( | |
| - page: Page, | |
| - helpers: IJupyterLabPage | |
| - ): Promise<void> => { | |
| + const waitIsReady = async (page: Page, helpers: IJupyterLabPage): Promise<void> => { | |
| await page.locator('#jupyterlab-splash').waitFor({ state: 'detached' }); | |
| await helpers.waitForCondition(() => { | |
| return helpers.activity.isTabActive('Launcher'); | |
| diff --git a/galata/src/galata.ts b/galata/src/galata.ts | |
| index 6e96f410d4..932c214f00 100644 | |
| --- a/galata/src/galata.ts | |
| +++ b/galata/src/galata.ts | |
| @@ -189,12 +189,7 @@ export namespace galata { | |
| waitForApplication: (page: Page, helpers: IJupyterLabPage) => Promise<void>, | |
| appPath?: string | |
| ): IJupyterLabPageFixture { | |
| - const jlabPage = new JupyterLabPage( | |
| - page, | |
| - baseURL, | |
| - waitForApplication, | |
| - appPath | |
| - ); | |
| + const jlabPage = new JupyterLabPage(page, baseURL, waitForApplication, appPath); | |
| const handler = { | |
| get: function (obj: JupyterLabPage, prop: string) { | |
| @@ -224,12 +219,7 @@ export namespace galata { | |
| kernels?: Map<string, Kernel.IModel> | null | |
| ): Promise<IJupyterLabPageFixture> { | |
| // Hook the helpers | |
| - const jlabWithPage = addHelpersToPage( | |
| - page, | |
| - baseURL, | |
| - waitForApplication, | |
| - appPath | |
| - ); | |
| + const jlabWithPage = addHelpersToPage(page, baseURL, waitForApplication, appPath); | |
| // Add server mocks | |
| if (mockConfig) { | |
| @@ -354,9 +344,7 @@ export namespace galata { | |
| const kernels = mockKernels ? new Map<string, Kernel.IModel>() : null; | |
| const sessions = mockSessions ? new Map<string, Session.IModel>() : null; | |
| - const terminals = mockTerminals | |
| - ? new Map<string, TerminalAPI.IModel>() | |
| - : null; | |
| + const terminals = mockTerminals ? new Map<string, TerminalAPI.IModel>() : null; | |
| return { | |
| page: await initTestPage( | |
| @@ -504,11 +492,7 @@ export namespace galata { | |
| const cells = new Array<nbformat.ICell>(); | |
| for (let i = 0; i < nCells; i++) { | |
| const execution_count = | |
| - cellType === 'code' | |
| - ? defaultOutput.length > 0 | |
| - ? i + 1 | |
| - : null | |
| - : undefined; | |
| + cellType === 'code' ? (defaultOutput.length > 0 ? i + 1 : null) : undefined; | |
| const cell = makeCell({ | |
| cell_type: cellType, | |
| source: [...defaultInput], | |
| @@ -527,9 +511,7 @@ export namespace galata { | |
| * @param skeleton Cell description template | |
| * @returns A cell | |
| */ | |
| - export function makeCell( | |
| - skeleton: Partial<nbformat.ICell> | |
| - ): nbformat.ICell { | |
| + export function makeCell(skeleton: Partial<nbformat.ICell>): nbformat.ICell { | |
| switch (skeleton.cell_type ?? 'code') { | |
| case 'code': | |
| return { | |
| @@ -632,10 +614,7 @@ export namespace galata { | |
| } | |
| const data = await response.json(); | |
| // Modify the last_modified values to be set one day before now. | |
| - if ( | |
| - data['type'] === 'directory' && | |
| - Array.isArray(data['content']) | |
| - ) { | |
| + if (data['type'] === 'directory' && Array.isArray(data['content'])) { | |
| if (filter) { | |
| data['content'] = filter(data['content']); | |
| } | |
| @@ -749,8 +728,7 @@ export namespace galata { | |
| config: Record<string, JSONObject> | |
| ): Promise<void> { | |
| return page.route(Routes.config, (route, request) => { | |
| - const section = Routes.config.exec(request.url())?.groups | |
| - ?.section as string; | |
| + const section = Routes.config.exec(request.url())?.groups?.section as string; | |
| switch (request.method()) { | |
| case 'GET': | |
| return route.fulfill({ | |
| @@ -785,10 +763,7 @@ export namespace galata { | |
| * @param page Page model object | |
| * @param customCSS Custom CSS content | |
| */ | |
| - export function mockCustomCSS( | |
| - page: Page, | |
| - customCSS: string | |
| - ): Promise<void> { | |
| + export function mockCustomCSS(page: Page, customCSS: string): Promise<void> { | |
| return page.route(Routes.customCSS, async (route, request) => { | |
| switch (request.method()) { | |
| case 'GET': | |
| @@ -898,8 +873,7 @@ export namespace galata { | |
| const data = (await response.json()) as any[]; | |
| const updated = new Set<string>(); | |
| data.forEach(item => { | |
| - const itemID: string = | |
| - type === 'terminals' ? item.name : item.id; | |
| + const itemID: string = type === 'terminals' ? item.name : item.id; | |
| if (runners.has(itemID)) { | |
| updated.add(itemID); | |
| runners.set(itemID, item); | |
| @@ -1131,9 +1105,7 @@ export namespace galata { | |
| try { | |
| pluginSettings.settings = json5.parse(pluginSettings.raw); | |
| } catch (e) { | |
| - console.warn( | |
| - `Failed to read raw settings ${pluginSettings.raw}` | |
| - ); | |
| + console.warn(`Failed to read raw settings ${pluginSettings.raw}`); | |
| pluginSettings.settings = {}; | |
| } | |
| } else { | |
| diff --git a/galata/src/helpers/activity.ts b/galata/src/helpers/activity.ts | |
| index b13d121b85..dc0cf8c1d3 100644 | |
| --- a/galata/src/helpers/activity.ts | |
| +++ b/galata/src/helpers/activity.ts | |
| @@ -159,9 +159,7 @@ export class ActivityHelper { | |
| if (!id) { | |
| return null; | |
| } | |
| - locator = this.page | |
| - .getByRole('main') | |
| - .locator(`[role="tabpanel"][id="${id}"]`); | |
| + locator = this.page.getByRole('main').locator(`[role="tabpanel"][id="${id}"]`); | |
| } | |
| return locator; | |
| diff --git a/galata/src/helpers/debuggerpanel.ts b/galata/src/helpers/debuggerpanel.ts | |
| index f17f5c7c56..d10b60116b 100644 | |
| --- a/galata/src/helpers/debuggerpanel.ts | |
| +++ b/galata/src/helpers/debuggerpanel.ts | |
| @@ -44,10 +44,7 @@ export class DebuggerHelper { | |
| } | |
| const button = toolbar.locator('.jp-DebuggerBugButton'); | |
| await waitForCondition(async () => (await button.count()) === 1); | |
| - await waitForCondition( | |
| - async () => (await button!.isDisabled()) === false, | |
| - 2000 | |
| - ); | |
| + await waitForCondition(async () => (await button!.isDisabled()) === false, 2000); | |
| if (!(await this.isOn(name))) { | |
| await button!.click(); | |
| @@ -105,10 +102,7 @@ export class DebuggerHelper { | |
| * Waits for variables to be populated in the variables panel | |
| */ | |
| async waitForVariables(): Promise<void> { | |
| - await this.page | |
| - .locator('.jp-DebuggerVariables-body') | |
| - .getByRole('tree') | |
| - .waitFor(); | |
| + await this.page.locator('.jp-DebuggerVariables-body').getByRole('tree').waitFor(); | |
| } | |
| /** | |
| diff --git a/galata/src/helpers/filebrowser.ts b/galata/src/helpers/filebrowser.ts | |
| index 30e87febf5..2c79bad21d 100644 | |
| --- a/galata/src/helpers/filebrowser.ts | |
| +++ b/galata/src/helpers/filebrowser.ts | |
| @@ -111,13 +111,8 @@ export class FileBrowserHelper { | |
| if (await fileItem.count()) { | |
| if (factory) { | |
| await fileItem.click({ button: 'right' }); | |
| - await this.page | |
| - .getByRole('listitem') | |
| - .filter({ hasText: 'Open With' }) | |
| - .click(); | |
| - await this.page | |
| - .getByRole('menuitem', { name: factory, exact: true }) | |
| - .click(); | |
| + await this.page.getByRole('listitem').filter({ hasText: 'Open With' }).click(); | |
| + await this.page.getByRole('menuitem', { name: factory, exact: true }).click(); | |
| } else { | |
| await fileItem.dblclick(); | |
| } | |
| @@ -211,9 +206,7 @@ export class FileBrowserHelper { | |
| const page = this.page; | |
| const button = page | |
| .locator('#filebrowser') | |
| - .locator( | |
| - '.jp-ToolbarButtonComponent[data-command="filebrowser:refresh"]' | |
| - ); | |
| + .locator('.jp-ToolbarButtonComponent[data-command="filebrowser:refresh"]'); | |
| // Use Promise.race to manage the network response timeout | |
| // This is useful for lab-based applications not using the Jupyter Server Contents API. | |
| diff --git a/galata/src/helpers/menu.ts b/galata/src/helpers/menu.ts | |
| index 6ab1bc6254..90859c4d62 100644 | |
| --- a/galata/src/helpers/menu.ts | |
| +++ b/galata/src/helpers/menu.ts | |
| @@ -46,9 +46,7 @@ export class MenuHelper { | |
| * @returns Locator to the menu | |
| */ | |
| getMenuBarItemLocator(label: string): Locator { | |
| - return this.page.locator( | |
| - `li:has(div.lm-MenuBar-itemLabel:text-is("${label}"))` | |
| - ); | |
| + return this.page.locator(`li:has(div.lm-MenuBar-itemLabel:text-is("${label}"))`); | |
| } | |
| /** | |
| @@ -59,9 +57,7 @@ export class MenuHelper { | |
| * | |
| * @deprecated You should use locator instead {@link openContextMenuLocator} | |
| */ | |
| - async openContextMenu( | |
| - selector: string | |
| - ): Promise<ElementHandle<Element> | null> { | |
| + async openContextMenu(selector: string): Promise<ElementHandle<Element> | null> { | |
| return (await this.openContextMenuLocator(selector)).elementHandle(); | |
| } | |
| @@ -235,15 +231,12 @@ export class MenuHelper { | |
| subMenu = page.locator('.lm-Menu.lm-MenuBar-menu'); | |
| await subMenu.waitFor({ state: 'visible' }); | |
| } else { | |
| - const expectedMenusCount = | |
| - (await page.locator('.lm-Menu').count()) + 1; | |
| + const expectedMenusCount = (await page.locator('.lm-Menu').count()) + 1; | |
| await menuItem.hover(); | |
| await Utils.waitForCondition(async () => { | |
| return ( | |
| (await page.locator('.lm-Menu').count()) === expectedMenusCount && | |
| - (await Utils.getLocatorClassList(menuItem)).includes( | |
| - 'lm-mod-active' | |
| - ) | |
| + (await Utils.getLocatorClassList(menuItem)).includes('lm-mod-active') | |
| ); | |
| }); | |
| await page.waitForTimeout(200); | |
| diff --git a/galata/src/helpers/notebook.ts b/galata/src/helpers/notebook.ts | |
| index 9c31956023..7fc828679c 100644 | |
| --- a/galata/src/helpers/notebook.ts | |
| +++ b/galata/src/helpers/notebook.ts | |
| @@ -101,12 +101,8 @@ export class NotebookHelper { | |
| * | |
| * @deprecated You should use locator instead {@link getNotebookInPanelLocator} | |
| */ | |
| - async getNotebookInPanel( | |
| - name?: string | |
| - ): Promise<ElementHandle<Element> | null> { | |
| - return ( | |
| - (await this.getNotebookInPanelLocator(name))?.elementHandle() ?? null | |
| - ); | |
| + async getNotebookInPanel(name?: string): Promise<ElementHandle<Element> | null> { | |
| + return (await this.getNotebookInPanelLocator(name))?.elementHandle() ?? null; | |
| } | |
| /** | |
| @@ -147,9 +143,8 @@ export class NotebookHelper { | |
| */ | |
| async getToolbarLocator(name?: string): Promise<Locator | null> { | |
| return ( | |
| - (await this.activity.getPanelLocator(name)) | |
| - ?.locator('.jp-Toolbar') | |
| - .first() ?? null | |
| + (await this.activity.getPanelLocator(name))?.locator('.jp-Toolbar').first() ?? | |
| + null | |
| ); | |
| } | |
| @@ -214,9 +209,7 @@ export class NotebookHelper { | |
| notebookName?: string | |
| ): Promise<ElementHandle<Element> | null> { | |
| return ( | |
| - ( | |
| - await this.getToolbarItemLocator(itemId, notebookName) | |
| - )?.elementHandle() ?? null | |
| + (await this.getToolbarItemLocator(itemId, notebookName))?.elementHandle() ?? null | |
| ); | |
| } | |
| @@ -370,23 +363,17 @@ export class NotebookHelper { | |
| if (callback) { | |
| callbackName = `_runCallbacksExposed${++this._runCallbacksExposed}`; | |
| - await this.page.exposeFunction( | |
| - `${callbackName}_onBeforeScroll`, | |
| - async () => { | |
| - if (callback && callback.onBeforeScroll) { | |
| - await callback.onBeforeScroll(); | |
| - } | |
| + await this.page.exposeFunction(`${callbackName}_onBeforeScroll`, async () => { | |
| + if (callback && callback.onBeforeScroll) { | |
| + await callback.onBeforeScroll(); | |
| } | |
| - ); | |
| + }); | |
| - await this.page.exposeFunction( | |
| - `${callbackName}_onAfterScroll`, | |
| - async () => { | |
| - if (callback && callback.onAfterScroll) { | |
| - await callback.onAfterScroll(); | |
| - } | |
| + await this.page.exposeFunction(`${callbackName}_onAfterScroll`, async () => { | |
| + if (callback && callback.onAfterScroll) { | |
| + await callback.onAfterScroll(); | |
| } | |
| - ); | |
| + }); | |
| await this.page.exposeFunction( | |
| `${callbackName}_onAfterCellRun`, | |
| @@ -412,9 +399,7 @@ export class NotebookHelper { | |
| }, | |
| onAfterCellRun: async (cellIndex: number) => { | |
| - await (window as any)[`${callbackName}_onAfterCellRun`]( | |
| - cellIndex | |
| - ); | |
| + await (window as any)[`${callbackName}_onAfterCellRun`](cellIndex); | |
| } | |
| } as INotebookRunCallback); | |
| @@ -432,9 +417,7 @@ export class NotebookHelper { | |
| async trust(): Promise<boolean> { | |
| if ( | |
| (await this.isAnyActive()) && | |
| - (await this.page | |
| - .locator('[data-icon="ui-components:not-trusted"]') | |
| - .count()) === 1 | |
| + (await this.page.locator('[data-icon="ui-components:not-trusted"]').count()) === 1 | |
| ) { | |
| await this.page.keyboard.press('Control+Shift+C'); | |
| await this.page.getByPlaceholder('SEARCH', { exact: true }).fill('trust'); | |
| @@ -442,9 +425,7 @@ export class NotebookHelper { | |
| await this.page.getByRole('button', { name: 'Trust' }).click(); | |
| return ( | |
| - (await this.page | |
| - .locator('[data-icon="ui-components:trusted"]') | |
| - .count()) === 1 | |
| + (await this.page.locator('[data-icon="ui-components:trusted"]').count()) === 1 | |
| ); | |
| } | |
| @@ -532,8 +513,7 @@ export class NotebookHelper { | |
| // Scroll to bottom | |
| let previousScrollHeight = scrollTop; | |
| let scrollHeight = | |
| - previousScrollHeight + | |
| - (await scroller.evaluate(node => node.clientHeight)); | |
| + previousScrollHeight + (await scroller.evaluate(node => node.clientHeight)); | |
| do { | |
| await scroller.evaluate((node, scrollTarget) => { | |
| node.scrollTo({ top: scrollTarget }); | |
| @@ -546,10 +526,8 @@ export class NotebookHelper { | |
| } while (scrollHeight > previousScrollHeight); | |
| const lastCell = notebook.locator('div.jp-Cell').last(); | |
| const count = | |
| - parseInt( | |
| - (await lastCell.getAttribute('data-windowed-list-index')) ?? '0', | |
| - 10 | |
| - ) + 1; | |
| + parseInt((await lastCell.getAttribute('data-windowed-list-index')) ?? '0', 10) + | |
| + 1; | |
| // Scroll back to original position | |
| await scroller.evaluate((node, scrollTarget) => { | |
| @@ -634,9 +612,7 @@ export class NotebookHelper { | |
| } | |
| if (firstIndex <= cellIndex && cellIndex <= lastIndex) { | |
| - return notebook.locator( | |
| - `.jp-Cell[data-windowed-list-index="${cellIndex}"]` | |
| - ); | |
| + return notebook.locator(`.jp-Cell[data-windowed-list-index="${cellIndex}"]`); | |
| } else { | |
| return null; | |
| } | |
| @@ -650,9 +626,7 @@ export class NotebookHelper { | |
| * | |
| * @deprecated You should use locator instead {@link getCellInputLocator} | |
| */ | |
| - async getCellInput( | |
| - cellIndex: number | |
| - ): Promise<ElementHandle<Element> | null> { | |
| + async getCellInput(cellIndex: number): Promise<ElementHandle<Element> | null> { | |
| return (await this.getCellInputLocator(cellIndex))?.elementHandle() ?? null; | |
| } | |
| @@ -673,9 +647,9 @@ export class NotebookHelper { | |
| return null; | |
| } | |
| - const isRenderedMarkdown = ( | |
| - await Utils.getLocatorClassList(cellEditor) | |
| - ).includes('lm-mod-hidden'); | |
| + const isRenderedMarkdown = (await Utils.getLocatorClassList(cellEditor)).includes( | |
| + 'lm-mod-hidden' | |
| + ); | |
| if (isRenderedMarkdown) { | |
| return cell.locator('.jp-MarkdownOutput'); | |
| @@ -707,9 +681,7 @@ export class NotebookHelper { | |
| } catch { | |
| // Firefox does not support clipboard-read but does not it it either | |
| } | |
| - const handle = await this.page.evaluateHandle(() => | |
| - navigator.clipboard.readText() | |
| - ); | |
| + const handle = await this.page.evaluateHandle(() => navigator.clipboard.readText()); | |
| if (!wasInEditingMode) { | |
| await this.leaveCellEditingMode(cellIndex); | |
| } | |
| @@ -727,10 +699,7 @@ export class NotebookHelper { | |
| async getCellInputExpander( | |
| cellIndex: number | |
| ): Promise<ElementHandle<Element> | null> { | |
| - return ( | |
| - (await this.getCellInputExpanderLocator(cellIndex))?.elementHandle() ?? | |
| - null | |
| - ); | |
| + return (await this.getCellInputExpanderLocator(cellIndex))?.elementHandle() ?? null; | |
| } | |
| /** | |
| @@ -739,9 +708,7 @@ export class NotebookHelper { | |
| * @param cellIndex Cell index | |
| * @returns Locator to the cell input expander | |
| */ | |
| - async getCellInputExpanderLocator( | |
| - cellIndex: number | |
| - ): Promise<Locator | null> { | |
| + async getCellInputExpanderLocator(cellIndex: number): Promise<Locator | null> { | |
| const cell = await this.getCellLocator(cellIndex); | |
| if (!cell) { | |
| return null; | |
| @@ -799,10 +766,7 @@ export class NotebookHelper { | |
| async getCellOutputExpander( | |
| cellIndex: number | |
| ): Promise<ElementHandle<Element> | null> { | |
| - return ( | |
| - (await this.getCellInputExpanderLocator(cellIndex))?.elementHandle() ?? | |
| - null | |
| - ); | |
| + return (await this.getCellInputExpanderLocator(cellIndex))?.elementHandle() ?? null; | |
| } | |
| /** | |
| @@ -811,9 +775,7 @@ export class NotebookHelper { | |
| * @param cellIndex Cell index | |
| * @returns Handle to the cell output expander | |
| */ | |
| - async getCellOutputExpanderLocator( | |
| - cellIndex: number | |
| - ): Promise<Locator | null> { | |
| + async getCellOutputExpanderLocator(cellIndex: number): Promise<Locator | null> { | |
| const cell = await this.getCellLocator(cellIndex); | |
| if (!cell) { | |
| return null; | |
| @@ -870,12 +832,8 @@ export class NotebookHelper { | |
| * | |
| * @deprecated You should use locator instead {@link getCellOutputLocator} | |
| */ | |
| - async getCellOutput( | |
| - cellIndex: number | |
| - ): Promise<ElementHandle<Element> | null> { | |
| - return ( | |
| - (await this.getCellOutputLocator(cellIndex))?.elementHandle() ?? null | |
| - ); | |
| + async getCellOutput(cellIndex: number): Promise<ElementHandle<Element> | null> { | |
| + return (await this.getCellOutputLocator(cellIndex))?.elementHandle() ?? null; | |
| } | |
| /** | |
| @@ -946,9 +904,7 @@ export class NotebookHelper { | |
| const cellEditor = cell.locator('.jp-InputArea-editor'); | |
| if (await cellEditor.count()) { | |
| - return (await Utils.getLocatorClassList(cellEditor)).includes( | |
| - 'jp-mod-focused' | |
| - ); | |
| + return (await Utils.getLocatorClassList(cellEditor)).includes('jp-mod-focused'); | |
| } | |
| return false; | |
| @@ -1035,10 +991,7 @@ export class NotebookHelper { | |
| * @param cellIndex Cell index | |
| * @param lineNumber Cell line number, starts at 1 | |
| */ | |
| - async clickCellGutter( | |
| - cellIndex: number, | |
| - lineNumber: number | |
| - ): Promise<boolean> { | |
| + async clickCellGutter(cellIndex: number, lineNumber: number): Promise<boolean> { | |
| if (lineNumber < 1) { | |
| return false; | |
| } | |
| @@ -1094,9 +1047,7 @@ export class NotebookHelper { | |
| await Utils.waitForCondition( | |
| async () => | |
| (await panel | |
| - .locator( | |
| - '.cm-gutters > .cm-gutter.cm-breakpoint-gutter > .cm-gutterElement' | |
| - ) | |
| + .locator('.cm-gutters > .cm-gutter.cm-breakpoint-gutter > .cm-gutterElement') | |
| .count()) > 0 | |
| ); | |
| @@ -1124,10 +1075,7 @@ export class NotebookHelper { | |
| return Utils.waitForCondition(() => this.isCodeGutterPresent()); | |
| } | |
| - protected async _clickOnGutter( | |
| - panel: Locator, | |
| - line: number | |
| - ): Promise<boolean> { | |
| + protected async _clickOnGutter(panel: Locator, line: number): Promise<boolean> { | |
| const gutters = panel.locator( | |
| '.cm-gutters > .cm-gutter.cm-breakpoint-gutter > .cm-gutterElement' | |
| ); | |
| @@ -1317,10 +1265,7 @@ export class NotebookHelper { | |
| * @param cellType Cell type | |
| * @returns Action success status | |
| */ | |
| - async setCellType( | |
| - cellIndex: number, | |
| - cellType: nbformat.CellType | |
| - ): Promise<boolean> { | |
| + async setCellType(cellIndex: number, cellType: nbformat.CellType): Promise<boolean> { | |
| const nbPanel = await this.activity.getPanelLocator(); | |
| if (!(nbPanel && (await nbPanel.count()))) { | |
| return false; | |
| @@ -1419,9 +1364,7 @@ export class NotebookHelper { | |
| await this.page.evaluate(cellIdx => { | |
| window.galata.resetExecutionCount(cellIdx); | |
| }, cellIndex); | |
| - await this.page.keyboard.press( | |
| - inplace === true ? 'Control+Enter' : 'Shift+Enter' | |
| - ); | |
| + await this.page.keyboard.press(inplace === true ? 'Control+Enter' : 'Shift+Enter'); | |
| await this.waitForRun(cellIndex); | |
| return true; | |
| @@ -1446,10 +1389,7 @@ export class NotebookHelper { | |
| if (options && options.kernel !== undefined) { | |
| if (options.kernel === null) { | |
| - await page | |
| - .getByRole('dialog') | |
| - .getByRole('combobox') | |
| - .selectOption('null'); | |
| + await page.getByRole('dialog').getByRole('combobox').selectOption('null'); | |
| } else { | |
| await page | |
| .getByRole('dialog') | |
| diff --git a/galata/src/helpers/sidebar.ts b/galata/src/helpers/sidebar.ts | |
| index 4e559bb6dc..fe43beb113 100644 | |
| --- a/galata/src/helpers/sidebar.ts | |
| +++ b/galata/src/helpers/sidebar.ts | |
| @@ -34,9 +34,7 @@ export class SidebarHelper { | |
| * @returns Tab opened status | |
| */ | |
| async isTabOpen(id: galata.SidebarTabId): Promise<boolean> { | |
| - const tabButton = this.page.locator( | |
| - `${this.buildTabSelector(id)}.lm-mod-current` | |
| - ); | |
| + const tabButton = this.page.locator(`${this.buildTabSelector(id)}.lm-mod-current`); | |
| return (await tabButton.count()) > 0; | |
| } | |
| @@ -149,10 +147,7 @@ export class SidebarHelper { | |
| 'Sessions and Tabs': 'left', | |
| 'Table of Contents': 'left' | |
| }; | |
| - const currentLayout = (await settingRegistry.get( | |
| - SHELL_ID, | |
| - 'layout' | |
| - )) as any; | |
| + const currentLayout = (await settingRegistry.get(SHELL_ID, 'layout')) as any; | |
| await settingRegistry.set(SHELL_ID, 'layout', { | |
| single: { ...currentLayout.single, ...sidebars }, | |
| multiple: { ...currentLayout.multiple, ...sidebars } | |
| @@ -178,9 +173,7 @@ export class SidebarHelper { | |
| * | |
| * @deprecated You should use locator instead {@link getTabLocator} | |
| */ | |
| - async getTab( | |
| - id: galata.SidebarTabId | |
| - ): Promise<ElementHandle<Element> | null> { | |
| + async getTab(id: galata.SidebarTabId): Promise<ElementHandle<Element> | null> { | |
| return await this.getTabLocator(id).elementHandle(); | |
| } | |
| @@ -309,10 +302,7 @@ export class SidebarHelper { | |
| * @param width Sidebar width in pixels | |
| * @param side Which sidebar to set: 'left' or 'right' | |
| */ | |
| - async setWidth( | |
| - width = 251, | |
| - side: galata.SidebarPosition = 'left' | |
| - ): Promise<boolean> { | |
| + async setWidth(width = 251, side: galata.SidebarPosition = 'left'): Promise<boolean> { | |
| if (!(await this.isOpen(side))) { | |
| return false; | |
| } | |
| @@ -332,9 +322,7 @@ export class SidebarHelper { | |
| ); | |
| await this.page.mouse.down(); | |
| await this.page.mouse.move( | |
| - side === 'left' | |
| - ? 33 + width | |
| - : this.page.viewportSize()!.width - 33 - width, | |
| + side === 'left' ? 33 + width : this.page.viewportSize()!.width - 33 - width, | |
| handleBBox!.y + 0.5 * handleBBox!.height | |
| ); | |
| await this.page.mouse.up(); | |
| @@ -352,14 +340,9 @@ export class SidebarHelper { | |
| return `.lm-TabBar.jp-SideBar .lm-TabBar-content li.lm-TabBar-tab[data-id="${id}"]`; | |
| } | |
| - protected async _waitForTabActivate( | |
| - tab: Locator, | |
| - activate = true | |
| - ): Promise<void> { | |
| + protected async _waitForTabActivate(tab: Locator, activate = true): Promise<void> { | |
| await Utils.waitForCondition(async () => { | |
| - const current = (await Utils.getLocatorClassList(tab)).includes( | |
| - 'lm-mod-current' | |
| - ); | |
| + const current = (await Utils.getLocatorClassList(tab)).includes('lm-mod-current'); | |
| return activate ? current : !current; | |
| }); | |
| } | |
| diff --git a/galata/src/helpers/statusbar.ts b/galata/src/helpers/statusbar.ts | |
| index fdacbeda89..35786538dd 100644 | |
| --- a/galata/src/helpers/statusbar.ts | |
| +++ b/galata/src/helpers/statusbar.ts | |
| @@ -20,9 +20,7 @@ export class StatusBarHelper { | |
| */ | |
| async isVisible(): Promise<boolean> { | |
| return await this.page.evaluate(() => { | |
| - const statusBar = document.querySelector( | |
| - '#jp-main-statusbar' | |
| - ) as HTMLElement; | |
| + const statusBar = document.querySelector('#jp-main-statusbar') as HTMLElement; | |
| return window.galata.isElementVisible(statusBar); | |
| }); | |
| } | |
| diff --git a/galata/src/helpers/style.ts b/galata/src/helpers/style.ts | |
| index 13f6298100..f5d1cb82e7 100644 | |
| --- a/galata/src/helpers/style.ts | |
| +++ b/galata/src/helpers/style.ts | |
| @@ -52,9 +52,7 @@ export class StyleHelper { | |
| * @param options specify which rules to include/exclude. | |
| * @returns List of rules with no matching elements on the page. | |
| */ | |
| - async findUnusedStyleRules( | |
| - options: IUnusedStyleCheckOptions | |
| - ): Promise<string[]> { | |
| + async findUnusedStyleRules(options: IUnusedStyleCheckOptions): Promise<string[]> { | |
| let exclude = typeof options.exclude !== 'undefined' ? options.exclude : []; | |
| if (!options.includeModifiers) { | |
| exclude = [...exclude, ...['.jp-mod-', '.lm-mod-']]; | |
| @@ -74,14 +72,10 @@ export class StyleHelper { | |
| .filter(selector => | |
| options.fragments.some(fragment => selector.includes(fragment)) | |
| ) | |
| - .filter( | |
| - selector => !exclude.some(fragment => selector.includes(fragment)) | |
| - ); | |
| + .filter(selector => !exclude.some(fragment => selector.includes(fragment))); | |
| const potentiallyUnusedRules = await this.page.evaluate( | |
| relevantRules => | |
| - relevantRules.filter( | |
| - selector => document.querySelector(selector) == null | |
| - ), | |
| + relevantRules.filter(selector => document.querySelector(selector) == null), | |
| relevantRules | |
| ); | |
| if (potentiallyUnusedRules.length !== 0) { | |
| diff --git a/galata/src/jupyterlabpage.ts b/galata/src/jupyterlabpage.ts | |
| index 6fcaaf0f7d..16a8d4b299 100644 | |
| --- a/galata/src/jupyterlabpage.ts | |
| +++ b/galata/src/jupyterlabpage.ts | |
| @@ -25,8 +25,7 @@ import * as Utils from './utils'; | |
| /** | |
| * JupyterLab page interface | |
| */ | |
| -export interface IJupyterLabPageFixture | |
| - extends Omit<Page, 'goto'>, IJupyterLabPage {} | |
| +export interface IJupyterLabPageFixture extends Omit<Page, 'goto'>, IJupyterLabPage {} | |
| /** | |
| * JupyterLab specific helpers interface | |
| @@ -226,9 +225,7 @@ export interface IJupyterLabPage { | |
| * | |
| * @param element Element or selector to watch | |
| */ | |
| - waitForTransition( | |
| - element: ElementHandle<Element> | Locator | string | |
| - ): Promise<void>; | |
| + waitForTransition(element: ElementHandle<Element> | Locator | string): Promise<void>; | |
| /** | |
| * Factory for active activity tab xpath | |
| @@ -600,17 +597,12 @@ export class JupyterLabPage implements IJupyterLabPage { | |
| * @returns Whether this operation succeeds or not | |
| */ | |
| async setSimpleMode(simple: boolean): Promise<boolean> { | |
| - const toggle = this.page.locator( | |
| - '#jp-single-document-mode button.jp-switch' | |
| - ); | |
| + const toggle = this.page.locator('#jp-single-document-mode button.jp-switch'); | |
| if (toggle) { | |
| const checked = (await toggle.getAttribute('aria-checked')) === 'true'; | |
| if ((checked && !simple) || (!checked && simple)) { | |
| - await Promise.all([ | |
| - Utils.waitForTransition(this.page, toggle), | |
| - toggle.click() | |
| - ]); | |
| + await Promise.all([Utils.waitForTransition(this.page, toggle), toggle.click()]); | |
| } | |
| await Utils.waitForCondition(async () => { | |
| @@ -727,8 +719,5 @@ export class JupyterLabPage implements IJupyterLabPage { | |
| /** | |
| * Wait for the splash screen to be hidden and the launcher to be the active tab. | |
| */ | |
| - protected waitIsReady: ( | |
| - page: Page, | |
| - helpers: IJupyterLabPage | |
| - ) => Promise<void>; | |
| + protected waitIsReady: (page: Page, helpers: IJupyterLabPage) => Promise<void>; | |
| } | |
| diff --git a/galata/src/utils.ts b/galata/src/utils.ts | |
| index 34a86f8108..3461b5a95f 100644 | |
| --- a/galata/src/utils.ts | |
| +++ b/galata/src/utils.ts | |
| @@ -79,9 +79,7 @@ export async function getBaseUrl(page: Page): Promise<string> { | |
| * | |
| * @deprecated You should use locator instead {@link getLocatorClassList} | |
| */ | |
| -export async function getElementClassList( | |
| - element: ElementHandle | |
| -): Promise<string[]> { | |
| +export async function getElementClassList(element: ElementHandle): Promise<string[]> { | |
| if (!element) { | |
| return []; | |
| } | |
| @@ -119,10 +117,7 @@ export async function getLocatorClassList(locator: Locator): Promise<string[]> { | |
| * @param filePaths List to populate with the directory content | |
| * @returns Content of the directory | |
| */ | |
| -export function getFilesInDirectory( | |
| - dirPath: string, | |
| - filePaths?: string[] | |
| -): string[] { | |
| +export function getFilesInDirectory(dirPath: string, filePaths?: string[]): string[] { | |
| const files = fs.readdirSync(dirPath); | |
| filePaths = filePaths || []; | |
| @@ -160,8 +155,7 @@ export async function getOption(page: Page, name: string): Promise<string> { | |
| */ | |
| export async function getToken(page: Page): Promise<string> { | |
| return ( | |
| - (await getOption(page, 'token')) || | |
| - (await getBodyData(page, 'jupyterApiToken')) | |
| + (await getOption(page, 'token')) || (await getBodyData(page, 'jupyterApiToken')) | |
| ); | |
| } | |
| diff --git a/galata/test/benchmark/notebook.spec.ts b/galata/test/benchmark/notebook.spec.ts | |
| index aad8dadbbd..a52cc3ab32 100644 | |
| --- a/galata/test/benchmark/notebook.spec.ts | |
| +++ b/galata/test/benchmark/notebook.spec.ts | |
| @@ -13,9 +13,7 @@ const textFile = 'lorem_ipsum.txt'; | |
| // Build test parameters list [file, index] | |
| const parameters = [].concat( | |
| ...[codeNotebook, mdNotebook].map(file => | |
| - new Array<number>(benchmark.nSamples) | |
| - .fill(0) | |
| - .map((_, index) => [file, index]) | |
| + new Array<number>(benchmark.nSamples).fill(0).map((_, index) => [file, index]) | |
| ) | |
| ); | |
| @@ -130,9 +128,7 @@ test.describe('Benchmark', () => { | |
| // Wait for the cell toolbar to be visible in code cell. | |
| if (file === codeNotebook) { | |
| await expect( | |
| - page.locator( | |
| - '.jp-Notebook .jp-Cell .jp-cell-toolbar:not(.jp-Toolbar-micro)' | |
| - ) | |
| + page.locator('.jp-Notebook .jp-Cell .jp-cell-toolbar:not(.jp-Toolbar-micro)') | |
| ).toBeVisible(); | |
| } | |
| @@ -150,9 +146,7 @@ test.describe('Benchmark', () => { | |
| // Shutdown the kernel to be sure it does not get in our way (especially for the close action) | |
| await page.click('li[role="menuitem"]:has-text("Kernel")'); | |
| - await page.click( | |
| - '.lm-Menu ul[role="menu"] >> text=Shut Down All Kernels…' | |
| - ); | |
| + await page.click('.lm-Menu ul[role="menu"] >> text=Shut Down All Kernels…'); | |
| await page.click('button:has-text("Shut Down All") >> nth=-1'); // Click on the last matched button. | |
| // Open text file | |
| @@ -182,9 +176,7 @@ test.describe('Benchmark', () => { | |
| // Switch back | |
| const toTime = await perf.measure(async () => { | |
| - await page.click( | |
| - `div[role="main"] >> .lm-DockPanel-tabBar >> text=${file}` | |
| - ); | |
| + await page.click(`div[role="main"] >> .lm-DockPanel-tabBar >> text=${file}`); | |
| }); | |
| // Check the notebook is correctly opened | |
| diff --git a/galata/test/documentation/commands.test.ts b/galata/test/documentation/commands.test.ts | |
| index eec06480aa..df55ff062b 100644 | |
| --- a/galata/test/documentation/commands.test.ts | |
| +++ b/galata/test/documentation/commands.test.ts | |
| @@ -68,8 +68,7 @@ test('All commands must have a default label and describedBy', async ({ | |
| const commandsSnapshotPath = testInfo.snapshotPath('commandsList.json'); | |
| - const existingCommands: typeof commands = | |
| - await fs.readJSON(commandsSnapshotPath); | |
| + const existingCommands: typeof commands = await fs.readJSON(commandsSnapshotPath); | |
| // Update snapshots only when explicitly requested with --update-snapshots | |
| if (testInfo.config.updateSnapshots === 'all') { | |
| diff --git a/galata/test/documentation/customization.test.ts b/galata/test/documentation/customization.test.ts | |
| index feddc2333d..38c2865136 100644 | |
| --- a/galata/test/documentation/customization.test.ts | |
| +++ b/galata/test/documentation/customization.test.ts | |
| @@ -44,25 +44,17 @@ test.describe('Default', () => { | |
| await page.sidebar.setWidth(); | |
| - await page.dblclick( | |
| - '[aria-label="File Browser Section"] >> text=notebooks' | |
| - ); | |
| + await page.dblclick('[aria-label="File Browser Section"] >> text=notebooks'); | |
| await page.dblclick('text=Lorenz.ipynb'); | |
| await page.locator('div[role="main"] >> text=Lorenz.ipynb').waitFor(); | |
| // Wait for kernel to settle on idle | |
| - await page | |
| - .locator('.jp-DebuggerBugButton[aria-disabled="false"]') | |
| - .waitFor(); | |
| - await page | |
| - .locator('.jp-Notebook-ExecutionIndicator[data-status="idle"]') | |
| - .waitFor(); | |
| + await page.locator('.jp-DebuggerBugButton[aria-disabled="false"]').waitFor(); | |
| + await page.locator('.jp-Notebook-ExecutionIndicator[data-status="idle"]').waitFor(); | |
| expect( | |
| - await page | |
| - .locator('div[role="main"] >> .jp-NotebookPanel-toolbar') | |
| - .screenshot() | |
| + await page.locator('div[role="main"] >> .jp-NotebookPanel-toolbar').screenshot() | |
| ).toMatchSnapshot('default-notebook-toolbar.png'); | |
| }); | |
| @@ -97,9 +89,7 @@ test.describe('Default', () => { | |
| await page.sidebar.setWidth(); | |
| - await page.dblclick( | |
| - '[aria-label="File Browser Section"] >> text=notebooks' | |
| - ); | |
| + await page.dblclick('[aria-label="File Browser Section"] >> text=notebooks'); | |
| await page.click('text=Lorenz.ipynb', { button: 'right' }); | |
| await page.hover('ul[role="menu"] >> text=New File'); | |
| @@ -222,9 +212,7 @@ test.describe('Customized', () => { | |
| await page.sidebar.setWidth(); | |
| - await page.dblclick( | |
| - '[aria-label="File Browser Section"] >> text=notebooks' | |
| - ); | |
| + await page.dblclick('[aria-label="File Browser Section"] >> text=notebooks'); | |
| await page.dblclick('text=Lorenz.ipynb'); | |
| await page.locator('div[role="main"] >> text=Lorenz.ipynb').waitFor(); | |
| @@ -232,9 +220,7 @@ test.describe('Customized', () => { | |
| await page.locator('text=Python 3 (ipykernel) | Idle').waitFor(); | |
| expect( | |
| - await page | |
| - .locator('div[role="main"] >> .jp-NotebookPanel-toolbar') | |
| - .screenshot() | |
| + await page.locator('div[role="main"] >> .jp-NotebookPanel-toolbar').screenshot() | |
| ).toMatchSnapshot('customized-notebook-toolbar.png'); | |
| }); | |
| @@ -269,9 +255,7 @@ test.describe('Customized', () => { | |
| await page.sidebar.setWidth(); | |
| - await page.dblclick( | |
| - '[aria-label="File Browser Section"] >> text=notebooks' | |
| - ); | |
| + await page.dblclick('[aria-label="File Browser Section"] >> text=notebooks'); | |
| await page.click('text=Lorenz.ipynb', { button: 'right' }); | |
| await page.hover('ul[role="menu"] >> text=New File'); | |
| diff --git a/galata/test/documentation/debugger.test.ts b/galata/test/documentation/debugger.test.ts | |
| index 4119f0e47a..9abbaa786a 100644 | |
| --- a/galata/test/documentation/debugger.test.ts | |
| +++ b/galata/test/documentation/debugger.test.ts | |
| @@ -18,12 +18,8 @@ test.describe('Debugger', () => { | |
| await createNotebook(page); | |
| // Wait for kernel to settle on idle | |
| - await page | |
| - .locator('.jp-DebuggerBugButton[aria-disabled="false"]') | |
| - .waitFor(); | |
| - await page | |
| - .locator('.jp-Notebook-ExecutionIndicator[data-status="idle"]') | |
| - .waitFor(); | |
| + await page.locator('.jp-DebuggerBugButton[aria-disabled="false"]').waitFor(); | |
| + await page.locator('.jp-Notebook-ExecutionIndicator[data-status="idle"]').waitFor(); | |
| expect( | |
| await page.screenshot({ | |
| @@ -137,22 +133,22 @@ test.describe('Debugger', () => { | |
| await page.waitForCondition(() => page.debugger.isOpen()); | |
| await page.sidebar.setWidth(251, 'right'); | |
| - await expect( | |
| - page.locator('jp-button.jp-PauseOnExceptions') | |
| - ).toHaveAttribute('aria-pressed', 'false'); | |
| + await expect(page.locator('jp-button.jp-PauseOnExceptions')).toHaveAttribute( | |
| + 'aria-pressed', | |
| + 'false' | |
| + ); | |
| await page.locator('jp-button.jp-PauseOnExceptions').click(); | |
| const menu = page.locator('.jp-PauseOnExceptions-menu'); | |
| await expect(menu).toBeVisible(); | |
| await expect(menu.locator('li.lm-Menu-item')).toHaveCount(3); | |
| await expect(menu.locator('li.lm-Menu-item.lm-mod-toggled')).toHaveCount(0); | |
| - await menu | |
| - .locator('li div.lm-Menu-itemLabel:text("userUnhandled")') | |
| - .click(); | |
| + await menu.locator('li div.lm-Menu-itemLabel:text("userUnhandled")').click(); | |
| - await expect( | |
| - page.locator('jp-button.jp-PauseOnExceptions') | |
| - ).toHaveAttribute('aria-pressed', 'true'); | |
| + await expect(page.locator('jp-button.jp-PauseOnExceptions')).toHaveAttribute( | |
| + 'aria-pressed', | |
| + 'true' | |
| + ); | |
| await page.notebook.enterCellEditingMode(0); | |
| const keyboard = page.keyboard; | |
| @@ -252,9 +248,7 @@ test.describe('Debugger', () => { | |
| // Wait to be stopped on the breakpoint and the local variables to be displayed | |
| await page.debugger.waitForCallStack(); | |
| - await expect(page.locator('select[aria-label="Scope"]')).toHaveValue( | |
| - 'Locals' | |
| - ); | |
| + await expect(page.locator('select[aria-label="Scope"]')).toHaveValue('Locals'); | |
| expect( | |
| await page.screenshot({ | |
| @@ -364,11 +358,7 @@ async function createNotebook(page: IJupyterLabPageFixture) { | |
| } | |
| async function setBreakpoint(page: IJupyterLabPageFixture) { | |
| - await page.notebook.setCell( | |
| - 0, | |
| - 'code', | |
| - 'def add(a, b):\nres = a + b\nreturn res' | |
| - ); | |
| + await page.notebook.setCell(0, 'code', 'def add(a, b):\nres = a + b\nreturn res'); | |
| await page.notebook.run(); | |
| await page.notebook.addCell('code', 'result = add(1, 2)\nprint(result)'); | |
| diff --git a/galata/test/documentation/export_notebook.test.ts b/galata/test/documentation/export_notebook.test.ts | |
| index 6e9e770f8a..31453349e4 100644 | |
| --- a/galata/test/documentation/export_notebook.test.ts | |
| +++ b/galata/test/documentation/export_notebook.test.ts | |
| @@ -15,17 +15,13 @@ test.describe('Export Notebook', () => { | |
| await page.sidebar.setWidth(); | |
| - await page.dblclick( | |
| - '[aria-label="File Browser Section"] >> text=notebooks' | |
| - ); | |
| + await page.dblclick('[aria-label="File Browser Section"] >> text=notebooks'); | |
| await page.dblclick('text=Lorenz.ipynb'); | |
| await page.locator('text=Python 3 (ipykernel) | Idle').waitFor(); | |
| await page.click('text=File'); | |
| - await page.click( | |
| - '.lm-Menu ul[role="menu"] >> text=Save and Export Notebook As' | |
| - ); | |
| + await page.click('.lm-Menu ul[role="menu"] >> text=Save and Export Notebook As'); | |
| // Wait for Latex renderer | |
| // note: requires the a11y/assistive-mml MathJax extension | |
| @@ -51,10 +47,7 @@ test.describe('Export Notebook', () => { | |
| await page.getByTitle('Property Inspector').click(); | |
| - await page | |
| - .locator('.jp-PropertyInspector') | |
| - .getByText('Common Tools') | |
| - .click(); | |
| + await page.locator('.jp-PropertyInspector').getByText('Common Tools').click(); | |
| await page | |
| .locator('.jp-ActiveCellTool') | |
| diff --git a/galata/test/documentation/extension_manager.test.ts b/galata/test/documentation/extension_manager.test.ts | |
| index bab60a8ed7..7453ba5f3d 100644 | |
| --- a/galata/test/documentation/extension_manager.test.ts | |
| +++ b/galata/test/documentation/extension_manager.test.ts | |
| @@ -184,9 +184,7 @@ async function openExtensionSidebar(page: IJupyterLabPageFixture) { | |
| await Promise.all([ | |
| page.waitForResponse(new RegExp(`${galata.Routes.extensions}?refresh=0`)), | |
| page.waitForResponse( | |
| - new RegExp( | |
| - `${galata.Routes.extensions}?query&page=1&per_page=30&refresh=0` | |
| - ) | |
| + new RegExp(`${galata.Routes.extensions}?query&page=1&per_page=30&refresh=0`) | |
| ), | |
| page.click('button:has-text("Yes")') | |
| ]); | |
| diff --git a/galata/test/documentation/general.test.ts b/galata/test/documentation/general.test.ts | |
| index 2bc1b8b6f0..4abe045ef4 100644 | |
| --- a/galata/test/documentation/general.test.ts | |
| +++ b/galata/test/documentation/general.test.ts | |
| @@ -36,9 +36,7 @@ test.describe('General', () => { | |
| await page.click('text=Open With'); | |
| await page.click('text=Markdown Preview'); | |
| - await page.dblclick( | |
| - '[aria-label="File Browser Section"] >> text=notebooks' | |
| - ); | |
| + await page.dblclick('[aria-label="File Browser Section"] >> text=notebooks'); | |
| await page.dblclick('text=Lorenz.ipynb'); | |
| await page.click('text=File'); | |
| @@ -66,9 +64,7 @@ test.describe('General', () => { | |
| await page.click('text=Create New View for Cell Output'); | |
| // Emulate drag and drop | |
| - const viewerHandle = page.locator( | |
| - '.lm-TabBar-tabLabel:text-is("lorenz.py")' | |
| - ); | |
| + const viewerHandle = page.locator('.lm-TabBar-tabLabel:text-is("lorenz.py")'); | |
| await viewerHandle.click(); | |
| const viewerBBox = await viewerHandle.boundingBox(); | |
| @@ -82,9 +78,7 @@ test.describe('General', () => { | |
| // wait for the debugger bug icon to settle | |
| const panel = (await page.activity.getPanelLocator('Lorenz.ipynb'))!; | |
| - await panel | |
| - .locator('.jp-DebuggerBugButton[aria-disabled="false"]') | |
| - .waitFor(); | |
| + await panel.locator('.jp-DebuggerBugButton[aria-disabled="false"]').waitFor(); | |
| expect(await page.screenshot()).toMatchSnapshot('jupyterlab.png'); | |
| }); | |
| @@ -133,12 +127,10 @@ test.describe('General', () => { | |
| await page.click('.jp-PropertyInspector >> text=Common Tools'); | |
| - await expect( | |
| - page.locator('.jp-ActiveCellTool .jp-InputPrompt') | |
| - ).not.toBeEmpty(); | |
| - await expect( | |
| - page.locator('.jp-ActiveCellTool .jp-InputPrompt') | |
| - ).not.toHaveClass(/lm-mod-hidden/); | |
| + await expect(page.locator('.jp-ActiveCellTool .jp-InputPrompt')).not.toBeEmpty(); | |
| + await expect(page.locator('.jp-ActiveCellTool .jp-InputPrompt')).not.toHaveClass( | |
| + /lm-mod-hidden/ | |
| + ); | |
| expect( | |
| await page.screenshot({ | |
| @@ -161,9 +153,9 @@ test.describe('General', () => { | |
| // Open Advanced tools and get metadata content | |
| await page.click('.jp-PropertyInspector >> text=Advanced Tools'); | |
| - await expect( | |
| - page.locator('.jp-MetadataForm .jp-MetadataEditorTool') | |
| - ).toHaveCount(2); | |
| + await expect(page.locator('.jp-MetadataForm .jp-MetadataEditorTool')).toHaveCount( | |
| + 2 | |
| + ); | |
| const cellMetadata = await page | |
| .locator('.jp-MetadataForm .jp-MetadataEditorTool') | |
| .first() | |
| @@ -196,10 +188,7 @@ test.describe('General', () => { | |
| .locator('.jp-MetadataForm input[label="Table of content - Base number"]') | |
| .fill('3'); | |
| const newNotebookMetadata = ( | |
| - await page | |
| - .locator('.jp-MetadataForm .jp-MetadataEditorTool') | |
| - .last() | |
| - .textContent() | |
| + await page.locator('.jp-MetadataForm .jp-MetadataEditorTool').last().textContent() | |
| )?.replace(/\s/g, ''); | |
| expect(newNotebookMetadata).toContain('"base_numbering":3'); | |
| @@ -207,9 +196,9 @@ test.describe('General', () => { | |
| await expect( | |
| page.locator('.jp-ActiveCellTool .jp-ActiveCellTool-Content pre') | |
| ).toHaveText('Raw cell'); | |
| - await expect( | |
| - page.locator('.jp-ActiveCellTool .jp-InputPrompt') | |
| - ).toHaveClass(/lm-mod-hidden/); | |
| + await expect(page.locator('.jp-ActiveCellTool .jp-InputPrompt')).toHaveClass( | |
| + /lm-mod-hidden/ | |
| + ); | |
| await (await page.notebook.getCellInputLocator(1))?.click(); | |
| await page.keyboard.type(' content'); | |
| await expect( | |
| @@ -220,17 +209,13 @@ test.describe('General', () => { | |
| await expect( | |
| page.locator('.jp-ActiveCellTool .jp-ActiveCellTool-Content pre') | |
| ).toHaveText('print("test")'); | |
| - await expect( | |
| - page.locator('.jp-ActiveCellTool .jp-InputPrompt') | |
| - ).not.toHaveClass(/lm-mod-hidden/); | |
| - await expect(page.locator('.jp-ActiveCellTool .jp-InputPrompt')).toHaveText( | |
| - '[ ]:' | |
| + await expect(page.locator('.jp-ActiveCellTool .jp-InputPrompt')).not.toHaveClass( | |
| + /lm-mod-hidden/ | |
| ); | |
| + await expect(page.locator('.jp-ActiveCellTool .jp-InputPrompt')).toHaveText('[ ]:'); | |
| await page.notebook.runCell(2, true); | |
| - await expect(page.locator('.jp-ActiveCellTool .jp-InputPrompt')).toHaveText( | |
| - '[1]:' | |
| - ); | |
| + await expect(page.locator('.jp-ActiveCellTool .jp-InputPrompt')).toHaveText('[1]:'); | |
| }); | |
| test('File menu', async ({ page }) => { | |
| @@ -306,9 +291,7 @@ test.describe('General', () => { | |
| await page.sidebar.setWidth(); | |
| - await page.dblclick( | |
| - '[aria-label="File Browser Section"] >> text=notebooks' | |
| - ); | |
| + await page.dblclick('[aria-label="File Browser Section"] >> text=notebooks'); | |
| await page.click('text=Lorenz.ipynb', { button: 'right' }); | |
| await page.hover('text=Copy Shareable Link'); | |
| @@ -366,9 +349,7 @@ test.describe('General', () => { | |
| }); | |
| // Open jupyterlab.md | |
| - await page.dblclick( | |
| - '[aria-label="File Browser Section"] >> text=narrative' | |
| - ); | |
| + await page.dblclick('[aria-label="File Browser Section"] >> text=narrative'); | |
| await page.dblclick('text=jupyterlab.md'); | |
| // Hide file browser | |
| @@ -388,15 +369,11 @@ test.describe('General', () => { | |
| await page.sidebar.setWidth(); | |
| // Open jupyterlab.md | |
| - await page.dblclick( | |
| - '[aria-label="File Browser Section"] >> text=narrative' | |
| - ); | |
| + await page.dblclick('[aria-label="File Browser Section"] >> text=narrative'); | |
| await page.dblclick('text=jupyterlab.md'); | |
| await page.click('text=Settings'); | |
| - await page.click( | |
| - '.lm-Menu ul[role="menu"] >> text=Text Editor Indentation' | |
| - ); | |
| + await page.click('.lm-Menu ul[role="menu"] >> text=Text Editor Indentation'); | |
| expect( | |
| await page.screenshot({ clip: { y: 0, x: 260, width: 600, height: 450 } }) | |
| @@ -415,9 +392,7 @@ test.describe('General', () => { | |
| await page.sidebar.setWidth(); | |
| // Open Data.ipynb | |
| - await page.dblclick( | |
| - '[aria-label="File Browser Section"] >> text=notebooks' | |
| - ); | |
| + await page.dblclick('[aria-label="File Browser Section"] >> text=notebooks'); | |
| await page.dblclick('text=Data.ipynb'); | |
| await page.menu.clickMenuItem('Edit>Clear Outputs of All Cells'); | |
| await page.notebook.setCell( | |
| @@ -446,9 +421,7 @@ test.describe('General', () => { | |
| test('Trust indicator', async ({ page }) => { | |
| await page.goto(); | |
| // Open Data.ipynb which is not trusted by default | |
| - await page.dblclick( | |
| - '[aria-label="File Browser Section"] >> text=notebooks' | |
| - ); | |
| + await page.dblclick('[aria-label="File Browser Section"] >> text=notebooks'); | |
| await page.dblclick('text=Data.ipynb'); | |
| const trustIndictor = page.locator('.jp-StatusItem-trust'); | |
| @@ -468,9 +441,7 @@ test.describe('General', () => { | |
| // Wait until dialog is gone | |
| await trustPromise; | |
| - expect(await trustIndictor.screenshot()).toMatchSnapshot( | |
| - 'notebook_trusted.png' | |
| - ); | |
| + expect(await trustIndictor.screenshot()).toMatchSnapshot('notebook_trusted.png'); | |
| }); | |
| test('Heading anchor', async ({ page }, testInfo) => { | |
| @@ -478,14 +449,10 @@ test.describe('General', () => { | |
| await page.sidebar.setWidth(); | |
| // Open Data.ipynb | |
| - await page.dblclick( | |
| - '[aria-label="File Browser Section"] >> text=notebooks' | |
| - ); | |
| + await page.dblclick('[aria-label="File Browser Section"] >> text=notebooks'); | |
| await page.dblclick('text=Data.ipynb'); | |
| - const heading = page.locator( | |
| - 'h2[data-jupyter-id="Open-a-CSV-file-using-Pandas"]' | |
| - ); | |
| + const heading = page.locator('h2[data-jupyter-id="Open-a-CSV-file-using-Pandas"]'); | |
| await heading.waitFor(); | |
| const anchor = heading.locator('text=¶'); | |
| await heading.hover(); | |
| @@ -531,9 +498,7 @@ test.describe('General', () => { | |
| await page.sidebar.setWidth(); | |
| // Open Data.ipynb | |
| - await page.dblclick( | |
| - '[aria-label="File Browser Section"] >> text=notebooks' | |
| - ); | |
| + await page.dblclick('[aria-label="File Browser Section"] >> text=notebooks'); | |
| await page.dblclick('text=Data.ipynb'); | |
| // Open a terminal | |
| @@ -570,9 +535,7 @@ test.describe('General', () => { | |
| await page.click('.lm-Menu ul[role="menu"] >> text=New'); | |
| await page.click('#jp-mainmenu-file-new >> text=Terminal'); | |
| - await page.dblclick( | |
| - '[aria-label="File Browser Section"] >> text=notebooks' | |
| - ); | |
| + await page.dblclick('[aria-label="File Browser Section"] >> text=notebooks'); | |
| await page.dblclick('text=Data.ipynb'); | |
| await page.dblclick('text=Julia.ipynb'); | |
| @@ -602,13 +565,9 @@ test.describe('General', () => { | |
| await page.click('jp-button[data-command="running:show-modal"]'); | |
| // Playwright uses shadow-piercing selectors so this works with webcomponents too | |
| - await expect | |
| - .soft(page.locator('.jp-SearchableSessions-modal input')) | |
| - .toBeFocused(); | |
| + await expect.soft(page.locator('.jp-SearchableSessions-modal input')).toBeFocused(); | |
| - const dialog = page.locator( | |
| - '.jp-SearchableSessions-modal .jp-Dialog-content' | |
| - ); | |
| + const dialog = page.locator('.jp-SearchableSessions-modal .jp-Dialog-content'); | |
| await freeezeKernelIds(dialog, mockedKernelIds); | |
| expect(await dialog.screenshot()).toMatchSnapshot('running_modal.png'); | |
| @@ -619,9 +578,9 @@ test.describe('General', () => { | |
| await page.keyboard.press('Control+Shift+C'); | |
| - expect( | |
| - await page.locator('#modal-command-palette').screenshot() | |
| - ).toMatchSnapshot('command_palette.png'); | |
| + expect(await page.locator('#modal-command-palette').screenshot()).toMatchSnapshot( | |
| + 'command_palette.png' | |
| + ); | |
| }); | |
| test('Keyboard Shortcuts Help', async ({ page, tmpPath }) => { | |
| @@ -677,9 +636,7 @@ test.describe('General', () => { | |
| await page.notebook.run(); | |
| await page.click('text=File'); | |
| - await page.click( | |
| - '.lm-Menu ul[role="menu"] >> text=New Console for Notebook' | |
| - ); | |
| + await page.click('.lm-Menu ul[role="menu"] >> text=New Console for Notebook'); | |
| await page.click('.jp-CodeConsole-input >> .cm-content'); | |
| await page.keyboard.type( | |
| @@ -689,9 +646,7 @@ test.describe('General', () => { | |
| await page.keyboard.press('Shift+Enter'); | |
| const main = page.getByRole('main'); | |
| - expect(await main.screenshot()).toMatchSnapshot( | |
| - 'file_formats_html_display.png' | |
| - ); | |
| + expect(await main.screenshot()).toMatchSnapshot('file_formats_html_display.png'); | |
| }); | |
| test('Altair', async ({ page, tmpPath }) => { | |
| diff --git a/galata/test/documentation/internationalization.test.ts b/galata/test/documentation/internationalization.test.ts | |
| index 37613eb511..94258f21ee 100644 | |
| --- a/galata/test/documentation/internationalization.test.ts | |
| +++ b/galata/test/documentation/internationalization.test.ts | |
| @@ -73,8 +73,7 @@ test.describe('Internationalization', () => { | |
| let requestedLanguage: string | undefined; | |
| await page.route(galata.Routes.translations, async (route, request) => { | |
| - const language = galata.Routes.translations.exec(request.url())?.groups | |
| - ?.id; | |
| + const language = galata.Routes.translations.exec(request.url())?.groups?.id; | |
| switch (request.method()) { | |
| case 'GET': | |
| if (language) { | |
| diff --git a/galata/test/documentation/overview.test.ts b/galata/test/documentation/overview.test.ts | |
| index 809bafdfcb..66ecd134e8 100644 | |
| --- a/galata/test/documentation/overview.test.ts | |
| +++ b/galata/test/documentation/overview.test.ts | |
| @@ -107,10 +107,7 @@ async function openOverview(page: IJupyterLabPageFixture) { | |
| const panelHandle = await page.activity.getPanelLocator(); | |
| const panelBBox = await panelHandle.boundingBox(); | |
| - await page.mouse.move( | |
| - mdBBox.x + 0.5 * mdBBox.width, | |
| - mdBBox.y + 0.5 * mdBBox.height | |
| - ); | |
| + await page.mouse.move(mdBBox.x + 0.5 * mdBBox.width, mdBBox.y + 0.5 * mdBBox.height); | |
| await page.mouse.down(); | |
| await page.mouse.move(panelBBox.x + 0.5 * panelBBox.width, 200); | |
| await page.mouse.up(); | |
| diff --git a/galata/test/documentation/plugin_manager.test.ts b/galata/test/documentation/plugin_manager.test.ts | |
| index a44f75a4e4..34fce51eda 100644 | |
| --- a/galata/test/documentation/plugin_manager.test.ts | |
| +++ b/galata/test/documentation/plugin_manager.test.ts | |
| @@ -55,9 +55,7 @@ test.describe('Advanced Plugin Manager', () => { | |
| expect(await pluginCheckbox.isChecked()).toEqual(true); | |
| }); | |
| - test('Warns if plugin to be disabled is used by other plugins', async ({ | |
| - page | |
| - }) => { | |
| + test('Warns if plugin to be disabled is used by other plugins', async ({ page }) => { | |
| await page.evaluate(async () => { | |
| // The command paltte should not be required by any plugins, | |
| // but is used by many. There are multiple plugins starting | |
| @@ -82,9 +80,7 @@ test.describe('Advanced Plugin Manager', () => { | |
| ); | |
| }); | |
| - test('Blocks disabling required plugin with an explanation', async ({ | |
| - page | |
| - }) => { | |
| + test('Blocks disabling required plugin with an explanation', async ({ page }) => { | |
| await page.evaluate(async () => { | |
| await window.jupyterapp.commands.execute('pluginmanager:open', { | |
| query: 'INotebookTracker' | |
| diff --git a/galata/test/documentation/plugins.test.ts b/galata/test/documentation/plugins.test.ts | |
| index b67de6ce9e..9694533061 100644 | |
| --- a/galata/test/documentation/plugins.test.ts | |
| +++ b/galata/test/documentation/plugins.test.ts | |
| @@ -17,9 +17,7 @@ const IGNORED_PLUGINS = [ | |
| /^@jupyterlab\/services-extension:content-provider-warning$/ | |
| ]; | |
| -test('All plugins and tokens must have a description', async ({ | |
| - page | |
| -}, testInfo) => { | |
| +test('All plugins and tokens must have a description', async ({ page }, testInfo) => { | |
| const { plugins, tokens } = await page.evaluate(async ignored => { | |
| const pluginIDs = window.jupyterapp.listPlugins(); | |
| pluginIDs.sort(); | |
| @@ -27,10 +25,7 @@ test('All plugins and tokens must have a description', async ({ | |
| const plugins: Record<string, string> = {}; | |
| const tokens: Record<string, string | undefined> = {}; | |
| pluginIDs.forEach(id => { | |
| - if ( | |
| - !id.startsWith('@jupyterlab/') || | |
| - ignored.some(pattern => pattern.test(id)) | |
| - ) { | |
| + if (!id.startsWith('@jupyterlab/') || ignored.some(pattern => pattern.test(id))) { | |
| return; | |
| } | |
| @@ -113,9 +108,7 @@ test('All plugins and tokens must have a description', async ({ | |
| expect(missingTokenDescriptions).toEqual([]); | |
| }); | |
| -test('Plugins must be named using the same convention', async ({ | |
| - page | |
| -}, testInfo) => { | |
| +test('Plugins must be named using the same convention', async ({ page }, testInfo) => { | |
| const pluginIDs = await page.evaluate(async ignored => { | |
| return window.jupyterapp.listPlugins().filter(id => { | |
| return !ignored.some(pattern => pattern.test(id)); | |
| diff --git a/galata/test/documentation/utils.ts b/galata/test/documentation/utils.ts | |
| index c7647aed1f..7f2b57d4e8 100644 | |
| --- a/galata/test/documentation/utils.ts | |
| +++ b/galata/test/documentation/utils.ts | |
| @@ -16,8 +16,7 @@ import path from 'path'; | |
| export function filterContent(array: any[]): any[] { | |
| return array.filter( | |
| item => | |
| - item['type'] !== 'directory' || | |
| - !(item['name'] as string).startsWith('test-') | |
| + item['type'] !== 'directory' || !(item['name'] as string).startsWith('test-') | |
| ); | |
| } | |
| diff --git a/galata/test/documentation/workspaces.test.ts b/galata/test/documentation/workspaces.test.ts | |
| index 9c94961049..89c44e07ca 100644 | |
| --- a/galata/test/documentation/workspaces.test.ts | |
| +++ b/galata/test/documentation/workspaces.test.ts | |
| @@ -37,9 +37,7 @@ test.describe('Workspaces sidebar', () => { | |
| test('Workspaces context menu', async ({ page }) => { | |
| // Load the test workspace | |
| - await page.dblclick( | |
| - `.jp-DirListing-item span:has-text("${testWorkspace}")` | |
| - ); | |
| + await page.dblclick(`.jp-DirListing-item span:has-text("${testWorkspace}")`); | |
| await page.getByRole('treeitem', { name: workspaceName }).waitFor(); | |
| await galata.Mock.mockRunners(page, new Map(), 'sessions'); | |
| @@ -95,9 +93,7 @@ test.describe('Workspaces sidebar', () => { | |
| } | |
| } | |
| const button = kernelsSection.locator('.jp-RunningSessions-shutdownAll'); | |
| - await button.evaluate( | |
| - node => ((node as HTMLButtonElement).disabled = true) | |
| - ); | |
| + await button.evaluate(node => ((node as HTMLButtonElement).disabled = true)); | |
| expect( | |
| await page.screenshot({ clip: { y: 0, x: 0, width: 400, height: 420 } }) | |
| diff --git a/galata/test/galata/benchmarkReporter.spec.ts b/galata/test/galata/benchmarkReporter.spec.ts | |
| index f370a4bbf9..1eaa60ee0a 100644 | |
| --- a/galata/test/galata/benchmarkReporter.spec.ts | |
| +++ b/galata/test/galata/benchmarkReporter.spec.ts | |
| @@ -58,9 +58,7 @@ function createReporter(options?: { | |
| allData: Array<IReportRecord>, | |
| comparison?: 'snapshot' | 'project' | |
| ) => JSONObject; | |
| - textReportFactory?: ( | |
| - allData: Array<IReportRecord> | |
| - ) => Promise<[string, string]>; | |
| + textReportFactory?: (allData: Array<IReportRecord>) => Promise<[string, string]>; | |
| }): BenchmarkReporter { | |
| const rootDir = '../../'; | |
| const reporter = new BenchmarkReporter(options); | |
| @@ -118,10 +116,7 @@ test.describe('BenchmarkReporter', () => { | |
| test.describe('benchmark.distributionChange', () => { | |
| test('matches result from paper', () => { | |
| - const change = benchmark.distributionChange( | |
| - [7.75, 12.25, 11.5], | |
| - [8.75, 6.25, 4.5] | |
| - ); | |
| + const change = benchmark.distributionChange([7.75, 12.25, 11.5], [8.75, 6.25, 4.5]); | |
| expect(change.mean).toBeCloseTo(68.3 / 74.5); | |
| expect(change.confidenceInterval).toBeCloseTo(60.2 / 74.5); | |
| diff --git a/galata/test/galata/contents.spec.ts b/galata/test/galata/contents.spec.ts | |
| index 3502ef1bfb..77d6b8d2a5 100644 | |
| --- a/galata/test/galata/contents.spec.ts | |
| +++ b/galata/test/galata/contents.spec.ts | |
| @@ -10,10 +10,7 @@ import { expect, test } from '@jupyterlab/galata'; | |
| test.describe('Contents API Tests', () => { | |
| test('Upload directory to server', async ({ page, tmpPath }) => { | |
| - await page.contents.uploadDirectory( | |
| - path.resolve(__dirname, './upload'), | |
| - tmpPath | |
| - ); | |
| + await page.contents.uploadDirectory(path.resolve(__dirname, './upload'), tmpPath); | |
| // Upload removed existing tmpPath, so we need to get inside | |
| await page.dblclick(`text=${tmpPath}`); | |
| @@ -32,15 +29,15 @@ test.describe('Contents API Tests', () => { | |
| `${tmpPath}/upload_image.png`, | |
| `${tmpPath}/renamed_image.png` | |
| ); | |
| - expect( | |
| - await page.contents.fileExists(`${tmpPath}/renamed_image.png`) | |
| - ).toEqual(true); | |
| + expect(await page.contents.fileExists(`${tmpPath}/renamed_image.png`)).toEqual( | |
| + true | |
| + ); | |
| await page.filebrowser.openDirectory(tmpPath); | |
| expect(await page.filebrowser.getCurrentDirectory()).toEqual(tmpPath); | |
| - expect( | |
| - await page.contents.deleteFile(`${tmpPath}/renamed_image.png`) | |
| - ).toEqual(true); | |
| + expect(await page.contents.deleteFile(`${tmpPath}/renamed_image.png`)).toEqual( | |
| + true | |
| + ); | |
| }); | |
| test('Go to home directory', async ({ page }) => { | |
| @@ -48,22 +45,19 @@ test.describe('Contents API Tests', () => { | |
| }); | |
| test('File Explorer visibility', async ({ page, tmpPath }) => { | |
| - await page.contents.uploadDirectory( | |
| - path.resolve(__dirname, './upload'), | |
| - tmpPath | |
| - ); | |
| + await page.contents.uploadDirectory(path.resolve(__dirname, './upload'), tmpPath); | |
| await page.contents.deleteFile(`${tmpPath}/upload_image.png`); | |
| - expect( | |
| - await page.filebrowser.isFileListedInBrowser('upload_image.png') | |
| - ).toEqual(false); | |
| + expect(await page.filebrowser.isFileListedInBrowser('upload_image.png')).toEqual( | |
| + false | |
| + ); | |
| await page.filebrowser.revealFileInBrowser( | |
| `${tmpPath}/sub_folder/upload_image.png` | |
| ); | |
| - expect( | |
| - await page.filebrowser.isFileListedInBrowser('upload_image.png') | |
| - ).toEqual(true); | |
| + expect(await page.filebrowser.isFileListedInBrowser('upload_image.png')).toEqual( | |
| + true | |
| + ); | |
| }); | |
| test('Delete uploads', async ({ page, tmpPath }) => { | |
| @@ -72,11 +66,9 @@ test.describe('Contents API Tests', () => { | |
| `${tmpPath}/sub_dir/notebook.ipynb` | |
| ); | |
| - expect( | |
| - await page.contents.deleteFile(`${tmpPath}/sub_dir/notebook.ipynb`) | |
| - ).toEqual(true); | |
| - expect(await page.contents.deleteDirectory(`${tmpPath}/sub_dir`)).toEqual( | |
| + expect(await page.contents.deleteFile(`${tmpPath}/sub_dir/notebook.ipynb`)).toEqual( | |
| true | |
| ); | |
| + expect(await page.contents.deleteDirectory(`${tmpPath}/sub_dir`)).toEqual(true); | |
| }); | |
| }); | |
| diff --git a/galata/test/galata/filebrowser.spec.ts b/galata/test/galata/filebrowser.spec.ts | |
| index 707e6fac02..13cc2fea03 100644 | |
| --- a/galata/test/galata/filebrowser.spec.ts | |
| +++ b/galata/test/galata/filebrowser.spec.ts | |
| @@ -54,10 +54,7 @@ test.describe('upload auto-open behavior', () => { | |
| await page.activity.closeAll(); | |
| }); | |
| - test('small notebook uploads and opens automatically', async ({ | |
| - page, | |
| - tmpPath | |
| - }) => { | |
| + test('small notebook uploads and opens automatically', async ({ page, tmpPath }) => { | |
| const nbName = 'small.ipynb'; | |
| const nbPath = path.join(tmpPath, nbName); | |
| fs.mkdirSync(tmpPath, { recursive: true }); | |
| diff --git a/galata/test/galata/fixture.spec.ts b/galata/test/galata/fixture.spec.ts | |
| index 5cb3d622a8..1148d2cad3 100644 | |
| --- a/galata/test/galata/fixture.spec.ts | |
| +++ b/galata/test/galata/fixture.spec.ts | |
| @@ -98,9 +98,7 @@ test.describe('mockState', () => { | |
| test('should return the mocked state', async ({ page }) => { | |
| expect( | |
| - await page.locator( | |
| - '[aria-label="Running Sessions section"] >> text=Open Tabs' | |
| - ) | |
| + await page.locator('[aria-label="Running Sessions section"] >> text=Open Tabs') | |
| ).toBeTruthy(); | |
| }); | |
| }); | |
| @@ -110,9 +108,7 @@ test.describe('kernels', () => { | |
| await page.notebook.createNew(); | |
| await page.locator('text= | Idle').waitFor(); | |
| - await page | |
| - .getByRole('tab', { name: 'Running Terminals and Kernels' }) | |
| - .click(); | |
| + await page.getByRole('tab', { name: 'Running Terminals and Kernels' }).click(); | |
| await Promise.all([ | |
| page.waitForResponse( | |
| diff --git a/galata/test/galata/jupyterlabpage.spec.ts b/galata/test/galata/jupyterlabpage.spec.ts | |
| index 6ccb22de1a..3352b6608c 100644 | |
| --- a/galata/test/galata/jupyterlabpage.spec.ts | |
| +++ b/galata/test/galata/jupyterlabpage.spec.ts | |
| @@ -14,9 +14,7 @@ test.describe('appPath', () => { | |
| }); | |
| test('should goto the application page and load hook', async ({ page }) => { | |
| - expect(await page.evaluate(() => typeof window.galata === 'object')).toEqual( | |
| - true | |
| - ); | |
| + expect(await page.evaluate(() => typeof window.galata === 'object')).toEqual(true); | |
| }); | |
| test('should test if the application is in simple mode', async ({ page }) => { | |
| @@ -26,9 +24,7 @@ test('should test if the application is in simple mode', async ({ page }) => { | |
| test('should reload the application page and load hook', async ({ page }) => { | |
| await page.reload(); | |
| - expect(await page.evaluate(() => typeof window.galata === 'object')).toEqual( | |
| - true | |
| - ); | |
| + expect(await page.evaluate(() => typeof window.galata === 'object')).toEqual(true); | |
| }); | |
| test('should reset the UI', async ({ page }) => { | |
| @@ -138,10 +134,9 @@ test.describe('listeners', () => { | |
| // the toast is not yet displayed and won't be removed when the notification | |
| // is dismissed. | |
| setTimeout(() => { | |
| - void window.jupyterapp.commands.execute( | |
| - 'apputils:dismiss-notification', | |
| - { id: n.id } | |
| - ); | |
| + void window.jupyterapp.commands.execute('apputils:dismiss-notification', { | |
| + id: n.id | |
| + }); | |
| }, 100); | |
| }); | |
| }); | |
| @@ -165,10 +160,9 @@ test.describe('listeners', () => { | |
| // the toast is not yet displayed and won't be removed when the notification | |
| // is dismissed. | |
| setTimeout(() => { | |
| - void window.jupyterapp.commands.execute( | |
| - 'apputils:dismiss-notification', | |
| - { id: n.id } | |
| - ); | |
| + void window.jupyterapp.commands.execute('apputils:dismiss-notification', { | |
| + id: n.id | |
| + }); | |
| }, 100); | |
| window.galata.off('notification', callback); | |
| }; | |
| @@ -200,19 +194,16 @@ test.describe('listeners', () => { | |
| await expect(page.locator('.Toastify__toast')).toHaveCount(1); | |
| }); | |
| - test('should listen only once to JupyterLab notification', async ({ | |
| - page | |
| - }) => { | |
| + test('should listen only once to JupyterLab notification', async ({ page }) => { | |
| await page.evaluate(() => { | |
| const callback = n => { | |
| // We need to slightly wait before dismissing otherwise | |
| // the toast is not yet displayed and won't be removed when the notification | |
| // is dismissed. | |
| setTimeout(() => { | |
| - void window.jupyterapp.commands.execute( | |
| - 'apputils:dismiss-notification', | |
| - { id: n.id } | |
| - ); | |
| + void window.jupyterapp.commands.execute('apputils:dismiss-notification', { | |
| + id: n.id | |
| + }); | |
| }, 100); | |
| }; | |
| window.galata.once('notification', callback); | |
| diff --git a/galata/test/galata/notebook.spec.ts b/galata/test/galata/notebook.spec.ts | |
| index 49ad80b6ff..30e7066cfa 100644 | |
| --- a/galata/test/galata/notebook.spec.ts | |
| +++ b/galata/test/galata/notebook.spec.ts | |
| @@ -14,33 +14,24 @@ test.describe('Notebook Tests', () => { | |
| await page.notebook.createNew(fileName); | |
| await page.getByRole('main').getByText(fileName).waitFor(); | |
| - expect(await page.contents.fileExists(`${tmpPath}/${fileName}`)).toEqual( | |
| - true | |
| - ); | |
| + expect(await page.contents.fileExists(`${tmpPath}/${fileName}`)).toEqual(true); | |
| }); | |
| test('Create New Notebook with kernel', async ({ page, tmpPath }) => { | |
| const fileName = 'create_kernel_test.ipynb'; | |
| await page.notebook.createNew(fileName, { kernel: 'python3' }); | |
| await page.getByRole('main').getByText(fileName).waitFor(); | |
| - expect(await page.contents.fileExists(`${tmpPath}/${fileName}`)).toEqual( | |
| - true | |
| - ); | |
| + expect(await page.contents.fileExists(`${tmpPath}/${fileName}`)).toEqual(true); | |
| const toolbar = page.getByRole('toolbar', { name: 'main area toolbar' }); | |
| await expect(toolbar.getByText('Python 3 (ipykernel)')).toBeVisible(); | |
| }); | |
| - test('Create New Notebook with kernel - no kernel', async ({ | |
| - page, | |
| - tmpPath | |
| - }) => { | |
| + test('Create New Notebook with kernel - no kernel', async ({ page, tmpPath }) => { | |
| const fileName = 'create_no_kernel_test.ipynb'; | |
| await page.notebook.createNew(fileName, { kernel: null }); | |
| await page.getByRole('main').getByText(fileName).waitFor(); | |
| - expect(await page.contents.fileExists(`${tmpPath}/${fileName}`)).toEqual( | |
| - true | |
| - ); | |
| + expect(await page.contents.fileExists(`${tmpPath}/${fileName}`)).toEqual(true); | |
| const toolbar = page.getByRole('toolbar', { name: 'main area toolbar' }); | |
| await expect(toolbar.getByText('No Kernel')).toBeVisible(); | |
| }); | |
| @@ -51,9 +42,7 @@ test.describe('Notebook Tests', () => { | |
| await page.notebook.setCell(0, 'markdown', '## This is a markdown cell'); | |
| expect(await page.notebook.getCellCount()).toBe(1); | |
| expect(await page.notebook.getCellType(0)).toBe('markdown'); | |
| - expect(await page.notebook.getCellTextInput(0)).toBe( | |
| - '## This is a markdown cell' | |
| - ); | |
| + expect(await page.notebook.getCellTextInput(0)).toBe('## This is a markdown cell'); | |
| expect(await page.locator('.jp-Notebook').screenshot()).toMatchSnapshot( | |
| 'markdown-cell.png' | |
| @@ -121,9 +110,7 @@ test.describe('Notebook Tests', () => { | |
| await page.notebook.save(); | |
| await expect(notSavedIndicator).toHaveCount(0); | |
| - expect(await tabList.screenshot()).toMatchSnapshot( | |
| - 'notebook-tab-saved.png' | |
| - ); | |
| + expect(await tabList.screenshot()).toMatchSnapshot('notebook-tab-saved.png'); | |
| }); | |
| test('Open and run cell by cell', async ({ page, tmpPath }) => { | |
| diff --git a/galata/test/jupyterlab/announcements.test.ts b/galata/test/jupyterlab/announcements.test.ts | |
| index 1787863c9b..b4d280e4b3 100644 | |
| --- a/galata/test/jupyterlab/announcements.test.ts | |
| +++ b/galata/test/jupyterlab/announcements.test.ts | |
| @@ -20,9 +20,7 @@ test('Announcements requires user agreement', async ({ page }) => { | |
| 'Would you like to get notified about official Jupyter news?' | |
| ); | |
| expect(notifications[0].options.actions).toHaveLength(3); | |
| - expect(notifications[0].options.actions[0].label).toEqual( | |
| - 'Open privacy policy' | |
| - ); | |
| + expect(notifications[0].options.actions[0].label).toEqual('Open privacy policy'); | |
| }); | |
| test.describe('Update available', () => { | |
| @@ -187,13 +185,9 @@ test.describe('Fetch news', () => { | |
| const notifications = await page.notifications; | |
| - const news = notifications.filter(n => | |
| - n.options?.data?.tags?.includes('news') | |
| - ); | |
| + const news = notifications.filter(n => n.options?.data?.tags?.includes('news')); | |
| expect(news).toHaveLength(2); | |
| - expect(news.filter(n => n.options.data.id === id)[0].message).toEqual( | |
| - message | |
| - ); | |
| + expect(news.filter(n => n.options.data.id === id)[0].message).toEqual(message); | |
| expect( | |
| news.filter(n => n.options.data.id === id)[0].options.actions[1].label | |
| ).toEqual(actionLabel); | |
| @@ -214,9 +208,7 @@ test.describe('Fetch news', () => { | |
| const notifications = await page.notifications; | |
| - const news = notifications.filter(n => | |
| - n.options?.data?.tags?.includes('news') | |
| - ); | |
| + const news = notifications.filter(n => n.options?.data?.tags?.includes('news')); | |
| expect(news).toHaveLength(0); | |
| }); | |
| @@ -241,9 +233,7 @@ test.describe('Fetch news', () => { | |
| const notifications = await page.notifications; | |
| - const news = notifications.filter(n => | |
| - n.options?.data?.tags?.includes('news') | |
| - ); | |
| + const news = notifications.filter(n => n.options?.data?.tags?.includes('news')); | |
| expect(news).toHaveLength(1); | |
| expect(news[0].id).not.toEqual(id); | |
| }); | |
| diff --git a/galata/test/jupyterlab/cells-motion.spec.ts b/galata/test/jupyterlab/cells-motion.spec.ts | |
| index 10247fdcb6..261d5f8cad 100644 | |
| --- a/galata/test/jupyterlab/cells-motion.spec.ts | |
| +++ b/galata/test/jupyterlab/cells-motion.spec.ts | |
| @@ -21,150 +21,98 @@ test.beforeEach(async ({ page }) => { | |
| }); | |
| test('Move down a cell', async ({ page }) => { | |
| - const content = await page | |
| - .locator(`${cellSelector} >> nth=2`) | |
| - .allTextContents(); | |
| - await page | |
| - .locator(`${cellSelector} >> nth=2 >> .jp-InputArea-prompt`) | |
| - .click(); | |
| + const content = await page.locator(`${cellSelector} >> nth=2`).allTextContents(); | |
| + await page.locator(`${cellSelector} >> nth=2 >> .jp-InputArea-prompt`).click(); | |
| await page.keyboard.press('Control+Shift+ArrowDown'); | |
| - await expect(page.locator(`${cellSelector} >> nth=3`)).toHaveClass( | |
| - /jp-mod-active/ | |
| + await expect(page.locator(`${cellSelector} >> nth=3`)).toHaveClass(/jp-mod-active/); | |
| + expect(await page.locator(`${cellSelector} >> nth=3`).allTextContents()).toEqual( | |
| + content | |
| ); | |
| - expect( | |
| - await page.locator(`${cellSelector} >> nth=3`).allTextContents() | |
| - ).toEqual(content); | |
| }); | |
| test('Move up a cell', async ({ page }) => { | |
| - const content = await page | |
| - .locator(`${cellSelector} >> nth=2`) | |
| - .allTextContents(); | |
| - await page | |
| - .locator(`${cellSelector} >> nth=2 >> .jp-InputArea-prompt`) | |
| - .click(); | |
| + const content = await page.locator(`${cellSelector} >> nth=2`).allTextContents(); | |
| + await page.locator(`${cellSelector} >> nth=2 >> .jp-InputArea-prompt`).click(); | |
| await page.keyboard.press('Control+Shift+ArrowUp'); | |
| - await expect(page.locator(`${cellSelector} >> nth=1`)).toHaveClass( | |
| - /jp-mod-active/ | |
| + await expect(page.locator(`${cellSelector} >> nth=1`)).toHaveClass(/jp-mod-active/); | |
| + expect(await page.locator(`${cellSelector} >> nth=1`).allTextContents()).toEqual( | |
| + content | |
| ); | |
| - expect( | |
| - await page.locator(`${cellSelector} >> nth=1`).allTextContents() | |
| - ).toEqual(content); | |
| }); | |
| test('Move down two cells with first active', async ({ page }) => { | |
| - const content1 = await page | |
| - .locator(`${cellSelector} >> nth=2`) | |
| - .allTextContents(); | |
| - const content2 = await page | |
| - .locator(`${cellSelector} >> nth=3`) | |
| - .allTextContents(); | |
| + const content1 = await page.locator(`${cellSelector} >> nth=2`).allTextContents(); | |
| + const content2 = await page.locator(`${cellSelector} >> nth=3`).allTextContents(); | |
| - await page | |
| - .locator(`${cellSelector} >> nth=3 >> .jp-InputArea-prompt`) | |
| - .click(); | |
| + await page.locator(`${cellSelector} >> nth=3 >> .jp-InputArea-prompt`).click(); | |
| await page.keyboard.press('Shift+ArrowUp'); | |
| await page.keyboard.press('Control+Shift+ArrowDown'); | |
| - await expect(page.locator(`${cellSelector} >> nth=3`)).toHaveClass( | |
| - /jp-mod-active/ | |
| + await expect(page.locator(`${cellSelector} >> nth=3`)).toHaveClass(/jp-mod-active/); | |
| + await expect(page.locator(`${cellSelector} >> nth=4`)).toHaveClass(/jp-mod-selected/); | |
| + expect(await page.locator(`${cellSelector} >> nth=3`).allTextContents()).toEqual( | |
| + content1 | |
| ); | |
| - await expect(page.locator(`${cellSelector} >> nth=4`)).toHaveClass( | |
| - /jp-mod-selected/ | |
| + expect(await page.locator(`${cellSelector} >> nth=4`).allTextContents()).toEqual( | |
| + content2 | |
| ); | |
| - expect( | |
| - await page.locator(`${cellSelector} >> nth=3`).allTextContents() | |
| - ).toEqual(content1); | |
| - expect( | |
| - await page.locator(`${cellSelector} >> nth=4`).allTextContents() | |
| - ).toEqual(content2); | |
| }); | |
| test('Move up two cells with first active', async ({ page }) => { | |
| - const content1 = await page | |
| - .locator(`${cellSelector} >> nth=2`) | |
| - .allTextContents(); | |
| - const content2 = await page | |
| - .locator(`${cellSelector} >> nth=3`) | |
| - .allTextContents(); | |
| + const content1 = await page.locator(`${cellSelector} >> nth=2`).allTextContents(); | |
| + const content2 = await page.locator(`${cellSelector} >> nth=3`).allTextContents(); | |
| - await page | |
| - .locator(`${cellSelector} >> nth=3 >> .jp-InputArea-prompt`) | |
| - .click(); | |
| + await page.locator(`${cellSelector} >> nth=3 >> .jp-InputArea-prompt`).click(); | |
| await page.keyboard.press('Shift+ArrowUp'); | |
| await page.keyboard.press('Control+Shift+ArrowUp'); | |
| - await expect(page.locator(`${cellSelector} >> nth=1`)).toHaveClass( | |
| - /jp-mod-active/ | |
| + await expect(page.locator(`${cellSelector} >> nth=1`)).toHaveClass(/jp-mod-active/); | |
| + await expect(page.locator(`${cellSelector} >> nth=2`)).toHaveClass(/jp-mod-selected/); | |
| + expect(await page.locator(`${cellSelector} >> nth=1`).allTextContents()).toEqual( | |
| + content1 | |
| ); | |
| - await expect(page.locator(`${cellSelector} >> nth=2`)).toHaveClass( | |
| - /jp-mod-selected/ | |
| + expect(await page.locator(`${cellSelector} >> nth=2`).allTextContents()).toEqual( | |
| + content2 | |
| ); | |
| - expect( | |
| - await page.locator(`${cellSelector} >> nth=1`).allTextContents() | |
| - ).toEqual(content1); | |
| - expect( | |
| - await page.locator(`${cellSelector} >> nth=2`).allTextContents() | |
| - ).toEqual(content2); | |
| }); | |
| test('Move down two cells with last active', async ({ page }) => { | |
| - const content1 = await page | |
| - .locator(`${cellSelector} >> nth=2`) | |
| - .allTextContents(); | |
| - const content2 = await page | |
| - .locator(`${cellSelector} >> nth=3`) | |
| - .allTextContents(); | |
| - | |
| - await page | |
| - .locator(`${cellSelector} >> nth=2 >> .jp-InputArea-prompt`) | |
| - .click(); | |
| + const content1 = await page.locator(`${cellSelector} >> nth=2`).allTextContents(); | |
| + const content2 = await page.locator(`${cellSelector} >> nth=3`).allTextContents(); | |
| + | |
| + await page.locator(`${cellSelector} >> nth=2 >> .jp-InputArea-prompt`).click(); | |
| await page.keyboard.press('Shift+ArrowDown'); | |
| await page.keyboard.press('Control+Shift+ArrowDown'); | |
| - await expect(page.locator(`${cellSelector} >> nth=3`)).toHaveClass( | |
| - /jp-mod-selected/ | |
| + await expect(page.locator(`${cellSelector} >> nth=3`)).toHaveClass(/jp-mod-selected/); | |
| + await expect(page.locator(`${cellSelector} >> nth=4`)).toHaveClass(/jp-mod-active/); | |
| + expect(await page.locator(`${cellSelector} >> nth=3`).allTextContents()).toEqual( | |
| + content1 | |
| ); | |
| - await expect(page.locator(`${cellSelector} >> nth=4`)).toHaveClass( | |
| - /jp-mod-active/ | |
| + expect(await page.locator(`${cellSelector} >> nth=4`).allTextContents()).toEqual( | |
| + content2 | |
| ); | |
| - expect( | |
| - await page.locator(`${cellSelector} >> nth=3`).allTextContents() | |
| - ).toEqual(content1); | |
| - expect( | |
| - await page.locator(`${cellSelector} >> nth=4`).allTextContents() | |
| - ).toEqual(content2); | |
| }); | |
| test('Move up two cells with last active', async ({ page }) => { | |
| - const content1 = await page | |
| - .locator(`${cellSelector} >> nth=2`) | |
| - .allTextContents(); | |
| - const content2 = await page | |
| - .locator(`${cellSelector} >> nth=3`) | |
| - .allTextContents(); | |
| - await page | |
| - .locator(`${cellSelector} >> nth=2 >> .jp-InputArea-prompt`) | |
| - .click(); | |
| + const content1 = await page.locator(`${cellSelector} >> nth=2`).allTextContents(); | |
| + const content2 = await page.locator(`${cellSelector} >> nth=3`).allTextContents(); | |
| + await page.locator(`${cellSelector} >> nth=2 >> .jp-InputArea-prompt`).click(); | |
| await page.keyboard.press('Shift+ArrowDown'); | |
| await page.keyboard.press('Control+Shift+ArrowDown'); | |
| - await expect(page.locator(`${cellSelector} >> nth=3`)).toHaveClass( | |
| - /jp-mod-selected/ | |
| + await expect(page.locator(`${cellSelector} >> nth=3`)).toHaveClass(/jp-mod-selected/); | |
| + await expect(page.locator(`${cellSelector} >> nth=4`)).toHaveClass(/jp-mod-active/); | |
| + expect(await page.locator(`${cellSelector} >> nth=3`).allTextContents()).toEqual( | |
| + content1 | |
| ); | |
| - await expect(page.locator(`${cellSelector} >> nth=4`)).toHaveClass( | |
| - /jp-mod-active/ | |
| + expect(await page.locator(`${cellSelector} >> nth=4`).allTextContents()).toEqual( | |
| + content2 | |
| ); | |
| - expect( | |
| - await page.locator(`${cellSelector} >> nth=3`).allTextContents() | |
| - ).toEqual(content1); | |
| - expect( | |
| - await page.locator(`${cellSelector} >> nth=4`).allTextContents() | |
| - ).toEqual(content2); | |
| }); | |
| diff --git a/galata/test/jupyterlab/cells.test.ts b/galata/test/jupyterlab/cells.test.ts | |
| index 24fe88632f..685d6b1ef3 100644 | |
| --- a/galata/test/jupyterlab/cells.test.ts | |
| +++ b/galata/test/jupyterlab/cells.test.ts | |
| @@ -85,9 +85,7 @@ test.describe('Cell Toolbar Delete', () => { | |
| await page.notebook.selectCells(0); | |
| }); | |
| - test('should show confirmation dialog and cancel deletion', async ({ | |
| - page | |
| - }) => { | |
| + test('should show confirmation dialog and cancel deletion', async ({ page }) => { | |
| await page.hover('.jp-Cell >> nth=0'); | |
| await page | |
| @@ -98,9 +96,7 @@ test.describe('Cell Toolbar Delete', () => { | |
| // Verify dialog appears | |
| const dialog = page.locator('.jp-Dialog'); | |
| await expect(dialog).toBeVisible(); | |
| - await expect(dialog).toContainText( | |
| - 'Are you sure you want to delete this cell?' | |
| - ); | |
| + await expect(dialog).toContainText('Are you sure you want to delete this cell?'); | |
| await dialog.locator('button.jp-mod-reject').click(); | |
| diff --git a/galata/test/jupyterlab/codemirror.test.ts b/galata/test/jupyterlab/codemirror.test.ts | |
| index 5b422f12f7..db14ef97b3 100644 | |
| --- a/galata/test/jupyterlab/codemirror.test.ts | |
| +++ b/galata/test/jupyterlab/codemirror.test.ts | |
| @@ -80,9 +80,7 @@ test.describe('Code Folding Menu', () => { | |
| await cellEditor | |
| .locator('span[title="unfold"]') | |
| .waitFor({ state: 'visible', timeout: 5000 }); | |
| - const unfoldCount = await cellEditor | |
| - .locator('span[title="unfold"]') | |
| - .count(); | |
| + const unfoldCount = await cellEditor.locator('span[title="unfold"]').count(); | |
| expect(unfoldCount).toBe(1); | |
| // Verify that there are still multiple lines | |
| @@ -95,9 +93,7 @@ test.describe('Code Folding Menu', () => { | |
| await cellEditor | |
| .locator('span[title="unfold"]') | |
| .waitFor({ state: 'detached', timeout: 5000 }); | |
| - const unfoldCountAfter = await cellEditor | |
| - .locator('span[title="unfold"]') | |
| - .count(); | |
| + const unfoldCountAfter = await cellEditor.locator('span[title="unfold"]').count(); | |
| expect(unfoldCountAfter).toBe(0); | |
| const finalLineCount = await cellEditor.locator('.cm-line').count(); | |
| expect(finalLineCount).toBe(initialLineCount); | |
| @@ -123,16 +119,12 @@ test.describe('Code Folding Menu', () => { | |
| .waitFor({ state: 'visible', timeout: 5000 }); | |
| // Count unfold spans - 2 (if and else block) | |
| - const unfoldCount = await cellEditor | |
| - .locator('span[title="unfold"]') | |
| - .count(); | |
| + const unfoldCount = await cellEditor.locator('span[title="unfold"]').count(); | |
| expect(unfoldCount).toBe(2); | |
| // Unfold all subregions | |
| await page.menu.clickMenuItem('View>Code Folding>Unfold All Subregions'); | |
| - const unfoldCountAfter = await cellEditor | |
| - .locator('span[title="unfold"]') | |
| - .count(); | |
| + const unfoldCountAfter = await cellEditor.locator('span[title="unfold"]').count(); | |
| expect(unfoldCountAfter).toBe(0); | |
| }); | |
| @@ -156,16 +148,12 @@ test.describe('Code Folding Menu', () => { | |
| const visibleLineCount = await cellEditor.locator('.cm-line').count(); | |
| expect(visibleLineCount).toBe(5); | |
| - const unfoldCount = await cellEditor | |
| - .locator('span[title="unfold"]') | |
| - .count(); | |
| + const unfoldCount = await cellEditor.locator('span[title="unfold"]').count(); | |
| expect(unfoldCount).toBe(2); | |
| // Unfold all | |
| await page.menu.clickMenuItem('View>Code Folding>Unfold All Regions'); | |
| - const unfoldCountAfter = await cellEditor | |
| - .locator('span[title="unfold"]') | |
| - .count(); | |
| + const unfoldCountAfter = await cellEditor.locator('span[title="unfold"]').count(); | |
| expect(unfoldCountAfter).toBe(0); | |
| const finalLineCount = await cellEditor.locator('.cm-line').count(); | |
| expect(finalLineCount).toBe(initialLineCount); | |
| diff --git a/galata/test/jupyterlab/collapsible-headings.test.ts b/galata/test/jupyterlab/collapsible-headings.test.ts | |
| index 41da268f23..1e9659cd01 100644 | |
| --- a/galata/test/jupyterlab/collapsible-headings.test.ts | |
| +++ b/galata/test/jupyterlab/collapsible-headings.test.ts | |
| @@ -22,23 +22,21 @@ test.describe('Collapsible Headings; showHCB', () => { | |
| }); | |
| test('Show Collapser Unselected; showHCB', async ({ page }) => { | |
| - expect( | |
| - await (await page.notebook.getCellLocator(0))!.screenshot() | |
| - ).toMatchSnapshot('showHCB_heading_unselected.png'); | |
| + expect(await (await page.notebook.getCellLocator(0))!.screenshot()).toMatchSnapshot( | |
| + 'showHCB_heading_unselected.png' | |
| + ); | |
| }); | |
| test('Show Collapser Selected; showHCB', async ({ page }) => { | |
| await page.notebook.selectCells(0); | |
| - expect( | |
| - await (await page.notebook.getCellLocator(0))!.screenshot() | |
| - ).toMatchSnapshot('showHCB_heading_selected.png'); | |
| + expect(await (await page.notebook.getCellLocator(0))!.screenshot()).toMatchSnapshot( | |
| + 'showHCB_heading_selected.png' | |
| + ); | |
| }); | |
| test('Collapse Heading; showHCB', async ({ page }) => { | |
| await page.notebook.selectCells(0); | |
| - await page.click( | |
| - 'text=# Heading 1Heading 1¶ >> button.jp-collapseHeadingButton' | |
| - ); | |
| + await page.click('text=# Heading 1Heading 1¶ >> button.jp-collapseHeadingButton'); | |
| expect( | |
| await (await page.notebook.getNotebookInPanelLocator())!.screenshot() | |
| ).toMatchSnapshot('showHCB_collapse_heading.png'); | |
| @@ -46,12 +44,8 @@ test.describe('Collapsible Headings; showHCB', () => { | |
| test('Expand Heading via Collapser Button; showHCB', async ({ page }) => { | |
| await page.notebook.selectCells(0); | |
| - await page.click( | |
| - 'text=# Heading 1Heading 1¶ >> button.jp-collapseHeadingButton' | |
| - ); | |
| - await page.click( | |
| - 'text=# Heading 1Heading 1¶ >> button.jp-collapseHeadingButton' | |
| - ); | |
| + await page.click('text=# Heading 1Heading 1¶ >> button.jp-collapseHeadingButton'); | |
| + await page.click('text=# Heading 1Heading 1¶ >> button.jp-collapseHeadingButton'); | |
| expect( | |
| await (await page.notebook.getNotebookInPanelLocator())!.screenshot() | |
| ).toMatchSnapshot('showHCB_expand_heading_via_collapser.png'); | |
| @@ -77,23 +71,21 @@ test.describe('Collapsible Headings; no_showHCB', () => { | |
| }); | |
| test('Show Collapser Unselected; no_showHCB', async ({ page }) => { | |
| - expect( | |
| - await (await page.notebook.getCellLocator(0))!.screenshot() | |
| - ).toMatchSnapshot('no_showHCB_heading_unselected.png'); | |
| + expect(await (await page.notebook.getCellLocator(0))!.screenshot()).toMatchSnapshot( | |
| + 'no_showHCB_heading_unselected.png' | |
| + ); | |
| }); | |
| test('Show Collapser Selected; no_showHCB', async ({ page }) => { | |
| await page.notebook.selectCells(0); | |
| - expect( | |
| - await (await page.notebook.getCellLocator(0))!.screenshot() | |
| - ).toMatchSnapshot('no_showHCB_heading_selected.png'); | |
| + expect(await (await page.notebook.getCellLocator(0))!.screenshot()).toMatchSnapshot( | |
| + 'no_showHCB_heading_selected.png' | |
| + ); | |
| }); | |
| test('Collapse Heading; no_showHCB', async ({ page }) => { | |
| await page.notebook.selectCells(0); | |
| - await page.click( | |
| - 'text=# Heading 1Heading 1¶ >> button.jp-collapseHeadingButton' | |
| - ); | |
| + await page.click('text=# Heading 1Heading 1¶ >> button.jp-collapseHeadingButton'); | |
| expect( | |
| await (await page.notebook.getNotebookInPanelLocator())!.screenshot() | |
| ).toMatchSnapshot('no_showHCB_collapse_heading.png'); | |
| @@ -101,20 +93,15 @@ test.describe('Collapsible Headings; no_showHCB', () => { | |
| test('Expand Heading via Collapser Button; no_showHCB', async ({ page }) => { | |
| await page.notebook.selectCells(0); | |
| - await page.click( | |
| - 'text=# Heading 1Heading 1¶ >> button.jp-collapseHeadingButton' | |
| - ); | |
| - await page.click( | |
| - 'text=# Heading 1Heading 1¶ >> button.jp-collapseHeadingButton' | |
| - ); | |
| + await page.click('text=# Heading 1Heading 1¶ >> button.jp-collapseHeadingButton'); | |
| + await page.click('text=# Heading 1Heading 1¶ >> button.jp-collapseHeadingButton'); | |
| expect( | |
| await (await page.notebook.getNotebookInPanelLocator())!.screenshot() | |
| ).toMatchSnapshot('no_showHCB_expand_heading_via_collapser.png'); | |
| }); | |
| }); | |
| -const keyboardNavigationNotebook = | |
| - 'collapsible_headings_keyboard_navigation.ipynb'; | |
| +const keyboardNavigationNotebook = 'collapsible_headings_keyboard_navigation.ipynb'; | |
| test.describe('Collapsible Headings; keyboard navigation', () => { | |
| test.use({ tmpPath: 'test-collapsible-headings-keyboard' }); | |
| diff --git a/galata/test/jupyterlab/completer.test.ts b/galata/test/jupyterlab/completer.test.ts | |
| index a6170152f4..e35a5c53f0 100644 | |
| --- a/galata/test/jupyterlab/completer.test.ts | |
| +++ b/galata/test/jupyterlab/completer.test.ts | |
| @@ -13,9 +13,7 @@ test.describe('Completer', () => { | |
| await page.notebook.createNew(fileName); | |
| }); | |
| - test('Open completer on notebook and accept suggestion', async ({ | |
| - page | |
| - }) => { | |
| + test('Open completer on notebook and accept suggestion', async ({ page }) => { | |
| await page.notebook.setCell( | |
| 0, | |
| 'code', | |
| @@ -100,9 +98,7 @@ test.describe('Completer', () => { | |
| await page.keyboard.press('Tab'); | |
| completer = page.locator(COMPLETER_SELECTOR); | |
| await completer.waitFor(); | |
| - await page | |
| - .locator('.jp-Completer-loading-bar') | |
| - .waitFor({ state: 'detached' }); | |
| + await page.locator('.jp-Completer-loading-bar').waitFor({ state: 'detached' }); | |
| await session?.detach(); | |
| const imageName = 'completer-with-doc-panel.png'; | |
| expect(await completer.screenshot()).toMatchSnapshot(imageName); | |
| @@ -114,10 +110,7 @@ test.describe('Completer', () => { | |
| await page.notebook.setCell( | |
| 0, | |
| 'code', | |
| - 'option_1 = 1\n' + | |
| - 'option_2 = lambda x: x\n' + | |
| - 'option_3 = int\n' + | |
| - 'option' | |
| + 'option_1 = 1\n' + 'option_2 = lambda x: x\n' + 'option_3 = int\n' + 'option' | |
| ); | |
| await page.notebook.enterCellEditingMode(0); | |
| // move to the end of cell | |
| @@ -139,9 +132,7 @@ test.describe('Completer', () => { | |
| expect(await completer.screenshot()).toMatchSnapshot(imageName); | |
| }); | |
| - test('Filter notebook completer suggestions by typing', async ({ | |
| - page | |
| - }) => { | |
| + test('Filter notebook completer suggestions by typing', async ({ page }) => { | |
| // test against https://github.com/jupyterlab/jupyterlab/issues/11377 | |
| // `getopt` did not change much in many years, it should be stable | |
| diff --git a/galata/test/jupyterlab/console.test.ts b/galata/test/jupyterlab/console.test.ts | |
| index cb62afa26d..cd460e9679 100644 | |
| --- a/galata/test/jupyterlab/console.test.ts | |
| +++ b/galata/test/jupyterlab/console.test.ts | |
| @@ -72,9 +72,7 @@ test.describe('Console (terminal mode)', () => { | |
| test.describe('Console Input Auto-Resize', () => { | |
| test.beforeEach(async ({ page }) => setupConsole(page)); | |
| - test('Input prompt auto-resizes with multiple lines of text', async ({ | |
| - page | |
| - }) => { | |
| + test('Input prompt auto-resizes with multiple lines of text', async ({ page }) => { | |
| const codeConsoleInput = page.locator('.jp-CodeConsole-input'); | |
| const initialHeight = await codeConsoleInput.boundingBox(); | |
| @@ -92,9 +90,7 @@ return "Done"`; | |
| expect(afterTypingHeight!.height).toBeGreaterThan(initialHeight!.height); | |
| }); | |
| - test('Input prompt auto-resize works with paste operations', async ({ | |
| - page | |
| - }) => { | |
| + test('Input prompt auto-resize works with paste operations', async ({ page }) => { | |
| const codeConsoleInput = page.locator('.jp-CodeConsole-input'); | |
| const initialHeight = await codeConsoleInput.boundingBox(); | |
| @@ -170,9 +166,7 @@ print(data.head())`; | |
| const heightBeforeExecution = await codeConsoleInput.boundingBox(); | |
| expect(heightBeforeExecution).not.toBeNull(); | |
| - expect(heightBeforeExecution!.height).toBeGreaterThan( | |
| - initialHeight!.height | |
| - ); | |
| + expect(heightBeforeExecution!.height).toBeGreaterThan(initialHeight!.height); | |
| // Execute the code | |
| await page.keyboard.press('Shift+Enter'); | |
| @@ -196,9 +190,7 @@ print("After execution")`; | |
| expect(heightAfterTyping).not.toBeNull(); | |
| // The input should have grown again for the new multi-line content | |
| - expect(heightAfterTyping!.height).toBeGreaterThan( | |
| - heightAfterExecution!.height | |
| - ); | |
| + expect(heightAfterTyping!.height).toBeGreaterThan(heightAfterExecution!.height); | |
| }); | |
| test('Input prompt shrinks when content is cleared', async ({ page }) => { | |
| diff --git a/galata/test/jupyterlab/contextmenu.test.ts b/galata/test/jupyterlab/contextmenu.test.ts | |
| index 898d347887..de5e4023c0 100644 | |
| --- a/galata/test/jupyterlab/contextmenu.test.ts | |
| +++ b/galata/test/jupyterlab/contextmenu.test.ts | |
| @@ -84,9 +84,9 @@ test.describe('Application Context Menu', () => { | |
| }) => { | |
| await page.notebook.openByPath(`${tmpPath}/${testNotebook}`); | |
| // Wait for kernel to be idle | |
| - await expect( | |
| - page.locator(`#jp-main-statusbar >> text=Idle`).first() | |
| - ).toHaveCount(1); | |
| + await expect(page.locator(`#jp-main-statusbar >> text=Idle`).first()).toHaveCount( | |
| + 1 | |
| + ); | |
| await page.click(`.jp-DirListing-item span:has-text("${testNotebook}")`, { | |
| button: 'right' | |
| @@ -110,9 +110,7 @@ test.describe('Application Context Menu', () => { | |
| expect(await page.menu.isAnyOpen()).toBe(true); | |
| await page.hover('text=Open With'); | |
| - await page | |
| - .locator('.lm-Menu li[role="menuitem"]:has-text("Editor")') | |
| - .waitFor(); | |
| + await page.locator('.lm-Menu li[role="menuitem"]:has-text("Editor")').waitFor(); | |
| const imageName = `file-openwith.png`; | |
| // Get the last menu -> will be submenu | |
| diff --git a/galata/test/jupyterlab/debugger-console.test.ts b/galata/test/jupyterlab/debugger-console.test.ts | |
| index c2f07bca27..ff88507e9c 100644 | |
| --- a/galata/test/jupyterlab/debugger-console.test.ts | |
| +++ b/galata/test/jupyterlab/debugger-console.test.ts | |
| @@ -11,10 +11,7 @@ const DEBUG_CONSOLE_WIDGET_SELECTOR = '.jp-DebugConsole-widget'; | |
| const fileName = 'debugger_console.ipynb'; | |
| -async function setupDebuggerConsole( | |
| - page: IJupyterLabPageFixture, | |
| - tmpPath: string | |
| -) { | |
| +async function setupDebuggerConsole(page: IJupyterLabPageFixture, tmpPath: string) { | |
| // Open a notebook which has code setting variables to debug | |
| await page.notebook.openByPath(`${tmpPath}/${fileName}`); | |
| @@ -97,9 +94,7 @@ test.describe('Debugger Console', () => { | |
| } | |
| }); | |
| - test('Debug console toggles when evaluate button is clicked', async ({ | |
| - page | |
| - }) => { | |
| + test('Debug console toggles when evaluate button is clicked', async ({ page }) => { | |
| // Verify debug console is visible (already opened by setupDebuggerConsole) | |
| const debugConsole = page.locator(DEBUG_CONSOLE_SELECTOR); | |
| await expect(debugConsole).toBeVisible(); | |
| @@ -123,9 +118,7 @@ test.describe('Debugger Console', () => { | |
| await expect(debugConsole).toBeVisible(); | |
| // Check that the debug console widget is present | |
| - const debugConsoleWidget = debugConsole.locator( | |
| - DEBUG_CONSOLE_WIDGET_SELECTOR | |
| - ); | |
| + const debugConsoleWidget = debugConsole.locator(DEBUG_CONSOLE_WIDGET_SELECTOR); | |
| await expect(debugConsoleWidget).toBeVisible(); | |
| // Verify the console has a prompt cell ready for input | |
| @@ -152,15 +145,11 @@ test.describe('Debugger Console', () => { | |
| await page.waitForTimeout(1000); | |
| // Check that the output shows the correct value (42) | |
| - const outputArea = debugConsoleWidget | |
| - .locator('.jp-OutputArea-child') | |
| - .last(); | |
| + const outputArea = debugConsoleWidget.locator('.jp-OutputArea-child').last(); | |
| await expect(outputArea).toContainText('42'); | |
| }); | |
| - test('Debug evaluation returns correct values for expressions', async ({ | |
| - page | |
| - }) => { | |
| + test('Debug evaluation returns correct values for expressions', async ({ page }) => { | |
| // Focus on the debug console input | |
| const debugConsoleWidget = page.locator(DEBUG_CONSOLE_WIDGET_SELECTOR); | |
| const promptCell = debugConsoleWidget.locator('.jp-CodeConsole-promptCell'); | |
| @@ -177,15 +166,11 @@ test.describe('Debugger Console', () => { | |
| await page.waitForTimeout(1000); | |
| // Check that the output shows the correct value (52) | |
| - const outputArea = debugConsoleWidget | |
| - .locator('.jp-OutputArea-child') | |
| - .last(); | |
| + const outputArea = debugConsoleWidget.locator('.jp-OutputArea-child').last(); | |
| await expect(outputArea).toContainText('52'); | |
| }); | |
| - test('Debug evaluation works with complex data structures', async ({ | |
| - page | |
| - }) => { | |
| + test('Debug evaluation works with complex data structures', async ({ page }) => { | |
| // Focus on the debug console input | |
| const debugConsoleWidget = page.locator(DEBUG_CONSOLE_WIDGET_SELECTOR); | |
| const promptCell = debugConsoleWidget.locator('.jp-CodeConsole-promptCell'); | |
| @@ -202,9 +187,7 @@ test.describe('Debugger Console', () => { | |
| await page.waitForTimeout(1000); | |
| // Check that the output shows the list | |
| - const outputArea = debugConsoleWidget | |
| - .locator('.jp-OutputArea-child') | |
| - .last(); | |
| + const outputArea = debugConsoleWidget.locator('.jp-OutputArea-child').last(); | |
| await expect(outputArea).toContainText('[1, 2, 3, 4, 5]'); | |
| }); | |
| @@ -222,9 +205,7 @@ test.describe('Debugger Console', () => { | |
| await page.waitForTimeout(1000); | |
| // Find the visible completer and interact with it | |
| - const visibleCompleter = page | |
| - .locator('.jp-Completer:not(.lm-mod-hidden)') | |
| - .first(); | |
| + const visibleCompleter = page.locator('.jp-Completer:not(.lm-mod-hidden)').first(); | |
| await expect(visibleCompleter).toBeVisible(); | |
| // Verify completion suggestions include built-in functions | |
| @@ -257,9 +238,7 @@ test.describe('Debugger Console', () => { | |
| await page.waitForTimeout(1000); | |
| // Find the visible completer and interact with it | |
| - const visibleCompleter = page | |
| - .locator('.jp-Completer:not(.lm-mod-hidden)') | |
| - .first(); | |
| + const visibleCompleter = page.locator('.jp-Completer:not(.lm-mod-hidden)').first(); | |
| await expect(visibleCompleter).toBeVisible(); | |
| // Verify completion suggestions include local variables | |
| @@ -306,9 +285,7 @@ test.describe('Debugger Console', () => { | |
| await page.waitForTimeout(1000); | |
| // Check that the output shows the error message | |
| - const outputArea = debugConsoleWidget | |
| - .locator('.jp-OutputArea-child') | |
| - .last(); | |
| + const outputArea = debugConsoleWidget.locator('.jp-OutputArea-child').last(); | |
| await expect(outputArea).toContainText( | |
| 'Debugger does not have stopped threads - cannot evaluate' | |
| ); | |
| diff --git a/galata/test/jupyterlab/debugger.test.ts b/galata/test/jupyterlab/debugger.test.ts | |
| index 49d917f3dd..f7496c4044 100644 | |
| --- a/galata/test/jupyterlab/debugger.test.ts | |
| +++ b/galata/test/jupyterlab/debugger.test.ts | |
| @@ -15,9 +15,7 @@ async function openNotebook(page: IJupyterLabPageFixture, tmpPath, fileName) { | |
| test('Move Debugger to right', async ({ page }) => { | |
| await page.sidebar.moveTabToRight('jp-debugger-sidebar'); | |
| - expect(await page.sidebar.getTabPosition('jp-debugger-sidebar')).toBe( | |
| - 'right' | |
| - ); | |
| + expect(await page.sidebar.getTabPosition('jp-debugger-sidebar')).toBe('right'); | |
| }); | |
| test('Open Debugger on right', async ({ page }) => { | |
| @@ -131,9 +129,7 @@ test.describe('Debugger Tests', () => { | |
| }); | |
| const menu = await page.menu.getOpenMenuLocator(); | |
| - await menu | |
| - ?.getByRole('menuitem', { name: 'Create Console for Editor' }) | |
| - .click(); | |
| + await menu?.getByRole('menuitem', { name: 'Create Console for Editor' }).click(); | |
| await page.getByRole('dialog').waitFor(); | |
| const select = page.getByRole('dialog').getByRole('combobox'); | |
| @@ -232,9 +228,7 @@ test.describe('Debugger Variables', () => { | |
| }); | |
| // Request the copy of the local variable to globals scope. | |
| - await page | |
| - .getByRole('menuitem', { name: 'Copy Variable to Globals' }) | |
| - .click(); | |
| + await page.getByRole('menuitem', { name: 'Copy Variable to Globals' }).click(); | |
| // Wait for the request to be sent. | |
| await copyToGlobalsRequest.promise; | |
| @@ -253,10 +247,7 @@ test.describe('Debugger Variables', () => { | |
| await page.click('jp-button[title^=Continue]'); | |
| }); | |
| - test('Copy to globals not available from kernel', async ({ | |
| - page, | |
| - tmpPath | |
| - }) => { | |
| + test('Copy to globals not available from kernel', async ({ page, tmpPath }) => { | |
| await init({ page, tmpPath }); | |
| // Kernel doesn't support copyToGlobals. | |
| @@ -285,9 +276,9 @@ test.describe('Debugger Variables', () => { | |
| // Close the contextual menu | |
| await page.keyboard.press('Escape'); | |
| - await expect( | |
| - page.getByRole('menuitem', { name: 'Copy to Clipboard' }) | |
| - ).toHaveCount(0); | |
| + await expect(page.getByRole('menuitem', { name: 'Copy to Clipboard' })).toHaveCount( | |
| + 0 | |
| + ); | |
| await page.click('jp-button[title^=Continue]'); | |
| }); | |
| @@ -321,9 +312,9 @@ test.describe('Debugger Variables', () => { | |
| // Close the contextual menu | |
| await page.keyboard.press('Escape'); | |
| - await expect( | |
| - page.getByRole('menuitem', { name: 'Copy to Clipboard' }) | |
| - ).toHaveCount(0); | |
| + await expect(page.getByRole('menuitem', { name: 'Copy to Clipboard' })).toHaveCount( | |
| + 0 | |
| + ); | |
| await page.click('jp-button[title^=Continue]'); | |
| }); | |
| diff --git a/galata/test/jupyterlab/docmanager.test.ts b/galata/test/jupyterlab/docmanager.test.ts | |
| index 4e2d874f49..e5125b3ed7 100644 | |
| --- a/galata/test/jupyterlab/docmanager.test.ts | |
| +++ b/galata/test/jupyterlab/docmanager.test.ts | |
| @@ -12,9 +12,7 @@ test.beforeEach(async ({ page }) => { | |
| }); | |
| test.afterEach(async ({ page, tmpPath }) => { | |
| - if ( | |
| - await page.filebrowser.contents.fileExists(`${tmpPath}/${DEFAULT_NAME}`) | |
| - ) { | |
| + if (await page.filebrowser.contents.fileExists(`${tmpPath}/${DEFAULT_NAME}`)) { | |
| await page.filebrowser.contents.deleteFile(`${tmpPath}/${DEFAULT_NAME}`); | |
| } | |
| }); | |
| @@ -33,10 +31,7 @@ test('Should open the document and activate it by default', async ({ | |
| await expect(tab).toHaveClass(/jp-mod-active/); | |
| }); | |
| -test('Should open the document and not activate it', async ({ | |
| - page, | |
| - tmpPath | |
| -}) => { | |
| +test('Should open the document and not activate it', async ({ page, tmpPath }) => { | |
| await page.evaluate(async filename => { | |
| await window.jupyterapp.commands.execute('docmanager:open', { | |
| path: filename, | |
| diff --git a/galata/test/jupyterlab/file-edit.test.ts b/galata/test/jupyterlab/file-edit.test.ts | |
| index c114a47bc5..e31c5ce4f1 100644 | |
| --- a/galata/test/jupyterlab/file-edit.test.ts | |
| +++ b/galata/test/jupyterlab/file-edit.test.ts | |
| @@ -55,9 +55,7 @@ test.describe('Console Interactions', () => { | |
| await page.getByText('Create Console for Editor').click(); | |
| await page.getByRole('button', { name: 'Select Kernel' }).click(); | |
| - await page | |
| - .getByText("Type 'copyright', 'credits'") | |
| - .waitFor({ state: 'visible' }); | |
| + await page.getByText("Type 'copyright', 'credits'").waitFor({ state: 'visible' }); | |
| await page.getByText('123', { exact: true }).click(); | |
| @@ -78,8 +76,6 @@ async function getEditorText(page: Page): Promise<string> { | |
| } catch { | |
| // Firefox does not support clipboard-read but does not it it either | |
| } | |
| - const handle = await page.evaluateHandle(() => | |
| - navigator.clipboard.readText() | |
| - ); | |
| + const handle = await page.evaluateHandle(() => navigator.clipboard.readText()); | |
| return await handle.jsonValue(); | |
| } | |
| diff --git a/galata/test/jupyterlab/file-search.test.ts b/galata/test/jupyterlab/file-search.test.ts | |
| index 46048eafc7..f484276cdc 100644 | |
| --- a/galata/test/jupyterlab/file-search.test.ts | |
| +++ b/galata/test/jupyterlab/file-search.test.ts | |
| @@ -45,21 +45,16 @@ test('Search with a text and replacement', async ({ page }) => { | |
| await page.evaluate( | |
| async ([searchText, replaceText]) => { | |
| - await window.jupyterapp.commands.execute( | |
| - 'documentsearch:startWithReplace', | |
| - { | |
| - searchText, | |
| - replaceText | |
| - } | |
| - ); | |
| + await window.jupyterapp.commands.execute('documentsearch:startWithReplace', { | |
| + searchText, | |
| + replaceText | |
| + }); | |
| }, | |
| [searchText, replaceText] | |
| ); | |
| await expect(page.locator('[placeholder="Find"]')).toHaveValue(searchText); | |
| - await expect(page.locator('[placeholder="Replace"]')).toHaveValue( | |
| - replaceText | |
| - ); | |
| + await expect(page.locator('[placeholder="Replace"]')).toHaveValue(replaceText); | |
| }); | |
| test('Populate search box with selected text', async ({ page }) => { | |
| @@ -74,18 +69,14 @@ test('Populate search box with selected text', async ({ page }) => { | |
| await page.keyboard.press('Control+f'); | |
| // Expect it to be populated with the first word | |
| - const inputWithFirstWord = page.locator( | |
| - '[placeholder="Find"] >> text="Lorem"' | |
| - ); | |
| + const inputWithFirstWord = page.locator('[placeholder="Find"] >> text="Lorem"'); | |
| await expect.soft(inputWithFirstWord).toBeVisible(); | |
| await expect.soft(inputWithFirstWord).toBeFocused(); | |
| // Expect the newly set text to be selected | |
| - expect | |
| - .soft(await inputWithFirstWord.evaluate(getSelectionRange)) | |
| - .toStrictEqual({ | |
| - start: 0, | |
| - end: 5 | |
| - }); | |
| + expect.soft(await inputWithFirstWord.evaluate(getSelectionRange)).toStrictEqual({ | |
| + start: 0, | |
| + end: 5 | |
| + }); | |
| // Check the CM search panel is not displayed. | |
| await expect(page.locator('.cm-search.cm-panel')).toHaveCount(0); | |
| @@ -99,18 +90,16 @@ test('Populate search box with selected text', async ({ page }) => { | |
| }); | |
| test.describe('File search from selection', () => { | |
| - test('should expand the selection to the next occurrence', async ({ | |
| - page | |
| - }) => { | |
| + test('should expand the selection to the next occurrence', async ({ page }) => { | |
| // This could be improved as the following statement will double click | |
| // on the last line that will result in the last word being selected. | |
| await page.getByRole('textbox').getByText('in').last().dblclick(); | |
| await page.keyboard.press('Control+Shift+d'); | |
| - await expect( | |
| - page.getByRole('main').locator('.cm-selectionBackground') | |
| - ).toHaveCount(2); | |
| + await expect(page.getByRole('main').locator('.cm-selectionBackground')).toHaveCount( | |
| + 2 | |
| + ); | |
| }); | |
| test('search highlighting', async ({ page }) => { | |
| @@ -166,8 +155,8 @@ test.describe('File search from selection', () => { | |
| // FIXME it should not be needed when we get https://github.com/jupyterlab/lumino/pull/662 | |
| await page.activity.activateTab(DEFAULT_NAME); | |
| - await expect( | |
| - page.getByRole('main').locator('.cm-selectionBackground') | |
| - ).toHaveCount(7); | |
| + await expect(page.getByRole('main').locator('.cm-selectionBackground')).toHaveCount( | |
| + 7 | |
| + ); | |
| }); | |
| }); | |
| diff --git a/galata/test/jupyterlab/filebrowser.test.ts b/galata/test/jupyterlab/filebrowser.test.ts | |
| index b900538b38..79e7762b03 100644 | |
| --- a/galata/test/jupyterlab/filebrowser.test.ts | |
| +++ b/galata/test/jupyterlab/filebrowser.test.ts | |
| @@ -57,9 +57,7 @@ test('File rename input respects UI font size', async ({ page }) => { | |
| const normalFontSize = await getFileListFontSize(page); | |
| // Trigger rename | |
| - await page | |
| - .locator('.jp-DirListing-itemName:has-text("untitled.txt")') | |
| - .click(); | |
| + await page.locator('.jp-DirListing-itemName:has-text("untitled.txt")').click(); | |
| await page.keyboard.press('F2'); | |
| const renameInput = page.locator('.jp-DirListing-editor'); | |
| diff --git a/galata/test/jupyterlab/general.test.ts b/galata/test/jupyterlab/general.test.ts | |
| index 8e86bf6751..ed248a0b37 100644 | |
| --- a/galata/test/jupyterlab/general.test.ts | |
| +++ b/galata/test/jupyterlab/general.test.ts | |
| @@ -40,23 +40,17 @@ test.describe('General Tests', () => { | |
| test('Toggle Dark High Contrast theme', async ({ page }) => { | |
| await page.theme.setDarkHighContrastTheme(); | |
| - expect(await page.theme.getTheme()).toEqual( | |
| - 'JupyterLab Dark High Contrast' | |
| - ); | |
| + expect(await page.theme.getTheme()).toEqual('JupyterLab Dark High Contrast'); | |
| }); | |
| test('Toggle adaptive theme', async ({ page }) => { | |
| await page.emulateMedia({ colorScheme: 'dark' }); | |
| - await page.menu.clickMenuItem( | |
| - 'Settings>Theme>Synchronize with System Settings' | |
| - ); | |
| + await page.menu.clickMenuItem('Settings>Theme>Synchronize with System Settings'); | |
| await page.reload(); | |
| expect(await page.theme.getTheme()).toEqual('JupyterLab Dark'); | |
| }); | |
| - test('Browser tab name updates to file name in /doc mode', async ({ | |
| - page | |
| - }) => { | |
| + test('Browser tab name updates to file name in /doc mode', async ({ page }) => { | |
| // Switch to single-document mode | |
| const currentUrl = page.url(); | |
| const docUrl = currentUrl.replace('/lab/', '/doc/'); | |
| diff --git a/galata/test/jupyterlab/help.test.ts b/galata/test/jupyterlab/help.test.ts | |
| index 0afcc0735b..a5ba718333 100644 | |
| --- a/galata/test/jupyterlab/help.test.ts | |
| +++ b/galata/test/jupyterlab/help.test.ts | |
| @@ -43,9 +43,9 @@ test('Switch back and forth to reference page', async ({ page }) => { | |
| await page.locator('.jp-MarkdownCell .jp-InputArea-editor').waitFor(); | |
| - await expect( | |
| - page.locator('.jp-MarkdownCell .jp-InputArea-editor') | |
| - ).toHaveText(cellContent); | |
| + await expect(page.locator('.jp-MarkdownCell .jp-InputArea-editor')).toHaveText( | |
| + cellContent | |
| + ); | |
| }); | |
| test.describe('Licenses', () => { | |
| diff --git a/galata/test/jupyterlab/html-viewer.test.ts b/galata/test/jupyterlab/html-viewer.test.ts | |
| index e6d57d9f55..f89c56812c 100644 | |
| --- a/galata/test/jupyterlab/html-viewer.test.ts | |
| +++ b/galata/test/jupyterlab/html-viewer.test.ts | |
| @@ -25,9 +25,7 @@ test.describe('HTML Viewer', () => { | |
| await page.waitForSelector('iframe[src^="blob:"]', { timeout: 5000 }); | |
| }); | |
| - test('should notify links are blocked for untrusted file', async ({ | |
| - page | |
| - }) => { | |
| + test('should notify links are blocked for untrusted file', async ({ page }) => { | |
| await page.waitForTimeout(100); | |
| const frame = await waitForFrame(page, { | |
| url: url => url.protocol == 'blob:' | |
| @@ -50,9 +48,7 @@ test.describe('HTML Viewer', () => { | |
| }); | |
| test('should allow links for trusted file', async ({ page }) => { | |
| - await page | |
| - .getByRole('button', { name: 'Trust HTML' }) | |
| - .click({ force: true }); | |
| + await page.getByRole('button', { name: 'Trust HTML' }).click({ force: true }); | |
| const frame = await waitForFrame(page, { | |
| url: url => url.protocol == 'blob:' | |
| }); | |
| diff --git a/galata/test/jupyterlab/inline-completer.test.ts b/galata/test/jupyterlab/inline-completer.test.ts | |
| index 840a04f60d..0d7115c948 100644 | |
| --- a/galata/test/jupyterlab/inline-completer.test.ts | |
| +++ b/galata/test/jupyterlab/inline-completer.test.ts | |
| @@ -253,9 +253,7 @@ test.describe('Inline Completer', () => { | |
| await expect(ghostText).toBeHidden(); | |
| }); | |
| - test('Ghost text shows on middle of line when FIM is enabled', async ({ | |
| - page | |
| - }) => { | |
| + test('Ghost text shows on middle of line when FIM is enabled', async ({ page }) => { | |
| const cellEditor = (await page.notebook.getCellInputLocator(2))!; | |
| await page.keyboard.press('u'); | |
| @@ -278,8 +276,7 @@ test.describe('Inline Completer', () => { | |
| test('Empty space is retained to avoid jitter', async ({ page }) => { | |
| const cellEditor = (await page.notebook.getCellInputLocator(2))!; | |
| - const measureEditorHeight = async () => | |
| - (await cellEditor.boundingBox())!.height; | |
| + const measureEditorHeight = async () => (await cellEditor.boundingBox())!.height; | |
| const noGhostTextHeight = await measureEditorHeight(); | |
| await page.keyboard.type('uggestion_2'); | |
| diff --git a/galata/test/jupyterlab/kernel.test.ts b/galata/test/jupyterlab/kernel.test.ts | |
| index 8cfec42b5f..3e32630b34 100644 | |
| --- a/galata/test/jupyterlab/kernel.test.ts | |
| +++ b/galata/test/jupyterlab/kernel.test.ts | |
| @@ -9,19 +9,13 @@ test.describe('Kernel', () => { | |
| page | |
| }) => { | |
| await Promise.all([ | |
| - page | |
| - .getByRole('tabpanel', { name: 'Launcher' }) | |
| - .waitFor({ state: 'detached' }), | |
| - page | |
| - .locator('[data-category="Notebook"][title="Python 3 (ipykernel)"]') | |
| - .click() | |
| + page.getByRole('tabpanel', { name: 'Launcher' }).waitFor({ state: 'detached' }), | |
| + page.locator('[data-category="Notebook"][title="Python 3 (ipykernel)"]').click() | |
| ]); | |
| await expect.soft(page.locator('.jp-Dialog')).toHaveCount(0); | |
| - await expect(page.getByTitle('Switch kernel')).toHaveText( | |
| - 'Python 3 (ipykernel)' | |
| - ); | |
| + await expect(page.getByTitle('Switch kernel')).toHaveText('Python 3 (ipykernel)'); | |
| }); | |
| test('Should remember kernel auto start for notebook', async ({ page }) => { | |
| @@ -33,9 +27,7 @@ test.describe('Kernel', () => { | |
| .getByRole('button', { name: 'No Kernel' }) | |
| .click(); | |
| - await expect | |
| - .soft(page.getByTitle('Switch kernel')) | |
| - .toHaveText('No Kernel'); | |
| + await expect.soft(page.getByTitle('Switch kernel')).toHaveText('No Kernel'); | |
| await Promise.all([ | |
| page | |
| @@ -51,10 +43,7 @@ test.describe('Kernel', () => { | |
| .locator('.jp-Dialog') | |
| .getByText('Always start the preferred kernel') | |
| .click(); | |
| - await page | |
| - .locator('.jp-Dialog') | |
| - .getByRole('button', { name: 'Select' }) | |
| - .click(); | |
| + await page.locator('.jp-Dialog').getByRole('button', { name: 'Select' }).click(); | |
| await expect | |
| .soft(page.getByTitle('Switch kernel')) | |
| @@ -72,9 +61,7 @@ test.describe('Kernel', () => { | |
| // Open the same notebook and check it turns on the kernel | |
| await page.filebrowser.open('Untitled.ipynb'); | |
| - await expect(page.getByTitle('Switch kernel')).toHaveText( | |
| - 'Python 3 (ipykernel)' | |
| - ); | |
| + await expect(page.getByTitle('Switch kernel')).toHaveText('Python 3 (ipykernel)'); | |
| }); | |
| test('Should request kernel selection when executing a cell for notebook without kernel', async ({ | |
| @@ -88,9 +75,7 @@ test.describe('Kernel', () => { | |
| .getByRole('button', { name: 'No Kernel' }) | |
| .click(); | |
| - await expect | |
| - .soft(page.getByTitle('Switch kernel')) | |
| - .toHaveText('No Kernel'); | |
| + await expect.soft(page.getByTitle('Switch kernel')).toHaveText('No Kernel'); | |
| // Request cell execution | |
| await page.menu.clickMenuItem('Run>Run Selected Cell'); | |
| @@ -100,9 +85,7 @@ test.describe('Kernel', () => { | |
| .getByRole('button', { name: 'Select Kernel', exact: true }) | |
| .click(); | |
| - await expect(page.getByTitle('Switch kernel')).toHaveText( | |
| - 'Python 3 (ipykernel)' | |
| - ); | |
| + await expect(page.getByTitle('Switch kernel')).toHaveText('Python 3 (ipykernel)'); | |
| }); | |
| test('Should support opening subshell in separate code console', async ({ | |
| @@ -153,9 +136,7 @@ test.describe('Kernel', () => { | |
| // which will be something other than None (None means main shell not subshell). | |
| // The subshell ID should also be the one and only entry in the "subshell list", | |
| // and wrapped in quotes as it is a string. | |
| - const output2 = subshellConsole | |
| - .locator('.jp-OutputArea-output') | |
| - .locator('pre'); | |
| + const output2 = subshellConsole.locator('.jp-OutputArea-output').locator('pre'); | |
| const text2 = (await output2.innerText()).split('\n'); | |
| expect(text2[0]).toMatch(/^subshell id:/); | |
| const subshellId = text2[0].split(':')[1].trim(); | |
| @@ -184,12 +165,8 @@ test.describe('Kernel', () => { | |
| page | |
| }) => { | |
| await Promise.all([ | |
| - page | |
| - .getByRole('tabpanel', { name: 'Launcher' }) | |
| - .waitFor({ state: 'detached' }), | |
| - page | |
| - .locator('[data-category="Console"][title="Python 3 (ipykernel)"]') | |
| - .click() | |
| + page.getByRole('tabpanel', { name: 'Launcher' }).waitFor({ state: 'detached' }), | |
| + page.locator('[data-category="Console"][title="Python 3 (ipykernel)"]').click() | |
| ]); | |
| await expect.soft(page.locator('.jp-Dialog')).toHaveCount(0); | |
| @@ -199,9 +176,7 @@ test.describe('Kernel', () => { | |
| .waitFor(); | |
| }); | |
| - test('Should ask for kernel when creating console from menu', async ({ | |
| - page | |
| - }) => { | |
| + test('Should ask for kernel when creating console from menu', async ({ page }) => { | |
| await page.menu.clickMenuItem('File>New>Console'); | |
| await page | |
| @@ -223,9 +198,7 @@ test.describe('Kernel', () => { | |
| const statusBar = page.locator('#jp-main-statusbar'); | |
| await page.menu.clickMenuItem('File>New>Notebook'); | |
| - await page | |
| - .locator('.jp-Dialog-button.jp-mod-accept:has-text("select")') | |
| - .click(); | |
| + await page.locator('.jp-Dialog-button.jp-mod-accept:has-text("select")').click(); | |
| // Add long running script to first cell | |
| await page.notebook.setCell( | |
| @@ -240,9 +213,7 @@ test.describe('Kernel', () => { | |
| await statusBar.getByText('Busy').waitFor(); | |
| await page.menu.clickMenuItem('File>New>Notebook'); | |
| - await page | |
| - .locator('.jp-Dialog-button.jp-mod-accept:has-text("select")') | |
| - .click(); | |
| + await page.locator('.jp-Dialog-button.jp-mod-accept:has-text("select")').click(); | |
| await statusBar.getByText('Idle').waitFor(); | |
| // Switch back to running notebook | |
| diff --git a/galata/test/jupyterlab/launcher.test.ts b/galata/test/jupyterlab/launcher.test.ts | |
| index 9bce8c2cbc..bb077dae06 100644 | |
| --- a/galata/test/jupyterlab/launcher.test.ts | |
| +++ b/galata/test/jupyterlab/launcher.test.ts | |
| @@ -18,9 +18,7 @@ test.describe('Dynamic Text Spacing', () => { | |
| await element.nth(i).waitFor(); | |
| let height = await element | |
| .nth(i) | |
| - .evaluate(el => | |
| - window.getComputedStyle(el).getPropertyValue('min-height') | |
| - ); | |
| + .evaluate(el => window.getComputedStyle(el).getPropertyValue('min-height')); | |
| let expectedValue = | |
| 2.462 * | |
| @@ -28,10 +26,7 @@ test.describe('Dynamic Text Spacing', () => { | |
| await element | |
| .nth(i) | |
| .evaluate(el => | |
| - window | |
| - .getComputedStyle(el) | |
| - .getPropertyValue('font-size') | |
| - .toString() | |
| + window.getComputedStyle(el).getPropertyValue('font-size').toString() | |
| ) | |
| ); | |
| @@ -39,8 +34,8 @@ test.describe('Dynamic Text Spacing', () => { | |
| } | |
| const imageName = 'launcher-card-label-height.png'; | |
| - expect( | |
| - await page.locator('.jp-Launcher-content').screenshot() | |
| - ).toMatchSnapshot(imageName.toLowerCase()); | |
| + expect(await page.locator('.jp-Launcher-content').screenshot()).toMatchSnapshot( | |
| + imageName.toLowerCase() | |
| + ); | |
| }); | |
| }); | |
| diff --git a/galata/test/jupyterlab/menus.test.ts b/galata/test/jupyterlab/menus.test.ts | |
| index f8648decdc..9932de266e 100644 | |
| --- a/galata/test/jupyterlab/menus.test.ts | |
| +++ b/galata/test/jupyterlab/menus.test.ts | |
| @@ -74,16 +74,10 @@ test('Main menu definition must target an valid command', async ({ page }) => { | |
| const settings = await window.galata.getPlugin( | |
| '@jupyterlab/apputils-extension:settings' | |
| ); | |
| - const menus = await settings.get( | |
| - '@jupyterlab/mainmenu-extension:plugin', | |
| - 'menus' | |
| - ); | |
| + const menus = await settings.get('@jupyterlab/mainmenu-extension:plugin', 'menus'); | |
| const commandIds = window.jupyterapp.commands.listCommands(); | |
| - return Promise.resolve([ | |
| - menus.composite as ISettingRegistry.IMenu[], | |
| - commandIds | |
| - ]); | |
| + return Promise.resolve([menus.composite as ISettingRegistry.IMenu[], commandIds]); | |
| }); | |
| commands.push(...EXPECTED_MISSING_COMMANDS_MAINMENU); | |
| @@ -109,9 +103,7 @@ test('Main menu definition must target an valid command', async ({ page }) => { | |
| expect(missingCommands).toEqual([]); | |
| }); | |
| -test('Context menu definition must target an valid command', async ({ | |
| - page | |
| -}) => { | |
| +test('Context menu definition must target an valid command', async ({ page }) => { | |
| const [items, commands] = await page.evaluate(async () => { | |
| const settings = await window.galata.getPlugin( | |
| '@jupyterlab/apputils-extension:settings' | |
| @@ -144,10 +136,7 @@ test('Context menu definition must target an valid command', async ({ | |
| function reduceItem( | |
| item: ISettingRegistry.IMenuItem, | |
| commands: string[] | |
| -): | |
| - | ISettingRegistry.IMenuItem | |
| - | { [id: string]: ISettingRegistry.IMenuItem[] } | |
| - | null { | |
| +): ISettingRegistry.IMenuItem | { [id: string]: ISettingRegistry.IMenuItem[] } | null { | |
| switch (item.type ?? 'command') { | |
| case 'command': | |
| if (!commands.includes(item.command)) { | |
| diff --git a/galata/test/jupyterlab/metadataform.test.ts b/galata/test/jupyterlab/metadataform.test.ts | |
| index ce999d1aa0..fe32aa6ae2 100644 | |
| --- a/galata/test/jupyterlab/metadataform.test.ts | |
| +++ b/galata/test/jupyterlab/metadataform.test.ts | |
| @@ -42,15 +42,11 @@ async function activatePropertyInspector(page: IJupyterLabPageFixture) { | |
| } | |
| } | |
| - const widgetButton = page.locator( | |
| - ".lm-TabBar-tab[title='Property Inspector']" | |
| - ); | |
| + const widgetButton = page.locator(".lm-TabBar-tab[title='Property Inspector']"); | |
| const buttonPosition = await widgetButton.boundingBox(); | |
| if (buttonPosition === null) | |
| - throw new Error( | |
| - 'Cannot get the position of the property inspector button.' | |
| - ); | |
| + throw new Error('Cannot get the position of the property inspector button.'); | |
| await page.mouse.click( | |
| buttonPosition.x + buttonPosition.width / 2, | |
| @@ -63,10 +59,7 @@ async function activatePropertyInspector(page: IJupyterLabPageFixture) { | |
| /** | |
| * Expand the form (open notebook tools if necessary) | |
| */ | |
| -async function openForm( | |
| - page: IJupyterLabPageFixture, | |
| - label = 'Extension metadata' | |
| -) { | |
| +async function openForm(page: IJupyterLabPageFixture, label = 'Extension metadata') { | |
| await activatePropertyInspector(page); | |
| const form = page.locator('.jp-NotebookTools .jp-Collapse', { | |
| @@ -74,9 +67,7 @@ async function openForm( | |
| }); | |
| if (form.locator('.jp-Collapse-contents.lm-mod-hidden')) { | |
| await form.click(); | |
| - await expect( | |
| - form.locator('.jp-Collapse-contents.lm-mod-hidden') | |
| - ).toHaveCount(0); | |
| + await expect(form.locator('.jp-Collapse-contents.lm-mod-hidden')).toHaveCount(0); | |
| } | |
| return form; | |
| } | |
| @@ -156,18 +147,12 @@ test.describe('Required metadata', () => { | |
| const form = page.locator('.jp-NotebookTools .jp-Collapse', { | |
| hasText: 'Extension metadata' | |
| }); | |
| - expect(await form.screenshot()).toMatchSnapshot( | |
| - 'metadata-collapsed-form.png' | |
| - ); | |
| - await expect( | |
| - form.locator('.jp-Collapse-contents.lm-mod-hidden') | |
| - ).toHaveCount(1); | |
| + expect(await form.screenshot()).toMatchSnapshot('metadata-collapsed-form.png'); | |
| + await expect(form.locator('.jp-Collapse-contents.lm-mod-hidden')).toHaveCount(1); | |
| // Expand the form. | |
| await form.click(); | |
| - await expect( | |
| - form.locator('.jp-Collapse-contents.lm-mod-hidden') | |
| - ).toHaveCount(0); | |
| + await expect(form.locator('.jp-Collapse-contents.lm-mod-hidden')).toHaveCount(0); | |
| // Get the formGroup (form content). | |
| const formGroup = form.locator( | |
| @@ -180,9 +165,7 @@ test.describe('Required metadata', () => { | |
| formGroup.locator('.jp-FormGroup-compactTitle > .jp-FormGroup-fieldLabel') | |
| ).toHaveText('Basic metadata'); | |
| await expect( | |
| - formGroup.locator( | |
| - '.jp-FormGroup-compactTitle > .jp-FormGroup-description' | |
| - ) | |
| + formGroup.locator('.jp-FormGroup-compactTitle > .jp-FormGroup-description') | |
| ).toHaveText('Basic metadata description'); | |
| }); | |
| @@ -200,9 +183,7 @@ test.describe('Required metadata', () => { | |
| // Error should be displayed as required field is empty. | |
| await expect(formGroup.locator('.validationErrors')).not.toBeEmpty(); | |
| - expect(await form.screenshot()).toMatchSnapshot( | |
| - 'metadata-required-missing.png' | |
| - ); | |
| + expect(await form.screenshot()).toMatchSnapshot('metadata-required-missing.png'); | |
| // Relevant metadata should be empty. | |
| let cellMetadata = await getCellMetadata(page, 0); | |
| @@ -215,9 +196,7 @@ test.describe('Required metadata', () => { | |
| cellMetadata = await getCellMetadata(page, 0); | |
| expect(cellMetadata['basic-metadata']).toBe('abc'); | |
| await expect(formGroup.locator('.validationErrors')).toBeEmpty(); | |
| - expect(await form.screenshot()).toMatchSnapshot( | |
| - 'metadata-required-filled.png' | |
| - ); | |
| + expect(await form.screenshot()).toMatchSnapshot('metadata-required-filled.png'); | |
| }); | |
| }); | |
| @@ -276,11 +255,7 @@ test.describe('Nested metadata', () => { | |
| expect(cellMetadata['level1']).toBeUndefined(); | |
| }); | |
| - test('should remove only the empty metadata', async ({ | |
| - page, | |
| - baseURL, | |
| - tmpPath | |
| - }) => { | |
| + test('should remove only the empty metadata', async ({ page, baseURL, tmpPath }) => { | |
| // Open the Notebook. | |
| await page.goto(baseURL); | |
| await page.notebook.openByPath(`${tmpPath}/${nbFile}`); | |
| @@ -384,11 +359,7 @@ test.describe('Default metadata without "showModified" flag', () => { | |
| expect(cellMetadata['default-not-written']).toBeUndefined(); | |
| }); | |
| - test('should not display the modified field', async ({ | |
| - page, | |
| - baseURL, | |
| - tmpPath | |
| - }) => { | |
| + test('should not display the modified field', async ({ page, baseURL, tmpPath }) => { | |
| // Open the Notebook. | |
| await page.goto(baseURL); | |
| await page.notebook.openByPath(`${tmpPath}/${nbFile}`); | |
| @@ -434,11 +405,7 @@ test.describe('Default metadata with "showModified" flag', () => { | |
| } | |
| }); | |
| - test('should display the modified field', async ({ | |
| - page, | |
| - baseURL, | |
| - tmpPath | |
| - }) => { | |
| + test('should display the modified field', async ({ page, baseURL, tmpPath }) => { | |
| // Open the Notebook. | |
| await page.goto(baseURL); | |
| await page.notebook.openByPath(`${tmpPath}/${nbFile}`); | |
| @@ -548,26 +515,20 @@ test.describe('Notebook level and cell type metadata', () => { | |
| await page.notebook.selectCells((await page.notebook.getCellCount()) - 1); | |
| ({ form, formGroup } = await getFormGroup(page)); | |
| await expect(formGroup).toHaveCount(1); | |
| - expect(await form.screenshot()).toMatchSnapshot( | |
| - 'metadata-wrong-cell-type.png' | |
| - ); | |
| + expect(await form.screenshot()).toMatchSnapshot('metadata-wrong-cell-type.png'); | |
| // Create a raw cell and select it. | |
| await page.notebook.addCell('raw', 'Raw cell'); | |
| await page.notebook.selectCells((await page.notebook.getCellCount()) - 1); | |
| ({ form, formGroup } = await getFormGroup(page)); | |
| await expect(formGroup).toHaveCount(1); | |
| - expect(await form.screenshot()).toMatchSnapshot( | |
| - 'metadata-wrong-cell-type.png' | |
| - ); | |
| + expect(await form.screenshot()).toMatchSnapshot('metadata-wrong-cell-type.png'); | |
| // Select the code cell again to retrieve full form. | |
| await page.notebook.selectCells(0); | |
| ({ form, formGroup } = await getFormGroup(page)); | |
| await expect(formGroup).toHaveCount(2); | |
| - expect(await form.screenshot()).toMatchSnapshot( | |
| - 'metadata-correct-cell-type.png' | |
| - ); | |
| + expect(await form.screenshot()).toMatchSnapshot('metadata-correct-cell-type.png'); | |
| }); | |
| }); | |
| @@ -625,23 +586,17 @@ test.describe('Conditional metadata', () => { | |
| // There should be 1 field displayed as condition is not met. | |
| await formGroup.locator('select').first().selectOption('not met'); | |
| await expect(formGroup).toHaveCount(1); | |
| - expect(await form.screenshot()).toMatchSnapshot( | |
| - 'metadata-condition-not-met.png' | |
| - ); | |
| + expect(await form.screenshot()).toMatchSnapshot('metadata-condition-not-met.png'); | |
| // Met the condition, then the second field should be displayed too. | |
| await formGroup.locator('select').first().selectOption('met'); | |
| await expect(formGroup).toHaveCount(2); | |
| - expect(await form.screenshot()).toMatchSnapshot( | |
| - 'metadata-condition-met.png' | |
| - ); | |
| + expect(await form.screenshot()).toMatchSnapshot('metadata-condition-met.png'); | |
| // If the condition is not met, only one field should be displayed. | |
| await formGroup.locator('select').first().selectOption('not met'); | |
| await expect(formGroup).toHaveCount(1); | |
| - expect(await form.screenshot()).toMatchSnapshot( | |
| - 'metadata-condition-not-met.png' | |
| - ); | |
| + expect(await form.screenshot()).toMatchSnapshot('metadata-condition-not-met.png'); | |
| }); | |
| }); | |
| @@ -677,11 +632,7 @@ test.describe('UISchema', () => { | |
| } | |
| }); | |
| - test('should respect the order of the fields', async ({ | |
| - page, | |
| - baseURL, | |
| - tmpPath | |
| - }) => { | |
| + test('should respect the order of the fields', async ({ page, baseURL, tmpPath }) => { | |
| // Open the Notebook. | |
| await page.goto(baseURL); | |
| await page.notebook.openByPath(`${tmpPath}/${nbFile}`); | |
| @@ -693,25 +644,15 @@ test.describe('UISchema', () => { | |
| expect(await form.screenshot()).toMatchSnapshot('metadata-ui-schema.png'); | |
| await expect( | |
| - formGroup | |
| - .locator('.jp-FormGroup-compactTitle > .jp-FormGroup-fieldLabel') | |
| - .first() | |
| + formGroup.locator('.jp-FormGroup-compactTitle > .jp-FormGroup-fieldLabel').first() | |
| ).toHaveText('Metadata 2'); | |
| - await expect(formGroup.locator('input').first()).toHaveAttribute( | |
| - 'type', | |
| - 'number' | |
| - ); | |
| + await expect(formGroup.locator('input').first()).toHaveAttribute('type', 'number'); | |
| // Should display the title and description from uiSchema. | |
| await expect( | |
| - formGroup | |
| - .locator('.jp-FormGroup-compactTitle > .jp-FormGroup-fieldLabel') | |
| - .last() | |
| + formGroup.locator('.jp-FormGroup-compactTitle > .jp-FormGroup-fieldLabel').last() | |
| ).toHaveText('Metadata 1 title'); | |
| - await expect(formGroup.locator('input').last()).toHaveAttribute( | |
| - 'type', | |
| - 'text' | |
| - ); | |
| + await expect(formGroup.locator('input').last()).toHaveAttribute('type', 'text'); | |
| }); | |
| }); | |
| @@ -733,9 +674,7 @@ test.describe('Advanced tools', () => { | |
| hasText: 'Advanced Tools' | |
| }); | |
| await form.click(); | |
| - const cellMetadataEditor = page.locator( | |
| - '.jp-CellMetadataEditor .cm-content' | |
| - ); | |
| + const cellMetadataEditor = page.locator('.jp-CellMetadataEditor .cm-content'); | |
| // Modifying the cell metadata - removing the "trusted": "true" line | |
| const trustedLine = cellMetadataEditor.locator('.cm-line').filter({ | |
| diff --git a/galata/test/jupyterlab/notebook-create.test.ts b/galata/test/jupyterlab/notebook-create.test.ts | |
| index 3f05c9f71d..c80e0b1972 100644 | |
| --- a/galata/test/jupyterlab/notebook-create.test.ts | |
| +++ b/galata/test/jupyterlab/notebook-create.test.ts | |
| @@ -57,9 +57,9 @@ test.describe('Notebook Create', () => { | |
| menuPaths.forEach(menuPath => { | |
| test(`Open menu item ${menuPath}`, async ({ page, sessions }) => { | |
| // Wait for kernel to be idle as some menu depend of kernel information | |
| - await expect( | |
| - page.locator(`#jp-main-statusbar >> text=Idle`).first() | |
| - ).toHaveCount(1); | |
| + await expect(page.locator(`#jp-main-statusbar >> text=Idle`).first()).toHaveCount( | |
| + 1 | |
| + ); | |
| await page.menu.openLocator(menuPath); | |
| expect(await page.menu.isOpen(menuPath)).toBeTruthy(); | |
| diff --git a/galata/test/jupyterlab/notebook-edit.test.ts b/galata/test/jupyterlab/notebook-edit.test.ts | |
| index 6eef348f4f..78d2f66221 100644 | |
| --- a/galata/test/jupyterlab/notebook-edit.test.ts | |
| +++ b/galata/test/jupyterlab/notebook-edit.test.ts | |
| @@ -272,9 +272,7 @@ test.describe('Notebook Edit (defer mode)', () => { | |
| const getWindowingIndices = async (page: IJupyterLabPageFixture) => { | |
| const notebook = await page.notebook.getNotebookInPanelLocator(); | |
| - const cellElements = await notebook! | |
| - .locator('[data-windowed-list-index]') | |
| - .all(); | |
| + const cellElements = await notebook!.locator('[data-windowed-list-index]').all(); | |
| const indices: number[] = []; | |
| if (cellElements) { | |
| for (const element of cellElements) { | |
| diff --git a/galata/test/jupyterlab/notebook-footer.test.ts b/galata/test/jupyterlab/notebook-footer.test.ts | |
| index 7297d54205..95a8e2bee6 100644 | |
| --- a/galata/test/jupyterlab/notebook-footer.test.ts | |
| +++ b/galata/test/jupyterlab/notebook-footer.test.ts | |
| @@ -9,9 +9,7 @@ import { expect, test } from '@jupyterlab/galata'; | |
| * Test the responsive alignment of the Notebook Footer | |
| */ | |
| test.describe('Notebook Footer Responsive Alignment', () => { | |
| - test('should align correctly on screens smaller than 760px', async ({ | |
| - page | |
| - }) => { | |
| + test('should align correctly on screens smaller than 760px', async ({ page }) => { | |
| await page.notebook.createNew(); | |
| // Set the viewport to a mobile width | |
| diff --git a/galata/test/jupyterlab/notebook-markdown.test.ts b/galata/test/jupyterlab/notebook-markdown.test.ts | |
| index b31b5aa7df..f60f1249bc 100644 | |
| --- a/galata/test/jupyterlab/notebook-markdown.test.ts | |
| +++ b/galata/test/jupyterlab/notebook-markdown.test.ts | |
| @@ -51,9 +51,7 @@ test.describe('Notebook Markdown', () => { | |
| await page.notebook.enterCellEditingMode(0); | |
| const cell = await page.notebook.getCellLocator(0); | |
| - expect(await cell!.locator('.jp-Editor').screenshot()).toMatchSnapshot( | |
| - imageName | |
| - ); | |
| + expect(await cell!.locator('.jp-Editor').screenshot()).toMatchSnapshot(imageName); | |
| }); | |
| test('Do not highlight TeX in code blocks', async ({ page }) => { | |
| @@ -61,22 +59,15 @@ test.describe('Notebook Markdown', () => { | |
| await enterEditingModeForScreenshot(page, 1); | |
| const cell = await page.notebook.getCellLocator(1); | |
| - expect(await cell!.locator('.jp-Editor').screenshot()).toMatchSnapshot( | |
| - imageName | |
| - ); | |
| + expect(await cell!.locator('.jp-Editor').screenshot()).toMatchSnapshot(imageName); | |
| }); | |
| - test('Do not enter math mode for standalone dollar', async ({ | |
| - page, | |
| - tmpPath | |
| - }) => { | |
| + test('Do not enter math mode for standalone dollar', async ({ page, tmpPath }) => { | |
| const imageName = 'do-not-highlight-standalone-dollar.png'; | |
| await enterEditingModeForScreenshot(page, 2); | |
| const cell = await page.notebook.getCellLocator(2); | |
| - expect(await cell!.locator('.jp-Editor').screenshot()).toMatchSnapshot( | |
| - imageName | |
| - ); | |
| + expect(await cell!.locator('.jp-Editor').screenshot()).toMatchSnapshot(imageName); | |
| }); | |
| test('Render a MermaidJS flowchart', async ({ page, tmpPath }) => { | |
| diff --git a/galata/test/jupyterlab/notebook-max-outputs.test.ts b/galata/test/jupyterlab/notebook-max-outputs.test.ts | |
| index b5474a6795..569637705d 100644 | |
| --- a/galata/test/jupyterlab/notebook-max-outputs.test.ts | |
| +++ b/galata/test/jupyterlab/notebook-max-outputs.test.ts | |
| @@ -29,9 +29,7 @@ for i in range(10): | |
| await page.notebook.run(); | |
| await expect(page.locator('.jp-RenderedMarkdown')).toHaveCount(MAX_OUTPUTS); | |
| - await expect(page.locator('.jp-TrimmedOutputs')).toHaveText( | |
| - 'Show more outputs' | |
| - ); | |
| + await expect(page.locator('.jp-TrimmedOutputs')).toHaveText('Show more outputs'); | |
| }); | |
| test("Don't limit cell outputs if input is requested", async ({ page }) => { | |
| @@ -81,7 +79,5 @@ for i in range(10): | |
| expect(await page.locator('.jp-RenderedMarkdown').count()).toBeGreaterThan( | |
| MAX_OUTPUTS | |
| ); | |
| - await expect(page.locator('.jp-RenderedText').first()).toHaveText( | |
| - 'Your age: 42' | |
| - ); | |
| + await expect(page.locator('.jp-RenderedText').first()).toHaveText('Your age: 42'); | |
| }); | |
| diff --git a/galata/test/jupyterlab/notebook-mermaid-diagrams.test.ts b/galata/test/jupyterlab/notebook-mermaid-diagrams.test.ts | |
| index 7b4da446bc..56e5c0b7c1 100644 | |
| --- a/galata/test/jupyterlab/notebook-mermaid-diagrams.test.ts | |
| +++ b/galata/test/jupyterlab/notebook-mermaid-diagrams.test.ts | |
| @@ -112,16 +112,12 @@ for (const theme of ['default', 'dark']) { | |
| let diagram = EXPECTED_MERMAID_ORDER[i]; | |
| const iZero = `${i}`.padStart(2, '0'); | |
| - test(`Mermaid Diagram ${i} ${diagram} in ${theme} theme`, async ({ | |
| - page | |
| - }) => { | |
| + test(`Mermaid Diagram ${i} ${diagram} in ${theme} theme`, async ({ page }) => { | |
| test.fixme( | |
| i >= 18, | |
| `Diagram ${i} ${diagram} in ${theme} theme is flaky: sometimes the screenshot capture is 1px smaller in one dimension than expected, with other minor differences.` | |
| ); | |
| - const output = page.locator( | |
| - `.jp-Cell:nth-child(${i + 1}) .jp-RenderedMermaid` | |
| - ); | |
| + const output = page.locator(`.jp-Cell:nth-child(${i + 1}) .jp-RenderedMermaid`); | |
| await output.waitFor(); | |
| expect(await resizePageAndScreenshot(output)).toMatchSnapshot( | |
| diff --git a/galata/test/jupyterlab/notebook-no-kernel.test.ts b/galata/test/jupyterlab/notebook-no-kernel.test.ts | |
| index 06daf85755..40fad59b8d 100644 | |
| --- a/galata/test/jupyterlab/notebook-no-kernel.test.ts | |
| +++ b/galata/test/jupyterlab/notebook-no-kernel.test.ts | |
| @@ -23,16 +23,12 @@ test.describe('Notebook No Kernel', () => { | |
| await page.waitForSelector('.jp-NotebookPanel'); | |
| }); | |
| - test('Should show "No Kernel" message when opening notebook', async ({ | |
| - page | |
| - }) => { | |
| + test('Should show "No Kernel" message when opening notebook', async ({ page }) => { | |
| await expect(page.getByTitle('Switch kernel')).toHaveText('No Kernel'); | |
| expect(await page.activity.isTabActive(NOTEBOOK_NAME)).toBe(true); | |
| }); | |
| - test('Should maintain no kernel state when adding cells', async ({ | |
| - page | |
| - }) => { | |
| + test('Should maintain no kernel state when adding cells', async ({ page }) => { | |
| await page.notebook.setCell(0, 'code', 'print("Hello, World!")'); | |
| await page.notebook.addCell('markdown', '# Test Header'); | |
| @@ -40,9 +36,7 @@ test.describe('Notebook No Kernel', () => { | |
| expect(await page.notebook.getCellCount()).toBe(2); | |
| }); | |
| - test('Should not auto-start kernel when reopening notebook', async ({ | |
| - page | |
| - }) => { | |
| + test('Should not auto-start kernel when reopening notebook', async ({ page }) => { | |
| await page.notebook.setCell(0, 'code', 'print("test")'); | |
| await page.notebook.save(); | |
| await page.menu.clickMenuItem('File>Close Tab'); | |
| @@ -52,9 +46,7 @@ test.describe('Notebook No Kernel', () => { | |
| await expect(page.getByTitle('Switch kernel')).toHaveText('No Kernel'); | |
| }); | |
| - test('Should prompt for kernel when executing code cell', async ({ | |
| - page | |
| - }) => { | |
| + test('Should prompt for kernel when executing code cell', async ({ page }) => { | |
| await page.notebook.setCell(0, 'code', 'print("Hello, World!")'); | |
| await page.keyboard.press('Shift+Enter'); | |
| @@ -90,10 +82,9 @@ test.describe('Opening Two Notebooks with No Kernel', () => { | |
| await page.click(`.jp-DirListing-item span:has-text("${NOTEBOOK_NAME_1}")`); | |
| await page.keyboard.press('Shift+ArrowDown'); | |
| - await page.click( | |
| - `.jp-DirListing-item span:has-text("${NOTEBOOK_NAME_2}")`, | |
| - { button: 'right' } | |
| - ); | |
| + await page.click(`.jp-DirListing-item span:has-text("${NOTEBOOK_NAME_2}")`, { | |
| + button: 'right' | |
| + }); | |
| expect(await page.menu.isAnyOpen()).toBe(true); | |
| await page.hover('text=Open With'); | |
| await page.click('text=Notebook (no kernel)'); | |
| @@ -105,13 +96,9 @@ test.describe('Opening Two Notebooks with No Kernel', () => { | |
| expect(await page.activity.isTabActive(NOTEBOOK_NAME_2)).toBe(true); | |
| await page.activity.activateTab(NOTEBOOK_NAME_1); | |
| - await expect(page.getByTitle('Switch kernel').first()).toHaveText( | |
| - 'No Kernel' | |
| - ); | |
| + await expect(page.getByTitle('Switch kernel').first()).toHaveText('No Kernel'); | |
| await page.activity.activateTab(NOTEBOOK_NAME_2); | |
| - await expect(page.getByTitle('Switch kernel').first()).toHaveText( | |
| - 'No Kernel' | |
| - ); | |
| + await expect(page.getByTitle('Switch kernel').first()).toHaveText('No Kernel'); | |
| }); | |
| }); | |
| diff --git a/galata/test/jupyterlab/notebook-replace.test.ts b/galata/test/jupyterlab/notebook-replace.test.ts | |
| index 6ebdf490b8..4fe9c21775 100644 | |
| --- a/galata/test/jupyterlab/notebook-replace.test.ts | |
| +++ b/galata/test/jupyterlab/notebook-replace.test.ts | |
| @@ -85,9 +85,9 @@ test.describe('Notebook Search and Replace', () => { | |
| const cell = await page.notebook.getCellLocator(1); | |
| - expect( | |
| - await cell!.locator('.jp-Editor').first().screenshot() | |
| - ).toMatchSnapshot('replace-in-markdown-rendered-cell.png'); | |
| + expect(await cell!.locator('.jp-Editor').first().screenshot()).toMatchSnapshot( | |
| + 'replace-in-markdown-rendered-cell.png' | |
| + ); | |
| }); | |
| test('Replace all', async ({ page, browserName }) => { | |
| diff --git a/galata/test/jupyterlab/notebook-run-mermaid.test.ts b/galata/test/jupyterlab/notebook-run-mermaid.test.ts | |
| index 4052c7a35b..90fde17ce9 100644 | |
| --- a/galata/test/jupyterlab/notebook-run-mermaid.test.ts | |
| +++ b/galata/test/jupyterlab/notebook-run-mermaid.test.ts | |
| @@ -34,10 +34,7 @@ test.describe('Notebook Run Mermaid', () => { | |
| await page.filebrowser.openDirectory(tmpPath); | |
| }); | |
| - test('Run notebook with Mermaid cell in default theme', async ({ | |
| - page, | |
| - tmpPath | |
| - }) => { | |
| + test('Run notebook with Mermaid cell in default theme', async ({ page, tmpPath }) => { | |
| const nbPath = `${tmpPath}/${fileName}`; | |
| await page.notebook.openByPath(nbPath); | |
| await page.notebook.activate(fileName); | |
| @@ -55,10 +52,7 @@ test.describe('Notebook Run Mermaid', () => { | |
| expect(await nbDiskContent(page, nbPath)).toContain(SVG_MIME_TYPE); | |
| }); | |
| - test('Run notebook with Mermaid cell in dark theme', async ({ | |
| - page, | |
| - tmpPath | |
| - }) => { | |
| + test('Run notebook with Mermaid cell in dark theme', async ({ page, tmpPath }) => { | |
| const nbPath = `${tmpPath}/${fileName}`; | |
| await page.notebook.openByPath(nbPath); | |
| await page.notebook.activate(fileName); | |
| diff --git a/galata/test/jupyterlab/notebook-run-vega.test.ts b/galata/test/jupyterlab/notebook-run-vega.test.ts | |
| index 4fca36a9fe..ebf30704aa 100644 | |
| --- a/galata/test/jupyterlab/notebook-run-vega.test.ts | |
| +++ b/galata/test/jupyterlab/notebook-run-vega.test.ts | |
| @@ -34,10 +34,7 @@ test.describe('Notebook Run Vega', () => { | |
| await page.filebrowser.openDirectory(tmpPath); | |
| }); | |
| - test('Run notebook with Vega cell in default theme', async ({ | |
| - page, | |
| - tmpPath | |
| - }) => { | |
| + test('Run notebook with Vega cell in default theme', async ({ page, tmpPath }) => { | |
| const nbPath = `${tmpPath}/${fileName}`; | |
| await page.notebook.openByPath(nbPath); | |
| await page.notebook.activate(fileName); | |
| @@ -55,10 +52,7 @@ test.describe('Notebook Run Vega', () => { | |
| expect(await nbDiskContent(page, nbPath)).toContain(PNG_MIME_TYPE); | |
| }); | |
| - test('Run notebook with Vega cell in dark theme', async ({ | |
| - page, | |
| - tmpPath | |
| - }) => { | |
| + test('Run notebook with Vega cell in dark theme', async ({ page, tmpPath }) => { | |
| const nbPath = `${tmpPath}/${fileName}`; | |
| await page.notebook.openByPath(nbPath); | |
| await page.notebook.activate(fileName); | |
| diff --git a/galata/test/jupyterlab/notebook-scroll-no-windowing.test.ts b/galata/test/jupyterlab/notebook-scroll-no-windowing.test.ts | |
| index 7a3fff9b06..243a44274b 100644 | |
| --- a/galata/test/jupyterlab/notebook-scroll-no-windowing.test.ts | |
| +++ b/galata/test/jupyterlab/notebook-scroll-no-windowing.test.ts | |
| @@ -47,9 +47,7 @@ test.describe('Notebook scroll on navigation (no windowing)', () => { | |
| }; | |
| for (const [link, cellIdx] of Object.entries(cellLinks)) { | |
| test(`Scroll to ${link}`, async ({ page }) => { | |
| - const firstCellLocator = page.locator( | |
| - '.jp-Cell[data-windowed-list-index="0"]' | |
| - ); | |
| + const firstCellLocator = page.locator('.jp-Cell[data-windowed-list-index="0"]'); | |
| const lastCellLocator = page.locator( | |
| `.jp-Cell[data-windowed-list-index="${cellIdx}"]` | |
| ); | |
| @@ -100,9 +98,7 @@ test.describe('Notebook scroll on navigation (no windowing), named properties al | |
| }; | |
| for (const [link, cellIdx] of Object.entries(cellLinks)) { | |
| test(`Scroll to ${link}`, async ({ page }) => { | |
| - const firstCellLocator = page.locator( | |
| - '.jp-Cell[data-windowed-list-index="0"]' | |
| - ); | |
| + const firstCellLocator = page.locator('.jp-Cell[data-windowed-list-index="0"]'); | |
| const lastCellLocator = page.locator( | |
| `.jp-Cell[data-windowed-list-index="${cellIdx}"]` | |
| ); | |
| @@ -135,19 +131,14 @@ test.describe('Notebook scroll on dragging cells (no windowing)', () => { | |
| }); | |
| test('Scroll down on dragging cell to the bottom edge', async ({ page }) => { | |
| - const firstCellLocator = page.locator( | |
| - '.jp-Cell[data-windowed-list-index="0"]' | |
| - ); | |
| - const lastCellLocator = page.locator( | |
| - '.jp-Cell[data-windowed-list-index="19"]' | |
| - ); | |
| + const firstCellLocator = page.locator('.jp-Cell[data-windowed-list-index="0"]'); | |
| + const lastCellLocator = page.locator('.jp-Cell[data-windowed-list-index="19"]'); | |
| const scroller = page.locator(NOTEBOOK_SCROLLER); | |
| await firstCellLocator.scrollIntoViewIfNeeded(); | |
| const scrollerBBox = await scroller.boundingBox(); | |
| - const notebookContentHeight = ( | |
| - await page.locator(NOTEBOOK_CONTENT).boundingBox() | |
| - ).height; | |
| + const notebookContentHeight = (await page.locator(NOTEBOOK_CONTENT).boundingBox()) | |
| + .height; | |
| // Ensure the notebook is scrolled correctly and last cell is not visible | |
| const before = await scroller.evaluate(node => node.scrollTop); | |
| @@ -171,22 +162,14 @@ test.describe('Notebook scroll on dragging cells (no windowing)', () => { | |
| await expect(lastCellLocator).toBeInViewport(); | |
| }); | |
| - test('Scroll up on dragging cell to the top edge', async ({ | |
| - page, | |
| - browserName | |
| - }) => { | |
| - const firstCellLocator = page.locator( | |
| - '.jp-Cell[data-windowed-list-index="0"]' | |
| - ); | |
| - const lastCellLocator = page.locator( | |
| - '.jp-Cell[data-windowed-list-index="19"]' | |
| - ); | |
| + test('Scroll up on dragging cell to the top edge', async ({ page, browserName }) => { | |
| + const firstCellLocator = page.locator('.jp-Cell[data-windowed-list-index="0"]'); | |
| + const lastCellLocator = page.locator('.jp-Cell[data-windowed-list-index="19"]'); | |
| const scroller = page.locator(NOTEBOOK_SCROLLER); | |
| const scrollerBBox = await scroller.boundingBox(); | |
| - const notebookContentHeight = ( | |
| - await page.locator(NOTEBOOK_CONTENT).boundingBox() | |
| - ).height; | |
| + const notebookContentHeight = (await page.locator(NOTEBOOK_CONTENT).boundingBox()) | |
| + .height; | |
| // Scroll notebook to the bottom, leaving top 200px visible | |
| await page.mouse.move( | |
| @@ -249,9 +232,7 @@ test.describe('Notebook scroll on execution (no windowing)', () => { | |
| await expect(thirdCell!).toBeInViewport({ ratio: 0.0 }); | |
| await expect(thirdCell!).not.toBeInViewport({ ratio: 0.02 }); | |
| // Only a small fraction of notebook viewport should be taken up by that cell | |
| - expect(await notebookViewportRatio(notebook!, thirdCell!)).toBeLessThan( | |
| - 0.1 | |
| - ); | |
| + expect(await notebookViewportRatio(notebook!, thirdCell!)).toBeLessThan(0.1); | |
| // Run second cell | |
| await page.notebook.runCell(1); | |
| @@ -261,9 +242,7 @@ test.describe('Notebook scroll on execution (no windowing)', () => { | |
| await expect(thirdCell!).toBeInViewport({ ratio: 0.1 }); | |
| // The third cell should now occupy about half of the notebook viewport | |
| - expect(await notebookViewportRatio(notebook!, thirdCell!)).toBeGreaterThan( | |
| - 0.4 | |
| - ); | |
| + expect(await notebookViewportRatio(notebook!, thirdCell!)).toBeGreaterThan(0.4); | |
| }); | |
| test('should not scroll when advancing if top is non-marginally visible', async ({ | |
| @@ -337,9 +316,7 @@ test.describe('Notebook scroll over long outputs (no windowing)', () => { | |
| await page.contents.deleteDirectory(tmpPath); | |
| }); | |
| - test('should scroll smoothly without snapping to headings', async ({ | |
| - page | |
| - }) => { | |
| + test('should scroll smoothly without snapping to headings', async ({ page }) => { | |
| const renderedMarkdownLocator = page.locator( | |
| '.jp-Cell .jp-RenderedMarkdown:has-text("Before")' | |
| ); | |
| diff --git a/galata/test/jupyterlab/notebook-scroll.test.ts b/galata/test/jupyterlab/notebook-scroll.test.ts | |
| index d62abf259a..c7bc11758b 100644 | |
| --- a/galata/test/jupyterlab/notebook-scroll.test.ts | |
| +++ b/galata/test/jupyterlab/notebook-scroll.test.ts | |
| @@ -47,9 +47,7 @@ test.describe('Notebook scroll on navigation (with windowing)', () => { | |
| }; | |
| for (const [link, cellIdx] of Object.entries(cellLinks)) { | |
| test(`Scroll to ${link}`, async ({ page }) => { | |
| - const firstCellLocator = page.locator( | |
| - '.jp-Cell[data-windowed-list-index="0"]' | |
| - ); | |
| + const firstCellLocator = page.locator('.jp-Cell[data-windowed-list-index="0"]'); | |
| const lastCellLocator = page.locator( | |
| `.jp-Cell[data-windowed-list-index="${cellIdx}"]` | |
| ); | |
| @@ -101,9 +99,7 @@ test.describe('Notebook scroll on navigation (with windowing), named properties | |
| }; | |
| for (const [link, cellIdx] of Object.entries(cellLinks)) { | |
| test(`Scroll to ${link}`, async ({ page }) => { | |
| - const firstCellLocator = page.locator( | |
| - '.jp-Cell[data-windowed-list-index="0"]' | |
| - ); | |
| + const firstCellLocator = page.locator('.jp-Cell[data-windowed-list-index="0"]'); | |
| const lastCellLocator = page.locator( | |
| `.jp-Cell[data-windowed-list-index="${cellIdx}"]` | |
| ); | |
| @@ -136,19 +132,14 @@ test.describe('Notebook scroll on dragging cells (with windowing)', () => { | |
| }); | |
| test('Scroll down on dragging cell to the bottom edge', async ({ page }) => { | |
| - const firstCellLocator = page.locator( | |
| - '.jp-Cell[data-windowed-list-index="0"]' | |
| - ); | |
| - const lastCellLocator = page.locator( | |
| - '.jp-Cell[data-windowed-list-index="19"]' | |
| - ); | |
| + const firstCellLocator = page.locator('.jp-Cell[data-windowed-list-index="0"]'); | |
| + const lastCellLocator = page.locator('.jp-Cell[data-windowed-list-index="19"]'); | |
| const scroller = page.locator(NOTEBOOK_SCROLLER); | |
| await firstCellLocator.scrollIntoViewIfNeeded(); | |
| const scrollerBBox = await scroller.boundingBox(); | |
| - const notebookContentHeight = ( | |
| - await page.locator(NOTEBOOK_CONTENT).boundingBox() | |
| - ).height; | |
| + const notebookContentHeight = (await page.locator(NOTEBOOK_CONTENT).boundingBox()) | |
| + .height; | |
| // Ensure the notebook is scrolled correctly and last cell is not visible | |
| const before = await scroller.evaluate(node => node.scrollTop); | |
| @@ -172,22 +163,14 @@ test.describe('Notebook scroll on dragging cells (with windowing)', () => { | |
| await expect(lastCellLocator).toBeInViewport(); | |
| }); | |
| - test('Scroll up on dragging cell to the top edge', async ({ | |
| - page, | |
| - browserName | |
| - }) => { | |
| - const firstCellLocator = page.locator( | |
| - '.jp-Cell[data-windowed-list-index="0"]' | |
| - ); | |
| - const lastCellLocator = page.locator( | |
| - '.jp-Cell[data-windowed-list-index="19"]' | |
| - ); | |
| + test('Scroll up on dragging cell to the top edge', async ({ page, browserName }) => { | |
| + const firstCellLocator = page.locator('.jp-Cell[data-windowed-list-index="0"]'); | |
| + const lastCellLocator = page.locator('.jp-Cell[data-windowed-list-index="19"]'); | |
| const scroller = page.locator(NOTEBOOK_SCROLLER); | |
| const scrollerBBox = await scroller.boundingBox(); | |
| - const notebookContentHeight = ( | |
| - await page.locator(NOTEBOOK_CONTENT).boundingBox() | |
| - ).height; | |
| + const notebookContentHeight = (await page.locator(NOTEBOOK_CONTENT).boundingBox()) | |
| + .height; | |
| // Scroll notebook to the bottom, leaving top 200px visible | |
| await page.mouse.move( | |
| @@ -250,9 +233,7 @@ test.describe('Notebook scroll on execution (with windowing)', () => { | |
| await expect(thirdCell!).toBeInViewport({ ratio: 0.0 }); | |
| await expect(thirdCell!).not.toBeInViewport({ ratio: 0.02 }); | |
| // Only a small fraction of notebook viewport should be taken up by that cell | |
| - expect(await notebookViewportRatio(notebook!, thirdCell!)).toBeLessThan( | |
| - 0.1 | |
| - ); | |
| + expect(await notebookViewportRatio(notebook!, thirdCell!)).toBeLessThan(0.1); | |
| // Run second cell | |
| await page.notebook.runCell(1); | |
| @@ -261,9 +242,7 @@ test.describe('Notebook scroll on execution (with windowing)', () => { | |
| await expect(thirdCell!).toBeInViewport({ ratio: 0.1 }); | |
| // The third cell should now occupy about half of the notebook viewport | |
| - expect(await notebookViewportRatio(notebook!, thirdCell!)).toBeGreaterThan( | |
| - 0.4 | |
| - ); | |
| + expect(await notebookViewportRatio(notebook!, thirdCell!)).toBeGreaterThan(0.4); | |
| }); | |
| test('should not scroll when advancing if top is non-marginally visible', async ({ | |
| @@ -337,9 +316,7 @@ test.describe('Notebook scroll over long outputs (with windowing)', () => { | |
| await page.contents.deleteDirectory(tmpPath); | |
| }); | |
| - test('should scroll smoothly without snapping to headings', async ({ | |
| - page | |
| - }) => { | |
| + test('should scroll smoothly without snapping to headings', async ({ page }) => { | |
| const renderedMarkdownLocator = page.locator( | |
| '.jp-Cell .jp-RenderedMarkdown:has-text("Before")' | |
| ); | |
| @@ -461,9 +438,7 @@ test.describe('Jump to execution button', () => { | |
| // Hover and verify button exists | |
| await indicator.hover(); | |
| - const jumpButton = page.locator( | |
| - '.jp-Notebook-ExecutionIndicator-jumpButton' | |
| - ); | |
| + const jumpButton = page.locator('.jp-Notebook-ExecutionIndicator-jumpButton'); | |
| await expect(jumpButton).toBeVisible(); | |
| // Click and scroll to the first cell (currently executing) | |
| diff --git a/galata/test/jupyterlab/notebook-search-highlight.test.ts b/galata/test/jupyterlab/notebook-search-highlight.test.ts | |
| index bba6a848af..ccfceb5983 100644 | |
| --- a/galata/test/jupyterlab/notebook-search-highlight.test.ts | |
| +++ b/galata/test/jupyterlab/notebook-search-highlight.test.ts | |
| @@ -23,9 +23,7 @@ test.beforeEach(async ({ page, tmpPath }) => { | |
| const HIGHLIGHTS_LOCATOR = '.cm-searching'; | |
| -test('Open and close Search dialog, then add new code cell', async ({ | |
| - page | |
| -}) => { | |
| +test('Open and close Search dialog, then add new code cell', async ({ page }) => { | |
| // search for our needle | |
| await page.evaluate(async searchText => { | |
| await window.jupyterapp.commands.execute('documentsearch:start', { | |
| @@ -35,9 +33,7 @@ test('Open and close Search dialog, then add new code cell', async ({ | |
| // wait for the search to complete | |
| await page.locator('text=1/21').waitFor(); | |
| - expect(await page.locator(HIGHLIGHTS_LOCATOR).count()).toBeGreaterThanOrEqual( | |
| - 4 | |
| - ); | |
| + expect(await page.locator(HIGHLIGHTS_LOCATOR).count()).toBeGreaterThanOrEqual(4); | |
| // cancel search | |
| await page.keyboard.press('Escape'); | |
| diff --git a/galata/test/jupyterlab/notebook-search.test.ts b/galata/test/jupyterlab/notebook-search.test.ts | |
| index 5a4cb3b1f7..dd90623e4f 100644 | |
| --- a/galata/test/jupyterlab/notebook-search.test.ts | |
| +++ b/galata/test/jupyterlab/notebook-search.test.ts | |
| @@ -88,18 +88,13 @@ test.describe('Notebook Search', () => { | |
| const overlay = page.locator('.jp-DocumentSearch-overlay'); | |
| - expect(await overlay.screenshot()).toMatchSnapshot( | |
| - 'regexp-parsing-failure.png' | |
| - ); | |
| + expect(await overlay.screenshot()).toMatchSnapshot('regexp-parsing-failure.png'); | |
| }); | |
| test('Multi-line search', async ({ page }) => { | |
| await page.keyboard.press('Control+f'); | |
| - await page.fill( | |
| - '[placeholder="Find"]', | |
| - 'one notebook withr\n\n\nThis is a multi' | |
| - ); | |
| + await page.fill('[placeholder="Find"]', 'one notebook withr\n\n\nThis is a multi'); | |
| await page.locator('text=1/1').waitFor(); | |
| @@ -170,11 +165,7 @@ test.describe('Notebook Search', () => { | |
| await cell!.locator('.jp-MarkdownOutput').evaluate(element => { | |
| const textToSelect = 'notebook'; | |
| - const walker = document.createTreeWalker( | |
| - element, | |
| - NodeFilter.SHOW_TEXT, | |
| - null | |
| - ); | |
| + const walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT, null); | |
| let node; | |
| while ((node = walker.nextNode())) { | |
| @@ -214,12 +205,8 @@ test.describe('Notebook Search', () => { | |
| await page.locator('text=2/2').waitFor(); | |
| }); | |
| - test('Restore previous search query if there is no selection', async ({ | |
| - page | |
| - }) => { | |
| - const inputWithTestLocator = page.locator( | |
| - '[placeholder="Find"] >> text="test"' | |
| - ); | |
| + test('Restore previous search query if there is no selection', async ({ page }) => { | |
| + const inputWithTestLocator = page.locator('[placeholder="Find"] >> text="test"'); | |
| const overlayLocator = page.locator('.jp-DocumentSearch-overlay'); | |
| // Search for "test" | |
| @@ -313,9 +300,7 @@ test.describe('Notebook Search', () => { | |
| const nbPanel = await page.notebook.getNotebookInPanelLocator(); | |
| - expect(await nbPanel!.screenshot()).toMatchSnapshot( | |
| - 'search-within-outputs.png' | |
| - ); | |
| + expect(await nbPanel!.screenshot()).toMatchSnapshot('search-within-outputs.png'); | |
| }); | |
| test('Search in a single selected cell', async ({ page }) => { | |
| @@ -331,9 +316,7 @@ test.describe('Notebook Search', () => { | |
| await page.locator('text=1/4').waitFor(); | |
| const nbPanel = await page.notebook.getNotebookInPanelLocator(); | |
| - expect(await nbPanel!.screenshot()).toMatchSnapshot( | |
| - 'search-in-selected-cells.png' | |
| - ); | |
| + expect(await nbPanel!.screenshot()).toMatchSnapshot('search-in-selected-cells.png'); | |
| }); | |
| test('Search in multiple selected cells', async ({ page }) => { | |
| @@ -359,9 +342,7 @@ test.describe('Notebook Search', () => { | |
| await page.locator('text=Search in 1 Selected Cell').waitFor(); | |
| // Wait for the counter to be properly updated | |
| - await page | |
| - .locator('.jp-DocumentSearch-index-counter:has-text("1/10")') | |
| - .waitFor(); | |
| + await page.locator('.jp-DocumentSearch-index-counter:has-text("1/10")').waitFor(); | |
| // Select cell above | |
| await page.keyboard.press('Shift+ArrowUp'); | |
| @@ -434,9 +415,7 @@ test.describe('Notebook Search', () => { | |
| const nbPanel = await page.notebook.getNotebookInPanelLocator(); | |
| - expect(await nbPanel!.screenshot()).toMatchSnapshot( | |
| - 'search-in-selected-text.png' | |
| - ); | |
| + expect(await nbPanel!.screenshot()).toMatchSnapshot('search-in-selected-text.png'); | |
| }); | |
| test('Highlights are visible when text is selected', async ({ page }) => { | |
| @@ -511,9 +490,7 @@ test.describe('Notebook Search', () => { | |
| await page.locator('text=19/21').waitFor(); | |
| const hit = await page.notebook.getCellLocator(2); | |
| - expect(await hit!.screenshot()).toMatchSnapshot( | |
| - 'highlight-previous-element.png' | |
| - ); | |
| + expect(await hit!.screenshot()).toMatchSnapshot('highlight-previous-element.png'); | |
| }); | |
| test('Search from cursor', async ({ page }) => { | |
| @@ -606,9 +583,7 @@ test.describe('Notebook Search', () => { | |
| const nbPanel = await page.notebook.getNotebookInPanelLocator(); | |
| - expect(await nbPanel!.screenshot()).toMatchSnapshot( | |
| - 'search-on-new-cell.png' | |
| - ); | |
| + expect(await nbPanel!.screenshot()).toMatchSnapshot('search-on-new-cell.png'); | |
| }); | |
| test('Search on deleted cell', async ({ page, browserName }) => { | |
| @@ -632,9 +607,7 @@ test.describe('Notebook Search', () => { | |
| const nbPanel = await page.notebook.getNotebookInPanelLocator(); | |
| - expect(await nbPanel!.screenshot()).toMatchSnapshot( | |
| - 'search-on-deleted-cell.png' | |
| - ); | |
| + expect(await nbPanel!.screenshot()).toMatchSnapshot('search-on-deleted-cell.png'); | |
| }); | |
| test('Toggle search in selection with shortcut', async ({ page }) => { | |
| @@ -656,9 +629,7 @@ test.describe('Notebook Search', () => { | |
| await page.keyboard.press('Control+f'); | |
| await page.click('button[title="Show Search Filters"]'); | |
| - await expect( | |
| - page.locator('button[title="Next Match (Ctrl+G)"]') | |
| - ).toHaveCount(1); | |
| + await expect(page.locator('button[title="Next Match (Ctrl+G)"]')).toHaveCount(1); | |
| await expect( | |
| page.locator('button[title="Previous Match (Ctrl+Shift+G)"]') | |
| ).toHaveCount(1); | |
| @@ -688,9 +659,7 @@ test.describe('Auto search in multiple selection', async () => { | |
| await page.keyboard.press('Control+f'); | |
| await page.click('button[title="Show Search Filters"]'); | |
| // Expect search in selection to be disabled when only 1 cell is selected | |
| - await expect( | |
| - page.getByLabel('Search in 1 Selected Cell') | |
| - ).not.toBeChecked(); | |
| + await expect(page.getByLabel('Search in 1 Selected Cell')).not.toBeChecked(); | |
| // Close search box | |
| await page.keyboard.press('Escape'); | |
| @@ -717,9 +686,7 @@ test.describe('Auto search in multiple selection', async () => { | |
| await page.click('button[title="Show Search Filters"]'); | |
| // Expect search in selection to be disabled when only 1 cell is selected | |
| // As only one line is selected, the filter proposes to search in the cell. | |
| - await expect( | |
| - page.getByLabel('Search in 1 Selected Cell') | |
| - ).not.toBeChecked(); | |
| + await expect(page.getByLabel('Search in 1 Selected Cell')).not.toBeChecked(); | |
| // Select 1st and 2nd line | |
| await editor.click(); | |
| @@ -753,9 +720,7 @@ test.describe('Auto search in any selection', async () => { | |
| // Expect search in selection to be disabled as while there is an >active< | |
| // cell, no cells are >selected<; the label is not ideal but it may be | |
| // preferred as-is for consistency. | |
| - await expect( | |
| - page.getByLabel('Search in 1 Selected Cell') | |
| - ).not.toBeChecked(); | |
| + await expect(page.getByLabel('Search in 1 Selected Cell')).not.toBeChecked(); | |
| }); | |
| test('Toggles search in line selection', async ({ page }) => { | |
| @@ -768,9 +733,7 @@ test.describe('Auto search in any selection', async () => { | |
| await page.keyboard.press('Control+f'); | |
| await page.click('button[title="Show Search Filters"]'); | |
| // Expect search in selection to be disabled as no character is selected. | |
| - await expect( | |
| - page.getByLabel('Search in 1 Selected Cell') | |
| - ).not.toBeChecked(); | |
| + await expect(page.getByLabel('Search in 1 Selected Cell')).not.toBeChecked(); | |
| // Select 1st line | |
| await editor.click(); | |
| @@ -785,18 +748,16 @@ test.describe('Auto search in any selection', async () => { | |
| }); | |
| test.describe('Search from selection', () => { | |
| - test('should expand the selection to the next occurrence', async ({ | |
| - page | |
| - }) => { | |
| + test('should expand the selection to the next occurrence', async ({ page }) => { | |
| // This could be improved as the following statement will double click | |
| // on the last line within the first cell that will result in the last word being selected. | |
| await page.getByRole('textbox').getByText('with').nth(1).dblclick(); | |
| await page.keyboard.press('Control+Shift+d'); | |
| - await expect( | |
| - page.getByRole('main').locator('.cm-selectionBackground') | |
| - ).toHaveCount(2); | |
| + await expect(page.getByRole('main').locator('.cm-selectionBackground')).toHaveCount( | |
| + 2 | |
| + ); | |
| }); | |
| test('should expand the selection to all occurrences', async ({ page }) => { | |
| @@ -810,8 +771,8 @@ test.describe('Search from selection', () => { | |
| // FIXME it should not be needed when we get https://github.com/jupyterlab/lumino/pull/662 | |
| await page.activity.activateTab(fileName); | |
| - await expect( | |
| - page.getByRole('main').locator('.cm-selectionBackground') | |
| - ).toHaveCount(4); | |
| + await expect(page.getByRole('main').locator('.cm-selectionBackground')).toHaveCount( | |
| + 4 | |
| + ); | |
| }); | |
| }); | |
| diff --git a/galata/test/jupyterlab/notebook-toolbar.test.ts b/galata/test/jupyterlab/notebook-toolbar.test.ts | |
| index 873a8f1d56..53fe63cc4a 100644 | |
| --- a/galata/test/jupyterlab/notebook-toolbar.test.ts | |
| +++ b/galata/test/jupyterlab/notebook-toolbar.test.ts | |
| @@ -212,27 +212,19 @@ test.describe('Reactive toolbar', () => { | |
| await page.notebook.createNew(fileName); | |
| }); | |
| - test('Reducing toolbar width should display opener item', async ({ | |
| - page | |
| - }) => { | |
| + test('Reducing toolbar width should display opener item', async ({ page }) => { | |
| const toolbar = page.locator('.jp-NotebookPanel-toolbar'); | |
| await expect(toolbar.locator('.jp-Toolbar-item:visible')).toHaveCount(14); | |
| - await expect( | |
| - toolbar.locator('.jp-Toolbar-responsive-opener') | |
| - ).not.toBeVisible(); | |
| + await expect(toolbar.locator('.jp-Toolbar-responsive-opener')).not.toBeVisible(); | |
| await page.sidebar.setWidth(520); | |
| - await expect( | |
| - toolbar.locator('.jp-Toolbar-responsive-opener') | |
| - ).toBeVisible(); | |
| + await expect(toolbar.locator('.jp-Toolbar-responsive-opener')).toBeVisible(); | |
| await expect(toolbar.locator('.jp-Toolbar-item:visible')).toHaveCount(12); | |
| }); | |
| - test('Items in popup toolbar should have the same order', async ({ | |
| - page | |
| - }) => { | |
| + test('Items in popup toolbar should have the same order', async ({ page }) => { | |
| const toolbar = page.locator('.jp-NotebookPanel-toolbar'); | |
| await page.sidebar.setWidth(520); | |
| @@ -242,9 +234,7 @@ test.describe('Reactive toolbar', () => { | |
| // A 'visible' selector is added because there is another response popup element | |
| // when running in playwright (don't know where it come from, it is an empty | |
| // toolbar). | |
| - const popupToolbar = page.locator( | |
| - 'body > .jp-Toolbar-responsive-popup:visible' | |
| - ); | |
| + const popupToolbar = page.locator('body > .jp-Toolbar-responsive-popup:visible'); | |
| const popupToolbarItems = popupToolbar.locator('.jp-Toolbar-item:visible'); | |
| await expect(popupToolbarItems).toHaveCount(3); | |
| @@ -255,22 +245,15 @@ test.describe('Reactive toolbar', () => { | |
| ]; | |
| for (let i = 0; i < (await popupToolbarItems.count()); i++) { | |
| - await expect( | |
| - popupToolbarItems.nth(i).locator(itemChildClasses[i]) | |
| - ).toHaveCount(1); | |
| + await expect(popupToolbarItems.nth(i).locator(itemChildClasses[i])).toHaveCount( | |
| + 1 | |
| + ); | |
| } | |
| }); | |
| - test('Item added from extension should be correctly placed', async ({ | |
| - page | |
| - }) => { | |
| + test('Item added from extension should be correctly placed', async ({ page }) => { | |
| const toolbar = page.locator('.jp-NotebookPanel-toolbar'); | |
| - await addWidgetsInNotebookToolbar( | |
| - page, | |
| - 'notebook.ipynb', | |
| - 'new item 1', | |
| - 'cellType' | |
| - ); | |
| + await addWidgetsInNotebookToolbar(page, 'notebook.ipynb', 'new item 1', 'cellType'); | |
| const toolbarItems = toolbar.locator('.jp-Toolbar-item:visible'); | |
| await expect(toolbarItems.nth(10)).toHaveText('new item 1'); | |
| @@ -278,12 +261,7 @@ test.describe('Reactive toolbar', () => { | |
| test('Item should be correctly placed after resize', async ({ page }) => { | |
| const toolbar = page.locator('.jp-NotebookPanel-toolbar'); | |
| - await addWidgetsInNotebookToolbar( | |
| - page, | |
| - 'notebook.ipynb', | |
| - 'new item 1', | |
| - 'cellType' | |
| - ); | |
| + await addWidgetsInNotebookToolbar(page, 'notebook.ipynb', 'new item 1', 'cellType'); | |
| await page.sidebar.setWidth(600); | |
| await toolbar.locator('.jp-Toolbar-responsive-opener').click(); | |
| @@ -291,9 +269,7 @@ test.describe('Reactive toolbar', () => { | |
| // A 'visible' selector is added because there is another response popup element | |
| // when running in playwright (don't know where it come from, it is an empty | |
| // toolbar). | |
| - const popupToolbar = page.locator( | |
| - 'body > .jp-Toolbar-responsive-popup:visible' | |
| - ); | |
| + const popupToolbar = page.locator('body > .jp-Toolbar-responsive-popup:visible'); | |
| const popupToolbarItems = popupToolbar.locator('.jp-Toolbar-item:visible'); | |
| await expect(popupToolbarItems.nth(1)).toHaveText('new item 1'); | |
| @@ -310,21 +286,14 @@ test.describe('Reactive toolbar', () => { | |
| await page.sidebar.setWidth(600); | |
| - await addWidgetsInNotebookToolbar( | |
| - page, | |
| - 'notebook.ipynb', | |
| - 'new item 1', | |
| - 'cellType' | |
| - ); | |
| + await addWidgetsInNotebookToolbar(page, 'notebook.ipynb', 'new item 1', 'cellType'); | |
| await toolbar.locator('.jp-Toolbar-responsive-opener').click(); | |
| // A 'visible' selector is added because there is another response popup element | |
| // when running in playwright (don't know where it come from, it is an empty | |
| // toolbar). | |
| - const popupToolbar = page.locator( | |
| - 'body > .jp-Toolbar-responsive-popup:visible' | |
| - ); | |
| + const popupToolbar = page.locator('body > .jp-Toolbar-responsive-popup:visible'); | |
| const popupToolbarItems = popupToolbar.locator('.jp-Toolbar-item:visible'); | |
| await expect(popupToolbarItems.nth(1)).toHaveText('new item 1'); | |
| diff --git a/galata/test/jupyterlab/notebook-trust.test.ts b/galata/test/jupyterlab/notebook-trust.test.ts | |
| index cd7d7b0c56..a3b3c44cf8 100644 | |
| --- a/galata/test/jupyterlab/notebook-trust.test.ts | |
| +++ b/galata/test/jupyterlab/notebook-trust.test.ts | |
| @@ -59,10 +59,9 @@ test.describe('Notebook Trust', () => { | |
| const newContent = originalContent.replace('TEST_TEXT', 'SUBSTITUTED_TEXT'); | |
| await page.evaluate( | |
| async ([newContent]) => { | |
| - await window.jupyterapp.commands.execute( | |
| - 'fileeditor:replace-selection', | |
| - { text: newContent } | |
| - ); | |
| + await window.jupyterapp.commands.execute('fileeditor:replace-selection', { | |
| + text: newContent | |
| + }); | |
| // Save file after changes | |
| await window.jupyterapp.commands.execute('docmanager:save'); | |
| // Close the file editor view of the notebook | |
| diff --git a/galata/test/jupyterlab/notification.test.ts b/galata/test/jupyterlab/notification.test.ts | |
| index 0013f72573..e4c36e961e 100644 | |
| --- a/galata/test/jupyterlab/notification.test.ts | |
| +++ b/galata/test/jupyterlab/notification.test.ts | |
| @@ -73,9 +73,9 @@ test.describe('Toast', () => { | |
| const handle = page.locator('.Toastify__toast'); | |
| await handle.waitFor(); | |
| - expect(await handle.screenshot({ animations: 'disabled' })).toMatchSnapshot( | |
| - { name: `notification-with-actions.png` } | |
| - ); | |
| + expect(await handle.screenshot({ animations: 'disabled' })).toMatchSnapshot({ | |
| + name: `notification-with-actions.png` | |
| + }); | |
| await Promise.all([ | |
| handle.last().waitFor({ state: 'hidden' }), | |
| @@ -115,9 +115,7 @@ test.describe('Toast', () => { | |
| const handle = page.locator('.Toastify__toast').first(); | |
| await handle.waitFor(); | |
| - expect( | |
| - await handle.screenshot({ animations: 'disabled' }) | |
| - ).toMatchSnapshot({ | |
| + expect(await handle.screenshot({ animations: 'disabled' })).toMatchSnapshot({ | |
| name: `notification-${displayType}-action.png` | |
| }); | |
| }); | |
| @@ -136,9 +134,7 @@ test.describe('Toast', () => { | |
| await page.locator('.Toastify__toast').first().waitFor(); | |
| - expect( | |
| - await page.locator('.Toastify__toast-body').innerHTML() | |
| - ).toMatchSnapshot({ | |
| + expect(await page.locator('.Toastify__toast-body').innerHTML()).toMatchSnapshot({ | |
| name: 'text-content-notification.txt' | |
| }); | |
| }); | |
| @@ -154,19 +150,14 @@ test.describe('Toast', () => { | |
| await page.locator('.Toastify__toast >> text=Simple note').waitFor(); | |
| await page.evaluate(id => { | |
| - return window.jupyterapp.commands.execute( | |
| - 'apputils:update-notification', | |
| - { | |
| - id, | |
| - message: 'Updated message', | |
| - type: 'success' | |
| - } | |
| - ); | |
| + return window.jupyterapp.commands.execute('apputils:update-notification', { | |
| + id, | |
| + message: 'Updated message', | |
| + type: 'success' | |
| + }); | |
| }, id); | |
| - await expect(page.locator('.Toastify__toast')).toHaveText( | |
| - 'Updated message' | |
| - ); | |
| + await expect(page.locator('.Toastify__toast')).toHaveText('Updated message'); | |
| }); | |
| test('should dismiss a notification', async ({ page }) => { | |
| @@ -184,10 +175,9 @@ test.describe('Toast', () => { | |
| .locator('.Toastify__toast >> text=Simple note') | |
| .waitFor({ state: 'detached' }), | |
| page.evaluate(id => { | |
| - return window.jupyterapp.commands.execute( | |
| - 'apputils:dismiss-notification', | |
| - { id } | |
| - ); | |
| + return window.jupyterapp.commands.execute('apputils:dismiss-notification', { | |
| + id | |
| + }); | |
| }, id) | |
| ]); | |
| }); | |
| @@ -196,9 +186,7 @@ test.describe('Toast', () => { | |
| test.describe('Notification center', () => { | |
| test('should display no notification by default', async ({ page }) => { | |
| const status = page.locator('.jp-Notification-Status'); | |
| - expect(await status.getAttribute('class')).not.toMatch( | |
| - /\s?jp-mod-selected\s?/ | |
| - ); | |
| + expect(await status.getAttribute('class')).not.toMatch(/\s?jp-mod-selected\s?/); | |
| await expect(status).toHaveText('0'); | |
| await status.click(); | |
| @@ -222,14 +210,10 @@ test.describe('Notification center', () => { | |
| await status.click(); | |
| - await expect(page.locator('.jp-Notification-Header')).toHaveText( | |
| - '1 notification' | |
| - ); | |
| + await expect(page.locator('.jp-Notification-Header')).toHaveText('1 notification'); | |
| }); | |
| - test('should stop the highlight once the center is closed', async ({ | |
| - page | |
| - }) => { | |
| + test('should stop the highlight once the center is closed', async ({ page }) => { | |
| await page.evaluate(() => { | |
| return window.jupyterapp.commands.execute('apputils:notify', { | |
| message: 'Simple note' | |
| @@ -240,19 +224,13 @@ test.describe('Notification center', () => { | |
| await status.click(); | |
| - await expect(page.locator('.jp-Notification-Header')).toHaveText( | |
| - '1 notification' | |
| - ); | |
| + await expect(page.locator('.jp-Notification-Header')).toHaveText('1 notification'); | |
| await page | |
| - .locator( | |
| - '.jp-Notification-Header >> jp-button[title="Hide notifications"]' | |
| - ) | |
| + .locator('.jp-Notification-Header >> jp-button[title="Hide notifications"]') | |
| .click(); | |
| - expect(await status.getAttribute('class')).not.toMatch( | |
| - /\s?jp-mod-selected\s?/ | |
| - ); | |
| + expect(await status.getAttribute('class')).not.toMatch(/\s?jp-mod-selected\s?/); | |
| await expect(status).toHaveText('1'); | |
| }); | |
| @@ -271,9 +249,7 @@ test.describe('Notification center', () => { | |
| await status.click(); | |
| - await expect(page.locator('.jp-Notification-Header')).toHaveText( | |
| - '2 notifications' | |
| - ); | |
| + await expect(page.locator('.jp-Notification-Header')).toHaveText('2 notifications'); | |
| await page | |
| .locator('.jp-Notification-List >> li >> [title="Dismiss notification"]') | |
| diff --git a/galata/test/jupyterlab/output-scrolling.test.ts b/galata/test/jupyterlab/output-scrolling.test.ts | |
| index a7b49dab2b..58f3e71600 100644 | |
| --- a/galata/test/jupyterlab/output-scrolling.test.ts | |
| +++ b/galata/test/jupyterlab/output-scrolling.test.ts | |
| @@ -32,9 +32,7 @@ test.describe('Output Scrolling', () => { | |
| test('Scrolling mode', async ({ page }) => { | |
| await page.evaluate(() => { | |
| - return window.jupyterapp.commands.execute( | |
| - 'notebook:enable-output-scrolling' | |
| - ); | |
| + return window.jupyterapp.commands.execute('notebook:enable-output-scrolling'); | |
| }); | |
| await page.notebook.selectCells(0); | |
| await expect(page.locator(`${cellSelector} >> nth=0`)).toHaveClass( | |
| @@ -48,9 +46,7 @@ test.describe('Output Scrolling', () => { | |
| ); | |
| await page.evaluate(() => { | |
| - return window.jupyterapp.commands.execute( | |
| - 'notebook:disable-output-scrolling' | |
| - ); | |
| + return window.jupyterapp.commands.execute('notebook:disable-output-scrolling'); | |
| }); | |
| await expect(page.locator(`${cellSelector} >> nth=0`)).not.toHaveClass( | |
| /jp-mod-outputsScrolled/ | |
| @@ -62,21 +58,13 @@ test.describe('Output Scrolling', () => { | |
| .locator(`${cellSelector} >> nth=1 >> .jp-OutputArea-promptOverlay`) | |
| .hover(); | |
| const cell = await page.notebook.getCellLocator(1); | |
| - expect(await cell!.screenshot()).toMatchSnapshot( | |
| - 'prompt-overlay-hover-normal.png' | |
| - ); | |
| - await page.click( | |
| - `${cellSelector} >> nth=1 >> .jp-OutputArea-promptOverlay` | |
| - ); | |
| + expect(await cell!.screenshot()).toMatchSnapshot('prompt-overlay-hover-normal.png'); | |
| + await page.click(`${cellSelector} >> nth=1 >> .jp-OutputArea-promptOverlay`); | |
| await expect(page.locator(`${cellSelector} >> nth=1`)).toHaveClass( | |
| /jp-mod-outputsScrolled/ | |
| ); | |
| - expect(await cell!.screenshot()).toMatchSnapshot( | |
| - 'prompt-overlay-hover-scroll.png' | |
| - ); | |
| - await page.click( | |
| - `${cellSelector} >> nth=1 >> .jp-OutputArea-promptOverlay` | |
| - ); | |
| + expect(await cell!.screenshot()).toMatchSnapshot('prompt-overlay-hover-scroll.png'); | |
| + await page.click(`${cellSelector} >> nth=1 >> .jp-OutputArea-promptOverlay`); | |
| await expect(page.locator(`${cellSelector} >> nth=1`)).not.toHaveClass( | |
| /jp-mod-outputsScrolled/ | |
| ); | |
| diff --git a/galata/test/jupyterlab/outputarea-stdin.test.ts b/galata/test/jupyterlab/outputarea-stdin.test.ts | |
| index b3f6fd8c78..82ad38743c 100644 | |
| --- a/galata/test/jupyterlab/outputarea-stdin.test.ts | |
| +++ b/galata/test/jupyterlab/outputarea-stdin.test.ts | |
| @@ -59,9 +59,7 @@ test.describe('Stdin for ipdb', () => { | |
| // Mask out random kernel temporary file path | |
| // e.g. `/tmp/ipykernel_104185/2235509928.py` | |
| - const filePath = page.locator( | |
| - '.jp-OutputArea-output :text-matches("/tmp/")' | |
| - ); | |
| + const filePath = page.locator('.jp-OutputArea-output :text-matches("/tmp/")'); | |
| await filePath.evaluate(node => (node.textContent = '/tmp/masked.py')); | |
| const imageName = 'stdin-history-search.png'; | |
| diff --git a/galata/test/jupyterlab/save.test.ts b/galata/test/jupyterlab/save.test.ts | |
| index 75141b1ae3..d6c7971509 100644 | |
| --- a/galata/test/jupyterlab/save.test.ts | |
| +++ b/galata/test/jupyterlab/save.test.ts | |
| @@ -44,9 +44,7 @@ for (const type of ['Text', 'Notebook', 'Markdown']) { | |
| } | |
| for (const type of ['Text', 'Notebook', 'Markdown']) { | |
| - test(`Should not prompt to rename new renamed ${type} file`, async ({ | |
| - page | |
| - }) => { | |
| + test(`Should not prompt to rename new renamed ${type} file`, async ({ page }) => { | |
| await page.menu.clickMenuItem( | |
| type === 'Notebook' ? `File>New>${type}` : `File>New>${type} File` | |
| ); | |
| diff --git a/galata/test/jupyterlab/settings.test.ts b/galata/test/jupyterlab/settings.test.ts | |
| index f6a47aa65d..b406413850 100644 | |
| --- a/galata/test/jupyterlab/settings.test.ts | |
| +++ b/galata/test/jupyterlab/settings.test.ts | |
| @@ -9,9 +9,7 @@ import fs from 'fs'; | |
| import path from 'path'; | |
| import { changeCodeFontSize, getFileListFontSize } from './utils'; | |
| -test('Open the settings editor with a specific search query', async ({ | |
| - page | |
| -}) => { | |
| +test('Open the settings editor with a specific search query', async ({ page }) => { | |
| await page.evaluate(async () => { | |
| await window.jupyterapp.commands.execute('settingeditor:open', { | |
| query: 'Command Palette' | |
| @@ -19,9 +17,7 @@ test('Open the settings editor with a specific search query', async ({ | |
| }); | |
| expect( | |
| - await page | |
| - .locator('.jp-PluginList jp-search') | |
| - .evaluate(elem => (elem as any).value) | |
| + await page.locator('.jp-PluginList jp-search').evaluate(elem => (elem as any).value) | |
| ).toEqual('Command Palette'); | |
| await expect(page.locator('.jp-SettingsForm')).toHaveCount(1); | |
| @@ -34,9 +30,7 @@ test('Open the settings editor with a specific search query', async ({ | |
| const settingsPanel = page.locator('.jp-SettingsPanel'); | |
| - expect | |
| - .soft(await settingsPanel.screenshot()) | |
| - .toMatchSnapshot('settings-panel.png'); | |
| + expect.soft(await settingsPanel.screenshot()).toMatchSnapshot('settings-panel.png'); | |
| // Test that new query takes effect | |
| await expect(page.locator('.jp-PluginList-entry')).toHaveCount(1); | |
| @@ -77,9 +71,7 @@ test.describe('change font-size', () => { | |
| const cellElement = page.locator( | |
| 'div.lm-Widget.jp-Cell.jp-CodeCell.jp-Notebook-cell.jp-mod-noOutputs.jp-mod-active.jp-mod-selected .cm-line' | |
| ); | |
| - const newFontSize = await cellElement.evaluate( | |
| - el => getComputedStyle(el).fontSize | |
| - ); | |
| + const newFontSize = await cellElement.evaluate(el => getComputedStyle(el).fontSize); | |
| return parseInt(newFontSize); | |
| }; | |
| const getMarkdownFontSize = async (page: IJupyterLabPageFixture) => { | |
| @@ -102,9 +94,7 @@ test.describe('change font-size', () => { | |
| const cellElement = page.locator( | |
| 'div.lm-Widget.jp-Cell.jp-CodeCell.jp-Notebook-cell.jp-mod-noOutputs.jp-mod-active.jp-mod-selected .cm-line' | |
| ); | |
| - const newFontSize = await cellElement.evaluate( | |
| - el => getComputedStyle(el).fontSize | |
| - ); | |
| + const newFontSize = await cellElement.evaluate(el => getComputedStyle(el).fontSize); | |
| expect(newFontSize).toEqual(`${fontSize + 1}px`); | |
| }); | |
| @@ -119,9 +109,7 @@ test.describe('change font-size', () => { | |
| const cellElement = page.locator( | |
| 'div.lm-Widget.jp-Cell.jp-CodeCell.jp-Notebook-cell.jp-mod-noOutputs.jp-mod-active.jp-mod-selected .cm-line' | |
| ); | |
| - const newFontSize = await cellElement.evaluate( | |
| - el => getComputedStyle(el).fontSize | |
| - ); | |
| + const newFontSize = await cellElement.evaluate(el => getComputedStyle(el).fontSize); | |
| expect(newFontSize).toEqual(`${fontSize - 1}px`); | |
| }); | |
| @@ -137,9 +125,7 @@ test.describe('change font-size', () => { | |
| await page.locator('.jp-FileEditor .cm-content').waitFor(); | |
| const fileElement = page.locator('.jp-RenderedHTMLCommon'); | |
| - const newFontSize = await fileElement.evaluate( | |
| - el => getComputedStyle(el).fontSize | |
| - ); | |
| + const newFontSize = await fileElement.evaluate(el => getComputedStyle(el).fontSize); | |
| expect(newFontSize).toEqual(`${fontSize + 1}px`); | |
| }); | |
| @@ -155,9 +141,7 @@ test.describe('change font-size', () => { | |
| await page.locator('.jp-FileEditor .cm-content').waitFor(); | |
| const fileElement = page.locator('.jp-RenderedHTMLCommon'); | |
| - const newFontSize = await fileElement.evaluate( | |
| - el => getComputedStyle(el).fontSize | |
| - ); | |
| + const newFontSize = await fileElement.evaluate(el => getComputedStyle(el).fontSize); | |
| expect(newFontSize).toEqual(`${fontSize - 1}px`); | |
| }); | |
| @@ -166,15 +150,9 @@ test.describe('change font-size', () => { | |
| const fontSize = await getFileListFontSize(page); | |
| await changeCodeFontSize(page, 'Increase UI Font Size'); | |
| - await page | |
| - .locator('.jp-DirListing-content .jp-DirListing-itemText') | |
| - .waitFor(); | |
| - const fileElement = page.locator( | |
| - '.jp-DirListing-content .jp-DirListing-itemText' | |
| - ); | |
| - const newFontSize = await fileElement.evaluate( | |
| - el => getComputedStyle(el).fontSize | |
| - ); | |
| + await page.locator('.jp-DirListing-content .jp-DirListing-itemText').waitFor(); | |
| + const fileElement = page.locator('.jp-DirListing-content .jp-DirListing-itemText'); | |
| + const newFontSize = await fileElement.evaluate(el => getComputedStyle(el).fontSize); | |
| expect(newFontSize).toEqual(`${fontSize + 1}px`); | |
| }); | |
| @@ -183,22 +161,14 @@ test.describe('change font-size', () => { | |
| const fontSize = await getFileListFontSize(page); | |
| await changeCodeFontSize(page, 'Decrease UI Font Size'); | |
| - await page | |
| - .locator('.jp-DirListing-content .jp-DirListing-itemText') | |
| - .waitFor(); | |
| - const fileElement = page.locator( | |
| - '.jp-DirListing-content .jp-DirListing-itemText' | |
| - ); | |
| - const newFontSize = await fileElement.evaluate( | |
| - el => getComputedStyle(el).fontSize | |
| - ); | |
| + await page.locator('.jp-DirListing-content .jp-DirListing-itemText').waitFor(); | |
| + const fileElement = page.locator('.jp-DirListing-content .jp-DirListing-itemText'); | |
| + const newFontSize = await fileElement.evaluate(el => getComputedStyle(el).fontSize); | |
| expect(newFontSize).toEqual(`${fontSize - 1}px`); | |
| }); | |
| }); | |
| -test('Check codemirror settings can all be set at the same time.', async ({ | |
| - page | |
| -}) => { | |
| +test('Check codemirror settings can all be set at the same time.', async ({ page }) => { | |
| await page.evaluate(async () => { | |
| await window.jupyterapp.commands.execute('settingeditor:open', { | |
| query: 'CodeMirror' | |
| @@ -301,18 +271,14 @@ test('Keyboard Shortcuts: validate "Or" button behavior when editing shortcuts', | |
| const filterInput = shortcutsForm.locator('jp-search.jp-FilterBox'); | |
| await filterInput.locator('input').fill('merge cell below'); | |
| - const shortcutsContainer = page.locator( | |
| - '.jp-Shortcuts-ShortcutListContainer' | |
| - ); | |
| + const shortcutsContainer = page.locator('.jp-Shortcuts-ShortcutListContainer'); | |
| const firstRow = shortcutsContainer.locator('.jp-Shortcuts-Row').first(); | |
| const shortcutKey = firstRow.locator('.jp-Shortcuts-ShortcutKeys').first(); | |
| await shortcutKey.click(); | |
| await page.waitForTimeout(300); | |
| await firstRow.hover(); | |
| - expect(await firstRow.screenshot()).toMatchSnapshot( | |
| - 'settings-shortcuts-edit.png' | |
| - ); | |
| + expect(await firstRow.screenshot()).toMatchSnapshot('settings-shortcuts-edit.png'); | |
| }); | |
| test('Settings Export: Clicking the export button triggers a download and matches content', async ({ | |
| @@ -373,10 +339,7 @@ test('Settings Import: Importing a JSON file applies the correct settings', asyn | |
| } | |
| }; | |
| const importDirectory = 'temporary/imports'; | |
| - const importFilePath = path.join( | |
| - importDirectory, | |
| - 'overrides_settings_test.json' | |
| - ); | |
| + const importFilePath = path.join(importDirectory, 'overrides_settings_test.json'); | |
| // Create directory and write the JSON file | |
| fs.mkdirSync(importDirectory, { recursive: true }); | |
| @@ -411,9 +374,7 @@ test('Settings Import: Importing a JSON file applies the correct settings', asyn | |
| test('Ensure that fuzzy filter works properly', async ({ page }) => { | |
| // Helper function to rename a notebook | |
| const renameFile = async (oldName: string, newName: string) => { | |
| - await page | |
| - .locator(`.jp-DirListing-itemName:has-text("${oldName}")`) | |
| - .click(); | |
| + await page.locator(`.jp-DirListing-itemName:has-text("${oldName}")`).click(); | |
| await page.keyboard.press('F2'); | |
| await page.keyboard.type(newName); | |
| await page.keyboard.press('Enter'); | |
| @@ -465,9 +426,7 @@ test('Read-only cells should remain read-only after changing settings', async ({ | |
| .selectOption({ label: 'Read-Only' }); | |
| // Change a notebook setting (kernel preference) | |
| - await page.notebook | |
| - .getToolbarItemLocator('kernelName') | |
| - .then(item => item?.click()); | |
| + await page.notebook.getToolbarItemLocator('kernelName').then(item => item?.click()); | |
| await page.locator('.jp-Dialog-checkbox').click(); | |
| await page.locator('.jp-Dialog-button:has-text("Select")').click(); | |
| diff --git a/galata/test/jupyterlab/sidebars.test.ts b/galata/test/jupyterlab/sidebars.test.ts | |
| index 14747aa81d..12544c873d 100644 | |
| --- a/galata/test/jupyterlab/sidebars.test.ts | |
| +++ b/galata/test/jupyterlab/sidebars.test.ts | |
| @@ -16,9 +16,9 @@ const sidebarElementIds = { | |
| 'right-sidebar': ['jp-property-inspector', 'jp-debugger-sidebar'] | |
| }; | |
| -const sidebarIds: galata.SidebarTabId[] = sidebarElementIds[ | |
| - 'left-sidebar' | |
| -].concat(sidebarElementIds['right-sidebar']); | |
| +const sidebarIds: galata.SidebarTabId[] = sidebarElementIds['left-sidebar'].concat( | |
| + sidebarElementIds['right-sidebar'] | |
| +); | |
| test.use({ | |
| mockState: true | |
| @@ -46,12 +46,8 @@ test.describe('Sidebars', () => { | |
| const imageName = `opened-sidebar-${sidebarId.replace('.', '-')}.png`; | |
| const position = await page.sidebar.getTabPosition(sidebarId); | |
| - const sidebar = page.sidebar.getContentPanelLocator( | |
| - position ?? undefined | |
| - ); | |
| - expect(await sidebar.screenshot()).toMatchSnapshot( | |
| - imageName.toLowerCase() | |
| - ); | |
| + const sidebar = page.sidebar.getContentPanelLocator(position ?? undefined); | |
| + expect(await sidebar.screenshot()).toMatchSnapshot(imageName.toLowerCase()); | |
| }); | |
| }); | |
| @@ -61,10 +57,7 @@ test.describe('Sidebars', () => { | |
| const contextmenu = await page.menu.openContextMenuLocator( | |
| '.jp-DirListing-headerItem' | |
| ); | |
| - const item = await page.menu.getMenuItemLocatorInMenu( | |
| - contextmenu, | |
| - command | |
| - ); | |
| + const item = await page.menu.getMenuItemLocatorInMenu(contextmenu, command); | |
| await item?.click(); | |
| }; | |
| await clickMenuItem('Show File Checkboxes'); | |
| @@ -138,9 +131,7 @@ test.describe('Sidebars', () => { | |
| test('Move Debugger to left', async ({ page }) => { | |
| await page.sidebar.moveTabToLeft('jp-debugger-sidebar'); | |
| - expect(await page.sidebar.getTabPosition('jp-debugger-sidebar')).toEqual( | |
| - 'left' | |
| - ); | |
| + expect(await page.sidebar.getTabPosition('jp-debugger-sidebar')).toEqual('left'); | |
| }); | |
| test('Check Running Session button on sidebar has correct aria label and role', async ({ | |
| @@ -150,8 +141,7 @@ test.describe('Sidebars', () => { | |
| const runningSessionsWidget = page.locator('#jp-running-sessions'); | |
| const runningSessionsElementAriaLabel = | |
| await runningSessionsWidget.getAttribute('aria-label'); | |
| - const runningSessionsElementRole = | |
| - await runningSessionsWidget.getAttribute('role'); | |
| + const runningSessionsElementRole = await runningSessionsWidget.getAttribute('role'); | |
| expect(runningSessionsElementAriaLabel).toEqual('Running Sessions section'); | |
| expect(runningSessionsElementRole).toEqual('region'); | |
| }); | |
| @@ -160,16 +150,12 @@ test.describe('Sidebars', () => { | |
| page | |
| }) => { | |
| await page.sidebar.open('left'); | |
| - const extensionManagerWidget = page.locator( | |
| - '#extensionmanager\\.main-view' | |
| - ); | |
| + const extensionManagerWidget = page.locator('#extensionmanager\\.main-view'); | |
| const extensionManagerElementAriaLabel = | |
| await extensionManagerWidget.getAttribute('aria-label'); | |
| const extensionManagerElementRole = | |
| await extensionManagerWidget.getAttribute('role'); | |
| - expect(extensionManagerElementAriaLabel).toEqual( | |
| - 'Extension Manager section' | |
| - ); | |
| + expect(extensionManagerElementAriaLabel).toEqual('Extension Manager section'); | |
| expect(extensionManagerElementRole).toEqual('region'); | |
| }); | |
| @@ -190,8 +176,7 @@ test.describe('Sidebars', () => { | |
| }) => { | |
| await page.sidebar.open('right'); | |
| const debuggerWidget = page.locator('#jp-debugger-sidebar'); | |
| - const debuggerElementAriaLabel = | |
| - await debuggerWidget.getAttribute('aria-label'); | |
| + const debuggerElementAriaLabel = await debuggerWidget.getAttribute('aria-label'); | |
| const debuggerElementRole = await debuggerWidget.getAttribute('role'); | |
| expect(debuggerElementAriaLabel).toEqual('Debugger section'); | |
| expect(debuggerElementRole).toEqual('region'); | |
| @@ -204,11 +189,8 @@ test.describe('Sidebars', () => { | |
| const tableOfContentsWidget = page.locator('#table-of-contents'); | |
| const tableOfContentsElementAriaLabel = | |
| await tableOfContentsWidget.getAttribute('aria-label'); | |
| - const tableOfContentsElementRole = | |
| - await tableOfContentsWidget.getAttribute('role'); | |
| - expect(tableOfContentsElementAriaLabel).toEqual( | |
| - 'Table of Contents section' | |
| - ); | |
| + const tableOfContentsElementRole = await tableOfContentsWidget.getAttribute('role'); | |
| + expect(tableOfContentsElementAriaLabel).toEqual('Table of Contents section'); | |
| expect(tableOfContentsElementRole).toEqual('region'); | |
| }); | |
| }); | |
| @@ -250,10 +232,7 @@ test.describe('Sidebar keyboard navigation @a11y', () => { | |
| await page.goto(); | |
| await page.sidebar.close('right'); | |
| await page.sidebar.close('left'); | |
| - await page.activity.keyToElement( | |
| - `[data-id='${keyValueArray[0]}']`, | |
| - 'Tab' | |
| - ); | |
| + await page.activity.keyToElement(`[data-id='${keyValueArray[0]}']`, 'Tab'); | |
| await page.activity.keyToElement(`[data-id='${dataId}']`, 'ArrowDown'); | |
| diff --git a/galata/test/jupyterlab/styles.test.ts b/galata/test/jupyterlab/styles.test.ts | |
| index ebf7ff3f2e..5d3ec37cb5 100644 | |
| --- a/galata/test/jupyterlab/styles.test.ts | |
| +++ b/galata/test/jupyterlab/styles.test.ts | |
| @@ -171,9 +171,7 @@ test.describe('CSS Selectors', () => { | |
| const allTags = new Set([...standardHTMLTags, ...detectedTags]); | |
| const selectors: string[] = await page.style.collectAllSelectors(); | |
| - const matcher = new RegExp( | |
| - ':hover.*\\s+(' + [...allTags].join('|') + ')($|\\s)' | |
| - ); | |
| + const matcher = new RegExp(':hover.*\\s+(' + [...allTags].join('|') + ')($|\\s)'); | |
| const matchedSelectors: string[] = []; | |
| diff --git a/galata/test/jupyterlab/terminal.test.ts b/galata/test/jupyterlab/terminal.test.ts | |
| index fdbeed4fa5..921882a289 100644 | |
| --- a/galata/test/jupyterlab/terminal.test.ts | |
| +++ b/galata/test/jupyterlab/terminal.test.ts | |
| @@ -25,13 +25,8 @@ test.describe('Terminal', () => { | |
| test('Light theme terminal inherit', async ({ page }) => { | |
| const terminal = page.locator(TERMINAL_SELECTOR); | |
| await terminal.waitFor(); | |
| - await expect(terminal).toHaveAttribute( | |
| - TERMINAL_THEME_ATTRIBUTE, | |
| - 'inherit' | |
| - ); | |
| - expect(await terminal.screenshot()).toMatchSnapshot( | |
| - 'light-term-inherit.png' | |
| - ); | |
| + await expect(terminal).toHaveAttribute(TERMINAL_THEME_ATTRIBUTE, 'inherit'); | |
| + expect(await terminal.screenshot()).toMatchSnapshot('light-term-inherit.png'); | |
| }); | |
| test('Light theme terminal light', async ({ page }) => { | |
| @@ -39,9 +34,7 @@ test.describe('Terminal', () => { | |
| await terminal.waitFor(); | |
| await page.menu.clickMenuItem('Settings>Terminal Theme>Light'); | |
| await expect(terminal).toHaveAttribute(TERMINAL_THEME_ATTRIBUTE, 'light'); | |
| - expect(await terminal.screenshot()).toMatchSnapshot( | |
| - 'light-term-light.png' | |
| - ); | |
| + expect(await terminal.screenshot()).toMatchSnapshot('light-term-light.png'); | |
| }); | |
| test('Light theme terminal dark', async ({ page }) => { | |
| @@ -49,22 +42,15 @@ test.describe('Terminal', () => { | |
| await terminal.waitFor(); | |
| await page.menu.clickMenuItem('Settings>Terminal Theme>Dark'); | |
| await expect(terminal).toHaveAttribute(TERMINAL_THEME_ATTRIBUTE, 'dark'); | |
| - expect(await terminal.screenshot()).toMatchSnapshot( | |
| - 'light-term-dark.png' | |
| - ); | |
| + expect(await terminal.screenshot()).toMatchSnapshot('light-term-dark.png'); | |
| }); | |
| test('Dark theme terminal inherit', async ({ page }) => { | |
| const terminal = page.locator(TERMINAL_SELECTOR); | |
| await terminal.waitFor(); | |
| await page.theme.setDarkTheme(); | |
| - await expect(terminal).toHaveAttribute( | |
| - TERMINAL_THEME_ATTRIBUTE, | |
| - 'inherit' | |
| - ); | |
| - expect(await terminal.screenshot()).toMatchSnapshot( | |
| - 'dark-term-inherit.png' | |
| - ); | |
| + await expect(terminal).toHaveAttribute(TERMINAL_THEME_ATTRIBUTE, 'inherit'); | |
| + expect(await terminal.screenshot()).toMatchSnapshot('dark-term-inherit.png'); | |
| }); | |
| test('Dark theme terminal light', async ({ page }) => { | |
| @@ -73,9 +59,7 @@ test.describe('Terminal', () => { | |
| await page.theme.setDarkTheme(); | |
| await page.menu.clickMenuItem('Settings>Terminal Theme>Light'); | |
| await expect(terminal).toHaveAttribute(TERMINAL_THEME_ATTRIBUTE, 'light'); | |
| - expect(await terminal.screenshot()).toMatchSnapshot( | |
| - 'dark-term-light.png' | |
| - ); | |
| + expect(await terminal.screenshot()).toMatchSnapshot('dark-term-light.png'); | |
| }); | |
| test('Dark theme terminal dark', async ({ page }) => { | |
| diff --git a/galata/test/jupyterlab/texteditor.test.ts b/galata/test/jupyterlab/texteditor.test.ts | |
| index a008139035..647a56ac82 100644 | |
| --- a/galata/test/jupyterlab/texteditor.test.ts | |
| +++ b/galata/test/jupyterlab/texteditor.test.ts | |
| @@ -108,18 +108,14 @@ ut elit.` | |
| const wrapperElement = page.locator( | |
| '.jp-MainAreaWidget .jp-FileEditor .cm-content.cm-lineWrapping' | |
| ); | |
| - const computedStyle = await wrapperElement.evaluate(el => | |
| - getComputedStyle(el) | |
| - ); | |
| + const computedStyle = await wrapperElement.evaluate(el => getComputedStyle(el)); | |
| return parseInt(computedStyle.fontSize); | |
| }; | |
| const createNewTextEditor = async (page: IJupyterLabPageFixture) => { | |
| await page.menu.clickMenuItem('File>New>Text File'); | |
| await page.locator(`[role="main"] >> text=${DEFAULT_NAME}`).waitFor(); | |
| - await page | |
| - .locator('.jp-FileEditorCodeWrapper .cm-content') | |
| - .fill('text editor'); | |
| + await page.locator('.jp-FileEditorCodeWrapper .cm-content').fill('text editor'); | |
| }; | |
| const changeFontSize = async (page: IJupyterLabPageFixture, menuOption) => { | |
| await page.click('text=Settings'); | |
| diff --git a/galata/test/jupyterlab/toc-running.test.ts b/galata/test/jupyterlab/toc-running.test.ts | |
| index 252db576b1..23b8d000ee 100644 | |
| --- a/galata/test/jupyterlab/toc-running.test.ts | |
| +++ b/galata/test/jupyterlab/toc-running.test.ts | |
| @@ -15,9 +15,7 @@ test.describe('ToC Running indicator', () => { | |
| await page.sidebar.openTab('table-of-contents'); | |
| // Wait until the last heading has loaded into the ToC | |
| - await page | |
| - .getByRole('treeitem', { name: 'Title 1.3', exact: true }) | |
| - .waitFor(); | |
| + await page.getByRole('treeitem', { name: 'Title 1.3', exact: true }).waitFor(); | |
| }); | |
| test.beforeAll(async ({ request, tmpPath }) => { | |
| @@ -40,9 +38,7 @@ test.describe('ToC Running indicator', () => { | |
| ); | |
| const executed = page.notebook.run(); | |
| await tocPanel.locator('[data-running="1"]').waitFor(); | |
| - expect(await tocPanel.screenshot()).toMatchSnapshot( | |
| - 'toc-running-indicators.png' | |
| - ); | |
| + expect(await tocPanel.screenshot()).toMatchSnapshot('toc-running-indicators.png'); | |
| await executed; | |
| }); | |
| @@ -76,9 +72,10 @@ test.describe('ToC Running indicator', () => { | |
| const executed = page.notebook.runCell(5); | |
| - await expect( | |
| - tocPanel.getByTitle('Title 1', { exact: true }) | |
| - ).toHaveAttribute('data-running', '1'); | |
| + await expect(tocPanel.getByTitle('Title 1', { exact: true })).toHaveAttribute( | |
| + 'data-running', | |
| + '1' | |
| + ); | |
| expect(await tocPanel.screenshot()).toMatchSnapshot( | |
| 'toc-running-indicator-top-level.png' | |
| ); | |
| diff --git a/galata/test/jupyterlab/toc-scrolling.test.ts b/galata/test/jupyterlab/toc-scrolling.test.ts | |
| index d9849e3887..0708151e06 100644 | |
| --- a/galata/test/jupyterlab/toc-scrolling.test.ts | |
| +++ b/galata/test/jupyterlab/toc-scrolling.test.ts | |
| @@ -44,10 +44,7 @@ test.describe('Table of Contents scrolling to heading', () => { | |
| ); | |
| await contentPanel.waitFor(); | |
| - await page | |
| - .locator('.jp-TableOfContents-tree') | |
| - .getByText('the last one') | |
| - .click(); | |
| + await page.locator('.jp-TableOfContents-tree').getByText('the last one').click(); | |
| await page.waitForTimeout(100); | |
| // Should switch to command mode | |
| @@ -60,17 +57,11 @@ test.describe('Table of Contents scrolling to heading', () => { | |
| // Scroll up | |
| const bbox = await nbPanel!.boundingBox(); | |
| - await page.mouse.move( | |
| - bbox!.x + 0.5 * bbox!.width, | |
| - bbox!.y + 0.5 * bbox!.height | |
| - ); | |
| + await page.mouse.move(bbox!.x + 0.5 * bbox!.width, bbox!.y + 0.5 * bbox!.height); | |
| await page.mouse.wheel(0, -1200); | |
| await page.waitForTimeout(100); | |
| - await page | |
| - .locator('.jp-TableOfContents-tree') | |
| - .getByText('the last one') | |
| - .click(); | |
| + await page.locator('.jp-TableOfContents-tree').getByText('the last one').click(); | |
| await page.waitForTimeout(100); | |
| expect(await nbPanel!.screenshot()).toMatchSnapshot( | |
| diff --git a/galata/test/jupyterlab/toc.test.ts b/galata/test/jupyterlab/toc.test.ts | |
| index 0f982633ee..eda2755df7 100644 | |
| --- a/galata/test/jupyterlab/toc.test.ts | |
| +++ b/galata/test/jupyterlab/toc.test.ts | |
| @@ -23,9 +23,7 @@ test.describe('Table of Contents', () => { | |
| await page.sidebar.openTab('table-of-contents'); | |
| - await page | |
| - .getByRole('button', { name: 'Show heading number in the' }) | |
| - .click(); | |
| + await page.getByRole('button', { name: 'Show heading number in the' }).click(); | |
| }); | |
| test.afterEach(async ({ page }) => { | |
| @@ -54,9 +52,7 @@ test.describe('Table of Contents', () => { | |
| ); | |
| const imageName = 'toggle-numbered-list.png'; | |
| - await page | |
| - .getByRole('button', { name: 'Show heading number in the' }) | |
| - .click(); | |
| + await page.getByRole('button', { name: 'Show heading number in the' }).click(); | |
| expect(await tocPanel.screenshot()).toMatchSnapshot(imageName); | |
| }); | |
| @@ -74,14 +70,10 @@ test.describe('Table of Contents', () => { | |
| const menu = await page.menu.getOpenMenuLocator(); | |
| - await menu | |
| - ?.getByRole('menuitem', { name: 'Select and Run Cell(s) for' }) | |
| - .click(); | |
| + await menu?.getByRole('menuitem', { name: 'Select and Run Cell(s) for' }).click(); | |
| await page.getByRole('treeitem', { name: 'HTML title' }).waitFor(); | |
| - expect(await tocPanel.screenshot()).toMatchSnapshot( | |
| - 'notebook-output-headings.png' | |
| - ); | |
| + expect(await tocPanel.screenshot()).toMatchSnapshot('notebook-output-headings.png'); | |
| }); | |
| }); | |
| diff --git a/galata/test/jupyterlab/toolbars.test.ts b/galata/test/jupyterlab/toolbars.test.ts | |
| index 6e29b621e2..10d36b4d43 100644 | |
| --- a/galata/test/jupyterlab/toolbars.test.ts | |
| +++ b/galata/test/jupyterlab/toolbars.test.ts | |
| @@ -49,21 +49,14 @@ test.describe('Toolbar Button', () => { | |
| await page.notebook.createNew(); | |
| }); | |
| - test('Render Switch Kernel ToolbarButton in default theme', async ({ | |
| - page | |
| - }) => { | |
| + test('Render Switch Kernel ToolbarButton in default theme', async ({ page }) => { | |
| const label = await page.$( | |
| 'jp-button.jp-Toolbar-kernelName .jp-ToolbarButtonComponent-label' | |
| ); | |
| - const labelColor = await page.evaluate( | |
| - el => getComputedStyle(el).color, | |
| - label | |
| - ); | |
| + const labelColor = await page.evaluate(el => getComputedStyle(el).color, label); | |
| const color = await page.evaluate(() => | |
| - getComputedStyle(document.body) | |
| - .getPropertyValue('--jp-ui-font-color1') | |
| - .trim() | |
| + getComputedStyle(document.body).getPropertyValue('--jp-ui-font-color1').trim() | |
| ); | |
| expect(normalizeColor(labelColor)).toEqual(normalizeColor(color)); | |
| @@ -74,15 +67,10 @@ test.describe('Toolbar Button', () => { | |
| const label = await page.$( | |
| 'jp-button.jp-Toolbar-kernelName .jp-ToolbarButtonComponent-label' | |
| ); | |
| - const labelColor = await page.evaluate( | |
| - el => getComputedStyle(el).color, | |
| - label | |
| - ); | |
| + const labelColor = await page.evaluate(el => getComputedStyle(el).color, label); | |
| const color = await page.evaluate(() => | |
| - getComputedStyle(document.body) | |
| - .getPropertyValue('--jp-ui-font-color1') | |
| - .trim() | |
| + getComputedStyle(document.body).getPropertyValue('--jp-ui-font-color1').trim() | |
| ); | |
| expect(normalizeColor(labelColor)).toEqual(normalizeColor(color)); | |
| diff --git a/galata/test/jupyterlab/utils.ts b/galata/test/jupyterlab/utils.ts | |
| index 6aa8bd859c..70dd263873 100644 | |
| --- a/galata/test/jupyterlab/utils.ts | |
| +++ b/galata/test/jupyterlab/utils.ts | |
| @@ -20,8 +20,7 @@ export async function notebookViewportRatio( | |
| const cellTop = c.y; | |
| const notebookBottom = n.y + n.height; | |
| const notebookTop = n.y; | |
| - const visibleBottom = | |
| - notebookBottom > cellBottom ? cellBottom - notebookTop : 0; | |
| + const visibleBottom = notebookBottom > cellBottom ? cellBottom - notebookTop : 0; | |
| const visibleTop = cellTop > notebookTop ? notebookBottom - cellTop : 0; | |
| const intersection = | |
| notebookBottom > cellBottom && cellTop > notebookTop | |
| @@ -99,13 +98,9 @@ export function isBlank(value: string): boolean { | |
| export async function getFileListFontSize( | |
| page: IJupyterLabPageFixture | |
| ): Promise<number> { | |
| - const itemElement = page.locator( | |
| - '.jp-DirListing-content .jp-DirListing-itemText' | |
| - ); | |
| + const itemElement = page.locator('.jp-DirListing-content .jp-DirListing-itemText'); | |
| await itemElement.waitFor(); | |
| - const fontSize = await itemElement.evaluate( | |
| - el => getComputedStyle(el).fontSize | |
| - ); | |
| + const fontSize = await itemElement.evaluate(el => getComputedStyle(el).fontSize); | |
| return parseInt(fontSize); | |
| } | |
| diff --git a/galata/test/jupyterlab/windowed-notebook.test.ts b/galata/test/jupyterlab/windowed-notebook.test.ts | |
| index 9a68aeac72..10f24477b3 100644 | |
| --- a/galata/test/jupyterlab/windowed-notebook.test.ts | |
| +++ b/galata/test/jupyterlab/windowed-notebook.test.ts | |
| @@ -112,10 +112,7 @@ test('should hide first inactive code cell when scrolling down', async ({ | |
| const bbox = await h!.boundingBox(); | |
| await page.mouse.move(bbox!.x, bbox!.y); | |
| - await Promise.all([ | |
| - firstCell.waitFor({ state: 'hidden' }), | |
| - page.mouse.wheel(0, 600) | |
| - ]); | |
| + await Promise.all([firstCell.waitFor({ state: 'hidden' }), page.mouse.wheel(0, 600)]); | |
| // Check the content contains only the output | |
| expect(await firstCell.textContent()).toEqual('[16]:local link\n'); | |
| @@ -248,10 +245,7 @@ const scrollOnKeyPressCases: { | |
| } | |
| ]; | |
| test.describe('Scrolling on keyboard interaction when active editor is above the viewport', () => { | |
| - test.skip( | |
| - ({ browserName }) => browserName === 'firefox', | |
| - 'Needs fixing on Firefox' | |
| - ); | |
| + test.skip(({ browserName }) => browserName === 'firefox', 'Needs fixing on Firefox'); | |
| for (const testCase of scrollOnKeyPressCases) { | |
| test(`Show ${testCase.showCell} cell on pressing ${testCase.key} ${testCase.times} times`, async ({ | |
| @@ -321,10 +315,7 @@ test('should detach a markdown code cell when scrolling out of the viewport', as | |
| const bbox = await h!.boundingBox(); | |
| await page.mouse.move(bbox!.x, bbox!.y); | |
| - await Promise.all([ | |
| - mdCell.waitFor({ state: 'hidden' }), | |
| - page.mouse.wheel(0, 1200) | |
| - ]); | |
| + await Promise.all([mdCell.waitFor({ state: 'hidden' }), page.mouse.wheel(0, 1200)]); | |
| let found = true; | |
| try { | |
| @@ -384,9 +375,7 @@ test('should remove all cells including hidden outputs artifacts', async ({ | |
| await page.keyboard.press('d'); | |
| // Check that the notebook only contains one cell | |
| - expect(await h!.locator('.jp-WindowedPanel-inner')!.textContent()).toEqual( | |
| - '[ ]:' | |
| - ); | |
| + expect(await h!.locator('.jp-WindowedPanel-inner')!.textContent()).toEqual('[ ]:'); | |
| // Check there are no hidden cells | |
| let found = true; | |
| @@ -421,19 +410,13 @@ test('should display cells below on scrolling after inserting a cell on top', as | |
| await page.mouse.wheel(0, 3000); | |
| // Scroll down to reveal last cell to ensure these all items have been measured... | |
| - await Promise.all([ | |
| - firstCell.waitFor({ state: 'hidden' }), | |
| - lastCell.waitFor() | |
| - ]); | |
| + await Promise.all([firstCell.waitFor({ state: 'hidden' }), lastCell.waitFor()]); | |
| await page.mouse.wheel(0, -3000); | |
| await page.mouse.wheel(0, -3000); | |
| // ...then scroll back up and select first cell. | |
| - await Promise.all([ | |
| - lastCell.waitFor({ state: 'hidden' }), | |
| - firstCell.waitFor() | |
| - ]); | |
| + await Promise.all([lastCell.waitFor({ state: 'hidden' }), firstCell.waitFor()]); | |
| await page.notebook.selectCells(0); | |
| // Insert cell below. | |
| @@ -442,10 +425,7 @@ test('should display cells below on scrolling after inserting a cell on top', as | |
| await page.mouse.wheel(0, 3000); | |
| // Scroll down again. | |
| - await Promise.all([ | |
| - firstCell.waitFor({ state: 'hidden' }), | |
| - lastCell.waitFor() | |
| - ]); | |
| + await Promise.all([firstCell.waitFor({ state: 'hidden' }), lastCell.waitFor()]); | |
| await expect(lastCell).toBeVisible(); | |
| }); | |
| @@ -460,9 +440,7 @@ test('should center on next cell after rendering markdown cell and advancing', a | |
| const thirdCell = page.locator('.jp-CodeCell[data-windowed-list-index="3"]'); | |
| const fourthCell = page.locator('.jp-RawCell[data-windowed-list-index="4"]'); | |
| - await page | |
| - .locator('.jp-Notebook-ExecutionIndicator[data-status="idle"]') | |
| - .waitFor(); | |
| + await page.locator('.jp-Notebook-ExecutionIndicator[data-status="idle"]').waitFor(); | |
| // Un-render markdown cell | |
| await page.notebook.enterCellEditingMode(2); | |
| @@ -501,8 +479,7 @@ test('should rendered injected styles of out-of-viewport cells', async ({ | |
| const cell = document.querySelector('.jp-Notebook-cell'); | |
| if (cell) { | |
| return ( | |
| - window.getComputedStyle(cell, '::after').content == | |
| - '"CSS ::after element"' | |
| + window.getComputedStyle(cell, '::after').content == '"CSS ::after element"' | |
| ); | |
| } else { | |
| return false; | |
| @@ -513,8 +490,7 @@ test('should rendered injected styles of out-of-viewport cells', async ({ | |
| let count = 0; | |
| for (const cell of document.querySelectorAll('.jp-Notebook-cell')) { | |
| count += | |
| - window.getComputedStyle(cell, '::after').content == | |
| - '"CSS ::after element"' | |
| + window.getComputedStyle(cell, '::after').content == '"CSS ::after element"' | |
| ? 1 | |
| : 0; | |
| } | |
| @@ -537,9 +513,9 @@ test('should rendered injected HTML scripts of out-of-viewport cells', async ({ | |
| .not.toBeVisible(); | |
| await page.getByText('JavaScript injected from HTML').first().waitFor(); | |
| - expect( | |
| - await page.getByText('JavaScript injected from HTML').count() | |
| - ).toBeGreaterThan(1); | |
| + expect(await page.getByText('JavaScript injected from HTML').count()).toBeGreaterThan( | |
| + 1 | |
| + ); | |
| }); | |
| test('should rendered injected JavaScript snippets of out-of-viewport cells', async ({ | |
| @@ -555,9 +531,7 @@ test('should rendered injected JavaScript snippets of out-of-viewport cells', as | |
| .not.toBeVisible(); | |
| await page.getByText('JavaScript injected header').first().waitFor(); | |
| - expect( | |
| - await page.getByText('JavaScript injected header').count() | |
| - ).toBeGreaterThan(1); | |
| + expect(await page.getByText('JavaScript injected header').count()).toBeGreaterThan(1); | |
| }); | |
| test('should navigate to a search hit in a out-of-viewport cell', async ({ | |
| @@ -588,12 +562,10 @@ test('should navigate to a search hit in a out-of-viewport cell', async ({ | |
| .soft(page.locator('.jp-Cell[data-windowed-list-index="18"]')) | |
| .not.toBeVisible(); | |
| - await page | |
| - .getByRole('button', { name: 'Previous Match (Ctrl+Shift+G)' }) | |
| - .click(); | |
| + await page.getByRole('button', { name: 'Previous Match (Ctrl+Shift+G)' }).click(); | |
| await page.locator('.jp-Cell[data-windowed-list-index="18"]').waitFor(); | |
| - await expect( | |
| - page.locator('.jp-Cell[data-windowed-list-index="18"]') | |
| - ).toContainText('Final'); | |
| + await expect(page.locator('.jp-Cell[data-windowed-list-index="18"]')).toContainText( | |
| + 'Final' | |
| + ); | |
| }); | |
| diff --git a/galata/test/jupyterlab/workspace.test.ts b/galata/test/jupyterlab/workspace.test.ts | |
| index 9d11048f61..28191909ab 100644 | |
| --- a/galata/test/jupyterlab/workspace.test.ts | |
| +++ b/galata/test/jupyterlab/workspace.test.ts | |
| @@ -46,17 +46,13 @@ test.describe('Workspace', () => { | |
| const launcher = page.locator('div.jp-Launcher-sectionHeader'); | |
| - expect(await launcher.first().screenshot()).toMatchSnapshot( | |
| - 'workspace-reset.png' | |
| - ); | |
| + expect(await launcher.first().screenshot()).toMatchSnapshot('workspace-reset.png'); | |
| }); | |
| test('should open a file from `tree` url', async ({ page, tmpPath }) => { | |
| await page.goto(`tree/${tmpPath}/${mdFile}`); | |
| - await expect( | |
| - page.locator('[role="main"] >> text=Title').first() | |
| - ).toBeVisible(); | |
| + await expect(page.locator('[role="main"] >> text=Title').first()).toBeVisible(); | |
| }); | |
| test('should open a file from `tree` url if workspace is not empty', async ({ | |
| @@ -74,15 +70,11 @@ test.describe('Workspace', () => { | |
| page.goto(`tree/${tmpPath}/${mdFile}`) | |
| ]); | |
| - await expect( | |
| - page.locator('[role="main"] >> text=Title').first() | |
| - ).toBeVisible(); | |
| + await expect(page.locator('[role="main"] >> text=Title').first()).toBeVisible(); | |
| await page.goto(`tree/${tmpPath}/${nbFile}`); | |
| - await expect( | |
| - page.locator(`[role="main"] >> text=${mdFile}`).first() | |
| - ).toBeVisible(); | |
| + await expect(page.locator(`[role="main"] >> text=${mdFile}`).first()).toBeVisible(); | |
| await expect( | |
| page.locator('[role="main"] >> text=Test Notebook¶').first() | |
| ).toBeVisible(); | |
| @@ -113,9 +105,7 @@ test.describe('Workspace', () => { | |
| }) => { | |
| await page.goto(`${baseURL}/doc/tree/${tmpPath}/${mdFile}`); | |
| - await expect( | |
| - page.locator('[role="main"] >> text=Title').first() | |
| - ).toBeVisible(); | |
| + await expect(page.locator('[role="main"] >> text=Title').first()).toBeVisible(); | |
| }); | |
| test('should open a new file in simple mode from `tree` url', async ({ | |
| @@ -131,16 +121,13 @@ test.describe('Workspace', () => { | |
| response => | |
| response.request().method() === 'PUT' && | |
| /api\/workspaces/.test(response.request().url()) && | |
| - response.request().postDataJSON().data['layout-restorer:data'][ | |
| - 'main' | |
| - ] === null | |
| + response.request().postDataJSON().data['layout-restorer:data']['main'] === | |
| + null | |
| ), | |
| page.goto(`${baseURL}/doc/tree/${tmpPath}/${mdFile}`) | |
| ]); | |
| - await expect( | |
| - page.locator('[role="main"] >> text=Title').first() | |
| - ).toBeVisible(); | |
| + await expect(page.locator('[role="main"] >> text=Title').first()).toBeVisible(); | |
| await page.goto(`${baseURL}/doc/tree/${tmpPath}/${nbFile}`); | |
| @@ -185,9 +172,7 @@ test.describe('Workspace', () => { | |
| page.goto('workspaces/foo?clone') | |
| ]); | |
| - await expect(page.locator('[role="main"] >> .lm-TabBar-tab')).toHaveCount( | |
| - 3 | |
| - ); | |
| + await expect(page.locator('[role="main"] >> .lm-TabBar-tab')).toHaveCount(3); | |
| await expect(page.locator(`[role="main"] >> text=${mdFile}`)).toBeVisible(); | |
| await expect(page.locator(`[role="main"] >> text=${nbFile}`)).toBeVisible(); | |
| }); | |
| @@ -222,16 +207,12 @@ test.describe('Workspace', () => { | |
| ]); | |
| // Then | |
| - await expect(page.locator('[role="main"] >> .lm-TabBar-tab')).toHaveCount( | |
| - 3 | |
| - ); | |
| + await expect(page.locator('[role="main"] >> .lm-TabBar-tab')).toHaveCount(3); | |
| await expect(page.locator(`[role="main"] >> text=${mdFile}`)).toBeVisible(); | |
| await expect(page.locator(`[role="main"] >> text=${nbFile}`)).toBeVisible(); | |
| }); | |
| - test('should display workspace indicator and switch workspaces', async ({ | |
| - page | |
| - }) => { | |
| + test('should display workspace indicator and switch workspaces', async ({ page }) => { | |
| await page.goto(); | |
| const workspaceSelector = page.locator('.jp-WorkspaceSelector-header'); | |
| // Not visible by default | |
| @@ -242,9 +223,7 @@ test.describe('Workspace', () => { | |
| await page.menu.clickMenuItem('View>Appearance>Show Workspace Indicator'); | |
| await expect(workspaceSelector).toBeVisible(); | |
| await workspaceSelector.click(); | |
| - await page | |
| - .locator('.jp-WorkspaceSelector-item:has-text("default")') | |
| - .click(); | |
| + await page.locator('.jp-WorkspaceSelector-item:has-text("default")').click(); | |
| const url = page.url(); | |
| expect(url).toContain('/workspaces/default'); | |
| @@ -300,9 +279,7 @@ test.describe('Workspace in doc mode', () => { | |
| expansionStates: [false, false, false, false] | |
| }, | |
| ['extensionmanager.main-view']: { | |
| - sizes: [ | |
| - 0.3333333333333333, 0.3333333333333333, 0.3333333333333333 | |
| - ], | |
| + sizes: [0.3333333333333333, 0.3333333333333333, 0.3333333333333333], | |
| expansionStates: [false, false, false] | |
| } | |
| } | |
| @@ -349,23 +326,18 @@ test.describe('Workspace in doc mode', () => { | |
| await Promise.all([ | |
| // Wait for the workspace to be saved. | |
| page.waitForRequest(request => { | |
| - if ( | |
| - request.method() !== 'PUT' || | |
| - !/api\/workspaces/.test(request.url()) | |
| - ) { | |
| + if (request.method() !== 'PUT' || !/api\/workspaces/.test(request.url())) { | |
| return false; | |
| } | |
| let restorerData: any = {}; | |
| let mainRestorerWidgets = []; | |
| if (request.postDataJSON() && request.postDataJSON().data) { | |
| - restorerData = | |
| - request.postDataJSON().data['layout-restorer:data'] ?? {}; | |
| + restorerData = request.postDataJSON().data['layout-restorer:data'] ?? {}; | |
| mainRestorerWidgets = restorerData.main?.dock?.widgets; | |
| } | |
| return ( | |
| mainRestorerWidgets.length === 1 && | |
| - mainRestorerWidgets[0] === | |
| - 'notebook:workspace-test/simple_notebook.ipynb' | |
| + mainRestorerWidgets[0] === 'notebook:workspace-test/simple_notebook.ipynb' | |
| ); | |
| }), | |
| page.goto(`${baseURL}/doc/tree/${tmpPath}/${mdFile}`) | |
| @@ -376,9 +348,7 @@ test.describe('Workspace in doc mode', () => { | |
| page.locator('#jp-main-dock-panel .jp-MainAreaWidget .jp-FileEditor') | |
| ).toHaveCount(1); | |
| - await expect( | |
| - page.locator('#jp-main-dock-panel .jp-MainAreaWidget') | |
| - ).toHaveCount(1); | |
| + await expect(page.locator('#jp-main-dock-panel .jp-MainAreaWidget')).toHaveCount(1); | |
| // Switch to lab mode, which should restore the loaded workspace. | |
| await Promise.all([ | |
| @@ -395,8 +365,7 @@ test.describe('Workspace in doc mode', () => { | |
| request.method() === 'PUT' && | |
| /api\/workspaces/.test(request.url()) && | |
| mainRestorerWidgets.length === 1 && | |
| - mainRestorerWidgets[0] === | |
| - 'notebook:workspace-test/simple_notebook.ipynb' | |
| + mainRestorerWidgets[0] === 'notebook:workspace-test/simple_notebook.ipynb' | |
| ); | |
| }), | |
| page.url() === `${baseURL}/lab`, | |
| @@ -408,9 +377,7 @@ test.describe('Workspace in doc mode', () => { | |
| page.locator('#jp-main-dock-panel .jp-MainAreaWidget .jp-Notebook') | |
| ).toHaveCount(1); | |
| - await expect( | |
| - page.locator('#jp-main-dock-panel .jp-MainAreaWidget') | |
| - ).toHaveCount(1); | |
| + await expect(page.locator('#jp-main-dock-panel .jp-MainAreaWidget')).toHaveCount(1); | |
| }); | |
| }); | |
| @@ -460,9 +427,7 @@ test.describe('Restore non-default-type editor', () => { | |
| expansionStates: [false, false, false, false] | |
| }, | |
| ['extensionmanager.main-view']: { | |
| - sizes: [ | |
| - 0.3333333333333333, 0.3333333333333333, 0.3333333333333333 | |
| - ], | |
| + sizes: [0.3333333333333333, 0.3333333333333333, 0.3333333333333333], | |
| expansionStates: [false, false, false] | |
| } | |
| } | |
| @@ -523,9 +488,7 @@ test.describe('Restore non-default-type editor', () => { | |
| page.locator('#jp-main-dock-panel .jp-MainAreaWidget .jp-Notebook') | |
| ).toHaveCount(0); // opened as a File, not a Notebook | |
| - await expect( | |
| - page.locator('#jp-main-dock-panel .jp-MainAreaWidget') | |
| - ).toHaveCount(1); | |
| + await expect(page.locator('#jp-main-dock-panel .jp-MainAreaWidget')).toHaveCount(1); | |
| // Reload, which should restore the loaded workspace, which means a file editor and not opening a new Notebook. | |
| await Promise.all([page.reload()]); | |
| @@ -544,9 +507,7 @@ test.describe('Restore non-default-type editor', () => { | |
| page.locator('#jp-main-dock-panel .jp-MainAreaWidget .jp-Notebook') | |
| ).toHaveCount(0); // opened as a File, not a Notebook | |
| - await expect( | |
| - page.locator('#jp-main-dock-panel .jp-MainAreaWidget') | |
| - ).toHaveCount(1); | |
| + await expect(page.locator('#jp-main-dock-panel .jp-MainAreaWidget')).toHaveCount(1); | |
| // try to open the already open file from the filebrowser, and confirm it doesn't open a new Notebook editor. | |
| await Promise.all([page.filebrowser.open('simple_notebook.ipynb')]); | |
| @@ -560,8 +521,6 @@ test.describe('Restore non-default-type editor', () => { | |
| page.locator('#jp-main-dock-panel .jp-MainAreaWidget .jp-Notebook') | |
| ).toHaveCount(0); // opened as a File, not a Notebook | |
| - await expect( | |
| - page.locator('#jp-main-dock-panel .jp-MainAreaWidget') | |
| - ).toHaveCount(1); | |
| + await expect(page.locator('#jp-main-dock-panel .jp-MainAreaWidget')).toHaveCount(1); | |
| }); | |
| }); | |
| diff --git a/jupyterlab/staging/bootstrap.js b/jupyterlab/staging/bootstrap.js | |
| index 9a5ae3eb31..c54d3b780d 100644 | |
| --- a/jupyterlab/staging/bootstrap.js | |
| +++ b/jupyterlab/staging/bootstrap.js | |
| @@ -77,10 +77,7 @@ void (async function bootstrap() { | |
| let labExtensionUrl = getOption('fullLabextensionsUrl'); | |
| const extensions = await Promise.allSettled( | |
| extension_data.map(async data => { | |
| - await loadComponent( | |
| - `${labExtensionUrl}/${data.name}/${data.load}`, | |
| - data.name | |
| - ); | |
| + await loadComponent(`${labExtensionUrl}/${data.name}/${data.load}`, data.name); | |
| }) | |
| ); | |
| diff --git a/jupyterlab/staging/webpack.prod.config.js b/jupyterlab/staging/webpack.prod.config.js | |
| index bb8c9b33cf..224aab0fc6 100644 | |
| --- a/jupyterlab/staging/webpack.prod.config.js | |
| +++ b/jupyterlab/staging/webpack.prod.config.js | |
| @@ -21,8 +21,7 @@ config[0] = merge(config[0], { | |
| }, | |
| plugins: [ | |
| new WPPlugin.JSONLicenseWebpackPlugin({ | |
| - excludedPackageTest: packageName => | |
| - packageName === '@jupyterlab/application-top' | |
| + excludedPackageTest: packageName => packageName === '@jupyterlab/application-top' | |
| }) | |
| ] | |
| }); | |
| diff --git a/jupyterlab/staging/webpack.prod.minimize.config.js b/jupyterlab/staging/webpack.prod.minimize.config.js | |
| index 4078546f70..e8e99715d0 100644 | |
| --- a/jupyterlab/staging/webpack.prod.minimize.config.js | |
| +++ b/jupyterlab/staging/webpack.prod.minimize.config.js | |
| @@ -21,8 +21,7 @@ config[0] = merge(config[0], { | |
| }, | |
| plugins: [ | |
| new WPPlugin.JSONLicenseWebpackPlugin({ | |
| - excludedPackageTest: packageName => | |
| - packageName === '@jupyterlab/application-top' | |
| + excludedPackageTest: packageName => packageName === '@jupyterlab/application-top' | |
| }) | |
| ] | |
| }); | |
| diff --git a/packages/application-extension/src/index.tsx b/packages/application-extension/src/index.tsx | |
| index 1076c742e3..de1bcca43f 100644 | |
| --- a/packages/application-extension/src/index.tsx | |
| +++ b/packages/application-extension/src/index.tsx | |
| @@ -40,12 +40,7 @@ import { IStatusBar } from '@jupyterlab/statusbar'; | |
| import type { TranslationBundle } from '@jupyterlab/translation'; | |
| import { ITranslator, nullTranslator } from '@jupyterlab/translation'; | |
| import type { ContextMenuSvg } from '@jupyterlab/ui-components'; | |
| -import { | |
| - buildIcon, | |
| - jupyterIcon, | |
| - RankedMenu, | |
| - Switch | |
| -} from '@jupyterlab/ui-components'; | |
| +import { buildIcon, jupyterIcon, RankedMenu, Switch } from '@jupyterlab/ui-components'; | |
| import { find, some } from '@lumino/algorithm'; | |
| import type { ReadonlyPartialJSONValue } from '@lumino/coreutils'; | |
| import { JSONExt, PromiseDelegate } from '@lumino/coreutils'; | |
| @@ -67,13 +62,11 @@ export const DEFAULT_CONTEXT_ITEM_RANK = 100; | |
| namespace CommandIDs { | |
| export const activateNextTab: string = 'application:activate-next-tab'; | |
| - export const activatePreviousTab: string = | |
| - 'application:activate-previous-tab'; | |
| + export const activatePreviousTab: string = 'application:activate-previous-tab'; | |
| export const activateNextTabBar: string = 'application:activate-next-tab-bar'; | |
| - export const activatePreviousTabBar: string = | |
| - 'application:activate-previous-tab-bar'; | |
| + export const activatePreviousTabBar: string = 'application:activate-previous-tab-bar'; | |
| export const close = 'application:close'; | |
| @@ -101,14 +94,11 @@ namespace CommandIDs { | |
| export const toggleSideTabBar: string = 'application:toggle-side-tabbar'; | |
| - export const toggleSidebarWidget: string = | |
| - 'application:toggle-sidebar-widget'; | |
| + export const toggleSidebarWidget: string = 'application:toggle-sidebar-widget'; | |
| - export const togglePresentationMode: string = | |
| - 'application:toggle-presentation-mode'; | |
| + export const togglePresentationMode: string = 'application:toggle-presentation-mode'; | |
| - export const toggleFullscreenMode: string = | |
| - 'application:toggle-fullscreen-mode'; | |
| + export const toggleFullscreenMode: string = 'application:toggle-fullscreen-mode'; | |
| export const tree: string = 'router:tree'; | |
| @@ -223,9 +213,7 @@ const mainCommands: JupyterFrontEndPlugin<void> = { | |
| if (side === 'left') { | |
| activeTab = document.querySelector('.lm-TabBar-tab.lm-mod-current'); | |
| } else { | |
| - const query = document.querySelectorAll( | |
| - '.lm-TabBar-tab.lm-mod-current' | |
| - ); | |
| + const query = document.querySelectorAll('.lm-TabBar-tab.lm-mod-current'); | |
| activeTab = query[query.length - 1]; | |
| } | |
| const activeTabDataId = activeTab?.getAttribute('data-id'); | |
| @@ -298,8 +286,7 @@ const mainCommands: JupyterFrontEndPlugin<void> = { | |
| } | |
| }, | |
| isEnabled: () => | |
| - !!contextMenuWidget() && | |
| - widgetsRightOf(contextMenuWidget()!).length > 0, | |
| + !!contextMenuWidget() && widgetsRightOf(contextMenuWidget()!).length > 0, | |
| execute: () => { | |
| const widget = contextMenuWidget(); | |
| if (!widget) { | |
| @@ -310,11 +297,9 @@ const mainCommands: JupyterFrontEndPlugin<void> = { | |
| }); | |
| shell.currentChanged?.connect(() => { | |
| - [ | |
| - CommandIDs.close, | |
| - CommandIDs.closeOtherTabs, | |
| - CommandIDs.closeRightTabs | |
| - ].forEach(cmd => commands.notifyCommandChanged(cmd)); | |
| + [CommandIDs.close, CommandIDs.closeOtherTabs, CommandIDs.closeRightTabs].forEach( | |
| + cmd => commands.notifyCommandChanged(cmd) | |
| + ); | |
| }); | |
| if (labShell) { | |
| @@ -446,9 +431,7 @@ const mainCommands: JupyterFrontEndPlugin<void> = { | |
| commands.addCommand(CommandIDs.toggleSidebarWidget, { | |
| label: args => | |
| - args === undefined || | |
| - args.side === undefined || | |
| - args.index === undefined | |
| + args === undefined || args.side === undefined || args.index === undefined | |
| ? trans.__('Toggle Sidebar Element') | |
| : args.side === 'right' | |
| ? trans.__( | |
| @@ -535,9 +518,7 @@ const mainCommands: JupyterFrontEndPlugin<void> = { | |
| ? labShell.isSideTabBarVisible('right') | |
| : labShell.isSideTabBarVisible('left'), | |
| isEnabled: args => | |
| - args.side === 'right' | |
| - ? !labShell.isEmpty('right') | |
| - : !labShell.isEmpty('left') | |
| + args.side === 'right' ? !labShell.isEmpty('right') : !labShell.isEmpty('left') | |
| }); | |
| commands.addCommand(CommandIDs.togglePresentationMode, { | |
| @@ -644,11 +625,9 @@ const mainCommands: JupyterFrontEndPlugin<void> = { | |
| execute: () => { | |
| // Turn off presentation mode | |
| if (labShell.presentationMode) { | |
| - commands | |
| - .execute(CommandIDs.togglePresentationMode) | |
| - .catch(reason => { | |
| - console.error('Failed to undo presentation mode.', reason); | |
| - }); | |
| + commands.execute(CommandIDs.togglePresentationMode).catch(reason => { | |
| + console.error('Failed to undo presentation mode.', reason); | |
| + }); | |
| } | |
| // Turn off fullscreen mode | |
| if ( | |
| @@ -670,15 +649,10 @@ const mainCommands: JupyterFrontEndPlugin<void> = { | |
| } | |
| // Display side tabbar | |
| (['left', 'right'] as ('left' | 'right')[]).forEach(side => { | |
| - if ( | |
| - !labShell.isSideTabBarVisible(side) && | |
| - !labShell.isEmpty(side) | |
| - ) { | |
| - commands | |
| - .execute(CommandIDs.toggleSideTabBar, { side }) | |
| - .catch(reason => { | |
| - console.error(`Failed to show ${side} activity bar.`, reason); | |
| - }); | |
| + if (!labShell.isSideTabBarVisible(side) && !labShell.isEmpty(side)) { | |
| + commands.execute(CommandIDs.toggleSideTabBar, { side }).catch(reason => { | |
| + console.error(`Failed to show ${side} activity bar.`, reason); | |
| + }); | |
| } | |
| }); | |
| @@ -760,11 +734,7 @@ const mainCommands: JupyterFrontEndPlugin<void> = { | |
| return tabBar.titles.length > 1; | |
| }, | |
| execute: args => { | |
| - const direction = args?.['direction'] as | |
| - | 'left' | |
| - | 'right' | |
| - | 'top' | |
| - | 'bottom'; | |
| + const direction = args?.['direction'] as 'left' | 'right' | 'top' | 'bottom'; | |
| const widget = contextMenuTabWidget(); | |
| if (widget && direction) { | |
| @@ -809,14 +779,8 @@ const mainCommands: JupyterFrontEndPlugin<void> = { | |
| */ | |
| const main: JupyterFrontEndPlugin<ITreePathUpdater> = { | |
| id: '@jupyterlab/application-extension:main', | |
| - description: | |
| - 'Initializes the application and provides the URL tree path handler.', | |
| - requires: [ | |
| - IRouter, | |
| - IWindowResolver, | |
| - ITranslator, | |
| - JupyterFrontEnd.ITreeResolver | |
| - ], | |
| + description: 'Initializes the application and provides the URL tree path handler.', | |
| + requires: [IRouter, IWindowResolver, ITranslator, JupyterFrontEnd.ITreeResolver], | |
| optional: [IConnectionLost], | |
| provides: ITreePathUpdater, | |
| activate: ( | |
| @@ -862,9 +826,7 @@ const main: JupyterFrontEndPlugin<ITreePathUpdater> = { | |
| // If there were errors registering plugins, tell the user. | |
| if (app.registerPluginErrors.length !== 0) { | |
| - const body = ( | |
| - <pre>{app.registerPluginErrors.map(e => e.message).join('\n')}</pre> | |
| - ); | |
| + const body = <pre>{app.registerPluginErrors.map(e => e.message).join('\n')}</pre>; | |
| void showErrorMessage(trans.__('Error Registering Plugins'), { | |
| message: body | |
| @@ -1240,9 +1202,7 @@ const tree: JupyterFrontEndPlugin<JupyterFrontEnd.ITreeResolver> = { | |
| } | |
| }) | |
| ); | |
| - set.add( | |
| - router.register({ command: CommandIDs.tree, pattern: treePattern }) | |
| - ); | |
| + set.add(router.register({ command: CommandIDs.tree, pattern: treePattern })); | |
| // If a route is handled by the router without the tree command being | |
| // invoked, resolve to `null` and clean up artifacts. | |
| @@ -1342,10 +1302,7 @@ const shell: JupyterFrontEndPlugin<ILabShell> = { | |
| description: | |
| 'Provides the JupyterLab shell. It has an extended API compared to `app.shell`.', | |
| optional: [ISettingRegistry], | |
| - activate: ( | |
| - app: JupyterFrontEnd, | |
| - settingRegistry: ISettingRegistry | null | |
| - ) => { | |
| + activate: (app: JupyterFrontEnd, settingRegistry: ISettingRegistry | null) => { | |
| if (!(app.shell instanceof LabShell)) { | |
| throw new Error(`${shell.id} did not find a LabShell instance.`); | |
| } | |
| @@ -1591,10 +1548,7 @@ namespace Private { | |
| body: trans.__( | |
| 'Context menu customization has changed. You will need to reload JupyterLab to see the changes.' | |
| ), | |
| - buttons: [ | |
| - Dialog.cancelButton(), | |
| - Dialog.okButton({ label: trans.__('Reload') }) | |
| - ] | |
| + buttons: [Dialog.cancelButton(), Dialog.okButton({ label: trans.__('Reload') })] | |
| }); | |
| if (result.button.accept) { | |
| @@ -1624,8 +1578,7 @@ namespace Private { | |
| const pluginDefaults = Object.keys(registry.plugins) | |
| .map(plugin => { | |
| const items = | |
| - registry.plugins[plugin]!.schema['jupyter.lab.menus']?.context ?? | |
| - []; | |
| + registry.plugins[plugin]!.schema['jupyter.lab.menus']?.context ?? []; | |
| loaded[plugin] = items; | |
| return items; | |
| }) | |
| @@ -1751,12 +1704,8 @@ namespace Private { | |
| loaded[plugin] = JSONExt.deepCopy(newItems); | |
| // Merge potential disabled state | |
| const toAdd = | |
| - SettingRegistry.reconcileItems( | |
| - newItems, | |
| - contextItems, | |
| - false, | |
| - false | |
| - ) ?? []; | |
| + SettingRegistry.reconcileItems(newItems, contextItems, false, false) ?? | |
| + []; | |
| SettingRegistry.filterDisabledItems(toAdd).forEach(item => { | |
| MenuFactory.addContextItem( | |
| { | |
| @@ -1785,8 +1734,7 @@ namespace Private { | |
| }, | |
| isToggleable: true, | |
| isToggled: () => !settings.get('disabled').composite, | |
| - execute: () => | |
| - void settings.set('disabled', !settings.get('disabled').composite) | |
| + execute: () => void settings.set('disabled', !settings.get('disabled').composite) | |
| }); | |
| } | |
| @@ -1845,10 +1793,7 @@ namespace Private { | |
| multiple: newLayout['multiple-document'] | |
| } as any) | |
| .catch(reason => { | |
| - console.error( | |
| - 'Failed to save user layout customization.', | |
| - reason | |
| - ); | |
| + console.error('Failed to save user layout customization.', reason); | |
| }); | |
| } | |
| } | |
| diff --git a/packages/application-extension/src/topbar.ts b/packages/application-extension/src/topbar.ts | |
| index 22de0018b0..6f9b837cbe 100644 | |
| --- a/packages/application-extension/src/topbar.ts | |
| +++ b/packages/application-extension/src/topbar.ts | |
| @@ -3,10 +3,7 @@ | |
| * Distributed under the terms of the Modified BSD License. | |
| */ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { | |
| createToolbarFactory, | |
| IToolbarWidgetRegistry, | |
| diff --git a/packages/application/src/connectionlost.ts b/packages/application/src/connectionlost.ts | |
| index c1531fc7d8..20d5e45505 100644 | |
| --- a/packages/application/src/connectionlost.ts | |
| +++ b/packages/application/src/connectionlost.ts | |
| @@ -72,7 +72,5 @@ namespace Private { | |
| /** | |
| * The resulting connection lost dialog promise. | |
| */ | |
| - export let serverConnectionLost: | |
| - | Promise<void | Dialog.IResult<string>> | |
| - | undefined; | |
| + export let serverConnectionLost: Promise<void | Dialog.IResult<string>> | undefined; | |
| } | |
| diff --git a/packages/application/src/frontend.ts b/packages/application/src/frontend.ts | |
| index 0706642268..96bbeaf108 100644 | |
| --- a/packages/application/src/frontend.ts | |
| +++ b/packages/application/src/frontend.ts | |
| @@ -70,8 +70,7 @@ export abstract class JupyterFrontEnd< | |
| options.commandLinker || new CommandLinker({ commands: this.commands }); | |
| this.docRegistry = options.docRegistry || new DocumentRegistry(); | |
| this.restored = | |
| - options.restored || | |
| - this.started.then(() => restored).catch(() => restored); | |
| + options.restored || this.started.then(() => restored).catch(() => restored); | |
| this.serviceManager = options.serviceManager || new ServiceManager(); | |
| } | |
| @@ -146,13 +145,8 @@ export abstract class JupyterFrontEnd< | |
| * | |
| * @returns an HTMLElement or undefined, if none is found. | |
| */ | |
| - contextMenuHitTest( | |
| - fn: (node: HTMLElement) => boolean | |
| - ): HTMLElement | undefined { | |
| - if ( | |
| - !this._contextMenuEvent || | |
| - !(this._contextMenuEvent.target instanceof Node) | |
| - ) { | |
| + contextMenuHitTest(fn: (node: HTMLElement) => boolean): HTMLElement | undefined { | |
| + if (!this._contextMenuEvent || !(this._contextMenuEvent.target instanceof Node)) { | |
| return undefined; | |
| } | |
| let node: Node | null = this._contextMenuEvent.target; | |
| @@ -183,10 +177,7 @@ export abstract class JupyterFrontEnd< | |
| */ | |
| protected evtContextMenu(event: MouseEvent): void { | |
| this._contextMenuEvent = event; | |
| - if ( | |
| - event.shiftKey || | |
| - Private.suppressContextMenu(event.target as HTMLElement) | |
| - ) { | |
| + if (event.shiftKey || Private.suppressContextMenu(event.target as HTMLElement)) { | |
| return; | |
| } | |
| const opened = this.contextMenu.open(event); | |
| @@ -268,11 +259,7 @@ export namespace JupyterFrontEnd { | |
| * @param options - Optional flags the shell might use when opening the | |
| * widget, as defined in the `DocumentRegistry`. | |
| */ | |
| - add( | |
| - widget: Widget, | |
| - area?: string, | |
| - options?: DocumentRegistry.IOpenOptions | |
| - ): void; | |
| + add(widget: Widget, area?: string, options?: DocumentRegistry.IOpenOptions): void; | |
| /** | |
| * The focused widget in the application shell. | |
| @@ -295,10 +282,7 @@ export namespace JupyterFrontEnd { | |
| * current widget may not be the one focused as its definition is an implementation | |
| * detail. | |
| */ | |
| - readonly currentChanged?: ISignal< | |
| - IShell, | |
| - FocusTracker.IChangedArgs<Widget> | |
| - >; | |
| + readonly currentChanged?: ISignal<IShell, FocusTracker.IChangedArgs<Widget>>; | |
| /** | |
| * Returns an iterator for the widgets inside the application shell. | |
| diff --git a/packages/application/src/lab.ts b/packages/application/src/lab.ts | |
| index 428c56cc43..bc5a56c1fa 100644 | |
| --- a/packages/application/src/lab.ts | |
| +++ b/packages/application/src/lab.ts | |
| @@ -46,9 +46,7 @@ export class JupyterLab extends JupyterFrontEnd<ILabShell> { | |
| activated.push(deferred); | |
| if (this._info.deferred) { | |
| const customizedDeferred = Promise.all( | |
| - this._info.deferred.matches.map(pluginID => | |
| - this.activatePlugin(pluginID) | |
| - ) | |
| + this._info.deferred.matches.map(pluginID => this.activatePlugin(pluginID)) | |
| ).catch(error => { | |
| console.error( | |
| 'Error when activating customized list of deferred plugins:\n', | |
| @@ -209,10 +207,7 @@ export class JupyterLab extends JupyterFrontEnd<ILabShell> { | |
| const permissionToExecute = new PromiseDelegate<boolean>(); | |
| // Hold the execution of any keybinding until we know if this event would cause text insertion | |
| - this.commands.holdKeyBindingExecution( | |
| - keyDownEvent, | |
| - permissionToExecute.promise | |
| - ); | |
| + this.commands.holdKeyBindingExecution(keyDownEvent, permissionToExecute.promise); | |
| // Process the key immediately to invoke the prevent default handlers as needed | |
| this.commands.processKeydownEvent(keyDownEvent); | |
| @@ -396,15 +391,11 @@ export namespace JupyterLab { | |
| this._disabled = JSON.parse( | |
| JSON.stringify(options.disabled ?? JupyterLab.defaultInfo.disabled) | |
| ); | |
| - this._filesCached = | |
| - options.filesCached ?? JupyterLab.defaultInfo.filesCached; | |
| + this._filesCached = options.filesCached ?? JupyterLab.defaultInfo.filesCached; | |
| this._mimeExtensions = JSON.parse( | |
| - JSON.stringify( | |
| - options.mimeExtensions ?? JupyterLab.defaultInfo.mimeExtensions | |
| - ) | |
| + JSON.stringify(options.mimeExtensions ?? JupyterLab.defaultInfo.mimeExtensions) | |
| ); | |
| - this.isConnected = | |
| - options.isConnected ?? JupyterLab.defaultInfo.isConnected; | |
| + this.isConnected = options.isConnected ?? JupyterLab.defaultInfo.isConnected; | |
| } | |
| /** | |
| @@ -478,9 +469,7 @@ export namespace JupyterLab { | |
| /* | |
| * A read-only subset of the `Token`. | |
| */ | |
| - export interface IToken extends Readonly< | |
| - Pick<Token<any>, 'name' | 'description'> | |
| - > { | |
| + export interface IToken extends Readonly<Pick<Token<any>, 'name' | 'description'>> { | |
| // no-op | |
| } | |
| diff --git a/packages/application/src/layoutrestorer.ts b/packages/application/src/layoutrestorer.ts | |
| index 5b712827af..0714550dde 100644 | |
| --- a/packages/application/src/layoutrestorer.ts | |
| +++ b/packages/application/src/layoutrestorer.ts | |
| @@ -186,8 +186,7 @@ export class LayoutRestorer implements ILayoutRestorer { | |
| return blank; | |
| } | |
| - const { main, down, left, right, relativeSizes, top } = | |
| - data as Private.ILayout; | |
| + const { main, down, left, right, relativeSizes, top } = data as Private.ILayout; | |
| // If any data exists, then this is not a fresh session. | |
| const fresh = false; | |
| @@ -436,9 +435,7 @@ export class LayoutRestorer implements ILayoutRestorer { | |
| const widgets = !Array.isArray(area.widgets) | |
| ? null | |
| : area.widgets | |
| - .map(name => | |
| - internal.has(`${name}`) ? internal.get(`${name}`) : null | |
| - ) | |
| + .map(name => (internal.has(`${name}`) ? internal.get(`${name}`) : null)) | |
| .filter(widget => !!widget); | |
| return { | |
| currentWidget: currentWidget!, | |
| @@ -489,9 +486,7 @@ export class LayoutRestorer implements ILayoutRestorer { | |
| * This function consumes data that can become corrupted, so it uses type | |
| * coercion to guarantee the dehydrated object is safely processed. | |
| */ | |
| - private _rehydrateSideArea( | |
| - area?: Private.ISideArea | null | |
| - ): ILabShell.ISideArea { | |
| + private _rehydrateSideArea(area?: Private.ISideArea | null): ILabShell.ISideArea { | |
| if (!area) { | |
| return { | |
| collapsed: true, | |
| @@ -515,9 +510,7 @@ export class LayoutRestorer implements ILayoutRestorer { | |
| const widgets = !Array.isArray(area.widgets) | |
| ? null | |
| : area.widgets | |
| - .map(name => | |
| - internal.has(`${name}`) ? internal.get(`${name}`) : null | |
| - ) | |
| + .map(name => (internal.has(`${name}`) ? internal.get(`${name}`) : null)) | |
| .filter(widget => !!widget); | |
| const widgetStates = area.widgetStates as { | |
| [id: string]: { | |
| @@ -787,9 +780,9 @@ namespace Private { | |
| type: 'split-area', | |
| orientation: area.orientation, | |
| sizes: area.sizes, | |
| - children: area.children | |
| - .map(serializeArea) | |
| - .filter(area => !!area) as Array<ITabArea | ISplitArea> | |
| + children: area.children.map(serializeArea).filter(area => !!area) as Array< | |
| + ITabArea | ISplitArea | |
| + > | |
| }; | |
| } | |
| diff --git a/packages/application/src/router.ts b/packages/application/src/router.ts | |
| index f6e7c60737..86f9da07dc 100644 | |
| --- a/packages/application/src/router.ts | |
| +++ b/packages/application/src/router.ts | |
| @@ -72,8 +72,7 @@ export class Router implements IRouter { | |
| const { history } = window; | |
| const { hard } = options; | |
| const old = document.location.href; | |
| - const url = | |
| - path && path.indexOf(base) === 0 ? path : URLExt.join(base, path); | |
| + const url = path && path.indexOf(base) === 0 ? path : URLExt.join(base, path); | |
| if (url === old) { | |
| return hard ? this.reload() : undefined; | |
| diff --git a/packages/application/src/shell.ts b/packages/application/src/shell.ts | |
| index c3feb3d2ad..d8c272c109 100644 | |
| --- a/packages/application/src/shell.ts | |
| +++ b/packages/application/src/shell.ts | |
| @@ -332,9 +332,7 @@ export class LabShell extends Widget implements JupyterFrontEnd.IShell { | |
| } | |
| // Skip Links | |
| - const skipLinkWidget = (this._skipLinkWidget = new Private.SkipLinkWidget( | |
| - this | |
| - )); | |
| + const skipLinkWidget = (this._skipLinkWidget = new Private.SkipLinkWidget(this)); | |
| this._skipLinkWidget.show(); | |
| // Wrap the skip widget to customize its position and size | |
| const skipLinkWrapper = new Panel(); | |
| @@ -349,15 +347,13 @@ export class LabShell extends Widget implements JupyterFrontEnd.IShell { | |
| const bottomPanel = (this._bottomPanel = new BoxPanel()); | |
| bottomPanel.node.setAttribute('role', 'contentinfo'); | |
| const hboxPanel = new BoxPanel(); | |
| - const vsplitPanel = (this._vsplitPanel = | |
| - new Private.RestorableSplitPanel()); | |
| + const vsplitPanel = (this._vsplitPanel = new Private.RestorableSplitPanel()); | |
| const dockPanel = (this._dockPanel = new DockPanelSvg({ | |
| hiddenMode: Widget.HiddenMode.Display | |
| })); | |
| MessageLoop.installMessageHook(dockPanel, this._dockChildHook); | |
| - const hsplitPanel = (this._hsplitPanel = | |
| - new Private.RestorableSplitPanel()); | |
| + const hsplitPanel = (this._hsplitPanel = new Private.RestorableSplitPanel()); | |
| const downPanel = (this._downPanel = new TabPanelSvg({ | |
| tabsMovable: true | |
| })); | |
| @@ -460,10 +456,7 @@ export class LabShell extends Widget implements JupyterFrontEnd.IShell { | |
| // Connect down panel change listeners | |
| this._downPanel.currentChanged.connect(this._onLayoutModified, this); | |
| this._downPanel.tabBar.tabMoved.connect(this._onTabPanelChanged, this); | |
| - this._downPanel.stackedPanel.widgetRemoved.connect( | |
| - this._onTabPanelChanged, | |
| - this | |
| - ); | |
| + this._downPanel.stackedPanel.widgetRemoved.connect(this._onTabPanelChanged, this); | |
| // Catch current changed events on the side handlers. | |
| this._leftHandler.updated.connect(this._onLayoutModified, this); | |
| @@ -496,10 +489,7 @@ export class LabShell extends Widget implements JupyterFrontEnd.IShell { | |
| oldValue.title.changed.disconnect(this._updateTitlePanelTitle, this); | |
| if (oldValue instanceof DocumentWidget) { | |
| - oldValue.context.pathChanged.disconnect( | |
| - this._updateCurrentPath, | |
| - this | |
| - ); | |
| + oldValue.context.pathChanged.disconnect(this._updateCurrentPath, this); | |
| } | |
| } | |
| @@ -737,10 +727,7 @@ export class LabShell extends Widget implements JupyterFrontEnd.IShell { | |
| TabBarSvg.translator = value; | |
| const trans = value.load('jupyterlab'); | |
| - this._menuHandler.panel.node.setAttribute( | |
| - 'aria-label', | |
| - trans.__('main menu') | |
| - ); | |
| + this._menuHandler.panel.node.setAttribute('aria-label', trans.__('main menu')); | |
| this._leftHandler.sideBar.node.setAttribute( | |
| 'aria-label', | |
| trans.__('main sidebar') | |
| @@ -757,14 +744,8 @@ export class LabShell extends Widget implements JupyterFrontEnd.IShell { | |
| 'aria-label', | |
| trans.__('alternate sidebar') | |
| ); | |
| - this._topHandler.panel.node.setAttribute( | |
| - 'aria-label', | |
| - trans.__('Top Bar') | |
| - ); | |
| - this._bottomPanel.node.setAttribute( | |
| - 'aria-label', | |
| - trans.__('Bottom Panel') | |
| - ); | |
| + this._topHandler.panel.node.setAttribute('aria-label', trans.__('Top Bar')); | |
| + this._bottomPanel.node.setAttribute('aria-label', trans.__('Bottom Panel')); | |
| this._dockPanel.node.setAttribute('aria-label', trans.__('Main Content')); | |
| } | |
| } | |
| @@ -1174,8 +1155,7 @@ export class LabShell extends Widget implements JupyterFrontEnd.IShell { | |
| const layout = await layoutRestorer.fetch(); | |
| // Reset the layout | |
| - const { mainArea, downArea, leftArea, rightArea, topArea, relativeSizes } = | |
| - layout; | |
| + const { mainArea, downArea, leftArea, rightArea, topArea, relativeSizes } = layout; | |
| // Rehydrate the main area. | |
| if (mainArea) { | |
| @@ -1214,9 +1194,7 @@ export class LabShell extends Widget implements JupyterFrontEnd.IShell { | |
| .filter(title => !widgetIds.includes(title.owner.id)) | |
| .map(title => title.owner.close()); | |
| // Add new widgets | |
| - const titleIds = this._downPanel.tabBar.titles.map( | |
| - title => title.owner.id | |
| - ); | |
| + const titleIds = this._downPanel.tabBar.titles.map(title => title.owner.id); | |
| widgets | |
| ?.filter(widget => !titleIds.includes(widget.id)) | |
| .map(widget => this._downPanel.addWidget(widget)); | |
| @@ -1542,10 +1520,7 @@ export class LabShell extends Widget implements JupyterFrontEnd.IShell { | |
| * #### Notes | |
| * Widgets must have a unique `id` property, which will be used as the DOM id. | |
| */ | |
| - private _addToTopArea( | |
| - widget: Widget, | |
| - options?: DocumentRegistry.IOpenOptions | |
| - ): void { | |
| + private _addToTopArea(widget: Widget, options?: DocumentRegistry.IOpenOptions): void { | |
| if (!widget.id) { | |
| console.error('Widgets added to app shell must have unique id property.'); | |
| return; | |
| @@ -1679,11 +1654,7 @@ export class LabShell extends Widget implements JupyterFrontEnd.IShell { | |
| } | |
| // Otherwise, direction is 'next'. | |
| - return index < len - 1 | |
| - ? bars[index + 1] | |
| - : index === len - 1 | |
| - ? bars[0] | |
| - : null; | |
| + return index < len - 1 ? bars[index + 1] : index === len - 1 ? bars[0] : null; | |
| } | |
| /* | |
| @@ -1703,10 +1674,7 @@ export class LabShell extends Widget implements JupyterFrontEnd.IShell { | |
| /** | |
| * Handle a change to the dock area active widget. | |
| */ | |
| - private _onActiveChanged( | |
| - sender: any, | |
| - args: FocusTracker.IChangedArgs<Widget> | |
| - ): void { | |
| + private _onActiveChanged(sender: any, args: FocusTracker.IChangedArgs<Widget>): void { | |
| if (args.newValue) { | |
| args.newValue.title.className += ` ${ACTIVE_CLASS}`; | |
| } | |
| @@ -1759,10 +1727,7 @@ export class LabShell extends Widget implements JupyterFrontEnd.IShell { | |
| /** | |
| * A message hook for child add/remove messages on the main area dock panel. | |
| */ | |
| - private _dockChildHook = ( | |
| - handler: IMessageHandler, | |
| - msg: Message | |
| - ): boolean => { | |
| + private _dockChildHook = (handler: IMessageHandler, msg: Message): boolean => { | |
| switch (msg.type) { | |
| case 'child-added': | |
| (msg as Widget.ChildMessage).child.addClass(ACTIVITY_CLASS); | |
| @@ -1814,10 +1779,9 @@ export class LabShell extends Widget implements JupyterFrontEnd.IShell { | |
| private _cachedLayout: DockLayout.ILayoutConfig | null = null; | |
| private _currentChanged = new Signal<this, ILabShell.IChangedArgs>(this); | |
| private _currentPath = ''; | |
| - private _currentPathChanged = new Signal< | |
| - this, | |
| - ILabShell.ICurrentPathChangedArgs | |
| - >(this); | |
| + private _currentPathChanged = new Signal<this, ILabShell.ICurrentPathChangedArgs>( | |
| + this | |
| + ); | |
| private _modeChanged = new Signal<this, DockPanel.Mode>(this); | |
| private _dockPanel: DockPanel; | |
| private _downPanel: TabPanel; | |
| @@ -1926,10 +1890,7 @@ namespace Private { | |
| /** | |
| * A message hook for child add/remove messages on the main area dock panel. | |
| */ | |
| - private _panelChildHook = ( | |
| - handler: IMessageHandler, | |
| - msg: Message | |
| - ): boolean => { | |
| + private _panelChildHook = (handler: IMessageHandler, msg: Message): boolean => { | |
| switch (msg.type) { | |
| case 'child-added': | |
| { | |
| @@ -1979,10 +1940,7 @@ namespace Private { | |
| this._stackedPanel.hide(); | |
| this._lastCurrent = null; | |
| this._sideBar.currentChanged.connect(this._onCurrentChanged, this); | |
| - this._sideBar.tabActivateRequested.connect( | |
| - this._onTabActivateRequested, | |
| - this | |
| - ); | |
| + this._sideBar.tabActivateRequested.connect(this._onTabActivateRequested, this); | |
| this._stackedPanel.widgetRemoved.connect(this._onWidgetRemoved, this); | |
| } | |
| diff --git a/packages/application/src/utils.ts b/packages/application/src/utils.ts | |
| index 785af25bd7..c25f3290aa 100644 | |
| --- a/packages/application/src/utils.ts | |
| +++ b/packages/application/src/utils.ts | |
| @@ -151,9 +151,7 @@ export function addSemanticCommand(options: ISemanticCommandOptions): void { | |
| * be removed of the public API in JupyterLab 5. | |
| */ | |
| export function createSemanticCommand( | |
| - app: | |
| - | JupyterFrontEnd | |
| - | { commands: CommandRegistry; shell: JupyterFrontEnd.IShell }, | |
| + app: JupyterFrontEnd | { commands: CommandRegistry; shell: JupyterFrontEnd.IShell }, | |
| semanticCommands: SemanticCommand | SemanticCommand[], | |
| defaultValues: ISemanticCommandDefault, | |
| trans: TranslationBundle | |
| @@ -169,8 +167,7 @@ export function createSemanticCommand( | |
| isEnabled: () => { | |
| const isEnabled = reduceAttribute('isEnabled'); | |
| return ( | |
| - (isEnabled.length > 0 && | |
| - !isEnabled.some(enabled => enabled === false)) || | |
| + (isEnabled.length > 0 && !isEnabled.some(enabled => enabled === false)) || | |
| (defaultValues.isEnabled ?? false) | |
| ); | |
| }, | |
| @@ -184,8 +181,7 @@ export function createSemanticCommand( | |
| isVisible: () => { | |
| const isVisible = reduceAttribute('isVisible'); | |
| return ( | |
| - (isVisible.length > 0 && | |
| - !isVisible.some(visible => visible === false)) || | |
| + (isVisible.length > 0 && !isVisible.some(visible => visible === false)) || | |
| (defaultValues.isVisible ?? true) | |
| ); | |
| }, | |
| @@ -216,9 +212,7 @@ export function createSemanticCommand( | |
| } | |
| }; | |
| - function reduceAttribute( | |
| - attribute: keyof CommandRegistry.ICommandOptions | |
| - ): any[] { | |
| + function reduceAttribute(attribute: keyof CommandRegistry.ICommandOptions): any[] { | |
| const widget = shell.currentWidget; | |
| const commandIds = commandList.map(cmd => | |
| widget !== null ? cmd.getActiveCommandId(widget) : null | |
| @@ -233,11 +227,8 @@ export function createSemanticCommand( | |
| attribute: 'label' | 'caption' | |
| ): string | CommandRegistry.CommandFunc<string> | undefined { | |
| return () => { | |
| - const texts = (reduceAttribute(attribute) as string[]).map( | |
| - (text, textIndex) => | |
| - attribute == 'caption' && textIndex > 0 | |
| - ? text.toLocaleLowerCase() | |
| - : text | |
| + const texts = (reduceAttribute(attribute) as string[]).map((text, textIndex) => | |
| + attribute == 'caption' && textIndex > 0 ? text.toLocaleLowerCase() : text | |
| ); | |
| switch (texts.length) { | |
| @@ -251,8 +242,7 @@ export function createSemanticCommand( | |
| .slice(undefined, -1) | |
| .map(l => l.replace(/…$/, '')) | |
| .join(', '); | |
| - const end = | |
| - texts.slice(-1)[0].replace(/…$/, '') + (hasEllipsis ? '…' : ''); | |
| + const end = texts.slice(-1)[0].replace(/…$/, '') + (hasEllipsis ? '…' : ''); | |
| return trans.__('%1 and %2', main, end); | |
| } | |
| } | |
| diff --git a/packages/application/style/core.css b/packages/application/style/core.css | |
| index 7e0f248125..c9f5f781aa 100644 | |
| --- a/packages/application/style/core.css | |
| +++ b/packages/application/style/core.css | |
| @@ -69,15 +69,11 @@ | |
| } | |
| .jp-LabShell[data-shell-mode='single-document'] #jp-menu-panel { | |
| - padding-left: calc( | |
| - var(--jp-private-sidebar-tab-width) + var(--jp-border-width) | |
| - ); | |
| + padding-left: calc(var(--jp-private-sidebar-tab-width) + var(--jp-border-width)); | |
| border-bottom: var(--jp-border-width) solid var(--jp-border-color0); | |
| /* Adjust min-height so open menus show up in the right place */ | |
| - min-height: calc( | |
| - var(--jp-private-menu-panel-height) + var(--jp-border-width) | |
| - ); | |
| + min-height: calc(var(--jp-private-menu-panel-height) + var(--jp-border-width)); | |
| } | |
| #jp-bottom-panel { | |
| diff --git a/packages/application/style/menus.css b/packages/application/style/menus.css | |
| index c3042097aa..e9ed97853b 100644 | |
| --- a/packages/application/style/menus.css | |
| +++ b/packages/application/style/menus.css | |
| @@ -74,9 +74,7 @@ | |
| border-left: var(--jp-border-width) solid transparent; | |
| border-right: var(--jp-border-width) solid transparent; | |
| border-top: var(--jp-border-width) solid transparent; | |
| - line-height: calc( | |
| - var(--jp-private-menubar-height) - var(--jp-border-width) * 2 | |
| - ); | |
| + line-height: calc(var(--jp-private-menubar-height) - var(--jp-border-width) * 2); | |
| } | |
| .lm-MenuBar-content:focus-visible { | |
| diff --git a/packages/application/test/lab.spec.ts b/packages/application/test/lab.spec.ts | |
| index 7acb2835d2..6fa000cf9f 100644 | |
| --- a/packages/application/test/lab.spec.ts | |
| +++ b/packages/application/test/lab.spec.ts | |
| @@ -32,9 +32,7 @@ describe('plugins', () => { | |
| const mode: DockPanel.Mode = 'multiple-document'; | |
| void lab.shell.restoreLayout(mode, restorer); | |
| await lab.restored; | |
| - expect( | |
| - lab.isPluginActivated('@jupyterlab/test-extension:plugin') | |
| - ).toBeTruthy(); | |
| + expect(lab.isPluginActivated('@jupyterlab/test-extension:plugin')).toBeTruthy(); | |
| }); | |
| it('autoStart=false plugin should never be activated', async () => { | |
| @@ -49,13 +47,9 @@ describe('plugins', () => { | |
| const mode: DockPanel.Mode = 'multiple-document'; | |
| void lab.shell.restoreLayout(mode, restorer); | |
| await lab.restored; | |
| - expect( | |
| - lab.isPluginActivated('@jupyterlab/test-extension:plugin') | |
| - ).toBeFalsy(); | |
| + expect(lab.isPluginActivated('@jupyterlab/test-extension:plugin')).toBeFalsy(); | |
| await lab.allPluginsActivated; | |
| - expect( | |
| - lab.isPluginActivated('@jupyterlab/test-extension:plugin') | |
| - ).toBeFalsy(); | |
| + expect(lab.isPluginActivated('@jupyterlab/test-extension:plugin')).toBeFalsy(); | |
| }); | |
| it('deferred plugin should not be activated right after application restore', async () => { | |
| @@ -70,12 +64,8 @@ describe('plugins', () => { | |
| const mode: DockPanel.Mode = 'multiple-document'; | |
| void lab.shell.restoreLayout(mode, restorer); | |
| await lab.restored; | |
| - expect( | |
| - lab.isPluginActivated('@jupyterlab/test-extension:plugin') | |
| - ).toBeFalsy(); | |
| + expect(lab.isPluginActivated('@jupyterlab/test-extension:plugin')).toBeFalsy(); | |
| await lab.allPluginsActivated; | |
| - expect( | |
| - lab.isPluginActivated('@jupyterlab/test-extension:plugin') | |
| - ).toBeTruthy(); | |
| + expect(lab.isPluginActivated('@jupyterlab/test-extension:plugin')).toBeTruthy(); | |
| }); | |
| }); | |
| diff --git a/packages/application/test/shell.spec.ts b/packages/application/test/shell.spec.ts | |
| index eb5d562040..cc8b665f69 100644 | |
| --- a/packages/application/test/shell.spec.ts | |
| +++ b/packages/application/test/shell.spec.ts | |
| @@ -473,26 +473,16 @@ describe('LabShell', () => { | |
| widget.id = 'main'; | |
| shell.add(widget, 'main'); | |
| - expect(Array.from(shell.widgets('header')).map(v => v.id)).toEqual([ | |
| - 'header' | |
| - ]); | |
| + expect(Array.from(shell.widgets('header')).map(v => v.id)).toEqual(['header']); | |
| expect( | |
| Array.from(shell.widgets('top')) | |
| .slice(-1) | |
| .map(v => v.id) | |
| ).toEqual(['top']); | |
| - expect(Array.from(shell.widgets('menu')).map(v => v.id)).toEqual([ | |
| - 'menu' | |
| - ]); | |
| - expect(Array.from(shell.widgets('left')).map(v => v.id)).toEqual([ | |
| - 'left' | |
| - ]); | |
| - expect(Array.from(shell.widgets('right')).map(v => v.id)).toEqual([ | |
| - 'right' | |
| - ]); | |
| - expect(Array.from(shell.widgets('main')).map(v => v.id)).toEqual([ | |
| - 'main' | |
| - ]); | |
| + expect(Array.from(shell.widgets('menu')).map(v => v.id)).toEqual(['menu']); | |
| + expect(Array.from(shell.widgets('left')).map(v => v.id)).toEqual(['left']); | |
| + expect(Array.from(shell.widgets('right')).map(v => v.id)).toEqual(['right']); | |
| + expect(Array.from(shell.widgets('main')).map(v => v.id)).toEqual(['main']); | |
| }); | |
| it('should default to main area', () => { | |
| @@ -551,9 +541,7 @@ describe('LabShell', () => { | |
| shell.add(widget, 'left'); | |
| const leftHandler = document.getElementsByClassName('jp-mod-left'); | |
| expect(leftHandler[0]?.getAttribute('role')).toEqual('complementary'); | |
| - expect(leftHandler[0]?.getAttribute('aria-label')).toEqual( | |
| - 'main sidebar' | |
| - ); | |
| + expect(leftHandler[0]?.getAttribute('aria-label')).toEqual('main sidebar'); | |
| }); | |
| it('right handler should have a role of complementary and aria label of alternate sidebar', () => { | |
| @@ -562,9 +550,7 @@ describe('LabShell', () => { | |
| shell.add(widget, 'right'); | |
| const rightHandler = document.getElementsByClassName('jp-mod-right'); | |
| expect(rightHandler[0]?.getAttribute('role')).toEqual('complementary'); | |
| - expect(rightHandler[0]?.getAttribute('aria-label')).toEqual( | |
| - 'alternate sidebar' | |
| - ); | |
| + expect(rightHandler[0]?.getAttribute('aria-label')).toEqual('alternate sidebar'); | |
| }); | |
| it('dock panel should have a role of main', () => { | |
| diff --git a/packages/application/test/utils.spec.ts b/packages/application/test/utils.spec.ts | |
| index 2a6231f3c7..d6a8417ff0 100644 | |
| --- a/packages/application/test/utils.spec.ts | |
| +++ b/packages/application/test/utils.spec.ts | |
| @@ -143,41 +143,17 @@ describe('@jupyterlab/application', () => { | |
| [['label a', 'label b…'], 'default', 'label a and label b…'], | |
| [['label a…', 'label b'], 'default', 'label a and label b…'], | |
| [['label a…', 'label b…'], 'default', 'label a and label b…'], | |
| - [ | |
| - ['label a', 'label b', 'label c'], | |
| - 'default', | |
| - 'label a, label b and label c' | |
| - ], | |
| - [ | |
| - ['label a…', 'label b…', 'label c'], | |
| - 'default', | |
| - 'label a, label b and label c…' | |
| - ], | |
| - [ | |
| - ['label a…', 'label b', 'label c…'], | |
| - 'default', | |
| - 'label a, label b and label c…' | |
| - ], | |
| + [['label a', 'label b', 'label c'], 'default', 'label a, label b and label c'], | |
| + [['label a…', 'label b…', 'label c'], 'default', 'label a, label b and label c…'], | |
| + [['label a…', 'label b', 'label c…'], 'default', 'label a, label b and label c…'], | |
| [ | |
| ['label a…', 'label b…', 'label c…'], | |
| 'default', | |
| 'label a, label b and label c…' | |
| ], | |
| - [ | |
| - ['label a', 'label b…', 'label c'], | |
| - 'default', | |
| - 'label a, label b and label c…' | |
| - ], | |
| - [ | |
| - ['label a', 'label b…', 'label c…'], | |
| - 'default', | |
| - 'label a, label b and label c…' | |
| - ], | |
| - [ | |
| - ['label a', 'label b', 'label c…'], | |
| - 'default', | |
| - 'label a, label b and label c…' | |
| - ] | |
| + [['label a', 'label b…', 'label c'], 'default', 'label a, label b and label c…'], | |
| + [['label a', 'label b…', 'label c…'], 'default', 'label a, label b and label c…'], | |
| + [['label a', 'label b', 'label c…'], 'default', 'label a, label b and label c…'] | |
| ])( | |
| 'labels/captions %j, and default %s has label/caption %s', | |
| (values, defaultValue, expected) => { | |
| diff --git a/packages/apputils-extension/src/announcements.ts b/packages/apputils-extension/src/announcements.ts | |
| index a8df559385..caf4b7236a 100644 | |
| --- a/packages/apputils-extension/src/announcements.ts | |
| +++ b/packages/apputils-extension/src/announcements.ts | |
| @@ -3,10 +3,7 @@ | |
| * Distributed under the terms of the Modified BSD License. | |
| */ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { Notification } from '@jupyterlab/apputils'; | |
| import { URLExt } from '@jupyterlab/coreutils'; | |
| import type { ConfigSection } from '@jupyterlab/services'; | |
| @@ -17,8 +14,7 @@ import { ITranslator, nullTranslator } from '@jupyterlab/translation'; | |
| const COMMAND_HELP_OPEN = 'help:open'; | |
| const NEWS_API_URL = '/lab/api/news'; | |
| const UPDATE_API_URL = '/lab/api/update'; | |
| -const PRIVACY_URL = | |
| - 'https://jupyterlab.readthedocs.io/en/latest/privacy_policies.html'; | |
| +const PRIVACY_URL = 'https://jupyterlab.readthedocs.io/en/latest/privacy_policies.html'; | |
| /** | |
| * Call the announcement API | |
| @@ -84,15 +80,13 @@ export const announcements: JupyterFrontEndPlugin<void> = { | |
| if (change.type !== 'removed') { | |
| return; | |
| } | |
| - const { id, tags }: { id?: string; tags?: Array<string> } = (change | |
| - .notification.options.data ?? {}) as any; | |
| + const { id, tags }: { id?: string; tags?: Array<string> } = (change.notification | |
| + .options.data ?? {}) as any; | |
| if ((tags ?? []).some(tag => ['news', 'update'].includes(tag)) && id) { | |
| const update: { [k: string]: INewsState } = {}; | |
| update[id] = { seen: true, dismissed: true }; | |
| config?.update(update as any).catch(reason => { | |
| - console.error( | |
| - `Failed to update the announcements config:\n${reason}` | |
| - ); | |
| + console.error(`Failed to update the announcements config:\n${reason}`); | |
| }); | |
| } | |
| }); | |
| @@ -103,9 +97,7 @@ export const announcements: JupyterFrontEndPlugin<void> = { | |
| | 'none'; | |
| if (mustFetchNews === 'none') { | |
| const notificationId = Notification.emit( | |
| - trans.__( | |
| - 'Would you like to get notified about official Jupyter news?' | |
| - ), | |
| + trans.__('Would you like to get notified about official Jupyter news?'), | |
| 'default', | |
| { | |
| autoClose: false, | |
| @@ -137,9 +129,7 @@ export const announcements: JupyterFrontEndPlugin<void> = { | |
| console.error(`Failed to get the news:\n${reason}`); | |
| }); | |
| settings?.set('fetchNews', 'true').catch((reason: any) => { | |
| - console.error( | |
| - `Failed to save setting 'fetchNews':\n${reason}` | |
| - ); | |
| + console.error(`Failed to save setting 'fetchNews':\n${reason}`); | |
| }); | |
| } | |
| }, | |
| @@ -148,9 +138,7 @@ export const announcements: JupyterFrontEndPlugin<void> = { | |
| callback: () => { | |
| Notification.dismiss(notificationId); | |
| settings?.set('fetchNews', 'false').catch((reason: any) => { | |
| - console.error( | |
| - `Failed to save setting 'fetchNews':\n${reason}` | |
| - ); | |
| + console.error(`Failed to save setting 'fetchNews':\n${reason}`); | |
| }); | |
| } | |
| } | |
| diff --git a/packages/apputils-extension/src/index.ts b/packages/apputils-extension/src/index.ts | |
| index c103a0f6c0..7c33a94601 100644 | |
| --- a/packages/apputils-extension/src/index.ts | |
| +++ b/packages/apputils-extension/src/index.ts | |
| @@ -8,11 +8,7 @@ | |
| */ | |
| import type { JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| -import { | |
| - ILayoutRestorer, | |
| - IRouter, | |
| - JupyterFrontEnd | |
| -} from '@jupyterlab/application'; | |
| +import { ILayoutRestorer, IRouter, JupyterFrontEnd } from '@jupyterlab/application'; | |
| import { | |
| Dialog, | |
| ICommandPalette, | |
| @@ -136,8 +132,7 @@ const resolver: JupyterFrontEndPlugin<IWindowResolver> = { | |
| const solver = new WindowResolver(); | |
| const workspace = PageConfig.getOption('workspace'); | |
| const treePath = PageConfig.getOption('treePath'); | |
| - const mode = | |
| - PageConfig.getOption('mode') === 'multiple-document' ? 'lab' : 'doc'; | |
| + const mode = PageConfig.getOption('mode') === 'multiple-document' ? 'lab' : 'doc'; | |
| // This is used as a key in local storage to refer to workspaces, either the name | |
| // of the workspace or the string PageConfig.defaultWorkspace. Both lab and doc modes share the same workspace. | |
| const candidate = workspace ? workspace : PageConfig.defaultWorkspace; | |
| @@ -151,8 +146,7 @@ const resolver: JupyterFrontEndPlugin<IWindowResolver> = { | |
| // that rely on `IWindowResolver`. | |
| return new Promise<IWindowResolver>(() => { | |
| const { base } = paths.urls; | |
| - const pool = | |
| - 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; | |
| + const pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; | |
| const random = pool[Math.floor(Math.random() * pool.length)]; | |
| let path = URLExt.join(base, mode, 'workspaces', `auto-${random}`); | |
| path = rest ? URLExt.join(path, URLExt.encodeParts(rest)) : path; | |
| @@ -401,9 +395,7 @@ async function updateTabTitle(options: { | |
| } | |
| // Truncate to first 12 characters of current document name + ... if length > 15 | |
| currentFile = | |
| - currentFile.length > 15 | |
| - ? currentFile.slice(0, 12).concat(`…`) | |
| - : currentFile; | |
| + currentFile.length > 15 ? currentFile.slice(0, 12).concat(`…`) : currentFile; | |
| const truncatedWorkspace = | |
| workspace.length > 15 ? workspace.slice(0, 12).concat(`…`) : workspace; | |
| // Number of restorable items that are either notebooks or editors | |
| @@ -484,9 +476,7 @@ const state: JupyterFrontEndPlugin<IStateDB> = { | |
| }, | |
| search: { | |
| type: 'string', | |
| - description: trans.__( | |
| - 'The URL search string containing query parameters' | |
| - ) | |
| + description: trans.__('The URL search string containing query parameters') | |
| } | |
| } | |
| } | |
| @@ -561,9 +551,7 @@ const state: JupyterFrontEndPlugin<IStateDB> = { | |
| properties: { | |
| reload: { | |
| type: 'boolean', | |
| - description: trans.__( | |
| - 'Whether to reload the page after resetting' | |
| - ) | |
| + description: trans.__('Whether to reload the page after resetting') | |
| } | |
| } | |
| } | |
| @@ -593,9 +581,7 @@ const state: JupyterFrontEndPlugin<IStateDB> = { | |
| }, | |
| search: { | |
| type: 'string', | |
| - description: trans.__( | |
| - 'The URL search string containing query parameters' | |
| - ) | |
| + description: trans.__('The URL search string containing query parameters') | |
| } | |
| } | |
| } | |
| @@ -759,8 +745,7 @@ const utilityCommands: JupyterFrontEndPlugin<void> = { | |
| const commands: string[] = (args.commands as string[]) ?? []; | |
| const commandArgs: any = args.args; | |
| const argList = Array.isArray(args); | |
| - const errorIfNotEnabled: boolean = | |
| - (args.errorIfNotEnabled as boolean) ?? false; | |
| + const errorIfNotEnabled: boolean = (args.errorIfNotEnabled as boolean) ?? false; | |
| for (let i = 0; i < commands.length; i++) { | |
| const cmd = commands[i]; | |
| const arg = argList ? commandArgs[i] : commandArgs; | |
| @@ -830,8 +815,7 @@ const sanitizer: JupyterFrontEndPlugin<IRenderMime.ISanitizer> = { | |
| ): IRenderMime.ISanitizer => { | |
| const sanitizer = new Sanitizer(); | |
| const loadSetting = (setting: ISettingRegistry.ISettings): void => { | |
| - const allowedSchemes = setting.get('allowedSchemes') | |
| - .composite as Array<string>; | |
| + const allowedSchemes = setting.get('allowedSchemes').composite as Array<string>; | |
| const autolink = setting.get('autolink').composite as boolean; | |
| const allowNamedProperties = setting.get('allowNamedProperties') | |
| diff --git a/packages/apputils-extension/src/licensesplugin.ts b/packages/apputils-extension/src/licensesplugin.ts | |
| index 88c3ae3579..1cd29009ca 100644 | |
| --- a/packages/apputils-extension/src/licensesplugin.ts | |
| +++ b/packages/apputils-extension/src/licensesplugin.ts | |
| @@ -3,10 +3,7 @@ | |
| * Distributed under the terms of the Modified BSD License. | |
| */ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { ILayoutRestorer } from '@jupyterlab/application'; | |
| import { | |
| ICommandPalette, | |
| @@ -175,8 +172,7 @@ export const licensesPlugin: JupyterFrontEndPlugin<void> = { | |
| properties: { | |
| noLabel: { | |
| oneOf: [{ type: 'boolean' }, { type: 'number' }], | |
| - description: | |
| - 'Whether to hide the label (truthy values hide label)' | |
| + description: 'Whether to hide the label (truthy values hide label)' | |
| } | |
| } | |
| } | |
| @@ -212,8 +208,7 @@ export const licensesPlugin: JupyterFrontEndPlugin<void> = { | |
| }, | |
| noLabel: { | |
| oneOf: [{ type: 'boolean' }, { type: 'number' }], | |
| - description: | |
| - 'Whether to hide the label (truthy values hide label)' | |
| + description: 'Whether to hide the label (truthy values hide label)' | |
| } | |
| }, | |
| required: ['format'] | |
| diff --git a/packages/apputils-extension/src/notificationplugin.tsx b/packages/apputils-extension/src/notificationplugin.tsx | |
| index 21334600f4..7107c54365 100644 | |
| --- a/packages/apputils-extension/src/notificationplugin.tsx | |
| +++ b/packages/apputils-extension/src/notificationplugin.tsx | |
| @@ -3,20 +3,12 @@ | |
| * Distributed under the terms of the Modified BSD License. | |
| */ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import type { NotificationManager } from '@jupyterlab/apputils'; | |
| import { Notification, ReactWidget } from '@jupyterlab/apputils'; | |
| import { ISettingRegistry } from '@jupyterlab/settingregistry'; | |
| import type { Popup } from '@jupyterlab/statusbar'; | |
| -import { | |
| - GroupItem, | |
| - IStatusBar, | |
| - showPopup, | |
| - TextItem | |
| -} from '@jupyterlab/statusbar'; | |
| +import { GroupItem, IStatusBar, showPopup, TextItem } from '@jupyterlab/statusbar'; | |
| import type { TranslationBundle } from '@jupyterlab/translation'; | |
| import { ITranslator, nullTranslator } from '@jupyterlab/translation'; | |
| import type { LabIcon } from '@jupyterlab/ui-components'; | |
| @@ -289,8 +281,7 @@ class NotificationStatusModel extends VDomModel { | |
| const { autoClose } = change.notification.options; | |
| const noToast = | |
| - this.doNotDisturbMode || | |
| - (typeof autoClose === 'number' && autoClose <= 0); | |
| + this.doNotDisturbMode || (typeof autoClose === 'number' && autoClose <= 0); | |
| // Highlight if | |
| // the list is not opened (the style change if list is opened due to clickedItem style in statusbar.) | |
| @@ -354,10 +345,7 @@ function NotificationStatus(props: INotificationStatusProps): JSX.Element { | |
| : props.trans.__('No notifications') | |
| } | |
| > | |
| - <TextItem | |
| - className="jp-Notification-Status-Text" | |
| - source={`${props.count}`} | |
| - /> | |
| + <TextItem className="jp-Notification-Status-Text" source={`${props.count}`} /> | |
| <bellIcon.react top={'2px'} stylesheet={'statusBar'} /> | |
| </GroupItem> | |
| ); | |
| @@ -389,8 +377,7 @@ export const notificationPlugin: JupyterFrontEndPlugin<void> = { | |
| app.restored | |
| ]).then(([plugin]) => { | |
| const updateSettings = () => { | |
| - model.doNotDisturbMode = plugin.get('doNotDisturbMode') | |
| - .composite as boolean; | |
| + model.doNotDisturbMode = plugin.get('doNotDisturbMode').composite as boolean; | |
| }; | |
| updateSettings(); | |
| plugin.changed.connect(updateSettings); | |
| @@ -421,8 +408,7 @@ export const notificationPlugin: JupyterFrontEndPlugin<void> = { | |
| properties: { | |
| autoClose: { | |
| oneOf: [{ type: 'number' }, { type: 'boolean' }], | |
| - description: | |
| - 'Auto-close timeout in milliseconds, or false to disable' | |
| + description: 'Auto-close timeout in milliseconds, or false to disable' | |
| }, | |
| actions: { | |
| type: 'array', | |
| @@ -454,8 +440,7 @@ export const notificationPlugin: JupyterFrontEndPlugin<void> = { | |
| } | |
| }, | |
| data: { | |
| - description: | |
| - 'Additional data associated with the notification' | |
| + description: 'Additional data associated with the notification' | |
| } | |
| } | |
| } | |
| @@ -480,13 +465,11 @@ export const notificationPlugin: JupyterFrontEndPlugin<void> = { | |
| return { | |
| ...action, | |
| callback: () => { | |
| - app.commands | |
| - .execute(action.commandId, action.args) | |
| - .catch(r => { | |
| - console.error( | |
| - `Failed to executed '${action.commandId}':\n${r}` | |
| - ); | |
| - }); | |
| + app.commands.execute(action.commandId, action.args).catch(r => { | |
| + console.error( | |
| + `Failed to executed '${action.commandId}':\n${r}` | |
| + ); | |
| + }); | |
| } | |
| } as Notification.IAction; | |
| } | |
| @@ -524,8 +507,7 @@ export const notificationPlugin: JupyterFrontEndPlugin<void> = { | |
| properties: { | |
| autoClose: { | |
| oneOf: [{ type: 'number' }, { type: 'boolean' }], | |
| - description: | |
| - 'Auto-close timeout in milliseconds, or false to disable' | |
| + description: 'Auto-close timeout in milliseconds, or false to disable' | |
| }, | |
| actions: { | |
| type: 'array', | |
| @@ -557,8 +539,7 @@ export const notificationPlugin: JupyterFrontEndPlugin<void> = { | |
| } | |
| }, | |
| data: { | |
| - description: | |
| - 'Additional data associated with the notification' | |
| + description: 'Additional data associated with the notification' | |
| } | |
| } | |
| } | |
| @@ -585,13 +566,11 @@ export const notificationPlugin: JupyterFrontEndPlugin<void> = { | |
| return { | |
| ...action, | |
| callback: () => { | |
| - app.commands | |
| - .execute(action.commandId, action.args) | |
| - .catch(r => { | |
| - console.error( | |
| - `Failed to executed '${action.commandId}':\n${r}` | |
| - ); | |
| - }); | |
| + app.commands.execute(action.commandId, action.args).catch(r => { | |
| + console.error( | |
| + `Failed to executed '${action.commandId}':\n${r}` | |
| + ); | |
| + }); | |
| } | |
| } as Notification.IAction; | |
| } | |
| @@ -661,8 +640,7 @@ export const notificationPlugin: JupyterFrontEndPlugin<void> = { | |
| const actions = options.actions; | |
| const autoClose = | |
| - options.autoClose ?? | |
| - (actions && actions.length > 0 ? false : null); | |
| + options.autoClose ?? (actions && actions.length > 0 ? false : null); | |
| if (toast.isActive(id)) { | |
| // Update existing toast | |
| @@ -676,11 +654,7 @@ export const notificationPlugin: JupyterFrontEndPlugin<void> = { | |
| type: type === 'in-progress' ? null : type, | |
| isLoading: type === 'in-progress', | |
| autoClose: autoClose, | |
| - render: Private.createContent( | |
| - message, | |
| - closeToast, | |
| - options.actions | |
| - ) | |
| + render: Private.createContent(message, closeToast, options.actions) | |
| }); | |
| } else { | |
| // Needs to recreate a closed toast | |
| @@ -923,9 +897,7 @@ namespace Private { | |
| if (toastify === null) { | |
| toastify = await import('react-toastify'); | |
| - const container = document.body.appendChild( | |
| - document.createElement('div') | |
| - ); | |
| + const container = document.body.appendChild(document.createElement('div')); | |
| container.id = 'react-toastify-container'; | |
| container.classList.add('jp-ThemedContainer'); | |
| const root = createRoot(container); | |
| @@ -1069,8 +1041,7 @@ namespace Private { | |
| const { actions, autoClose, data } = options; | |
| const t = await toast(); | |
| const toastOptions = { | |
| - autoClose: | |
| - autoClose ?? (actions && actions.length > 0 ? false : undefined), | |
| + autoClose: autoClose ?? (actions && actions.length > 0 ? false : undefined), | |
| data: data as any, | |
| className: `jp-Notification-Toast-${type}`, | |
| toastId, | |
| diff --git a/packages/apputils-extension/src/palette.ts b/packages/apputils-extension/src/palette.ts | |
| index 9ef42af258..2d842eb541 100644 | |
| --- a/packages/apputils-extension/src/palette.ts | |
| +++ b/packages/apputils-extension/src/palette.ts | |
| @@ -104,10 +104,7 @@ export namespace Palette { | |
| let modal = false; | |
| palette.node.setAttribute('role', 'region'); | |
| - palette.node.setAttribute( | |
| - 'aria-label', | |
| - trans.__('Command Palette Section') | |
| - ); | |
| + palette.node.setAttribute('aria-label', trans.__('Command Palette Section')); | |
| shell.add(palette, 'left', { rank: 300, type: 'Command Palette' }); | |
| if (settingRegistry) { | |
| const loadSettings = settingRegistry.load(PALETTE_PLUGIN_ID); | |
| diff --git a/packages/apputils-extension/src/settingconnector.ts b/packages/apputils-extension/src/settingconnector.ts | |
| index 5a3f0d30a7..f16f7fda6b 100644 | |
| --- a/packages/apputils-extension/src/settingconnector.ts | |
| +++ b/packages/apputils-extension/src/settingconnector.ts | |
| @@ -4,10 +4,7 @@ | |
| */ | |
| import { PageConfig } from '@jupyterlab/coreutils'; | |
| -import type { | |
| - ISettingConnector, | |
| - ISettingRegistry | |
| -} from '@jupyterlab/settingregistry'; | |
| +import type { ISettingConnector, ISettingRegistry } from '@jupyterlab/settingregistry'; | |
| import type { IDataConnector } from '@jupyterlab/statedb'; | |
| import { DataConnector } from '@jupyterlab/statedb'; | |
| import { Throttler } from '@lumino/polling'; | |
| diff --git a/packages/apputils-extension/src/settingsplugin.ts b/packages/apputils-extension/src/settingsplugin.ts | |
| index 8069292814..37c614c708 100644 | |
| --- a/packages/apputils-extension/src/settingsplugin.ts | |
| +++ b/packages/apputils-extension/src/settingsplugin.ts | |
| @@ -3,10 +3,7 @@ | |
| | Distributed under the terms of the Modified BSD License. | |
| |----------------------------------------------------------------------------*/ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { PageConfig } from '@jupyterlab/coreutils'; | |
| import { | |
| ISettingConnector, | |
| @@ -25,8 +22,7 @@ export const settingsConnector: JupyterFrontEndPlugin<ISettingConnector> = { | |
| description: 'Provides the settings connector.', | |
| autoStart: true, | |
| provides: ISettingConnector, | |
| - activate: (app: JupyterFrontEnd) => | |
| - new SettingConnector(app.serviceManager.settings) | |
| + activate: (app: JupyterFrontEnd) => new SettingConnector(app.serviceManager.settings) | |
| }; | |
| /** | |
| diff --git a/packages/apputils-extension/src/shortcuts.tsx b/packages/apputils-extension/src/shortcuts.tsx | |
| index 8ee10d87fa..68c1a72f15 100644 | |
| --- a/packages/apputils-extension/src/shortcuts.tsx | |
| +++ b/packages/apputils-extension/src/shortcuts.tsx | |
| @@ -120,10 +120,7 @@ export function displayShortcuts(options: IOptions) { | |
| } | |
| // Find active keybindings for target element | |
| - const activeBindings = new Map< | |
| - string, | |
| - [number, CommandRegistry.IKeyBinding] | |
| - >(); | |
| + const activeBindings = new Map<string, [number, CommandRegistry.IKeyBinding]>(); | |
| for (let i = 0; i < commands.keyBindings.length; i++) { | |
| const kb = commands.keyBindings[i]; | |
| let distance = matchDistance(kb.selector, elt); | |
| @@ -168,17 +165,12 @@ export function displayShortcuts(options: IOptions) { | |
| key={`${b.command}-${b.keys.join('-').replace(' ', '_')}`} | |
| > | |
| <td className={SHORTCUT_TABLE_ITEM_CLASS}>{formatLabel(b)}</td> | |
| - <td className={SHORTCUT_TABLE_ITEM_CLASS}> | |
| - {formatKeys([...b.keys])} | |
| - </td> | |
| + <td className={SHORTCUT_TABLE_ITEM_CLASS}>{formatKeys([...b.keys])}</td> | |
| </tr> | |
| )) | |
| ); | |
| bindingTable.push( | |
| - <tr | |
| - className={SHORTCUT_TABLE_LAST_ROW_CLASS} | |
| - key={`group-${d}-last`} | |
| - ></tr> | |
| + <tr className={SHORTCUT_TABLE_LAST_ROW_CLASS} key={`group-${d}-last`}></tr> | |
| ); | |
| } | |
| } | |
| diff --git a/packages/apputils-extension/src/statusbarplugin.ts b/packages/apputils-extension/src/statusbarplugin.ts | |
| index d03aac90f8..85c8b066f1 100644 | |
| --- a/packages/apputils-extension/src/statusbarplugin.ts | |
| +++ b/packages/apputils-extension/src/statusbarplugin.ts | |
| @@ -3,10 +3,7 @@ | |
| | Distributed under the terms of the Modified BSD License. | |
| |----------------------------------------------------------------------------*/ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { ILabShell } from '@jupyterlab/application'; | |
| import type { ISessionContext } from '@jupyterlab/apputils'; | |
| import { | |
| @@ -41,8 +38,7 @@ export const kernelStatus: JupyterFrontEndPlugin<IKernelStatusModel> = { | |
| labShell: ILabShell | null | |
| ): IKernelStatusModel => { | |
| const translator = translator_ ?? nullTranslator; | |
| - const sessionDialogs = | |
| - sessionDialogs_ ?? new SessionContextDialogs({ translator }); | |
| + const sessionDialogs = sessionDialogs_ ?? new SessionContextDialogs({ translator }); | |
| // When the status item is clicked, launch the kernel | |
| // selection dialog for the current session. | |
| const changeKernel = async () => { | |
| @@ -52,14 +48,8 @@ export const kernelStatus: JupyterFrontEndPlugin<IKernelStatusModel> = { | |
| await sessionDialogs.selectKernel(item.model.sessionContext); | |
| }; | |
| - const changeKernelOnKeyDown = async ( | |
| - event: KeyboardEvent<HTMLImageElement> | |
| - ) => { | |
| - if ( | |
| - event.key === 'Enter' || | |
| - event.key === 'Spacebar' || | |
| - event.key === ' ' | |
| - ) { | |
| + const changeKernelOnKeyDown = async (event: KeyboardEvent<HTMLImageElement>) => { | |
| + if (event.key === 'Enter' || event.key === 'Spacebar' || event.key === ' ') { | |
| event.preventDefault(); | |
| event.stopPropagation(); | |
| return changeKernel(); | |
| @@ -155,11 +145,7 @@ export const runningSessionsStatus: JupyterFrontEndPlugin<void> = { | |
| const item = new RunningSessions({ | |
| onClick: () => app.shell.activateById('jp-running-sessions'), | |
| onKeyDown: (event: KeyboardEvent<HTMLImageElement>) => { | |
| - if ( | |
| - event.key === 'Enter' || | |
| - event.key === 'Spacebar' || | |
| - event.key === ' ' | |
| - ) { | |
| + if (event.key === 'Enter' || event.key === 'Spacebar' || event.key === ' ') { | |
| event.preventDefault(); | |
| event.stopPropagation(); | |
| app.shell.activateById('jp-running-sessions'); | |
| @@ -170,12 +156,8 @@ export const runningSessionsStatus: JupyterFrontEndPlugin<void> = { | |
| ...options | |
| }); | |
| - item.model.sessions = Array.from( | |
| - app.serviceManager.sessions.running() | |
| - ).length; | |
| - item.model.terminals = Array.from( | |
| - app.serviceManager.terminals.running() | |
| - ).length; | |
| + item.model.sessions = Array.from(app.serviceManager.sessions.running()).length; | |
| + item.model.terminals = Array.from(app.serviceManager.terminals.running()).length; | |
| return item; | |
| }; | |
| @@ -204,9 +186,8 @@ export const runningSessionsStatus: JupyterFrontEndPlugin<void> = { | |
| always: true | |
| }; | |
| const showKernels = | |
| - (kernelSettings?.get('showStatusBarItem').composite as | |
| - | boolean | |
| - | undefined) ?? true; | |
| + (kernelSettings?.get('showStatusBarItem').composite as boolean | undefined) ?? | |
| + true; | |
| const showTerminals = | |
| showTerminalsMap[ | |
| (terminalsSettings?.get('showStatusBarItem').composite as | |
| diff --git a/packages/apputils-extension/src/subshell-settings.ts b/packages/apputils-extension/src/subshell-settings.ts | |
| index a31bb1a2f1..354454daaf 100644 | |
| --- a/packages/apputils-extension/src/subshell-settings.ts | |
| +++ b/packages/apputils-extension/src/subshell-settings.ts | |
| @@ -3,10 +3,7 @@ | |
| | Distributed under the terms of the Modified BSD License. | |
| |----------------------------------------------------------------------------*/ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import type { CommsOverSubshells } from '@jupyterlab/services'; | |
| import { ISettingRegistry } from '@jupyterlab/settingregistry'; | |
| @@ -19,10 +16,7 @@ export const subshellsSettings: JupyterFrontEndPlugin<void> = { | |
| autoStart: true, | |
| requires: [], | |
| optional: [ISettingRegistry], | |
| - activate: ( | |
| - app: JupyterFrontEnd, | |
| - settingRegistry: ISettingRegistry | null | |
| - ) => { | |
| + activate: (app: JupyterFrontEnd, settingRegistry: ISettingRegistry | null) => { | |
| if (settingRegistry) { | |
| app.started | |
| .then(async () => { | |
| @@ -36,9 +30,8 @@ export const subshellsSettings: JupyterFrontEndPlugin<void> = { | |
| app.serviceManager.kernels.commsOverSubshells = commsOverSubshells; | |
| subshellsSettings.changed.connect(() => { | |
| - const commsOverSubshells = subshellsSettings.get( | |
| - 'commsOverSubshells' | |
| - ).composite as CommsOverSubshells; | |
| + const commsOverSubshells = subshellsSettings.get('commsOverSubshells') | |
| + .composite as CommsOverSubshells; | |
| app.serviceManager.kernels.commsOverSubshells = commsOverSubshells; | |
| }); | |
| }) | |
| diff --git a/packages/apputils-extension/src/themesplugins.ts b/packages/apputils-extension/src/themesplugins.ts | |
| index 9ac48667e6..e24178b331 100644 | |
| --- a/packages/apputils-extension/src/themesplugins.ts | |
| +++ b/packages/apputils-extension/src/themesplugins.ts | |
| @@ -83,9 +83,7 @@ export const themesPlugin: JupyterFrontEndPlugin<IThemeManager> = { | |
| manager.themeChanged.connect((sender, args) => { | |
| // Set data attributes on the application shell for the current theme. | |
| currentTheme = args.newValue; | |
| - document.body.dataset.jpThemeLight = String( | |
| - manager.isLight(currentTheme) | |
| - ); | |
| + document.body.dataset.jpThemeLight = String(manager.isLight(currentTheme)); | |
| document.body.dataset.jpThemeName = currentTheme; | |
| document.body.style.colorScheme = manager.isLight(currentTheme) | |
| ? 'light' | |
| @@ -106,9 +104,7 @@ export const themesPlugin: JupyterFrontEndPlugin<IThemeManager> = { | |
| } | |
| } else { | |
| if (scrollbarsStyleElement && scrollbarsStyleElement.parentElement) { | |
| - scrollbarsStyleElement.parentElement.removeChild( | |
| - scrollbarsStyleElement | |
| - ); | |
| + scrollbarsStyleElement.parentElement.removeChild(scrollbarsStyleElement); | |
| } | |
| } | |
| } | |
| @@ -123,9 +119,7 @@ export const themesPlugin: JupyterFrontEndPlugin<IThemeManager> = { | |
| } | |
| const theme = args['theme'] as string; | |
| const displayName = manager.getDisplayName(theme); | |
| - return args['isPalette'] | |
| - ? trans.__('Use Theme: %1', displayName) | |
| - : displayName; | |
| + return args['isPalette'] ? trans.__('Use Theme: %1', displayName) : displayName; | |
| }, | |
| describedBy: { | |
| args: { | |
| @@ -363,9 +357,7 @@ export const themesPlugin: JupyterFrontEndPlugin<IThemeManager> = { | |
| execute: args => manager.decrFontSize(args['key'] as string) | |
| }); | |
| - const darkModeMediaQuery = window.matchMedia( | |
| - '(prefers-color-scheme: dark)' | |
| - ); | |
| + const darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)'); | |
| const syncThemeOnSystemChange = (event: MediaQueryListEvent) => { | |
| // Only act if the "Synchronize with System Settings" option is enabled. | |
| diff --git a/packages/apputils-extension/src/toolbarregistryplugin.ts b/packages/apputils-extension/src/toolbarregistryplugin.ts | |
| index 7c3e65d128..059c815dd1 100644 | |
| --- a/packages/apputils-extension/src/toolbarregistryplugin.ts | |
| +++ b/packages/apputils-extension/src/toolbarregistryplugin.ts | |
| @@ -3,10 +3,7 @@ | |
| * Distributed under the terms of the Modified BSD License. | |
| */ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { | |
| createDefaultFactory, | |
| IToolbarWidgetRegistry, | |
| diff --git a/packages/apputils-extension/src/workspacesplugin.ts b/packages/apputils-extension/src/workspacesplugin.ts | |
| index 0f3f369661..e531d95535 100644 | |
| --- a/packages/apputils-extension/src/workspacesplugin.ts | |
| +++ b/packages/apputils-extension/src/workspacesplugin.ts | |
| @@ -4,10 +4,7 @@ | |
| import type { JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { IRouter, JupyterFrontEnd } from '@jupyterlab/application'; | |
| import { URLExt } from '@jupyterlab/coreutils'; | |
| -import type { | |
| - DocumentRegistry, | |
| - IDocumentWidget | |
| -} from '@jupyterlab/docregistry'; | |
| +import type { DocumentRegistry, IDocumentWidget } from '@jupyterlab/docregistry'; | |
| import { ABCWidgetFactory, DocumentWidget } from '@jupyterlab/docregistry'; | |
| import type { Workspace, WorkspaceManager } from '@jupyterlab/services'; | |
| import { IStateDB } from '@jupyterlab/statedb'; | |
| @@ -102,9 +99,7 @@ namespace Private { | |
| * Loads the workspace into load, and jump to it | |
| * @param context This is used to query the workspace content | |
| */ | |
| - protected createNewWidget( | |
| - context: DocumentRegistry.Context | |
| - ): IDocumentWidget { | |
| + protected createNewWidget(context: DocumentRegistry.Context): IDocumentWidget { | |
| // Save a file's contents as a workspace and navigate to that workspace. | |
| void context.ready.then(async () => { | |
| const file = context.model; | |
| diff --git a/packages/apputils-extension/style/scrollbar.raw.css b/packages/apputils-extension/style/scrollbar.raw.css | |
| index 54d343f310..48351e95dd 100644 | |
| --- a/packages/apputils-extension/style/scrollbar.raw.css | |
| +++ b/packages/apputils-extension/style/scrollbar.raw.css | |
| @@ -23,17 +23,13 @@ | |
| } | |
| ::-webkit-scrollbar-track:horizontal { | |
| - border-left: var(--jp-scrollbar-endpad) solid | |
| - var(--jp-scrollbar-background-color); | |
| - border-right: var(--jp-scrollbar-endpad) solid | |
| - var(--jp-scrollbar-background-color); | |
| + border-left: var(--jp-scrollbar-endpad) solid var(--jp-scrollbar-background-color); | |
| + border-right: var(--jp-scrollbar-endpad) solid var(--jp-scrollbar-background-color); | |
| } | |
| ::-webkit-scrollbar-track:vertical { | |
| - border-top: var(--jp-scrollbar-endpad) solid | |
| - var(--jp-scrollbar-background-color); | |
| - border-bottom: var(--jp-scrollbar-endpad) solid | |
| - var(--jp-scrollbar-background-color); | |
| + border-top: var(--jp-scrollbar-endpad) solid var(--jp-scrollbar-background-color); | |
| + border-bottom: var(--jp-scrollbar-endpad) solid var(--jp-scrollbar-background-color); | |
| } | |
| /* for code nodes, use a transparent style of scrollbar */ | |
| diff --git a/packages/apputils-extension/test/palette.spec.ts b/packages/apputils-extension/test/palette.spec.ts | |
| index 4bfb1e5040..e20a157863 100644 | |
| --- a/packages/apputils-extension/test/palette.spec.ts | |
| +++ b/packages/apputils-extension/test/palette.spec.ts | |
| @@ -21,9 +21,7 @@ describe('Palette', () => { | |
| Palette.activate(app as JupyterFrontEnd, nullTranslator, settingRegistry); | |
| const node = document.getElementById('command-palette')!; | |
| - expect(node.getAttribute('aria-label')).toEqual( | |
| - 'Command Palette Section' | |
| - ); | |
| + expect(node.getAttribute('aria-label')).toEqual('Command Palette Section'); | |
| expect(node.getAttribute('role')).toEqual('region'); | |
| }); | |
| }); | |
| diff --git a/packages/apputils/src/commandpalette.ts b/packages/apputils/src/commandpalette.ts | |
| index 6502c2054e..2158e1fcf6 100644 | |
| --- a/packages/apputils/src/commandpalette.ts | |
| +++ b/packages/apputils/src/commandpalette.ts | |
| @@ -83,9 +83,7 @@ export class ModalCommandPalette extends Panel { | |
| // focus went away from child element | |
| this.node.contains(event.target as HTMLElement) && | |
| // and it did NOT go to another child element but someplace else | |
| - !this.node.contains( | |
| - (event as MouseEvent).relatedTarget as HTMLElement | |
| - ) | |
| + !this.node.contains((event as MouseEvent).relatedTarget as HTMLElement) | |
| ) { | |
| event.stopPropagation(); | |
| this.hideAndReset(); | |
| diff --git a/packages/apputils/src/dialog.tsx b/packages/apputils/src/dialog.tsx | |
| index bbf6ae7524..6a9282d25c 100644 | |
| --- a/packages/apputils/src/dialog.tsx | |
| +++ b/packages/apputils/src/dialog.tsx | |
| @@ -510,8 +510,7 @@ export class Dialog<T> extends Widget { | |
| promise.resolve({ | |
| button, | |
| isChecked: | |
| - this._checkboxNode?.querySelector<HTMLInputElement>('input')?.checked ?? | |
| - null, | |
| + this._checkboxNode?.querySelector<HTMLInputElement>('input')?.checked ?? null, | |
| value | |
| }); | |
| } | |
| @@ -814,9 +813,7 @@ export namespace Dialog { | |
| /** | |
| * Create a reject button. | |
| */ | |
| - export function cancelButton( | |
| - options: Partial<IButton> = {} | |
| - ): Readonly<IButton> { | |
| + export function cancelButton(options: Partial<IButton> = {}): Readonly<IButton> { | |
| options.accept = false; | |
| return createButton(options); | |
| } | |
| @@ -832,9 +829,7 @@ export namespace Dialog { | |
| /** | |
| * Create a warn button. | |
| */ | |
| - export function warnButton( | |
| - options: Partial<IButton> = {} | |
| - ): Readonly<IButton> { | |
| + export function warnButton(options: Partial<IButton> = {}): Readonly<IButton> { | |
| options.displayType = 'warn'; | |
| return createButton(options); | |
| } | |
| @@ -1136,10 +1131,7 @@ namespace Private { | |
| export function handleOptions<T>( | |
| options: Partial<Dialog.IOptions<T>> = {} | |
| ): Dialog.IOptions<T> { | |
| - const buttons = options.buttons ?? [ | |
| - Dialog.cancelButton(), | |
| - Dialog.okButton() | |
| - ]; | |
| + const buttons = options.buttons ?? [Dialog.cancelButton(), Dialog.okButton()]; | |
| return { | |
| title: options.title ?? '', | |
| body: options.body ?? '', | |
| diff --git a/packages/apputils/src/domutils.ts b/packages/apputils/src/domutils.ts | |
| index 5fc74fcd78..e211303226 100644 | |
| --- a/packages/apputils/src/domutils.ts | |
| +++ b/packages/apputils/src/domutils.ts | |
| @@ -26,10 +26,7 @@ export namespace DOMUtils { | |
| * Find the first element matching a class name. | |
| * Only use this function when the element existence is guaranteed. | |
| */ | |
| - export function findElement( | |
| - parent: HTMLElement, | |
| - className: string | |
| - ): HTMLElement { | |
| + export function findElement(parent: HTMLElement, className: string): HTMLElement { | |
| return parent.querySelector(`.${className}`) as HTMLElement; | |
| } | |
| @@ -40,9 +37,7 @@ export namespace DOMUtils { | |
| parent: HTMLElement, | |
| className: string | |
| ): HTMLCollectionOf<HTMLElement> { | |
| - return parent.getElementsByClassName( | |
| - className | |
| - ) as HTMLCollectionOf<HTMLElement>; | |
| + return parent.getElementsByClassName(className) as HTMLCollectionOf<HTMLElement>; | |
| } | |
| /** | |
| diff --git a/packages/apputils/src/inputdialog.ts b/packages/apputils/src/inputdialog.ts | |
| index a0181d9f87..860b70204a 100644 | |
| --- a/packages/apputils/src/inputdialog.ts | |
| +++ b/packages/apputils/src/inputdialog.ts | |
| @@ -102,9 +102,7 @@ export namespace InputDialog { | |
| * | |
| * @returns A promise that resolves with whether the dialog was accepted | |
| */ | |
| - export function getNumber( | |
| - options: INumberOptions | |
| - ): Promise<Dialog.IResult<number>> { | |
| + export function getNumber(options: INumberOptions): Promise<Dialog.IResult<number>> { | |
| return showDialog({ | |
| ...options, | |
| body: new InputNumberDialog(options), | |
| @@ -148,9 +146,7 @@ export namespace InputDialog { | |
| * | |
| * @returns A promise that resolves with whether the dialog was accepted | |
| */ | |
| - export function getItem( | |
| - options: IItemOptions | |
| - ): Promise<Dialog.IResult<string>> { | |
| + export function getItem(options: IItemOptions): Promise<Dialog.IResult<string>> { | |
| return showDialog({ | |
| ...options, | |
| body: new InputItemsDialog(options), | |
| @@ -232,9 +228,7 @@ export namespace InputDialog { | |
| * | |
| * @returns A promise that resolves with whether the dialog was accepted | |
| */ | |
| - export function getText( | |
| - options: ITextOptions | |
| - ): Promise<Dialog.IResult<string>> { | |
| + export function getText(options: ITextOptions): Promise<Dialog.IResult<string>> { | |
| return showDialog({ | |
| ...options, | |
| body: new InputTextDialog(options), | |
| diff --git a/packages/apputils/src/kernelstatuses.tsx b/packages/apputils/src/kernelstatuses.tsx | |
| index ffddf855e7..b07c4fb77a 100644 | |
| --- a/packages/apputils/src/kernelstatuses.tsx | |
| +++ b/packages/apputils/src/kernelstatuses.tsx | |
| @@ -175,9 +175,7 @@ export namespace KernelStatus { | |
| * The current status of the kernel. | |
| */ | |
| get status(): string | undefined { | |
| - return this._kernelStatus | |
| - ? this._statusNames[this._kernelStatus] | |
| - : undefined; | |
| + return this._kernelStatus ? this._statusNames[this._kernelStatus] : undefined; | |
| } | |
| /** | |
| @@ -202,18 +200,12 @@ export namespace KernelStatus { | |
| return this._sessionContext; | |
| } | |
| set sessionContext(sessionContext: ISessionContext | null) { | |
| - this._sessionContext?.statusChanged.disconnect( | |
| - this._onKernelStatusChanged, | |
| - this | |
| - ); | |
| + this._sessionContext?.statusChanged.disconnect(this._onKernelStatusChanged, this); | |
| this._sessionContext?.connectionStatusChanged.disconnect( | |
| this._onKernelStatusChanged, | |
| this | |
| ); | |
| - this._sessionContext?.kernelChanged.disconnect( | |
| - this._onKernelChanged, | |
| - this | |
| - ); | |
| + this._sessionContext?.kernelChanged.disconnect(this._onKernelChanged, this); | |
| const oldState = this._getAllState(); | |
| this._sessionContext = sessionContext; | |
| @@ -268,10 +260,7 @@ export namespace KernelStatus { | |
| private _kernelName: string = ''; | |
| private _kernelStatus: ISessionContext.KernelDisplayStatus | undefined = ''; | |
| private _sessionContext: ISessionContext | null = null; | |
| - private readonly _statusNames: Record< | |
| - ISessionContext.KernelDisplayStatus, | |
| - string | |
| - >; | |
| + private readonly _statusNames: Record<ISessionContext.KernelDisplayStatus, string>; | |
| } | |
| /** | |
| diff --git a/packages/apputils/src/licenses.tsx b/packages/apputils/src/licenses.tsx | |
| index 9d269ad07c..64fef938ef 100644 | |
| --- a/packages/apputils/src/licenses.tsx | |
| +++ b/packages/apputils/src/licenses.tsx | |
| @@ -308,8 +308,7 @@ export namespace Licenses { | |
| */ | |
| constructor(options: ILicenseClientOptions = {}) { | |
| this._preferredLicensesUrl = options.licensesUrl; | |
| - this._serverSettings = | |
| - options.serverSettings ?? ServerConnection.makeSettings(); | |
| + this._serverSettings = options.serverSettings ?? ServerConnection.makeSettings(); | |
| } | |
| /** | |
| @@ -347,10 +346,8 @@ export namespace Licenses { | |
| private get _licensesUrl(): string { | |
| return ( | |
| this._preferredLicensesUrl ?? | |
| - URLExt.join( | |
| - this._serverSettings.baseUrl, | |
| - PageConfig.getOption('licensesUrl') | |
| - ) + '/' | |
| + URLExt.join(this._serverSettings.baseUrl, PageConfig.getOption('licensesUrl')) + | |
| + '/' | |
| ); | |
| } | |
| @@ -480,11 +477,7 @@ export namespace Licenses { | |
| * The license data for the currently-selected package | |
| */ | |
| get currentPackage(): IPackageLicenseInfo | null { | |
| - if ( | |
| - this.currentBundleName && | |
| - this.bundles && | |
| - this._currentPackageIndex != null | |
| - ) { | |
| + if (this.currentBundleName && this.bundles && this._currentPackageIndex != null) { | |
| return this.getFilteredPackages( | |
| this.bundles[this.currentBundleName]?.packages || [] | |
| )[this._currentPackageIndex]; | |
| @@ -619,9 +612,7 @@ export namespace Licenses { | |
| /** | |
| * Handle a filter input changing | |
| */ | |
| - protected onFilterInput = ( | |
| - evt: React.ChangeEvent<HTMLInputElement> | |
| - ): void => { | |
| + protected onFilterInput = (evt: React.ChangeEvent<HTMLInputElement>): void => { | |
| const input = evt.currentTarget; | |
| const { name, value } = input; | |
| this.model.packageFilter = { ...this.model.packageFilter, [name]: value }; | |
| @@ -690,9 +681,7 @@ export namespace Licenses { | |
| protected render(): JSX.Element { | |
| const { bundles, currentBundleName, trans } = this.model; | |
| const filteredPackages = this.model.getFilteredPackages( | |
| - bundles && currentBundleName | |
| - ? bundles[currentBundleName]?.packages || [] | |
| - : [] | |
| + bundles && currentBundleName ? bundles[currentBundleName]?.packages || [] : [] | |
| ); | |
| if (!filteredPackages.length) { | |
| return ( | |
| diff --git a/packages/apputils/src/notification.ts b/packages/apputils/src/notification.ts | |
| index f7ba94683f..cafc5ef33c 100644 | |
| --- a/packages/apputils/src/notification.ts | |
| +++ b/packages/apputils/src/notification.ts | |
| @@ -123,9 +123,7 @@ export class NotificationManager implements IDisposable { | |
| // By default notification will be silent | |
| autoClose: 0, | |
| progress: | |
| - typeof progress === 'number' | |
| - ? Math.min(Math.max(0, progress), 1) | |
| - : progress, | |
| + typeof progress === 'number' ? Math.min(Math.max(0, progress), 1) : progress, | |
| ...othersOptions | |
| } | |
| }); | |
| @@ -156,9 +154,7 @@ export class NotificationManager implements IDisposable { | |
| ): boolean { | |
| const { id, message, actions, autoClose, data, progress, type } = args; | |
| const newProgress = | |
| - typeof progress === 'number' | |
| - ? Math.min(Math.max(0, progress), 1) | |
| - : progress; | |
| + typeof progress === 'number' ? Math.min(Math.max(0, progress), 1) : progress; | |
| const notificationIndex = this._queue.findIndex(n => n.id === id); | |
| if (notificationIndex > -1) { | |
| const oldNotification = this._queue[notificationIndex]; | |
| @@ -242,9 +238,7 @@ export namespace Notification { | |
| /** | |
| * Notification interface | |
| */ | |
| - export interface INotification< | |
| - T extends ReadonlyJSONValue = ReadonlyJSONValue | |
| - > { | |
| + export interface INotification<T extends ReadonlyJSONValue = ReadonlyJSONValue> { | |
| /** | |
| * Notification unique identifier | |
| */ | |
| diff --git a/packages/apputils/src/printing.ts b/packages/apputils/src/printing.ts | |
| index 59a105553c..b593ac97e9 100644 | |
| --- a/packages/apputils/src/printing.ts | |
| +++ b/packages/apputils/src/printing.ts | |
| @@ -77,9 +77,7 @@ export namespace Printing { | |
| serverSettings?: ServerConnection.ISettings | |
| ): Promise<void> { | |
| const settings = serverSettings ?? ServerConnection.makeSettings(); | |
| - const text = await ( | |
| - await ServerConnection.makeRequest(url, {}, settings) | |
| - ).text(); | |
| + const text = await (await ServerConnection.makeRequest(url, {}, settings)).text(); | |
| return printContent(text); | |
| } | |
| diff --git a/packages/apputils/src/sanitizer.ts b/packages/apputils/src/sanitizer.ts | |
| index b2e70fa80a..6d52032da7 100644 | |
| --- a/packages/apputils/src/sanitizer.ts | |
| +++ b/packages/apputils/src/sanitizer.ts | |
| @@ -461,9 +461,7 @@ class CssProp { | |
| static BORDER_LEFT_COLOR = CssProp.reg(CssProp.CP.border_left_color); | |
| static BORDER_RIGHT_COLOR = CssProp.reg(CssProp.CP.border_right_color); | |
| static BORDER_STYLE = CssProp.reg(CssProp.CP.border_style); | |
| - static BORDER_TOP_LEFT_RADIUS = CssProp.reg( | |
| - CssProp.CP.border_top_left_radius | |
| - ); | |
| + static BORDER_TOP_LEFT_RADIUS = CssProp.reg(CssProp.CP.border_top_left_radius); | |
| static BORDER_TOP_WIDTH = CssProp.reg(CssProp.CP.border_top_width); | |
| static BOX_SHADOW = CssProp.reg(CssProp.CP.box_shadow); | |
| static CLIP = CssProp.reg(CssProp.CP.clip); | |
| @@ -483,9 +481,7 @@ class CssProp { | |
| static Z_INDEX = CssProp.reg(CssProp.CP.z_index); | |
| static BACKGROUND = CssProp.reg(CssProp.CP.background); | |
| static BACKGROUND_SIZE = CssProp.reg(CssProp.CP.background_size); | |
| - static BORDER_BOTTOM_LEFT_RADIUS = CssProp.reg( | |
| - CssProp.CP.border_bottom_left_radius | |
| - ); | |
| + static BORDER_BOTTOM_LEFT_RADIUS = CssProp.reg(CssProp.CP.border_bottom_left_radius); | |
| static BORDER_BOTTOM_WIDTH = CssProp.reg(CssProp.CP.border_bottom_width); | |
| static BORDER_LEFT_STYLE = CssProp.reg(CssProp.CP.border_left_style); | |
| static BORDER_RIGHT_STYLE = CssProp.reg(CssProp.CP.border_right_style); | |
| @@ -516,9 +512,7 @@ class CssProp { | |
| static BORDER_LEFT = CssProp.reg(CssProp.CP.border_left); | |
| static FONT = CssProp.reg(CssProp.CP.font); | |
| static QUOTES = CssProp.reg(CssProp.CP.quotes); | |
| - static BORDER_TOP_RIGHT_RADIUS = CssProp.reg( | |
| - CssProp.CP.border_top_right_radius | |
| - ); | |
| + static BORDER_TOP_RIGHT_RADIUS = CssProp.reg(CssProp.CP.border_top_right_radius); | |
| static MIN_WIDTH = CssProp.reg(CssProp.CP.min_width); | |
| // Flexbox properties | |
| @@ -776,15 +770,7 @@ export class Sanitizer implements IRenderMime.ISanitizer { | |
| 'target', | |
| 'type' | |
| ], | |
| - area: [ | |
| - 'accesskey', | |
| - 'alt', | |
| - 'coords', | |
| - 'href', | |
| - 'nohref', | |
| - 'shape', | |
| - 'tabindex' | |
| - ], | |
| + area: ['accesskey', 'alt', 'coords', 'href', 'nohref', 'shape', 'tabindex'], | |
| // 'autoplay' was *not* allowed by Google Caja | |
| audio: [ | |
| 'autoplay', | |
| diff --git a/packages/apputils/src/sessioncontext.tsx b/packages/apputils/src/sessioncontext.tsx | |
| index 26370aa9db..5f00494508 100644 | |
| --- a/packages/apputils/src/sessioncontext.tsx | |
| +++ b/packages/apputils/src/sessioncontext.tsx | |
| @@ -421,10 +421,7 @@ export class SessionContext implements ISessionContext { | |
| /** | |
| * A signal emitted when the kernel connection changes, proxied from the session connection. | |
| */ | |
| - get kernelChanged(): ISignal< | |
| - this, | |
| - Session.ISessionConnection.IKernelChangedArgs | |
| - > { | |
| + get kernelChanged(): ISignal<this, Session.ISessionConnection.IKernelChangedArgs> { | |
| return this._kernelChanged; | |
| } | |
| @@ -583,16 +580,15 @@ export class SessionContext implements ISessionContext { | |
| if (this._pendingKernelName) { | |
| return ( | |
| - this.specsManager.specs?.kernelspecs[this._pendingKernelName] | |
| - ?.display_name ?? this._pendingKernelName | |
| + this.specsManager.specs?.kernelspecs[this._pendingKernelName]?.display_name ?? | |
| + this._pendingKernelName | |
| ); | |
| } | |
| if (!kernel) { | |
| return this.noKernelName; | |
| } | |
| return ( | |
| - this.specsManager.specs?.kernelspecs[kernel.name]?.display_name ?? | |
| - kernel.name | |
| + this.specsManager.specs?.kernelspecs[kernel.name]?.display_name ?? kernel.name | |
| ); | |
| } | |
| @@ -1013,10 +1009,7 @@ export class SessionContext implements ISessionContext { | |
| session.propertyChanged.connect(this._onPropertyChanged, this); | |
| session.kernelChanged.connect(this._onKernelChanged, this); | |
| session.statusChanged.connect(this._onStatusChanged, this); | |
| - session.connectionStatusChanged.connect( | |
| - this._onConnectionStatusChanged, | |
| - this | |
| - ); | |
| + session.connectionStatusChanged.connect(this._onConnectionStatusChanged, this); | |
| session.pendingInput.connect(this._onPendingInput, this); | |
| session.iopubMessage.connect(this._onIopubMessage, this); | |
| session.unhandledMessage.connect(this._onUnhandledMessage, this); | |
| @@ -1185,10 +1178,7 @@ export class SessionContext implements ISessionContext { | |
| /** | |
| * Handle a change to the pending input. | |
| */ | |
| - private _onPendingInput( | |
| - sender: Session.ISessionConnection, | |
| - value: boolean | |
| - ): void { | |
| + private _onPendingInput(sender: Session.ISessionConnection, value: boolean): void { | |
| // Set the signal value | |
| this._pendingInput = value; | |
| } | |
| @@ -1248,9 +1238,7 @@ export class SessionContext implements ISessionContext { | |
| > | |
| >(this); | |
| private _statusChanged = new Signal<this, Kernel.Status>(this); | |
| - private _connectionStatusChanged = new Signal<this, Kernel.ConnectionStatus>( | |
| - this | |
| - ); | |
| + private _connectionStatusChanged = new Signal<this, Kernel.ConnectionStatus>(this); | |
| private translator: ITranslator; | |
| private _trans: TranslationBundle; | |
| private _pendingInput = false; | |
| @@ -1471,10 +1459,7 @@ export class SessionContextDialogs implements ISessionContext.IDialogs { | |
| const skipKernelRestartDialog = | |
| sessionContext.kernelPreference?.skipKernelRestartDialog ?? false; | |
| const skipKernelRestartDialogSetting = ( | |
| - await this._settingRegistry?.get( | |
| - kernelPluginId, | |
| - 'skipKernelRestartDialog' | |
| - ) | |
| + await this._settingRegistry?.get(kernelPluginId, 'skipKernelRestartDialog') | |
| )?.composite as boolean; | |
| if (skipKernelRestartDialogSetting || skipKernelRestartDialog) { | |
| await sessionContext.restartKernel(); | |
| @@ -1616,9 +1601,7 @@ export namespace SessionContextDialogs { | |
| .filter(session => !!session.kernel) | |
| .map(session => session.kernel!) | |
| ); | |
| - const sessions = Array.from( | |
| - sessionContext.sessionManager.running() ?? [] | |
| - ).reduce( | |
| + const sessions = Array.from(sessionContext.sessionManager.running() ?? []).reduce( | |
| (sessions, session) => { | |
| if (session.kernel?.id) sessions[session.kernel.id] = session; | |
| return sessions; | |
| @@ -1746,13 +1729,11 @@ export namespace SessionContextDialogs { | |
| })) | |
| .sort((a, b) => a.option.text.localeCompare(b.option.text)) | |
| .forEach(kernel => | |
| - (language === kernel.language | |
| - ? preferredRunning | |
| - : otherRunning | |
| - ).options.push(kernel.option) | |
| + (language === kernel.language ? preferredRunning : otherRunning).options.push( | |
| + kernel.option | |
| + ) | |
| ); | |
| - if (preferredRunning.options.length) | |
| - options.groups.push(preferredRunning); | |
| + if (preferredRunning.options.length) options.groups.push(preferredRunning); | |
| if (otherRunning.options.length) options.groups.push(otherRunning); | |
| } else { | |
| // Add kernelspecs first. | |
| @@ -1793,8 +1774,7 @@ export namespace SessionContextDialogs { | |
| } | |
| if (currentKernelDisplayName) { | |
| if ( | |
| - currentKernelDisplayName === | |
| - specs.kernelspecs[choice.name]?.display_name | |
| + currentKernelDisplayName === specs.kernelspecs[choice.name]?.display_name | |
| ) { | |
| option.selected = true; | |
| return options; | |
| @@ -1861,10 +1841,7 @@ namespace Private { | |
| body.appendChild(text); | |
| const select = document.createElement('select'); | |
| - const options = SessionContextDialogs.kernelOptions( | |
| - sessionContext, | |
| - translator | |
| - ); | |
| + const options = SessionContextDialogs.kernelOptions(sessionContext, translator); | |
| if (options.disabled) select.disabled = true; | |
| for (const group of options.groups) { | |
| const { label, options } = group; | |
| diff --git a/packages/apputils/src/thememanager.ts b/packages/apputils/src/thememanager.ts | |
| index e68e292aa3..e596065c0e 100644 | |
| --- a/packages/apputils/src/thememanager.ts | |
| +++ b/packages/apputils/src/thememanager.ts | |
| @@ -127,8 +127,7 @@ export class ThemeManager implements IThemeManager { | |
| */ | |
| isSystemColorSchemeDark(): boolean { | |
| return ( | |
| - window.matchMedia && | |
| - window.matchMedia('(prefers-color-scheme: dark)').matches | |
| + window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches | |
| ); | |
| } | |
| @@ -146,8 +145,7 @@ export class ThemeManager implements IThemeManager { | |
| val = isLight ? val.light : val.dark; | |
| } | |
| return ( | |
| - val ?? | |
| - getComputedStyle(document.documentElement).getPropertyValue(`--jp-${key}`) | |
| + val ?? getComputedStyle(document.documentElement).getPropertyValue(`--jp-${key}`) | |
| ); | |
| } | |
| @@ -185,8 +183,7 @@ export class ThemeManager implements IThemeManager { | |
| */ | |
| loadCSSOverrides(): void { | |
| const newOverrides = | |
| - (this._settings.user['overrides'] as Dict<string | ThemedProp<string>>) ?? | |
| - {}; | |
| + (this._settings.user['overrides'] as Dict<string | ThemedProp<string>>) ?? {}; | |
| // iterate over the union of current and new CSS override keys | |
| Object.keys({ ...this._overrides, ...newOverrides }).forEach(key => { | |
| @@ -475,11 +472,7 @@ export class ThemeManager implements IThemeManager { | |
| if (!themes[fallback]) { | |
| this._onError( | |
| - this._trans.__( | |
| - 'Neither theme %1 nor default %2 loaded.', | |
| - theme, | |
| - fallback | |
| - ) | |
| + this._trans.__('Neither theme %1 nor default %2 loaded.', theme, fallback) | |
| ); | |
| return; | |
| } | |
| @@ -583,9 +576,7 @@ export class ThemeManager implements IThemeManager { | |
| private _settings: ISettingRegistry.ISettings; | |
| private _splash: ISplashScreen | null; | |
| private _themes: { [key: string]: IThemeManager.ITheme } = {}; | |
| - private _themeChanged = new Signal<this, IChangedArgs<string, string | null>>( | |
| - this | |
| - ); | |
| + private _themeChanged = new Signal<this, IChangedArgs<string, string | null>>(this); | |
| } | |
| export namespace ThemeManager { | |
| diff --git a/packages/apputils/src/toolbar/factory.ts b/packages/apputils/src/toolbar/factory.ts | |
| index 0d48de3e25..4159154b2d 100644 | |
| --- a/packages/apputils/src/toolbar/factory.ts | |
| +++ b/packages/apputils/src/toolbar/factory.ts | |
| @@ -37,10 +37,7 @@ async function displayInformation(trans: TranslationBundle): Promise<void> { | |
| body: trans.__( | |
| 'Toolbar customization has changed. You will need to reload JupyterLab to see the changes.' | |
| ), | |
| - buttons: [ | |
| - Dialog.cancelButton(), | |
| - Dialog.okButton({ label: trans.__('Reload') }) | |
| - ] | |
| + buttons: [Dialog.cancelButton(), Dialog.okButton({ label: trans.__('Reload') })] | |
| }); | |
| if (result.button.accept) { | |
| @@ -91,9 +88,7 @@ async function setToolbarItems( | |
| .filter(plugin => plugin !== pluginId) | |
| .map(plugin => { | |
| const items = | |
| - (registry.plugins[plugin]!.schema[TOOLBAR_KEY] ?? {})[ | |
| - factoryName | |
| - ] ?? []; | |
| + (registry.plugins[plugin]!.schema[TOOLBAR_KEY] ?? {})[factoryName] ?? []; | |
| loaded[plugin] = items; | |
| return items; | |
| }) | |
| @@ -106,16 +101,14 @@ async function setToolbarItems( | |
| // Apply default value as last step to take into account overrides.json | |
| // The standard toolbars default is [] as the plugin must use | |
| // `jupyter.lab.toolbars.<factory>` to define its default value. | |
| - schema.properties![propertyId].default = | |
| - SettingRegistry.reconcileToolbarItems( | |
| - pluginDefaults, | |
| - schema.properties![propertyId].default as any[], | |
| - true | |
| - )!.sort( | |
| - (a, b) => | |
| - (a.rank ?? DEFAULT_TOOLBAR_ITEM_RANK) - | |
| - (b.rank ?? DEFAULT_TOOLBAR_ITEM_RANK) | |
| - ); | |
| + schema.properties![propertyId].default = SettingRegistry.reconcileToolbarItems( | |
| + pluginDefaults, | |
| + schema.properties![propertyId].default as any[], | |
| + true | |
| + )!.sort( | |
| + (a, b) => | |
| + (a.rank ?? DEFAULT_TOOLBAR_ITEM_RANK) - (b.rank ?? DEFAULT_TOOLBAR_ITEM_RANK) | |
| + ); | |
| } | |
| // Transform the plugin object to return different schema than the default. | |
| @@ -127,15 +120,13 @@ async function setToolbarItems( | |
| populate(canonical); | |
| } | |
| - const defaults = | |
| - ((canonical.properties ?? {})[propertyId] ?? {}).default ?? []; | |
| + const defaults = ((canonical.properties ?? {})[propertyId] ?? {}).default ?? []; | |
| // Initialize the settings | |
| const user: PartialJSONObject = plugin.data.user; | |
| const composite: PartialJSONObject = plugin.data.composite; | |
| // Overrides the value with using the aggregated default for the toolbar property | |
| user[propertyId] = | |
| - (plugin.data.user[propertyId] as ISettingRegistry.IToolbarItem[]) ?? | |
| - []; | |
| + (plugin.data.user[propertyId] as ISettingRegistry.IToolbarItem[]) ?? []; | |
| composite[propertyId] = ( | |
| SettingRegistry.reconcileToolbarItems( | |
| defaults as ISettingRegistry.IToolbarItem[], | |
| @@ -309,13 +300,8 @@ export function createToolbarFactory( | |
| } | |
| }; | |
| - const updateWidget = ( | |
| - registry: IToolbarWidgetRegistry, | |
| - itemName: string | |
| - ) => { | |
| - const itemIndex = Array.from(items).findIndex( | |
| - item => item.name === itemName | |
| - ); | |
| + const updateWidget = (registry: IToolbarWidgetRegistry, itemName: string) => { | |
| + const itemIndex = Array.from(items).findIndex(item => item.name === itemName); | |
| if (itemIndex >= 0) { | |
| toolbar.set(itemIndex, { | |
| name: itemName, | |
| @@ -362,9 +348,7 @@ export function setToolbar( | |
| widget: Toolbar.IWidgetToolbar | Widget, | |
| factory: ( | |
| widget: Widget | |
| - ) => | |
| - | IObservableList<ToolbarRegistry.IToolbarItem> | |
| - | ToolbarRegistry.IToolbarItem[], | |
| + ) => IObservableList<ToolbarRegistry.IToolbarItem> | ToolbarRegistry.IToolbarItem[], | |
| toolbar?: Toolbar | |
| ): void { | |
| // @ts-expect-error Widget has no toolbar | |
| @@ -392,11 +376,7 @@ export function setToolbar( | |
| switch (changes.type) { | |
| case 'add': | |
| changes.newValues.forEach((item, index) => { | |
| - toolbar_.insertItem( | |
| - changes.newIndex + index, | |
| - item.name, | |
| - item.widget | |
| - ); | |
| + toolbar_.insertItem(changes.newIndex + index, item.name, item.widget); | |
| }); | |
| break; | |
| case 'move': | |
| @@ -404,11 +384,7 @@ export function setToolbar( | |
| item.widget.parent = null; | |
| }); | |
| changes.newValues.forEach((item, index) => { | |
| - toolbar_.insertItem( | |
| - changes.newIndex + index, | |
| - item.name, | |
| - item.widget | |
| - ); | |
| + toolbar_.insertItem(changes.newIndex + index, item.name, item.widget); | |
| }); | |
| break; | |
| case 'remove': | |
| @@ -430,11 +406,7 @@ export function setToolbar( | |
| Array.from(toolbar_.children())[existingIndex].parent = null; | |
| } | |
| - toolbar_.insertItem( | |
| - changes.newIndex + index, | |
| - item.name, | |
| - item.widget | |
| - ); | |
| + toolbar_.insertItem(changes.newIndex + index, item.name, item.widget); | |
| }); | |
| break; | |
| case 'clear': | |
| diff --git a/packages/apputils/src/toolbar/registry.ts b/packages/apputils/src/toolbar/registry.ts | |
| index fb9c666fa6..f95314d3f1 100644 | |
| --- a/packages/apputils/src/toolbar/registry.ts | |
| +++ b/packages/apputils/src/toolbar/registry.ts | |
| @@ -3,11 +3,7 @@ | |
| * Distributed under the terms of the Modified BSD License. | |
| */ | |
| -import { | |
| - CommandToolbarButton, | |
| - LabIcon, | |
| - Toolbar | |
| -} from '@jupyterlab/ui-components'; | |
| +import { CommandToolbarButton, LabIcon, Toolbar } from '@jupyterlab/ui-components'; | |
| import type { CommandRegistry } from '@lumino/commands'; | |
| import { Widget } from '@lumino/widgets'; | |
| import type { IToolbarWidgetRegistry, ToolbarRegistry } from '../tokens'; | |
| @@ -115,8 +111,10 @@ export class ToolbarWidgetRegistry implements IToolbarWidgetRegistry { | |
| widget: Widget, | |
| toolbarItem: ToolbarRegistry.IWidget | |
| ) => Widget; | |
| - protected _widgets: Map<string, Map<string, (main: Widget) => Widget>> = | |
| - new Map<string, Map<string, (main: Widget) => Widget>>(); | |
| + protected _widgets: Map<string, Map<string, (main: Widget) => Widget>> = new Map< | |
| + string, | |
| + Map<string, (main: Widget) => Widget> | |
| + >(); | |
| protected _factoryAdded = new Signal<this, string>(this); | |
| } | |
| @@ -155,8 +153,7 @@ export function createDefaultFactory( | |
| // If there is an icon, undefined label will results in no label | |
| // otherwise the label will be set using the setting or the command label | |
| - const label = | |
| - (icon ?? commands.icon(id, args)) ? (tLabel ?? '') : tLabel; | |
| + const label = (icon ?? commands.icon(id, args)) ? (tLabel ?? '') : tLabel; | |
| return new CommandToolbarButton({ | |
| commands, | |
| id, | |
| diff --git a/packages/apputils/src/toolbar/widget.tsx b/packages/apputils/src/toolbar/widget.tsx | |
| index 0e9d8a3078..4bc8528bc2 100644 | |
| --- a/packages/apputils/src/toolbar/widget.tsx | |
| +++ b/packages/apputils/src/toolbar/widget.tsx | |
| @@ -146,9 +146,7 @@ namespace Private { | |
| * session for changes. | |
| */ | |
| - export function KernelNameComponent( | |
| - props: KernelNameComponent.IProps | |
| - ): JSX.Element { | |
| + export function KernelNameComponent(props: KernelNameComponent.IProps): JSX.Element { | |
| const translator = props.translator || nullTranslator; | |
| const trans = translator.load('jupyterlab'); | |
| const callback = () => { | |
| @@ -188,10 +186,7 @@ namespace Private { | |
| this._statusNames = translateKernelStatuses(this.translator); | |
| this._onStatusChanged(sessionContext); | |
| sessionContext.statusChanged.connect(this._onStatusChanged, this); | |
| - sessionContext.connectionStatusChanged.connect( | |
| - this._onStatusChanged, | |
| - this | |
| - ); | |
| + sessionContext.connectionStatusChanged.connect(this._onStatusChanged, this); | |
| } | |
| /** | |
| @@ -234,9 +229,6 @@ namespace Private { | |
| protected translator: ITranslator; | |
| private _trans: TranslationBundle; | |
| - private readonly _statusNames: Record< | |
| - ISessionContext.KernelDisplayStatus, | |
| - string | |
| - >; | |
| + private readonly _statusNames: Record<ISessionContext.KernelDisplayStatus, string>; | |
| } | |
| } | |
| diff --git a/packages/apputils/src/windowresolver.ts b/packages/apputils/src/windowresolver.ts | |
| index 1d4b17e411..076d7723fd 100644 | |
| --- a/packages/apputils/src/windowresolver.ts | |
| +++ b/packages/apputils/src/windowresolver.ts | |
| @@ -120,11 +120,7 @@ namespace Private { | |
| } | |
| // If the beacon was fired, respond with a ping. | |
| - if ( | |
| - key === BEACON && | |
| - newValue !== currentBeaconRequest && | |
| - candidate !== null | |
| - ) { | |
| + if (key === BEACON && newValue !== currentBeaconRequest && candidate !== null) { | |
| ping(resolved ? name : candidate); | |
| return; | |
| } | |
| diff --git a/packages/apputils/style/commandpalette.css b/packages/apputils/style/commandpalette.css | |
| index 5a5cec73b3..e086bfabc4 100644 | |
| --- a/packages/apputils/style/commandpalette.css | |
| +++ b/packages/apputils/style/commandpalette.css | |
| @@ -59,9 +59,7 @@ | |
| margin-right: 4px; | |
| } | |
| -.jp-ModalCommandPalette | |
| - .lm-CommandPalette | |
| - .lm-CommandPalette-item.lm-mod-disabled { | |
| +.jp-ModalCommandPalette .lm-CommandPalette .lm-CommandPalette-item.lm-mod-disabled { | |
| display: none; | |
| } | |
| diff --git a/packages/apputils/style/inputdialog.css b/packages/apputils/style/inputdialog.css | |
| index 39bfa36054..533fb370e5 100644 | |
| --- a/packages/apputils/style/inputdialog.css | |
| +++ b/packages/apputils/style/inputdialog.css | |
| @@ -23,8 +23,7 @@ | |
| background: var(--jp-error-color3); | |
| } | |
| -.jp-InputDialog-inputWrapper | |
| - > input[required].jp-mod-styled:invalid:placeholder-shown { | |
| +.jp-InputDialog-inputWrapper > input[required].jp-mod-styled:invalid:placeholder-shown { | |
| /* Do not show invalid style when placeholder is shown */ | |
| border-color: unset; | |
| background: unset; | |
| diff --git a/packages/apputils/test/dialog.spec.tsx b/packages/apputils/test/dialog.spec.tsx | |
| index 61ac9c0032..7ab17ecc31 100644 | |
| --- a/packages/apputils/test/dialog.spec.tsx | |
| +++ b/packages/apputils/test/dialog.spec.tsx | |
| @@ -3,11 +3,7 @@ | |
| // Distributed under the terms of the Modified BSD License. | |
| import { Dialog, ReactWidget, showDialog } from '@jupyterlab/apputils'; | |
| -import { | |
| - acceptDialog, | |
| - dismissDialog, | |
| - waitForDialog | |
| -} from '@jupyterlab/testing'; | |
| +import { acceptDialog, dismissDialog, waitForDialog } from '@jupyterlab/testing'; | |
| import type { Message } from '@lumino/messaging'; | |
| import { Widget } from '@lumino/widgets'; | |
| import * as React from 'react'; | |
| @@ -207,9 +203,7 @@ describe('@jupyterlab/apputils', () => { | |
| await waitForDialog(); | |
| - const textarea = dialog.node.querySelector( | |
| - '[data-testid="dialog-textarea"]' | |
| - ); | |
| + const textarea = dialog.node.querySelector('[data-testid="dialog-textarea"]'); | |
| expect(textarea).not.toBeNull(); | |
| if (textarea) { | |
| @@ -682,10 +676,7 @@ describe('@jupyterlab/apputils', () => { | |
| body: 'Hello', | |
| host: node, | |
| defaultButton: 0, | |
| - buttons: [ | |
| - Dialog.cancelButton({ actions: ['reload'] }), | |
| - Dialog.okButton() | |
| - ], | |
| + buttons: [Dialog.cancelButton({ actions: ['reload'] }), Dialog.okButton()], | |
| hasClose: true | |
| }); | |
| diff --git a/packages/apputils/test/domutils.spec.ts b/packages/apputils/test/domutils.spec.ts | |
| index 6e5b4d65d4..f169a221ca 100644 | |
| --- a/packages/apputils/test/domutils.spec.ts | |
| +++ b/packages/apputils/test/domutils.spec.ts | |
| @@ -41,9 +41,7 @@ describe('@jupyterlab/apputils', () => { | |
| it.each(testCases)( | |
| 'should work in light DOM: `%s` element should result in `%s`', | |
| (selector, expected) => { | |
| - const element = lightHost.querySelector( | |
| - selector as string | |
| - ) as HTMLElement; | |
| + const element = lightHost.querySelector(selector as string) as HTMLElement; | |
| element.focus(); | |
| const result = DOMUtils.hasActiveEditableElement(div); | |
| @@ -54,9 +52,7 @@ describe('@jupyterlab/apputils', () => { | |
| it.each(testCases)( | |
| 'should work in shadow DOM: `%s` element should result in `%s`', | |
| (selector, expected) => { | |
| - const element = shadowRoot.querySelector( | |
| - selector as string | |
| - ) as HTMLElement; | |
| + const element = shadowRoot.querySelector(selector as string) as HTMLElement; | |
| element.focus(); | |
| const result = DOMUtils.hasActiveEditableElement(div); | |
| diff --git a/packages/apputils/test/inputdialog.spec.ts b/packages/apputils/test/inputdialog.spec.ts | |
| index 85701a2d61..a399960164 100644 | |
| --- a/packages/apputils/test/inputdialog.spec.ts | |
| +++ b/packages/apputils/test/inputdialog.spec.ts | |
| @@ -2,11 +2,7 @@ | |
| // Distributed under the terms of the Modified BSD License. | |
| import { InputDialog } from '@jupyterlab/apputils'; | |
| -import { | |
| - acceptDialog, | |
| - dismissDialog, | |
| - waitForDialog | |
| -} from '@jupyterlab/testing'; | |
| +import { acceptDialog, dismissDialog, waitForDialog } from '@jupyterlab/testing'; | |
| describe('@jupyterlab/apputils', () => { | |
| describe('InputDialog', () => { | |
| @@ -260,9 +256,7 @@ describe('@jupyterlab/apputils', () => { | |
| }); | |
| await waitForDialog(node); | |
| - const input = node.querySelector( | |
| - 'input[type="text"]' | |
| - ) as HTMLInputElement; | |
| + const input = node.querySelector('input[type="text"]') as HTMLInputElement; | |
| input.value = '123'; | |
| input.dispatchEvent(new Event('input')); | |
| @@ -292,9 +286,7 @@ describe('@jupyterlab/apputils', () => { | |
| }); | |
| await waitForDialog(node); | |
| - const input = node.querySelector( | |
| - 'input[type="text"]' | |
| - ) as HTMLInputElement; | |
| + const input = node.querySelector('input[type="text"]') as HTMLInputElement; | |
| input.value = 'abc'; | |
| input.dispatchEvent(new Event('input')); | |
| diff --git a/packages/apputils/test/notification.spec.ts b/packages/apputils/test/notification.spec.ts | |
| index 5b155aa92c..3932a092b2 100644 | |
| --- a/packages/apputils/test/notification.spec.ts | |
| +++ b/packages/apputils/test/notification.spec.ts | |
| @@ -34,23 +34,19 @@ describe('@jupyterlab/apputils', () => { | |
| }); | |
| describe('#emit', () => { | |
| - it.each([ | |
| - 'default', | |
| - 'error', | |
| - 'info', | |
| - 'in-progress', | |
| - 'success', | |
| - 'warning' | |
| - ])('should emit a notification of the type %s', type => { | |
| - const id = Notification.emit('dummy message', type as any); | |
| + it.each(['default', 'error', 'info', 'in-progress', 'success', 'warning'])( | |
| + 'should emit a notification of the type %s', | |
| + type => { | |
| + const id = Notification.emit('dummy message', type as any); | |
| - expect(Notification.manager.count).toEqual(1); | |
| - expect(Notification.manager.notifications[0].id).toEqual(id); | |
| - expect(Notification.manager.notifications[0].message).toEqual( | |
| - 'dummy message' | |
| - ); | |
| - expect(Notification.manager.notifications[0].type).toEqual(type); | |
| - }); | |
| + expect(Notification.manager.count).toEqual(1); | |
| + expect(Notification.manager.notifications[0].id).toEqual(id); | |
| + expect(Notification.manager.notifications[0].message).toEqual( | |
| + 'dummy message' | |
| + ); | |
| + expect(Notification.manager.notifications[0].type).toEqual(type); | |
| + } | |
| + ); | |
| it('should emit a default notification by default', () => { | |
| Notification.emit('dummy 1'); | |
| @@ -91,9 +87,7 @@ describe('@jupyterlab/apputils', () => { | |
| ])('should bound the progress %s', (progress, expected) => { | |
| Notification.emit('dummy message', 'in-progress', { progress }); | |
| - expect(Notification.manager.notifications[0].options.progress).toEqual( | |
| - expected | |
| - ); | |
| + expect(Notification.manager.notifications[0].options.progress).toEqual(expected); | |
| }); | |
| describe('#error', () => { | |
| @@ -102,9 +96,7 @@ describe('@jupyterlab/apputils', () => { | |
| expect(Notification.manager.count).toEqual(1); | |
| expect(Notification.manager.notifications[0].id).toEqual(id); | |
| - expect(Notification.manager.notifications[0].message).toEqual( | |
| - 'dummy message' | |
| - ); | |
| + expect(Notification.manager.notifications[0].message).toEqual('dummy message'); | |
| expect(Notification.manager.notifications[0].type).toEqual('error'); | |
| }); | |
| }); | |
| @@ -115,9 +107,7 @@ describe('@jupyterlab/apputils', () => { | |
| expect(Notification.manager.count).toEqual(1); | |
| expect(Notification.manager.notifications[0].id).toEqual(id); | |
| - expect(Notification.manager.notifications[0].message).toEqual( | |
| - 'dummy message' | |
| - ); | |
| + expect(Notification.manager.notifications[0].message).toEqual('dummy message'); | |
| expect(Notification.manager.notifications[0].type).toEqual('info'); | |
| }); | |
| }); | |
| @@ -135,9 +125,7 @@ describe('@jupyterlab/apputils', () => { | |
| } | |
| }); | |
| - expect(Notification.manager.notifications[0].type).toEqual( | |
| - 'in-progress' | |
| - ); | |
| + expect(Notification.manager.notifications[0].type).toEqual('in-progress'); | |
| expect(Notification.manager.notifications[0].message).toEqual( | |
| 'Waiting for promise resolution' | |
| ); | |
| @@ -169,9 +157,7 @@ describe('@jupyterlab/apputils', () => { | |
| } | |
| }); | |
| - expect(Notification.manager.notifications[0].type).toEqual( | |
| - 'in-progress' | |
| - ); | |
| + expect(Notification.manager.notifications[0].type).toEqual('in-progress'); | |
| expect(Notification.manager.notifications[0].message).toEqual( | |
| 'Waiting for promise resolution' | |
| ); | |
| @@ -198,9 +184,7 @@ describe('@jupyterlab/apputils', () => { | |
| expect(Notification.manager.count).toEqual(1); | |
| expect(Notification.manager.notifications[0].id).toEqual(id); | |
| - expect(Notification.manager.notifications[0].message).toEqual( | |
| - 'dummy message' | |
| - ); | |
| + expect(Notification.manager.notifications[0].message).toEqual('dummy message'); | |
| expect(Notification.manager.notifications[0].type).toEqual('success'); | |
| }); | |
| }); | |
| @@ -249,9 +233,7 @@ describe('@jupyterlab/apputils', () => { | |
| id, | |
| progress: 0.5 | |
| }); | |
| - expect(Notification.manager.notifications[0].options.progress).toEqual( | |
| - 0.5 | |
| - ); | |
| + expect(Notification.manager.notifications[0].options.progress).toEqual(0.5); | |
| }); | |
| }); | |
| @@ -261,9 +243,7 @@ describe('@jupyterlab/apputils', () => { | |
| expect(Notification.manager.count).toEqual(1); | |
| expect(Notification.manager.notifications[0].id).toEqual(id); | |
| - expect(Notification.manager.notifications[0].message).toEqual( | |
| - 'dummy message' | |
| - ); | |
| + expect(Notification.manager.notifications[0].message).toEqual('dummy message'); | |
| expect(Notification.manager.notifications[0].type).toEqual('warning'); | |
| }); | |
| }); | |
| diff --git a/packages/apputils/test/printing.spec.ts b/packages/apputils/test/printing.spec.ts | |
| index 1e9cb8c180..5f7f3749e5 100644 | |
| --- a/packages/apputils/test/printing.spec.ts | |
| +++ b/packages/apputils/test/printing.spec.ts | |
| @@ -61,9 +61,7 @@ describe('@jupyterlab/apputils', () => { | |
| // Verify that settings were provided (not undefined) | |
| expect(capturedSettings).toBeDefined(); | |
| - expect(capturedSettings.baseUrl).toBe( | |
| - ServerConnection.makeSettings().baseUrl | |
| - ); | |
| + expect(capturedSettings.baseUrl).toBe(ServerConnection.makeSettings().baseUrl); | |
| }); | |
| }); | |
| }); | |
| diff --git a/packages/apputils/test/sanitizer.spec.ts b/packages/apputils/test/sanitizer.spec.ts | |
| index 0e7a41c215..98f79c47c3 100644 | |
| --- a/packages/apputils/test/sanitizer.spec.ts | |
| +++ b/packages/apputils/test/sanitizer.spec.ts | |
| @@ -48,8 +48,7 @@ describe('sanitizer', () => { | |
| }); | |
| it('should allow img tags and some attributes', () => { | |
| - const img = | |
| - '<img src="smiley.gif" alt="Smiley face" height="42" width="42" />'; | |
| + const img = '<img src="smiley.gif" alt="Smiley face" height="42" width="42" />'; | |
| expect(sanitizer.sanitize(img)).toBe(img); | |
| }); | |
| @@ -167,8 +166,7 @@ describe('sanitizer', () => { | |
| }); | |
| it('should allow simple background CSS radial-gradient', () => { | |
| - const div = | |
| - '<div style="background:radial-gradient(#e66465, #9198e5)"></div>'; | |
| + const div = '<div style="background:radial-gradient(#e66465, #9198e5)"></div>'; | |
| expect(sanitizer.sanitize(div)).toBe(div); | |
| }); | |
| @@ -179,8 +177,7 @@ describe('sanitizer', () => { | |
| }); | |
| it('strip incorrect CSS line-gradient', () => { | |
| - const div = | |
| - '<div style="background:linear-gradient(http://example.com)"></div>'; | |
| + const div = '<div style="background:linear-gradient(http://example.com)"></div>'; | |
| expect(sanitizer.sanitize(div)).toBe('<div></div>'); | |
| }); | |
| @@ -318,8 +315,7 @@ describe('sanitizer', () => { | |
| }); | |
| it('should allow calc expressions in grid and flex properties', () => { | |
| - const div = | |
| - '<div style="grid-template-columns:calc(100% - 50px) 50px"></div>'; | |
| + const div = '<div style="grid-template-columns:calc(100% - 50px) 50px"></div>'; | |
| expect(sanitizer.sanitize(div)).toBe(div); | |
| }); | |
| diff --git a/packages/apputils/test/sessioncontext.spec.ts b/packages/apputils/test/sessioncontext.spec.ts | |
| index a23930b13e..b594bd1cad 100644 | |
| --- a/packages/apputils/test/sessioncontext.spec.ts | |
| +++ b/packages/apputils/test/sessioncontext.spec.ts | |
| @@ -1,15 +1,8 @@ | |
| // Copyright (c) Jupyter Development Team. | |
| // Distributed under the terms of the Modified BSD License. | |
| -import type { | |
| - ISessionContext, | |
| - ISessionContextDialogs | |
| -} from '@jupyterlab/apputils'; | |
| -import { | |
| - Dialog, | |
| - SessionContext, | |
| - SessionContextDialogs | |
| -} from '@jupyterlab/apputils'; | |
| +import type { ISessionContext, ISessionContextDialogs } from '@jupyterlab/apputils'; | |
| +import { Dialog, SessionContext, SessionContextDialogs } from '@jupyterlab/apputils'; | |
| import { | |
| KernelManager, | |
| KernelSpecManager, | |
| @@ -151,17 +144,15 @@ describe('@jupyterlab/apputils', () => { | |
| describe('#kernelChanged', () => { | |
| it('should be emitted when the kernel changes', async () => { | |
| let called = false; | |
| - sessionContext.kernelChanged.connect( | |
| - (sender, { oldValue, newValue }) => { | |
| - if (oldValue !== null) { | |
| - return; | |
| - } | |
| - expect(sender).toBe(sessionContext); | |
| - expect(oldValue).toBeNull(); | |
| - expect(newValue).toBe(sessionContext.session?.kernel || null); | |
| - called = true; | |
| + sessionContext.kernelChanged.connect((sender, { oldValue, newValue }) => { | |
| + if (oldValue !== null) { | |
| + return; | |
| } | |
| - ); | |
| + expect(sender).toBe(sessionContext); | |
| + expect(oldValue).toBeNull(); | |
| + expect(newValue).toBe(sessionContext.session?.kernel || null); | |
| + called = true; | |
| + }); | |
| await sessionContext.initialize(); | |
| expect(called).toBe(true); | |
| }); | |
| @@ -170,17 +161,15 @@ describe('@jupyterlab/apputils', () => { | |
| describe('#sessionChanged', () => { | |
| it('should be emitted when the session changes', async () => { | |
| let called = false; | |
| - sessionContext.sessionChanged.connect( | |
| - (sender, { oldValue, newValue }) => { | |
| - if (oldValue !== null) { | |
| - return; | |
| - } | |
| - expect(sender).toBe(sessionContext); | |
| - expect(oldValue).toBeNull(); | |
| - expect(newValue).toBe(sessionContext.session); | |
| - called = true; | |
| + sessionContext.sessionChanged.connect((sender, { oldValue, newValue }) => { | |
| + if (oldValue !== null) { | |
| + return; | |
| } | |
| - ); | |
| + expect(sender).toBe(sessionContext); | |
| + expect(oldValue).toBeNull(); | |
| + expect(newValue).toBe(sessionContext.session); | |
| + called = true; | |
| + }); | |
| await sessionContext.initialize(); | |
| expect(called).toBe(true); | |
| }); | |
| @@ -283,9 +272,7 @@ describe('@jupyterlab/apputils', () => { | |
| describe('#initialize()', () => { | |
| it('should start the default kernel', async () => { | |
| await sessionContext.initialize(); | |
| - expect(sessionContext.session?.kernel?.name).toBe( | |
| - specsManager.specs!.default | |
| - ); | |
| + expect(sessionContext.session?.kernel?.name).toBe(specsManager.specs!.default); | |
| }); | |
| it('should connect to an existing session on the path', async () => { | |
| @@ -541,8 +528,7 @@ describe('@jupyterlab/apputils', () => { | |
| }); | |
| it('should return a matching name', () => { | |
| - const spec = | |
| - specsManager.specs!.kernelspecs[specsManager.specs!.default]!; | |
| + const spec = specsManager.specs!.kernelspecs[specsManager.specs!.default]!; | |
| expect( | |
| SessionContext.getDefaultKernel({ | |
| @@ -562,8 +548,7 @@ describe('@jupyterlab/apputils', () => { | |
| }); | |
| it('should return a matching language', () => { | |
| - const spec = | |
| - specsManager.specs!.kernelspecs[specsManager.specs!.default]!; | |
| + const spec = specsManager.specs!.kernelspecs[specsManager.specs!.default]!; | |
| const kernelspecs: any = {}; | |
| kernelspecs[spec.name] = spec; | |
| @@ -579,8 +564,7 @@ describe('@jupyterlab/apputils', () => { | |
| }); | |
| it('should return null if a language matches twice', () => { | |
| - const spec = | |
| - specsManager.specs!.kernelspecs[specsManager.specs!.default]!; | |
| + const spec = specsManager.specs!.kernelspecs[specsManager.specs!.default]!; | |
| const kernelspecs: any = {}; | |
| kernelspecs['foo'] = spec; | |
| @@ -650,9 +634,7 @@ describe('@jupyterlab/apputils', () => { | |
| (acc, group) => acc.concat(group.options), | |
| [] as { text: string }[] | |
| ); | |
| - expect(options[options.length - 1].text).toContain( | |
| - MOCK_KERNEL['kernel_name'] | |
| - ); | |
| + expect(options[options.length - 1].text).toContain(MOCK_KERNEL['kernel_name']); | |
| }); | |
| }); | |
| diff --git a/packages/apputils/test/toolbar.spec.ts b/packages/apputils/test/toolbar.spec.ts | |
| index 7883495032..316e1fe853 100644 | |
| --- a/packages/apputils/test/toolbar.spec.ts | |
| +++ b/packages/apputils/test/toolbar.spec.ts | |
| @@ -47,9 +47,7 @@ describe('@jupyterlab/apputils', () => { | |
| const button = Toolbar.createInterruptButton(sessionContext); | |
| Widget.attach(button, document.body); | |
| await framePromise(); | |
| - expect( | |
| - button.node.querySelector("[data-icon$='stop']") | |
| - ).toBeDefined(); | |
| + expect(button.node.querySelector("[data-icon$='stop']")).toBeDefined(); | |
| }); | |
| }); | |
| @@ -61,9 +59,7 @@ describe('@jupyterlab/apputils', () => { | |
| ); | |
| Widget.attach(button, document.body); | |
| await framePromise(); | |
| - expect( | |
| - button.node.querySelector("[data-icon$='refresh']") | |
| - ).toBeDefined(); | |
| + expect(button.node.querySelector("[data-icon$='refresh']")).toBeDefined(); | |
| }); | |
| }); | |
| @@ -93,9 +89,7 @@ describe('@jupyterlab/apputils', () => { | |
| sessionContext.statusChanged.connect((_, status) => { | |
| if (status === 'busy') { | |
| // eslint-disable-next-line jest/no-conditional-expect | |
| - expect( | |
| - item.node.querySelector("[data-icon$='circle']") | |
| - ).toBeDefined(); | |
| + expect(item.node.querySelector("[data-icon$='circle']")).toBeDefined(); | |
| called = true; | |
| } | |
| }); | |
| @@ -132,9 +126,7 @@ describe('@jupyterlab/apputils', () => { | |
| await sessionContext.initialize(); | |
| const item = Toolbar.createKernelStatusItem(sessionContext); | |
| expect(item.node.title).toBe('Kernel Connecting'); | |
| - expect( | |
| - item.node.querySelector("[data-icon$='circle-empty']") | |
| - ).toBeDefined(); | |
| + expect(item.node.querySelector("[data-icon$='circle-empty']")).toBeDefined(); | |
| await sessionContext.initialize(); | |
| await sessionContext.session?.kernel?.info; | |
| }); | |
| @@ -223,9 +215,7 @@ describe('@jupyterlab/apputils', () => { | |
| name: 'test' | |
| }; | |
| - expect( | |
| - registry.addFactory('factory', item.name, dummy) | |
| - ).toBeUndefined(); | |
| + expect(registry.addFactory('factory', item.name, dummy)).toBeUndefined(); | |
| expect(registry.addFactory('factory', item.name, dummy2)).toBe(dummy); | |
| }); | |
| }); | |
| @@ -421,15 +411,11 @@ describe('@jupyterlab/apputils', () => { | |
| ); | |
| const barPlugin = await settingRegistry.load(bar.id); | |
| - const baseToolbar = JSONExt.deepCopy( | |
| - barPlugin.composite['toolbar'] as any | |
| - ); | |
| + const baseToolbar = JSONExt.deepCopy(barPlugin.composite['toolbar'] as any); | |
| let waitForChange = new PromiseDelegate<void>(); | |
| barPlugin.changed.connect(() => { | |
| - if ( | |
| - !JSONExt.deepEqual(baseToolbar, barPlugin.composite['toolbar'] as any) | |
| - ) { | |
| + if (!JSONExt.deepEqual(baseToolbar, barPlugin.composite['toolbar'] as any)) { | |
| waitForChange.resolve(); | |
| } | |
| }); | |
| diff --git a/packages/apputils/test/widgettracker.spec.ts b/packages/apputils/test/widgettracker.spec.ts | |
| index 1b4360eb84..bcba2dd7d8 100644 | |
| --- a/packages/apputils/test/widgettracker.spec.ts | |
| +++ b/packages/apputils/test/widgettracker.spec.ts | |
| @@ -356,9 +356,7 @@ describe('@jupyterlab/apputils', () => { | |
| void tracker.add(widgetA); | |
| void tracker.add(widgetB); | |
| void tracker.add(widgetC); | |
| - const list = tracker.filter( | |
| - widget => widget.id.indexOf('include') !== -1 | |
| - ); | |
| + const list = tracker.filter(widget => widget.id.indexOf('include') !== -1); | |
| expect(list.length).toBe(2); | |
| expect(list[0]).toBe(widgetA); | |
| expect(list[1]).toBe(widgetB); | |
| @@ -439,9 +437,7 @@ describe('@jupyterlab/apputils', () => { | |
| const tracker = new TestTracker({ namespace }); | |
| const widget = createWidget(); | |
| await tracker.add(widget); | |
| - expect(tracker.methods).toEqual( | |
| - expect.arrayContaining(['onCurrentChanged']) | |
| - ); | |
| + expect(tracker.methods).toEqual(expect.arrayContaining(['onCurrentChanged'])); | |
| widget.dispose(); | |
| }); | |
| }); | |
| diff --git a/packages/attachments/src/model.ts b/packages/attachments/src/model.ts | |
| index 99b7b0f52c..b94999c67c 100644 | |
| --- a/packages/attachments/src/model.ts | |
| +++ b/packages/attachments/src/model.ts | |
| @@ -307,9 +307,7 @@ export namespace AttachmentsModel { | |
| /** | |
| * Create an attachment model. | |
| */ | |
| - createAttachmentModel( | |
| - options: IAttachmentModel.IOptions | |
| - ): IAttachmentModel { | |
| + createAttachmentModel(options: IAttachmentModel.IOptions): IAttachmentModel { | |
| return new AttachmentModel(options); | |
| } | |
| } | |
| diff --git a/packages/audio-extension/src/index.ts b/packages/audio-extension/src/index.ts | |
| index 568460e809..8b1bf10e9a 100644 | |
| --- a/packages/audio-extension/src/index.ts | |
| +++ b/packages/audio-extension/src/index.ts | |
| @@ -7,16 +7,10 @@ | |
| * @module audio-extension | |
| */ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { ILayoutRestorer } from '@jupyterlab/application'; | |
| import { WidgetTracker } from '@jupyterlab/apputils'; | |
| -import type { | |
| - DocumentRegistry, | |
| - IDocumentWidget | |
| -} from '@jupyterlab/docregistry'; | |
| +import type { DocumentRegistry, IDocumentWidget } from '@jupyterlab/docregistry'; | |
| import { ABCWidgetFactory, DocumentWidget } from '@jupyterlab/docregistry'; | |
| import type { Contents } from '@jupyterlab/services'; | |
| import { IDefaultDrive, RestContentProvider } from '@jupyterlab/services'; | |
| @@ -108,9 +102,7 @@ export class AudioViewer extends Widget { | |
| */ | |
| private async _updateAudio(): Promise<void> { | |
| // Use getDownloadUrl for proper URL encoding and security tokens | |
| - const audioUrl = await this._contentsManager.getDownloadUrl( | |
| - this._context.path | |
| - ); | |
| + const audioUrl = await this._contentsManager.getDownloadUrl(this._context.path); | |
| this._audio.src = audioUrl; | |
| } | |
| @@ -161,9 +153,7 @@ export namespace AudioDocumentWidget { | |
| /** | |
| * A widget factory for audio viewers. | |
| */ | |
| -export class AudioViewerFactory extends ABCWidgetFactory< | |
| - IDocumentWidget<AudioViewer> | |
| -> { | |
| +export class AudioViewerFactory extends ABCWidgetFactory<IDocumentWidget<AudioViewer>> { | |
| /** | |
| * Construct a new audio viewer factory. | |
| */ | |
| @@ -295,9 +285,7 @@ const plugin: JupyterFrontEndPlugin<void> = { | |
| }); | |
| // Set appropriate icon based on file type from document registry | |
| - const fileTypes = app.docRegistry.getFileTypesForPath( | |
| - widget.context.path | |
| - ); | |
| + const fileTypes = app.docRegistry.getFileTypesForPath(widget.context.path); | |
| const audioFileType = fileTypes.find(ft => | |
| ft.mimeTypes.some(mimeType => mimeType.startsWith('audio/')) | |
| ); | |
| diff --git a/packages/cell-toolbar-extension/src/index.ts b/packages/cell-toolbar-extension/src/index.ts | |
| index d4cdbbaf9d..4e609ba168 100644 | |
| --- a/packages/cell-toolbar-extension/src/index.ts | |
| +++ b/packages/cell-toolbar-extension/src/index.ts | |
| @@ -7,10 +7,7 @@ | |
| * @module cell-toolbar-extension | |
| */ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { ISettingRegistry } from '@jupyterlab/settingregistry'; | |
| import { CellBarExtension } from '@jupyterlab/cell-toolbar'; | |
| import { | |
| @@ -90,9 +87,7 @@ const cellToolbar: JupyterFrontEndPlugin<void> = { | |
| function loadSetting(setting: ISettingRegistry.ISettings | null): void { | |
| // Read the setting and convert to the correct type | |
| const showCellToolbar: boolean | null = | |
| - setting === null | |
| - ? true | |
| - : (setting.get('showToolbar').composite as boolean); | |
| + setting === null ? true : (setting.get('showToolbar').composite as boolean); | |
| extension.enabled = showCellToolbar; | |
| } | |
| diff --git a/packages/cell-toolbar/src/celltoolbartracker.ts b/packages/cell-toolbar/src/celltoolbartracker.ts | |
| index 81aa0c9d67..59b01243d1 100644 | |
| --- a/packages/cell-toolbar/src/celltoolbartracker.ts | |
| +++ b/packages/cell-toolbar/src/celltoolbartracker.ts | |
| @@ -60,9 +60,7 @@ export class CellToolbarTracker implements IDisposable { | |
| constructor( | |
| panel: NotebookPanel, | |
| toolbar?: IObservableList<ToolbarRegistry.IToolbarItem>, | |
| - toolbarFactory?: ( | |
| - widget: Cell | |
| - ) => IObservableList<ToolbarRegistry.IToolbarItem>, | |
| + toolbarFactory?: (widget: Cell) => IObservableList<ToolbarRegistry.IToolbarItem>, | |
| translator?: ITranslator | |
| ) { | |
| this._panel = panel; | |
| @@ -91,10 +89,7 @@ export class CellToolbarTracker implements IDisposable { | |
| notebook.activeCellChanged.connect(this._onActiveCellChanged, this); | |
| // Check whether the toolbar should be rendered upon a layout change | |
| - notebook.renderingLayoutChanged.connect( | |
| - this._onActiveCellChanged, | |
| - this | |
| - ); | |
| + notebook.renderingLayoutChanged.connect(this._onActiveCellChanged, this); | |
| notebook.disposed.connect(() => { | |
| notebook.activeCellChanged.disconnect(this._onActiveCellChanged); | |
| @@ -198,10 +193,7 @@ export class CellToolbarTracker implements IDisposable { | |
| toolbarWidget.addClass(CELL_MENU_CLASS); | |
| toolbarWidget.addClass(CELL_TOOLBAR_CLASS); | |
| - toolbarWidget.node.setAttribute( | |
| - 'aria-label', | |
| - this._trans.__('Cell toolbar') | |
| - ); | |
| + toolbarWidget.node.setAttribute('aria-label', this._trans.__('Cell toolbar')); | |
| const promises: Promise<void>[] = [cell.ready]; | |
| if (this._toolbarFactory) { | |
| // Use our custom factory directly instead of setToolbar | |
| @@ -241,10 +233,7 @@ export class CellToolbarTracker implements IDisposable { | |
| // Hide the toolbar by default, to avoid temporary overlapping. | |
| cell.node.classList.add(TOOLBAR_OVERLAP_CLASS); | |
| - (cell.inputArea!.layout as PanelLayout).insertWidget( | |
| - 0, | |
| - toolbarWidget | |
| - ); | |
| + (cell.inputArea!.layout as PanelLayout).insertWidget(0, toolbarWidget); | |
| // For rendered markdown, watch for resize events. | |
| cell.displayChanged.connect(this._resizeEventCallback, this); | |
| @@ -415,19 +404,14 @@ export class CellToolbarTracker implements IDisposable { | |
| const node = output.firstElementChild; | |
| if (node) { | |
| const range = new Range(); | |
| - if ( | |
| - TEXT_MIME_TYPES.includes( | |
| - output.getAttribute('data-mime-type') || '' | |
| - ) | |
| - ) { | |
| + if (TEXT_MIME_TYPES.includes(output.getAttribute('data-mime-type') || '')) { | |
| // If the node is plain text, it's in a <pre>. To get the true bounding box of the | |
| // text, the node contents need to be selected. | |
| range.selectNodeContents(node); | |
| } else { | |
| range.selectNode(node); | |
| } | |
| - const { right: nodeRight, top: nodeTop } = | |
| - range.getBoundingClientRect(); | |
| + const { right: nodeRight, top: nodeTop } = range.getBoundingClientRect(); | |
| // Note: y-coordinate increases toward the bottom of page | |
| return nodeRight > toolbarLeft && nodeTop < toolbarBottom; | |
| @@ -483,8 +467,7 @@ export class CellToolbarTracker implements IDisposable { | |
| private _panel: NotebookPanel | null; | |
| private _previousActiveCell: Cell<ICellModel> | null; | |
| private _toolbar: Widget | null = null; | |
| - private _toolbarItems: IObservableList<ToolbarRegistry.IToolbarItem> | null = | |
| - null; | |
| + private _toolbarItems: IObservableList<ToolbarRegistry.IToolbarItem> | null = null; | |
| private _toolbarFactory: | |
| | ((widget: Cell) => IObservableList<ToolbarRegistry.IToolbarItem>) | |
| | null = null; | |
| @@ -558,11 +541,7 @@ export class CellBarExtension implements DocumentRegistry.WidgetExtension { | |
| return { | |
| name: item.name, | |
| - widget: itemFactory( | |
| - CellBarExtension.FACTORY_NAME, | |
| - widget, | |
| - itemWithArgs | |
| - ) | |
| + widget: itemFactory(CellBarExtension.FACTORY_NAME, widget, itemWithArgs) | |
| }; | |
| }) | |
| }); | |
| diff --git a/packages/cell-toolbar/test/celltoolbartracker.spec.ts b/packages/cell-toolbar/test/celltoolbartracker.spec.ts | |
| index ee0be501ca..ad9503edab 100644 | |
| --- a/packages/cell-toolbar/test/celltoolbartracker.spec.ts | |
| +++ b/packages/cell-toolbar/test/celltoolbartracker.spec.ts | |
| @@ -2,10 +2,7 @@ | |
| | Copyright (c) Jupyter Development Team. | |
| | Distributed under the terms of the Modified BSD License. | |
| |----------------------------------------------------------------------------*/ | |
| -import { | |
| - createToolbarFactory, | |
| - ToolbarWidgetRegistry | |
| -} from '@jupyterlab/apputils'; | |
| +import { createToolbarFactory, ToolbarWidgetRegistry } from '@jupyterlab/apputils'; | |
| import { CellBarExtension, CellToolbarTracker } from '@jupyterlab/cell-toolbar'; | |
| import type { ToolbarRegistry } from '@jupyterlab/apputils'; | |
| import type { NotebookPanel } from '@jupyterlab/notebook'; | |
| @@ -30,10 +27,7 @@ class CellBarExtensionWithCustomItemFactory extends CellBarExtension { | |
| if (toolbarItem.command) { | |
| const button = document.createElement('button'); | |
| button.dataset.command = toolbarItem.command; | |
| - button.disabled = !commands.isEnabled( | |
| - toolbarItem.command, | |
| - toolbarItem.args | |
| - ); | |
| + button.disabled = !commands.isEnabled(toolbarItem.command, toolbarItem.args); | |
| itemWidget.node.appendChild(button); | |
| } | |
| return itemWidget; | |
| @@ -86,12 +80,7 @@ function testToolbarFactory() { | |
| version: 'test' | |
| }; | |
| - const connector: IDataConnector< | |
| - ISettingRegistry.IPlugin, | |
| - string, | |
| - string, | |
| - string | |
| - > = { | |
| + const connector: IDataConnector<ISettingRegistry.IPlugin, string, string, string> = { | |
| fetch: jest.fn().mockImplementation((id: string) => { | |
| switch (id) { | |
| case bar.id: | |
| @@ -227,12 +216,10 @@ describe('@jupyterlab/cell-toolbar', () => { | |
| await framePromise(); | |
| await framePromise(); | |
| - const toolbarA = notebookA.content.activeCell!.node.querySelector( | |
| - CELL_TOOLBAR_SELECTOR | |
| - )!; | |
| - const toolbarB = notebookB.content.activeCell!.node.querySelector( | |
| - CELL_TOOLBAR_SELECTOR | |
| - )!; | |
| + const toolbarA = | |
| + notebookA.content.activeCell!.node.querySelector(CELL_TOOLBAR_SELECTOR)!; | |
| + const toolbarB = | |
| + notebookB.content.activeCell!.node.querySelector(CELL_TOOLBAR_SELECTOR)!; | |
| const buttonUpA = toolbarA.querySelector( | |
| '[data-command="notebook:move-cell-up"]' | |
| diff --git a/packages/cells/src/celldragutils.ts b/packages/cells/src/celldragutils.ts | |
| index 2ad0edce3c..25533977af 100644 | |
| --- a/packages/cells/src/celldragutils.ts | |
| +++ b/packages/cells/src/celldragutils.ts | |
| @@ -91,10 +91,7 @@ export namespace CellDragUtils { | |
| * @param cell - The cell which contains the MouseEvent's target | |
| * @param target - The DOM node which triggered the MouseEvent | |
| */ | |
| - export function detectTargetArea( | |
| - cell: Cell, | |
| - target: HTMLElement | |
| - ): ICellTargetArea { | |
| + export function detectTargetArea(cell: Cell, target: HTMLElement): ICellTargetArea { | |
| let targetArea: ICellTargetArea; | |
| if (cell) { | |
| if (cell.editorWidget?.node.contains(target)) { | |
| @@ -143,8 +140,7 @@ export namespace CellDragUtils { | |
| const count = selectedCells.length; | |
| let promptNumber: string; | |
| if (activeCell.model.type === 'code') { | |
| - const executionCount = (activeCell.model as ICodeCellModel) | |
| - .executionCount; | |
| + const executionCount = (activeCell.model as ICodeCellModel).executionCount; | |
| promptNumber = ' '; | |
| if (executionCount) { | |
| promptNumber = executionCount.toString(); | |
| @@ -163,10 +159,7 @@ export namespace CellDragUtils { | |
| h.div( | |
| h.div( | |
| { className: DRAG_IMAGE_CLASS }, | |
| - h.span( | |
| - { className: CELL_DRAG_PROMPT_CLASS }, | |
| - '[' + promptNumber + ']:' | |
| - ), | |
| + h.span({ className: CELL_DRAG_PROMPT_CLASS }, '[' + promptNumber + ']:'), | |
| h.span({ className: CELL_DRAG_CONTENT_CLASS }, cellContent) | |
| ), | |
| h.div({ className: CELL_DRAG_MULTIPLE_BACK }, '') | |
| @@ -190,10 +183,7 @@ export namespace CellDragUtils { | |
| h.div( | |
| h.div( | |
| { className: `${DRAG_IMAGE_CLASS} ${SINGLE_DRAG_IMAGE_CLASS}` }, | |
| - h.span( | |
| - { className: CELL_DRAG_PROMPT_CLASS }, | |
| - '[' + promptNumber + ']:' | |
| - ), | |
| + h.span({ className: CELL_DRAG_PROMPT_CLASS }, '[' + promptNumber + ']:'), | |
| h.span({ className: CELL_DRAG_CONTENT_CLASS }, cellContent) | |
| ) | |
| ) | |
| diff --git a/packages/cells/src/model.ts b/packages/cells/src/model.ts | |
| index 144379e8b7..002c5b66b6 100644 | |
| --- a/packages/cells/src/model.ts | |
| +++ b/packages/cells/src/model.ts | |
| @@ -15,10 +15,7 @@ import type { IChangedArgs } from '@jupyterlab/coreutils'; | |
| import type * as nbformat from '@jupyterlab/nbformat'; | |
| -import type { | |
| - IObservableString, | |
| - ObservableValue | |
| -} from '@jupyterlab/observables'; | |
| +import type { IObservableString, ObservableValue } from '@jupyterlab/observables'; | |
| import type { IOutputAreaModel } from '@jupyterlab/outputarea'; | |
| import { OutputAreaModel } from '@jupyterlab/outputarea'; | |
| @@ -60,10 +57,7 @@ export interface ICellModel extends CodeEditor.IModel { | |
| /** | |
| * A signal emitted when a model state changes. | |
| */ | |
| - readonly stateChanged: ISignal< | |
| - ICellModel, | |
| - IChangedArgs<boolean, boolean, any> | |
| - >; | |
| + readonly stateChanged: ISignal<ICellModel, IChangedArgs<boolean, boolean, any>>; | |
| /** | |
| * Whether the cell is trusted. | |
| @@ -214,9 +208,7 @@ export function isCodeCellModel(model: ICellModel): model is ICodeCellModel { | |
| return model.type === 'code'; | |
| } | |
| -export function isMarkdownCellModel( | |
| - model: ICellModel | |
| -): model is IMarkdownCellModel { | |
| +export function isMarkdownCellModel(model: ICellModel): model is IMarkdownCellModel { | |
| return model.type === 'markdown'; | |
| } | |
| @@ -270,11 +262,7 @@ export abstract class CellModel extends CodeEditor.Model implements ICellModel { | |
| */ | |
| readonly stateChanged = new Signal< | |
| this, | |
| - IChangedArgs< | |
| - any, | |
| - any, | |
| - 'isDirty' | 'trusted' | 'executionCount' | 'executionState' | |
| - > | |
| + IChangedArgs<any, any, 'isDirty' | 'trusted' | 'executionCount' | 'executionState'> | |
| >(this); | |
| /** | |
| @@ -322,10 +310,7 @@ export abstract class CellModel extends CodeEditor.Model implements ICellModel { | |
| * | |
| * The default implementation is a no-op. | |
| */ | |
| - onTrustedChanged( | |
| - trusted: CellModel, | |
| - args: ObservableValue.IChangedArgs | |
| - ): void { | |
| + onTrustedChanged(trusted: CellModel, args: ObservableValue.IChangedArgs): void { | |
| /* no-op */ | |
| } | |
| @@ -427,9 +412,7 @@ export abstract class AttachmentsCellModel extends CellModel { | |
| super(options); | |
| const factory = | |
| options.contentFactory ?? AttachmentsCellModel.defaultContentFactory; | |
| - const values = ( | |
| - this.sharedModel as ISharedAttachmentsCell | |
| - ).getAttachments(); | |
| + const values = (this.sharedModel as ISharedAttachmentsCell).getAttachments(); | |
| this._attachments = factory.createAttachmentsModel({ values }); | |
| this._attachments.stateChanged.connect(this.onGenericChange, this); | |
| this._attachments.changed.connect(this._onAttachmentsChange, this); | |
| @@ -485,9 +468,7 @@ export abstract class AttachmentsCellModel extends CellModel { | |
| ): void { | |
| if (change.attachmentsChange) { | |
| const cell = this.sharedModel as ISharedAttachmentsCell; | |
| - globalModelDBMutex(() => | |
| - this._attachments.fromJSON(cell.getAttachments() ?? {}) | |
| - ); | |
| + globalModelDBMutex(() => this._attachments.fromJSON(cell.getAttachments() ?? {})); | |
| } | |
| } | |
| @@ -501,9 +482,7 @@ export namespace AttachmentsCellModel { | |
| /** | |
| * The options used to initialize a `AttachmentsCellModel`. | |
| */ | |
| - export interface IOptions< | |
| - T extends ISharedCell | |
| - > extends CellModel.IOptions<T> { | |
| + export interface IOptions<T extends ISharedCell> extends CellModel.IOptions<T> { | |
| /** | |
| * The factory for attachment model creation. | |
| */ | |
| @@ -517,9 +496,7 @@ export namespace AttachmentsCellModel { | |
| /** | |
| * Create an output area. | |
| */ | |
| - createAttachmentsModel( | |
| - options: IAttachmentsModel.IOptions | |
| - ): IAttachmentsModel; | |
| + createAttachmentsModel(options: IAttachmentsModel.IOptions): IAttachmentsModel; | |
| } | |
| /** | |
| @@ -529,9 +506,7 @@ export namespace AttachmentsCellModel { | |
| /** | |
| * Create an attachments model. | |
| */ | |
| - createAttachmentsModel( | |
| - options: IAttachmentsModel.IOptions | |
| - ): IAttachmentsModel { | |
| + createAttachmentsModel(options: IAttachmentsModel.IOptions): IAttachmentsModel { | |
| return new AttachmentsModel(options); | |
| } | |
| } | |
| @@ -550,10 +525,7 @@ export class RawCellModel extends AttachmentsCellModel { | |
| * Construct a raw cell model from optional shared model. | |
| */ | |
| constructor( | |
| - options: Omit< | |
| - AttachmentsCellModel.IOptions<ISharedRawCell>, | |
| - 'cell_type' | |
| - > = {} | |
| + options: Omit<AttachmentsCellModel.IOptions<ISharedRawCell>, 'cell_type'> = {} | |
| ) { | |
| super({ | |
| cell_type: 'raw', | |
| @@ -584,10 +556,7 @@ export class MarkdownCellModel extends AttachmentsCellModel { | |
| * Construct a markdown cell model from optional shared model. | |
| */ | |
| constructor( | |
| - options: Omit< | |
| - AttachmentsCellModel.IOptions<ISharedMarkdownCell>, | |
| - 'cell_type' | |
| - > = {} | |
| + options: Omit<AttachmentsCellModel.IOptions<ISharedMarkdownCell>, 'cell_type'> = {} | |
| ) { | |
| super({ | |
| cell_type: 'markdown', | |
| @@ -625,8 +594,7 @@ export class CodeCellModel extends CellModel implements ICodeCellModel { | |
| ...options | |
| }); | |
| - const factory = | |
| - options?.contentFactory ?? CodeCellModel.defaultContentFactory; | |
| + const factory = options?.contentFactory ?? CodeCellModel.defaultContentFactory; | |
| const trusted = this.trusted; | |
| const outputs = this.sharedModel.getOutputs(); | |
| this._outputs = factory.createOutputArea({ trusted, values: outputs }); | |
| @@ -719,10 +687,7 @@ export class CodeCellModel extends CellModel implements ICodeCellModel { | |
| /** | |
| * Handle a change to the trusted state. | |
| */ | |
| - onTrustedChanged( | |
| - trusted: CellModel, | |
| - args: ObservableValue.IChangedArgs | |
| - ): void { | |
| + onTrustedChanged(trusted: CellModel, args: ObservableValue.IChangedArgs): void { | |
| const newTrusted = args.newValue as boolean; | |
| if (this._outputs) { | |
| this._outputs.trusted = newTrusted; | |
| @@ -829,10 +794,7 @@ export class CodeCellModel extends CellModel implements ICodeCellModel { | |
| /** | |
| * Handle a change to the code cell value. | |
| */ | |
| - private _onSharedModelChanged( | |
| - slot: ISharedCodeCell, | |
| - change: CellChange | |
| - ): void { | |
| + private _onSharedModelChanged(slot: ISharedCodeCell, change: CellChange): void { | |
| if (change.streamOutputChange) { | |
| globalModelDBMutex(() => { | |
| for (const streamOutputChange of change.streamOutputChange!) { | |
| @@ -840,9 +802,7 @@ export class CodeCellModel extends CellModel implements ICodeCellModel { | |
| this._outputs.removeStreamOutput(streamOutputChange.delete!); | |
| } | |
| if ('insert' in streamOutputChange) { | |
| - this._outputs.appendStreamOutput( | |
| - streamOutputChange.insert!.toString() | |
| - ); | |
| + this._outputs.appendStreamOutput(streamOutputChange.insert!.toString()); | |
| } | |
| } | |
| }); | |
| @@ -896,9 +856,7 @@ export class CodeCellModel extends CellModel implements ICodeCellModel { | |
| change.sourceChange && | |
| (this.executionCount !== null || this.executionState === 'running') | |
| ) { | |
| - this._setDirty( | |
| - this._executedCode !== this.sharedModel.getSource().trim() | |
| - ); | |
| + this._setDirty(this._executedCode !== this.sharedModel.getSource().trim()); | |
| } | |
| } | |
| diff --git a/packages/cells/src/searchprovider.ts b/packages/cells/src/searchprovider.ts | |
| index 4864ce83b8..b10cbc5687 100644 | |
| --- a/packages/cells/src/searchprovider.ts | |
| +++ b/packages/cells/src/searchprovider.ts | |
| @@ -104,9 +104,7 @@ class CodeCellSearchProvider extends CellSearchProvider { | |
| */ | |
| async clearHighlight(): Promise<void> { | |
| await super.clearHighlight(); | |
| - await Promise.all( | |
| - this.outputsProvider.map(provider => provider.clearHighlight()) | |
| - ); | |
| + await Promise.all(this.outputsProvider.map(provider => provider.clearHighlight())); | |
| } | |
| /** | |
| @@ -171,10 +169,7 @@ class CodeCellSearchProvider extends CellSearchProvider { | |
| super.matchesCount + | |
| this.outputsProvider | |
| .slice(0, this.currentProviderIndex) | |
| - .reduce( | |
| - (sum, provider) => (sum += provider.matchesCount ?? 0), | |
| - 0 | |
| - ) + | |
| + .reduce((sum, provider) => (sum += provider.matchesCount ?? 0), 0) + | |
| provider.currentMatchIndex!; | |
| return match; | |
| } else { | |
| @@ -210,10 +205,7 @@ class CodeCellSearchProvider extends CellSearchProvider { | |
| super.matchesCount + | |
| this.outputsProvider | |
| .slice(0, this.currentProviderIndex) | |
| - .reduce( | |
| - (sum, provider) => (sum += provider.matchesCount ?? 0), | |
| - 0 | |
| - ) + | |
| + .reduce((sum, provider) => (sum += provider.matchesCount ?? 0), 0) + | |
| provider.currentMatchIndex!; | |
| return match; | |
| } else { | |
| @@ -253,9 +245,7 @@ class CodeCellSearchProvider extends CellSearchProvider { | |
| async endQuery(): Promise<void> { | |
| await super.endQuery(); | |
| if (this.filters?.output !== false && this.isActive) { | |
| - await Promise.all( | |
| - this.outputsProvider.map(provider => provider.endQuery()) | |
| - ); | |
| + await Promise.all(this.outputsProvider.map(provider => provider.endQuery())); | |
| } | |
| } | |
| @@ -269,8 +259,7 @@ class CodeCellSearchProvider extends CellSearchProvider { | |
| newText: string, | |
| options?: IReplaceOptions | |
| ): Promise<boolean> { | |
| - if (this.model.getMetadata('editable') === false) | |
| - return Promise.resolve(false); | |
| + if (this.model.getMetadata('editable') === false) return Promise.resolve(false); | |
| const result = await super.replaceAllMatches(newText, options); | |
| return result; | |
| @@ -288,8 +277,7 @@ class CodeCellSearchProvider extends CellSearchProvider { | |
| loop?: boolean, | |
| options?: IReplaceOptions | |
| ): Promise<boolean> { | |
| - if (this.model.getMetadata('editable') === false) | |
| - return Promise.resolve(false); | |
| + if (this.model.getMetadata('editable') === false) return Promise.resolve(false); | |
| const result = await super.replaceCurrentMatch(newText, loop, options); | |
| return result; | |
| @@ -335,9 +323,7 @@ class MarkdownCellSearchProvider extends CellSearchProvider { | |
| */ | |
| constructor(cell: Cell<ICellModel>) { | |
| super(cell); | |
| - this.renderedProvider = new GenericSearchProvider( | |
| - (cell as MarkdownCell).renderer | |
| - ); | |
| + this.renderedProvider = new GenericSearchProvider((cell as MarkdownCell).renderer); | |
| } | |
| /** | |
| @@ -442,8 +428,7 @@ class MarkdownCellSearchProvider extends CellSearchProvider { | |
| newText: string, | |
| options?: IReplaceOptions | |
| ): Promise<boolean> { | |
| - if (this.model.getMetadata('editable') === false) | |
| - return Promise.resolve(false); | |
| + if (this.model.getMetadata('editable') === false) return Promise.resolve(false); | |
| const result = await super.replaceAllMatches(newText, options); | |
| // if the cell is rendered force update | |
| @@ -465,8 +450,7 @@ class MarkdownCellSearchProvider extends CellSearchProvider { | |
| loop?: boolean, | |
| options?: IReplaceOptions | |
| ): Promise<boolean> { | |
| - if (this.model.getMetadata('editable') === false) | |
| - return Promise.resolve(false); | |
| + if (this.model.getMetadata('editable') === false) return Promise.resolve(false); | |
| const result = await super.replaceCurrentMatch(newText, loop, options); | |
| return result; | |
| @@ -504,9 +488,7 @@ class MarkdownCellSearchProvider extends CellSearchProvider { | |
| * @param cell Cell widget | |
| * @returns Cell search provider | |
| */ | |
| -export function createCellSearchProvider( | |
| - cell: Cell<ICellModel> | |
| -): CellSearchProvider { | |
| +export function createCellSearchProvider(cell: Cell<ICellModel>): CellSearchProvider { | |
| if (cell.isPlaceholder()) { | |
| return new CellSearchProvider(cell); | |
| } | |
| diff --git a/packages/cells/src/testutils.ts b/packages/cells/src/testutils.ts | |
| index 05cf376210..f66343a755 100644 | |
| --- a/packages/cells/src/testutils.ts | |
| +++ b/packages/cells/src/testutils.ts | |
| @@ -26,10 +26,9 @@ export namespace NBTestUtils { | |
| }; | |
| })(); | |
| - export const editorFactory = | |
| - editorServices.factoryService.newInlineEditor.bind( | |
| - editorServices.factoryService | |
| - ); | |
| + export const editorFactory = editorServices.factoryService.newInlineEditor.bind( | |
| + editorServices.factoryService | |
| + ); | |
| export const mimeTypeService = editorServices.mimeTypeService; | |
| /** | |
| diff --git a/packages/cells/src/widget.ts b/packages/cells/src/widget.ts | |
| index fb32390839..db123ea9ac 100644 | |
| --- a/packages/cells/src/widget.ts | |
| +++ b/packages/cells/src/widget.ts | |
| @@ -395,8 +395,7 @@ export class Cell<T extends ICellModel = ICellModel> extends Widget { | |
| */ | |
| loadEditableState(): void { | |
| this.readOnly = | |
| - (this.model.sharedModel.getMetadata('editable') as unknown as boolean) === | |
| - false; | |
| + (this.model.sharedModel.getMetadata('editable') as unknown as boolean) === false; | |
| } | |
| /** | |
| @@ -623,9 +622,7 @@ export class Cell<T extends ICellModel = ICellModel> extends Widget { | |
| input.model.contentChanged.connect((sender, args) => { | |
| if (this._inputPlaceholder && this.inputHidden) { | |
| - this._inputPlaceholder.text = sender.sharedModel | |
| - .getSource() | |
| - .split('\n')?.[0]; | |
| + this._inputPlaceholder.text = sender.sharedModel.getSource().split('\n')?.[0]; | |
| } | |
| }); | |
| @@ -694,9 +691,7 @@ export class Cell<T extends ICellModel = ICellModel> extends Widget { | |
| protected onContentChanged() { | |
| if (this.inputHidden && this._inputPlaceholder) { | |
| - this._inputPlaceholder.text = this.model.sharedModel | |
| - .getSource() | |
| - .split('\n')?.[0]; | |
| + this._inputPlaceholder.text = this.model.sharedModel.getSource().split('\n')?.[0]; | |
| } | |
| } | |
| @@ -760,9 +755,7 @@ export class Cell<T extends ICellModel = ICellModel> extends Widget { | |
| private _inputHidden = false; | |
| private _inputWrapper: Widget | null; | |
| private _inputPlaceholder: InputPlaceholder | null; | |
| - private _inViewportChanged: Signal<Cell, boolean> = new Signal<Cell, boolean>( | |
| - this | |
| - ); | |
| + private _inViewportChanged: Signal<Cell, boolean> = new Signal<Cell, boolean>(this); | |
| private _model: T; | |
| private _placeholder: boolean; | |
| private _readOnly = false; | |
| @@ -1052,10 +1045,7 @@ export class CodeCellLayout extends PanelLayout { | |
| // TODO we could improve this further by removing outputs based | |
| // on their mime type (for example plain/text or markdown could safely be detached) | |
| // If the cell is out of the view port, its children are already detached -> skip detaching | |
| - if ( | |
| - !widget.hasClass(CELL_OUTPUT_WRAPPER_CLASS) && | |
| - widget.node.isConnected | |
| - ) { | |
| + if (!widget.hasClass(CELL_OUTPUT_WRAPPER_CLASS) && widget.node.isConnected) { | |
| // Not called in NotebookWindowedLayout for windowed notebook | |
| MessageLoop.sendMessage(widget, Widget.Msg.BeforeDetach); | |
| @@ -1148,10 +1138,7 @@ export class CodeCell extends Cell<ICodeCellModel> { | |
| 'selectionchange', | |
| this._lastOnCaretMovedHandler | |
| ); | |
| - document.removeEventListener( | |
| - 'selectionchange', | |
| - this._lastOnCaretMovedHandler | |
| - ); | |
| + document.removeEventListener('selectionchange', this._lastOnCaretMovedHandler); | |
| } | |
| const onCaretMoved = () => { | |
| @@ -1465,10 +1452,7 @@ export class CodeCell extends Cell<ICodeCellModel> { | |
| * Update the Prompt Overlay Icon | |
| */ | |
| updatePromptOverlayIcon(): void { | |
| - const overlay = DOMUtils.findElement( | |
| - this.node, | |
| - 'jp-OutputArea-promptOverlay' | |
| - ); | |
| + const overlay = DOMUtils.findElement(this.node, 'jp-OutputArea-promptOverlay'); | |
| if (!overlay) { | |
| return; | |
| } | |
| @@ -1592,14 +1576,8 @@ export class CodeCell extends Cell<ICodeCellModel> { | |
| if (this.isDisposed) { | |
| return; | |
| } | |
| - this._output.outputLengthChanged.disconnect( | |
| - this._outputLengthHandler, | |
| - this | |
| - ); | |
| - this._output.node.removeEventListener( | |
| - 'keydown', | |
| - this._detectCaretMovementInOuput | |
| - ); | |
| + this._output.outputLengthChanged.disconnect(this._outputLengthHandler, this); | |
| + this._output.node.removeEventListener('keydown', this._detectCaretMovementInOuput); | |
| this._rendermime = null!; | |
| this._output = null!; | |
| this._outputWrapper = null!; | |
| @@ -1772,10 +1750,7 @@ export namespace CodeCell { | |
| model.executionState = 'running'; | |
| model.trusted = true; | |
| let future: | |
| - | Kernel.IFuture< | |
| - KernelMessage.IExecuteRequestMsg, | |
| - KernelMessage.IExecuteReplyMsg | |
| - > | |
| + | Kernel.IFuture<KernelMessage.IExecuteRequestMsg, KernelMessage.IExecuteReplyMsg> | |
| | undefined; | |
| try { | |
| const msgPromise = OutputArea.execute( | |
| @@ -1803,10 +1778,7 @@ export namespace CodeCell { | |
| // If the data is missing, estimate it to now | |
| // Date was added in 5.1: https://jupyter-client.readthedocs.io/en/stable/messaging.html#message-header | |
| const value = msg.header.date || new Date().toISOString(); | |
| - const timingInfo: any = Object.assign( | |
| - {}, | |
| - model.getMetadata('execution') | |
| - ); | |
| + const timingInfo: any = Object.assign({}, model.getMetadata('execution')); | |
| timingInfo[`iopub.${label}`] = value; | |
| model.setMetadata('execution', timingInfo); | |
| return true; | |
| @@ -1820,10 +1792,7 @@ export namespace CodeCell { | |
| const msg = (await msgPromise)!; | |
| model.executionCount = msg.content.execution_count; | |
| if (recordTiming) { | |
| - const timingInfo = Object.assign( | |
| - {}, | |
| - model.getMetadata('execution') as any | |
| - ); | |
| + const timingInfo = Object.assign({}, model.getMetadata('execution') as any); | |
| const started = msg.metadata.started as string; | |
| // Started is not in the API, but metadata IPyKernel sends | |
| if (started) { | |
| @@ -1831,8 +1800,7 @@ export namespace CodeCell { | |
| } | |
| // Per above, the 5.0 spec does not assume date, so we estimate is required | |
| const finished = msg.header.date as string; | |
| - timingInfo['shell.execute_reply'] = | |
| - finished || new Date().toISOString(); | |
| + timingInfo['shell.execute_reply'] = finished || new Date().toISOString(); | |
| model.setMetadata('execution', timingInfo); | |
| } | |
| return msg; | |
| @@ -1843,10 +1811,7 @@ export namespace CodeCell { | |
| cell.model.executionState = 'idle'; | |
| if (recordTiming && future.isDisposed) { | |
| // Record the time when the cell execution was aborted | |
| - const timingInfo: any = Object.assign( | |
| - {}, | |
| - model.getMetadata('execution') | |
| - ); | |
| + const timingInfo: any = Object.assign({}, model.getMetadata('execution')); | |
| timingInfo['execution_failed'] = new Date().toISOString(); | |
| model.setMetadata('execution', timingInfo); | |
| } | |
| @@ -1860,9 +1825,7 @@ export namespace CodeCell { | |
| * `AttachmentsCell` - A base class for a cell widget that allows | |
| * attachments to be drag/drop'd or pasted onto it | |
| */ | |
| -export abstract class AttachmentsCell< | |
| - T extends IAttachmentsCellModel | |
| -> extends Cell<T> { | |
| +export abstract class AttachmentsCell<T extends IAttachmentsCellModel> extends Cell<T> { | |
| /** | |
| * Handle the DOM events for the widget. | |
| * | |
| @@ -2006,9 +1969,7 @@ export abstract class AttachmentsCell< | |
| const data = event.mimeData.getData( | |
| CONTENTS_MIME_RICH | |
| ) as DirListing.IContentsThunk; | |
| - return ( | |
| - imageRendererFactory.mimeTypes.indexOf(data.model.mimetype) !== -1 | |
| - ); | |
| + return imageRendererFactory.mimeTypes.indexOf(data.model.mimetype) !== -1; | |
| } | |
| return imageRendererFactory.mimeTypes.indexOf(mimeType) !== -1; | |
| }); | |
| @@ -2143,9 +2104,8 @@ export class MarkdownCell extends AttachmentsCell<IMarkdownCellModel> { | |
| this._renderer.addClass(MARKDOWN_OUTPUT_CLASS); | |
| // Check if heading cell is set to be collapsed | |
| - this._headingCollapsed = (this.model.getMetadata( | |
| - MARKDOWN_HEADING_COLLAPSED | |
| - ) ?? false) as boolean; | |
| + this._headingCollapsed = (this.model.getMetadata(MARKDOWN_HEADING_COLLAPSED) ?? | |
| + false) as boolean; | |
| this._showEditorForReadOnlyMarkdown = | |
| options.showEditorForReadOnlyMarkdown ?? | |
| @@ -2240,9 +2200,7 @@ export class MarkdownCell extends AttachmentsCell<IMarkdownCellModel> { | |
| this._headingCollapsed = value; | |
| if (value) { | |
| this.model.setMetadata(MARKDOWN_HEADING_COLLAPSED, value); | |
| - } else if ( | |
| - this.model.getMetadata(MARKDOWN_HEADING_COLLAPSED) !== 'undefined' | |
| - ) { | |
| + } else if (this.model.getMetadata(MARKDOWN_HEADING_COLLAPSED) !== 'undefined') { | |
| this.model.deleteMetadata(MARKDOWN_HEADING_COLLAPSED); | |
| } | |
| const collapseButton = this.inputArea?.promptNode.getElementsByClassName( | |
| @@ -2419,9 +2377,7 @@ export class MarkdownCell extends AttachmentsCell<IMarkdownCellModel> { | |
| if (needToUpdateButtonText) { | |
| showHiddenCellsButtonList[0].childNodes[1].textContent = buttonText; | |
| } | |
| - let needToRemoveButton = !( | |
| - this.headingCollapsed && this._numberChildNodes > 0 | |
| - ); | |
| + let needToRemoveButton = !(this.headingCollapsed && this._numberChildNodes > 0); | |
| if (needToRemoveButton) { | |
| for (const button of showHiddenCellsButtonList) { | |
| this.node.removeChild(button); | |
| @@ -2450,10 +2406,7 @@ export class MarkdownCell extends AttachmentsCell<IMarkdownCellModel> { | |
| * button. | |
| */ | |
| protected renderCollapseButtons(widget?: Widget): void { | |
| - this.node.classList.toggle( | |
| - MARKDOWN_HEADING_COLLAPSED, | |
| - this._headingCollapsed | |
| - ); | |
| + this.node.classList.toggle(MARKDOWN_HEADING_COLLAPSED, this._headingCollapsed); | |
| this.maybeCreateCollapseButton(); | |
| this.maybeCreateOrUpdateExpandButton(); | |
| } | |
| @@ -2477,9 +2430,8 @@ export class MarkdownCell extends AttachmentsCell<IMarkdownCellModel> { | |
| if (!this.placeholder && !this.isDisposed) { | |
| this.inputArea!.showEditor(); | |
| // if this is going to be a heading, place the cursor accordingly | |
| - let numHashAtStart = (this.model.sharedModel | |
| - .getSource() | |
| - .match(/^#+/g) || [''])[0].length; | |
| + let numHashAtStart = (this.model.sharedModel.getSource().match(/^#+/g) || [''])[0] | |
| + .length; | |
| if (numHashAtStart > 0) { | |
| this.inputArea!.editor.setCursorPosition( | |
| { | |
| @@ -2506,10 +2458,7 @@ export class MarkdownCell extends AttachmentsCell<IMarkdownCellModel> { | |
| /** | |
| * Modify the cell source to include a reference to the attachment. | |
| */ | |
| - protected updateCellSourceWithAttachment( | |
| - attachmentName: string, | |
| - URI?: string | |
| - ): void { | |
| + protected updateCellSourceWithAttachment(attachmentName: string, URI?: string): void { | |
| const textToBeAppended = ``; | |
| @@ -2543,8 +2492,7 @@ export class MarkdownCell extends AttachmentsCell<IMarkdownCellModel> { | |
| } | |
| const model = this.model; | |
| - const text = | |
| - (model && model.sharedModel.getSource()) || this._emptyPlaceholder; | |
| + const text = (model && model.sharedModel.getSource()) || this._emptyPlaceholder; | |
| // Do not re-render if the text has not changed. | |
| if (text !== this._prevText) { | |
| const mimeModel = new MimeModel({ data: { 'text/markdown': text } }); | |
| diff --git a/packages/cells/style/widget.css b/packages/cells/style/widget.css | |
| index 771adb77f8..ab5cf24630 100644 | |
| --- a/packages/cells/style/widget.css | |
| +++ b/packages/cells/style/widget.css | |
| @@ -103,10 +103,7 @@ | |
| var(--jp-cell-prompt-width) - var(--jp-private-cell-scrolling-output-offset) | |
| ); | |
| flex: 0 0 | |
| - calc( | |
| - var(--jp-cell-prompt-width) - | |
| - var(--jp-private-cell-scrolling-output-offset) | |
| - ); | |
| + calc(var(--jp-cell-prompt-width) - var(--jp-private-cell-scrolling-output-offset)); | |
| } | |
| .jp-CodeCell.jp-mod-outputsScrolled .jp-OutputArea-promptOverlay { | |
| diff --git a/packages/cells/test/model.spec.ts b/packages/cells/test/model.spec.ts | |
| index 499a32081c..05d5fd4981 100644 | |
| --- a/packages/cells/test/model.spec.ts | |
| +++ b/packages/cells/test/model.spec.ts | |
| @@ -625,9 +625,7 @@ describe('cells/model', () => { | |
| } as any; | |
| model['onOutputsChange'](null as any, newEvent0); | |
| expect(sharedModel.ymodel.get('outputs').length).toBe(1); | |
| - expect(sharedModel.ymodel.get('outputs').get(0).toJSON()).toEqual( | |
| - output0 | |
| - ); | |
| + expect(sharedModel.ymodel.get('outputs').get(0).toJSON()).toEqual(output0); | |
| const newEvent1 = { | |
| type: 'add', | |
| @@ -638,9 +636,7 @@ describe('cells/model', () => { | |
| } as any; | |
| model['onOutputsChange'](null as any, newEvent1); | |
| expect(sharedModel.ymodel.get('outputs').length).toBe(2); | |
| - expect(sharedModel.ymodel.get('outputs').get(1).toJSON()).toEqual( | |
| - output1 | |
| - ); | |
| + expect(sharedModel.ymodel.get('outputs').get(1).toJSON()).toEqual(output1); | |
| }); | |
| it('should set new items correctly', () => { | |
| @@ -659,9 +655,7 @@ describe('cells/model', () => { | |
| } as any; | |
| model['onOutputsChange'](null as any, newEvent0); | |
| expect(sharedModel.ymodel.get('outputs').length).toBe(2); | |
| - expect(sharedModel.ymodel.get('outputs').get(0).toJSON()).toEqual( | |
| - output2 | |
| - ); | |
| + expect(sharedModel.ymodel.get('outputs').get(0).toJSON()).toEqual(output2); | |
| const newEvent1 = { | |
| type: 'set', | |
| newValues: [{ toJSON: () => output2 }], | |
| @@ -671,9 +665,7 @@ describe('cells/model', () => { | |
| } as any; | |
| model['onOutputsChange'](null as any, newEvent1); | |
| expect(sharedModel.ymodel.get('outputs').length).toBe(2); | |
| - expect(sharedModel.ymodel.get('outputs').get(1).toJSON()).toEqual( | |
| - output2 | |
| - ); | |
| + expect(sharedModel.ymodel.get('outputs').get(1).toJSON()).toEqual(output2); | |
| }); | |
| it('should remove items correctly', () => { | |
| diff --git a/packages/cells/test/widget.spec.ts b/packages/cells/test/widget.spec.ts | |
| index 54116da21d..6fc39345b4 100644 | |
| --- a/packages/cells/test/widget.spec.ts | |
| +++ b/packages/cells/test/widget.spec.ts | |
| @@ -24,11 +24,7 @@ import { CodeEditorWrapper } from '@jupyterlab/codeeditor'; | |
| import { OutputArea, OutputPrompt } from '@jupyterlab/outputarea'; | |
| import { defaultRenderMime } from '@jupyterlab/rendermime/lib/testutils'; | |
| import type { IExecuteReplyMsg } from '@jupyterlab/services/lib/kernel/messages'; | |
| -import { | |
| - framePromise, | |
| - JupyterServer, | |
| - signalToPromise | |
| -} from '@jupyterlab/testing'; | |
| +import { framePromise, JupyterServer, signalToPromise } from '@jupyterlab/testing'; | |
| import type { Message } from '@lumino/messaging'; | |
| import { MessageLoop } from '@lumino/messaging'; | |
| import { Widget } from '@lumino/widgets'; | |
| @@ -904,9 +900,7 @@ describe('cells/widget', () => { | |
| placeholder: false | |
| }); | |
| widget.initializeState(); | |
| - await expect( | |
| - CodeCell.execute(widget, sessionContext) | |
| - ).resolves.not.toThrow(); | |
| + await expect(CodeCell.execute(widget, sessionContext)).resolves.not.toThrow(); | |
| }); | |
| it('should fulfill a promise if there is code to execute', async () => { | |
| @@ -1076,9 +1070,7 @@ describe('cells/widget', () => { | |
| const event = new ClipboardEvent('paste', { clipboardData: dt }); | |
| widget.editor!.host.querySelector('.cm-content')!.dispatchEvent(event); | |
| - expect(widget.model.sharedModel.getSource()).toEqual( | |
| - '\nTest\nString\n.\n' | |
| - ); | |
| + expect(widget.model.sharedModel.getSource()).toEqual('\nTest\nString\n.\n'); | |
| }); | |
| }); | |
| diff --git a/packages/celltags-extension/src/celltag.tsx b/packages/celltags-extension/src/celltag.tsx | |
| index 6931acc96e..8b66f2747b 100644 | |
| --- a/packages/celltags-extension/src/celltag.tsx | |
| +++ b/packages/celltags-extension/src/celltag.tsx | |
| @@ -129,10 +129,7 @@ export class CellTagField { | |
| } | |
| } | |
| - private _onAddTagClick( | |
| - props: FieldProps, | |
| - event: React.MouseEvent<HTMLElement> | |
| - ) { | |
| + private _onAddTagClick(props: FieldProps, event: React.MouseEvent<HTMLElement>) { | |
| const elem = (event.target as HTMLElement).closest('div'); | |
| const input = elem?.childNodes[0] as HTMLInputElement; | |
| if (!this._editing) { | |
| diff --git a/packages/celltags-extension/src/index.ts b/packages/celltags-extension/src/index.ts | |
| index 11e46b9480..5cd609b2f2 100644 | |
| --- a/packages/celltags-extension/src/index.ts | |
| +++ b/packages/celltags-extension/src/index.ts | |
| @@ -6,10 +6,7 @@ | |
| */ | |
| import type { FieldProps } from '@rjsf/utils'; | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { INotebookTracker } from '@jupyterlab/notebook'; | |
| diff --git a/packages/codeeditor/src/editor.ts b/packages/codeeditor/src/editor.ts | |
| index 60d3f2e948..884922074a 100644 | |
| --- a/packages/codeeditor/src/editor.ts | |
| +++ b/packages/codeeditor/src/editor.ts | |
| @@ -170,8 +170,7 @@ export namespace CodeEditor { | |
| // Track if we need to dispose the model or not. | |
| this.standaloneModel = typeof options.sharedModel === 'undefined'; | |
| this.sharedModel = options.sharedModel ?? new YFile(); | |
| - this._mimeType = | |
| - options.mimeType ?? IEditorMimeTypeService.defaultMimeType; | |
| + this._mimeType = options.mimeType ?? IEditorMimeTypeService.defaultMimeType; | |
| } | |
| /** | |
| @@ -268,10 +267,7 @@ export namespace CodeEditor { | |
| * #### Notes | |
| * This will remove any secondary cursors. | |
| */ | |
| - setCursorPosition( | |
| - position: IPosition, | |
| - options?: { scroll?: boolean } | |
| - ): void; | |
| + setCursorPosition(position: IPosition, options?: { scroll?: boolean }): void; | |
| /** | |
| * Returns the primary selection, never `null`. | |
| @@ -313,10 +309,7 @@ export namespace CodeEditor { | |
| * Return `true` to prevent the default handling of the event by the | |
| * editor. | |
| */ | |
| - export type KeydownHandler = ( | |
| - instance: IEditor, | |
| - event: KeyboardEvent | |
| - ) => boolean; | |
| + export type KeydownHandler = (instance: IEditor, event: KeyboardEvent) => boolean; | |
| /** | |
| * The location of requested edges. | |
| diff --git a/packages/codeeditor/src/lineCol.tsx b/packages/codeeditor/src/lineCol.tsx | |
| index 26584bbf69..590e4be527 100644 | |
| --- a/packages/codeeditor/src/lineCol.tsx | |
| +++ b/packages/codeeditor/src/lineCol.tsx | |
| @@ -132,14 +132,8 @@ class LineFormComponent extends React.Component< | |
| /> | |
| </div> | |
| </div> | |
| - <label | |
| - className="jp-lineFormCaption" | |
| - htmlFor={this.state.textInputId} | |
| - > | |
| - {this._trans.__( | |
| - 'Go to line number between 1 and %1', | |
| - this.props.maxLine | |
| - )} | |
| + <label className="jp-lineFormCaption" htmlFor={this.state.textInputId}> | |
| + {this._trans.__('Go to line number between 1 and %1', this.props.maxLine)} | |
| </label> | |
| </form> | |
| </div> | |
| @@ -160,12 +154,7 @@ class LineFormComponent extends React.Component< | |
| event.preventDefault(); | |
| const value = parseInt(this._textInput!.value, 10); | |
| - if ( | |
| - !isNaN(value) && | |
| - isFinite(value) && | |
| - 1 <= value && | |
| - value <= this.props.maxLine | |
| - ) { | |
| + if (!isNaN(value) && isFinite(value) && 1 <= value && value <= this.props.maxLine) { | |
| this.props.handleSubmit(value); | |
| } | |
| @@ -232,11 +221,7 @@ function LineColComponent( | |
| const translator = props.translator || nullTranslator; | |
| const trans = translator.load('jupyterlab'); | |
| const keydownHandler = (event: React.KeyboardEvent<HTMLImageElement>) => { | |
| - if ( | |
| - event.key === 'Enter' || | |
| - event.key === 'Spacebar' || | |
| - event.key === ' ' | |
| - ) { | |
| + if (event.key === 'Enter' || event.key === 'Spacebar' || event.key === ' ') { | |
| event.preventDefault(); | |
| event.stopPropagation(); | |
| props.handleClick(); | |
| @@ -390,10 +375,7 @@ export namespace LineCol { | |
| return [this._line, this._column]; | |
| } | |
| - private _triggerChange( | |
| - oldState: [number, number], | |
| - newState: [number, number] | |
| - ) { | |
| + private _triggerChange(oldState: [number, number], newState: [number, number]) { | |
| if (oldState[0] !== newState[0] || oldState[1] !== newState[1]) { | |
| this.stateChanged.emit(void 0); | |
| } | |
| diff --git a/packages/codeeditor/src/tokens.ts b/packages/codeeditor/src/tokens.ts | |
| index 2d4d3dc1c0..d5b9897a5d 100644 | |
| --- a/packages/codeeditor/src/tokens.ts | |
| +++ b/packages/codeeditor/src/tokens.ts | |
| @@ -20,8 +20,7 @@ export const COMPLETER_ACTIVE_CLASS: string = 'jp-mod-completer-active'; | |
| /** | |
| * A class added to editors that have a cursor at the beginning of the line. | |
| */ | |
| -export const COMPLETER_LINE_BEGINNING_CLASS: string = | |
| - 'jp-mod-at-line-beginning'; | |
| +export const COMPLETER_LINE_BEGINNING_CLASS: string = 'jp-mod-at-line-beginning'; | |
| /** | |
| * Code editor services token. | |
| diff --git a/packages/codeeditor/src/viewer.ts b/packages/codeeditor/src/viewer.ts | |
| index 6d56f630a3..0314c76d5d 100644 | |
| --- a/packages/codeeditor/src/viewer.ts | |
| +++ b/packages/codeeditor/src/viewer.ts | |
| @@ -27,9 +27,7 @@ export class CodeViewerWidget extends Widget { | |
| layout.addWidget(editorWidget); | |
| } | |
| - static createCodeViewer( | |
| - options: CodeViewerWidget.INoModelOptions | |
| - ): CodeViewerWidget { | |
| + static createCodeViewer(options: CodeViewerWidget.INoModelOptions): CodeViewerWidget { | |
| const { content, mimeType, ...others } = options; | |
| const model = new CodeEditor.Model({ | |
| mimeType | |
| diff --git a/packages/codeeditor/src/widget.ts b/packages/codeeditor/src/widget.ts | |
| index 23cef93f24..410fb95ce9 100644 | |
| --- a/packages/codeeditor/src/widget.ts | |
| +++ b/packages/codeeditor/src/widget.ts | |
| @@ -143,10 +143,7 @@ export class CodeEditorWrapper extends Widget { | |
| this.removeClass(HAS_SELECTION_CLASS); | |
| if ( | |
| - this.editor | |
| - .getLine(end.line)! | |
| - .slice(0, end.column) | |
| - .match(leadingWhitespaceRe) | |
| + this.editor.getLine(end.line)!.slice(0, end.column).match(leadingWhitespaceRe) | |
| ) { | |
| this.addClass(HAS_IN_LEADING_WHITESPACE_CLASS); | |
| } else { | |
| diff --git a/packages/codeeditor/test/jsoneditor.spec.ts b/packages/codeeditor/test/jsoneditor.spec.ts | |
| index fe7b13a50e..79f8811ed2 100644 | |
| --- a/packages/codeeditor/test/jsoneditor.spec.ts | |
| +++ b/packages/codeeditor/test/jsoneditor.spec.ts | |
| @@ -225,9 +225,7 @@ describe('codeeditor', () => { | |
| editor.model.sharedModel.setSource('foo'); | |
| editor.source.set('foo', 1); | |
| simulate(editor.revertButtonNode, 'click'); | |
| - expect(editor.model.sharedModel.getSource()).toBe( | |
| - '{\n "foo": 1\n}' | |
| - ); | |
| + expect(editor.model.sharedModel.getSource()).toBe('{\n "foo": 1\n}'); | |
| }); | |
| it('should handle click events on the commit button', () => { | |
| @@ -248,9 +246,7 @@ describe('codeeditor', () => { | |
| editor.model.sharedModel.setSource('{"foo": 2}'); | |
| editor.source.set('foo', 1); | |
| simulate(editor.commitButtonNode, 'click'); | |
| - expect(editor.model.sharedModel.getSource()).toBe( | |
| - '{\n "foo": 2\n}' | |
| - ); | |
| + expect(editor.model.sharedModel.getSource()).toBe('{\n "foo": 2\n}'); | |
| }); | |
| it('should allow a programmatic key to update', () => { | |
| @@ -281,9 +277,7 @@ describe('codeeditor', () => { | |
| editor.source.set('bar', 1); | |
| editor.model.sharedModel.setSource('{"foo": 1}'); | |
| simulate(editor.commitButtonNode, 'click'); | |
| - expect(editor.model.sharedModel.getSource()).toBe( | |
| - '{\n "foo": 1\n}' | |
| - ); | |
| + expect(editor.model.sharedModel.getSource()).toBe('{\n "foo": 1\n}'); | |
| }); | |
| it('should allow a key to be removed programmatically that was not set by the user', () => { | |
| @@ -293,9 +287,7 @@ describe('codeeditor', () => { | |
| editor.model.sharedModel.setSource('{"foo": 1, "bar": 3}'); | |
| editor.source.delete('foo'); | |
| simulate(editor.commitButtonNode, 'click'); | |
| - expect(editor.model.sharedModel.getSource()).toBe( | |
| - '{\n "bar": 3\n}' | |
| - ); | |
| + expect(editor.model.sharedModel.getSource()).toBe('{\n "bar": 3\n}'); | |
| }); | |
| it('should keep a key that was removed programmatically that was changed by the user', () => { | |
| @@ -314,9 +306,7 @@ describe('codeeditor', () => { | |
| describe('#onAfterAttach()', () => { | |
| it('should add event listeners', () => { | |
| Widget.attach(editor, document.body); | |
| - expect(editor.methods).toEqual( | |
| - expect.arrayContaining(['onAfterAttach']) | |
| - ); | |
| + expect(editor.methods).toEqual(expect.arrayContaining(['onAfterAttach'])); | |
| editor.editor.focus(); | |
| simulate(editor.editorHostNode, 'blur'); | |
| simulate(editor.revertButtonNode, 'click'); | |
| @@ -329,9 +319,7 @@ describe('codeeditor', () => { | |
| it('should remove event listeners', () => { | |
| Widget.attach(editor, document.body); | |
| Widget.detach(editor); | |
| - expect(editor.methods).toEqual( | |
| - expect.arrayContaining(['onBeforeDetach']) | |
| - ); | |
| + expect(editor.methods).toEqual(expect.arrayContaining(['onBeforeDetach'])); | |
| editor.editor.focus(); | |
| simulate(editor.editorHostNode, 'blur'); | |
| simulate(editor.revertButtonNode, 'click'); | |
| diff --git a/packages/codemirror-extension/src/commands.ts b/packages/codemirror-extension/src/commands.ts | |
| index 4ae34f6946..09060cb369 100644 | |
| --- a/packages/codemirror-extension/src/commands.ts | |
| +++ b/packages/codemirror-extension/src/commands.ts | |
| @@ -22,10 +22,7 @@ import { | |
| import { EditorSelection } from '@codemirror/state'; | |
| import { EditorView } from '@codemirror/view'; | |
| import { selectNextOccurrence } from '@codemirror/search'; | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { ITranslator, nullTranslator } from '@jupyterlab/translation'; | |
| import { INotebookTracker } from '@jupyterlab/notebook'; | |
| import { ICommandPalette } from '@jupyterlab/apputils'; | |
| @@ -58,8 +55,7 @@ const CODE_MIRROR_SELECTOR = '.cm-content'; | |
| */ | |
| export const commandsPlugin: JupyterFrontEndPlugin<void> = { | |
| id: '@jupyterlab/codemirror-extension:commands', | |
| - description: | |
| - 'Registers commands acting on selected/active CodeMirror editor.', | |
| + description: 'Registers commands acting on selected/active CodeMirror editor.', | |
| autoStart: true, | |
| requires: [INotebookTracker], | |
| optional: [ITranslator, ICommandPalette], | |
| diff --git a/packages/codemirror-extension/src/index.ts b/packages/codemirror-extension/src/index.ts | |
| index 32ce2a8af4..59df082e86 100644 | |
| --- a/packages/codemirror-extension/src/index.ts | |
| +++ b/packages/codemirror-extension/src/index.ts | |
| @@ -5,10 +5,7 @@ | |
| * @module codemirror-extension | |
| */ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { ILabShell } from '@jupyterlab/application'; | |
| import type { CodeEditor } from '@jupyterlab/codeeditor'; | |
| import { IPositionModel, LineCol } from '@jupyterlab/codeeditor'; | |
| @@ -83,8 +80,7 @@ export const lineColItem: JupyterFrontEndPlugin<IPositionModel> = { | |
| ) { | |
| Promise.all([...providers].map(provider => provider(changes.newValue))) | |
| .then(editors => { | |
| - item.model.editor = | |
| - editors.filter(editor => editor !== null)[0] ?? null; | |
| + item.model.editor = editors.filter(editor => editor !== null)[0] ?? null; | |
| }) | |
| .catch(reason => { | |
| console.error('Get editors', reason); | |
| diff --git a/packages/codemirror-extension/src/services.tsx b/packages/codemirror-extension/src/services.tsx | |
| index cc12e6a087..936d42b4e1 100644 | |
| --- a/packages/codemirror-extension/src/services.tsx | |
| +++ b/packages/codemirror-extension/src/services.tsx | |
| @@ -5,10 +5,7 @@ | |
| import { LanguageSupport, StreamLanguage } from '@codemirror/language'; | |
| import type { IYText } from '@jupyter/ydoc'; | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { IEditorServices } from '@jupyterlab/codeeditor'; | |
| import { | |
| CodeMirrorEditorFactory, | |
| @@ -25,10 +22,7 @@ import { | |
| } from '@jupyterlab/codemirror'; | |
| import { ISettingRegistry } from '@jupyterlab/settingregistry'; | |
| import { ITranslator, nullTranslator } from '@jupyterlab/translation'; | |
| -import { | |
| - FormComponent, | |
| - IFormRendererRegistry | |
| -} from '@jupyterlab/ui-components'; | |
| +import { FormComponent, IFormRendererRegistry } from '@jupyterlab/ui-components'; | |
| import type { ReadonlyJSONValue } from '@lumino/coreutils'; | |
| import { JSONExt } from '@lumino/coreutils'; | |
| import type { FieldProps } from '@rjsf/utils'; | |
| @@ -73,9 +67,7 @@ export const languagePlugin: JupyterFrontEndPlugin<IEditorLanguageRegistry> = { | |
| const mdlang = m.markdown({ | |
| base: m.markdownLanguage, | |
| codeLanguages: (info: string) => languages.findBest(info) as any, | |
| - extensions: [ | |
| - parseMathIPython(StreamLanguage.define(tex.stexMath).parser) | |
| - ] | |
| + extensions: [parseMathIPython(StreamLanguage.define(tex.stexMath).parser)] | |
| }); | |
| return new LanguageSupport(mdlang.language, [ | |
| mdlang.support, | |
| @@ -108,121 +100,103 @@ export const themePlugin: JupyterFrontEndPlugin<IEditorThemeRegistry> = { | |
| /** | |
| * CodeMirror editor extensions registry provider. | |
| */ | |
| -export const extensionPlugin: JupyterFrontEndPlugin<IEditorExtensionRegistry> = | |
| - { | |
| - id: '@jupyterlab/codemirror-extension:extensions', | |
| - description: 'Provides the CodeMirror extension factory registry.', | |
| - provides: IEditorExtensionRegistry, | |
| - requires: [IEditorThemeRegistry], | |
| - optional: [ITranslator, ISettingRegistry, IFormRendererRegistry], | |
| - activate: ( | |
| - app: JupyterFrontEnd, | |
| - themes: IEditorThemeRegistry, | |
| - translator: ITranslator | null, | |
| - settingRegistry: ISettingRegistry | null, | |
| - formRegistry: IFormRendererRegistry | null | |
| - ): IEditorExtensionRegistry => { | |
| - const registry = new EditorExtensionRegistry(); | |
| +export const extensionPlugin: JupyterFrontEndPlugin<IEditorExtensionRegistry> = { | |
| + id: '@jupyterlab/codemirror-extension:extensions', | |
| + description: 'Provides the CodeMirror extension factory registry.', | |
| + provides: IEditorExtensionRegistry, | |
| + requires: [IEditorThemeRegistry], | |
| + optional: [ITranslator, ISettingRegistry, IFormRendererRegistry], | |
| + activate: ( | |
| + app: JupyterFrontEnd, | |
| + themes: IEditorThemeRegistry, | |
| + translator: ITranslator | null, | |
| + settingRegistry: ISettingRegistry | null, | |
| + formRegistry: IFormRendererRegistry | null | |
| + ): IEditorExtensionRegistry => { | |
| + const registry = new EditorExtensionRegistry(); | |
| - // Register default extensions | |
| - for (const extensionFactory of EditorExtensionRegistry.getDefaultExtensions( | |
| - { | |
| - themes, | |
| - translator | |
| - } | |
| - )) { | |
| - registry.addExtension(extensionFactory); | |
| - } | |
| + // Register default extensions | |
| + for (const extensionFactory of EditorExtensionRegistry.getDefaultExtensions({ | |
| + themes, | |
| + translator | |
| + })) { | |
| + registry.addExtension(extensionFactory); | |
| + } | |
| - if (settingRegistry) { | |
| - const updateSettings = (settings: ISettingRegistry.ISettings) => { | |
| - registry.baseConfiguration = | |
| - (settings.get('defaultConfig').composite as Record<string, any>) ?? | |
| - {}; | |
| - }; | |
| - void Promise.all([ | |
| - settingRegistry.load(SETTINGS_ID), | |
| - app.restored | |
| - ]).then(([settings]) => { | |
| + if (settingRegistry) { | |
| + const updateSettings = (settings: ISettingRegistry.ISettings) => { | |
| + registry.baseConfiguration = | |
| + (settings.get('defaultConfig').composite as Record<string, any>) ?? {}; | |
| + }; | |
| + void Promise.all([settingRegistry.load(SETTINGS_ID), app.restored]).then( | |
| + ([settings]) => { | |
| updateSettings(settings); | |
| settings.changed.connect(updateSettings); | |
| - }); | |
| + } | |
| + ); | |
| - formRegistry?.addRenderer(`${SETTINGS_ID}.defaultConfig`, { | |
| - fieldRenderer: (props: FieldProps) => { | |
| - let defaultFormData: Record<string, any>; | |
| - const properties = React.useMemo( | |
| - () => registry.settingsSchema, | |
| - [] | |
| - ) as any; | |
| - if (props.name in props.formContext.defaultFormData) { | |
| - defaultFormData = props.formContext.defaultFormData[props.name]; | |
| - } else { | |
| - defaultFormData = {}; | |
| - } | |
| - // Only provide customizable options | |
| - for (const [key, value] of Object.entries( | |
| - registry.defaultConfiguration | |
| - )) { | |
| - if ( | |
| - typeof properties[key] !== 'undefined' && | |
| - !(key in defaultFormData) | |
| - ) { | |
| - defaultFormData[key] = value; | |
| - } | |
| + formRegistry?.addRenderer(`${SETTINGS_ID}.defaultConfig`, { | |
| + fieldRenderer: (props: FieldProps) => { | |
| + let defaultFormData: Record<string, any>; | |
| + const properties = React.useMemo(() => registry.settingsSchema, []) as any; | |
| + if (props.name in props.formContext.defaultFormData) { | |
| + defaultFormData = props.formContext.defaultFormData[props.name]; | |
| + } else { | |
| + defaultFormData = {}; | |
| + } | |
| + // Only provide customizable options | |
| + for (const [key, value] of Object.entries(registry.defaultConfiguration)) { | |
| + if (typeof properties[key] !== 'undefined' && !(key in defaultFormData)) { | |
| + defaultFormData[key] = value; | |
| } | |
| - | |
| - return ( | |
| - <div className="jp-FormGroup-contentNormal"> | |
| - <h3 className="jp-FormGroup-fieldLabel jp-FormGroup-contentItem"> | |
| - {props.schema.title} | |
| - </h3> | |
| - {props.schema.description && ( | |
| - <div className="jp-FormGroup-description"> | |
| - {props.schema.description} | |
| - </div> | |
| - )} | |
| - <FormComponent | |
| - schema={{ | |
| - title: props.schema.title, | |
| - description: props.schema.description, | |
| - type: 'object', | |
| - properties, | |
| - additionalProperties: false | |
| - }} | |
| - validator={validatorAjv8} | |
| - formData={{ ...defaultFormData, ...props.formData }} | |
| - formContext={{ defaultFormData }} | |
| - liveValidate | |
| - onChange={e => { | |
| - // Only save non-default values | |
| - const nonDefault: Record<string, ReadonlyJSONValue> = {}; | |
| - for (const [property, value] of Object.entries( | |
| - e.formData ?? {} | |
| - )) { | |
| - const default_ = defaultFormData[property]; | |
| - if ( | |
| - default_ === undefined || | |
| - !JSONExt.deepEqual(value, default_) | |
| - ) { | |
| - nonDefault[property] = value; | |
| - } | |
| - } | |
| - props.onChange(nonDefault); | |
| - }} | |
| - tagName="div" | |
| - translator={translator ?? nullTranslator} | |
| - buttonStyle="icons" | |
| - /> | |
| - </div> | |
| - ); | |
| } | |
| - }); | |
| - } | |
| - return registry; | |
| + return ( | |
| + <div className="jp-FormGroup-contentNormal"> | |
| + <h3 className="jp-FormGroup-fieldLabel jp-FormGroup-contentItem"> | |
| + {props.schema.title} | |
| + </h3> | |
| + {props.schema.description && ( | |
| + <div className="jp-FormGroup-description"> | |
| + {props.schema.description} | |
| + </div> | |
| + )} | |
| + <FormComponent | |
| + schema={{ | |
| + title: props.schema.title, | |
| + description: props.schema.description, | |
| + type: 'object', | |
| + properties, | |
| + additionalProperties: false | |
| + }} | |
| + validator={validatorAjv8} | |
| + formData={{ ...defaultFormData, ...props.formData }} | |
| + formContext={{ defaultFormData }} | |
| + liveValidate | |
| + onChange={e => { | |
| + // Only save non-default values | |
| + const nonDefault: Record<string, ReadonlyJSONValue> = {}; | |
| + for (const [property, value] of Object.entries(e.formData ?? {})) { | |
| + const default_ = defaultFormData[property]; | |
| + if (default_ === undefined || !JSONExt.deepEqual(value, default_)) { | |
| + nonDefault[property] = value; | |
| + } | |
| + } | |
| + props.onChange(nonDefault); | |
| + }} | |
| + tagName="div" | |
| + translator={translator ?? nullTranslator} | |
| + buttonStyle="icons" | |
| + /> | |
| + </div> | |
| + ); | |
| + } | |
| + }); | |
| } | |
| - }; | |
| + | |
| + return registry; | |
| + } | |
| +}; | |
| /** | |
| * CodeMirror shared model binding provider. | |
| diff --git a/packages/codemirror/src/commands.ts b/packages/codemirror/src/commands.ts | |
| index e795317073..c7adc8f3d3 100644 | |
| --- a/packages/codemirror/src/commands.ts | |
| +++ b/packages/codemirror/src/commands.ts | |
| @@ -37,8 +37,7 @@ const TOOLTIP_OPENER_SELECTOR = | |
| /** | |
| * Selector for an active cell in edit mode. | |
| */ | |
| -const ACTIVE_CELL_IN_EDIT_MODE_SELECTOR = | |
| - '.jp-mod-editMode .jp-Cell.jp-mod-active'; | |
| +const ACTIVE_CELL_IN_EDIT_MODE_SELECTOR = '.jp-mod-editMode .jp-Cell.jp-mod-active'; | |
| /** | |
| * CodeMirror commands namespace | |
| diff --git a/packages/codemirror/src/editor.ts b/packages/codemirror/src/editor.ts | |
| index 1cc3a4b21f..8d2f4ac38a 100644 | |
| --- a/packages/codemirror/src/editor.ts | |
| +++ b/packages/codemirror/src/editor.ts | |
| @@ -5,12 +5,7 @@ | |
| import { insertNewlineAndIndent } from '@codemirror/commands'; | |
| import { ensureSyntaxTree } from '@codemirror/language'; | |
| import type { Extension, StateCommand, Text } from '@codemirror/state'; | |
| -import { | |
| - Compartment, | |
| - EditorSelection, | |
| - EditorState, | |
| - Prec | |
| -} from '@codemirror/state'; | |
| +import { Compartment, EditorSelection, EditorState, Prec } from '@codemirror/state'; | |
| import type { Command, ViewUpdate } from '@codemirror/view'; | |
| import { EditorView } from '@codemirror/view'; | |
| import type { CodeEditor } from '@jupyterlab/codeeditor'; | |
| @@ -73,11 +68,9 @@ export class CodeMirrorEditor implements CodeEditor.IEditor { | |
| } | |
| }); | |
| - const updateListener = EditorView.updateListener.of( | |
| - (update: ViewUpdate) => { | |
| - this._onDocChanged(update); | |
| - } | |
| - ); | |
| + const updateListener = EditorView.updateListener.of((update: ViewUpdate) => { | |
| + this._onDocChanged(update); | |
| + }); | |
| this._editor = Private.createEditor( | |
| host, | |
| @@ -361,10 +354,7 @@ export class CodeMirrorEditor implements CodeEditor.IEditor { | |
| /** | |
| * Reveal the given selection in the editor. | |
| */ | |
| - revealSelection( | |
| - selection: CodeEditor.IRange, | |
| - options?: ScrollIntoViewOptions | |
| - ): void { | |
| + revealSelection(selection: CodeEditor.IRange, options?: ScrollIntoViewOptions): void { | |
| const start = this.getOffsetAt(selection.start); | |
| const end = this.getOffsetAt(selection.end); | |
| this._editor.dispatch({ | |
| @@ -478,10 +468,7 @@ export class CodeMirrorEditor implements CodeEditor.IEditor { | |
| setSelections(selections: CodeEditor.IRange[]): void { | |
| const sel = selections.length | |
| ? selections.map(r => | |
| - EditorSelection.range( | |
| - this.getOffsetAt(r.start), | |
| - this.getOffsetAt(r.end) | |
| - ) | |
| + EditorSelection.range(this.getOffsetAt(r.start), this.getOffsetAt(r.end)) | |
| ) | |
| : [EditorSelection.range(0, 0)]; | |
| this.editor.dispatch({ selection: EditorSelection.create(sel) }); | |
| @@ -661,10 +648,7 @@ export class CodeMirrorEditor implements CodeEditor.IEditor { | |
| }); | |
| }) | |
| .catch(reason => { | |
| - console.log( | |
| - `Failed to load language for '${this._model.mimeType}'.`, | |
| - reason | |
| - ); | |
| + console.log(`Failed to load language for '${this._model.mimeType}'.`, reason); | |
| this._editor.dispatch({ | |
| effects: this._language.reconfigure([]) | |
| }); | |
| diff --git a/packages/codemirror/src/extension.ts b/packages/codemirror/src/extension.ts | |
| index c8a5524a47..5ce04c639f 100644 | |
| --- a/packages/codemirror/src/extension.ts | |
| +++ b/packages/codemirror/src/extension.ts | |
| @@ -86,9 +86,7 @@ export interface IEditorHandlerOptions { | |
| * It stores the editor configuration and the editor extensions. | |
| * It also allows to inject new extensions into an editor. | |
| */ | |
| -export class ExtensionsHandler | |
| - implements IExtensionsHandler, IObservableDisposable | |
| -{ | |
| +export class ExtensionsHandler implements IExtensionsHandler, IObservableDisposable { | |
| constructor({ | |
| baseConfiguration, | |
| config, | |
| @@ -256,18 +254,13 @@ export class ExtensionsHandler | |
| * @param view Editor view | |
| * @param configuration Editor configuration | |
| */ | |
| - reconfigureExtensions( | |
| - view: EditorView, | |
| - configuration: Record<string, any> | |
| - ): void { | |
| + reconfigureExtensions(view: EditorView, configuration: Record<string, any>): void { | |
| const effects = Object.keys(configuration) | |
| .filter(key => this.has(key)) | |
| .map(key => this.getEffect(view.state, key, configuration[key])); | |
| view.dispatch({ | |
| - effects: effects.filter( | |
| - effect => effect !== null | |
| - ) as StateEffect<unknown>[] | |
| + effects: effects.filter(effect => effect !== null) as StateEffect<unknown>[] | |
| }); | |
| } | |
| @@ -469,10 +462,7 @@ export class EditorExtensionRegistry implements IEditorExtensionRegistry { | |
| return handler; | |
| } | |
| - protected configurationBuilder = new Map< | |
| - string, | |
| - IEditorExtensionFactory<any> | |
| - >(); | |
| + protected configurationBuilder = new Map<string, IEditorExtensionFactory<any>>(); | |
| protected configurationSchema: Record<string, any> = {}; | |
| protected defaultOptions: Record<string, any> = {}; | |
| @@ -516,9 +506,7 @@ export namespace EditorExtensionRegistry { | |
| * @returns Editor state effect | |
| */ | |
| reconfigure(value: T): StateEffect<T> { | |
| - return this._compartment.reconfigure( | |
| - this._builder(value) | |
| - ) as StateEffect<T>; | |
| + return this._compartment.reconfigure(this._builder(value)) as StateEffect<T>; | |
| } | |
| private _compartment: Compartment; | |
| @@ -584,9 +572,7 @@ export namespace EditorExtensionRegistry { | |
| truthy: Extension, | |
| falsy: Extension = [] | |
| ): IConfigurableExtension<boolean> { | |
| - return new ConfigurableExtension<boolean>(value => | |
| - value ? truthy : falsy | |
| - ); | |
| + return new ConfigurableExtension<boolean>(value => (value ? truthy : falsy)); | |
| } | |
| /** | |
| @@ -669,8 +655,7 @@ export namespace EditorExtensionRegistry { | |
| Object.freeze({ | |
| name: 'highlightTrailingWhitespace', | |
| default: false, | |
| - factory: () => | |
| - createConditionalExtension(highlightTrailingWhitespace()), | |
| + factory: () => createConditionalExtension(highlightTrailingWhitespace()), | |
| schema: { | |
| type: 'boolean', | |
| title: trans.__('Highlight trailing white spaces') | |
| @@ -803,10 +788,7 @@ export namespace EditorExtensionRegistry { | |
| name: 'rectangularSelection', | |
| default: true, | |
| factory: () => | |
| - createConditionalExtension([ | |
| - rectangularSelection(), | |
| - crosshairCursor() | |
| - ]), | |
| + createConditionalExtension([rectangularSelection(), crosshairCursor()]), | |
| schema: { | |
| type: 'boolean', | |
| title: trans.__('Rectangular selection'), | |
| @@ -821,9 +803,7 @@ export namespace EditorExtensionRegistry { | |
| factory: () => | |
| createConfigurableExtension((value: boolean) => [ | |
| EditorState.readOnly.of(value), | |
| - value | |
| - ? EditorView.editorAttributes.of({ class: READ_ONLY_CLASS }) | |
| - : [] | |
| + value ? EditorView.editorAttributes.of({ class: READ_ONLY_CLASS }) : [] | |
| ]) | |
| }), | |
| Object.freeze({ | |
| @@ -945,9 +925,7 @@ export namespace EditorExtensionRegistry { | |
| name: 'tabSize', | |
| default: 4, | |
| factory: () => | |
| - createConfigurableExtension((value: number) => | |
| - EditorState.tabSize.of(value) | |
| - ), | |
| + createConfigurableExtension((value: number) => EditorState.tabSize.of(value)), | |
| schema: { | |
| type: 'number', | |
| title: trans.__('Tab size') | |
| @@ -981,9 +959,7 @@ export namespace EditorExtensionRegistry { | |
| Object.freeze({ | |
| name: 'customStyles', | |
| factory: () => | |
| - createConfigurableExtension<CustomTheme>(config => | |
| - customTheme(config) | |
| - ), | |
| + createConfigurableExtension<CustomTheme>(config => customTheme(config)), | |
| default: { | |
| fontFamily: null, | |
| fontSize: null, | |
| @@ -1019,9 +995,7 @@ export namespace EditorExtensionRegistry { | |
| name: 'theme', | |
| default: 'jupyter', | |
| factory: () => | |
| - createConfigurableExtension<string>(value => | |
| - themes.getTheme(value) | |
| - ), | |
| + createConfigurableExtension<string>(value => themes.getTheme(value)), | |
| schema: { | |
| type: 'string', | |
| title: trans.__('Theme'), | |
| diff --git a/packages/codemirror/src/extensions/customStyle.ts b/packages/codemirror/src/extensions/customStyle.ts | |
| index f06ab4ba5f..5cdd5f7c1d 100644 | |
| --- a/packages/codemirror/src/extensions/customStyle.ts | |
| +++ b/packages/codemirror/src/extensions/customStyle.ts | |
| @@ -49,8 +49,7 @@ const customThemeConfig = Facet.define<CustomTheme, CustomTheme>({ | |
| }); | |
| function setEditorStyle(view: EditorView): Record<string, string> | null { | |
| - const { fontFamily, fontSize, lineHeight } = | |
| - view.state.facet(customThemeConfig); | |
| + const { fontFamily, fontSize, lineHeight } = view.state.facet(customThemeConfig); | |
| let style = ''; | |
| if (fontSize) { | |
| @@ -73,8 +72,5 @@ function setEditorStyle(view: EditorView): Record<string, string> | null { | |
| * @returns Editor extension | |
| */ | |
| export function customTheme(config: CustomTheme): Extension { | |
| - return [ | |
| - customThemeConfig.of(config), | |
| - EditorView.editorAttributes.of(setEditorStyle) | |
| - ]; | |
| + return [customThemeConfig.of(config), EditorView.editorAttributes.of(setEditorStyle)]; | |
| } | |
| diff --git a/packages/codemirror/src/extensions/ipython-md.ts b/packages/codemirror/src/extensions/ipython-md.ts | |
| index a32334a6b2..96c8d30213 100644 | |
| --- a/packages/codemirror/src/extensions/ipython-md.ts | |
| +++ b/packages/codemirror/src/extensions/ipython-md.ts | |
| @@ -31,12 +31,13 @@ const DELIMITER_LENGTH: Record<string, number> = { | |
| * Delimiters for math expressions | |
| */ | |
| // Delimiters must be defined as constant because they are used in object match tests | |
| -const DELIMITERS = Object.keys(DELIMITER_LENGTH).reduce< | |
| - Record<string, DelimiterType> | |
| ->((agg, name) => { | |
| - agg[name] = { mark: `${name}Mark`, resolve: name }; | |
| - return agg; | |
| -}, {}); | |
| +const DELIMITERS = Object.keys(DELIMITER_LENGTH).reduce<Record<string, DelimiterType>>( | |
| + (agg, name) => { | |
| + agg[name] = { mark: `${name}Mark`, resolve: name }; | |
| + return agg; | |
| + }, | |
| + {} | |
| +); | |
| /** | |
| * Define an IPython mathematical expression parser for Markdown. | |
| diff --git a/packages/codemirror/src/extensions/rulers.ts b/packages/codemirror/src/extensions/rulers.ts | |
| index 021c179157..ef73343344 100644 | |
| --- a/packages/codemirror/src/extensions/rulers.ts | |
| +++ b/packages/codemirror/src/extensions/rulers.ts | |
| @@ -44,9 +44,7 @@ const rulerConfig = Facet.define<number[], number[]>({ | |
| const plugin = ViewPlugin.fromClass( | |
| class { | |
| constructor(view: EditorView) { | |
| - this.rulersContainer = view.dom.appendChild( | |
| - document.createElement('div') | |
| - ); | |
| + this.rulersContainer = view.dom.appendChild(document.createElement('div')); | |
| this.rulersContainer.style.cssText = ` | |
| position: absolute; | |
| left: 0; | |
| @@ -62,9 +60,7 @@ const plugin = ViewPlugin.fromClass( | |
| const guttersWidths = | |
| view.scrollDOM.querySelector('.cm-gutters')?.clientWidth ?? 0; | |
| this.rulers = widths.map(width => { | |
| - const ruler = this.rulersContainer.appendChild( | |
| - document.createElement('div') | |
| - ); | |
| + const ruler = this.rulersContainer.appendChild(document.createElement('div')); | |
| ruler.classList.add(RULERS_CLASSNAME); | |
| ruler.style.cssText = ` | |
| position: absolute; | |
| diff --git a/packages/codemirror/src/extensions/ybinding.ts b/packages/codemirror/src/extensions/ybinding.ts | |
| index 8d7d798989..b75a9cc39a 100644 | |
| --- a/packages/codemirror/src/extensions/ybinding.ts | |
| +++ b/packages/codemirror/src/extensions/ybinding.ts | |
| @@ -11,18 +11,8 @@ import type { Extension, SelectionRange } from '@codemirror/state'; | |
| import { Annotation, EditorSelection, Facet } from '@codemirror/state'; | |
| import type { EditorView, ViewUpdate } from '@codemirror/view'; | |
| import { ViewPlugin } from '@codemirror/view'; | |
| -import { | |
| - yUndoManager, | |
| - YUndoManagerConfig, | |
| - yUndoManagerFacet | |
| -} from './yundomanager'; | |
| -import type { | |
| - RelativePosition, | |
| - Text, | |
| - Transaction, | |
| - UndoManager, | |
| - YTextEvent | |
| -} from 'yjs'; | |
| +import { yUndoManager, YUndoManagerConfig, yUndoManagerFacet } from './yundomanager'; | |
| +import type { RelativePosition, Text, Transaction, UndoManager, YTextEvent } from 'yjs'; | |
| import { | |
| createAbsolutePositionFromRelativePosition, | |
| createRelativePositionFromJSON, | |
| diff --git a/packages/codemirror/src/extensions/yundomanager.ts b/packages/codemirror/src/extensions/yundomanager.ts | |
| index 8baf354ed1..4de4f17143 100644 | |
| --- a/packages/codemirror/src/extensions/yundomanager.ts | |
| +++ b/packages/codemirror/src/extensions/yundomanager.ts | |
| @@ -32,10 +32,7 @@ export class YUndoManagerConfig { | |
| public undoManager: UndoManager; | |
| } | |
| -export const yUndoManagerFacet = Facet.define< | |
| - YUndoManagerConfig, | |
| - YUndoManagerConfig | |
| ->({ | |
| +export const yUndoManagerFacet = Facet.define<YUndoManagerConfig, YUndoManagerConfig>({ | |
| combine(inputs) { | |
| return inputs[inputs.length - 1]; | |
| } | |
| diff --git a/packages/codemirror/src/factory.ts b/packages/codemirror/src/factory.ts | |
| index 4d3a202cff..60fa17c47d 100644 | |
| --- a/packages/codemirror/src/factory.ts | |
| +++ b/packages/codemirror/src/factory.ts | |
| @@ -37,9 +37,7 @@ export class CodeMirrorEditorFactory implements IEditorFactoryService { | |
| /** | |
| * Create a new editor for inline code. | |
| */ | |
| - readonly newInlineEditor = ( | |
| - options: CodeEditor.IOptions | |
| - ): CodeMirrorEditor => { | |
| + readonly newInlineEditor = (options: CodeEditor.IOptions): CodeMirrorEditor => { | |
| options.host.dataset.type = 'inline'; | |
| return this.newEditor({ | |
| ...options, | |
| @@ -51,9 +49,7 @@ export class CodeMirrorEditorFactory implements IEditorFactoryService { | |
| /** | |
| * Create a new editor for a full document. | |
| */ | |
| - readonly newDocumentEditor = ( | |
| - options: CodeEditor.IOptions | |
| - ): CodeMirrorEditor => { | |
| + readonly newDocumentEditor = (options: CodeEditor.IOptions): CodeMirrorEditor => { | |
| options.host.dataset.type = 'document'; | |
| return this.newEditor({ | |
| ...options, | |
| diff --git a/packages/codemirror/src/language.ts b/packages/codemirror/src/language.ts | |
| index f1186a543c..e0aa47fa36 100644 | |
| --- a/packages/codemirror/src/language.ts | |
| +++ b/packages/codemirror/src/language.ts | |
| @@ -44,8 +44,7 @@ export class EditorLanguageRegistry implements IEditorLanguageRegistry { | |
| * @param language Language to register | |
| */ | |
| addLanguage(language: IEditorLanguage): void { | |
| - const info = | |
| - this.findByName(language.name) ?? this.findByMIME(language.mime, true); | |
| + const info = this.findByName(language.name) ?? this.findByMIME(language.mime, true); | |
| if (info) { | |
| throw new Error(`${language.mime} already registered`); | |
| } | |
| @@ -86,10 +85,7 @@ export class EditorLanguageRegistry implements IEditorLanguageRegistry { | |
| * @param strict Whether xml and json should be assimilated to the generic mimetype | |
| * @returns The mode or null | |
| */ | |
| - findByMIME( | |
| - mime: string | readonly string[], | |
| - strict = false | |
| - ): IEditorLanguage | null { | |
| + findByMIME(mime: string | readonly string[], strict = false): IEditorLanguage | null { | |
| if (Array.isArray(mime)) { | |
| for (let i = 0; i < mime.length; i++) { | |
| const spec = this.findByMIME(mime[i]); | |
| @@ -206,9 +202,7 @@ export class EditorLanguageRegistry implements IEditorLanguageRegistry { | |
| (modename ? this.findByName(modename) : null) ?? | |
| (mimetype ? this.findByMIME(mimetype) : null) ?? | |
| this.findByExtension(ext) ?? | |
| - (fallback | |
| - ? this.findByMIME(IEditorMimeTypeService.defaultMimeType) | |
| - : null) | |
| + (fallback ? this.findByMIME(IEditorMimeTypeService.defaultMimeType) : null) | |
| ); | |
| } | |
| @@ -287,9 +281,7 @@ export namespace EditorLanguageRegistry { | |
| * @param dialectName SQL dialect | |
| * @returns Language object | |
| */ | |
| - async function sql( | |
| - dialectName: keyof typeof SQLModule | |
| - ): Promise<LanguageSupport> { | |
| + async function sql(dialectName: keyof typeof SQLModule): Promise<LanguageSupport> { | |
| const m = await import('@codemirror/lang-sql'); | |
| return m.sql({ dialect: (m as any)[dialectName] }); | |
| } | |
| @@ -458,11 +450,7 @@ export namespace EditorLanguageRegistry { | |
| { | |
| name: 'PHP', | |
| displayName: trans.__('PHP'), | |
| - mime: [ | |
| - 'text/x-php', | |
| - 'application/x-httpd-php', | |
| - 'application/x-httpd-php-open' | |
| - ], | |
| + mime: ['text/x-php', 'application/x-httpd-php', 'application/x-httpd-php-open'], | |
| extensions: ['php', 'php3', 'php4', 'php5', 'php7', 'phtml'], | |
| async load() { | |
| const m = await import('@codemirror/lang-php'); | |
| @@ -494,10 +482,7 @@ export namespace EditorLanguageRegistry { | |
| filename: /^(BUCK|BUILD)$/, | |
| async load() { | |
| const m = await import('@codemirror/lang-python'); | |
| - return new LanguageSupport( | |
| - m.pythonLanguage, | |
| - pythonBuiltin(m.pythonLanguage) | |
| - ); | |
| + return new LanguageSupport(m.pythonLanguage, pythonBuiltin(m.pythonLanguage)); | |
| } | |
| }, | |
| { | |
| @@ -509,10 +494,7 @@ export namespace EditorLanguageRegistry { | |
| // to activate feature such as code folding. | |
| // return Promise.resolve(legacy(mkPython({ singleOperators: /\?/ }))); | |
| const m = await import('@codemirror/lang-python'); | |
| - return new LanguageSupport( | |
| - m.pythonLanguage, | |
| - pythonBuiltin(m.pythonLanguage) | |
| - ); | |
| + return new LanguageSupport(m.pythonLanguage, pythonBuiltin(m.pythonLanguage)); | |
| } | |
| }, | |
| { | |
| @@ -1172,11 +1154,7 @@ export namespace EditorLanguageRegistry { | |
| { | |
| name: 'NTriples', | |
| displayName: trans.__('NTriples'), | |
| - mime: [ | |
| - 'application/n-triples', | |
| - 'application/n-quads', | |
| - 'text/n-triples' | |
| - ], | |
| + mime: ['application/n-triples', 'application/n-quads', 'text/n-triples'], | |
| extensions: ['nt', 'nq'], | |
| async load() { | |
| const m = await import('@codemirror/legacy-modes/mode/ntriples'); | |
| diff --git a/packages/codemirror/src/searchprovider.ts b/packages/codemirror/src/searchprovider.ts | |
| index 0963ade708..38e940cb07 100644 | |
| --- a/packages/codemirror/src/searchprovider.ts | |
| +++ b/packages/codemirror/src/searchprovider.ts | |
| @@ -42,10 +42,7 @@ import type { | |
| IFilters, | |
| IReplaceOptions | |
| } from '@jupyterlab/documentsearch'; | |
| -import { | |
| - GenericSearchProvider, | |
| - TextSearchEngine | |
| -} from '@jupyterlab/documentsearch'; | |
| +import { GenericSearchProvider, TextSearchEngine } from '@jupyterlab/documentsearch'; | |
| import type { ISignal } from '@lumino/signaling'; | |
| import { Signal } from '@lumino/signaling'; | |
| import type { ISharedText, SourceChange } from '@jupyter/ydoc'; | |
| @@ -360,8 +357,7 @@ export abstract class EditorSearchProvider< | |
| this.updateCodeMirror(this.model.sharedModel.getSource()) | |
| .then(() => { | |
| const allMatches = this.cmHandler.matches; | |
| - const positionAfterReplacement = | |
| - match!.position + insertText.length; | |
| + const positionAfterReplacement = match!.position + insertText.length; | |
| let nextMatchFound = false; | |
| for ( | |
| let matchIdx = this.currentIndex || 0; | |
| @@ -400,10 +396,7 @@ export abstract class EditorSearchProvider< | |
| * @param newText The replacement text. | |
| * @returns Whether a replace occurred. | |
| */ | |
| - replaceAllMatches( | |
| - newText: string, | |
| - options?: IReplaceOptions | |
| - ): Promise<boolean> { | |
| + replaceAllMatches(newText: string, options?: IReplaceOptions): Promise<boolean> { | |
| if (!this.isActive) { | |
| return Promise.resolve(false); | |
| } | |
| @@ -480,10 +473,7 @@ export abstract class EditorSearchProvider< | |
| match => match.position >= start && match.position <= end | |
| ); | |
| // A special case to always have a current match when in line selection mode. | |
| - if ( | |
| - this.cmHandler.currentIndex === null && | |
| - this.cmHandler.matches.length > 0 | |
| - ) { | |
| + if (this.cmHandler.currentIndex === null && this.cmHandler.matches.length > 0) { | |
| await this.cmHandler.highlightNext({ | |
| from: 'selection', | |
| select: false, | |
| @@ -559,9 +549,7 @@ export class CodeMirrorSearchHighlighter { | |
| }); | |
| return { | |
| matches: value.matches.map(transform), | |
| - currentMatch: value.currentMatch | |
| - ? transform(value.currentMatch) | |
| - : null | |
| + currentMatch: value.currentMatch ? transform(value.currentMatch) : null | |
| }; | |
| } | |
| }); | |
| @@ -582,10 +570,7 @@ export class CodeMirrorSearchHighlighter { | |
| // inside `.jp-current-match`, sometime the other way round. | |
| highlights = highlights.update({ | |
| add: e.value.matches.map(m => | |
| - this._highlightMark.range( | |
| - m.position, | |
| - m.position + m.text.length | |
| - ) | |
| + this._highlightMark.range(m.position, m.position + m.text.length) | |
| ), | |
| // filter out old marks | |
| filter: () => false | |
| @@ -595,8 +580,7 @@ export class CodeMirrorSearchHighlighter { | |
| ? [ | |
| this._currentMark.range( | |
| e.value.currentMatch.position, | |
| - e.value.currentMatch.position + | |
| - e.value.currentMatch.text.length | |
| + e.value.currentMatch.position + e.value.currentMatch.text.length | |
| ) | |
| ] | |
| : [] | |
| @@ -634,10 +618,7 @@ export class CodeMirrorSearchHighlighter { | |
| } | |
| set matches(v: ISearchMatch[]) { | |
| this._matches = v; | |
| - if ( | |
| - this._currentIndex !== null && | |
| - this._currentIndex > this._matches.length | |
| - ) { | |
| + if (this._currentIndex !== null && this._currentIndex > this._matches.length) { | |
| this._currentIndex = this._matches.length > 0 ? 0 : null; | |
| } | |
| this._highlightCurrentMatch({ select: false }); | |
| @@ -691,9 +672,7 @@ export class CodeMirrorSearchHighlighter { | |
| this._currentIndex = this._findNext(false, options?.from ?? 'auto'); | |
| this._highlightCurrentMatch(options); | |
| return Promise.resolve( | |
| - this._currentIndex !== null | |
| - ? this._matches[this._currentIndex] | |
| - : undefined | |
| + this._currentIndex !== null ? this._matches[this._currentIndex] : undefined | |
| ); | |
| } | |
| @@ -708,9 +687,7 @@ export class CodeMirrorSearchHighlighter { | |
| this._currentIndex = this._findNext(true, options?.from ?? 'auto'); | |
| this._highlightCurrentMatch(options); | |
| return Promise.resolve( | |
| - this._currentIndex !== null | |
| - ? this._matches[this._currentIndex] | |
| - : undefined | |
| + this._currentIndex !== null ? this._matches[this._currentIndex] : undefined | |
| ); | |
| } | |
| @@ -828,10 +805,7 @@ export class CodeMirrorSearchHighlighter { | |
| this._cm!.editor.dispatch({ effects }); | |
| } | |
| - private _findNext( | |
| - reverse: boolean, | |
| - from: SearchStartAnchor = 'auto' | |
| - ): number | null { | |
| + private _findNext(reverse: boolean, from: SearchStartAnchor = 'auto'): number | null { | |
| if (this._matches.length === 0) { | |
| // No-op | |
| return null; | |
| @@ -844,10 +818,7 @@ export class CodeMirrorSearchHighlighter { | |
| } | |
| let lastPosition = 0; | |
| - if ( | |
| - (from === 'auto' && (this._cm?.hasFocus() ?? false)) || | |
| - from === 'selection' | |
| - ) { | |
| + if ((from === 'auto' && (this._cm?.hasFocus() ?? false)) || from === 'selection') { | |
| const cursor = this._cm!.state.selection.main; | |
| lastPosition = reverse ? cursor.anchor : cursor.head; | |
| } else if (from === 'selection-start') { | |
| @@ -864,18 +835,12 @@ export class CodeMirrorSearchHighlighter { | |
| // The default position is (0, 0) but we want to start from the end in that case | |
| // Fallback to the end of the latest match if the editor is not instantiated | |
| lastPosition = | |
| - this._cm?.doc.length ?? | |
| - endLastMatch(this._matches[this._matches.length - 1]); | |
| + this._cm?.doc.length ?? endLastMatch(this._matches[this._matches.length - 1]); | |
| } | |
| const position = lastPosition; | |
| - let found = Utils.findNext( | |
| - this._matches, | |
| - position, | |
| - 0, | |
| - this._matches.length - 1 | |
| - ); | |
| + let found = Utils.findNext(this._matches, position, 0, this._matches.length - 1); | |
| if (found === null) { | |
| // Don't loop | |
| @@ -937,10 +902,7 @@ namespace Utils { | |
| if (currentPosition < position) { | |
| lowerBound = middle + 1; | |
| - if ( | |
| - lowerBound < matches.length && | |
| - matches[lowerBound].position > position | |
| - ) { | |
| + if (lowerBound < matches.length && matches[lowerBound].position > position) { | |
| return lowerBound; | |
| } | |
| } else if (currentPosition > position) { | |
| diff --git a/packages/codemirror/src/theme.ts b/packages/codemirror/src/theme.ts | |
| index d9bf470b17..9805302855 100644 | |
| --- a/packages/codemirror/src/theme.ts | |
| +++ b/packages/codemirror/src/theme.ts | |
| @@ -73,8 +73,7 @@ export const jupyterEditorTheme = EditorView.theme({ | |
| }, | |
| '.cm-cursor, .cm-dropCursor': { | |
| - borderLeft: | |
| - 'var(--jp-code-cursor-width0) solid var(--jp-editor-cursor-color)' | |
| + borderLeft: 'var(--jp-code-cursor-width0) solid var(--jp-editor-cursor-color)' | |
| }, | |
| '.cm-selectionBackground, .cm-content ::selection': { | |
| @@ -95,8 +94,7 @@ export const jupyterEditorTheme = EditorView.theme({ | |
| }, | |
| '.cm-activeLine': { | |
| - backgroundColor: | |
| - 'color-mix(in srgb, var(--jp-layout-color3) 25%, transparent)' | |
| + backgroundColor: 'color-mix(in srgb, var(--jp-layout-color3) 25%, transparent)' | |
| }, | |
| '.cm-lineNumbers': { | |
| @@ -109,8 +107,7 @@ export const jupyterEditorTheme = EditorView.theme({ | |
| }, | |
| '.cm-searchMatch.cm-searchMatch-selected': { | |
| - backgroundColor: | |
| - 'var(--jp-search-selected-match-background-color) !important', | |
| + backgroundColor: 'var(--jp-search-selected-match-background-color) !important', | |
| color: 'var(--jp-search-selected-match-color) !important' | |
| }, | |
| @@ -267,10 +264,7 @@ export namespace EditorThemeRegistry { | |
| Object.freeze({ | |
| name: 'codemirror', | |
| displayName: trans.__('codemirror'), | |
| - theme: [ | |
| - EditorView.baseTheme({}), | |
| - syntaxHighlighting(defaultHighlightStyle) | |
| - ] | |
| + theme: [EditorView.baseTheme({}), syntaxHighlighting(defaultHighlightStyle)] | |
| }) | |
| ]; | |
| } | |
| diff --git a/packages/codemirror/src/token.ts b/packages/codemirror/src/token.ts | |
| index 6b16fa3a38..0328b1031c 100644 | |
| --- a/packages/codemirror/src/token.ts | |
| +++ b/packages/codemirror/src/token.ts | |
| @@ -133,10 +133,7 @@ export interface IExtensionsHandler extends IDisposable { | |
| * @param view Editor view | |
| * @param configuration Editor configuration | |
| */ | |
| - reconfigureExtensions( | |
| - view: EditorView, | |
| - configuration: Record<string, any> | |
| - ): void; | |
| + reconfigureExtensions(view: EditorView, configuration: Record<string, any>): void; | |
| } | |
| /** | |
| @@ -361,9 +358,7 @@ export interface IEditorLanguageRegistry { | |
| * | |
| * @returns A promise that resolves when the language is available. | |
| */ | |
| - getLanguage( | |
| - language: string | IEditorLanguage | |
| - ): Promise<IEditorLanguage | null>; | |
| + getLanguage(language: string | IEditorLanguage): Promise<IEditorLanguage | null>; | |
| /** | |
| * Get the raw list of available languages specs. | |
| diff --git a/packages/codemirror/style/base.css b/packages/codemirror/style/base.css | |
| index 2f4d75eca3..cec082cf24 100644 | |
| --- a/packages/codemirror/style/base.css | |
| +++ b/packages/codemirror/style/base.css | |
| @@ -35,16 +35,14 @@ | |
| /* When zoomed out 67% and 33% on a screen of 1440 width x 900 height */ | |
| @media screen and (width >= 2138px) and (width <= 4319px) { | |
| .jp-CodeMirrorEditor[data-type='inline'] .cm-cursor { | |
| - border-left: var(--jp-code-cursor-width1) solid | |
| - var(--jp-editor-cursor-color); | |
| + border-left: var(--jp-code-cursor-width1) solid var(--jp-editor-cursor-color); | |
| } | |
| } | |
| /* When zoomed out less than 33% */ | |
| @media screen and (width >= 4320px) { | |
| .jp-CodeMirrorEditor[data-type='inline'] .cm-cursor { | |
| - border-left: var(--jp-code-cursor-width2) solid | |
| - var(--jp-editor-cursor-color); | |
| + border-left: var(--jp-code-cursor-width2) solid var(--jp-editor-cursor-color); | |
| } | |
| } | |
| diff --git a/packages/codemirror/test/editor.spec.ts b/packages/codemirror/test/editor.spec.ts | |
| index 2f787f70fc..379ce72054 100644 | |
| --- a/packages/codemirror/test/editor.spec.ts | |
| +++ b/packages/codemirror/test/editor.spec.ts | |
| @@ -43,12 +43,9 @@ describe('CodeMirrorEditor', () => { | |
| extensionsRegistry = new EditorExtensionRegistry(); | |
| EditorExtensionRegistry.getDefaultExtensions() | |
| .filter(ext => | |
| - [ | |
| - 'lineNumbers', | |
| - 'lineWrap', | |
| - 'readOnly', | |
| - 'allowMultipleSelections' | |
| - ].includes(ext.name) | |
| + ['lineNumbers', 'lineWrap', 'readOnly', 'allowMultipleSelections'].includes( | |
| + ext.name | |
| + ) | |
| ) | |
| .forEach(ext => { | |
| extensionsRegistry.addExtension(ext); | |
| diff --git a/packages/codemirror/test/extension.spec.ts b/packages/codemirror/test/extension.spec.ts | |
| index f248399be1..7ea9aef75b 100644 | |
| --- a/packages/codemirror/test/extension.spec.ts | |
| +++ b/packages/codemirror/test/extension.spec.ts | |
| @@ -2,10 +2,7 @@ | |
| // Distributed under the terms of the Modified BSD License. | |
| import type { CodeEditor } from '@jupyterlab/codeeditor'; | |
| -import { | |
| - EditorExtensionRegistry, | |
| - ExtensionsHandler | |
| -} from '@jupyterlab/codemirror'; | |
| +import { EditorExtensionRegistry, ExtensionsHandler } from '@jupyterlab/codemirror'; | |
| import { signalToPromise } from '@jupyterlab/coreutils'; | |
| describe('@jupyterlab/codemirror', () => { | |
| @@ -82,8 +79,7 @@ describe('@jupyterlab/codemirror', () => { | |
| registry.addExtension({ | |
| name: 'dummy', | |
| default: true, | |
| - factory: () => | |
| - EditorExtensionRegistry.createConfigurableExtension(v => []), | |
| + factory: () => EditorExtensionRegistry.createConfigurableExtension(v => []), | |
| schema: { | |
| type: 'boolean', | |
| default: false | |
| @@ -102,8 +98,7 @@ describe('@jupyterlab/codemirror', () => { | |
| const registry = new EditorExtensionRegistry(); | |
| registry.addExtension({ | |
| name: 'dummy', | |
| - factory: () => | |
| - EditorExtensionRegistry.createConfigurableExtension(v => []), | |
| + factory: () => EditorExtensionRegistry.createConfigurableExtension(v => []), | |
| schema: { | |
| type: ['string', 'null'] | |
| } | |
| @@ -124,8 +119,7 @@ describe('@jupyterlab/codemirror', () => { | |
| registry.addExtension({ | |
| name: 'dummy', | |
| default: true, | |
| - factory: () => | |
| - EditorExtensionRegistry.createConfigurableExtension(v => []) | |
| + factory: () => EditorExtensionRegistry.createConfigurableExtension(v => []) | |
| }); | |
| expect( | |
| @@ -139,8 +133,7 @@ describe('@jupyterlab/codemirror', () => { | |
| const registry = new EditorExtensionRegistry(); | |
| registry.addExtension({ | |
| name: 'dummy', | |
| - factory: () => | |
| - EditorExtensionRegistry.createConfigurableExtension(v => []) | |
| + factory: () => EditorExtensionRegistry.createConfigurableExtension(v => []) | |
| }); | |
| const handler = registry.createNew({ | |
| @@ -155,15 +148,13 @@ describe('@jupyterlab/codemirror', () => { | |
| const registry = new EditorExtensionRegistry(); | |
| registry.addExtension({ | |
| name: 'dummy', | |
| - factory: () => | |
| - EditorExtensionRegistry.createConfigurableExtension(v => []) | |
| + factory: () => EditorExtensionRegistry.createConfigurableExtension(v => []) | |
| }); | |
| expect(() => { | |
| registry.addExtension({ | |
| name: 'dummy', | |
| - factory: () => | |
| - EditorExtensionRegistry.createConfigurableExtension(v => []) | |
| + factory: () => EditorExtensionRegistry.createConfigurableExtension(v => []) | |
| }); | |
| }).toThrow(); | |
| }); | |
| @@ -213,10 +204,7 @@ describe('@jupyterlab/codemirror', () => { | |
| }, | |
| config, | |
| defaultExtensions: [ | |
| - [ | |
| - 'lineNumbers', | |
| - EditorExtensionRegistry.createConditionalExtension([]) | |
| - ], | |
| + ['lineNumbers', EditorExtensionRegistry.createConditionalExtension([])], | |
| ['readOnly', EditorExtensionRegistry.createConditionalExtension([])], | |
| ['immutable', EditorExtensionRegistry.createImmutableExtension([])] | |
| ] | |
| diff --git a/packages/codemirror/test/mathparser.spec.ts b/packages/codemirror/test/mathparser.spec.ts | |
| index c861d05363..41a6cb693c 100644 | |
| --- a/packages/codemirror/test/mathparser.spec.ts | |
| +++ b/packages/codemirror/test/mathparser.spec.ts | |
| @@ -30,8 +30,7 @@ function compareTree(a: Tree, b: Tree) { | |
| mismatch = `Start pos mismatch for ${curA.name}: ${curA.from} vs ${curB.from}`; | |
| else if (curA.to != curB.to) | |
| mismatch = `End pos mismatch for ${curA.name}: ${curA.to} vs ${curB.to}`; | |
| - else if ((next = curA.next()) != curB.next()) | |
| - mismatch = `Tree size mismatch`; | |
| + else if ((next = curA.next()) != curB.next()) mismatch = `Tree size mismatch`; | |
| if (mismatch) throw new Error(`${mismatch}\n ${a}\n ${b}`); | |
| if (!next) break; | |
| } | |
| @@ -113,9 +112,7 @@ class SpecParser { | |
| tag = name && this.type(name[1]); | |
| if (tag == null) { | |
| if (name != null) | |
| - throw new Error( | |
| - `Invalid node opening mark at ${pos} in ${specName}` | |
| - ); | |
| + throw new Error(`Invalid node opening mark at ${pos} in ${specName}`); | |
| // If no tag found, assume curly brace is part of the document | |
| hasOpenedCurlyBrace++; | |
| doc += ch; | |
| @@ -125,9 +122,7 @@ class SpecParser { | |
| stack.push(tag, doc.length, buffer.length); | |
| } else if (ch == '}') { | |
| if (!stack.length && !hasOpenedCurlyBrace) | |
| - throw new Error( | |
| - `Mismatched node close mark at ${pos} in ${specName}` | |
| - ); | |
| + throw new Error(`Mismatched node close mark at ${pos} in ${specName}`); | |
| if (hasOpenedCurlyBrace) { | |
| hasOpenedCurlyBrace--; | |
| doc += ch; | |
| diff --git a/packages/codemirror/test/widget.spec.ts b/packages/codemirror/test/widget.spec.ts | |
| index 43ff9c54a6..66143cfd07 100644 | |
| --- a/packages/codemirror/test/widget.spec.ts | |
| +++ b/packages/codemirror/test/widget.spec.ts | |
| @@ -2,10 +2,7 @@ | |
| // Distributed under the terms of the Modified BSD License. | |
| import { CodeEditor, CodeEditorWrapper } from '@jupyterlab/codeeditor'; | |
| -import { | |
| - CodeMirrorEditor, | |
| - EditorExtensionRegistry | |
| -} from '@jupyterlab/codemirror'; | |
| +import { CodeMirrorEditor, EditorExtensionRegistry } from '@jupyterlab/codemirror'; | |
| import { YFile } from '@jupyter/ydoc'; | |
| import type { Message } from '@lumino/messaging'; | |
| import { MessageLoop } from '@lumino/messaging'; | |
| @@ -135,9 +132,7 @@ describe('CodeEditorWrapper', () => { | |
| it('should focus the editor', () => { | |
| Widget.attach(widget, document.body); | |
| MessageLoop.sendMessage(widget, Widget.Msg.ActivateRequest); | |
| - expect(widget.methods).toEqual( | |
| - expect.arrayContaining(['onActivateRequest']) | |
| - ); | |
| + expect(widget.methods).toEqual(expect.arrayContaining(['onActivateRequest'])); | |
| expect(widget.editor.hasFocus()).toBe(true); | |
| }); | |
| }); | |
| diff --git a/packages/completer-extension/src/index.ts b/packages/completer-extension/src/index.ts | |
| index 164de4f431..67a9f44358 100644 | |
| --- a/packages/completer-extension/src/index.ts | |
| +++ b/packages/completer-extension/src/index.ts | |
| @@ -5,10 +5,7 @@ | |
| * @module completer-extension | |
| */ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { COMPLETER_ACTIVE_CLASS } from '@jupyterlab/codeeditor'; | |
| import { CommandToolbarButton } from '@jupyterlab/ui-components'; | |
| import type { | |
| @@ -39,8 +36,7 @@ import { CommandRegistry } from '@lumino/commands'; | |
| import { renderAvailableProviders } from './renderer'; | |
| const COMPLETION_MANAGER_PLUGIN = '@jupyterlab/completer-extension:manager'; | |
| -const INLINE_COMPLETER_PLUGIN = | |
| - '@jupyterlab/completer-extension:inline-completer'; | |
| +const INLINE_COMPLETER_PLUGIN = '@jupyterlab/completer-extension:inline-completer'; | |
| namespace CommandIDs { | |
| export const nextInline = 'inline-completer:next'; | |
| @@ -104,16 +100,12 @@ const inlineCompleterFactory: JupyterFrontEndPlugin<IInlineCompleterFactory> = { | |
| const binding = app.commands.keyBindings.find( | |
| binding => binding.command === commandID | |
| ); | |
| - const keys = binding | |
| - ? CommandRegistry.formatKeystroke(binding.keys) | |
| - : ''; | |
| + const keys = binding ? CommandRegistry.formatKeystroke(binding.keys) : ''; | |
| return keys ? `${keys}` : ''; | |
| }; | |
| const labelCache = { | |
| - [CommandIDs.previousInline]: describeShortcut( | |
| - CommandIDs.previousInline | |
| - ), | |
| + [CommandIDs.previousInline]: describeShortcut(CommandIDs.previousInline), | |
| [CommandIDs.nextInline]: describeShortcut(CommandIDs.nextInline), | |
| [CommandIDs.acceptInline]: describeShortcut(CommandIDs.acceptInline) | |
| }; | |
| @@ -191,11 +183,7 @@ const inlineCompleter: JupyterFrontEndPlugin<void> = { | |
| id: INLINE_COMPLETER_PLUGIN, | |
| description: | |
| 'Registers the inline completer factory; adds inline completer commands, shortcuts and settings.', | |
| - requires: [ | |
| - ICompletionProviderManager, | |
| - IInlineCompleterFactory, | |
| - ISettingRegistry | |
| - ], | |
| + requires: [ICompletionProviderManager, IInlineCompleterFactory, ISettingRegistry], | |
| optional: [ITranslator], | |
| autoStart: true, | |
| activate: ( | |
| @@ -207,8 +195,7 @@ const inlineCompleter: JupyterFrontEndPlugin<void> = { | |
| ): void => { | |
| completionManager.setInlineCompleterFactory(factory); | |
| const trans = (translator || nullTranslator).load('jupyterlab'); | |
| - const isEnabled = () => | |
| - !!app.shell.currentWidget && !!completionManager.inline; | |
| + const isEnabled = () => !!app.shell.currentWidget && !!completionManager.inline; | |
| let inlineCompleterSettings: IInlineCompleterSettings | undefined; | |
| app.commands.addCommand(CommandIDs.nextInline, { | |
| execute: () => { | |
| @@ -225,10 +212,7 @@ const inlineCompleter: JupyterFrontEndPlugin<void> = { | |
| }); | |
| app.commands.addCommand(CommandIDs.previousInline, { | |
| execute: () => { | |
| - completionManager.inline?.cycle( | |
| - app.shell.currentWidget!.id!, | |
| - 'previous' | |
| - ); | |
| + completionManager.inline?.cycle(app.shell.currentWidget!.id!, 'previous'); | |
| }, | |
| label: trans.__('Previous Inline Completion'), | |
| isEnabled, | |
| @@ -378,9 +362,7 @@ const inlineCompleter: JupyterFrontEndPlugin<void> = { | |
| const findKeybinding = ( | |
| commandID: string | |
| ): CommandRegistry.IKeyBinding | undefined => { | |
| - return app.commands.keyBindings.find( | |
| - binding => binding.command === commandID | |
| - ); | |
| + return app.commands.keyBindings.find(binding => binding.command === commandID); | |
| }; | |
| const keyBindings = { | |
| @@ -389,14 +371,10 @@ const inlineCompleter: JupyterFrontEndPlugin<void> = { | |
| }; | |
| app.commands.keyBindingChanged.connect( | |
| - ( | |
| - _emitter: CommandRegistry, | |
| - change: CommandRegistry.IKeyBindingChangedArgs | |
| - ) => { | |
| + (_emitter: CommandRegistry, change: CommandRegistry.IKeyBindingChangedArgs) => { | |
| const command = change.binding.command; | |
| if (keyBindings.hasOwnProperty(command)) { | |
| - keyBindings[command as keyof typeof keyBindings] = | |
| - findKeybinding(command); | |
| + keyBindings[command as keyof typeof keyBindings] = findKeybinding(command); | |
| } | |
| } | |
| ); | |
| @@ -423,9 +401,7 @@ const inlineCompleter: JupyterFrontEndPlugin<void> = { | |
| target.closest(binding.selector) && | |
| app.commands.isEnabled(binding.command) | |
| ) { | |
| - const tabCompleterActive = target.closest( | |
| - '.' + COMPLETER_ACTIVE_CLASS | |
| - ); | |
| + const tabCompleterActive = target.closest('.' + COMPLETER_ACTIVE_CLASS); | |
| if ( | |
| inlineCompleterSettings?.suppressIfTabCompleterActive && | |
| tabCompleterActive | |
| @@ -470,9 +446,7 @@ const manager: JupyterFrontEndPlugin<ICompletionProviderManager> = { | |
| const providersData = settingValues.get(AVAILABLE_PROVIDERS); | |
| const composite = settingValues.composite; | |
| manager.setTimeout(composite.providerTimeout as number); | |
| - manager.setShowDocumentationPanel( | |
| - composite.showDocumentationPanel as boolean | |
| - ); | |
| + manager.setShowDocumentationPanel(composite.showDocumentationPanel as boolean); | |
| manager.setContinuousHinting(composite.autoCompletion as boolean); | |
| manager.setSuppressIfInlineCompleterActive( | |
| composite.suppressIfInlineCompleterActive as boolean | |
| @@ -488,9 +462,7 @@ const manager: JupyterFrontEndPlugin<ICompletionProviderManager> = { | |
| app.restored | |
| .then(() => { | |
| const availableProviders = [...manager.getProviders().entries()]; | |
| - const availableProviderIDs = availableProviders.map( | |
| - ([key, value]) => key | |
| - ); | |
| + const availableProviderIDs = availableProviders.map(([key, value]) => key); | |
| settings.transform(COMPLETION_MANAGER_PLUGIN, { | |
| fetch: plugin => { | |
| const schema = plugin.schema.properties!; | |
| diff --git a/packages/completer-extension/src/renderer.tsx b/packages/completer-extension/src/renderer.tsx | |
| index 528b9bba16..09363267c3 100644 | |
| --- a/packages/completer-extension/src/renderer.tsx | |
| +++ b/packages/completer-extension/src/renderer.tsx | |
| @@ -36,10 +36,7 @@ export function renderAvailableProviders(props: FieldProps): JSX.Element { | |
| } | |
| const [settingValue, setValue] = useState(items); | |
| - const onSettingChange = ( | |
| - key: string, | |
| - e: React.ChangeEvent<HTMLInputElement> | |
| - ) => { | |
| + const onSettingChange = (key: string, e: React.ChangeEvent<HTMLInputElement>) => { | |
| const newValue = { | |
| ...settingValue, | |
| [key]: parseInt(e.target.value) | |
| diff --git a/packages/completer/src/ghost.ts b/packages/completer/src/ghost.ts | |
| index 47f8ff7f9c..4e878e5aef 100644 | |
| --- a/packages/completer/src/ghost.ts | |
| +++ b/packages/completer/src/ghost.ts | |
| @@ -117,9 +117,7 @@ export class GhostTextManager { | |
| if (this.options.onBlur(event) === false) { | |
| return true; | |
| } | |
| - const effects: StateEffect<unknown>[] = [ | |
| - Private.removeMark.of(null) | |
| - ]; | |
| + const effects: StateEffect<unknown>[] = [Private.removeMark.of(null)]; | |
| // Only execute it after editor update has completed. | |
| setTimeout(() => { | |
| view.dispatch({ effects }); | |
| @@ -275,11 +273,7 @@ class GhostTextWidget extends WidgetType { | |
| if (editorLanguage) { | |
| // Pass the IEditorLanguage object to the highlight method. | |
| - await GHOST_TEXT_LANGUAGE_REGISTRY.highlight( | |
| - content, | |
| - editorLanguage, | |
| - dom | |
| - ); | |
| + await GHOST_TEXT_LANGUAGE_REGISTRY.highlight(content, editorLanguage, dom); | |
| } else { | |
| // Fallback if the language isn't in our registry. | |
| dom.appendChild(document.createTextNode(content)); | |
| @@ -368,8 +362,7 @@ class TransientLineSpacerWidget extends TransientSpacerWidget { | |
| const wrap = super.toDOM(view); | |
| wrap.classList.add(TRANSIENT_LINE_SPACER_CLASS); | |
| wrap.style.animationDelay = GhostTextManager.spacerRemovalDelay + 'ms'; | |
| - wrap.style.animationDuration = | |
| - GhostTextManager.spacerRemovalDuration + 'ms'; | |
| + wrap.style.animationDuration = GhostTextManager.spacerRemovalDuration + 'ms'; | |
| return wrap; | |
| } | |
| } | |
| @@ -448,11 +441,7 @@ namespace Private { | |
| ); | |
| } | |
| - function createSpacer( | |
| - spec: IGhostText, | |
| - tr: Transaction, | |
| - timeout: number = 1000 | |
| - ) { | |
| + function createSpacer(spec: IGhostText, tr: Transaction, timeout: number = 1000) { | |
| // no spacer needed if content is only one character long. | |
| if (spec.content.length < 2) { | |
| return []; | |
| @@ -550,14 +539,9 @@ namespace Private { | |
| } | |
| if (fromA === toA && fromB !== toB) { | |
| // text was inserted without modifying old text | |
| - for ( | |
| - let lineNumber = 0; | |
| - lineNumber < inserted.lines; | |
| - lineNumber++ | |
| - ) { | |
| + for (let lineNumber = 0; lineNumber < inserted.lines; lineNumber++) { | |
| const lineContent = inserted.lineAt(lineNumber).text; | |
| - const line = | |
| - lineNumber > 0 ? '\n' + lineContent : lineContent; | |
| + const line = lineNumber > 0 ? '\n' + lineContent : lineContent; | |
| if (spec.content.startsWith(line)) { | |
| spec.content = spec.content.slice(line.length); | |
| spec.from += line.length; | |
| diff --git a/packages/completer/src/handler.ts b/packages/completer/src/handler.ts | |
| index 2c019d73d7..5aead5c827 100644 | |
| --- a/packages/completer/src/handler.ts | |
| +++ b/packages/completer/src/handler.ts | |
| @@ -473,8 +473,7 @@ export class CompletionHandler implements IDisposable { | |
| const line = editor.getLine(position.line); | |
| if ( | |
| trigger === InlineCompletionTriggerKind.Automatic && | |
| - (typeof line === 'undefined' || | |
| - line.slice(0, position.column).match(/^\s*$/)) | |
| + (typeof line === 'undefined' || line.slice(0, position.column).match(/^\s*$/)) | |
| ) { | |
| // In Automatic mode we only auto-trigger on the end of line (and not on the beginning). | |
| // Increase the counter to avoid out-of date replies when pressing Backspace quickly. | |
| @@ -497,11 +496,7 @@ export class CompletionHandler implements IDisposable { | |
| model.cursor = position; | |
| const current = ++this._fetchingInline; | |
| - const promises = this._reconciliator.fetchInline( | |
| - request, | |
| - trigger, | |
| - isMiddleOfLine | |
| - ); | |
| + const promises = this._reconciliator.fetchInline(request, trigger, isMiddleOfLine); | |
| let cancelled = false; | |
| const completed = new Set< | |
| @@ -668,9 +663,7 @@ export namespace CompletionHandler { | |
| /** | |
| * Method allowing to update fields asynchronously. | |
| */ | |
| - resolve?: ( | |
| - patch?: Completer.IPatch | |
| - ) => Promise<CompletionHandler.ICompletionItem>; | |
| + resolve?: (patch?: Completer.IPatch) => Promise<CompletionHandler.ICompletionItem>; | |
| } | |
| /** | |
| @@ -689,8 +682,7 @@ export namespace CompletionHandler { | |
| * A reply to a completion items fetch request. | |
| */ | |
| export interface ICompletionItemsReply< | |
| - T extends CompletionHandler.ICompletionItem = | |
| - CompletionHandler.ICompletionItem | |
| + T extends CompletionHandler.ICompletionItem = CompletionHandler.ICompletionItem | |
| > { | |
| /** | |
| * The starting index for the substring being replaced by completion. | |
| diff --git a/packages/completer/src/inline.ts b/packages/completer/src/inline.ts | |
| index c17f2d71d3..8b0943e072 100644 | |
| --- a/packages/completer/src/inline.ts | |
| +++ b/packages/completer/src/inline.ts | |
| @@ -85,26 +85,14 @@ export class InlineCompleter extends Widget { | |
| return; | |
| } | |
| if (this._model) { | |
| - this._model.suggestionsChanged.disconnect( | |
| - this._onModelSuggestionsChanged, | |
| - this | |
| - ); | |
| - this._model.filterTextChanged.disconnect( | |
| - this._onModelFilterTextChanged, | |
| - this | |
| - ); | |
| + this._model.suggestionsChanged.disconnect(this._onModelSuggestionsChanged, this); | |
| + this._model.filterTextChanged.disconnect(this._onModelFilterTextChanged, this); | |
| this._model.provisionProgress.disconnect(this._onProvisionProgress, this); | |
| } | |
| this._model = model; | |
| if (this._model) { | |
| - this._model.suggestionsChanged.connect( | |
| - this._onModelSuggestionsChanged, | |
| - this | |
| - ); | |
| - this._model.filterTextChanged.connect( | |
| - this._onModelFilterTextChanged, | |
| - this | |
| - ); | |
| + this._model.suggestionsChanged.connect(this._onModelSuggestionsChanged, this); | |
| + this._model.filterTextChanged.connect(this._onModelFilterTextChanged, this); | |
| this._model.provisionProgress.connect(this._onProvisionProgress, this); | |
| } | |
| } | |
| @@ -199,10 +187,7 @@ export class InlineCompleter extends Widget { | |
| this._updateShortcutsVisibility(); | |
| } | |
| GhostTextManager.streamingAnimation = settings.streamingAnimation; | |
| - GhostTextManager.spacerRemovalDelay = Math.max( | |
| - 0, | |
| - settings.editorResizeDelay - 300 | |
| - ); | |
| + GhostTextManager.spacerRemovalDelay = Math.max(0, settings.editorResizeDelay - 300); | |
| GhostTextManager.spacerRemovalDuration = Math.max( | |
| 0, | |
| Math.min(300, settings.editorResizeDelay - 300) | |
| @@ -225,9 +210,7 @@ export class InlineCompleter extends Widget { | |
| * Whether the inline completer is active. | |
| */ | |
| get isActive(): boolean { | |
| - return !!this.editor?.host.classList.contains( | |
| - INLINE_COMPLETER_ACTIVE_CLASS | |
| - ); | |
| + return !!this.editor?.host.classList.contains(INLINE_COMPLETER_ACTIVE_CLASS); | |
| } | |
| /** | |
| @@ -441,9 +424,7 @@ export class InlineCompleter extends Widget { | |
| let minLines: number; | |
| if (this._reserveSpaceForLongest) { | |
| const items = this.model?.completions?.items ?? []; | |
| - const longest = Math.max( | |
| - ...items.map(i => i.insertText.split('\n').length) | |
| - ); | |
| + const longest = Math.max(...items.map(i => i.insertText.split('\n').length)); | |
| minLines = Math.max(this._minLines, longest); | |
| } else { | |
| minLines = this._minLines; | |
| @@ -644,9 +625,7 @@ export namespace InlineCompleter { | |
| /** | |
| * Set completions clearing existing ones. | |
| */ | |
| - setCompletions( | |
| - reply: IInlineCompletionList<CompletionHandler.IInlineItem> | |
| - ): void; | |
| + setCompletions(reply: IInlineCompletionList<CompletionHandler.IInlineItem>): void; | |
| /** | |
| * Append completions while preserving new ones. | |
| @@ -680,9 +659,7 @@ export namespace InlineCompleter { | |
| * Model for inline completions. | |
| */ | |
| export class Model implements InlineCompleter.IModel { | |
| - setCompletions( | |
| - reply: IInlineCompletionList<CompletionHandler.IInlineItem> | |
| - ) { | |
| + setCompletions(reply: IInlineCompletionList<CompletionHandler.IInlineItem>) { | |
| const previousPositions: Map<string, number> = new Map( | |
| this._completions?.items?.map((item, index) => [item.insertText, index]) | |
| ); | |
| @@ -699,9 +676,7 @@ export namespace InlineCompleter { | |
| }); | |
| } | |
| - appendCompletions( | |
| - reply: IInlineCompletionList<CompletionHandler.IInlineItem> | |
| - ) { | |
| + appendCompletions(reply: IInlineCompletionList<CompletionHandler.IInlineItem>) { | |
| if (!this._completions || !this._completions.items) { | |
| console.warn('No completions to append to'); | |
| return; | |
| @@ -740,15 +715,12 @@ export namespace InlineCompleter { | |
| handleTextChange(sourceChange: SourceChange) { | |
| const completions = this._completions; | |
| - if ( | |
| - !completions || | |
| - !completions.items || | |
| - completions.items.length === 0 | |
| - ) { | |
| + if (!completions || !completions.items || completions.items.length === 0) { | |
| return; | |
| } | |
| - const originalPositions: Map<CompletionHandler.IInlineItem, number> = | |
| - new Map(completions.items.map((item, index) => [item, index])); | |
| + const originalPositions: Map<CompletionHandler.IInlineItem, number> = new Map( | |
| + completions.items.map((item, index) => [item, index]) | |
| + ); | |
| for (let change of sourceChange.sourceChange ?? []) { | |
| const insert = change.insert; | |
| if (insert) { | |
| @@ -791,10 +763,7 @@ export namespace InlineCompleter { | |
| // Cancel if user started selecting text. | |
| this.reset(); | |
| } | |
| - if ( | |
| - start.line !== initialCursor.line || | |
| - start.column < initialCursor.column | |
| - ) { | |
| + if (start.line !== initialCursor.line || start.column < initialCursor.column) { | |
| // Cancel if user moved cursor to next line or receded to before the origin | |
| this.reset(); | |
| } | |
| diff --git a/packages/completer/src/manager.ts b/packages/completer/src/manager.ts | |
| index b736b4da10..5edf168ac7 100644 | |
| --- a/packages/completer/src/manager.ts | |
| +++ b/packages/completer/src/manager.ts | |
| @@ -35,13 +35,8 @@ export class CompletionProviderManager implements ICompletionProviderManager { | |
| this._inlineProviders = new Map(); | |
| this._panelHandlers = new Map(); | |
| this._mostRecentContext = new Map(); | |
| - this._activeProvidersChanged = new Signal<ICompletionProviderManager, void>( | |
| - this | |
| - ); | |
| - this._selected = new Signal< | |
| - ICompletionProviderManager, | |
| - ICompleterSelection | |
| - >(this); | |
| + this._activeProvidersChanged = new Signal<ICompletionProviderManager, void>(this); | |
| + this._selected = new Signal<ICompletionProviderManager, ICompleterSelection>(this); | |
| this._inlineCompleterFactory = null; | |
| } | |
| @@ -72,9 +67,7 @@ export class CompletionProviderManager implements ICompletionProviderManager { | |
| * Enable/disable the document panel. | |
| */ | |
| setShowDocumentationPanel(showDoc: boolean): void { | |
| - this._panelHandlers.forEach( | |
| - handler => (handler.completer.showDocsPanel = showDoc) | |
| - ); | |
| + this._panelHandlers.forEach(handler => (handler.completer.showDocsPanel = showDoc)); | |
| this._showDoc = showDoc; | |
| } | |
| @@ -162,9 +155,7 @@ export class CompletionProviderManager implements ICompletionProviderManager { | |
| * | |
| * @param newCompleterContext - The completion context. | |
| */ | |
| - async updateCompleter( | |
| - newCompleterContext: ICompletionContext | |
| - ): Promise<void> { | |
| + async updateCompleter(newCompleterContext: ICompletionContext): Promise<void> { | |
| const { widget, editor, sanitizer } = newCompleterContext; | |
| const id = widget.id; | |
| const handler = this._panelHandlers.get(id); | |
| @@ -172,8 +163,7 @@ export class CompletionProviderManager implements ICompletionProviderManager { | |
| const firstProvider = [...this._activeProviders][0]; | |
| const provider = this._providers.get(firstProvider); | |
| - let renderer = | |
| - provider?.renderer ?? Completer.getDefaultRenderer(sanitizer); | |
| + let renderer = provider?.renderer ?? Completer.getDefaultRenderer(sanitizer); | |
| const modelFactory = provider?.modelFactory; | |
| let model: Completer.IModel; | |
| if (modelFactory) { | |
| @@ -209,16 +199,14 @@ export class CompletionProviderManager implements ICompletionProviderManager { | |
| completer.model = options.model; | |
| completer.renderer = options.renderer; | |
| completer.showDocsPanel = options.showDoc; | |
| - completer.suppressIfInlineCompleterActive = | |
| - this._suppressIfInlineCompleterActive; | |
| + completer.suppressIfInlineCompleterActive = this._suppressIfInlineCompleterActive; | |
| // Update other handler attributes. | |
| handler.autoCompletion = this._autoCompletion; | |
| if (editor) { | |
| handler.editor = editor; | |
| - handler.reconciliator = | |
| - await this.generateReconciliator(newCompleterContext); | |
| + handler.reconciliator = await this.generateReconciliator(newCompleterContext); | |
| } | |
| } | |
| } | |
| @@ -332,8 +320,8 @@ export class CompletionProviderManager implements ICompletionProviderManager { | |
| enabledProviders.push(id); | |
| } | |
| } | |
| - const inlineProviders = [...this._inlineProviders.values()].filter( | |
| - provider => enabledProviders.includes(provider.identifier) | |
| + const inlineProviders = [...this._inlineProviders.values()].filter(provider => | |
| + enabledProviders.includes(provider.identifier) | |
| ); | |
| const providers: Array<ICompletionProvider> = []; | |
| diff --git a/packages/completer/src/model.ts b/packages/completer/src/model.ts | |
| index acfa338e54..a95cb6808c 100644 | |
| --- a/packages/completer/src/model.ts | |
| +++ b/packages/completer/src/model.ts | |
| @@ -45,9 +45,7 @@ export class CompleterModel implements Completer.IModel { | |
| set original(newValue: Completer.ITextState | null) { | |
| const unchanged = | |
| this._original === newValue || | |
| - (this._original && | |
| - newValue && | |
| - JSONExt.deepEqual(newValue, this._original)); | |
| + (this._original && newValue && JSONExt.deepEqual(newValue, this._original)); | |
| if (unchanged) { | |
| return; | |
| } | |
| @@ -220,9 +218,7 @@ export class CompleterModel implements Completer.IModel { | |
| return; | |
| } | |
| this._completionItems = newValue; | |
| - this._orderedTypes = Private.findOrderedCompletionItemTypes( | |
| - this._completionItems | |
| - ); | |
| + this._orderedTypes = Private.findOrderedCompletionItemTypes(this._completionItems); | |
| this.processedItemsCache = null; | |
| this._processedToOriginalItem = null; | |
| this._stateChanged.emit(undefined); | |
| @@ -389,9 +385,7 @@ export class CompleterModel implements Completer.IModel { | |
| // don't count parameters, `b`, `a`, and `r` as matches. | |
| const index = originalItem.label.indexOf('('); | |
| const text = | |
| - index > -1 | |
| - ? originalItem.label.substring(0, index) | |
| - : originalItem.label; | |
| + index > -1 ? originalItem.label.substring(0, index) : originalItem.label; | |
| const match = StringExt.matchSumOfSquares(escapeHTML(text), query); | |
| // Filter non-matching items. | |
| if (match) { | |
| @@ -404,8 +398,7 @@ export class CompleterModel implements Completer.IModel { | |
| // Use `Object.assign` to evaluate getters. | |
| const highlightedItem = Object.assign({}, originalItem); | |
| highlightedItem.label = marked.join(''); | |
| - highlightedItem.insertText = | |
| - originalItem.insertText ?? originalItem.label; | |
| + highlightedItem.insertText = originalItem.insertText ?? originalItem.label; | |
| results.push({ | |
| item: highlightedItem, | |
| score: match.score, | |
| @@ -489,14 +482,10 @@ export class CompleterModel implements Completer.IModel { | |
| // Escape the label it in place | |
| this._escapeItemLabel(activeItem, true); | |
| ( | |
| - Object.keys(activeItem) as Array< | |
| - keyof CompletionHandler.ICompletionItem | |
| - > | |
| - ).forEach( | |
| - <Key extends keyof CompletionHandler.ICompletionItem>(key: Key) => { | |
| - completionItem[key] = activeItem[key]; | |
| - } | |
| - ); | |
| + Object.keys(activeItem) as Array<keyof CompletionHandler.ICompletionItem> | |
| + ).forEach(<Key extends keyof CompletionHandler.ICompletionItem>(key: Key) => { | |
| + completionItem[key] = activeItem[key]; | |
| + }); | |
| completionItem.resolve = undefined; | |
| if (current !== this._resolvingItem) { | |
| return Promise.resolve(null); | |
| @@ -549,8 +538,7 @@ export class CompleterModel implements Completer.IModel { | |
| } | |
| } | |
| - protected processedItemsCache: CompletionHandler.ICompletionItems | null = | |
| - null; | |
| + protected processedItemsCache: CompletionHandler.ICompletionItems | null = null; | |
| private _current: Completer.ITextState | null = null; | |
| private _cursor: Completer.ICursorSpan | null = null; | |
| private _isDisposed = false; | |
| @@ -704,8 +692,7 @@ namespace Private { | |
| const filtered = Object.keys(typeMap) | |
| .map(key => typeMap[key]) | |
| .filter( | |
| - (value: string | null): value is string => | |
| - !!value && !(value in KNOWN_MAP) | |
| + (value: string | null): value is string => !!value && !(value in KNOWN_MAP) | |
| ) | |
| .sort((a, b) => a.localeCompare(b)); | |
| diff --git a/packages/completer/src/reconciliator.ts b/packages/completer/src/reconciliator.ts | |
| index b0da23bc97..beb7f121f5 100644 | |
| --- a/packages/completer/src/reconciliator.ts | |
| +++ b/packages/completer/src/reconciliator.ts | |
| @@ -18,8 +18,7 @@ import { Signal } from '@lumino/signaling'; | |
| import { isHintableMimeType } from './utils'; | |
| // Shorthand for readability. | |
| -export type InlineResult = | |
| - IInlineCompletionList<CompletionHandler.IInlineItem> | null; | |
| +export type InlineResult = IInlineCompletionList<CompletionHandler.IInlineItem> | null; | |
| /** | |
| * The reconciliator which is used to fetch and merge responses from multiple completion providers. | |
| @@ -54,9 +53,7 @@ export class ProviderReconciliator implements IProviderReconciliator { | |
| trigger: InlineCompletionTriggerKind, | |
| isMiddleOfLine?: boolean | |
| ): Promise<InlineResult>[] { | |
| - let promises: Promise< | |
| - IInlineCompletionList<CompletionHandler.IInlineItem> | |
| - >[] = []; | |
| + let promises: Promise<IInlineCompletionList<CompletionHandler.IInlineItem>>[] = []; | |
| const current = ++this._inlineFetching; | |
| for (const provider of this._inlineProviders) { | |
| const settings = this._inlineProvidersSettings[provider.identifier]; | |
| @@ -160,8 +157,7 @@ export class ProviderReconciliator implements IProviderReconciliator { | |
| trigger?: CompletionTriggerKind | |
| ): Promise<CompletionHandler.ICompletionItemsReply | null> { | |
| const current = ++this._fetching; | |
| - let promises: Promise<CompletionHandler.ICompletionItemsReply | null>[] = | |
| - []; | |
| + let promises: Promise<CompletionHandler.ICompletionItemsReply | null>[] = []; | |
| const applicableProviders = await this.applicableProviders(); | |
| for (const provider of applicableProviders) { | |
| let promise: Promise<CompletionHandler.ICompletionItemsReply | null>; | |
| @@ -334,8 +330,7 @@ export class ProviderReconciliator implements IProviderReconciliator { | |
| el: CompletionHandler.ICompletionItem | |
| ) => | |
| provider.resolve | |
| - ? (patch?: Completer.IPatch) => | |
| - provider.resolve!(el, this._context, patch) | |
| + ? (patch?: Completer.IPatch) => provider.resolve!(el, this._context, patch) | |
| : undefined; | |
| /** | |
| diff --git a/packages/completer/src/tokens.ts b/packages/completer/src/tokens.ts | |
| index 7b28cd9af6..8f688482f2 100644 | |
| --- a/packages/completer/src/tokens.ts | |
| +++ b/packages/completer/src/tokens.ts | |
| @@ -54,8 +54,7 @@ export interface ICompletionContext { | |
| * The interface to implement a completion provider. | |
| */ | |
| export interface ICompletionProvider< | |
| - T extends CompletionHandler.ICompletionItem = | |
| - CompletionHandler.ICompletionItem | |
| + T extends CompletionHandler.ICompletionItem = CompletionHandler.ICompletionItem | |
| > { | |
| /** | |
| * Unique identifier of the provider | |
| diff --git a/packages/completer/src/widget.ts b/packages/completer/src/widget.ts | |
| index 10865e0d33..731899e015 100644 | |
| --- a/packages/completer/src/widget.ts | |
| +++ b/packages/completer/src/widget.ts | |
| @@ -89,10 +89,7 @@ export class Completer extends Widget { | |
| this._scrollbarWidth = tempNode.offsetWidth - tempNode.clientWidth; | |
| document.body.removeChild(tempNode); | |
| const tempDocPanel = this._createDocPanelNode(); | |
| - this._docPanelWidth = Private.measureSize( | |
| - tempDocPanel, | |
| - 'inline-block' | |
| - ).width; | |
| + this._docPanelWidth = Private.measureSize(tempDocPanel, 'inline-block').width; | |
| } | |
| /** | |
| @@ -411,26 +408,17 @@ export class Completer extends Widget { | |
| // Add first N items to fill the first "page" assuming that the completer | |
| // would reach its maximum allowed height. | |
| - const first = this._renderer.createCompletionItemNode( | |
| - items[0], | |
| - orderedTypes | |
| - ); | |
| + const first = this._renderer.createCompletionItemNode(items[0], orderedTypes); | |
| const renderedItems = [first]; | |
| const firstItemSize = Private.measureSize(first, 'inline-grid'); | |
| - const pageSize = Math.max( | |
| - Math.ceil(this._maxHeight / firstItemSize.height), | |
| - 5 | |
| - ); | |
| + const pageSize = Math.max(Math.ceil(this._maxHeight / firstItemSize.height), 5); | |
| // We add one item in case if height heuristic is inaccurate. | |
| const toRenderImmediately = Math.min(pageSize + 1, items.length); | |
| const start = performance.now(); | |
| for (let i = 1; i < toRenderImmediately; i++) { | |
| - const li = this._renderer.createCompletionItemNode( | |
| - items[i], | |
| - orderedTypes | |
| - ); | |
| + const li = this._renderer.createCompletionItemNode(items[i], orderedTypes); | |
| renderedItems.push(li); | |
| } | |
| @@ -446,10 +434,7 @@ export class Completer extends Widget { | |
| const widestItem = | |
| widestItemIndex < renderedItems.length | |
| ? renderedItems[widestItemIndex] | |
| - : this._renderer.createCompletionItemNode( | |
| - items[widestItemIndex], | |
| - orderedTypes | |
| - ); | |
| + : this._renderer.createCompletionItemNode(items[widestItemIndex], orderedTypes); | |
| // The node needs to be cloned to avoid side-effect of detaching it. | |
| const widestItemSize = Private.measureSize( | |
| @@ -495,10 +480,7 @@ export class Completer extends Widget { | |
| previousChunkFinal.style.marginBottom = ''; | |
| const limit = Math.min(items.length, alreadyRendered + chunkSize); | |
| for (let i = alreadyRendered; i < limit; i++) { | |
| - const li = this._renderer.createCompletionItemNode( | |
| - items[i], | |
| - orderedTypes | |
| - ); | |
| + const li = this._renderer.createCompletionItemNode(items[i], orderedTypes); | |
| ul.appendChild(li); | |
| previousChunkFinal = li; | |
| } | |
| @@ -517,9 +499,7 @@ export class Completer extends Widget { | |
| /** | |
| * Use preferred heuristic to find the index of the widest item. | |
| */ | |
| - private _findWidestItemIndex( | |
| - items: CompletionHandler.ICompletionItems | |
| - ): number { | |
| + private _findWidestItemIndex(items: CompletionHandler.ICompletionItems): number { | |
| const widthHeuristic = this._getPreferredItemWidthHeuristic(); | |
| const widthHeuristics = items.map(widthHeuristic); | |
| @@ -1147,8 +1127,7 @@ export namespace Completer { | |
| * A renderer for completer widget nodes. | |
| */ | |
| export interface IRenderer< | |
| - T extends CompletionHandler.ICompletionItem = | |
| - CompletionHandler.ICompletionItem | |
| + T extends CompletionHandler.ICompletionItem = CompletionHandler.ICompletionItem | |
| > { | |
| /** | |
| * Create an item node (an `li` element) from a ICompletionItem | |
| @@ -1355,13 +1334,8 @@ export namespace Completer { | |
| /** | |
| * The default `IRenderer` instance. | |
| */ | |
| - export function getDefaultRenderer( | |
| - sanitizer?: IRenderMime.ISanitizer | |
| - ): Renderer { | |
| - if ( | |
| - !_defaultRenderer || | |
| - (sanitizer && _defaultRenderer.sanitizer !== sanitizer) | |
| - ) { | |
| + export function getDefaultRenderer(sanitizer?: IRenderMime.ISanitizer): Renderer { | |
| + if (!_defaultRenderer || (sanitizer && _defaultRenderer.sanitizer !== sanitizer)) { | |
| _defaultRenderer = new Renderer({ sanitizer: sanitizer }); | |
| } | |
| return _defaultRenderer; | |
| @@ -1445,9 +1419,7 @@ namespace Private { | |
| */ | |
| export function measureSize(element: HTMLElement, display: string): DOMRect { | |
| if (element.isConnected) { | |
| - console.warn( | |
| - 'Measuring connected elements with `measureSize` has side-effects' | |
| - ); | |
| + console.warn('Measuring connected elements with `measureSize` has side-effects'); | |
| } | |
| element.style.visibility = 'hidden'; | |
| element.style.display = display; | |
| diff --git a/packages/completer/style/base.css b/packages/completer/style/base.css | |
| index a5706ce1ae..f82da84649 100644 | |
| --- a/packages/completer/style/base.css | |
| +++ b/packages/completer/style/base.css | |
| @@ -102,8 +102,7 @@ | |
| font-family: var(--jp-ui-font-family); | |
| font-size: var(--jp-ui-font-size1); | |
| line-height: calc( | |
| - var(--jp-private-completer-item-height) - | |
| - var(--jp-private-completer-type-offset) | |
| + var(--jp-private-completer-item-height) - var(--jp-private-completer-type-offset) | |
| ); | |
| padding-bottom: var(--jp-private-completer-type-offset); | |
| } | |
| @@ -380,8 +379,7 @@ | |
| background: none; | |
| } | |
| -.jp-InlineCompleter[data-show-shortcuts='false'] | |
| - .jp-ToolbarButtonComponent-label { | |
| +.jp-InlineCompleter[data-show-shortcuts='false'] .jp-ToolbarButtonComponent-label { | |
| display: none; | |
| } | |
| diff --git a/packages/completer/test/inline.spec.ts b/packages/completer/test/inline.spec.ts | |
| index 20231f7d1e..e8f24eb0a6 100644 | |
| --- a/packages/completer/test/inline.spec.ts | |
| +++ b/packages/completer/test/inline.spec.ts | |
| @@ -11,12 +11,7 @@ import { Widget } from '@lumino/widgets'; | |
| import { MessageLoop } from '@lumino/messaging'; | |
| import type { Text } from 'yjs'; | |
| import { Doc } from 'yjs'; | |
| -import type { | |
| - CellChange, | |
| - FileChange, | |
| - ISharedText, | |
| - SourceChange | |
| -} from '@jupyter/ydoc'; | |
| +import type { CellChange, FileChange, ISharedText, SourceChange } from '@jupyter/ydoc'; | |
| const GHOST_TEXT_CLASS = 'jp-GhostText'; | |
| const STREAMING_INDICATOR_CLASS = 'jp-GhostText-streamingIndicator'; | |
| @@ -86,9 +81,7 @@ describe('completer/inline', () => { | |
| items: suggestionsAbc | |
| }); | |
| completer.accept(); | |
| - expect(editorWidget.editor.model.sharedModel.source).toBe( | |
| - 'suggestion a' | |
| - ); | |
| + expect(editorWidget.editor.model.sharedModel.source).toBe('suggestion a'); | |
| }); | |
| it('should set the cursor position at the same time as the completion suggestion', () => { | |
| @@ -114,9 +107,7 @@ describe('completer/inline', () => { | |
| try { | |
| completer.accept(); | |
| } finally { | |
| - editorWidget.editor.model.sharedModel.changed.disconnect( | |
| - onContentChange | |
| - ); | |
| + editorWidget.editor.model.sharedModel.changed.disconnect(onContentChange); | |
| } | |
| expect(editorPosition).toEqual({ | |
| line: 0, | |
| @@ -142,9 +133,7 @@ describe('completer/inline', () => { | |
| it('should render the completion as it is streamed', async () => { | |
| Widget.attach(editorWidget, document.body); | |
| Widget.attach(completer, document.body); | |
| - const stream = new Signal<any, CompletionHandler.StraemEvent>( | |
| - {} as any | |
| - ); | |
| + const stream = new Signal<any, CompletionHandler.StraemEvent>({} as any); | |
| const item: CompletionHandler.IInlineItem = { | |
| insertText: 'this', | |
| streaming: true, | |
| @@ -190,9 +179,7 @@ describe('completer/inline', () => { | |
| it('should render the error if stream errors out', async () => { | |
| Widget.attach(editorWidget, document.body); | |
| Widget.attach(completer, document.body); | |
| - const stream = new Signal<any, CompletionHandler.StraemEvent>( | |
| - {} as any | |
| - ); | |
| + const stream = new Signal<any, CompletionHandler.StraemEvent>({} as any); | |
| const item: CompletionHandler.IInlineItem = { | |
| insertText: 'this', | |
| streaming: true, | |
| @@ -329,8 +316,7 @@ describe('completer/inline', () => { | |
| const ghost = findInHost(`.${GHOST_TEXT_CLASS}`) as HTMLElement; | |
| // jest-dom does not support textContent/innerText properly, we need to extract it manually | |
| return ( | |
| - ghost.innerText + | |
| - [...ghost.childNodes].map(node => node.textContent).join('') | |
| + ghost.innerText + [...ghost.childNodes].map(node => node.textContent).join('') | |
| ); | |
| }; | |
| diff --git a/packages/completer/test/kernelprovider.spec.ts b/packages/completer/test/kernelprovider.spec.ts | |
| index a1674ea440..7fdd00bcc3 100644 | |
| --- a/packages/completer/test/kernelprovider.spec.ts | |
| +++ b/packages/completer/test/kernelprovider.spec.ts | |
| @@ -4,10 +4,7 @@ | |
| import type { KernelMessage } from '@jupyterlab/services'; | |
| import type { ICompletionContext } from '@jupyterlab/completer'; | |
| import { KernelCompleterProvider } from '@jupyterlab/completer'; | |
| -import { | |
| - KernelMock, | |
| - SessionConnectionMock | |
| -} from '@jupyterlab/services/lib/testutils'; | |
| +import { KernelMock, SessionConnectionMock } from '@jupyterlab/services/lib/testutils'; | |
| describe('completer/default/kernelprovider', () => { | |
| describe('KernelCompleterProvider', () => { | |
| diff --git a/packages/completer/test/model.spec.ts b/packages/completer/test/model.spec.ts | |
| index d6edcd00ba..8092cfdef0 100644 | |
| --- a/packages/completer/test/model.spec.ts | |
| +++ b/packages/completer/test/model.spec.ts | |
| @@ -547,8 +547,7 @@ describe('completer/model', () => { | |
| const model = new CompleterModel(); | |
| const item = { | |
| label: 'foo', | |
| - resolve: () => | |
| - Promise.resolve({ label: 'foo', documentation: 'Foo docs' }) | |
| + resolve: () => Promise.resolve({ label: 'foo', documentation: 'Foo docs' }) | |
| }; | |
| model.setCompletionItems([item]); | |
| const resolved = await model.resolveItem(0); | |
| @@ -563,8 +562,7 @@ describe('completer/model', () => { | |
| const model = new CompleterModel(); | |
| const item = { | |
| label: 'foo', | |
| - resolve: () => | |
| - Promise.resolve({ label: 'foo', documentation: 'Foo docs' }) | |
| + resolve: () => Promise.resolve({ label: 'foo', documentation: 'Foo docs' }) | |
| }; | |
| const resolved = await model.resolveItem(item); | |
| expect(resolved).toEqual({ label: 'foo', documentation: 'Foo docs' }); | |
| diff --git a/packages/console-extension/src/foreign.ts b/packages/console-extension/src/foreign.ts | |
| index faec1d090f..410ffee8c1 100644 | |
| --- a/packages/console-extension/src/foreign.ts | |
| +++ b/packages/console-extension/src/foreign.ts | |
| @@ -1,10 +1,7 @@ | |
| // Copyright (c) Jupyter Development Team. | |
| // Distributed under the terms of the Modified BSD License. | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { ICommandPalette } from '@jupyterlab/apputils'; | |
| import type { CodeConsole, ConsolePanel } from '@jupyterlab/console'; | |
| import { ForeignHandler, IConsoleTracker } from '@jupyterlab/console'; | |
| @@ -86,11 +83,9 @@ function activateForeign( | |
| }, | |
| isToggled: () => | |
| tracker.currentWidget !== null && | |
| - !!Private.foreignHandlerProperty.get(tracker.currentWidget.console) | |
| - ?.enabled, | |
| + !!Private.foreignHandlerProperty.get(tracker.currentWidget.console)?.enabled, | |
| isEnabled: () => | |
| - tracker.currentWidget !== null && | |
| - tracker.currentWidget === shell.currentWidget, | |
| + tracker.currentWidget !== null && tracker.currentWidget === shell.currentWidget, | |
| describedBy: { | |
| args: { | |
| type: 'object', | |
| diff --git a/packages/console-extension/src/index.ts b/packages/console-extension/src/index.ts | |
| index 29d1ad9219..5793a81623 100644 | |
| --- a/packages/console-extension/src/index.ts | |
| +++ b/packages/console-extension/src/index.ts | |
| @@ -5,10 +5,7 @@ | |
| * @module console-extension | |
| */ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { ILabStatus, ILayoutRestorer } from '@jupyterlab/application'; | |
| import type { ISessionContext } from '@jupyterlab/apputils'; | |
| import { | |
| @@ -207,9 +204,7 @@ const lineColStatus: JupyterFrontEndPlugin<void> = { | |
| const provider = async (widget: Widget | null) => { | |
| let editor: CodeEditor.IEditor | null = null; | |
| if (widget !== previousWidget) { | |
| - previousWidget?.console.promptCellCreated.disconnect( | |
| - positionModel.update | |
| - ); | |
| + previousWidget?.console.promptCellCreated.disconnect(positionModel.update); | |
| previousWidget = null; | |
| if (widget && tracker.has(widget)) { | |
| @@ -289,8 +284,7 @@ async function activateConsole( | |
| const manager = app.serviceManager; | |
| const { commands, shell } = app; | |
| const category = trans.__('Console'); | |
| - const sessionDialogs = | |
| - sessionDialogs_ ?? new SessionContextDialogs({ translator }); | |
| + const sessionDialogs = sessionDialogs_ ?? new SessionContextDialogs({ translator }); | |
| const pluginId = '@jupyterlab/console-extension:tracker'; | |
| const promptCellPositions: CodeConsole.PromptCellPosition[] = [ | |
| @@ -336,22 +330,18 @@ async function activateConsole( | |
| promptMenu.addItem({ command: `console:prompt-to-${position}` }); | |
| }); | |
| - toolbarRegistry.addFactory<ConsolePanel>( | |
| - factory, | |
| - 'promptPosition', | |
| - panel => { | |
| - const button = new ToolbarButton({ | |
| - tooltip: trans.__('Change Console Prompt Position'), | |
| - icon: dotsIcon, | |
| - onClick: () => { | |
| - const right = button.node.getBoundingClientRect().right; | |
| - const bottom = button.node.getBoundingClientRect().bottom; | |
| - promptMenu.open(right, bottom, { horizontalAlignment: 'right' }); | |
| - } | |
| - }); | |
| - return button; | |
| - } | |
| - ); | |
| + toolbarRegistry.addFactory<ConsolePanel>(factory, 'promptPosition', panel => { | |
| + const button = new ToolbarButton({ | |
| + tooltip: trans.__('Change Console Prompt Position'), | |
| + icon: dotsIcon, | |
| + onClick: () => { | |
| + const right = button.node.getBoundingClientRect().right; | |
| + const bottom = button.node.getBoundingClientRect().bottom; | |
| + promptMenu.open(right, bottom, { horizontalAlignment: 'right' }); | |
| + } | |
| + }); | |
| + return button; | |
| + }); | |
| } | |
| // Create a widget tracker for all console panels. | |
| @@ -403,9 +393,7 @@ async function activateConsole( | |
| rank, | |
| kernelIconUrl, | |
| metadata: { | |
| - kernel: JSONExt.deepCopy( | |
| - spec.metadata || {} | |
| - ) as ReadonlyJSONValue | |
| + kernel: JSONExt.deepCopy(spec.metadata || {}) as ReadonlyJSONValue | |
| } | |
| }) | |
| ); | |
| @@ -542,9 +530,8 @@ async function activateConsole( | |
| * @param panel Optional - single console to update. | |
| */ | |
| async function updateSettings(panel?: ConsolePanel) { | |
| - clearCellsOnExecute = ( | |
| - await settingRegistry.get(pluginId, 'clearCellsOnExecute') | |
| - ).composite as boolean; | |
| + clearCellsOnExecute = (await settingRegistry.get(pluginId, 'clearCellsOnExecute')) | |
| + .composite as boolean; | |
| clearCodeContentOnExecute = ( | |
| await settingRegistry.get(pluginId, 'clearCodeContentOnExecute') | |
| ).composite as boolean; | |
| @@ -554,9 +541,8 @@ async function activateConsole( | |
| .composite as string; | |
| promptCellConfig = (await settingRegistry.get(pluginId, 'promptCellConfig')) | |
| .composite as JSONObject; | |
| - promptCellPosition = ( | |
| - await settingRegistry.get(pluginId, 'promptCellPosition') | |
| - ).composite as CodeConsole.PromptCellPosition; | |
| + promptCellPosition = (await settingRegistry.get(pluginId, 'promptCellPosition')) | |
| + .composite as CodeConsole.PromptCellPosition; | |
| showBanner = (await settingRegistry.get(pluginId, 'showBanner')) | |
| .composite as boolean; | |
| @@ -715,15 +701,11 @@ async function activateConsole( | |
| properties: { | |
| isPalette: { | |
| type: 'boolean', | |
| - description: trans.__( | |
| - 'Whether the command is executed from the palette' | |
| - ) | |
| + description: trans.__('Whether the command is executed from the palette') | |
| }, | |
| isLauncher: { | |
| type: 'boolean', | |
| - description: trans.__( | |
| - 'Whether the command is executed from the launcher' | |
| - ) | |
| + description: trans.__('Whether the command is executed from the launcher') | |
| }, | |
| kernelPreference: { | |
| type: 'object', | |
| @@ -751,9 +733,7 @@ async function activateConsole( | |
| }, | |
| canStart: { | |
| type: 'boolean', | |
| - description: trans.__( | |
| - 'A kernel can be started (default `true`)' | |
| - ) | |
| + description: trans.__('A kernel can be started (default `true`)') | |
| }, | |
| shutdownOnDispose: { | |
| type: 'boolean', | |
| @@ -789,9 +769,7 @@ async function activateConsole( | |
| }, | |
| ref: { | |
| type: 'string', | |
| - description: trans.__( | |
| - 'The reference widget id for the insert location' | |
| - ) | |
| + description: trans.__('The reference widget id for the insert location') | |
| }, | |
| insertMode: { | |
| type: 'string', | |
| @@ -813,8 +791,7 @@ async function activateConsole( | |
| // Get the current widget and activate unless the args specify otherwise. | |
| function getCurrent(args: ReadonlyPartialJSONObject): ConsolePanel | null { | |
| const widget = args[SemanticCommand.WIDGET] | |
| - ? (tracker.find(panel => panel.id === args[SemanticCommand.WIDGET]) ?? | |
| - null) | |
| + ? (tracker.find(panel => panel.id === args[SemanticCommand.WIDGET]) ?? null) | |
| : tracker.currentWidget; | |
| const activate = args['activate'] !== false; | |
| if (activate && widget) { | |
| @@ -842,8 +819,7 @@ async function activateConsole( | |
| } | |
| current.console.setConfig({ promptCellPosition: position }); | |
| }, | |
| - isEnabled: () => | |
| - !!tracker.currentWidget && tracker.currentWidget.isVisible, | |
| + isEnabled: () => !!tracker.currentWidget && tracker.currentWidget.isVisible, | |
| label: trans.__(`Prompt to ${position}`), | |
| icon: args => (args['isPalette'] ? undefined : iconMap[position]), | |
| describedBy: { | |
| @@ -856,9 +832,7 @@ async function activateConsole( | |
| }, | |
| isPalette: { | |
| type: 'boolean', | |
| - description: trans.__( | |
| - 'Whether the command is executed from palette' | |
| - ) | |
| + description: trans.__('Whether the command is executed from palette') | |
| } | |
| } | |
| } | |
| @@ -1185,10 +1159,7 @@ async function activateConsole( | |
| } | |
| return showDialog({ | |
| title: trans.__('Shut down the console?'), | |
| - body: trans.__( | |
| - 'Are you sure you want to close "%1"?', | |
| - current.title.label | |
| - ), | |
| + body: trans.__('Are you sure you want to close "%1"?', current.title.label), | |
| buttons: [ | |
| Dialog.cancelButton({ | |
| ariaLabel: trans.__('Cancel console Shut Down') | |
| @@ -1199,12 +1170,10 @@ async function activateConsole( | |
| ] | |
| }).then(result => { | |
| if (result.button.accept) { | |
| - return commands | |
| - .execute(CommandIDs.shutdown, { activate: false }) | |
| - .then(() => { | |
| - current.dispose(); | |
| - return true; | |
| - }); | |
| + return commands.execute(CommandIDs.shutdown, { activate: false }).then(() => { | |
| + current.dispose(); | |
| + return true; | |
| + }); | |
| } else { | |
| return false; | |
| } | |
| diff --git a/packages/console/src/history.ts b/packages/console/src/history.ts | |
| index d75ed440ac..08fe285b2e 100644 | |
| --- a/packages/console/src/history.ts | |
| +++ b/packages/console/src/history.ts | |
| @@ -321,10 +321,7 @@ export class ConsoleHistory implements IConsoleHistory { | |
| for (let i = 0; i < this._history.length; i++) { | |
| current = this._history[i]; | |
| - if ( | |
| - current !== last && | |
| - filterStr === current.slice(0, filterStr.length) | |
| - ) { | |
| + if (current !== last && filterStr === current.slice(0, filterStr.length)) { | |
| this._filtered.push((last = current)); | |
| } | |
| } | |
| diff --git a/packages/console/src/panel.ts b/packages/console/src/panel.ts | |
| index 6a74cb9bfc..ef633de55e 100644 | |
| --- a/packages/console/src/panel.ts | |
| +++ b/packages/console/src/panel.ts | |
| @@ -326,10 +326,7 @@ namespace Private { | |
| trans.__('Kernel: %1', panel.console.sessionContext.kernelDisplayName); | |
| if (connected) { | |
| - caption += trans.__( | |
| - '\nConnected: %1', | |
| - Time.format(connected.toISOString()) | |
| - ); | |
| + caption += trans.__('\nConnected: %1', Time.format(connected.toISOString())); | |
| } | |
| if (executed) { | |
| diff --git a/packages/console/src/widget.ts b/packages/console/src/widget.ts | |
| index 2c38ff3721..445daf2765 100644 | |
| --- a/packages/console/src/widget.ts | |
| +++ b/packages/console/src/widget.ts | |
| @@ -179,10 +179,7 @@ export class CodeConsole extends Widget { | |
| void this._onKernelChanged(); | |
| this.sessionContext.kernelChanged.connect(this._onKernelChanged, this); | |
| - this.sessionContext.statusChanged.connect( | |
| - this._onKernelStatusChanged, | |
| - this | |
| - ); | |
| + this.sessionContext.statusChanged.connect(this._onKernelStatusChanged, this); | |
| } | |
| /** | |
| @@ -477,8 +474,7 @@ export class CodeConsole extends Widget { | |
| showBanner | |
| } = config; | |
| this._config = { | |
| - clearCellsOnExecute: | |
| - clearCellsOnExecute ?? this._config.clearCellsOnExecute, | |
| + clearCellsOnExecute: clearCellsOnExecute ?? this._config.clearCellsOnExecute, | |
| clearCodeContentOnExecute: | |
| clearCodeContentOnExecute ?? this._config.clearCodeContentOnExecute, | |
| hideCodeInput: hideCodeInput ?? this._config.hideCodeInput, | |
| @@ -535,10 +531,7 @@ export class CodeConsole extends Widget { | |
| // Firefox 57, which can have `null` anywhere in its parent line. If we fail | |
| // to find a cell using `event.target`, try again using a target | |
| // reconstructed from the position of the click event. | |
| - target = document.elementFromPoint( | |
| - event.clientX, | |
| - event.clientY | |
| - ) as HTMLElement; | |
| + target = document.elementFromPoint(event.clientX, event.clientY) as HTMLElement; | |
| cellIndex = CellDragUtils.findCell(target, this._cells, cellFilter); | |
| } | |
| @@ -548,8 +541,10 @@ export class CodeConsole extends Widget { | |
| const cell = this._cells.get(cellIndex); | |
| - const targetArea: CellDragUtils.ICellTargetArea = | |
| - CellDragUtils.detectTargetArea(cell, event.target as HTMLElement); | |
| + const targetArea: CellDragUtils.ICellTargetArea = CellDragUtils.detectTargetArea( | |
| + cell, | |
| + event.target as HTMLElement | |
| + ); | |
| if (targetArea === 'prompt') { | |
| this._dragData = { | |
| @@ -587,18 +582,11 @@ export class CodeConsole extends Widget { | |
| /** | |
| * Start a drag event | |
| */ | |
| - private _startDrag( | |
| - index: number, | |
| - clientX: number, | |
| - clientY: number | |
| - ): Promise<void> { | |
| + private _startDrag(index: number, clientX: number, clientY: number): Promise<void> { | |
| const cellModel = this._focusedCell!.model as ICodeCellModel; | |
| const selected: nbformat.ICell[] = [cellModel.toJSON()]; | |
| - const dragImage = CellDragUtils.createCellDragImage( | |
| - this._focusedCell!, | |
| - selected | |
| - ); | |
| + const dragImage = CellDragUtils.createCellDragImage(this._focusedCell!, selected); | |
| this._drag = new Drag({ | |
| mimeData: new MimeData(), | |
| @@ -770,10 +758,7 @@ export class CodeConsole extends Widget { | |
| } | |
| // Also listen for content changes to handle shrinking when content is removed (e.g. line deletes) | |
| - promptCell.model.sharedModel.changed.connect( | |
| - this._onPromptContentChanged, | |
| - this | |
| - ); | |
| + promptCell.model.sharedModel.changed.connect(this._onPromptContentChanged, this); | |
| if (!this._config.clearCodeContentOnExecute) { | |
| promptCell.model.sharedModel.setSource(previousContent); | |
| @@ -814,10 +799,7 @@ export class CodeConsole extends Widget { | |
| * Handle the `'mouseup'` event for the widget. | |
| */ | |
| private _evtMouseUp(event: MouseEvent): void { | |
| - if ( | |
| - this.promptCell && | |
| - this.promptCell.node.contains(event.target as HTMLElement) | |
| - ) { | |
| + if (this.promptCell && this.promptCell.node.contains(event.target as HTMLElement)) { | |
| this.promptCell.editor!.focus(); | |
| } | |
| } | |
| @@ -889,9 +871,7 @@ export class CodeConsole extends Widget { | |
| private _handleInfo(info: KernelMessage.IInfoReplyMsg['content']): void { | |
| if (info.status !== 'ok') { | |
| if (this._banner) { | |
| - this._banner.model.sharedModel.setSource( | |
| - 'Error in getting kernel banner' | |
| - ); | |
| + this._banner.model.sharedModel.setSource('Error in getting kernel banner'); | |
| } | |
| return; | |
| } | |
| @@ -1179,9 +1159,7 @@ export class CodeConsole extends Widget { | |
| // Reset manual resize flag when layout changes | |
| this._hasManualResize = false; | |
| - this._splitPanel.orientation = ['left', 'right'].includes( | |
| - promptCellPosition | |
| - ) | |
| + this._splitPanel.orientation = ['left', 'right'].includes(promptCellPosition) | |
| ? 'horizontal' | |
| : 'vertical'; | |
| @@ -1337,10 +1315,7 @@ export namespace CodeConsole { | |
| /** | |
| * Default implementation of `IContentFactory`. | |
| */ | |
| - export class ContentFactory | |
| - extends Cell.ContentFactory | |
| - implements IContentFactory | |
| - { | |
| + export class ContentFactory extends Cell.ContentFactory implements IContentFactory { | |
| /** | |
| * Create a new code cell widget. | |
| * | |
| diff --git a/packages/console/test/history.spec.ts b/packages/console/test/history.spec.ts | |
| index b3ffb6f70d..fc47229cb2 100644 | |
| --- a/packages/console/test/history.spec.ts | |
| +++ b/packages/console/test/history.spec.ts | |
| @@ -37,10 +37,7 @@ const mockHistory = { | |
| class TestHistory extends ConsoleHistory { | |
| methods: string[] = []; | |
| - onEdgeRequest( | |
| - editor: CodeEditor.IEditor, | |
| - location: CodeEditor.EdgeLocation | |
| - ): void { | |
| + onEdgeRequest(editor: CodeEditor.IEditor, location: CodeEditor.EdgeLocation): void { | |
| this.methods.push('onEdgeRequest'); | |
| super.onEdgeRequest(editor, location); | |
| } | |
| @@ -160,9 +157,7 @@ describe('console/history', () => { | |
| describe('#onTextChange()', () => { | |
| it('should be called upon an editor text change', () => { | |
| const history = new TestHistory({ sessionContext }); | |
| - expect(history.methods).toEqual( | |
| - expect.not.arrayContaining(['onTextChange']) | |
| - ); | |
| + expect(history.methods).toEqual(expect.not.arrayContaining(['onTextChange'])); | |
| const model = new CodeEditor.Model({ | |
| sharedModel: createStandaloneCell({ cell_type: 'code' }) | |
| }); | |
| @@ -174,18 +169,14 @@ describe('console/history', () => { | |
| }); | |
| history.editor = editor; | |
| model.sharedModel.setSource('foo'); | |
| - expect(history.methods).toEqual( | |
| - expect.arrayContaining(['onTextChange']) | |
| - ); | |
| + expect(history.methods).toEqual(expect.arrayContaining(['onTextChange'])); | |
| }); | |
| }); | |
| describe('#onEdgeRequest()', () => { | |
| it('should be called upon an editor edge request', async () => { | |
| const history = new TestHistory({ sessionContext }); | |
| - expect(history.methods).toEqual( | |
| - expect.not.arrayContaining(['onEdgeRequest']) | |
| - ); | |
| + expect(history.methods).toEqual(expect.not.arrayContaining(['onEdgeRequest'])); | |
| const host = document.createElement('div'); | |
| const model = new CodeEditor.Model({ | |
| sharedModel: createStandaloneCell({ cell_type: 'code' }) | |
| @@ -199,9 +190,7 @@ describe('console/history', () => { | |
| history.push('foo'); | |
| const promise = signalToPromise(editor.model.sharedModel.changed); | |
| editor.edgeRequested.emit('top'); | |
| - expect(history.methods).toEqual( | |
| - expect.arrayContaining(['onEdgeRequest']) | |
| - ); | |
| + expect(history.methods).toEqual(expect.arrayContaining(['onEdgeRequest'])); | |
| await promise; | |
| expect(editor.model.sharedModel.getSource()).toBe('foo'); | |
| }); | |
| diff --git a/packages/console/test/panel.spec.ts b/packages/console/test/panel.spec.ts | |
| index 4e03c9cc4e..5210aeb2f5 100644 | |
| --- a/packages/console/test/panel.spec.ts | |
| +++ b/packages/console/test/panel.spec.ts | |
| @@ -105,9 +105,7 @@ describe('console/panel', () => { | |
| it('should start the session', async () => { | |
| Widget.attach(panel, document.body); | |
| await panel.sessionContext.ready; | |
| - await expect( | |
| - panel.sessionContext.session!.kernel!.info | |
| - ).resolves.not.toThrow(); | |
| + await expect(panel.sessionContext.session!.kernel!.info).resolves.not.toThrow(); | |
| }); | |
| }); | |
| @@ -145,9 +143,7 @@ describe('console/panel', () => { | |
| mimeTypeService, | |
| sessionContext: panel.sessionContext | |
| }; | |
| - expect(contentFactory.createConsole(options)).toBeInstanceOf( | |
| - CodeConsole | |
| - ); | |
| + expect(contentFactory.createConsole(options)).toBeInstanceOf(CodeConsole); | |
| }); | |
| }); | |
| }); | |
| diff --git a/packages/console/test/utils.ts b/packages/console/test/utils.ts | |
| index 20da128c81..417770ff0f 100644 | |
| --- a/packages/console/test/utils.ts | |
| +++ b/packages/console/test/utils.ts | |
| @@ -32,8 +32,7 @@ const extensions = (() => { | |
| })(); | |
| const factoryService = new CodeMirrorEditorFactory({ extensions, languages }); | |
| -export const editorFactory = | |
| - factoryService.newInlineEditor.bind(factoryService); | |
| +export const editorFactory = factoryService.newInlineEditor.bind(factoryService); | |
| export const mimeTypeService = new CodeMirrorMimeTypeService(languages); | |
| diff --git a/packages/console/test/widget.spec.ts b/packages/console/test/widget.spec.ts | |
| index 29e08200d8..fce4e551d8 100644 | |
| --- a/packages/console/test/widget.spec.ts | |
| +++ b/packages/console/test/widget.spec.ts | |
| @@ -3,12 +3,7 @@ | |
| import type { SessionContext } from '@jupyterlab/apputils'; | |
| import { createSessionContext } from '@jupyterlab/apputils/lib/testutils'; | |
| -import { | |
| - CodeCell, | |
| - CodeCellModel, | |
| - RawCell, | |
| - RawCellModel | |
| -} from '@jupyterlab/cells'; | |
| +import { CodeCell, CodeCellModel, RawCell, RawCellModel } from '@jupyterlab/cells'; | |
| import type { YCodeCell } from '@jupyter/ydoc'; | |
| import { createStandaloneCell } from '@jupyter/ydoc'; | |
| import { NBTestUtils } from '@jupyterlab/cells/lib/testutils'; | |
| @@ -137,9 +132,7 @@ describe('console/widget', () => { | |
| describe('#contentFactory', () => { | |
| it('should be the content factory used by the widget', () => { | |
| - expect(widget.contentFactory).toBeInstanceOf( | |
| - CodeConsole.ContentFactory | |
| - ); | |
| + expect(widget.contentFactory).toBeInstanceOf(CodeConsole.ContentFactory); | |
| }); | |
| }); | |
| @@ -248,25 +241,17 @@ describe('console/widget', () => { | |
| describe('#newPromptCell()', () => { | |
| it('should be called after attach, creating a prompt', () => { | |
| expect(widget.promptCell).toBeFalsy(); | |
| - expect(widget.methods).toEqual( | |
| - expect.not.arrayContaining(['newPromptCell']) | |
| - ); | |
| + expect(widget.methods).toEqual(expect.not.arrayContaining(['newPromptCell'])); | |
| Widget.attach(widget, document.body); | |
| - expect(widget.methods).toEqual( | |
| - expect.arrayContaining(['newPromptCell']) | |
| - ); | |
| + expect(widget.methods).toEqual(expect.arrayContaining(['newPromptCell'])); | |
| expect(widget.promptCell).toBeTruthy(); | |
| }); | |
| it('should be called after execution, creating a prompt', async () => { | |
| expect(widget.promptCell).toBeFalsy(); | |
| - expect(widget.methods).toEqual( | |
| - expect.not.arrayContaining(['newPromptCell']) | |
| - ); | |
| + expect(widget.methods).toEqual(expect.not.arrayContaining(['newPromptCell'])); | |
| Widget.attach(widget, document.body); | |
| - expect(widget.methods).toEqual( | |
| - expect.arrayContaining(['newPromptCell']) | |
| - ); | |
| + expect(widget.methods).toEqual(expect.arrayContaining(['newPromptCell'])); | |
| const old = widget.promptCell; | |
| const force = true; | |
| @@ -278,9 +263,7 @@ describe('console/widget', () => { | |
| expect(widget.promptCell).toBeInstanceOf(CodeCell); | |
| expect(widget.promptCell).not.toBe(old); | |
| - expect(widget.methods).toEqual( | |
| - expect.arrayContaining(['newPromptCell']) | |
| - ); | |
| + expect(widget.methods).toEqual(expect.arrayContaining(['newPromptCell'])); | |
| }); | |
| it('should make previous cell read-only after execution', async () => { | |
| @@ -305,9 +288,7 @@ describe('console/widget', () => { | |
| ); | |
| Widget.attach(widget, document.body); | |
| MessageLoop.sendMessage(widget, Widget.Msg.ActivateRequest); | |
| - expect(widget.methods).toEqual( | |
| - expect.arrayContaining(['onActivateRequest']) | |
| - ); | |
| + expect(widget.methods).toEqual(expect.arrayContaining(['onActivateRequest'])); | |
| expect(widget.promptCell!.editor!.hasFocus()).toBe(true); | |
| }); | |
| }); | |
| @@ -315,13 +296,9 @@ describe('console/widget', () => { | |
| describe('#onAfterAttach()', () => { | |
| it('should be called after attach, creating a prompt', () => { | |
| expect(widget.promptCell).toBeFalsy(); | |
| - expect(widget.methods).toEqual( | |
| - expect.not.arrayContaining(['onAfterAttach']) | |
| - ); | |
| + expect(widget.methods).toEqual(expect.not.arrayContaining(['onAfterAttach'])); | |
| Widget.attach(widget, document.body); | |
| - expect(widget.methods).toEqual( | |
| - expect.arrayContaining(['onAfterAttach']) | |
| - ); | |
| + expect(widget.methods).toEqual(expect.arrayContaining(['onAfterAttach'])); | |
| expect(widget.promptCell).toBeTruthy(); | |
| }); | |
| }); | |
| @@ -375,9 +352,7 @@ describe('console/widget', () => { | |
| // Check the input is not visible in the executed cells | |
| for (const cell of widget.cells) { | |
| - expect(cell.inputArea!.node.classList.contains('lm-mod-hidden')).toBe( | |
| - true | |
| - ); | |
| + expect(cell.inputArea!.node.classList.contains('lm-mod-hidden')).toBe(true); | |
| } | |
| }); | |
| @@ -392,9 +367,7 @@ describe('console/widget', () => { | |
| // Set config to hide banner | |
| widget.setConfig({ showBanner: false }); | |
| await widget.sessionContext.restartKernel(); | |
| - const hiddenBanner = widget.node.querySelector( | |
| - '.jp-CodeConsole-banner' | |
| - ); | |
| + const hiddenBanner = widget.node.querySelector('.jp-CodeConsole-banner'); | |
| expect(hiddenBanner).toBeFalsy(); | |
| }); | |
| }); | |
| diff --git a/packages/coreutils/jest.config.js b/packages/coreutils/jest.config.js | |
| index 2ff43b542d..04ba631ce8 100644 | |
| --- a/packages/coreutils/jest.config.js | |
| +++ b/packages/coreutils/jest.config.js | |
| @@ -19,16 +19,7 @@ module.exports = { | |
| ], | |
| '^.+\\.jsx?$': 'babel-jest' | |
| }, | |
| - moduleFileExtensions: [ | |
| - 'ts', | |
| - 'tsx', | |
| - 'js', | |
| - 'jsx', | |
| - 'json', | |
| - 'node', | |
| - 'mjs', | |
| - 'cjs' | |
| - ], | |
| + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node', 'mjs', 'cjs'], | |
| reporters: ['default', 'jest-junit', 'github-actions'], | |
| coverageReporters: ['json', 'lcov', 'text', 'html'], | |
| coverageDirectory: path.join(__dirname, 'coverage'), | |
| diff --git a/packages/coreutils/src/activitymonitor.ts b/packages/coreutils/src/activitymonitor.ts | |
| index e0f3dfafe3..aab227c646 100644 | |
| --- a/packages/coreutils/src/activitymonitor.ts | |
| +++ b/packages/coreutils/src/activitymonitor.ts | |
| @@ -20,10 +20,7 @@ export class ActivityMonitor<Sender, Args> implements IDisposable { | |
| /** | |
| * A signal emitted when activity has ceased. | |
| */ | |
| - get activityStopped(): ISignal< | |
| - this, | |
| - ActivityMonitor.IArguments<Sender, Args> | |
| - > { | |
| + get activityStopped(): ISignal<this, ActivityMonitor.IArguments<Sender, Args>> { | |
| return this._activityStopped; | |
| } | |
| @@ -78,10 +75,9 @@ export class ActivityMonitor<Sender, Args> implements IDisposable { | |
| private _sender: Sender; | |
| private _args: Args; | |
| private _isDisposed = false; | |
| - private _activityStopped = new Signal< | |
| - this, | |
| - ActivityMonitor.IArguments<Sender, Args> | |
| - >(this); | |
| + private _activityStopped = new Signal<this, ActivityMonitor.IArguments<Sender, Args>>( | |
| + this | |
| + ); | |
| } | |
| /** | |
| diff --git a/packages/coreutils/test/markdowncodeblocks.spec.ts b/packages/coreutils/test/markdowncodeblocks.spec.ts | |
| index f6f3525124..82d8a10500 100644 | |
| --- a/packages/coreutils/test/markdowncodeblocks.spec.ts | |
| +++ b/packages/coreutils/test/markdowncodeblocks.spec.ts | |
| @@ -3,8 +3,7 @@ | |
| import { MarkdownCodeBlocks } from '@jupyterlab/coreutils'; | |
| -const MULTI_LINE_BLOCK = | |
| - 'Here is text\n\n```\na = 10\nb = 20\n```\n\nMore text.'; | |
| +const MULTI_LINE_BLOCK = 'Here is text\n\n```\na = 10\nb = 20\n```\n\nMore text.'; | |
| const SINGLE_LINE_BLOCK = 'Here is text\n\n```a = 10```\n\nMore text.'; | |
| const MULTI_LINE_BLOCK_WITH_LANGUAGE = | |
| 'Here is text\n\n```python\na = 10\nb = 20\n```\n\nMore text.'; | |
| @@ -20,15 +19,13 @@ describe('@jupyterlab/coreutils', () => { | |
| describe('.findMarkdownCodeBlocks()', () => { | |
| it('should find a simple block', () => { | |
| - const codeblocks = | |
| - MarkdownCodeBlocks.findMarkdownCodeBlocks(MULTI_LINE_BLOCK); | |
| + const codeblocks = MarkdownCodeBlocks.findMarkdownCodeBlocks(MULTI_LINE_BLOCK); | |
| expect(codeblocks.length).toBe(1); | |
| expect(codeblocks[0].code).toBe('a = 10\nb = 20\n'); | |
| }); | |
| it('should find a single line block', () => { | |
| - const codeblocks = | |
| - MarkdownCodeBlocks.findMarkdownCodeBlocks(SINGLE_LINE_BLOCK); | |
| + const codeblocks = MarkdownCodeBlocks.findMarkdownCodeBlocks(SINGLE_LINE_BLOCK); | |
| expect(codeblocks.length).toBe(1); | |
| expect(codeblocks[0].code).toBe('a = 10'); | |
| }); | |
| diff --git a/packages/coreutils/test/pluginregistry.spec.ts b/packages/coreutils/test/pluginregistry.spec.ts | |
| index 0b22f25871..eef1f2c1b5 100644 | |
| --- a/packages/coreutils/test/pluginregistry.spec.ts | |
| +++ b/packages/coreutils/test/pluginregistry.spec.ts | |
| @@ -47,9 +47,7 @@ describe('JupyterPluginRegistry', () => { | |
| await registry.activatePlugin('slow-plugin'); | |
| - expect(consoleWarnSpy).toHaveBeenCalledWith( | |
| - expect.stringContaining('slow-plugin') | |
| - ); | |
| + expect(consoleWarnSpy).toHaveBeenCalledWith(expect.stringContaining('slow-plugin')); | |
| expect(consoleWarnSpy).toHaveBeenCalledWith( | |
| expect.stringContaining('with 2 dependants') | |
| ); | |
| diff --git a/packages/coreutils/test/url.spec.ts b/packages/coreutils/test/url.spec.ts | |
| index dc5d15c951..2a401f8244 100644 | |
| --- a/packages/coreutils/test/url.spec.ts | |
| +++ b/packages/coreutils/test/url.spec.ts | |
| @@ -37,9 +37,7 @@ describe('@jupyterlab/coreutils', () => { | |
| it('should join a sequence of url components', () => { | |
| expect(URLExt.join('/foo/', 'bar/')).toBe('/foo/bar/'); | |
| expect(URLExt.join('//example.com', 'bar/')).toBe('//example.com/bar/'); | |
| - expect(URLExt.join('//example.com', 'foo:bar/')).toBe( | |
| - '//example.com/foo:bar/' | |
| - ); | |
| + expect(URLExt.join('//example.com', 'foo:bar/')).toBe('//example.com/foo:bar/'); | |
| expect(URLExt.join('http://www.example.com/', '/bar')).toBe( | |
| 'http://www.example.com/bar' | |
| ); | |
| @@ -52,9 +50,9 @@ describe('@jupyterlab/coreutils', () => { | |
| expect(URLExt.join('http://example.com', 'foo:bar:', 'baz')).toBe( | |
| 'http://example.com/foo:bar:/baz' | |
| ); | |
| - expect( | |
| - URLExt.join('http://example.com', 'foo', '..', '..', 'bar/') | |
| - ).toBe('http://example.com/bar/'); | |
| + expect(URLExt.join('http://example.com', 'foo', '..', '..', 'bar/')).toBe( | |
| + 'http://example.com/bar/' | |
| + ); | |
| }); | |
| }); | |
| diff --git a/packages/csvviewer-extension/src/index.ts b/packages/csvviewer-extension/src/index.ts | |
| index 2884a7af93..5f5308d6dc 100644 | |
| --- a/packages/csvviewer-extension/src/index.ts | |
| +++ b/packages/csvviewer-extension/src/index.ts | |
| @@ -5,10 +5,7 @@ | |
| * @module csvviewer-extension | |
| */ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { ILayoutRestorer } from '@jupyterlab/application'; | |
| import { | |
| createToolbarFactory, | |
| @@ -17,17 +14,11 @@ import { | |
| IToolbarWidgetRegistry, | |
| WidgetTracker | |
| } from '@jupyterlab/apputils'; | |
| -import { | |
| - CSVViewerFactory, | |
| - TSVViewerFactory | |
| -} from '@jupyterlab/csvviewer/lib/widget'; | |
| +import { CSVViewerFactory, TSVViewerFactory } from '@jupyterlab/csvviewer/lib/widget'; | |
| import { CSVDelimiter } from '@jupyterlab/csvviewer/lib/toolbar'; | |
| import type { CSVViewer } from '@jupyterlab/csvviewer'; | |
| import type { TextRenderConfig } from '@jupyterlab/csvviewer'; | |
| -import type { | |
| - DocumentRegistry, | |
| - IDocumentWidget | |
| -} from '@jupyterlab/docregistry'; | |
| +import type { DocumentRegistry, IDocumentWidget } from '@jupyterlab/docregistry'; | |
| import { ISearchProviderRegistry } from '@jupyterlab/documentsearch'; | |
| import { IMainMenu } from '@jupyterlab/mainmenu'; | |
| import type { IObservableList } from '@jupyterlab/observables'; | |
| @@ -200,9 +191,7 @@ function activateCsv( | |
| ? themeManager.isLight(themeManager.theme) | |
| : true; | |
| style = isLight ? Private.LIGHT_STYLE : Private.DARK_STYLE; | |
| - rendererConfig = isLight | |
| - ? Private.LIGHT_TEXT_CONFIG | |
| - : Private.DARK_TEXT_CONFIG; | |
| + rendererConfig = isLight ? Private.LIGHT_TEXT_CONFIG : Private.DARK_TEXT_CONFIG; | |
| tracker.forEach(async grid => { | |
| await grid.content.ready; | |
| grid.content.style = style; | |
| @@ -215,8 +204,7 @@ function activateCsv( | |
| // Add commands | |
| const isEnabled = () => | |
| - tracker.currentWidget !== null && | |
| - tracker.currentWidget === shell.currentWidget; | |
| + tracker.currentWidget !== null && tracker.currentWidget === shell.currentWidget; | |
| commands.addCommand(CommandIDs.CSVGoToLine, { | |
| label: trans.__('Go to Line'), | |
| @@ -366,9 +354,7 @@ function activateTsv( | |
| ? themeManager.isLight(themeManager.theme) | |
| : true; | |
| style = isLight ? Private.LIGHT_STYLE : Private.DARK_STYLE; | |
| - rendererConfig = isLight | |
| - ? Private.LIGHT_TEXT_CONFIG | |
| - : Private.DARK_TEXT_CONFIG; | |
| + rendererConfig = isLight ? Private.LIGHT_TEXT_CONFIG : Private.DARK_TEXT_CONFIG; | |
| tracker.forEach(async grid => { | |
| await grid.content.ready; | |
| grid.content.style = style; | |
| @@ -381,8 +367,7 @@ function activateTsv( | |
| // Add commands | |
| const isEnabled = () => | |
| - tracker.currentWidget !== null && | |
| - tracker.currentWidget === shell.currentWidget; | |
| + tracker.currentWidget !== null && tracker.currentWidget === shell.currentWidget; | |
| commands.addCommand(CommandIDs.TSVGoToLine, { | |
| label: trans.__('Go to Line'), | |
| diff --git a/packages/csvviewer-extension/src/searchprovider.ts b/packages/csvviewer-extension/src/searchprovider.ts | |
| index 1ccde3e79c..cc68131f61 100644 | |
| --- a/packages/csvviewer-extension/src/searchprovider.ts | |
| +++ b/packages/csvviewer-extension/src/searchprovider.ts | |
| @@ -39,9 +39,7 @@ export class CSVSearchProvider extends SearchProvider<CSVDocumentWidget> { | |
| static isApplicable(domain: Widget): domain is CSVDocumentWidget { | |
| // check to see if the CSVSearchProvider can search on the | |
| // first cell, false indicates another editor is present | |
| - return ( | |
| - domain instanceof DocumentWidget && domain.content instanceof CSVViewer | |
| - ); | |
| + return domain instanceof DocumentWidget && domain.content instanceof CSVViewer; | |
| } | |
| /** | |
| diff --git a/packages/csvviewer/src/model.ts b/packages/csvviewer/src/model.ts | |
| index f5112641f6..4bf0c23c15 100644 | |
| --- a/packages/csvviewer/src/model.ts | |
| +++ b/packages/csvviewer/src/model.ts | |
| @@ -482,9 +482,7 @@ export class DSVModel extends DataModel implements IDisposable { | |
| if (this._rowCount <= maxColumnOffsetsRows) { | |
| // Expand the existing column offset array for new column offsets. | |
| const oldColumnOffsets = this._columnOffsets; | |
| - this._columnOffsets = new Uint32Array( | |
| - this._rowCount * this._columnCount | |
| - ); | |
| + this._columnOffsets = new Uint32Array(this._rowCount * this._columnCount); | |
| this._columnOffsets.set(oldColumnOffsets); | |
| this._columnOffsets.fill(0xffffffff, oldColumnOffsets.length); | |
| } else { | |
| @@ -569,10 +567,7 @@ export class DSVModel extends DataModel implements IDisposable { | |
| nextIndex = this.getOffsetIndex(row, column + 1); | |
| // Trim off the delimiter if it exists at the end of the field | |
| - if ( | |
| - index < nextIndex && | |
| - this._rawData[nextIndex - 1] === this._delimiter | |
| - ) { | |
| + if (index < nextIndex && this._rawData[nextIndex - 1] === this._delimiter) { | |
| trimRight += 1; | |
| } | |
| } | |
| diff --git a/packages/csvviewer/src/parse.ts b/packages/csvviewer/src/parse.ts | |
| index 64ad6b138f..813c24ecc5 100644 | |
| --- a/packages/csvviewer/src/parse.ts | |
| +++ b/packages/csvviewer/src/parse.ts | |
| @@ -179,20 +179,11 @@ export function parseDSV(options: IParser.IOptions): IParser.IResults { | |
| const CH_LF = 10; // \n | |
| const CH_CR = 13; // \r | |
| const endIndex = data.length; | |
| - const { | |
| - QUOTED_FIELD, | |
| - QUOTED_FIELD_QUOTE, | |
| - UNQUOTED_FIELD, | |
| - NEW_FIELD, | |
| - NEW_ROW | |
| - } = STATE; | |
| + const { QUOTED_FIELD, QUOTED_FIELD_QUOTE, UNQUOTED_FIELD, NEW_FIELD, NEW_ROW } = | |
| + STATE; | |
| const { CR, LF, CRLF } = ROW_DELIMITER; | |
| const [rowDelimiterCode, rowDelimiterLength] = | |
| - rowDelimiter === '\r\n' | |
| - ? [CRLF, 2] | |
| - : rowDelimiter === '\r' | |
| - ? [CR, 1] | |
| - : [LF, 1]; | |
| + rowDelimiter === '\r\n' ? [CRLF, 2] : rowDelimiter === '\r' ? [CR, 1] : [LF, 1]; | |
| // Always start off at the beginning of a row. | |
| let state = NEW_ROW; | |
| @@ -250,10 +241,7 @@ export function parseDSV(options: IParser.IOptions): IParser.IResults { | |
| case CH_CR: | |
| if (rowDelimiterCode === CR) { | |
| state = NEW_ROW; | |
| - } else if ( | |
| - rowDelimiterCode === CRLF && | |
| - data.charCodeAt(i + 1) === CH_LF | |
| - ) { | |
| + } else if (rowDelimiterCode === CRLF && data.charCodeAt(i + 1) === CH_LF) { | |
| // If we see an expected \r\n, then increment to the end of the delimiter. | |
| i++; | |
| state = NEW_ROW; | |
| @@ -310,10 +298,7 @@ export function parseDSV(options: IParser.IOptions): IParser.IResults { | |
| case CH_CR: | |
| if (rowDelimiterCode === CR) { | |
| state = NEW_ROW; | |
| - } else if ( | |
| - rowDelimiterCode === CRLF && | |
| - data.charCodeAt(i + 1) === CH_LF | |
| - ) { | |
| + } else if (rowDelimiterCode === CRLF && data.charCodeAt(i + 1) === CH_LF) { | |
| // If we see an expected \r\n, then increment to the end of the delimiter. | |
| i++; | |
| state = NEW_ROW; | |
| @@ -360,10 +345,7 @@ export function parseDSV(options: IParser.IOptions): IParser.IResults { | |
| case CH_CR: | |
| if (rowDelimiterCode === CR) { | |
| state = NEW_ROW; | |
| - } else if ( | |
| - rowDelimiterCode === CRLF && | |
| - data.charCodeAt(i + 1) === CH_LF | |
| - ) { | |
| + } else if (rowDelimiterCode === CRLF && data.charCodeAt(i + 1) === CH_LF) { | |
| // If we see an expected \r\n, then increment to the end of the delimiter. | |
| i++; | |
| state = NEW_ROW; | |
| diff --git a/packages/csvviewer/src/toolbar.ts b/packages/csvviewer/src/toolbar.ts | |
| index 3bc023b287..ddad3bfca0 100644 | |
| --- a/packages/csvviewer/src/toolbar.ts | |
| +++ b/packages/csvviewer/src/toolbar.ts | |
| @@ -106,10 +106,7 @@ namespace Private { | |
| /** | |
| * Create the node for the delimiter switcher. | |
| */ | |
| - export function createNode( | |
| - selected: string, | |
| - translator?: ITranslator | |
| - ): HTMLElement { | |
| + export function createNode(selected: string, translator?: ITranslator): HTMLElement { | |
| translator = translator || nullTranslator; | |
| const trans = translator?.load('jupyterlab'); | |
| diff --git a/packages/csvviewer/src/widget.ts b/packages/csvviewer/src/widget.ts | |
| index ef10fbb790..03df35048b 100644 | |
| --- a/packages/csvviewer/src/widget.ts | |
| +++ b/packages/csvviewer/src/widget.ts | |
| @@ -2,10 +2,7 @@ | |
| // Distributed under the terms of the Modified BSD License. | |
| import { ActivityMonitor } from '@jupyterlab/coreutils'; | |
| -import type { | |
| - DocumentRegistry, | |
| - IDocumentWidget | |
| -} from '@jupyterlab/docregistry'; | |
| +import type { DocumentRegistry, IDocumentWidget } from '@jupyterlab/docregistry'; | |
| import { ABCWidgetFactory, DocumentWidget } from '@jupyterlab/docregistry'; | |
| import { PromiseDelegate } from '@lumino/coreutils'; | |
| import type * as DataGridModule from '@lumino/datagrid'; | |
| @@ -124,29 +121,20 @@ export class GridSearchService { | |
| const minRow = this._grid.scrollY / this._grid.defaultSizes.rowHeight; | |
| const maxRow = | |
| - (this._grid.scrollY + this._grid.pageHeight) / | |
| - this._grid.defaultSizes.rowHeight; | |
| - const minColumn = | |
| - this._grid.scrollX / this._grid.defaultSizes.columnHeaderHeight; | |
| + (this._grid.scrollY + this._grid.pageHeight) / this._grid.defaultSizes.rowHeight; | |
| + const minColumn = this._grid.scrollX / this._grid.defaultSizes.columnHeaderHeight; | |
| const maxColumn = | |
| (this._grid.scrollX + this._grid.pageWidth) / | |
| this._grid.defaultSizes.columnHeaderHeight; | |
| const isInViewport = (row: number, column: number) => { | |
| return ( | |
| - row >= minRow && | |
| - row <= maxRow && | |
| - column >= minColumn && | |
| - column <= maxColumn | |
| + row >= minRow && row <= maxRow && column >= minColumn && column <= maxColumn | |
| ); | |
| }; | |
| const increment = reverse ? -1 : 1; | |
| this._column += increment; | |
| - for ( | |
| - let row = this._row; | |
| - reverse ? row >= 0 : row < rowCount; | |
| - row += increment | |
| - ) { | |
| + for (let row = this._row; reverse ? row >= 0 : row < rowCount; row += increment) { | |
| for ( | |
| let col = this._column; | |
| reverse ? col >= 0 : col < columnCount; | |
| @@ -409,8 +397,7 @@ export class CSVViewer extends Widget { | |
| private _grid: DataGridModule.DataGrid; | |
| private _defaultStyle: typeof DataGridModule.DataGrid.defaultStyle; | |
| private _searchService: GridSearchService; | |
| - private _monitor: ActivityMonitor<DocumentRegistry.IModel, void> | null = | |
| - null; | |
| + private _monitor: ActivityMonitor<DocumentRegistry.IModel, void> | null = null; | |
| private _delimiter = ','; | |
| private _revealed = new PromiseDelegate<void>(); | |
| private _baseRenderer: TextRenderConfig | null = null; | |
| @@ -489,9 +476,7 @@ export namespace CSVDocumentWidget { | |
| /** | |
| * A widget factory for CSV widgets. | |
| */ | |
| -export class CSVViewerFactory extends ABCWidgetFactory< | |
| - IDocumentWidget<CSVViewer> | |
| -> { | |
| +export class CSVViewerFactory extends ABCWidgetFactory<IDocumentWidget<CSVViewer>> { | |
| /** | |
| * Create a new widget given a context. | |
| */ | |
| diff --git a/packages/csvviewer/test/model.spec.ts b/packages/csvviewer/test/model.spec.ts | |
| index 743b2615a3..978c415973 100644 | |
| --- a/packages/csvviewer/test/model.spec.ts | |
| +++ b/packages/csvviewer/test/model.spec.ts | |
| @@ -96,11 +96,7 @@ describe('csvviewer/model', () => { | |
| 'b', | |
| 'c' | |
| ]); | |
| - expect([0, 1, 2].map(i => d.data('body', 0, i))).toEqual([ | |
| - 'd', | |
| - 'e', | |
| - 'f' | |
| - ]); | |
| + expect([0, 1, 2].map(i => d.data('body', 0, i))).toEqual(['d', 'e', 'f']); | |
| }); | |
| }); | |
| @@ -271,11 +267,7 @@ describe('csvviewer/model', () => { | |
| 'b', | |
| `c'x` | |
| ]); | |
| - expect([0, 1, 2].map(i => d.data('body', 0, i))).toEqual([ | |
| - 'd,x', | |
| - 'e', | |
| - 'f' | |
| - ]); | |
| + expect([0, 1, 2].map(i => d.data('body', 0, i))).toEqual(['d,x', 'e', 'f']); | |
| }); | |
| it('handles rows that are too short or too long', () => { | |
| @@ -289,11 +281,7 @@ describe('csvviewer/model', () => { | |
| 'b', | |
| 'c' | |
| ]); | |
| - expect([0, 1, 2].map(i => d.data('body', 0, i))).toEqual([ | |
| - '', | |
| - 'c', | |
| - 'd,e,f' | |
| - ]); | |
| + expect([0, 1, 2].map(i => d.data('body', 0, i))).toEqual(['', 'c', 'd,e,f']); | |
| expect([0, 1, 2].map(i => d.data('body', 1, i))).toEqual(['g', 'h', '']); | |
| }); | |
| diff --git a/packages/csvviewer/test/parse-noquotes.spec.ts b/packages/csvviewer/test/parse-noquotes.spec.ts | |
| index 02bf20dc25..09f83ff39c 100644 | |
| --- a/packages/csvviewer/test/parse-noquotes.spec.ts | |
| +++ b/packages/csvviewer/test/parse-noquotes.spec.ts | |
| @@ -18,9 +18,7 @@ describe('csvviewer/parsenoquotes', () => { | |
| results = parser({ ...options, columnOffsets: true }); | |
| expect(results.nrows).toEqual(3); | |
| expect(results.ncols).toEqual(4); | |
| - expect(results.offsets).toEqual([ | |
| - 0, 2, 4, 6, 9, 11, 13, 15, 18, 20, 22, 24 | |
| - ]); | |
| + expect(results.offsets).toEqual([0, 2, 4, 6, 9, 11, 13, 15, 18, 20, 22, 24]); | |
| }); | |
| // For simplicity, we'll use \n as a row delimiter below. | |
| @@ -37,9 +35,7 @@ describe('csvviewer/parsenoquotes', () => { | |
| results = parser({ ...options, columnOffsets: true }); | |
| expect(results.nrows).toEqual(3); | |
| expect(results.ncols).toEqual(4); | |
| - expect(results.offsets).toEqual([ | |
| - 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22 | |
| - ]); | |
| + expect(results.offsets).toEqual([0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]); | |
| }); | |
| it('handles single-line data', () => { | |
| @@ -69,9 +65,7 @@ describe('csvviewer/parsenoquotes', () => { | |
| results = parser({ ...options, columnOffsets: true }); | |
| expect(results.nrows).toEqual(3); | |
| expect(results.ncols).toEqual(4); | |
| - expect(results.offsets).toEqual([ | |
| - 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22 | |
| - ]); | |
| + expect(results.offsets).toEqual([0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]); | |
| }); | |
| it('handles starting on a new row', () => { | |
| @@ -131,9 +125,7 @@ describe('csvviewer/parsenoquotes', () => { | |
| results = parser({ ...options, columnOffsets: true }); | |
| expect(results.nrows).toEqual(3); | |
| expect(results.ncols).toEqual(4); | |
| - expect(results.offsets).toEqual([ | |
| - 0, 2, 4, 6, 8, 10, 10, 10, 11, 13, 15, 17 | |
| - ]); | |
| + expect(results.offsets).toEqual([0, 2, 4, 6, 8, 10, 10, 10, 11, 13, 15, 17]); | |
| }); | |
| it('adjusts columns to match first row by default with CRLF row delimiter', () => { | |
| @@ -148,9 +140,7 @@ describe('csvviewer/parsenoquotes', () => { | |
| results = parser({ ...options, columnOffsets: true }); | |
| expect(results.nrows).toEqual(3); | |
| expect(results.ncols).toEqual(4); | |
| - expect(results.offsets).toEqual([ | |
| - 0, 2, 4, 6, 9, 11, 11, 11, 13, 15, 17, 19 | |
| - ]); | |
| + expect(results.offsets).toEqual([0, 2, 4, 6, 9, 11, 11, 11, 13, 15, 17, 19]); | |
| }); | |
| it('adjusts columns to match ncols', () => { | |
| diff --git a/packages/csvviewer/test/parse.spec.ts b/packages/csvviewer/test/parse.spec.ts | |
| index 03e5606868..41bd2d1427 100644 | |
| --- a/packages/csvviewer/test/parse.spec.ts | |
| +++ b/packages/csvviewer/test/parse.spec.ts | |
| @@ -18,9 +18,7 @@ describe('csvviewer/parse', () => { | |
| results = parser({ ...options, columnOffsets: true }); | |
| expect(results.nrows).toEqual(3); | |
| expect(results.ncols).toEqual(4); | |
| - expect(results.offsets).toEqual([ | |
| - 0, 2, 4, 6, 9, 11, 13, 15, 18, 20, 22, 24 | |
| - ]); | |
| + expect(results.offsets).toEqual([0, 2, 4, 6, 9, 11, 13, 15, 18, 20, 22, 24]); | |
| }); | |
| // For simplicity, we'll use \n as a row delimiter below. | |
| @@ -37,9 +35,7 @@ describe('csvviewer/parse', () => { | |
| results = parser({ ...options, columnOffsets: true }); | |
| expect(results.nrows).toEqual(3); | |
| expect(results.ncols).toEqual(4); | |
| - expect(results.offsets).toEqual([ | |
| - 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22 | |
| - ]); | |
| + expect(results.offsets).toEqual([0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]); | |
| }); | |
| it('handles single-line data', () => { | |
| @@ -69,9 +65,7 @@ describe('csvviewer/parse', () => { | |
| results = parser({ ...options, columnOffsets: true }); | |
| expect(results.nrows).toEqual(3); | |
| expect(results.ncols).toEqual(4); | |
| - expect(results.offsets).toEqual([ | |
| - 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22 | |
| - ]); | |
| + expect(results.offsets).toEqual([0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]); | |
| }); | |
| it('handles starting on a new row', () => { | |
| @@ -131,9 +125,7 @@ describe('csvviewer/parse', () => { | |
| results = parser({ ...options, columnOffsets: true }); | |
| expect(results.nrows).toEqual(3); | |
| expect(results.ncols).toEqual(4); | |
| - expect(results.offsets).toEqual([ | |
| - 0, 2, 4, 6, 8, 10, 10, 10, 11, 13, 15, 17 | |
| - ]); | |
| + expect(results.offsets).toEqual([0, 2, 4, 6, 8, 10, 10, 10, 11, 13, 15, 17]); | |
| }); | |
| it('adjusts columns to match first row by default with CRLF row delimiter', () => { | |
| @@ -148,9 +140,7 @@ describe('csvviewer/parse', () => { | |
| results = parser({ ...options, columnOffsets: true }); | |
| expect(results.nrows).toEqual(3); | |
| expect(results.ncols).toEqual(4); | |
| - expect(results.offsets).toEqual([ | |
| - 0, 2, 4, 6, 9, 11, 11, 11, 13, 15, 17, 19 | |
| - ]); | |
| + expect(results.offsets).toEqual([0, 2, 4, 6, 9, 11, 11, 11, 13, 15, 17, 19]); | |
| }); | |
| it('adjusts columns to match ncols', () => { | |
| diff --git a/packages/debugger-extension/src/debug-console-executor.ts b/packages/debugger-extension/src/debug-console-executor.ts | |
| index 61ee55e638..0f02610f69 100644 | |
| --- a/packages/debugger-extension/src/debug-console-executor.ts | |
| +++ b/packages/debugger-extension/src/debug-console-executor.ts | |
| @@ -41,9 +41,7 @@ export class DebugConsoleCellExecutor implements IConsoleCellExecutor { | |
| // Check if debugger has stopped threads (required for evaluation) | |
| if (!this._debuggerService.hasStoppedThreads()) { | |
| return this.createDisplayData( | |
| - this._trans.__( | |
| - 'Debugger does not have stopped threads - cannot evaluate' | |
| - ), | |
| + this._trans.__('Debugger does not have stopped threads - cannot evaluate'), | |
| executionCount | |
| ); | |
| } | |
| @@ -69,9 +67,7 @@ export class DebugConsoleCellExecutor implements IConsoleCellExecutor { | |
| /** | |
| * Execute a cell using debugger evaluation. | |
| */ | |
| - async runCell( | |
| - options: IConsoleCellExecutor.IRunCellOptions | |
| - ): Promise<boolean> { | |
| + async runCell(options: IConsoleCellExecutor.IRunCellOptions): Promise<boolean> { | |
| const { cell } = options; | |
| const code = cell.model.sharedModel.getSource(); | |
| diff --git a/packages/debugger-extension/src/debugger-completion-provider.ts b/packages/debugger-extension/src/debugger-completion-provider.ts | |
| index 055f967831..1418de75cd 100644 | |
| --- a/packages/debugger-extension/src/debugger-completion-provider.ts | |
| +++ b/packages/debugger-extension/src/debugger-completion-provider.ts | |
| @@ -42,8 +42,7 @@ export class DebuggerCompletionProvider implements ICompletionProvider { | |
| */ | |
| async isApplicable(context: ICompletionContext): Promise<boolean> { | |
| try { | |
| - const spec = | |
| - await this._debuggerService.session?.connection?.kernel?.spec; | |
| + const spec = await this._debuggerService.session?.connection?.kernel?.spec; | |
| return spec?.language === 'python'; | |
| } catch (error) { | |
| return false; | |
| @@ -133,8 +132,7 @@ def getCompletionsForDebugger(code, cursor_pos): | |
| const debuggerCompletions = `getCompletionsForDebugger(${JSON.stringify( | |
| text | |
| )}, ${offset})`; | |
| - const evalReply = | |
| - await this._debuggerService.evaluate(debuggerCompletions); | |
| + const evalReply = await this._debuggerService.evaluate(debuggerCompletions); | |
| if (!evalReply) { | |
| return { start: 0, end: 0, items: [] }; | |
| diff --git a/packages/debugger-extension/src/index.ts b/packages/debugger-extension/src/index.ts | |
| index 8b7f8818ac..a1505f2720 100644 | |
| --- a/packages/debugger-extension/src/index.ts | |
| +++ b/packages/debugger-extension/src/index.ts | |
| @@ -5,10 +5,7 @@ | |
| * @module debugger-extension | |
| */ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { ILabShell, ILayoutRestorer } from '@jupyterlab/application'; | |
| import { | |
| Clipboard, | |
| @@ -38,11 +35,7 @@ import { | |
| } from '@jupyterlab/debugger'; | |
| import { DocumentWidget } from '@jupyterlab/docregistry'; | |
| import { FileEditor, IEditorTracker } from '@jupyterlab/fileeditor'; | |
| -import { | |
| - INotebookTracker, | |
| - NotebookActions, | |
| - NotebookPanel | |
| -} from '@jupyterlab/notebook'; | |
| +import { INotebookTracker, NotebookActions, NotebookPanel } from '@jupyterlab/notebook'; | |
| import type { IRenderMime } from '@jupyterlab/rendermime'; | |
| import { | |
| standardRendererFactories as initialFactories, | |
| @@ -87,12 +80,7 @@ const consoles: JupyterFrontEndPlugin<void> = { | |
| description: 'Add debugger capability to the consoles.', | |
| autoStart: true, | |
| requires: [IDebugger, IConsoleTracker], | |
| - optional: [ | |
| - ILabShell, | |
| - ISettingRegistry, | |
| - ITranslator, | |
| - IDebuggerDisplayRegistry | |
| - ], | |
| + optional: [ILabShell, ISettingRegistry, ITranslator, IDebuggerDisplayRegistry], | |
| activate: async ( | |
| app: JupyterFrontEnd, | |
| debug: IDebugger, | |
| @@ -107,9 +95,7 @@ const consoles: JupyterFrontEndPlugin<void> = { | |
| const updateOverlaySetting = (): void => { | |
| const showOverlay = settings.composite['showPausedOverlay'] ?? true; | |
| - document.body.dataset.showPausedOverlay = showOverlay | |
| - ? 'true' | |
| - : 'false'; | |
| + document.body.dataset.showPausedOverlay = showOverlay ? 'true' : 'false'; | |
| }; | |
| updateOverlaySetting(); | |
| @@ -122,9 +108,7 @@ const consoles: JupyterFrontEndPlugin<void> = { | |
| translator: translator | |
| }); | |
| - const updateHandlerAndCommands = async ( | |
| - widget: ConsolePanel | |
| - ): Promise<void> => { | |
| + const updateHandlerAndCommands = async (widget: ConsolePanel): Promise<void> => { | |
| const { sessionContext } = widget; | |
| await sessionContext.ready; | |
| await handler.updateContext(widget, sessionContext); | |
| @@ -209,9 +193,7 @@ const files: JupyterFrontEndPlugin<void> = { | |
| const updateOverlaySetting = (): void => { | |
| const showOverlay = settings.composite['showPausedOverlay'] ?? true; | |
| - document.body.dataset.showPausedOverlay = showOverlay | |
| - ? 'true' | |
| - : 'false'; | |
| + document.body.dataset.showPausedOverlay = showOverlay ? 'true' : 'false'; | |
| }; | |
| updateOverlaySetting(); | |
| @@ -228,9 +210,7 @@ const files: JupyterFrontEndPlugin<void> = { | |
| [id: string]: Session.ISessionConnection; | |
| } = {}; | |
| - const updateHandlerAndCommands = async ( | |
| - widget: DocumentWidget | |
| - ): Promise<void> => { | |
| + const updateHandlerAndCommands = async (widget: DocumentWidget): Promise<void> => { | |
| const sessions = app.serviceManager.sessions; | |
| try { | |
| const model = await sessions.findByPath(widget.context.path); | |
| @@ -266,9 +246,7 @@ const files: JupyterFrontEndPlugin<void> = { | |
| } else { | |
| editorTracker.currentChanged.connect((_, documentWidget) => { | |
| if (documentWidget) { | |
| - void updateHandlerAndCommands( | |
| - documentWidget as unknown as DocumentWidget | |
| - ); | |
| + void updateHandlerAndCommands(documentWidget as unknown as DocumentWidget); | |
| } | |
| }); | |
| } | |
| @@ -311,16 +289,13 @@ const notebooks: JupyterFrontEndPlugin<IDebugger.IHandler> = { | |
| const updateOverlaySetting = (): void => { | |
| const showOverlay = settings.composite['showPausedOverlay'] ?? true; | |
| - document.body.dataset.showPausedOverlay = showOverlay | |
| - ? 'true' | |
| - : 'false'; | |
| + document.body.dataset.showPausedOverlay = showOverlay ? 'true' : 'false'; | |
| }; | |
| updateOverlaySetting(); | |
| settings.changed.connect(updateOverlaySetting); | |
| } | |
| - const sessionDialogs = | |
| - sessionDialogs_ ?? new SessionContextDialogs({ translator }); | |
| + const sessionDialogs = sessionDialogs_ ?? new SessionContextDialogs({ translator }); | |
| const handler = new Debugger.Handler({ | |
| type: 'notebook', | |
| shell: app.shell, | |
| @@ -368,9 +343,7 @@ const notebooks: JupyterFrontEndPlugin<IDebugger.IHandler> = { | |
| } | |
| }); | |
| - const updateHandlerAndCommands = async ( | |
| - widget: NotebookPanel | |
| - ): Promise<void> => { | |
| + const updateHandlerAndCommands = async (widget: NotebookPanel): Promise<void> => { | |
| if (widget) { | |
| const { sessionContext } = widget; | |
| await sessionContext.ready; | |
| @@ -450,12 +423,7 @@ const service: JupyterFrontEndPlugin<IDebugger> = { | |
| autoStart: true, | |
| provides: IDebugger, | |
| requires: [IDebuggerConfig], | |
| - optional: [ | |
| - IDebuggerDisplayRegistry, | |
| - IDebuggerSources, | |
| - ITranslator, | |
| - IEditorServices | |
| - ], | |
| + optional: [IDebuggerDisplayRegistry, IDebuggerSources, ITranslator, IEditorServices], | |
| activate: ( | |
| app: JupyterFrontEnd, | |
| config: IDebugger.IConfig, | |
| @@ -479,8 +447,7 @@ const service: JupyterFrontEndPlugin<IDebugger> = { | |
| */ | |
| const displayRegistry: JupyterFrontEndPlugin<IDebuggerDisplayRegistry> = { | |
| id: '@jupyterlab/debugger-extension:display-registry', | |
| - description: | |
| - 'Provides the debugger display registry for cell/file display names.', | |
| + description: 'Provides the debugger display registry for cell/file display names.', | |
| provides: IDebuggerDisplayRegistry, | |
| autoStart: true, | |
| activate: () => new DebuggerDisplayRegistry() | |
| @@ -531,8 +498,7 @@ const sources: JupyterFrontEndPlugin<IDebugger.ISources> = { | |
| */ | |
| const variables: JupyterFrontEndPlugin<void> = { | |
| id: '@jupyterlab/debugger-extension:variables', | |
| - description: | |
| - 'Adds variables renderer and inspection in the debugger variable panel.', | |
| + description: 'Adds variables renderer and inspection in the debugger variable panel.', | |
| autoStart: true, | |
| requires: [IDebugger, IDebuggerHandler, ITranslator], | |
| optional: [IThemeManager, IRenderMimeRegistry], | |
| @@ -595,17 +561,11 @@ const variables: JupyterFrontEndPlugin<void> = { | |
| } | |
| const id = `jp-debugger-variable-${name}`; | |
| - if ( | |
| - !name || | |
| - !variableReference || | |
| - tracker.find(widget => widget.id === id) | |
| - ) { | |
| + if (!name || !variableReference || tracker.find(widget => widget.id === id)) { | |
| return; | |
| } | |
| - const variables = await service.inspectVariable( | |
| - variableReference as number | |
| - ); | |
| + const variables = await service.inspectVariable(variableReference as number); | |
| if (!variables || variables.length === 0) { | |
| return; | |
| } | |
| @@ -1038,8 +998,7 @@ const main: JupyterFrontEndPlugin<void> = { | |
| // First check if there is a PageConfig override for the extension visibility | |
| const alwaysShowDebuggerExtension = | |
| - PageConfig.getOption('alwaysShowDebuggerExtension').toLowerCase() === | |
| - 'true'; | |
| + PageConfig.getOption('alwaysShowDebuggerExtension').toLowerCase() === 'true'; | |
| if (!alwaysShowDebuggerExtension) { | |
| // hide the debugger sidebar if no kernel with support for debugging is available | |
| await kernelspecs.ready; | |
| @@ -1057,14 +1016,10 @@ const main: JupyterFrontEndPlugin<void> = { | |
| commands.addCommand(CommandIDs.debugContinue, { | |
| label: () => { | |
| - return service.hasStoppedThreads() | |
| - ? trans.__('Continue') | |
| - : trans.__('Pause'); | |
| + return service.hasStoppedThreads() ? trans.__('Continue') : trans.__('Pause'); | |
| }, | |
| caption: () => { | |
| - return service.hasStoppedThreads() | |
| - ? trans.__('Continue') | |
| - : trans.__('Pause'); | |
| + return service.hasStoppedThreads() ? trans.__('Continue') : trans.__('Pause'); | |
| }, | |
| icon: () => { | |
| return service.hasStoppedThreads() | |
| @@ -1165,11 +1120,9 @@ const main: JupyterFrontEndPlugin<void> = { | |
| await service.pauseOnExceptionsFilter(filter as string); | |
| } else { | |
| let items: string[] = []; | |
| - service.session?.exceptionBreakpointFilters?.forEach( | |
| - availableFilter => { | |
| - items.push(availableFilter.filter); | |
| - } | |
| - ); | |
| + service.session?.exceptionBreakpointFilters?.forEach(availableFilter => { | |
| + items.push(availableFilter.filter); | |
| + }); | |
| const result = await InputDialog.getMultipleItems({ | |
| title: trans.__('Select a filter for breakpoints on exception'), | |
| items: items, | |
| @@ -1464,8 +1417,7 @@ const debugConsole: JupyterFrontEndPlugin<void> = { | |
| label: trans.__('Display the tab completion widget.'), | |
| execute: () => { | |
| const id = | |
| - debugConsoleTracker.currentWidget && | |
| - debugConsoleTracker.currentWidget.id; | |
| + debugConsoleTracker.currentWidget && debugConsoleTracker.currentWidget.id; | |
| if (id) { | |
| return manager.invoke(id); | |
| @@ -1483,8 +1435,7 @@ const debugConsole: JupyterFrontEndPlugin<void> = { | |
| label: trans.__('Select the completion suggestion.'), | |
| execute: () => { | |
| const id = | |
| - debugConsoleTracker.currentWidget && | |
| - debugConsoleTracker.currentWidget.id; | |
| + debugConsoleTracker.currentWidget && debugConsoleTracker.currentWidget.id; | |
| if (id) { | |
| return manager.select(id); | |
| diff --git a/packages/debugger/src/handler.ts b/packages/debugger/src/handler.ts | |
| index 68b9c5da88..2fff2d4a3a 100644 | |
| --- a/packages/debugger/src/handler.ts | |
| +++ b/packages/debugger/src/handler.ts | |
| @@ -155,8 +155,7 @@ export class DebuggerHandler implements DebuggerHandler.IHandler { | |
| if ( | |
| this._service.isStarted && | |
| !this._service.hasStoppedThreads() && | |
| - (msg.parent_header as KernelMessage.IHeader).msg_type === | |
| - 'execute_request' | |
| + (msg.parent_header as KernelMessage.IHeader).msg_type === 'execute_request' | |
| ) { | |
| void this._service.displayDefinedVariables(); | |
| } | |
| @@ -188,8 +187,7 @@ export class DebuggerHandler implements DebuggerHandler.IHandler { | |
| void this.update(widget, connection); | |
| }; | |
| - const contextKernelChangedHandlers = | |
| - this._contextKernelChangedHandlers[widget.id]; | |
| + const contextKernelChangedHandlers = this._contextKernelChangedHandlers[widget.id]; | |
| if (contextKernelChangedHandlers) { | |
| sessionContext.kernelChanged.disconnect(contextKernelChangedHandlers); | |
| @@ -319,10 +317,7 @@ export class DebuggerHandler implements DebuggerHandler.IHandler { | |
| }; | |
| const isDebuggerOn = (): boolean => { | |
| - return ( | |
| - this._service.isStarted && | |
| - this._previousConnection?.id === connection?.id | |
| - ); | |
| + return this._service.isStarted && this._previousConnection?.id === connection?.id; | |
| }; | |
| const stopDebugger = async (): Promise<void> => { | |
| @@ -402,11 +397,7 @@ export class DebuggerHandler implements DebuggerHandler.IHandler { | |
| } | |
| } | |
| - updateIconButtonState( | |
| - this._iconButtons[widget.id]!, | |
| - this._service.isStarted, | |
| - true | |
| - ); | |
| + updateIconButtonState(this._iconButtons[widget.id]!, this._service.isStarted, true); | |
| // check the state of the debug session | |
| if (!this._service.isStarted) { | |
| @@ -436,28 +427,17 @@ export class DebuggerHandler implements DebuggerHandler.IHandler { | |
| private _contextKernelChangedHandlers: { | |
| [id: string]: ( | |
| sender: SessionContext, | |
| - args: IChangedArgs< | |
| - Kernel.IKernelConnection, | |
| - Kernel.IKernelConnection, | |
| - 'kernel' | |
| - > | |
| + args: IChangedArgs<Kernel.IKernelConnection, Kernel.IKernelConnection, 'kernel'> | |
| ) => void; | |
| } = {}; | |
| private _kernelChangedHandlers: { | |
| [id: string]: ( | |
| sender: Session.ISessionConnection, | |
| - args: IChangedArgs< | |
| - Kernel.IKernelConnection, | |
| - Kernel.IKernelConnection, | |
| - 'kernel' | |
| - > | |
| + args: IChangedArgs<Kernel.IKernelConnection, Kernel.IKernelConnection, 'kernel'> | |
| ) => void; | |
| } = {}; | |
| private _statusChangedHandlers: { | |
| - [id: string]: ( | |
| - sender: Session.ISessionConnection, | |
| - status: Kernel.Status | |
| - ) => void; | |
| + [id: string]: (sender: Session.ISessionConnection, status: Kernel.Status) => void; | |
| } = {}; | |
| private _iopubMessageHandlers: { | |
| [id: string]: ( | |
| @@ -511,9 +491,7 @@ export namespace DebuggerHandler { | |
| /** | |
| * Get the active widget. | |
| */ | |
| - activeWidget: | |
| - | DebuggerHandler.SessionWidget[DebuggerHandler.SessionType] | |
| - | null; | |
| + activeWidget: DebuggerHandler.SessionWidget[DebuggerHandler.SessionType] | null; | |
| /** | |
| * Update a debug handler for the given widget, and | |
| diff --git a/packages/debugger/src/handlers/editor.ts b/packages/debugger/src/handlers/editor.ts | |
| index 77bf7c6d84..da6a15f649 100644 | |
| --- a/packages/debugger/src/handlers/editor.ts | |
| +++ b/packages/debugger/src/handlers/editor.ts | |
| @@ -26,10 +26,7 @@ import type { DecorationSet } from '@codemirror/view'; | |
| import { Decoration, EditorView, gutter, GutterMarker } from '@codemirror/view'; | |
| import type { IDebugger } from '../tokens'; | |
| -import { | |
| - breakpointIcon, | |
| - selectedBreakpointIcon | |
| -} from '@jupyterlab/ui-components'; | |
| +import { breakpointIcon, selectedBreakpointIcon } from '@jupyterlab/ui-components'; | |
| /** | |
| * The class name added to the current line. | |
| @@ -82,13 +79,10 @@ export class EditorHandler implements IDisposable { | |
| this._addBreakpointsToEditor(); | |
| }, this); | |
| - this._debuggerService.model.breakpoints.selectedChanged.connect( | |
| - (_, breakpoint) => { | |
| - this._selectedBreakpoint = breakpoint; | |
| - this._addBreakpointsToEditor(); | |
| - }, | |
| - this | |
| - ); | |
| + this._debuggerService.model.breakpoints.selectedChanged.connect((_, breakpoint) => { | |
| + this._selectedBreakpoint = breakpoint; | |
| + this._addBreakpointsToEditor(); | |
| + }, this); | |
| this._debuggerService.model.callstack.currentFrameChanged.connect( | |
| (_, frame: IDebugger.IStackFrame) => { | |
| @@ -97,8 +91,7 @@ export class EditorHandler implements IDisposable { | |
| EditorHandler.clearHighlight(editor); | |
| const framePath = frame?.source?.path ?? ''; | |
| const editorPath = | |
| - this._path || | |
| - this._debuggerService.getCodeId(this._src.getSource()); | |
| + this._path || this._debuggerService.getCodeId(this._src.getSource()); | |
| // If the current frame belongs to this editor, highlight its line. | |
| if (framePath && editorPath && framePath === editorPath) { | |
| @@ -111,9 +104,7 @@ export class EditorHandler implements IDisposable { | |
| this | |
| ); | |
| - this._breakpointEffect = StateEffect.define< | |
| - { pos: number; selected: boolean }[] | |
| - >({ | |
| + this._breakpointEffect = StateEffect.define<{ pos: number; selected: boolean }[]>({ | |
| map: (value, mapping) => | |
| value.map(v => ({ | |
| pos: mapping.mapPos(v.pos), | |
| @@ -127,8 +118,7 @@ export class EditorHandler implements IDisposable { | |
| }, | |
| update: (breakpoints, transaction) => { | |
| let hasEffect = false; | |
| - let decorations: Range<GutterMarker> | readonly Range<GutterMarker>[] = | |
| - []; | |
| + let decorations: Range<GutterMarker> | readonly Range<GutterMarker>[] = []; | |
| for (let ef of transaction.effects) { | |
| if (ef.is(this._breakpointEffect)) { | |
| @@ -328,10 +318,7 @@ export class EditorHandler implements IDisposable { | |
| return; | |
| } | |
| - const [clickedLine, isLineEmpty] = this._getEffectiveClickedLine( | |
| - editor, | |
| - position | |
| - ); | |
| + const [clickedLine, isLineEmpty] = this._getEffectiveClickedLine(editor, position); | |
| let breakpoints: IDebugger.IBreakpoint[] = this._getBreakpoints(); | |
| let stateBreakpoints = editor.state.field(this._breakpointState); | |
| let hasBreakpoint = false; | |
| @@ -354,9 +341,7 @@ export class EditorHandler implements IDisposable { | |
| /* if there is already a breakpoint */ | |
| if (!isLineEmpty) { | |
| /* remove the in place breakpoint if the clicked line of code is not empty*/ | |
| - breakpoints = breakpoints.filter( | |
| - ele => ele.line !== clickedLine.number | |
| - ); | |
| + breakpoints = breakpoints.filter(ele => ele.line !== clickedLine.number); | |
| if (this._selectedBreakpoint) { | |
| /* if the breakpoint is a selected one: remove it*/ | |
| @@ -391,10 +376,7 @@ export class EditorHandler implements IDisposable { | |
| * Add the breakpoints to the editor. | |
| */ | |
| private _addBreakpointsToEditor(): void { | |
| - if ( | |
| - !this.editor || | |
| - this._id !== this._debuggerService.session?.connection?.id | |
| - ) { | |
| + if (!this.editor || this._id !== this._debuggerService.session?.connection?.id) { | |
| return; | |
| } | |
| @@ -407,8 +389,7 @@ export class EditorHandler implements IDisposable { | |
| const selectedPath = this._selectedBreakpoint?.source?.path; | |
| const breakpointData = breakpoints.map(b => { | |
| const pos = editor.state.doc.line(b.line!).from; | |
| - const selected = | |
| - b.line! === selectedLine && b.source?.path === selectedPath; | |
| + const selected = b.line! === selectedLine && b.source?.path === selectedPath; | |
| return { pos, selected }; | |
| }); | |
| @@ -460,9 +441,7 @@ export class EditorHandler implements IDisposable { | |
| private _id: string; | |
| private _debuggerService: IDebugger; | |
| private _editor: () => CodeEditor.IEditor | null; | |
| - private _breakpointEffect: StateEffectType< | |
| - { pos: number; selected: boolean }[] | |
| - >; | |
| + private _breakpointEffect: StateEffectType<{ pos: number; selected: boolean }[]>; | |
| private _breakpointState: StateField<RangeSet<GutterMarker>>; | |
| private _gutter: Compartment; | |
| private _highlightDeco: Decoration; | |
| @@ -528,9 +507,7 @@ export namespace EditorHandler { | |
| const cmEditor = editor as CodeMirrorEditor; | |
| const linePos = cmEditor.doc.line(line).from; | |
| - const effects: StateEffect<any>[] = [ | |
| - _highlightEffect.of({ pos: [linePos] }) | |
| - ]; | |
| + const effects: StateEffect<any>[] = [_highlightEffect.of({ pos: [linePos] })]; | |
| if (scrollLogicalPosition) { | |
| // getOffsetAt increases the line number before scrolling to it, because | |
| @@ -539,9 +516,7 @@ export namespace EditorHandler { | |
| // stackFrame https://microsoft.github.io/debug-adapter-protocol/specification#Types_StackFrame, | |
| // therefore we need to decrease it first. | |
| const offset = cmEditor.getOffsetAt({ line: line - 1, column: 0 }); | |
| - effects.push( | |
| - EditorView.scrollIntoView(offset, { y: scrollLogicalPosition }) | |
| - ); | |
| + effects.push(EditorView.scrollIntoView(offset, { y: scrollLogicalPosition })); | |
| } | |
| cmEditor.editor.dispatch({ | |
| effects: effects | |
| diff --git a/packages/debugger/src/handlers/file.ts b/packages/debugger/src/handlers/file.ts | |
| index b6929d5621..c1abff21e5 100644 | |
| --- a/packages/debugger/src/handlers/file.ts | |
| +++ b/packages/debugger/src/handlers/file.ts | |
| @@ -31,9 +31,8 @@ export class FileHandler implements IDisposable { | |
| this.translator = options.translator || nullTranslator; | |
| this._hasLineNumber = | |
| - (this._fileEditor.editor.getOption('lineNumbers') as | |
| - | boolean | |
| - | undefined) ?? false; | |
| + (this._fileEditor.editor.getOption('lineNumbers') as boolean | undefined) ?? | |
| + false; | |
| this._editorHandler = new EditorHandler({ | |
| debuggerService: this._debuggerService, | |
| editorReady: () => Promise.resolve(this._fileEditor.editor), | |
| diff --git a/packages/debugger/src/handlers/notebook.ts b/packages/debugger/src/handlers/notebook.ts | |
| index ab5ebef8c2..23daac7f9a 100644 | |
| --- a/packages/debugger/src/handlers/notebook.ts | |
| +++ b/packages/debugger/src/handlers/notebook.ts | |
| @@ -95,9 +95,7 @@ export class NotebookHandler implements IDisposable { | |
| cells?: any, | |
| changes?: IObservableList.IChangedArgs<ICellModel> | |
| ): void { | |
| - this._notebookPanel.content.widgets.forEach(cell => | |
| - this._addEditorHandler(cell) | |
| - ); | |
| + this._notebookPanel.content.widgets.forEach(cell => this._addEditorHandler(cell)); | |
| if (changes?.type === 'move') { | |
| for (const cell of changes.newValues) { | |
| diff --git a/packages/debugger/src/model.ts b/packages/debugger/src/model.ts | |
| index 89cb0d5022..3c02f26281 100644 | |
| --- a/packages/debugger/src/model.ts | |
| +++ b/packages/debugger/src/model.ts | |
| @@ -28,8 +28,7 @@ export class DebuggerModel implements IDebugger.Model.IService { | |
| * Instantiate a new DebuggerModel | |
| */ | |
| constructor(options: DebuggerModel.IOptions) { | |
| - const displayRegistry = | |
| - options.displayRegistry ?? new DebuggerDisplayRegistry(); | |
| + const displayRegistry = options.displayRegistry ?? new DebuggerDisplayRegistry(); | |
| this.breakpoints = new BreakpointsModel({ displayRegistry }); | |
| this.callstack = new CallstackModel({ | |
| displayRegistry | |
| diff --git a/packages/debugger/src/panels/breakpoints/body.tsx b/packages/debugger/src/panels/breakpoints/body.tsx | |
| index afafa531f9..23af6ddb1e 100644 | |
| --- a/packages/debugger/src/panels/breakpoints/body.tsx | |
| +++ b/packages/debugger/src/panels/breakpoints/body.tsx | |
| @@ -6,10 +6,7 @@ import React, { useEffect, useState } from 'react'; | |
| import type { IDebugger } from '../../tokens'; | |
| import type { ITranslator, TranslationBundle } from '@jupyterlab/translation'; | |
| import { nullTranslator } from '@jupyterlab/translation'; | |
| -import { | |
| - breakpointIcon, | |
| - selectedBreakpointIcon | |
| -} from '@jupyterlab/ui-components'; | |
| +import { breakpointIcon, selectedBreakpointIcon } from '@jupyterlab/ui-components'; | |
| /** | |
| * The body for a Breakpoints Panel. | |
| @@ -32,9 +29,7 @@ export class BreakpointsBody extends ReactWidget { | |
| } | |
| render(): JSX.Element { | |
| - return ( | |
| - <BreakpointsComponent model={this._model} translator={this._translator} /> | |
| - ); | |
| + return <BreakpointsComponent model={this._model} translator={this._translator} />; | |
| } | |
| private _model: IDebugger.Model.IBreakpoints; | |
| diff --git a/packages/debugger/src/panels/breakpoints/index.ts b/packages/debugger/src/panels/breakpoints/index.ts | |
| index 282eb49576..8016e1cd08 100644 | |
| --- a/packages/debugger/src/panels/breakpoints/index.ts | |
| +++ b/packages/debugger/src/panels/breakpoints/index.ts | |
| @@ -34,10 +34,7 @@ export class Breakpoints extends PanelWithToolbar { | |
| const body = new BreakpointsBody(model); | |
| - this.toolbar.node.setAttribute( | |
| - 'aria-label', | |
| - trans.__('Breakpoints panel toolbar') | |
| - ); | |
| + this.toolbar.node.setAttribute('aria-label', trans.__('Breakpoints panel toolbar')); | |
| this.toolbar.addItem( | |
| 'pauseOnException', | |
| new PauseOnExceptionsWidget({ | |
| diff --git a/packages/debugger/src/panels/breakpoints/model.ts b/packages/debugger/src/panels/breakpoints/model.ts | |
| index 5fbe542e2a..a7e50ee955 100644 | |
| --- a/packages/debugger/src/panels/breakpoints/model.ts | |
| +++ b/packages/debugger/src/panels/breakpoints/model.ts | |
| @@ -11,8 +11,7 @@ import { DebuggerDisplayRegistry } from '../../displayregistry'; | |
| */ | |
| export class BreakpointsModel implements IDebugger.Model.IBreakpoints { | |
| constructor(options: { displayRegistry?: IDebuggerDisplayRegistry }) { | |
| - this._displayRegistry = | |
| - options.displayRegistry ?? new DebuggerDisplayRegistry(); | |
| + this._displayRegistry = options.displayRegistry ?? new DebuggerDisplayRegistry(); | |
| } | |
| /** | |
| @@ -100,9 +99,7 @@ export class BreakpointsModel implements IDebugger.Model.IBreakpoints { | |
| * Shows execution count if notebook cell, [*] if running, [ ] if never executed. | |
| */ | |
| getDisplayName(breakpoint: IDebugger.IBreakpoint): string { | |
| - return this._displayRegistry.getDisplayName( | |
| - breakpoint.source as IDebugger.Source | |
| - ); | |
| + return this._displayRegistry.getDisplayName(breakpoint.source as IDebugger.Source); | |
| } | |
| private _breakpoints = new Map<string, IDebugger.IBreakpoint[]>(); | |
| diff --git a/packages/debugger/src/panels/callstack/index.ts b/packages/debugger/src/panels/callstack/index.ts | |
| index ccd1af61ac..e993f56fce 100644 | |
| --- a/packages/debugger/src/panels/callstack/index.ts | |
| +++ b/packages/debugger/src/panels/callstack/index.ts | |
| @@ -3,10 +3,7 @@ | |
| import type { ITranslator } from '@jupyterlab/translation'; | |
| import { nullTranslator } from '@jupyterlab/translation'; | |
| -import { | |
| - CommandToolbarButton, | |
| - PanelWithToolbar | |
| -} from '@jupyterlab/ui-components'; | |
| +import { CommandToolbarButton, PanelWithToolbar } from '@jupyterlab/ui-components'; | |
| import type { CommandRegistry } from '@lumino/commands'; | |
| import type { Panel } from '@lumino/widgets'; | |
| import type { IDebugger } from '../../tokens'; | |
| @@ -28,10 +25,7 @@ export class Callstack extends PanelWithToolbar { | |
| this.title.label = trans.__('Callstack'); | |
| const body = new CallstackBody(model); | |
| - this.toolbar.node.setAttribute( | |
| - 'aria-label', | |
| - trans.__('Callstack panel toolbar') | |
| - ); | |
| + this.toolbar.node.setAttribute('aria-label', trans.__('Callstack panel toolbar')); | |
| this.toolbar.addItem( | |
| 'continue', | |
| new CommandToolbarButton({ | |
| diff --git a/packages/debugger/src/panels/callstack/model.ts b/packages/debugger/src/panels/callstack/model.ts | |
| index dfec541b51..e3fb21d50d 100644 | |
| --- a/packages/debugger/src/panels/callstack/model.ts | |
| +++ b/packages/debugger/src/panels/callstack/model.ts | |
| @@ -13,8 +13,7 @@ import type { IConsoleTracker } from '@jupyterlab/console'; | |
| */ | |
| export class CallstackModel implements IDebugger.Model.ICallstack { | |
| constructor(options: { displayRegistry?: IDebuggerDisplayRegistry }) { | |
| - this._displayRegistry = | |
| - options.displayRegistry ?? new DebuggerDisplayRegistry(); | |
| + this._displayRegistry = options.displayRegistry ?? new DebuggerDisplayRegistry(); | |
| } | |
| /** | |
| @@ -30,11 +29,8 @@ export class CallstackModel implements IDebugger.Model.ICallstack { | |
| */ | |
| set frames(newFrames: IDebugger.IStackFrame[]) { | |
| this._state = newFrames; | |
| - const currentFrameId = | |
| - this.frame !== null ? Private.getFrameId(this.frame) : ''; | |
| - const frame = newFrames.find( | |
| - frame => Private.getFrameId(frame) === currentFrameId | |
| - ); | |
| + const currentFrameId = this.frame !== null ? Private.getFrameId(this.frame) : ''; | |
| + const frame = newFrames.find(frame => Private.getFrameId(frame) === currentFrameId); | |
| // Default to the first frame if the previous one can't be found. | |
| // Otherwise keep the current frame selected. | |
| if (!frame) { | |
| @@ -76,9 +72,7 @@ export class CallstackModel implements IDebugger.Model.ICallstack { | |
| * Returns a human-readable display for a frame. | |
| */ | |
| getDisplayName(frame: IDebugger.IStackFrame): string { | |
| - let name = this._displayRegistry.getDisplayName( | |
| - frame.source as IDebugger.Source | |
| - ); | |
| + let name = this._displayRegistry.getDisplayName(frame.source as IDebugger.Source); | |
| if (frame.line !== undefined) { | |
| name += `:${frame.line}`; | |
| } | |
| @@ -88,9 +82,7 @@ export class CallstackModel implements IDebugger.Model.ICallstack { | |
| private _state: IDebugger.IStackFrame[] = []; | |
| private _currentFrame: IDebugger.IStackFrame | null = null; | |
| private _framesChanged = new Signal<this, IDebugger.IStackFrame[]>(this); | |
| - private _currentFrameChanged = new Signal<this, IDebugger.IStackFrame | null>( | |
| - this | |
| - ); | |
| + private _currentFrameChanged = new Signal<this, IDebugger.IStackFrame | null>(this); | |
| private _displayRegistry: IDebuggerDisplayRegistry; | |
| } | |
| diff --git a/packages/debugger/src/panels/kernelSources/body.tsx b/packages/debugger/src/panels/kernelSources/body.tsx | |
| index c176a9b903..9c76620c15 100644 | |
| --- a/packages/debugger/src/panels/kernelSources/body.tsx | |
| +++ b/packages/debugger/src/panels/kernelSources/body.tsx | |
| @@ -53,8 +53,7 @@ export class KernelSourcesBody extends ReactWidget { | |
| return filtered.map(module => { | |
| const name = module.name; | |
| const path = module.path; | |
| - const key = | |
| - name + (keymap[name] = (keymap[name] ?? 0) + 1).toString(); | |
| + const key = name + (keymap[name] = (keymap[name] ?? 0) + 1).toString(); | |
| return ( | |
| <div | |
| key={key} | |
| @@ -72,11 +71,7 @@ export class KernelSourcesBody extends ReactWidget { | |
| .catch(reason => { | |
| void showErrorMessage( | |
| this._trans.__('Fail to get source'), | |
| - this._trans.__( | |
| - "Fail to get '%1' source:\n%2", | |
| - path, | |
| - reason | |
| - ) | |
| + this._trans.__("Fail to get '%1' source:\n%2", path, reason) | |
| ); | |
| }); | |
| }} | |
| diff --git a/packages/debugger/src/panels/kernelSources/filter.tsx b/packages/debugger/src/panels/kernelSources/filter.tsx | |
| index 1b1515edbe..82cbf45029 100644 | |
| --- a/packages/debugger/src/panels/kernelSources/filter.tsx | |
| +++ b/packages/debugger/src/panels/kernelSources/filter.tsx | |
| @@ -42,10 +42,7 @@ const FilterBox = (props: IFilterBoxProps) => { | |
| */ | |
| export const KernelSourcesFilter = (props: IFilterBoxProps) => { | |
| return ( | |
| - <UseSignal | |
| - signal={props.model.filterChanged} | |
| - initialArgs={props.model.filter} | |
| - > | |
| + <UseSignal signal={props.model.filterChanged} initialArgs={props.model.filter}> | |
| {model => <FilterBox model={props.model} trans={props.trans} />} | |
| </UseSignal> | |
| ); | |
| diff --git a/packages/debugger/src/panels/kernelSources/model.ts b/packages/debugger/src/panels/kernelSources/model.ts | |
| index d9982ab2ca..9c21de007c 100644 | |
| --- a/packages/debugger/src/panels/kernelSources/model.ts | |
| +++ b/packages/debugger/src/panels/kernelSources/model.ts | |
| @@ -29,10 +29,7 @@ const compare = (a: IDebugger.KernelSource, b: IDebugger.KernelSource) => { | |
| export class KernelSourcesModel implements IDebugger.Model.IKernelSources { | |
| constructor() { | |
| this.refresh = this.refresh.bind(this); | |
| - this._refreshDebouncer = new Debouncer( | |
| - this.refresh, | |
| - DEBOUNCER_RATE_LIMIT_MS | |
| - ); | |
| + this._refreshDebouncer = new Debouncer(this.refresh, DEBOUNCER_RATE_LIMIT_MS); | |
| } | |
| /** | |
| diff --git a/packages/debugger/src/panels/sources/body.ts b/packages/debugger/src/panels/sources/body.ts | |
| index f2608255e1..afb1456e13 100644 | |
| --- a/packages/debugger/src/panels/sources/body.ts | |
| +++ b/packages/debugger/src/panels/sources/body.ts | |
| @@ -1,10 +1,7 @@ | |
| // Copyright (c) Jupyter Development Team. | |
| // Distributed under the terms of the Modified BSD License. | |
| -import type { | |
| - CodeEditorWrapper, | |
| - IEditorServices | |
| -} from '@jupyterlab/codeeditor'; | |
| +import type { CodeEditorWrapper, IEditorServices } from '@jupyterlab/codeeditor'; | |
| import { Signal } from '@lumino/signaling'; | |
| diff --git a/packages/debugger/src/panels/sources/model.ts b/packages/debugger/src/panels/sources/model.ts | |
| index fbf381b0a4..a22f1cdb6c 100644 | |
| --- a/packages/debugger/src/panels/sources/model.ts | |
| +++ b/packages/debugger/src/panels/sources/model.ts | |
| @@ -21,8 +21,7 @@ export class SourcesModel implements IDebugger.Model.ISources { | |
| this._currentSource = null; | |
| this._currentFrame = null; | |
| - this._displayRegistry = | |
| - options.displayRegistry ?? new DebuggerDisplayRegistry(); | |
| + this._displayRegistry = options.displayRegistry ?? new DebuggerDisplayRegistry(); | |
| if (options.mimeTypeService) { | |
| this._mimeTypeService = options.mimeTypeService; | |
| @@ -122,9 +121,7 @@ export class SourcesModel implements IDebugger.Model.ISources { | |
| * Returns a human-readable display for a frame. | |
| */ | |
| getDisplayName(frame: IDebugger.IStackFrame): string { | |
| - let name = this._displayRegistry.getDisplayName( | |
| - frame.source as IDebugger.Source | |
| - ); | |
| + let name = this._displayRegistry.getDisplayName(frame.source as IDebugger.Source); | |
| if (frame.line !== undefined) { | |
| name += `:${frame.line}`; | |
| } | |
| @@ -132,14 +129,12 @@ export class SourcesModel implements IDebugger.Model.ISources { | |
| } | |
| private _currentSource: IDebugger.Source | null; | |
| - private _currentSourceOpened = new Signal< | |
| - SourcesModel, | |
| - IDebugger.Source | null | |
| - >(this); | |
| - private _currentSourceChanged = new Signal< | |
| - SourcesModel, | |
| - IDebugger.Source | null | |
| - >(this); | |
| + private _currentSourceOpened = new Signal<SourcesModel, IDebugger.Source | null>( | |
| + this | |
| + ); | |
| + private _currentSourceChanged = new Signal<SourcesModel, IDebugger.Source | null>( | |
| + this | |
| + ); | |
| private _displayRegistry: IDebuggerDisplayRegistry; | |
| private _mimeTypeService: IEditorMimeTypeService | null = null; | |
| private _currentFrame: IDebugger.IStackFrame | null; | |
| diff --git a/packages/debugger/src/panels/variables/scope.tsx b/packages/debugger/src/panels/variables/scope.tsx | |
| index 08977a8e22..e3195037fd 100644 | |
| --- a/packages/debugger/src/panels/variables/scope.tsx | |
| +++ b/packages/debugger/src/panels/variables/scope.tsx | |
| @@ -42,11 +42,7 @@ const ScopeSwitcherComponent = ({ | |
| }; | |
| return ( | |
| - <HTMLSelect | |
| - onChange={onChange} | |
| - value={value} | |
| - aria-label={trans.__('Scope')} | |
| - > | |
| + <HTMLSelect onChange={onChange} value={value} aria-label={trans.__('Scope')}> | |
| {scopes.map(scope => ( | |
| <option key={scope.name} value={scope.name}> | |
| {trans.__(scope.name)} | |
| diff --git a/packages/debugger/src/panels/variables/tree.tsx b/packages/debugger/src/panels/variables/tree.tsx | |
| index 0a17e93f71..b341005bd4 100644 | |
| --- a/packages/debugger/src/panels/variables/tree.tsx | |
| +++ b/packages/debugger/src/panels/variables/tree.tsx | |
| @@ -4,11 +4,7 @@ | |
| import type { ITranslator } from '@jupyterlab/translation'; | |
| import { nullTranslator } from '@jupyterlab/translation'; | |
| -import { | |
| - getTreeItemElement, | |
| - ReactWidget, | |
| - searchIcon | |
| -} from '@jupyterlab/ui-components'; | |
| +import { getTreeItemElement, ReactWidget, searchIcon } from '@jupyterlab/ui-components'; | |
| import { Button, TreeItem, TreeView } from '@jupyter/react-components'; | |
| @@ -150,8 +146,7 @@ interface IVariablesBranchProps { | |
| * @param props.filter Optional variable filter list. | |
| */ | |
| const VariablesBranch = (props: IVariablesBranchProps): JSX.Element => { | |
| - const { commands, data, service, filter, translator, handleSelectVariable } = | |
| - props; | |
| + const { commands, data, service, filter, translator, handleSelectVariable } = props; | |
| const [variables, setVariables] = useState(data); | |
| useEffect(() => { | |
| @@ -161,9 +156,7 @@ const VariablesBranch = (props: IVariablesBranchProps): JSX.Element => { | |
| return ( | |
| <> | |
| {variables | |
| - .filter( | |
| - variable => !(filter || new Set()).has(variable.evaluateName || '') | |
| - ) | |
| + .filter(variable => !(filter || new Set()).has(variable.evaluateName || '')) | |
| .map(variable => { | |
| const key = `${variable.name}-${variable.evaluateName}-${variable.type}-${variable.value}-${variable.variablesReference}`; | |
| return ( | |
| @@ -241,9 +234,7 @@ const VariableComponent = (props: IVariableComponentProps): JSX.Element => { | |
| const [variable] = useState(data); | |
| const [showDetailsButton, setShowDetailsButton] = useState<boolean>(false); | |
| const [expanded, setExpanded] = useState<boolean>(false); | |
| - const [variables, setVariables] = useState<DebugProtocol.Variable[] | null>( | |
| - null | |
| - ); | |
| + const [variables, setVariables] = useState<DebugProtocol.Variable[] | null>(null); | |
| const trans = useMemo( | |
| () => (translator ?? nullTranslator).load('jupyterlab'), | |
| @@ -368,9 +359,7 @@ const VariableComponent = (props: IVariableComponentProps): JSX.Element => { | |
| }} | |
| > | |
| <span className="jp-DebuggerVariables-name">{variable.name}</span> | |
| - {details && ( | |
| - <span className="jp-DebuggerVariables-detail">{details}</span> | |
| - )} | |
| + {details && <span className="jp-DebuggerVariables-detail">{details}</span>} | |
| {hasMimeRenderer && showDetailsButton && ( | |
| <Button | |
| className="jp-DebuggerVariables-renderVariable" | |
| diff --git a/packages/debugger/src/service.ts b/packages/debugger/src/service.ts | |
| index 9b6ea02898..eb97d54241 100644 | |
| --- a/packages/debugger/src/service.ts | |
| +++ b/packages/debugger/src/service.ts | |
| @@ -152,10 +152,7 @@ export class DebuggerService implements IDebugger, IDisposable { | |
| */ | |
| getCodeId(code: string): string { | |
| try { | |
| - return this._config.getCodeId( | |
| - code, | |
| - this.session?.connection?.kernel?.name ?? '' | |
| - ); | |
| + return this._config.getCodeId(code, this.session?.connection?.kernel?.name ?? ''); | |
| } catch { | |
| return ''; | |
| } | |
| @@ -187,8 +184,7 @@ export class DebuggerService implements IDebugger, IDisposable { | |
| return true; | |
| } | |
| return !!( | |
| - this._specsManager.specs.kernelspecs[name]?.metadata?.['debugger'] ?? | |
| - false | |
| + this._specsManager.specs.kernelspecs[name]?.metadata?.['debugger'] ?? false | |
| ); | |
| } | |
| @@ -320,9 +316,7 @@ export class DebuggerService implements IDebugger, IDisposable { | |
| * | |
| * @param variablesReference The variable reference to request. | |
| */ | |
| - async inspectVariable( | |
| - variablesReference: number | |
| - ): Promise<DebugProtocol.Variable[]> { | |
| + async inspectVariable(variablesReference: number): Promise<DebugProtocol.Variable[]> { | |
| if (!this.session) { | |
| throw new Error('No active debugger session'); | |
| } | |
| @@ -346,9 +340,7 @@ export class DebuggerService implements IDebugger, IDisposable { | |
| throw new Error('No active debugger session'); | |
| } | |
| if (!this.model.supportCopyToGlobals) { | |
| - throw new Error( | |
| - 'The "copyToGlobals" request is not supported by the kernel' | |
| - ); | |
| + throw new Error('The "copyToGlobals" request is not supported by the kernel'); | |
| } | |
| const frames = this.model.callstack.frames; | |
| @@ -397,14 +389,12 @@ export class DebuggerService implements IDebugger, IDisposable { | |
| } | |
| const modules = await this.session.sendRequest('modules', {}); | |
| - this._model.kernelSources.kernelSources = modules.body.modules.map( | |
| - module => { | |
| - return { | |
| - name: module.name as string, | |
| - path: module.path as string | |
| - }; | |
| - } | |
| - ); | |
| + this._model.kernelSources.kernelSources = modules.body.modules.map(module => { | |
| + return { | |
| + name: module.name as string, | |
| + path: module.path as string | |
| + }; | |
| + }); | |
| } | |
| /** | |
| @@ -454,9 +444,7 @@ export class DebuggerService implements IDebugger, IDisposable { | |
| } | |
| if (this.isStarted || autoStart) { | |
| - this._model.title = this.isStarted | |
| - ? this.session?.connection?.name || '-' | |
| - : '-'; | |
| + this._model.title = this.isStarted ? this.session?.connection?.name || '-' : '-'; | |
| } | |
| const breakpoints = await this._migrateBreakpoints(oldDebuggerState); | |
| @@ -467,9 +455,7 @@ export class DebuggerService implements IDebugger, IDisposable { | |
| // Filter out kernel breakpoints that already exist at the same line | |
| const newBreakpoints = kernelBpList.filter( | |
| kernelBp => | |
| - !existingBreakpoints.some( | |
| - existingBp => existingBp.line === kernelBp.line | |
| - ) | |
| + !existingBreakpoints.some(existingBp => existingBp.line === kernelBp.line) | |
| ); | |
| // Merge existing and new breakpoints | |
| @@ -789,10 +775,7 @@ export class DebuggerService implements IDebugger, IDisposable { | |
| this._onCurrentFrameChanged, | |
| this | |
| ); | |
| - this._model.variables.variableExpanded.disconnect( | |
| - this._onVariableExpanded, | |
| - this | |
| - ); | |
| + this._model.variables.variableExpanded.disconnect(this._onVariableExpanded, this); | |
| } | |
| /** | |
| @@ -830,9 +813,7 @@ export class DebuggerService implements IDebugger, IDisposable { | |
| * | |
| * @param code The source code to dump. | |
| */ | |
| - private async _dumpCell( | |
| - code: string | |
| - ): Promise<IDebugger.ISession.IDumpCellResponse> { | |
| + private async _dumpCell(code: string): Promise<IDebugger.ISession.IDumpCellResponse> { | |
| if (!this.session) { | |
| throw new Error('No active debugger session'); | |
| } | |
| @@ -847,10 +828,7 @@ export class DebuggerService implements IDebugger, IDisposable { | |
| this._onCurrentFrameChanged, | |
| this | |
| ); | |
| - this._model.variables.variableExpanded.connect( | |
| - this._onVariableExpanded, | |
| - this | |
| - ); | |
| + this._model.variables.variableExpanded.connect(this._onVariableExpanded, this); | |
| const stackFrames = await this._getFrames(this._currentThread()); | |
| this._model.callstack.frames = stackFrames; | |
| @@ -861,9 +839,7 @@ export class DebuggerService implements IDebugger, IDisposable { | |
| * | |
| * @param threadId The thread id. | |
| */ | |
| - private async _getFrames( | |
| - threadId: number | |
| - ): Promise<DebugProtocol.StackFrame[]> { | |
| + private async _getFrames(threadId: number): Promise<DebugProtocol.StackFrame[]> { | |
| if (!this.session) { | |
| throw new Error('No active debugger session'); | |
| } | |
| @@ -960,9 +936,7 @@ export class DebuggerService implements IDebugger, IDisposable { | |
| return; | |
| } | |
| const scopes = await this._getScopes(frame); | |
| - const variables = await Promise.all( | |
| - scopes.map(scope => this._getVariables(scope)) | |
| - ); | |
| + const variables = await Promise.all(scopes.map(scope => this._getVariables(scope))); | |
| const variableScopes = this._convertScopes(scopes, variables); | |
| this._model.variables.scopes = variableScopes; | |
| } | |
| @@ -1045,9 +1019,7 @@ export class DebuggerService implements IDebugger, IDisposable { | |
| private _isDisposed = false; | |
| private _model: IDebugger.Model.IService; | |
| private _session: IDebugger.ISession | null; | |
| - private _sessionChanged = new Signal<IDebugger, IDebugger.ISession | null>( | |
| - this | |
| - ); | |
| + private _sessionChanged = new Signal<IDebugger, IDebugger.ISession | null>(this); | |
| private _specsManager: KernelSpec.IManager | null; | |
| private _trans: TranslationBundle; | |
| private _pauseOnExceptionChanged = new Signal<IDebugger, void>(this); | |
| diff --git a/packages/debugger/src/session.ts b/packages/debugger/src/session.ts | |
| index 2d830a83fb..8cae2be20e 100644 | |
| --- a/packages/debugger/src/session.ts | |
| +++ b/packages/debugger/src/session.ts | |
| @@ -192,9 +192,7 @@ export class DebuggerSession implements IDebugger.ISession { | |
| }); | |
| if (!initializeResponse.success) { | |
| - throw new Error( | |
| - `Could not start the debugger: ${initializeResponse.message}` | |
| - ); | |
| + throw new Error(`Could not start the debugger: ${initializeResponse.message}`); | |
| } | |
| this._capabilities = initializeResponse.body; | |
| this._isStarted = true; | |
| @@ -285,9 +283,7 @@ export class DebuggerSession implements IDebugger.ISession { | |
| ): Promise<KernelMessage.IDebugReplyMsg> { | |
| const kernel = this.connection?.kernel; | |
| if (!kernel) { | |
| - return Promise.reject( | |
| - new Error('A kernel is required to send debug messages.') | |
| - ); | |
| + return Promise.reject(new Error('A kernel is required to send debug messages.')); | |
| } | |
| const reply = new PromiseDelegate<KernelMessage.IDebugReplyMsg>(); | |
| const future = kernel.requestDebug(msg); | |
| @@ -312,10 +308,9 @@ export class DebuggerSession implements IDebugger.ISession { | |
| | undefined = []; | |
| private _currentExceptionFilters: IDebugger.ISession.IExceptionFilter = {}; | |
| private _disposed = new Signal<this, void>(this); | |
| - private _eventMessage = new Signal< | |
| - IDebugger.ISession, | |
| - IDebugger.ISession.Event | |
| - >(this); | |
| + private _eventMessage = new Signal<IDebugger.ISession, IDebugger.ISession.Event>( | |
| + this | |
| + ); | |
| } | |
| /** | |
| diff --git a/packages/debugger/src/sources.ts b/packages/debugger/src/sources.ts | |
| index 081d65556c..9066075716 100644 | |
| --- a/packages/debugger/src/sources.ts | |
| +++ b/packages/debugger/src/sources.ts | |
| @@ -3,10 +3,7 @@ | |
| import type { JupyterFrontEnd } from '@jupyterlab/application'; | |
| import { DOMUtils, MainAreaWidget, WidgetTracker } from '@jupyterlab/apputils'; | |
| -import type { | |
| - CodeEditorWrapper, | |
| - IEditorServices | |
| -} from '@jupyterlab/codeeditor'; | |
| +import type { CodeEditorWrapper, IEditorServices } from '@jupyterlab/codeeditor'; | |
| import type { IConsoleTracker } from '@jupyterlab/console'; | |
| import type { IEditorTracker } from '@jupyterlab/fileeditor'; | |
| import type { INotebookTracker } from '@jupyterlab/notebook'; | |
| @@ -28,9 +25,9 @@ export class DebuggerSources implements IDebugger.ISources { | |
| this._notebookTracker = options.notebookTracker ?? null; | |
| this._consoleTracker = options.consoleTracker ?? null; | |
| this._editorTracker = options.editorTracker ?? null; | |
| - this._readOnlyEditorTracker = new WidgetTracker< | |
| - MainAreaWidget<CodeEditorWrapper> | |
| - >({ namespace: '@jupyterlab/debugger' }); | |
| + this._readOnlyEditorTracker = new WidgetTracker<MainAreaWidget<CodeEditorWrapper>>({ | |
| + namespace: '@jupyterlab/debugger' | |
| + }); | |
| } | |
| /** | |
| @@ -108,11 +105,9 @@ export class DebuggerSources implements IDebugger.ISources { | |
| if (focus) { | |
| notebook.activeCellIndex = i; | |
| if (notebook.activeCell) { | |
| - notebook | |
| - .scrollToItem(notebook.activeCellIndex, 'smart') | |
| - .catch(reason => { | |
| - // no-op | |
| - }); | |
| + notebook.scrollToItem(notebook.activeCellIndex, 'smart').catch(reason => { | |
| + // no-op | |
| + }); | |
| } | |
| this._shell.activateById(notebookPanel.id); | |
| } | |
| @@ -164,8 +159,7 @@ export class DebuggerSources implements IDebugger.ISources { | |
| editors.push( | |
| Object.freeze({ | |
| get: () => cell.editor, | |
| - reveal: () => | |
| - Promise.resolve(this._shell.activateById(consoleWidget.id)), | |
| + reveal: () => Promise.resolve(this._shell.activateById(consoleWidget.id)), | |
| src: cell.model.sharedModel | |
| }) | |
| ); | |
| @@ -282,9 +276,7 @@ export class DebuggerSources implements IDebugger.ISources { | |
| } | |
| private _shell: JupyterFrontEnd.IShell; | |
| - private _readOnlyEditorTracker: WidgetTracker< | |
| - MainAreaWidget<CodeEditorWrapper> | |
| - >; | |
| + private _readOnlyEditorTracker: WidgetTracker<MainAreaWidget<CodeEditorWrapper>>; | |
| private _config: IDebugger.IConfig; | |
| private _notebookTracker: INotebookTracker | null; | |
| diff --git a/packages/debugger/src/tokens.ts b/packages/debugger/src/tokens.ts | |
| index a3266fb599..2bf716ec92 100644 | |
| --- a/packages/debugger/src/tokens.ts | |
| +++ b/packages/debugger/src/tokens.ts | |
| @@ -91,9 +91,7 @@ export interface IDebugger { | |
| /** | |
| * Evaluate an expression. | |
| */ | |
| - evaluate( | |
| - expression: string | |
| - ): Promise<DebugProtocol.EvaluateResponse['body'] | null>; | |
| + evaluate(expression: string): Promise<DebugProtocol.EvaluateResponse['body'] | null>; | |
| /** | |
| * Computes an id based on the given code. | |
| @@ -117,9 +115,7 @@ export interface IDebugger { | |
| * | |
| * @param variablesReference The variable reference to request. | |
| */ | |
| - inspectVariable( | |
| - variablesReference: number | |
| - ): Promise<DebugProtocol.Variable[]>; | |
| + inspectVariable(variablesReference: number): Promise<DebugProtocol.Variable[]>; | |
| /** | |
| * Request to set a variable in the global scope. | |
| @@ -392,17 +388,12 @@ export namespace IDebugger { | |
| /** | |
| * Get exception filters and default values. | |
| */ | |
| - exceptionBreakpointFilters: | |
| - | DebugProtocol.ExceptionBreakpointsFilter[] | |
| - | undefined; | |
| + exceptionBreakpointFilters: DebugProtocol.ExceptionBreakpointsFilter[] | undefined; | |
| /** | |
| * Signal emitted for debug event messages. | |
| */ | |
| - readonly eventMessage: ISignal< | |
| - IDebugger.ISession, | |
| - IDebugger.ISession.Event | |
| - >; | |
| + readonly eventMessage: ISignal<IDebugger.ISession, IDebugger.ISession.Event>; | |
| /** | |
| * Get current exception filter. | |
| diff --git a/packages/debugger/style/sidebar.css b/packages/debugger/style/sidebar.css | |
| index bebac8b8d1..2819485113 100644 | |
| --- a/packages/debugger/style/sidebar.css | |
| +++ b/packages/debugger/style/sidebar.css | |
| @@ -11,8 +11,6 @@ | |
| padding: 4px 10px; | |
| } | |
| -.jp-DebuggerSidebar-body | |
| - .jp-AccordionPanel-title | |
| - jp-toolbar::part(positioning-region) { | |
| +.jp-DebuggerSidebar-body .jp-AccordionPanel-title jp-toolbar::part(positioning-region) { | |
| flex-wrap: nowrap; | |
| } | |
| diff --git a/packages/debugger/test/debugger.spec.ts b/packages/debugger/test/debugger.spec.ts | |
| index 8c792cf853..decda2ec87 100644 | |
| --- a/packages/debugger/test/debugger.spec.ts | |
| +++ b/packages/debugger/test/debugger.spec.ts | |
| @@ -96,14 +96,9 @@ describe('Debugger', () => { | |
| mimeTypeService | |
| }); | |
| const lines = [3, 5]; | |
| - const code = [ | |
| - 'i = 0', | |
| - 'i += 1', | |
| - 'i += 1', | |
| - 'j = i**2', | |
| - 'j += 1', | |
| - 'print(i, j)' | |
| - ].join('\n'); | |
| + const code = ['i = 0', 'i += 1', 'i += 1', 'j = i**2', 'j += 1', 'print(i, j)'].join( | |
| + '\n' | |
| + ); | |
| let breakpoints: IDebugger.IBreakpoint[]; | |
| let session: Debugger.Session; | |
| @@ -163,9 +158,7 @@ describe('Debugger', () => { | |
| }); | |
| const model = service.model as DebuggerModel; | |
| - const currentFrameChanged = signalToPromise( | |
| - model.callstack.currentFrameChanged | |
| - ); | |
| + const currentFrameChanged = signalToPromise(model.callstack.currentFrameChanged); | |
| await act(async () => { | |
| await service.updateBreakpoints(code, breakpoints); | |
| @@ -190,9 +183,7 @@ describe('Debugger', () => { | |
| describe('Panel', () => { | |
| let toolbarList: any; | |
| beforeEach(() => { | |
| - toolbarList = sidebar.content.node.querySelectorAll( | |
| - '.jp-AccordionPanel-title' | |
| - ); | |
| + toolbarList = sidebar.content.node.querySelectorAll('.jp-AccordionPanel-title'); | |
| }); | |
| it('should have 5 child widgets', () => { | |
| expect(sidebar.widgets.length).toBe(5); | |
| @@ -207,15 +198,11 @@ describe('Debugger', () => { | |
| toolbar = toolbarList.item(0); | |
| }); | |
| it('should have expanding icon', () => { | |
| - const title = toolbar.querySelectorAll( | |
| - '.lm-AccordionPanel-titleCollapser' | |
| - ); | |
| + const title = toolbar.querySelectorAll('.lm-AccordionPanel-titleCollapser'); | |
| expect(title[0].innerHTML).toContain('ui-components:caret-down'); | |
| }); | |
| it('should have title', () => { | |
| - const title = toolbar.querySelectorAll( | |
| - 'span.lm-AccordionPanel-titleLabel' | |
| - ); | |
| + const title = toolbar.querySelectorAll('span.lm-AccordionPanel-titleLabel'); | |
| expect(title.length).toBe(1); | |
| expect(title[0].innerHTML).toContain('Variables'); | |
| }); | |
| @@ -232,15 +219,11 @@ describe('Debugger', () => { | |
| toolbar = toolbarList.item(1); | |
| }); | |
| it('should have expanding icon', () => { | |
| - const title = toolbar.querySelectorAll( | |
| - '.lm-AccordionPanel-titleCollapser' | |
| - ); | |
| + const title = toolbar.querySelectorAll('.lm-AccordionPanel-titleCollapser'); | |
| expect(title[0].innerHTML).toContain('ui-components:caret-down'); | |
| }); | |
| it('should have title', () => { | |
| - const title = toolbar.querySelectorAll( | |
| - 'span.lm-AccordionPanel-titleLabel' | |
| - ); | |
| + const title = toolbar.querySelectorAll('span.lm-AccordionPanel-titleLabel'); | |
| expect(title.length).toBe(1); | |
| expect(title[0].innerHTML).toContain('Callstack'); | |
| }); | |
| @@ -255,15 +238,11 @@ describe('Debugger', () => { | |
| toolbar = toolbarList.item(2); | |
| }); | |
| it('should have expanding icon', () => { | |
| - const title = toolbar.querySelectorAll( | |
| - '.lm-AccordionPanel-titleCollapser' | |
| - ); | |
| + const title = toolbar.querySelectorAll('.lm-AccordionPanel-titleCollapser'); | |
| expect(title[0].innerHTML).toContain('ui-components:caret-down'); | |
| }); | |
| it('should have title', () => { | |
| - const title = toolbar.querySelectorAll( | |
| - 'span.lm-AccordionPanel-titleLabel' | |
| - ); | |
| + const title = toolbar.querySelectorAll('span.lm-AccordionPanel-titleLabel'); | |
| expect(title.length).toBe(1); | |
| expect(title[0].innerHTML).toContain('Breakpoints'); | |
| }); | |
| @@ -278,15 +257,11 @@ describe('Debugger', () => { | |
| toolbar = toolbarList.item(3); | |
| }); | |
| it('should have expanding icon', () => { | |
| - const title = toolbar.querySelectorAll( | |
| - '.lm-AccordionPanel-titleCollapser' | |
| - ); | |
| + const title = toolbar.querySelectorAll('.lm-AccordionPanel-titleCollapser'); | |
| expect(title[0].innerHTML).toContain('ui-components:caret-down'); | |
| }); | |
| it('should have title', () => { | |
| - const title = toolbar.querySelectorAll( | |
| - 'span.lm-AccordionPanel-titleLabel' | |
| - ); | |
| + const title = toolbar.querySelectorAll('span.lm-AccordionPanel-titleLabel'); | |
| expect(title.length).toBe(1); | |
| expect(title[0].innerHTML).toContain('Source'); | |
| }); | |
| diff --git a/packages/debugger/test/service.spec.ts b/packages/debugger/test/service.spec.ts | |
| index 17be35aacd..6b52308783 100644 | |
| --- a/packages/debugger/test/service.spec.ts | |
| +++ b/packages/debugger/test/service.spec.ts | |
| @@ -2,11 +2,7 @@ | |
| // Distributed under the terms of the Modified BSD License. | |
| import type { KernelSpec, Session } from '@jupyterlab/services'; | |
| -import { | |
| - KernelManager, | |
| - KernelSpecManager, | |
| - SessionManager | |
| -} from '@jupyterlab/services'; | |
| +import { KernelManager, KernelSpecManager, SessionManager } from '@jupyterlab/services'; | |
| import { createSession } from '@jupyterlab/docregistry/lib/testutils'; | |
| @@ -222,17 +218,15 @@ describe('DebuggerService', () => { | |
| await service.restoreState(true); | |
| const breakpointLines: number[] = [3, 5]; | |
| sourceId = service.getCodeId(code); | |
| - breakpoints = breakpointLines.map( | |
| - (line: number): IDebugger.IBreakpoint => { | |
| - return { | |
| - line, | |
| - verified: true, | |
| - source: { | |
| - path: sourceId | |
| - } | |
| - }; | |
| - } | |
| - ); | |
| + breakpoints = breakpointLines.map((line: number): IDebugger.IBreakpoint => { | |
| + return { | |
| + line, | |
| + verified: true, | |
| + source: { | |
| + path: sourceId | |
| + } | |
| + }; | |
| + }); | |
| await service.updateBreakpoints(code, breakpoints); | |
| }); | |
| diff --git a/packages/debugger/test/session.spec.ts b/packages/debugger/test/session.spec.ts | |
| index 21ae7e268c..b55ef491de 100644 | |
| --- a/packages/debugger/test/session.spec.ts | |
| +++ b/packages/debugger/test/session.spec.ts | |
| @@ -124,10 +124,7 @@ describe('protocol', () => { | |
| 'print(j)' | |
| ].join('\n'); | |
| - const breakpoints: DebugProtocol.SourceBreakpoint[] = [ | |
| - { line: 3 }, | |
| - { line: 5 } | |
| - ]; | |
| + const breakpoints: DebugProtocol.SourceBreakpoint[] = [{ line: 3 }, { line: 5 }]; | |
| let connection: Session.ISessionConnection; | |
| let config: IDebugger.IConfig; | |
| diff --git a/packages/docmanager-extension/src/index.tsx b/packages/docmanager-extension/src/index.tsx | |
| index f423fd1631..bfe4fdc1c8 100644 | |
| --- a/packages/docmanager-extension/src/index.tsx | |
| +++ b/packages/docmanager-extension/src/index.tsx | |
| @@ -5,10 +5,7 @@ | |
| * @module docmanager-extension | |
| */ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { ILabShell, ILabStatus, JupyterLab } from '@jupyterlab/application'; | |
| import type { ISessionContext } from '@jupyterlab/apputils'; | |
| import { | |
| @@ -37,10 +34,7 @@ import { | |
| PathStatus, | |
| SavingStatus | |
| } from '@jupyterlab/docmanager'; | |
| -import type { | |
| - DocumentRegistry, | |
| - IDocumentWidget | |
| -} from '@jupyterlab/docregistry'; | |
| +import type { DocumentRegistry, IDocumentWidget } from '@jupyterlab/docregistry'; | |
| import { IUrlResolverFactory } from '@jupyterlab/rendermime'; | |
| import type { Contents, Kernel } from '@jupyterlab/services'; | |
| import { ISettingRegistry } from '@jupyterlab/settingregistry'; | |
| @@ -198,8 +192,7 @@ const manager: JupyterFrontEndPlugin<IDocumentManager> = { | |
| ) => { | |
| const { serviceManager: manager, docRegistry: registry } = app; | |
| const translator = translator_ ?? nullTranslator; | |
| - const sessionDialogs = | |
| - sessionDialogs_ ?? new SessionContextDialogs({ translator }); | |
| + const sessionDialogs = sessionDialogs_ ?? new SessionContextDialogs({ translator }); | |
| const docManagerDialogs = | |
| docManagerDialogs_ ?? new DocumentManagerDialogs({ translator }); | |
| const when = app.restored.then(() => void 0); | |
| @@ -266,8 +259,7 @@ const docManagerPlugin: JupyterFrontEndPlugin<void> = { | |
| const onSettingsUpdated = (settings: ISettingRegistry.ISettings) => { | |
| // Handle whether to autosave | |
| const autosave = settings.get('autosave').composite as boolean | null; | |
| - docManager.autosave = | |
| - autosave === true || autosave === false ? autosave : true; | |
| + docManager.autosave = autosave === true || autosave === false ? autosave : true; | |
| app.commands.notifyCommandChanged(CommandIDs.toggleAutosave); | |
| const confirmClosingDocument = settings.get('confirmClosingDocument') | |
| @@ -341,9 +333,7 @@ const docManagerPlugin: JupyterFrontEndPlugin<void> = { | |
| settings.get(change.name).composite !== change.newValue | |
| ) { | |
| settings.set(change.name, change.newValue).catch(reason => { | |
| - console.error( | |
| - `Failed to set the setting '${change.name}':\n${reason}` | |
| - ); | |
| + console.error(`Failed to set the setting '${change.name}':\n${reason}`); | |
| }); | |
| } | |
| }; | |
| @@ -395,9 +385,7 @@ Available file types: | |
| // If the document registry gains or loses a factory or file type, | |
| // regenerate the settings description with the available options. | |
| - registry.changed.connect(() => | |
| - settingRegistry.load(docManagerPluginId, true) | |
| - ); | |
| + registry.changed.connect(() => settingRegistry.load(docManagerPluginId, true)); | |
| } | |
| }; | |
| @@ -583,9 +571,7 @@ export const openBrowserTabPlugin: JupyterFrontEndPlugin<void> = { | |
| properties: { | |
| path: { | |
| type: 'string', | |
| - description: trans.__( | |
| - 'The path of the file to open in browser tab' | |
| - ) | |
| + description: trans.__('The path of the file to open in browser tab') | |
| }, | |
| icon: { | |
| type: 'string', | |
| @@ -732,14 +718,7 @@ function addCommands( | |
| if (!dialogs) { | |
| dialogs = new DocumentManagerDialogs({ translator: translator }); | |
| } | |
| - addLabCommands( | |
| - app, | |
| - docManager, | |
| - labShell, | |
| - widgetOpener, | |
| - translator, | |
| - dialogs | |
| - ); | |
| + addLabCommands(app, docManager, labShell, widgetOpener, translator, dialogs); | |
| } | |
| commands.addCommand(CommandIDs.deleteFile, { | |
| @@ -757,8 +736,7 @@ function addCommands( | |
| } | |
| }, | |
| execute: args => { | |
| - const path = | |
| - typeof args['path'] === 'undefined' ? '' : (args['path'] as string); | |
| + const path = typeof args['path'] === 'undefined' ? '' : (args['path'] as string); | |
| if (!path) { | |
| const command = CommandIDs.deleteFile; | |
| @@ -771,8 +749,7 @@ function addCommands( | |
| commands.addCommand(CommandIDs.newUntitled, { | |
| execute: async args => { | |
| const errorTitle = (args['error'] as string) || trans.__('Error'); | |
| - const path = | |
| - typeof args['path'] === 'undefined' ? '' : (args['path'] as string); | |
| + const path = typeof args['path'] === 'undefined' ? '' : (args['path'] as string); | |
| const options: Partial<Contents.ICreateOptions> = { | |
| type: args['type'] as Contents.ContentType, | |
| path | |
| @@ -819,25 +796,17 @@ function addCommands( | |
| commands.addCommand(CommandIDs.open, { | |
| execute: async args => { | |
| - const path = | |
| - typeof args['path'] === 'undefined' ? '' : (args['path'] as string); | |
| + const path = typeof args['path'] === 'undefined' ? '' : (args['path'] as string); | |
| const factory = (args['factory'] as string) || void 0; | |
| const kernel = args?.kernel as unknown as Kernel.IModel | undefined; | |
| const kernelPreference = args?.kernelPreference as unknown as | |
| | ISessionContext.IKernelPreference | |
| | undefined; | |
| - const options = | |
| - (args['options'] as DocumentRegistry.IOpenOptions) || void 0; | |
| + const options = (args['options'] as DocumentRegistry.IOpenOptions) || void 0; | |
| return docManager.services.contents | |
| .get(path, { content: false }) | |
| .then(() => | |
| - docManager.openOrReveal( | |
| - path, | |
| - factory, | |
| - kernel, | |
| - options, | |
| - kernelPreference | |
| - ) | |
| + docManager.openOrReveal(path, factory, kernel, options, kernelPreference) | |
| ); | |
| }, | |
| iconClass: args => (args['icon'] as string) || '', | |
| @@ -891,8 +860,7 @@ function addCommands( | |
| }, | |
| shouldStart: { | |
| type: 'boolean', | |
| - description: | |
| - 'A kernel should be started automatically (default `true`)' | |
| + description: 'A kernel should be started automatically (default `true`)' | |
| }, | |
| canStart: { | |
| type: 'boolean', | |
| @@ -963,10 +931,7 @@ function addCommands( | |
| commands.addCommand(CommandIDs.reload, { | |
| label: () => | |
| - trans.__( | |
| - 'Reload %1 from Disk', | |
| - fileType(shell.currentWidget, docManager) | |
| - ), | |
| + trans.__('Reload %1 from Disk', fileType(shell.currentWidget, docManager)), | |
| caption: trans.__('Reload contents from disk'), | |
| isEnabled, | |
| describedBy: { | |
| @@ -992,10 +957,7 @@ function addCommands( | |
| if (context.model.dirty) { | |
| return showDialog({ | |
| title: trans.__('Reload %1 from Disk', type), | |
| - body: trans.__( | |
| - 'Are you sure you want to reload the %1 from the disk?', | |
| - type | |
| - ), | |
| + body: trans.__('Are you sure you want to reload the %1 from the disk?', type), | |
| buttons: [ | |
| Dialog.cancelButton(), | |
| Dialog.warnButton({ label: trans.__('Reload') }) | |
| @@ -1015,10 +977,7 @@ function addCommands( | |
| commands.addCommand(CommandIDs.restoreCheckpoint, { | |
| label: () => | |
| - trans.__( | |
| - 'Revert %1 to Checkpoint…', | |
| - fileType(shell.currentWidget, docManager) | |
| - ), | |
| + trans.__('Revert %1 to Checkpoint…', fileType(shell.currentWidget, docManager)), | |
| caption: trans.__('Revert contents to previous checkpoint'), | |
| isEnabled, | |
| describedBy: { | |
| @@ -1104,8 +1063,7 @@ function addCommands( | |
| icon: args => (args.toolbar ? saveIcon : undefined), | |
| isEnabled: args => { | |
| if (args._luminoEvent) { | |
| - return (args._luminoEvent as ReadonlyPartialJSONObject).type === | |
| - 'keybinding' | |
| + return (args._luminoEvent as ReadonlyPartialJSONObject).type === 'keybinding' | |
| ? true | |
| : isWritable(); | |
| } else { | |
| @@ -1264,8 +1222,7 @@ function addCommands( | |
| }); | |
| commands.addCommand(CommandIDs.saveAs, { | |
| - label: () => | |
| - trans.__('Save %1 As…', fileType(shell.currentWidget, docManager)), | |
| + label: () => trans.__('Save %1 As…', fileType(shell.currentWidget, docManager)), | |
| caption: trans.__('Save with new path'), | |
| isEnabled, | |
| describedBy: { | |
| @@ -1286,10 +1243,7 @@ function addCommands( | |
| }); | |
| } | |
| - const onChange = ( | |
| - sender: Contents.IManager, | |
| - args: Contents.IChangedArgs | |
| - ) => { | |
| + const onChange = (sender: Contents.IManager, args: Contents.IChangedArgs) => { | |
| if ( | |
| args.type === 'save' && | |
| args.newValue && | |
| @@ -1304,9 +1258,7 @@ function addCommands( | |
| docManager.services.contents.fileChanged.connect(onChange); | |
| void context | |
| .saveAs() | |
| - .finally(() => | |
| - docManager.services.contents.fileChanged.disconnect(onChange) | |
| - ); | |
| + .finally(() => docManager.services.contents.fileChanged.disconnect(onChange)); | |
| } | |
| } | |
| }); | |
| @@ -1391,8 +1343,7 @@ function addLabCommands( | |
| }; | |
| commands.addCommand(CommandIDs.clone, { | |
| - label: () => | |
| - trans.__('New View for %1', fileType(contextMenuWidget(), docManager)), | |
| + label: () => trans.__('New View for %1', fileType(contextMenuWidget(), docManager)), | |
| isEnabled, | |
| execute: args => { | |
| const widget = contextMenuWidget(); | |
| @@ -1446,8 +1397,7 @@ function addLabCommands( | |
| }); | |
| commands.addCommand(CommandIDs.duplicate, { | |
| - label: () => | |
| - trans.__('Duplicate %1', fileType(contextMenuWidget(), docManager)), | |
| + label: () => trans.__('Duplicate %1', fileType(contextMenuWidget(), docManager)), | |
| isEnabled, | |
| execute: () => { | |
| if (isEnabled()) { | |
| @@ -1467,8 +1417,7 @@ function addLabCommands( | |
| }); | |
| commands.addCommand(CommandIDs.del, { | |
| - label: () => | |
| - trans.__('Delete %1', fileType(contextMenuWidget(), docManager)), | |
| + label: () => trans.__('Delete %1', fileType(contextMenuWidget(), docManager)), | |
| isEnabled, | |
| execute: async () => { | |
| // Implies contextMenuWidget() !== null | |
| @@ -1539,10 +1488,7 @@ function addLabCommands( | |
| /** | |
| * Handle dirty state for a context. | |
| */ | |
| -function handleContext( | |
| - status: ILabStatus, | |
| - context: DocumentRegistry.Context | |
| -): void { | |
| +function handleContext(status: ILabStatus, context: DocumentRegistry.Context): void { | |
| let disposable: IDisposable | null = null; | |
| const onStateChanged = (sender: any, args: IChangedArgs<any>) => { | |
| if (args.name === 'dirty') { | |
| @@ -1586,10 +1532,7 @@ namespace Private { | |
| const body = document.createElement('div'); | |
| const confirmMessage = document.createElement('p'); | |
| const confirmText = document.createTextNode( | |
| - trans.__( | |
| - 'Are you sure you want to revert the %1 to checkpoint? ', | |
| - fileType | |
| - ) | |
| + trans.__('Are you sure you want to revert the %1 to checkpoint? ', fileType) | |
| ); | |
| const cannotUndoText = document.createElement('strong'); | |
| cannotUndoText.textContent = trans.__('This cannot be undone.'); | |
| diff --git a/packages/docmanager-extension/src/recents.ts b/packages/docmanager-extension/src/recents.ts | |
| index 63f429507c..ede20fbebb 100644 | |
| --- a/packages/docmanager-extension/src/recents.ts | |
| +++ b/packages/docmanager-extension/src/recents.ts | |
| @@ -3,10 +3,7 @@ | |
| * Distributed under the terms of the Modified BSD License. | |
| */ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { IRecentsManager, RecentsManager } from '@jupyterlab/docmanager'; | |
| import { ISettingRegistry } from '@jupyterlab/settingregistry'; | |
| import { IStateDB } from '@jupyterlab/statedb'; | |
| @@ -21,8 +18,7 @@ namespace CommandIDs { | |
| namespace PluginIDs { | |
| export const recentsManager = '@jupyterlab/docmanager-extension:recents'; | |
| - export const reopenClosed = | |
| - '@jupyterlab/docmanager-extension:reopen-recently-closed'; | |
| + export const reopenClosed = '@jupyterlab/docmanager-extension:reopen-recently-closed'; | |
| export const mainPlugin = '@jupyterlab/docmanager-extension:plugin'; | |
| } | |
| @@ -54,13 +50,12 @@ export const recentsManagerPlugin: JupyterFrontEndPlugin<IRecentsManager> = { | |
| }; | |
| if (settingRegistry) { | |
| - void Promise.all([ | |
| - app.restored, | |
| - settingRegistry.load(PluginIDs.mainPlugin) | |
| - ]).then(([_, settings]) => { | |
| - settings.changed.connect(updateSettings); | |
| - updateSettings(settings); | |
| - }); | |
| + void Promise.all([app.restored, settingRegistry.load(PluginIDs.mainPlugin)]).then( | |
| + ([_, settings]) => { | |
| + settings.changed.connect(updateSettings); | |
| + updateSettings(settings); | |
| + } | |
| + ); | |
| } | |
| app.commands.addCommand(CommandIDs.clearRecents, { | |
| diff --git a/packages/docmanager/src/manager.ts b/packages/docmanager/src/manager.ts | |
| index eeaeadd68e..799891e705 100644 | |
| --- a/packages/docmanager/src/manager.ts | |
| +++ b/packages/docmanager/src/manager.ts | |
| @@ -5,10 +5,7 @@ import type { ISessionContext } from '@jupyterlab/apputils'; | |
| import { SessionContextDialogs } from '@jupyterlab/apputils'; | |
| import type { IChangedArgs } from '@jupyterlab/coreutils'; | |
| import { PathExt } from '@jupyterlab/coreutils'; | |
| -import type { | |
| - DocumentRegistry, | |
| - IDocumentWidget | |
| -} from '@jupyterlab/docregistry'; | |
| +import type { DocumentRegistry, IDocumentWidget } from '@jupyterlab/docregistry'; | |
| import { Context } from '@jupyterlab/docregistry'; | |
| import type { IUrlResolverFactory } from '@jupyterlab/rendermime'; | |
| @@ -399,9 +396,7 @@ export class DocumentManager implements IDocumentManager { | |
| } | |
| widgetNames = [factory.name]; | |
| } else if (widgetName === null) { | |
| - widgetNames = this.registry | |
| - .preferredWidgetFactories(newPath) | |
| - .map(f => f.name); | |
| + widgetNames = this.registry.preferredWidgetFactories(newPath).map(f => f.name); | |
| } | |
| for (const context of this._contextsForPath(newPath)) { | |
| @@ -546,9 +541,7 @@ export class DocumentManager implements IDocumentManager { | |
| ): Private.IContext | undefined { | |
| const normalizedPath = this.services.contents.normalize(path); | |
| return find(this._contexts, context => { | |
| - return ( | |
| - context.path === normalizedPath && context.factoryName === factoryName | |
| - ); | |
| + return context.path === normalizedPath && context.factoryName === factoryName; | |
| }); | |
| } | |
| @@ -725,10 +718,7 @@ export class DocumentManager implements IDocumentManager { | |
| /** | |
| * Handle an activateRequested signal from the widget manager. | |
| */ | |
| - private _onActivateRequested( | |
| - sender: DocumentWidgetManager, | |
| - args: string | |
| - ): void { | |
| + private _onActivateRequested(sender: DocumentWidgetManager, args: string): void { | |
| this._activateRequested.emit(args); | |
| } | |
| diff --git a/packages/docmanager/src/pathstatus.tsx b/packages/docmanager/src/pathstatus.tsx | |
| index 6437100683..d862c56b18 100644 | |
| --- a/packages/docmanager/src/pathstatus.tsx | |
| +++ b/packages/docmanager/src/pathstatus.tsx | |
| @@ -58,12 +58,7 @@ export class PathStatus extends VDomRenderer<PathStatus.Model> { | |
| * Render the status item. | |
| */ | |
| render(): JSX.Element { | |
| - return ( | |
| - <PathStatusComponent | |
| - fullPath={this.model!.path} | |
| - name={this.model!.name!} | |
| - /> | |
| - ); | |
| + return <PathStatusComponent fullPath={this.model!.path} name={this.model!.name!} />; | |
| } | |
| } | |
| @@ -173,10 +168,7 @@ export namespace PathStatus { | |
| /** | |
| * Trigger a state change to rerender. | |
| */ | |
| - private _triggerChange( | |
| - oldState: [string, string], | |
| - newState: [string, string] | |
| - ) { | |
| + private _triggerChange(oldState: [string, string], newState: [string, string]) { | |
| if (oldState[0] !== newState[0] || oldState[1] !== newState[1]) { | |
| this.stateChanged.emit(void 0); | |
| } | |
| diff --git a/packages/docmanager/src/recents.ts b/packages/docmanager/src/recents.ts | |
| index be2f905fba..e92b92abd2 100644 | |
| --- a/packages/docmanager/src/recents.ts | |
| +++ b/packages/docmanager/src/recents.ts | |
| @@ -91,10 +91,7 @@ export class RecentsManager implements IRecentsManager { | |
| /** | |
| * Add a new path to the recent list. | |
| */ | |
| - addRecent( | |
| - document: Omit<RecentDocument, 'root'>, | |
| - event: 'opened' | 'closed' | |
| - ): void { | |
| + addRecent(document: Omit<RecentDocument, 'root'>, event: 'opened' | 'closed'): void { | |
| const recent: RecentDocument = { | |
| ...document, | |
| root: this._serverRoot | |
| @@ -184,19 +181,14 @@ export class RecentsManager implements IRecentsManager { | |
| * Set the recent list | |
| * @param recents The new recent list | |
| */ | |
| - private _setRecents( | |
| - recents: RecentDocument[], | |
| - type: 'opened' | 'closed' | |
| - ): void { | |
| - this._recents[type] = recents | |
| - .slice(0, this.maximalRecentsLength) | |
| - .sort((a, b) => { | |
| - if (a.root === b.root) { | |
| - return 0; | |
| - } else { | |
| - return a.root !== this._serverRoot ? 1 : -1; | |
| - } | |
| - }); | |
| + private _setRecents(recents: RecentDocument[], type: 'opened' | 'closed'): void { | |
| + this._recents[type] = recents.slice(0, this.maximalRecentsLength).sort((a, b) => { | |
| + if (a.root === b.root) { | |
| + return 0; | |
| + } else { | |
| + return a.root !== this._serverRoot ? 1 : -1; | |
| + } | |
| + }); | |
| this._saveDebouncer.invoke().catch(console.warn); | |
| } | |
| diff --git a/packages/docmanager/src/savehandler.ts b/packages/docmanager/src/savehandler.ts | |
| index c86c4a9bf3..ce4d81162c 100644 | |
| --- a/packages/docmanager/src/savehandler.ts | |
| +++ b/packages/docmanager/src/savehandler.ts | |
| @@ -126,10 +126,7 @@ export class SaveHandler implements IDisposable { | |
| } | |
| const duration = new Date().getTime() - start; | |
| // New save interval: higher of 10x save duration or min interval. | |
| - this._interval = Math.max( | |
| - this._multiplier * duration, | |
| - this._minInterval | |
| - ); | |
| + this._interval = Math.max(this._multiplier * duration, this._minInterval); | |
| // Restart the update to pick up the new interval. | |
| this._setTimer(); | |
| }) | |
| diff --git a/packages/docmanager/src/savingstatus.tsx b/packages/docmanager/src/savingstatus.tsx | |
| index 007ffcf82a..07817ba2e8 100644 | |
| --- a/packages/docmanager/src/savingstatus.tsx | |
| +++ b/packages/docmanager/src/savingstatus.tsx | |
| @@ -69,11 +69,7 @@ export class SavingStatus extends VDomRenderer<SavingStatus.Model> { | |
| if (this.model === null || this.model.status === null) { | |
| return null; | |
| } else { | |
| - return ( | |
| - <SavingStatusComponent | |
| - fileStatus={this._statusMap[this.model.status]} | |
| - /> | |
| - ); | |
| + return <SavingStatusComponent fileStatus={this._statusMap[this.model.status]} />; | |
| } | |
| } | |
| @@ -135,9 +131,7 @@ export namespace SavingStatus { | |
| if (widgetContext) { | |
| widgetContext.saveState.connect(this._onStatusChange); | |
| } else if ((this._widget as any).content?.saveStateChanged) { | |
| - (this._widget as any).content.saveStateChanged.connect( | |
| - this._onStatusChange | |
| - ); | |
| + (this._widget as any).content.saveStateChanged.connect(this._onStatusChange); | |
| } | |
| } | |
| } | |
| @@ -145,10 +139,7 @@ export namespace SavingStatus { | |
| /** | |
| * React to a saving status change from the current document widget. | |
| */ | |
| - private _onStatusChange = ( | |
| - _: any, | |
| - newStatus: DocumentRegistry.SaveState | |
| - ) => { | |
| + private _onStatusChange = (_: any, newStatus: DocumentRegistry.SaveState) => { | |
| this._status = newStatus; | |
| if (this._status === 'completed') { | |
| diff --git a/packages/docmanager/src/tokens.ts b/packages/docmanager/src/tokens.ts | |
| index 22d3eb2edc..1444bae07d 100644 | |
| --- a/packages/docmanager/src/tokens.ts | |
| +++ b/packages/docmanager/src/tokens.ts | |
| @@ -3,10 +3,7 @@ | |
| import type { ISessionContext } from '@jupyterlab/apputils'; | |
| import type { IChangedArgs } from '@jupyterlab/coreutils'; | |
| -import type { | |
| - DocumentRegistry, | |
| - IDocumentWidget | |
| -} from '@jupyterlab/docregistry'; | |
| +import type { DocumentRegistry, IDocumentWidget } from '@jupyterlab/docregistry'; | |
| import type { Contents, Kernel, ServiceManager } from '@jupyterlab/services'; | |
| import { Token } from '@lumino/coreutils'; | |
| import type { IDisposable } from '@lumino/disposable'; | |
| @@ -300,10 +297,7 @@ export interface IDocumentManager extends IDisposable { | |
| * This can be used to find an existing widget instead of opening | |
| * a new widget. | |
| */ | |
| - findWidget( | |
| - path: string, | |
| - widgetName?: string | null | |
| - ): IDocumentWidget | undefined; | |
| + findWidget(path: string, widgetName?: string | null): IDocumentWidget | undefined; | |
| /** | |
| * Create a new untitled file. | |
| @@ -425,10 +419,7 @@ export interface IRecentsManager extends IDisposable { | |
| /** | |
| * Add a new path to the recent list. | |
| */ | |
| - addRecent( | |
| - document: Omit<RecentDocument, 'root'>, | |
| - event: 'opened' | 'closed' | |
| - ): void; | |
| + addRecent(document: Omit<RecentDocument, 'root'>, event: 'opened' | 'closed'): void; | |
| /** | |
| * Remove the document from recents list. | |
| diff --git a/packages/docmanager/src/widgetmanager.ts b/packages/docmanager/src/widgetmanager.ts | |
| index d492a9ed38..db9a1399a5 100644 | |
| --- a/packages/docmanager/src/widgetmanager.ts | |
| +++ b/packages/docmanager/src/widgetmanager.ts | |
| @@ -3,10 +3,7 @@ | |
| import type { IChangedArgs } from '@jupyterlab/coreutils'; | |
| import { Time } from '@jupyterlab/coreutils'; | |
| -import type { | |
| - DocumentRegistry, | |
| - IDocumentWidget | |
| -} from '@jupyterlab/docregistry'; | |
| +import type { DocumentRegistry, IDocumentWidget } from '@jupyterlab/docregistry'; | |
| import type { Contents } from '@jupyterlab/services'; | |
| import type { ITranslator } from '@jupyterlab/translation'; | |
| import { nullTranslator } from '@jupyterlab/translation'; | |
| @@ -150,10 +147,7 @@ export class DocumentWidgetManager implements IDisposable { | |
| * | |
| * @param widget - The widget to adopt. | |
| */ | |
| - adoptWidget( | |
| - context: DocumentRegistry.Context, | |
| - widget: IDocumentWidget | |
| - ): void { | |
| + adoptWidget(context: DocumentRegistry.Context, widget: IDocumentWidget): void { | |
| const widgets = Private.widgetsProperty.get(context); | |
| widgets.push(widget); | |
| MessageLoop.installMessageHook(widget, this); | |
| @@ -313,11 +307,7 @@ export class DocumentWidgetManager implements IDisposable { | |
| } | |
| const last = checkpoints[checkpoints.length - 1]; | |
| const checkpoint = last ? Time.format(last.last_modified) : 'None'; | |
| - let caption = trans.__( | |
| - 'Name: %1\nPath: %2\n', | |
| - model!.name, | |
| - model!.path | |
| - ); | |
| + let caption = trans.__('Name: %1\nPath: %2\n', model!.name, model!.path); | |
| if (context!.model.readOnly) { | |
| caption += trans.__('Read-only'); | |
| } else { | |
| @@ -338,10 +328,7 @@ export class DocumentWidgetManager implements IDisposable { | |
| */ | |
| protected async onClose(widget: Widget): Promise<boolean> { | |
| // Handle dirty state. | |
| - const [shouldClose, ignoreSave] = await this._maybeClose( | |
| - widget, | |
| - this.translator | |
| - ); | |
| + const [shouldClose, ignoreSave] = await this._maybeClose(widget, this.translator); | |
| if (widget.isDisposed) { | |
| return true; | |
| } | |
| @@ -467,18 +454,15 @@ export class DocumentWidgetManager implements IDisposable { | |
| const factory = Private.factoryProperty.get(widget); | |
| const isDirty = | |
| - context.model.dirty && | |
| - widgets.length <= 1 && | |
| - !(factory?.readOnly ?? true); | |
| + context.model.dirty && widgets.length <= 1 && !(factory?.readOnly ?? true); | |
| const dialogs = | |
| this._dialogs ?? new DocumentManagerDialogs({ translator: translator }); | |
| // Ask confirmation | |
| if (this.confirmClosingDocument) { | |
| - const { shouldClose, ignoreSave, doNotAskAgain } = | |
| - await dialogs.confirmClose({ | |
| - fileName, | |
| - isDirty | |
| - }); | |
| + const { shouldClose, ignoreSave, doNotAskAgain } = await dialogs.confirmClose({ | |
| + fileName, | |
| + isDirty | |
| + }); | |
| if (doNotAskAgain) { | |
| this.confirmClosingDocument = false; | |
| @@ -550,9 +534,7 @@ export class DocumentWidgetManager implements IDisposable { | |
| private _activateRequested = new Signal<this, string>(this); | |
| private _confirmClosingTab = false; | |
| private _isDisposed = false; | |
| - private _stateChanged = new Signal<DocumentWidgetManager, IChangedArgs<any>>( | |
| - this | |
| - ); | |
| + private _stateChanged = new Signal<DocumentWidgetManager, IChangedArgs<any>>(this); | |
| private _recentsManager: IRecentsManager | null; | |
| private _dialogs: IDocumentManagerDialogs | null; | |
| } | |
| @@ -627,10 +609,7 @@ namespace Private { | |
| /** | |
| * A private attached property for a widget's disposables. | |
| */ | |
| - export const disposablesProperty = new AttachedProperty< | |
| - Widget, | |
| - DisposableSet | |
| - >({ | |
| + export const disposablesProperty = new AttachedProperty<Widget, DisposableSet>({ | |
| name: 'disposables', | |
| create: () => new DisposableSet() | |
| }); | |
| diff --git a/packages/docmanager/test/dialog.spec.ts b/packages/docmanager/test/dialog.spec.ts | |
| index b4cf6a040e..0c03e1415e 100644 | |
| --- a/packages/docmanager/test/dialog.spec.ts | |
| +++ b/packages/docmanager/test/dialog.spec.ts | |
| @@ -4,11 +4,7 @@ | |
| */ | |
| import type { IDocumentManagerDialogs } from '@jupyterlab/docmanager'; | |
| -import { | |
| - DocumentManager, | |
| - renameDialog, | |
| - renameFile | |
| -} from '@jupyterlab/docmanager'; | |
| +import { DocumentManager, renameDialog, renameFile } from '@jupyterlab/docmanager'; | |
| import type { IDocumentWidget } from '@jupyterlab/docregistry'; | |
| import { | |
| ABCWidgetFactory, | |
| @@ -56,28 +52,19 @@ describe('docregistry/dialog', () => { | |
| it('should show overwrite dialog when file is already existing', async () => { | |
| alreadyExistsError.response.status = 409; | |
| await expect( | |
| - Promise.all([ | |
| - dismissDialog(), | |
| - renameFile(manager, 'foo.ipynb', 'bar.ipynb') | |
| - ]) | |
| + Promise.all([dismissDialog(), renameFile(manager, 'foo.ipynb', 'bar.ipynb')]) | |
| ).rejects.toBe('File not renamed'); | |
| }); | |
| it('should throw error on no status', async () => { | |
| alreadyExistsError.response = {}; | |
| await expect( | |
| - Promise.all([ | |
| - dismissDialog(), | |
| - renameFile(manager, 'foo.ipynb', 'bar.ipynb') | |
| - ]) | |
| + Promise.all([dismissDialog(), renameFile(manager, 'foo.ipynb', 'bar.ipynb')]) | |
| ).rejects.toBe(alreadyExistsError); | |
| }); | |
| it('should throw error on not 409 status', async () => { | |
| alreadyExistsError.response.status = 408; | |
| await expect( | |
| - Promise.all([ | |
| - dismissDialog(), | |
| - renameFile(manager, 'foo.ipynb', 'bar.ipynb') | |
| - ]) | |
| + Promise.all([dismissDialog(), renameFile(manager, 'foo.ipynb', 'bar.ipynb')]) | |
| ).rejects.toBe(alreadyExistsError); | |
| }); | |
| }); | |
| @@ -113,9 +100,7 @@ class MinimalCustomDialogs implements IDocumentManagerDialogs { | |
| } | |
| class WidgetFactory extends ABCWidgetFactory<IDocumentWidget> { | |
| - protected createNewWidget( | |
| - context: DocumentRegistry.Context | |
| - ): IDocumentWidget { | |
| + protected createNewWidget(context: DocumentRegistry.Context): IDocumentWidget { | |
| const content = new Widget(); | |
| const widget = new DocumentWidget({ content, context }); | |
| widget.addClass('WidgetFactory'); | |
| diff --git a/packages/docmanager/test/manager.spec.ts b/packages/docmanager/test/manager.spec.ts | |
| index a523dcd69d..c6500520eb 100644 | |
| --- a/packages/docmanager/test/manager.spec.ts | |
| +++ b/packages/docmanager/test/manager.spec.ts | |
| @@ -16,9 +16,7 @@ import { Widget } from '@lumino/widgets'; | |
| import { DocumentManager } from '../src'; | |
| class WidgetFactory extends ABCWidgetFactory<IDocumentWidget> { | |
| - protected createNewWidget( | |
| - context: DocumentRegistry.Context | |
| - ): IDocumentWidget { | |
| + protected createNewWidget(context: DocumentRegistry.Context): IDocumentWidget { | |
| const content = new Widget(); | |
| const widget = new DocumentWidget({ content, context }); | |
| widget.addClass('WidgetFactory'); | |
| @@ -344,9 +342,7 @@ describe('@jupyterlab/docmanager', () => { | |
| }); | |
| widget = manager.createNew(model.path)!; | |
| const clone = manager.cloneWidget(widget)!; | |
| - expect(manager.contextForWidget(widget)).toBe( | |
| - manager.contextForWidget(clone) | |
| - ); | |
| + expect(manager.contextForWidget(widget)).toBe(manager.contextForWidget(clone)); | |
| await dismissDialog(); | |
| }); | |
| @@ -366,9 +362,7 @@ describe('@jupyterlab/docmanager', () => { | |
| 'CloneTestWidget' | |
| ) as CloneTestWidget; | |
| expect(newWidget.counter).toBe(0); | |
| - expect( | |
| - (manager.cloneWidget(clonedWidget) as CloneTestWidget).counter | |
| - ).toBe(2); | |
| + expect((manager.cloneWidget(clonedWidget) as CloneTestWidget).counter).toBe(2); | |
| }); | |
| }); | |
| diff --git a/packages/docmanager/test/recents.spec.ts b/packages/docmanager/test/recents.spec.ts | |
| index cbb0850d31..0ae6ae2d3e 100644 | |
| --- a/packages/docmanager/test/recents.spec.ts | |
| +++ b/packages/docmanager/test/recents.spec.ts | |
| @@ -72,10 +72,7 @@ describe('@jupyterlab/docmanager', () => { | |
| describe('#addRecent()', () => { | |
| it('should add a document to recently opened list', () => { | |
| expect(manager.recentlyOpened.length).toBe(0); | |
| - manager.addRecent( | |
| - { path: 'test.py', contentType: 'text/x-python' }, | |
| - 'opened' | |
| - ); | |
| + manager.addRecent({ path: 'test.py', contentType: 'text/x-python' }, 'opened'); | |
| expect(manager.recentlyOpened.length).toBe(1); | |
| expect(manager.recentlyClosed.length).toBe(0); | |
| expect(manager.recentlyOpened[0].path).toBe('test.py'); | |
| @@ -85,10 +82,7 @@ describe('@jupyterlab/docmanager', () => { | |
| it('should add a document to recently closed list', () => { | |
| expect(manager.recentlyClosed.length).toBe(0); | |
| - manager.addRecent( | |
| - { path: 'test.py', contentType: 'text/x-python' }, | |
| - 'closed' | |
| - ); | |
| + manager.addRecent({ path: 'test.py', contentType: 'text/x-python' }, 'closed'); | |
| expect(manager.recentlyClosed.length).toBe(1); | |
| expect(manager.recentlyOpened.length).toBe(0); | |
| expect(manager.recentlyClosed[0].path).toBe('test.py'); | |
| @@ -98,9 +92,7 @@ describe('@jupyterlab/docmanager', () => { | |
| it('should auto-populate root dir', () => { | |
| manager.addRecent({ path: 'test', contentType: 'directory' }, 'opened'); | |
| - expect(manager.recentlyOpened[0].root).toBe( | |
| - PageConfig.getOption('serverRoot') | |
| - ); | |
| + expect(manager.recentlyOpened[0].root).toBe(PageConfig.getOption('serverRoot')); | |
| }); | |
| }); | |
| diff --git a/packages/docmanager/test/savehandler.spec.ts b/packages/docmanager/test/savehandler.spec.ts | |
| index 8492f39f34..eda3a572ce 100644 | |
| --- a/packages/docmanager/test/savehandler.spec.ts | |
| +++ b/packages/docmanager/test/savehandler.spec.ts | |
| @@ -132,14 +132,10 @@ describe('docregistry/savehandler', () => { | |
| jest.advanceTimersByTime(120000); // in ms | |
| await signalToPromise(context.fileChanged); | |
| - jest | |
| - .spyOn(handler as any, '_isConnectedCallback') | |
| - .mockReturnValue(false); | |
| + jest.spyOn(handler as any, '_isConnectedCallback').mockReturnValue(false); | |
| context.model.fromString('bar'); | |
| jest.advanceTimersByTime(240000); | |
| - jest | |
| - .spyOn(handler as any, '_isConnectedCallback') | |
| - .mockReturnValue(true); | |
| + jest.spyOn(handler as any, '_isConnectedCallback').mockReturnValue(true); | |
| jest.advanceTimersByTime(120000); | |
| jest.useRealTimers(); | |
| diff --git a/packages/docmanager/test/widgetmanager.spec.ts b/packages/docmanager/test/widgetmanager.spec.ts | |
| index 1cc1dcc442..075e2e27bd 100644 | |
| --- a/packages/docmanager/test/widgetmanager.spec.ts | |
| +++ b/packages/docmanager/test/widgetmanager.spec.ts | |
| @@ -19,9 +19,7 @@ import { Widget } from '@lumino/widgets'; | |
| import { DocumentWidgetManager } from '../src'; | |
| class WidgetFactory extends ABCWidgetFactory<IDocumentWidget> { | |
| - protected createNewWidget( | |
| - context: DocumentRegistry.Context | |
| - ): IDocumentWidget { | |
| + protected createNewWidget(context: DocumentRegistry.Context): IDocumentWidget { | |
| const content = new Widget(); | |
| const widget = new DocumentWidget({ content, context }); | |
| widget.addClass('WidgetFactory'); | |
| @@ -133,9 +131,7 @@ describe('@jupyterlab/docmanager', () => { | |
| manager.adoptWidget(context, widget); | |
| MessageLoop.sendMessage(widget, new Message('foo')); | |
| - expect(manager.methods).toEqual( | |
| - expect.arrayContaining(['messageHook']) | |
| - ); | |
| + expect(manager.methods).toEqual(expect.arrayContaining(['messageHook'])); | |
| }); | |
| it('should add the document class', () => { | |
| @@ -212,9 +208,7 @@ describe('@jupyterlab/docmanager', () => { | |
| manager.adoptWidget(context, widget); | |
| MessageLoop.sendMessage(widget, new Message('foo')); | |
| - expect(manager.methods).toEqual( | |
| - expect.arrayContaining(['messageHook']) | |
| - ); | |
| + expect(manager.methods).toEqual(expect.arrayContaining(['messageHook'])); | |
| }); | |
| it('should return false for close-request messages', () => { | |
| @@ -240,9 +234,7 @@ describe('@jupyterlab/docmanager', () => { | |
| const delegate = new PromiseDelegate(); | |
| widget.title.changed.connect(async () => { | |
| - expect(manager.methods).toEqual( | |
| - expect.arrayContaining(['setCaption']) | |
| - ); | |
| + expect(manager.methods).toEqual(expect.arrayContaining(['setCaption'])); | |
| expect(widget.title.caption).toContain('Last Checkpoint'); | |
| await dismissDialog(); | |
| delegate.resolve(undefined); | |
| diff --git a/packages/docregistry/src/context.ts b/packages/docregistry/src/context.ts | |
| index 7a4a9dc6f4..d4b04d23c4 100644 | |
| --- a/packages/docregistry/src/context.ts | |
| +++ b/packages/docregistry/src/context.ts | |
| @@ -13,11 +13,7 @@ import { PathExt } from '@jupyterlab/coreutils'; | |
| import type { IUrlResolverFactory } from '@jupyterlab/rendermime'; | |
| import { RenderMimeRegistry } from '@jupyterlab/rendermime'; | |
| import type { IRenderMime } from '@jupyterlab/rendermime-interfaces'; | |
| -import type { | |
| - Contents, | |
| - ServerConnection, | |
| - ServiceManager | |
| -} from '@jupyterlab/services'; | |
| +import type { Contents, ServerConnection, ServiceManager } from '@jupyterlab/services'; | |
| import type { ITranslator, TranslationBundle } from '@jupyterlab/translation'; | |
| import { nullTranslator } from '@jupyterlab/translation'; | |
| @@ -57,10 +53,9 @@ export class Context< | |
| const localPath = this._manager.contents.localPath(this._path); | |
| const lang = this._factory.preferredLanguage(PathExt.basename(localPath)); | |
| - const sharedFactory = this._manager.contents.getSharedModelFactory( | |
| - this._path, | |
| - { contentProviderId: options.contentProviderId } | |
| - ); | |
| + const sharedFactory = this._manager.contents.getSharedModelFactory(this._path, { | |
| + contentProviderId: options.contentProviderId | |
| + }); | |
| const sharedModel = sharedFactory?.createNew({ | |
| path: this._path, | |
| format: this._factory.fileFormat, | |
| @@ -95,9 +90,8 @@ export class Context< | |
| const urlResolverFactory = options.urlResolverFactory | |
| ? options.urlResolverFactory | |
| : { | |
| - createResolver: ( | |
| - resolverOptions: RenderMimeRegistry.IUrlResolverOptions | |
| - ) => new RenderMimeRegistry.UrlResolver(resolverOptions) | |
| + createResolver: (resolverOptions: RenderMimeRegistry.IUrlResolverOptions) => | |
| + new RenderMimeRegistry.UrlResolver(resolverOptions) | |
| }; | |
| this._urlResolver = urlResolverFactory.createResolver({ | |
| @@ -421,10 +415,7 @@ export class Context< | |
| * It is assumed that the widget has the same model and context | |
| * as the original widget. | |
| */ | |
| - addSibling( | |
| - widget: Widget, | |
| - options: DocumentRegistry.IOpenOptions = {} | |
| - ): IDisposable { | |
| + addSibling(widget: Widget, options: DocumentRegistry.IOpenOptions = {}): IDisposable { | |
| const opener = this._opener; | |
| if (opener) { | |
| opener(widget, options); | |
| @@ -497,9 +488,7 @@ export class Context< | |
| // The session uses local paths. | |
| // We need to convert it to a global path. | |
| const driveName = this._manager.contents.driveName(this.path); | |
| - let newPath = this._manager.contents.localPath( | |
| - this.sessionContext.session!.path | |
| - ); | |
| + let newPath = this._manager.contents.localPath(this.sessionContext.session!.path); | |
| if (driveName) { | |
| newPath = `${driveName}:${newPath}`; | |
| } | |
| @@ -558,8 +547,7 @@ export class Context< | |
| } | |
| if ( | |
| this._contentsModel && | |
| - (this._contentsModel.path !== newPath || | |
| - this._contentsModel.name !== name) | |
| + (this._contentsModel.path !== newPath || this._contentsModel.name !== name) | |
| ) { | |
| const contentsModel = { | |
| ...this._contentsModel, | |
| @@ -586,8 +574,7 @@ export class Context< | |
| } | |
| // Update the kernel preference. | |
| const name = | |
| - this._model.defaultKernelName || | |
| - this.sessionContext.kernelPreference.name; | |
| + this._model.defaultKernelName || this.sessionContext.kernelPreference.name; | |
| this.sessionContext.kernelPreference = { | |
| ...this.sessionContext.kernelPreference, | |
| name, | |
| @@ -656,10 +643,7 @@ export class Context< | |
| // Otherwise show an error message and throw the error. | |
| const localPath = this._manager.contents.localPath(this._path); | |
| const file = PathExt.basename(localPath); | |
| - void this._handleError( | |
| - err, | |
| - this._trans.__('File Save Error for %1', file) | |
| - ); | |
| + void this._handleError(err, this._trans.__('File Save Error for %1', file)); | |
| // Emit failure. | |
| this._saveState.emit('failed'); | |
| @@ -722,10 +706,7 @@ export class Context< | |
| .catch(async err => { | |
| const localPath = this._manager.contents.localPath(this._path); | |
| const name = PathExt.basename(localPath); | |
| - void this._handleError( | |
| - err, | |
| - this._trans.__('File Load Error for %1', name) | |
| - ); | |
| + void this._handleError(err, this._trans.__('File Load Error for %1', name)); | |
| throw err; | |
| }); | |
| } | |
| @@ -733,9 +714,7 @@ export class Context< | |
| /** | |
| * Save a file, dealing with conflicts. | |
| */ | |
| - private _maybeSave( | |
| - options: Partial<Contents.IModel> | |
| - ): Promise<Contents.IModel> { | |
| + private _maybeSave(options: Partial<Contents.IModel>): Promise<Contents.IModel> { | |
| const path = this._path; | |
| // Make sure the file has not changed on disk. | |
| const promise = this._manager.contents.get(path, { | |
| @@ -957,20 +936,14 @@ or load the version on disk (revert)?`, | |
| // If the save has been canceled by the user, | |
| // throw the error so that whoever called save() | |
| // can decide what to do. | |
| - if ( | |
| - err.message === 'Cancel' || | |
| - err.message === 'Modal is already displayed' | |
| - ) { | |
| + if (err.message === 'Cancel' || err.message === 'Modal is already displayed') { | |
| throw err; | |
| } | |
| // Otherwise show an error message and throw the error. | |
| const localPath = this._manager.contents.localPath(this._path); | |
| const name = PathExt.basename(localPath); | |
| - void this._handleError( | |
| - err, | |
| - this._trans.__('File Save Error for %1', name) | |
| - ); | |
| + void this._handleError(err, this._trans.__('File Save Error for %1', name)); | |
| // Emit failure. | |
| this._saveState.emit('failed'); | |
| @@ -1004,10 +977,7 @@ or load the version on disk (revert)?`, | |
| private _trans: TranslationBundle; | |
| private _contentProviderId?: string; | |
| private _manager: ServiceManager.IManager; | |
| - private _opener: ( | |
| - widget: Widget, | |
| - options?: DocumentRegistry.IOpenOptions | |
| - ) => void; | |
| + private _opener: (widget: Widget, options?: DocumentRegistry.IOpenOptions) => void; | |
| private _model: T; | |
| private _path = ''; | |
| @@ -1018,9 +988,7 @@ or load the version on disk (revert)?`, | |
| private _readyPromise: Promise<void>; | |
| private _populatedPromise = new PromiseDelegate<void>(); | |
| private _pathChanged = new Signal<this, string>(this); | |
| - private _fileChanged = new Signal<this, Omit<Contents.IModel, 'content'>>( | |
| - this | |
| - ); | |
| + private _fileChanged = new Signal<this, Omit<Contents.IModel, 'content'>>(this); | |
| private _saveState = new Signal<this, DocumentRegistry.SaveState>(this); | |
| private _urlResolver: RenderMimeRegistry.IUrlResolver; | |
| private _disposed = new Signal<this, void>(this); | |
| diff --git a/packages/docregistry/src/default.ts b/packages/docregistry/src/default.ts | |
| index ee53d7f011..f2134dc529 100644 | |
| --- a/packages/docregistry/src/default.ts | |
| +++ b/packages/docregistry/src/default.ts | |
| @@ -479,10 +479,7 @@ export abstract class ABCWidgetFactory< | |
| const widget = this.createNewWidget(context, source); | |
| // Add toolbar | |
| - setToolbar( | |
| - widget, | |
| - this._toolbarFactory ?? this.defaultToolbarFactory.bind(this) | |
| - ); | |
| + setToolbar(widget, this._toolbarFactory ?? this.defaultToolbarFactory.bind(this)); | |
| // Emit widget created signal | |
| this._widgetCreated.emit(widget); | |
| @@ -545,9 +542,7 @@ export abstract class ABCWidgetFactory< | |
| private _fileTypes: string[]; | |
| private _defaultFor: string[]; | |
| private _defaultRendered: string[]; | |
| - private _widgetCreated = new Signal<DocumentRegistry.IWidgetFactory<T, U>, T>( | |
| - this | |
| - ); | |
| + private _widgetCreated = new Signal<DocumentRegistry.IWidgetFactory<T, U>, T>(this); | |
| } | |
| /** | |
| @@ -600,8 +595,7 @@ export class DocumentWidget< | |
| const validNameExp = /[\/\\:]/; | |
| const name = this.title.label; | |
| // Use localPath to avoid the drive name | |
| - const filename = | |
| - this.context.localPath.split('/').pop() || this.context.localPath; | |
| + const filename = this.context.localPath.split('/').pop() || this.context.localPath; | |
| if (name === filename) { | |
| return; | |
| @@ -621,10 +615,7 @@ export class DocumentWidget< | |
| /** | |
| * Handle a path change. | |
| */ | |
| - private _onPathChanged( | |
| - sender: DocumentRegistry.IContext<U>, | |
| - path: string | |
| - ): void { | |
| + private _onPathChanged(sender: DocumentRegistry.IContext<U>, path: string): void { | |
| const newName = PathExt.basename(sender.localPath); | |
| if (newName !== this.title.label) { | |
| this.isUntitled = false; | |
| @@ -661,10 +652,7 @@ export class DocumentWidget< | |
| * Handle the dirty state of the context model. | |
| */ | |
| private _handleDirtyState(): void { | |
| - if ( | |
| - this.context.model.dirty && | |
| - !this.title.className.includes(DIRTY_CLASS) | |
| - ) { | |
| + if (this.context.model.dirty && !this.title.className.includes(DIRTY_CLASS)) { | |
| this.title.className += ` ${DIRTY_CLASS}`; | |
| } else { | |
| this.title.className = this.title.className.replace(DIRTY_CLASS, ''); | |
| diff --git a/packages/docregistry/src/mimedocument.ts b/packages/docregistry/src/mimedocument.ts | |
| index 366b4592f3..7584bf6c9a 100644 | |
| --- a/packages/docregistry/src/mimedocument.ts | |
| +++ b/packages/docregistry/src/mimedocument.ts | |
| @@ -177,9 +177,7 @@ export class MimeContent extends Widget { | |
| /** | |
| * A bound change callback. | |
| */ | |
| - private _changeCallback = ( | |
| - options: IRenderMime.IMimeModel.ISetDataOptions | |
| - ) => { | |
| + private _changeCallback = (options: IRenderMime.IMimeModel.ISetDataOptions) => { | |
| if (!options.data || !options.data[this.mimeType]) { | |
| return; | |
| } | |
| diff --git a/packages/docregistry/src/registry.ts b/packages/docregistry/src/registry.ts | |
| index 661875deff..d771445273 100644 | |
| --- a/packages/docregistry/src/registry.ts | |
| +++ b/packages/docregistry/src/registry.ts | |
| @@ -29,10 +29,7 @@ import { | |
| yamlIcon | |
| } from '@jupyterlab/ui-components'; | |
| import { ArrayExt, find } from '@lumino/algorithm'; | |
| -import type { | |
| - PartialJSONValue, | |
| - ReadonlyPartialJSONValue | |
| -} from '@lumino/coreutils'; | |
| +import type { PartialJSONValue, ReadonlyPartialJSONValue } from '@lumino/coreutils'; | |
| import type { IDisposable } from '@lumino/disposable'; | |
| import { DisposableDelegate } from '@lumino/disposable'; | |
| import type { ISignal } from '@lumino/signaling'; | |
| @@ -57,8 +54,7 @@ export class DocumentRegistry implements IDisposable { | |
| this._modelFactories['text'] = factory || new TextModelFactory(true); | |
| const fts = | |
| - options.initialFileTypes || | |
| - DocumentRegistry.getDefaultFileTypes(this.translator); | |
| + options.initialFileTypes || DocumentRegistry.getDefaultFileTypes(this.translator); | |
| fts.forEach(ft => { | |
| const value: DocumentRegistry.IFileType = { | |
| ...DocumentRegistry.getFileTypeDefaults(this.translator), | |
| @@ -305,9 +301,7 @@ export class DocumentRegistry implements IDisposable { | |
| if (!this._widgetFactoriesForFileType[fileTypeName]) { | |
| this._widgetFactoriesForFileType[fileTypeName] = []; | |
| } | |
| - if ( | |
| - !this._widgetFactoriesForFileType[fileTypeName].includes(factory) | |
| - ) { | |
| + if (!this._widgetFactoriesForFileType[fileTypeName].includes(factory)) { | |
| this._widgetFactoriesForFileType[fileTypeName].push(factory); | |
| } | |
| }); | |
| @@ -327,15 +321,9 @@ export class DocumentRegistry implements IDisposable { | |
| if (factories) { | |
| const fileTypeName = value.name.toLowerCase(); | |
| for (const name of factories.map(factory => factory.toLowerCase())) { | |
| - ArrayExt.removeFirstOf( | |
| - this._widgetFactoriesForFileType[fileTypeName], | |
| - name | |
| - ); | |
| + ArrayExt.removeFirstOf(this._widgetFactoriesForFileType[fileTypeName], name); | |
| } | |
| - if ( | |
| - this._defaultWidgetFactories[fileTypeName] === | |
| - factories[0].toLowerCase() | |
| - ) { | |
| + if (this._defaultWidgetFactories[fileTypeName] === factories[0].toLowerCase()) { | |
| delete this._defaultWidgetFactories[fileTypeName]; | |
| } | |
| } | |
| @@ -447,9 +435,7 @@ export class DocumentRegistry implements IDisposable { | |
| */ | |
| defaultRenderedWidgetFactory(path: string): DocumentRegistry.WidgetFactory { | |
| // Get the matching file types. | |
| - const ftNames = this.getFileTypesForPath(PathExt.basename(path)).map( | |
| - ft => ft.name | |
| - ); | |
| + const ftNames = this.getFileTypesForPath(PathExt.basename(path)).map(ft => ft.name); | |
| // Start with any user overrides for the defaults. | |
| for (const name in ftNames) { | |
| @@ -461,9 +447,7 @@ export class DocumentRegistry implements IDisposable { | |
| // Find if a there is a default rendered factory for this type. | |
| for (const name in ftNames) { | |
| if (name in this._defaultRenderedWidgetFactories) { | |
| - return this._widgetFactories[ | |
| - this._defaultRenderedWidgetFactories[name] | |
| - ]; | |
| + return this._widgetFactories[this._defaultRenderedWidgetFactories[name]]; | |
| } | |
| } | |
| @@ -591,9 +575,7 @@ export class DocumentRegistry implements IDisposable { | |
| * | |
| * @returns A widget factory instance. | |
| */ | |
| - getWidgetFactory( | |
| - widgetName: string | |
| - ): DocumentRegistry.WidgetFactory | undefined { | |
| + getWidgetFactory(widgetName: string): DocumentRegistry.WidgetFactory | undefined { | |
| return this._widgetFactories[widgetName.toLowerCase()]; | |
| } | |
| @@ -639,9 +621,7 @@ export class DocumentRegistry implements IDisposable { | |
| if (!widgetFactory) { | |
| return void 0; | |
| } | |
| - const modelFactory = this.getModelFactory( | |
| - widgetFactory.modelName || 'text' | |
| - ); | |
| + const modelFactory = this.getModelFactory(widgetFactory.modelName || 'text'); | |
| if (!modelFactory) { | |
| return void 0; | |
| } | |
| @@ -666,9 +646,7 @@ export class DocumentRegistry implements IDisposable { | |
| * | |
| * @returns The best matching file type. | |
| */ | |
| - getFileTypeForModel( | |
| - model: Partial<Contents.IModel> | |
| - ): DocumentRegistry.IFileType { | |
| + getFileTypeForModel(model: Partial<Contents.IModel>): DocumentRegistry.IFileType { | |
| let ft: DocumentRegistry.IFileType | null = null; | |
| if (model.name || model.path) { | |
| const name = model.name || PathExt.basename(model.path!); | |
| @@ -749,8 +727,7 @@ export class DocumentRegistry implements IDisposable { | |
| private _defaultWidgetFactoryOverrides: { | |
| [key: string]: string; | |
| } = Object.create(null); | |
| - private _defaultWidgetFactories: { [key: string]: string } = | |
| - Object.create(null); | |
| + private _defaultWidgetFactories: { [key: string]: string } = Object.create(null); | |
| private _defaultRenderedWidgetFactories: { | |
| [key: string]: string; | |
| } = Object.create(null); | |
| @@ -1053,9 +1030,7 @@ export namespace DocumentRegistry { | |
| /** | |
| * The options used to initialize a widget factory. | |
| */ | |
| - export interface IWidgetFactoryOptions< | |
| - T extends Widget = Widget | |
| - > extends Omit< | |
| + export interface IWidgetFactoryOptions<T extends Widget = Widget> extends Omit< | |
| IRenderMime.IDocumentWidgetFactoryOptions, | |
| 'primaryFileType' | 'toolbarFactory' | |
| > { | |
| @@ -1286,11 +1261,7 @@ export namespace DocumentRegistry { | |
| /** | |
| * The type of the changed item. | |
| */ | |
| - readonly type: | |
| - | 'widgetFactory' | |
| - | 'modelFactory' | |
| - | 'widgetExtension' | |
| - | 'fileType'; | |
| + readonly type: 'widgetFactory' | 'modelFactory' | 'widgetExtension' | 'fileType'; | |
| /** | |
| * The name of the item or the widget factory being extended. | |
| @@ -1353,9 +1324,7 @@ export namespace DocumentRegistry { | |
| * | |
| * @returns The default notebook file type. | |
| */ | |
| - export function getDefaultNotebookFileType( | |
| - translator?: ITranslator | |
| - ): IFileType { | |
| + export function getDefaultNotebookFileType(translator?: ITranslator): IFileType { | |
| translator = translator || nullTranslator; | |
| const trans = translator?.load('jupyterlab'); | |
| @@ -1378,9 +1347,7 @@ export namespace DocumentRegistry { | |
| * | |
| * @returns The default directory file type. | |
| */ | |
| - export function getDefaultDirectoryFileType( | |
| - translator?: ITranslator | |
| - ): IFileType { | |
| + export function getDefaultDirectoryFileType(translator?: ITranslator): IFileType { | |
| translator = translator || nullTranslator; | |
| const trans = translator?.load('jupyterlab'); | |
| @@ -1444,11 +1411,7 @@ export namespace DocumentRegistry { | |
| name: 'jsonl', | |
| displayName: trans.__('JSONLines File'), | |
| extensions: ['.jsonl', '.ndjson'], | |
| - mimeTypes: [ | |
| - 'text/jsonl', | |
| - 'application/jsonl', | |
| - 'application/json-lines' | |
| - ], | |
| + mimeTypes: ['text/jsonl', 'application/jsonl', 'application/json-lines'], | |
| icon: jsonIcon | |
| }, | |
| { | |
| diff --git a/packages/docregistry/src/testutils.ts b/packages/docregistry/src/testutils.ts | |
| index 151cd301be..3c790bed50 100644 | |
| --- a/packages/docregistry/src/testutils.ts | |
| +++ b/packages/docregistry/src/testutils.ts | |
| @@ -174,33 +174,26 @@ export const SessionContextMock = jest.fn< | |
| initialize: jest.fn(() => Promise.resolve(false)), | |
| ready: Promise.resolve(), | |
| changeKernel: jest.fn(partialModel => { | |
| - return changeKernel( | |
| - session.kernel || Private.RUNNING_KERNELS[0], | |
| - partialModel! | |
| - ); | |
| + return changeKernel(session.kernel || Private.RUNNING_KERNELS[0], partialModel!); | |
| }), | |
| shutdown: jest.fn(() => Promise.resolve()) | |
| }; | |
| const disposedSignal = new Signal<ISessionContext, undefined>(thisObject); | |
| - const propertyChangedSignal = new Signal< | |
| - ISessionContext, | |
| - 'path' | 'name' | 'type' | |
| - >(thisObject); | |
| - | |
| - const statusChangedSignal = new Signal<ISessionContext, Kernel.Status>( | |
| + const propertyChangedSignal = new Signal<ISessionContext, 'path' | 'name' | 'type'>( | |
| thisObject | |
| ); | |
| + | |
| + const statusChangedSignal = new Signal<ISessionContext, Kernel.Status>(thisObject); | |
| const kernelChangedSignal = new Signal< | |
| ISessionContext, | |
| Session.ISessionConnection.IKernelChangedArgs | |
| >(thisObject); | |
| - const iopubMessageSignal = new Signal< | |
| - ISessionContext, | |
| - KernelMessage.IIOPubMessage | |
| - >(thisObject); | |
| + const iopubMessageSignal = new Signal<ISessionContext, KernelMessage.IIOPubMessage>( | |
| + thisObject | |
| + ); | |
| session!.statusChanged.connect((_, args) => { | |
| statusChangedSignal.emit(args); | |
| diff --git a/packages/docregistry/test/context.spec.ts b/packages/docregistry/test/context.spec.ts | |
| index 31234c4efd..5ad0bc0813 100644 | |
| --- a/packages/docregistry/test/context.spec.ts | |
| +++ b/packages/docregistry/test/context.spec.ts | |
| @@ -257,9 +257,7 @@ describe('docregistry/context', () => { | |
| called += 1; | |
| }); | |
| - await expect(context.initialize(true)).rejects.toThrow( | |
| - /Invalid response: 403/ | |
| - ); | |
| + await expect(context.initialize(true)).rejects.toThrow(/Invalid response: 403/); | |
| expect(called).toBe(2); | |
| expect(checked).toBe('failed'); | |
| @@ -685,9 +683,7 @@ describe('docregistry/context', () => { | |
| // no-op | |
| } | |
| it('should be a url resolver', () => { | |
| - expect(context.urlResolver).toBeInstanceOf( | |
| - RenderMimeRegistry.UrlResolver | |
| - ); | |
| + expect(context.urlResolver).toBeInstanceOf(RenderMimeRegistry.UrlResolver); | |
| expect(context.urlResolver).not.toBeInstanceOf(TestResolver); | |
| }); | |
| it('should use preferred url resolver', () => { | |
| diff --git a/packages/docregistry/test/default.spec.ts b/packages/docregistry/test/default.spec.ts | |
| index 7a6376da8c..aec7ce3766 100644 | |
| --- a/packages/docregistry/test/default.spec.ts | |
| +++ b/packages/docregistry/test/default.spec.ts | |
| @@ -1,10 +1,7 @@ | |
| // Copyright (c) Jupyter Development Team. | |
| // Distributed under the terms of the Modified BSD License. | |
| -import type { | |
| - DocumentRegistry, | |
| - IDocumentWidget | |
| -} from '@jupyterlab/docregistry'; | |
| +import type { DocumentRegistry, IDocumentWidget } from '@jupyterlab/docregistry'; | |
| import { | |
| ABCWidgetFactory, | |
| Base64ModelFactory, | |
| @@ -21,9 +18,7 @@ import { UUID } from '@lumino/coreutils'; | |
| import { Widget } from '@lumino/widgets'; | |
| class WidgetFactory extends ABCWidgetFactory<IDocumentWidget> { | |
| - protected createNewWidget( | |
| - context: DocumentRegistry.Context | |
| - ): IDocumentWidget { | |
| + protected createNewWidget(context: DocumentRegistry.Context): IDocumentWidget { | |
| const content = new Widget(); | |
| const widget = new DocumentWidget({ content, context }); | |
| widget.addClass('WidgetFactory'); | |
| @@ -264,10 +259,7 @@ describe('docregistry/default', () => { | |
| const factory = createFactory(); | |
| const context = await createFileContextWithMockedServices(); | |
| const widget = factory.createNew(context); | |
| - const clonedWidget: IDocumentWidget = factory.createNew( | |
| - context, | |
| - widget | |
| - ); | |
| + const clonedWidget: IDocumentWidget = factory.createNew(context, widget); | |
| expect(clonedWidget).not.toBe(widget); | |
| expect(clonedWidget.hasClass('WidgetFactory')).toBe(true); | |
| expect(clonedWidget.context).toBe(widget.context); | |
| @@ -577,10 +569,7 @@ describe('docregistry/default', () => { | |
| let widget: DocumentWidget; | |
| const setup = async () => { | |
| - context = (await createFileContextWithMockedServices( | |
| - false, | |
| - manager | |
| - )) as any; | |
| + context = (await createFileContextWithMockedServices(false, manager)) as any; | |
| content = new Widget(); | |
| widget = new DocumentWidget({ context, content }); | |
| }; | |
| diff --git a/packages/docregistry/test/registry.spec.ts b/packages/docregistry/test/registry.spec.ts | |
| index 76b551fefd..7ebf7e2d8c 100644 | |
| --- a/packages/docregistry/test/registry.spec.ts | |
| +++ b/packages/docregistry/test/registry.spec.ts | |
| @@ -14,9 +14,7 @@ import { DisposableDelegate } from '@lumino/disposable'; | |
| import { Widget } from '@lumino/widgets'; | |
| class WidgetFactory extends ABCWidgetFactory<IDocumentWidget> { | |
| - protected createNewWidget( | |
| - context: DocumentRegistry.Context | |
| - ): IDocumentWidget { | |
| + protected createNewWidget(context: DocumentRegistry.Context): IDocumentWidget { | |
| const content = new Widget(); | |
| const widget = new DocumentWidget({ content, context }); | |
| widget.addClass('WidgetFactory'); | |
| @@ -87,9 +85,7 @@ describe('docregistry/registry', () => { | |
| const factory = createFactory(); | |
| registry.addWidgetFactory(factory); | |
| expect(registry.getWidgetFactory(factory.name)).toBe(factory); | |
| - expect(registry.getWidgetFactory(factory.name.toUpperCase())).toBe( | |
| - factory | |
| - ); | |
| + expect(registry.getWidgetFactory(factory.name.toUpperCase())).toBe(factory); | |
| }); | |
| it('should become the global default if `*` is given as a defaultFor', () => { | |
| @@ -250,15 +246,11 @@ describe('docregistry/registry', () => { | |
| }); | |
| registry.addWidgetFactory(gFactory); | |
| - expect(registry.defaultWidgetFactory('dummy.test').name).toEqual( | |
| - gFactory.name | |
| - ); | |
| + expect(registry.defaultWidgetFactory('dummy.test').name).toEqual(gFactory.name); | |
| const fileType = { name: 'test-file', extensions: ['.test'] }; | |
| registry.addFileType(fileType, [factory.name]); | |
| - expect(registry.defaultWidgetFactory('dummy.test').name).toEqual( | |
| - factory.name | |
| - ); | |
| + expect(registry.defaultWidgetFactory('dummy.test').name).toEqual(factory.name); | |
| }); | |
| it('should add a file type to some factories without changing the default', () => { | |
| @@ -308,9 +300,7 @@ describe('docregistry/registry', () => { | |
| disposable.dispose(); | |
| - expect(registry.defaultWidgetFactory('dummy.test').name).toBe( | |
| - gFactory.name | |
| - ); | |
| + expect(registry.defaultWidgetFactory('dummy.test').name).toBe(gFactory.name); | |
| }); | |
| it('should remove the link to factory when disposed without changing the default', () => { | |
| @@ -352,9 +342,7 @@ describe('docregistry/registry', () => { | |
| }); | |
| it('should give the valid registered widget factories', () => { | |
| - expect( | |
| - Array.from(registry.preferredWidgetFactories('foo.txt')) | |
| - ).toEqual([]); | |
| + expect(Array.from(registry.preferredWidgetFactories('foo.txt'))).toEqual([]); | |
| const factory = createFactory(); | |
| registry.addWidgetFactory(factory); | |
| const gFactory = new WidgetFactory({ | |
| @@ -369,9 +357,7 @@ describe('docregistry/registry', () => { | |
| it('should not list a factory whose model is not registered', () => { | |
| registry.addWidgetFactory(createFactory('foobar')); | |
| - expect(registry.preferredWidgetFactories('a.foo.bar').length).toEqual( | |
| - 0 | |
| - ); | |
| + expect(registry.preferredWidgetFactories('a.foo.bar').length).toEqual(0); | |
| }); | |
| it('should select the factory for a given extension', () => { | |
| @@ -498,9 +484,7 @@ describe('docregistry/registry', () => { | |
| }); | |
| registry.addWidgetFactory(mdFactory); | |
| registry.setDefaultWidgetFactory('foobar', 'markdown'); | |
| - expect(registry.defaultRenderedWidgetFactory('a.foo.bar')).toBe( | |
| - mdFactory | |
| - ); | |
| + expect(registry.defaultRenderedWidgetFactory('a.foo.bar')).toBe(mdFactory); | |
| }); | |
| it('should revert to the default widget factory when unset', () => { | |
| diff --git a/packages/documentsearch-extension/src/index.ts b/packages/documentsearch-extension/src/index.ts | |
| index 150939bd02..f79dc5aa80 100644 | |
| --- a/packages/documentsearch-extension/src/index.ts | |
| +++ b/packages/documentsearch-extension/src/index.ts | |
| @@ -5,10 +5,7 @@ | |
| * @module documentsearch-extension | |
| */ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { ILabShell } from '@jupyterlab/application'; | |
| import { ICommandPalette, MainAreaWidget } from '@jupyterlab/apputils'; | |
| import type { ISearchKeyBindings } from '@jupyterlab/documentsearch'; | |
| @@ -56,8 +53,7 @@ namespace CommandIDs { | |
| /** | |
| * Toggle search in selection | |
| */ | |
| - export const toggleSearchInSelection = | |
| - 'documentsearch:toggleSearchInSelection'; | |
| + export const toggleSearchInSelection = 'documentsearch:toggleSearchInSelection'; | |
| } | |
| /** | |
| @@ -95,9 +91,7 @@ const labShellWidgetListener: JupyterFrontEndPlugin<void> = { | |
| // Update searchability of the active widget when the registry | |
| // changes, in case a provider for the current widget was added | |
| // or removed | |
| - registry.changed.connect(() => | |
| - transformWidgetSearchability(labShell.activeWidget) | |
| - ); | |
| + registry.changed.connect(() => transformWidgetSearchability(labShell.activeWidget)); | |
| // Apply the searchable class only to the active widget if it is actually | |
| // searchable. Remove the searchable class from a widget when it's | |
| @@ -160,10 +154,7 @@ class SearchKeyBindings implements ISearchKeyBindings { | |
| } | |
| dispose() { | |
| - this._commandRegistry.keyBindingChanged.disconnect( | |
| - this._rebuildCache, | |
| - this | |
| - ); | |
| + this._commandRegistry.keyBindingChanged.disconnect(this._rebuildCache, this); | |
| } | |
| private _cache: KeyBindingsCache; | |
| @@ -191,17 +182,14 @@ const extension: JupyterFrontEndPlugin<ISearchProviderRegistry> = { | |
| let autoSearchInSelection: AutoSearchInSelection = 'never'; | |
| // Create registry | |
| - const registry: SearchProviderRegistry = new SearchProviderRegistry( | |
| - translator | |
| - ); | |
| + const registry: SearchProviderRegistry = new SearchProviderRegistry(translator); | |
| const searchViews = new Map<string, SearchDocumentView>(); | |
| if (settingRegistry) { | |
| const loadSettings = settingRegistry.load(extension.id); | |
| const updateSettings = (settings: ISettingRegistry.ISettings): void => { | |
| - searchDebounceTime = settings.get('searchDebounceTime') | |
| - .composite as number; | |
| + searchDebounceTime = settings.get('searchDebounceTime').composite as number; | |
| autoSearchInSelection = settings.get('autoSearchInSelection') | |
| .composite as AutoSearchInSelection; | |
| }; | |
| @@ -237,10 +225,7 @@ const extension: JupyterFrontEndPlugin<ISearchProviderRegistry> = { | |
| if (!searchProvider) { | |
| return; | |
| } | |
| - const searchModel = new SearchDocumentModel( | |
| - searchProvider, | |
| - searchDebounceTime | |
| - ); | |
| + const searchModel = new SearchDocumentModel(searchProvider, searchDebounceTime); | |
| const keyBingingsInfo = new SearchKeyBindings(app.commands); | |
| @@ -343,9 +328,7 @@ const extension: JupyterFrontEndPlugin<ISearchProviderRegistry> = { | |
| if (searchText) { | |
| searchWidget.setSearchText(searchText); | |
| } else { | |
| - searchWidget.setSearchText( | |
| - searchWidget.model.suggestedInitialQuery | |
| - ); | |
| + searchWidget.setSearchText(searchWidget.model.suggestedInitialQuery); | |
| } | |
| const selectionState = searchWidget.model.selectionState; | |
| @@ -395,9 +378,7 @@ const extension: JupyterFrontEndPlugin<ISearchProviderRegistry> = { | |
| if (searchText) { | |
| searchWidget.setSearchText(searchText); | |
| } else { | |
| - searchWidget.setSearchText( | |
| - searchWidget.model.suggestedInitialQuery | |
| - ); | |
| + searchWidget.setSearchText(searchWidget.model.suggestedInitialQuery); | |
| } | |
| const replaceText = args['replaceText'] as string; | |
| if (replaceText) { | |
| @@ -412,8 +393,7 @@ const extension: JupyterFrontEndPlugin<ISearchProviderRegistry> = { | |
| app.commands.addCommand(CommandIDs.findNext, { | |
| label: trans.__('Find Next'), | |
| isEnabled: () => | |
| - !!app.shell.currentWidget && | |
| - searchViews.has(app.shell.currentWidget.id), | |
| + !!app.shell.currentWidget && searchViews.has(app.shell.currentWidget.id), | |
| describedBy: { | |
| args: { | |
| type: 'object', | |
| @@ -433,8 +413,7 @@ const extension: JupyterFrontEndPlugin<ISearchProviderRegistry> = { | |
| app.commands.addCommand(CommandIDs.findPrevious, { | |
| label: trans.__('Find Previous'), | |
| isEnabled: () => | |
| - !!app.shell.currentWidget && | |
| - searchViews.has(app.shell.currentWidget.id), | |
| + !!app.shell.currentWidget && searchViews.has(app.shell.currentWidget.id), | |
| describedBy: { | |
| args: { | |
| type: 'object', | |
| @@ -454,8 +433,7 @@ const extension: JupyterFrontEndPlugin<ISearchProviderRegistry> = { | |
| app.commands.addCommand(CommandIDs.end, { | |
| label: trans.__('End Search'), | |
| isEnabled: () => | |
| - !!app.shell.currentWidget && | |
| - searchViews.has(app.shell.currentWidget.id), | |
| + !!app.shell.currentWidget && searchViews.has(app.shell.currentWidget.id), | |
| describedBy: { | |
| args: { | |
| type: 'object', | |
| diff --git a/packages/documentsearch/src/providers/genericsearchprovider.ts b/packages/documentsearch/src/providers/genericsearchprovider.ts | |
| index 68ba354963..f69a1e2447 100644 | |
| --- a/packages/documentsearch/src/providers/genericsearchprovider.ts | |
| +++ b/packages/documentsearch/src/providers/genericsearchprovider.ts | |
| @@ -195,9 +195,7 @@ export class GenericSearchProvider extends SearchProvider<Widget> { | |
| get matches(): IHTMLSearchMatch[] { | |
| // Ensure that no other fn can overwrite matches index property | |
| // We shallow clone each node | |
| - return this._matches | |
| - ? this._matches.map(m => Object.assign({}, m)) | |
| - : this._matches; | |
| + return this._matches ? this._matches.map(m => Object.assign({}, m)) : this._matches; | |
| } | |
| /** | |
| @@ -267,9 +265,7 @@ export class GenericSearchProvider extends SearchProvider<Widget> { | |
| * | |
| * @returns A promise that resolves once the action has completed. | |
| */ | |
| - async highlightPrevious( | |
| - loop?: boolean | |
| - ): Promise<IHTMLSearchMatch | undefined> { | |
| + async highlightPrevious(loop?: boolean): Promise<IHTMLSearchMatch | undefined> { | |
| return this._highlightNext(true, loop ?? true) ?? undefined; | |
| } | |
| @@ -321,10 +317,7 @@ export class GenericSearchProvider extends SearchProvider<Widget> { | |
| let parent = activeNode.parentNode!; | |
| let subMatches = [matches[nodeIdx]]; | |
| - while ( | |
| - ++nodeIdx < matches.length && | |
| - matches[nodeIdx].node === activeNode | |
| - ) { | |
| + while (++nodeIdx < matches.length && matches[nodeIdx].node === activeNode) { | |
| subMatches.unshift(matches[nodeIdx]); | |
| } | |
| @@ -377,10 +370,7 @@ export class GenericSearchProvider extends SearchProvider<Widget> { | |
| this._currentMatchIndex = -1; | |
| } | |
| - private _highlightNext( | |
| - reverse: boolean, | |
| - loop: boolean | |
| - ): IHTMLSearchMatch | null { | |
| + private _highlightNext(reverse: boolean, loop: boolean): IHTMLSearchMatch | null { | |
| if (this._matches.length === 0) { | |
| return null; | |
| } | |
| @@ -395,13 +385,11 @@ export class GenericSearchProvider extends SearchProvider<Widget> { | |
| : this._currentMatchIndex + 1; | |
| if ( | |
| loop && | |
| - (this._currentMatchIndex < 0 || | |
| - this._currentMatchIndex >= this._matches.length) | |
| + (this._currentMatchIndex < 0 || this._currentMatchIndex >= this._matches.length) | |
| ) { | |
| // Cheap way to make this a circular buffer | |
| this._currentMatchIndex = | |
| - (this._currentMatchIndex + this._matches.length) % | |
| - this._matches.length; | |
| + (this._currentMatchIndex + this._matches.length) % this._matches.length; | |
| } | |
| } | |
| diff --git a/packages/documentsearch/src/searchmodel.ts b/packages/documentsearch/src/searchmodel.ts | |
| index aad59390f9..a059e6e65e 100644 | |
| --- a/packages/documentsearch/src/searchmodel.ts | |
| +++ b/packages/documentsearch/src/searchmodel.ts | |
| @@ -17,10 +17,7 @@ import type { | |
| /** | |
| * Search in a document model. | |
| */ | |
| -export class SearchDocumentModel | |
| - extends VDomModel | |
| - implements IObservableDisposable | |
| -{ | |
| +export class SearchDocumentModel extends VDomModel implements IObservableDisposable { | |
| /** | |
| * Search document model | |
| * @param searchProvider Provider for the current document | |
| @@ -237,17 +234,11 @@ export class SearchDocumentModel | |
| if (this._searchExpression) { | |
| this.endQuery().catch(reason => { | |
| - console.error( | |
| - `Failed to end query '${this._searchExpression}.`, | |
| - reason | |
| - ); | |
| + console.error(`Failed to end query '${this._searchExpression}.`, reason); | |
| }); | |
| } | |
| - this.searchProvider.stateChanged.disconnect( | |
| - this._onProviderStateChanged, | |
| - this | |
| - ); | |
| + this.searchProvider.stateChanged.disconnect(this._onProviderStateChanged, this); | |
| this._searchDebouncer.dispose(); | |
| super.dispose(); | |
| @@ -362,10 +353,7 @@ export class SearchDocumentModel | |
| } catch (reason) { | |
| this._parsingError = reason.toString(); | |
| this.stateChanged.emit(); | |
| - console.error( | |
| - `Failed to parse expression ${this.searchExpression}`, | |
| - reason | |
| - ); | |
| + console.error(`Failed to parse expression ${this.searchExpression}`, reason); | |
| } | |
| } | |
| diff --git a/packages/documentsearch/src/searchview.tsx b/packages/documentsearch/src/searchview.tsx | |
| index c083ac0100..5b597d464e 100644 | |
| --- a/packages/documentsearch/src/searchview.tsx | |
| +++ b/packages/documentsearch/src/searchview.tsx | |
| @@ -287,12 +287,8 @@ function UpDownButtons(props: IUpDownProps) { | |
| const nextBinding = props.keyBindings?.next; | |
| const prevBinding = props.keyBindings?.previous; | |
| - const nextKeys = nextBinding | |
| - ? CommandRegistry.formatKeystroke(nextBinding.keys) | |
| - : ''; | |
| - const prevKeys = prevBinding | |
| - ? CommandRegistry.formatKeystroke(prevBinding.keys) | |
| - : ''; | |
| + const nextKeys = nextBinding ? CommandRegistry.formatKeystroke(nextBinding.keys) : ''; | |
| + const prevKeys = prevBinding ? CommandRegistry.formatKeystroke(prevBinding.keys) : ''; | |
| const prevShortcut = prevKeys ? ` (${prevKeys})` : ''; | |
| const nextShortcut = nextKeys ? ` (${nextKeys})` : ''; | |
| @@ -625,8 +621,7 @@ class SearchOverlay extends React.Component<ISearchOverlayProps> { | |
| render() { | |
| const trans = this.translator.load('jupyterlab'); | |
| - const showReplace = | |
| - !this.props.isReadOnly && this.props.replaceEntryVisible; | |
| + const showReplace = !this.props.isReadOnly && this.props.replaceEntryVisible; | |
| const filters = this.props.filtersDefinition; | |
| const hasFilters = Object.keys(filters).length > 0; | |
| @@ -663,15 +658,10 @@ class SearchOverlay extends React.Component<ISearchOverlayProps> { | |
| <FilterSelection | |
| key={name} | |
| title={filter.title} | |
| - description={ | |
| - description + (name == 'selection' ? selectionKeyHint : '') | |
| - } | |
| + description={description + (name == 'selection' ? selectionKeyHint : '')} | |
| isEnabled={isEnabled} | |
| onToggle={async () => { | |
| - await this.props.onFilterChanged( | |
| - name, | |
| - !this.props.filters[name] | |
| - ); | |
| + await this.props.onFilterChanged(name, !this.props.filters[name]); | |
| }} | |
| value={this.props.filters[name] ?? filter.default} | |
| /> | |
| @@ -679,9 +669,7 @@ class SearchOverlay extends React.Component<ISearchOverlayProps> { | |
| })} | |
| </div> | |
| ) : null; | |
| - const icon = this.props.replaceEntryVisible | |
| - ? caretDownIcon | |
| - : caretRightIcon; | |
| + const icon = this.props.replaceEntryVisible ? caretDownIcon : caretRightIcon; | |
| // TODO: Error messages from regex are not currently localizable. | |
| return ( | |
| @@ -694,11 +682,7 @@ class SearchOverlay extends React.Component<ISearchOverlayProps> { | |
| className={TOGGLE_WRAPPER} | |
| onClick={() => this._onReplaceToggled()} | |
| tabIndex={0} | |
| - title={ | |
| - showReplace | |
| - ? trans.__('Hide Replace') | |
| - : trans.__('Show Replace') | |
| - } | |
| + title={showReplace ? trans.__('Hide Replace') : trans.__('Show Replace')} | |
| > | |
| <icon.react | |
| className={`${REPLACE_TOGGLE_CLASS} ${BUTTON_CONTENT_CLASS}`} | |
| @@ -762,13 +746,9 @@ class SearchOverlay extends React.Component<ISearchOverlayProps> { | |
| <> | |
| <ReplaceEntry | |
| onPreserveCaseToggled={this.props.onPreserveCaseToggled} | |
| - onReplaceKeydown={(e: React.KeyboardEvent) => | |
| - this._onReplaceKeydown(e) | |
| - } | |
| + onReplaceKeydown={(e: React.KeyboardEvent) => this._onReplaceKeydown(e)} | |
| onChange={(e: React.ChangeEvent) => | |
| - this.props.onReplaceChanged( | |
| - (e.target as HTMLTextAreaElement).value | |
| - ) | |
| + this.props.onReplaceChanged((e.target as HTMLTextAreaElement).value) | |
| } | |
| onReplaceCurrent={() => this.props.onReplaceCurrent()} | |
| onReplaceAll={() => this.props.onReplaceAll()} | |
| @@ -912,9 +892,7 @@ export class SearchDocumentView extends VDomRenderer<SearchDocumentModel> { | |
| replaceText={this.model.replaceText} | |
| initialSearchText={this.model.initialQuery} | |
| lastSearchText={this.model.searchExpression} | |
| - searchInputRef={ | |
| - this._searchInput as React.RefObject<HTMLTextAreaElement> | |
| - } | |
| + searchInputRef={this._searchInput as React.RefObject<HTMLTextAreaElement>} | |
| totalMatches={this.model.totalMatches} | |
| translator={this.translator} | |
| useRegex={this.model.useRegex} | |
| diff --git a/packages/documentsearch/src/tokens.ts b/packages/documentsearch/src/tokens.ts | |
| index 6951c9c55b..ceb3e4bfda 100644 | |
| --- a/packages/documentsearch/src/tokens.ts | |
| +++ b/packages/documentsearch/src/tokens.ts | |
| @@ -314,10 +314,7 @@ export interface IBaseSearchProvider extends IDisposable { | |
| * | |
| * @returns A promise that resolves with a boolean indicating whether a replace occurred. | |
| */ | |
| - replaceAllMatches( | |
| - newText: string, | |
| - options?: IReplaceOptions | |
| - ): Promise<boolean>; | |
| + replaceAllMatches(newText: string, options?: IReplaceOptions): Promise<boolean>; | |
| /** | |
| * Signal indicating that something in the search has changed, so the UI should update | |
| diff --git a/packages/documentsearch/style/base.css b/packages/documentsearch/style/base.css | |
| index ffb5acba81..a2debd0435 100644 | |
| --- a/packages/documentsearch/style/base.css | |
| +++ b/packages/documentsearch/style/base.css | |
| @@ -100,8 +100,7 @@ | |
| .jp-DocumentSearch-toggle-wrapper:focus, | |
| .jp-DocumentSearch-button-wrapper:focus { | |
| - outline: var(--jp-border-width) solid | |
| - var(--jp-cell-editor-active-border-color); | |
| + outline: var(--jp-border-width) solid var(--jp-cell-editor-active-border-color); | |
| outline-offset: -1px; | |
| } | |
| diff --git a/packages/documentsearch/test/documentsearchprovider.spec.ts b/packages/documentsearch/test/documentsearchprovider.spec.ts | |
| index 081784c934..26f6cb5d9e 100644 | |
| --- a/packages/documentsearch/test/documentsearchprovider.spec.ts | |
| +++ b/packages/documentsearch/test/documentsearchprovider.spec.ts | |
| @@ -1,9 +1,6 @@ | |
| // Copyright (c) Jupyter Development Team. | |
| // Distributed under the terms of the Modified BSD License. | |
| -import { | |
| - FOUND_CLASSES, | |
| - GenericSearchProvider | |
| -} from '@jupyterlab/documentsearch'; | |
| +import { FOUND_CLASSES, GenericSearchProvider } from '@jupyterlab/documentsearch'; | |
| import { Widget } from '@lumino/widgets'; | |
| const MATCH_CLASSES = FOUND_CLASSES.join(' '); | |
| @@ -30,13 +27,10 @@ describe('documentsearch/genericsearchprovider', () => { | |
| ['old_text_1', 'NEW_TEXT_1', 'new_text_1'], | |
| ['Old', 'new', 'New'], | |
| ['Old', '𐐶ew', '𐐎ew'] | |
| - ])( | |
| - 'should copy case from %s to %s yielding %s', | |
| - (oldText, newText, expected) => { | |
| - const replace = GenericSearchProvider.preserveCase(oldText, newText); | |
| - expect(replace).toEqual(expected); | |
| - } | |
| - ); | |
| + ])('should copy case from %s to %s yielding %s', (oldText, newText, expected) => { | |
| + const replace = GenericSearchProvider.preserveCase(oldText, newText); | |
| + expect(replace).toEqual(expected); | |
| + }); | |
| }); | |
| describe('#startQuery()', () => { | |
| @@ -89,27 +83,21 @@ describe('documentsearch/genericsearchprovider', () => { | |
| '<pre>xy<span>z</span></pre>', | |
| `xy<span><mark class="${MATCH_CLASSES}">z</mark></span>` | |
| ] | |
| - ])( | |
| - 'should highlight %s fragment in %s', | |
| - async (query, content, expected) => { | |
| - widget.node.innerHTML = content; | |
| - await provider.startQuery(query); | |
| - expect(widget.node.firstElementChild!.innerHTML).toEqual(expected); | |
| - } | |
| - ); | |
| + ])('should highlight %s fragment in %s', async (query, content, expected) => { | |
| + widget.node.innerHTML = content; | |
| + await provider.startQuery(query); | |
| + expect(widget.node.firstElementChild!.innerHTML).toEqual(expected); | |
| + }); | |
| it.each([ | |
| [/z/, '<pre><svg>z</svg></pre>'], | |
| [/y/, '<pre><svg><text>y</text></svg></pre>'], | |
| [/x/, '<pre><svg><text x="5" y="15" fill="red">x</text></svg></pre>'] | |
| - ])( | |
| - 'should ignore %s in unsupported fragment %s', | |
| - async (query, content) => { | |
| - widget.node.innerHTML = content; | |
| - await provider.startQuery(query); | |
| - expect(widget.node.innerHTML).toEqual(content); | |
| - } | |
| - ); | |
| + ])('should ignore %s in unsupported fragment %s', async (query, content) => { | |
| + widget.node.innerHTML = content; | |
| + await provider.startQuery(query); | |
| + expect(widget.node.innerHTML).toEqual(content); | |
| + }); | |
| }); | |
| describe('#endQuery()', () => { | |
| @@ -126,15 +114,12 @@ describe('documentsearch/genericsearchprovider', () => { | |
| [/x/, '<pre>xy<span>z</span></pre>'], | |
| [/y/, '<pre>xy<span>z</span></pre>'], | |
| [/z/, '<pre>xy<span>z</span></pre>'] | |
| - ])( | |
| - 'should restore highlighted %s fragment in %s', | |
| - async (query, content) => { | |
| - widget.node.innerHTML = content; | |
| - await provider.startQuery(query); | |
| - await provider.endQuery(); | |
| - expect(widget.node.innerHTML).toEqual(content); | |
| - } | |
| - ); | |
| + ])('should restore highlighted %s fragment in %s', async (query, content) => { | |
| + widget.node.innerHTML = content; | |
| + await provider.startQuery(query); | |
| + await provider.endQuery(); | |
| + expect(widget.node.innerHTML).toEqual(content); | |
| + }); | |
| }); | |
| }); | |
| }); | |
| diff --git a/packages/documentsearch/test/searchmodel.spec.ts b/packages/documentsearch/test/searchmodel.spec.ts | |
| index b8651fc1a6..762a1e5d04 100644 | |
| --- a/packages/documentsearch/test/searchmodel.spec.ts | |
| +++ b/packages/documentsearch/test/searchmodel.spec.ts | |
| @@ -1,9 +1,6 @@ | |
| // Copyright (c) Jupyter Development Team. | |
| // Distributed under the terms of the Modified BSD License. | |
| -import { | |
| - GenericSearchProvider, | |
| - SearchDocumentModel | |
| -} from '@jupyterlab/documentsearch'; | |
| +import { GenericSearchProvider, SearchDocumentModel } from '@jupyterlab/documentsearch'; | |
| import { Widget } from '@lumino/widgets'; | |
| import { PromiseDelegate } from '@lumino/coreutils'; | |
| import { signalToPromise } from '@jupyterlab/testing'; | |
| diff --git a/packages/extensionmanager-extension/src/index.ts b/packages/extensionmanager-extension/src/index.ts | |
| index 95d6d93d63..4db74e2e79 100644 | |
| --- a/packages/extensionmanager-extension/src/index.ts | |
| +++ b/packages/extensionmanager-extension/src/index.ts | |
| @@ -5,10 +5,7 @@ | |
| * @module extensionmanager-extension | |
| */ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { ILayoutRestorer } from '@jupyterlab/application'; | |
| import { Dialog, ICommandPalette, showDialog } from '@jupyterlab/apputils'; | |
| import { ExtensionsPanel, ListModel } from '@jupyterlab/extensionmanager'; | |
| @@ -75,16 +72,13 @@ const plugin: JupyterFrontEndPlugin<void> = { | |
| model.isEnabled = settings.get('enabled').composite as boolean; | |
| model.stateChanged.connect(() => { | |
| if ( | |
| - model.isDisclaimed !== | |
| - (settings.get('disclaimed').composite as boolean) | |
| + model.isDisclaimed !== (settings.get('disclaimed').composite as boolean) | |
| ) { | |
| settings.set('disclaimed', model.isDisclaimed).catch(reason => { | |
| console.error(`Failed to set setting 'disclaimed'.\n${reason}`); | |
| }); | |
| } | |
| - if ( | |
| - model.isEnabled !== (settings.get('enabled').composite as boolean) | |
| - ) { | |
| + if (model.isEnabled !== (settings.get('enabled').composite as boolean)) { | |
| settings.set('enabled', model.isEnabled).catch(reason => { | |
| console.error(`Failed to set setting 'enabled'.\n${reason}`); | |
| }); | |
| @@ -119,9 +113,7 @@ const plugin: JupyterFrontEndPlugin<void> = { | |
| }); | |
| }) | |
| .catch(reason => { | |
| - console.error( | |
| - `Something went wrong when reading the settings.\n${reason}` | |
| - ); | |
| + console.error(`Something went wrong when reading the settings.\n${reason}`); | |
| }); | |
| commands.addCommand(CommandIDs.showPanel, { | |
| @@ -179,9 +171,7 @@ namespace Private { | |
| * | |
| * @returns whether the user accepted the dialog. | |
| */ | |
| - export async function showWarning( | |
| - trans: TranslationBundle | |
| - ): Promise<boolean> { | |
| + export async function showWarning(trans: TranslationBundle): Promise<boolean> { | |
| const result = await showDialog({ | |
| title: trans.__('Enable Extension Manager?'), | |
| body: trans.__(`Thanks for trying out JupyterLab's extension manager. | |
| diff --git a/packages/extensionmanager/src/model.ts b/packages/extensionmanager/src/model.ts | |
| index 000066c980..1cd88ab28b 100644 | |
| --- a/packages/extensionmanager/src/model.ts | |
| +++ b/packages/extensionmanager/src/model.ts | |
| @@ -195,10 +195,7 @@ export interface IActionOptions { | |
| * Model for an extension list. | |
| */ | |
| export class ListModel extends VDomModel { | |
| - constructor( | |
| - serviceManager: ServiceManager.IManager, | |
| - translator?: ITranslator | |
| - ) { | |
| + constructor(serviceManager: ServiceManager.IManager, translator?: ITranslator) { | |
| super(); | |
| const metadata = JSON.parse( | |
| @@ -360,10 +357,7 @@ export class ListModel extends VDomModel { | |
| * @param entry An entry indicating which extension to install. | |
| * @param options Additional options for the action. | |
| */ | |
| - async install( | |
| - entry: IEntry, | |
| - options: { useVersion?: string } = {} | |
| - ): Promise<void> { | |
| + async install(entry: IEntry, options: { useVersion?: string } = {}): Promise<void> { | |
| await this.performAction('install', entry, options).then(data => { | |
| if (data.status !== 'ok') { | |
| reportInstallError(entry.name, data.message, this.translator); | |
| @@ -458,9 +452,9 @@ export class ListModel extends VDomModel { | |
| const lastURL = links['last']; | |
| if (lastURL) { | |
| - const lastPage = URLExt.queryStringToObject( | |
| - URLExt.parse(lastURL).search ?? '' | |
| - )['page']; | |
| + const lastPage = URLExt.queryStringToObject(URLExt.parse(lastURL).search ?? '')[ | |
| + 'page' | |
| + ]; | |
| if (lastPage) { | |
| this._lastPage = parseInt(lastPage, 10); | |
| @@ -529,9 +523,7 @@ export class ListModel extends VDomModel { | |
| if (reply.needs_restart.includes('server')) { | |
| void showDialog({ | |
| title: trans.__('Information'), | |
| - body: trans.__( | |
| - 'You will need to restart JupyterLab to apply the changes.' | |
| - ), | |
| + body: trans.__('You will need to restart JupyterLab to apply the changes.'), | |
| buttons: [Dialog.okButton({ label: trans.__('Ok') })] | |
| }); | |
| } else { | |
| diff --git a/packages/extensionmanager/src/widget.tsx b/packages/extensionmanager/src/widget.tsx | |
| index dfc60d419b..c6c2567649 100644 | |
| --- a/packages/extensionmanager/src/widget.tsx | |
| +++ b/packages/extensionmanager/src/widget.tsx | |
| @@ -25,10 +25,7 @@ const BADGE_SIZE = 32; | |
| const BADGE_QUERY_SIZE = Math.floor(devicePixelRatio * BADGE_SIZE); | |
| function getExtensionGitHubUser(entry: IEntry) { | |
| - if ( | |
| - entry.homepage_url && | |
| - entry.homepage_url.startsWith('https://github.com/') | |
| - ) { | |
| + if (entry.homepage_url && entry.homepage_url.startsWith('https://github.com/')) { | |
| return entry.homepage_url.split('/')[3]; | |
| } else if ( | |
| entry.repository_url && | |
| @@ -66,9 +63,7 @@ function ListEntry(props: ListEntry.IProperties): React.ReactElement<any> { | |
| style={{ width: '32px', height: '32px' }} | |
| /> | |
| ) : ( | |
| - <div | |
| - style={{ width: `${BADGE_SIZE}px`, height: `${BADGE_SIZE}px` }} | |
| - /> | |
| + <div style={{ width: `${BADGE_SIZE}px`, height: `${BADGE_SIZE}px` }} /> | |
| )} | |
| </div> | |
| <div className="jp-extensionmanager-entry-description"> | |
| @@ -112,9 +107,7 @@ function ListEntry(props: ListEntry.IProperties): React.ReactElement<any> { | |
| top="1px" | |
| height="auto" | |
| width="1em" | |
| - title={trans.__( | |
| - 'This extension is approved by your security team.' | |
| - )} | |
| + title={trans.__('This extension is approved by your security team.')} | |
| /> | |
| )} | |
| </div> | |
| @@ -407,8 +400,7 @@ class Warning extends ReactWidget { | |
| return ( | |
| <> | |
| <p> | |
| - {this.trans | |
| - .__(`The JupyterLab development team is excited to have a robust | |
| + {this.trans.__(`The JupyterLab development team is excited to have a robust | |
| third-party extension community. However, we do not review | |
| third-party extensions, and some extensions may introduce security | |
| risks or contain malicious code that runs on your machine. Moreover in order | |
| @@ -494,12 +486,8 @@ class InstalledList extends ReactWidget { | |
| onPage={value => { | |
| /* no-op */ | |
| }} | |
| - performAction={ | |
| - this.model.isDisclaimed ? this.onAction.bind(this) : null | |
| - } | |
| - supportInstallation={ | |
| - this.model.canInstall && this.model.isDisclaimed | |
| - } | |
| + performAction={this.model.isDisclaimed ? this.onAction.bind(this) : null} | |
| + supportInstallation={this.model.canInstall && this.model.isDisclaimed} | |
| /> | |
| )} | |
| </> | |
| @@ -599,12 +587,8 @@ class SearchResult extends ReactWidget { | |
| onPage={value => { | |
| this.onPage(value); | |
| }} | |
| - performAction={ | |
| - this.model.isDisclaimed ? this.onAction.bind(this) : null | |
| - } | |
| - supportInstallation={ | |
| - this.model.canInstall && this.model.isDisclaimed | |
| - } | |
| + performAction={this.model.isDisclaimed ? this.onAction.bind(this) : null} | |
| + supportInstallation={this.model.canInstall && this.model.isDisclaimed} | |
| trans={this.trans} | |
| /> | |
| )} | |
| diff --git a/packages/filebrowser-extension/src/index.ts b/packages/filebrowser-extension/src/index.ts | |
| index 04d6e750c1..cc5af89866 100644 | |
| --- a/packages/filebrowser-extension/src/index.ts | |
| +++ b/packages/filebrowser-extension/src/index.ts | |
| @@ -45,10 +45,7 @@ import { ISettingRegistry } from '@jupyterlab/settingregistry'; | |
| import { IStateDB } from '@jupyterlab/statedb'; | |
| import { IStatusBar } from '@jupyterlab/statusbar'; | |
| import { ITranslator, nullTranslator } from '@jupyterlab/translation'; | |
| -import type { | |
| - IDisposableMenuItem, | |
| - RankedMenu | |
| -} from '@jupyterlab/ui-components'; | |
| +import type { IDisposableMenuItem, RankedMenu } from '@jupyterlab/ui-components'; | |
| import { | |
| addIcon, | |
| closeIcon, | |
| @@ -147,8 +144,7 @@ namespace CommandIDs { | |
| export const toggleFileSize = 'filebrowser:toggle-file-size'; | |
| - export const toggleSortNotebooksFirst = | |
| - 'filebrowser:toggle-sort-notebooks-first'; | |
| + export const toggleSortNotebooksFirst = 'filebrowser:toggle-sort-notebooks-first'; | |
| export const search = 'filebrowser:search'; | |
| @@ -179,12 +175,7 @@ const browser: JupyterFrontEndPlugin<IFileBrowserCommands> = { | |
| id: FILE_BROWSER_PLUGIN_ID, | |
| description: 'Set up the default file browser commands and state restoration', | |
| requires: [IDefaultFileBrowser, IFileBrowserFactory, ITranslator], | |
| - optional: [ | |
| - ILayoutRestorer, | |
| - ISettingRegistry, | |
| - ITreePathUpdater, | |
| - ICommandPalette | |
| - ], | |
| + optional: [ILayoutRestorer, ISettingRegistry, ITreePathUpdater, ICommandPalette], | |
| provides: IFileBrowserCommands, | |
| autoStart: true, | |
| activate: async ( | |
| @@ -215,14 +206,7 @@ const browser: JupyterFrontEndPlugin<IFileBrowserCommands> = { | |
| await browser.model.cd(preferredPath); | |
| } | |
| - addCommands( | |
| - app, | |
| - browser, | |
| - factory, | |
| - translator, | |
| - settingRegistry, | |
| - commandPalette | |
| - ); | |
| + addCommands(app, browser, factory, translator, settingRegistry, commandPalette); | |
| void Promise.all([app.restored, browser.model.restored]).then(() => { | |
| if (treePathUpdater) { | |
| @@ -269,8 +253,7 @@ const browserSettings: JupyterFrontEndPlugin<void> = { | |
| allowFileUploads: true | |
| }; | |
| - browser.showFileFilter = settings.get('showFileFilter') | |
| - .composite as boolean; | |
| + browser.showFileFilter = settings.get('showFileFilter').composite as boolean; | |
| function onSettingsChanged(settings: ISettingRegistry.ISettings): void { | |
| let key: keyof typeof defaultFileBrowserConfig; | |
| @@ -284,8 +267,7 @@ const browserSettings: JupyterFrontEndPlugin<void> = { | |
| browser.minimumBreadcrumbsRightItems = breadcrumbs.minimumRightItems; | |
| const filterDirectories = settings.get('filterDirectories') | |
| .composite as boolean; | |
| - const useFuzzyFilter = settings.get('useFuzzyFilter') | |
| - .composite as boolean; | |
| + const useFuzzyFilter = settings.get('useFuzzyFilter').composite as boolean; | |
| browser.model.filterDirectories = filterDirectories; | |
| browser.model.useFuzzyFilter = useFuzzyFilter; | |
| } | |
| @@ -318,9 +300,7 @@ const factory: JupyterFrontEndPlugin<IFileBrowserFactory> = { | |
| options: IFileBrowserFactory.IOptions = {} | |
| ) => { | |
| const state = | |
| - options.state === null | |
| - ? undefined | |
| - : options.state || stateDB || undefined; | |
| + options.state === null ? undefined : options.state || stateDB || undefined; | |
| const model = new FilterFileBrowserModel({ | |
| translator: translator, | |
| auto: options.auto ?? true, | |
| @@ -377,10 +357,7 @@ const defaultFileBrowser: JupyterFrontEndPlugin<IDefaultFileBrowser> = { | |
| // Set attributes when adding the browser to the UI | |
| defaultBrowser.node.setAttribute('role', 'region'); | |
| - defaultBrowser.node.setAttribute( | |
| - 'aria-label', | |
| - trans.__('File Browser Section') | |
| - ); | |
| + defaultBrowser.node.setAttribute('aria-label', trans.__('File Browser Section')); | |
| defaultBrowser.title.icon = folderIcon; | |
| // Show the current file browser shortcut in its title. | |
| @@ -400,14 +377,7 @@ const defaultFileBrowser: JupyterFrontEndPlugin<IDefaultFileBrowser> = { | |
| updateBrowserTitle(); | |
| }); | |
| - void Private.restoreBrowser( | |
| - defaultBrowser, | |
| - commands, | |
| - router, | |
| - tree, | |
| - app, | |
| - labShell | |
| - ); | |
| + void Private.restoreBrowser(defaultBrowser, commands, router, tree, app, labShell); | |
| return defaultBrowser; | |
| } | |
| }; | |
| @@ -491,10 +461,7 @@ const createNewLanguageFilePlugin: JupyterFrontEndPlugin<void> = { | |
| description: 'Adds context menu entries for creating Python/R/Julia files', | |
| requires: [ITranslator], | |
| autoStart: true, | |
| - activate: async ( | |
| - app: JupyterFrontEnd, | |
| - translator: ITranslator | |
| - ): Promise<void> => { | |
| + activate: async (app: JupyterFrontEnd, translator: ITranslator): Promise<void> => { | |
| const trans = translator.load('jupyterlab'); | |
| let filebrowsermenuDisposables = new DisposableSet(); | |
| @@ -569,8 +536,7 @@ const browserWidget: JupyterFrontEndPlugin<void> = { | |
| toolbarRegistry.addFactory( | |
| FILE_BROWSER_FACTORY, | |
| 'uploader', | |
| - (browser: FileBrowser) => | |
| - new Uploader({ model: browser.model, translator }) | |
| + (browser: FileBrowser) => new Uploader({ model: browser.model, translator }) | |
| ); | |
| setToolbar( | |
| @@ -618,11 +584,7 @@ const browserWidget: JupyterFrontEndPlugin<void> = { | |
| }, | |
| execute: args => { | |
| const path = (args.path as string) || ''; | |
| - const browserForPath = Private.getBrowserForPath( | |
| - path, | |
| - browser, | |
| - factory | |
| - ); | |
| + const browserForPath = Private.getBrowserForPath(path, browser, factory); | |
| // Check for browser not found | |
| if (!browserForPath) { | |
| @@ -708,10 +670,7 @@ const browserWidget: JupyterFrontEndPlugin<void> = { | |
| try { | |
| await Private.navigateToPath(path, browser, factory, translator); | |
| } catch (reason) { | |
| - console.warn( | |
| - `${CommandIDs.goToPath} failed to open: ${path}`, | |
| - reason | |
| - ); | |
| + console.warn(`${CommandIDs.goToPath} failed to open: ${path}`, reason); | |
| } | |
| } | |
| } | |
| @@ -799,8 +758,7 @@ const openWithPlugin: JupyterFrontEndPlugin<void> = { | |
| const openWith = | |
| (contextMenu.menu.items.find( | |
| item => | |
| - item.type === 'submenu' && | |
| - item.submenu?.id === 'jp-contextmenu-open-with' | |
| + item.type === 'submenu' && item.submenu?.id === 'jp-contextmenu-open-with' | |
| )?.submenu as RankedMenu) ?? null; | |
| if (!openWith) { | |
| @@ -905,9 +863,7 @@ const openBrowserTabPlugin: JupyterFrontEndPlugin<void> = { | |
| properties: { | |
| mode: { | |
| type: 'string', | |
| - description: trans.__( | |
| - 'Mode for opening files (e.g., single-document)' | |
| - ) | |
| + description: trans.__('Mode for opening files (e.g., single-document)') | |
| } | |
| } | |
| } | |
| @@ -1019,10 +975,7 @@ const openUrlPlugin: JupyterFrontEndPlugin<void> = { | |
| path: model.path | |
| }); | |
| } catch (error) { | |
| - return showErrorMessage( | |
| - trans._p('showErrorMessage', 'Upload Error'), | |
| - error | |
| - ); | |
| + return showErrorMessage(trans._p('showErrorMessage', 'Upload Error'), error); | |
| } | |
| }, | |
| describedBy: { | |
| @@ -1062,21 +1015,17 @@ const notifyUploadPlugin: JupyterFrontEndPlugin<void> = { | |
| // load and watch settings | |
| const settings = await settingRegistry.load(FILE_BROWSER_PLUGIN_ID); | |
| let autoOpen = settings.get('autoOpenUploads').composite as boolean; | |
| - let maxSize = | |
| - (settings.get('maxAutoOpenSizeMB').composite as number) * 1024 * 1024; | |
| + let maxSize = (settings.get('maxAutoOpenSizeMB').composite as number) * 1024 * 1024; | |
| settings.changed.connect(() => { | |
| autoOpen = settings.get('autoOpenUploads').composite as boolean; | |
| - maxSize = | |
| - (settings.get('maxAutoOpenSizeMB').composite as number) * 1024 * 1024; | |
| + maxSize = (settings.get('maxAutoOpenSizeMB').composite as number) * 1024 * 1024; | |
| }); | |
| // attach to the Uploader after restore | |
| void app.restored.then(() => { | |
| const widgets = Array.from(defaultBrowser.toolbar.children()); | |
| - const uploader = widgets.find(w => w instanceof Uploader) as | |
| - | Uploader | |
| - | undefined; | |
| + const uploader = widgets.find(w => w instanceof Uploader) as Uploader | undefined; | |
| if (!uploader) { | |
| console.warn('Uploader widget not found'); | |
| return; | |
| @@ -1097,26 +1046,17 @@ const notifyUploadPlugin: JupyterFrontEndPlugin<void> = { | |
| // Check if the uploaded file has an allowed extension | |
| const fileName = models[0].name.toLowerCase(); | |
| - const isAllowedFileType = allExtensions.some(ext => | |
| - fileName.endsWith(ext) | |
| - ); | |
| + const isAllowedFileType = allExtensions.some(ext => fileName.endsWith(ext)); | |
| if ( | |
| models.length === 1 && | |
| (models[0].type === 'notebook' || models[0].type === 'file') | |
| ) { | |
| const file = models[0]; | |
| - if ( | |
| - autoOpen && | |
| - file.size && | |
| - file.size <= maxSize && | |
| - isAllowedFileType | |
| - ) { | |
| + if (autoOpen && file.size && file.size <= maxSize && isAllowedFileType) { | |
| // open immediately | |
| - app.commands | |
| - .execute('docmanager:open', { path: file.path }) | |
| - .catch(err => { | |
| - void showErrorMessage(`Opening ${file.name} failed`, err); | |
| - }); | |
| + app.commands.execute('docmanager:open', { path: file.path }).catch(err => { | |
| + void showErrorMessage(`Opening ${file.name} failed`, err); | |
| + }); | |
| } else { | |
| // notify and offer an "Open" button | |
| Notification.emit( | |
| @@ -1135,10 +1075,7 @@ const notifyUploadPlugin: JupyterFrontEndPlugin<void> = { | |
| void app.commands | |
| .execute('docmanager:open', { path: file.path }) | |
| .catch(err => { | |
| - void showErrorMessage( | |
| - `Could not open ${file.name}`, | |
| - err | |
| - ); | |
| + void showErrorMessage(`Could not open ${file.name}`, err); | |
| }); | |
| } | |
| } | |
| @@ -1162,10 +1099,7 @@ const notifyUploadPlugin: JupyterFrontEndPlugin<void> = { | |
| void app.commands | |
| .execute('docmanager:open', { path: m.path }) | |
| .catch(err => { | |
| - void showErrorMessage( | |
| - `Could not open ${m.path}`, | |
| - err | |
| - ); | |
| + void showErrorMessage(`Could not open ${m.path}`, err); | |
| }) | |
| ); | |
| } | |
| @@ -1307,18 +1241,9 @@ function addCommands( | |
| const path = (args.path as string) || ''; | |
| const showBrowser = !(args?.dontShowBrowser ?? false); | |
| try { | |
| - const item = await Private.navigateToPath( | |
| - path, | |
| - browser, | |
| - factory, | |
| - translator | |
| - ); | |
| + const item = await Private.navigateToPath(path, browser, factory, translator); | |
| if (item.type !== 'directory' && showBrowser) { | |
| - const browserForPath = Private.getBrowserForPath( | |
| - path, | |
| - browser, | |
| - factory | |
| - ); | |
| + const browserForPath = Private.getBrowserForPath(path, browser, factory); | |
| if (browserForPath) { | |
| browserForPath.clearSelectedItems(); | |
| const parts = path.split('/'); | |
| @@ -1385,11 +1310,7 @@ function addCommands( | |
| // The normal contents service errors on paths ending in slash | |
| path = path.slice(0, path.length - 1); | |
| } | |
| - const browserForPath = Private.getBrowserForPath( | |
| - path, | |
| - browser, | |
| - factory | |
| - )!; | |
| + const browserForPath = Private.getBrowserForPath(path, browser, factory)!; | |
| const { services } = browserForPath.model.manager; | |
| const item = await services.contents.get(path, { | |
| content: false | |
| @@ -1476,8 +1397,7 @@ function addCommands( | |
| return folderIcon.bindprops({ stylesheet: 'menuItem' }); | |
| } | |
| }, | |
| - label: args => | |
| - (args['label'] || args['factory'] || trans.__('Open')) as string, | |
| + label: args => (args['label'] || args['factory'] || trans.__('Open')) as string, | |
| mnemonic: 0, | |
| describedBy: { | |
| args: { | |
| @@ -1911,9 +1831,7 @@ namespace Private { | |
| const driveName = browser.model.manager.services.contents.driveName(path); | |
| if (driveName) { | |
| - const browserForPath = tracker.find( | |
| - _path => _path.model.driveName === driveName | |
| - ); | |
| + const browserForPath = tracker.find(_path => _path.model.driveName === driveName); | |
| if (!browserForPath) { | |
| // warn that no filebrowser could be found for this driveName | |
| diff --git a/packages/filebrowser/src/browser.ts b/packages/filebrowser/src/browser.ts | |
| index c0b8452acd..959c0fe810 100644 | |
| --- a/packages/filebrowser/src/browser.ts | |
| +++ b/packages/filebrowser/src/browser.ts | |
| @@ -10,11 +10,7 @@ import type { IStateDB } from '@jupyterlab/statedb'; | |
| import type { ITranslator } from '@jupyterlab/translation'; | |
| import { nullTranslator } from '@jupyterlab/translation'; | |
| import type { IScore } from '@jupyterlab/ui-components'; | |
| -import { | |
| - FilenameSearcher, | |
| - SidePanel, | |
| - Toolbar | |
| -} from '@jupyterlab/ui-components'; | |
| +import { FilenameSearcher, SidePanel, Toolbar } from '@jupyterlab/ui-components'; | |
| import type { ISignal } from '@lumino/signaling'; | |
| import { Signal } from '@lumino/signaling'; | |
| import { Panel } from '@lumino/widgets'; | |
| @@ -84,10 +80,7 @@ export class FileBrowser extends SidePanel { | |
| model.connectionFailure.connect(this._onConnectionFailure, this); | |
| this._manager = model.manager; | |
| - this.toolbar.node.setAttribute( | |
| - 'aria-label', | |
| - this._trans.__('file browser') | |
| - ); | |
| + this.toolbar.node.setAttribute('aria-label', this._trans.__('file browser')); | |
| // File browser widgets container | |
| this.mainPanel = new Panel(); | |
| @@ -417,9 +410,7 @@ export class FileBrowser extends SidePanel { | |
| return this.listing.paste(); | |
| } | |
| - private async _createNew( | |
| - options: Contents.ICreateOptions | |
| - ): Promise<Contents.IModel> { | |
| + private async _createNew(options: Contents.ICreateOptions): Promise<Contents.IModel> { | |
| // normalize the path if the file is created from a custom drive | |
| if (options.path) { | |
| const localPath = this._manager.services.contents.localPath(options.path); | |
| @@ -457,9 +448,7 @@ export class FileBrowser extends SidePanel { | |
| /** | |
| * Create a new file | |
| */ | |
| - async createNewFile( | |
| - options: FileBrowser.IFileOptions | |
| - ): Promise<Contents.IModel> { | |
| + async createNewFile(options: FileBrowser.IFileOptions): Promise<Contents.IModel> { | |
| if (this._filePending) { | |
| return this._filePending; | |
| } | |
| @@ -566,19 +555,13 @@ export class FileBrowser extends SidePanel { | |
| /** | |
| * Handle a connection lost signal from the model. | |
| */ | |
| - private _onConnectionFailure( | |
| - sender: FilterFileBrowserModel, | |
| - args: Error | |
| - ): void { | |
| + private _onConnectionFailure(sender: FilterFileBrowserModel, args: Error): void { | |
| if ( | |
| args instanceof ServerConnection.ResponseError && | |
| args.response.status === 404 | |
| ) { | |
| const title = this._trans.__('Directory not found'); | |
| - args.message = this._trans.__( | |
| - 'Directory not found: "%1"', | |
| - this.model.path | |
| - ); | |
| + args.message = this._trans.__('Directory not found: "%1"', this.model.path); | |
| void showErrorMessage(title, args); | |
| } | |
| } | |
| diff --git a/packages/filebrowser/src/crumbs.ts b/packages/filebrowser/src/crumbs.ts | |
| index bc1219e5fa..3b2615b03e 100644 | |
| --- a/packages/filebrowser/src/crumbs.ts | |
| +++ b/packages/filebrowser/src/crumbs.ts | |
| @@ -210,9 +210,7 @@ export class BreadCrumbs extends Widget { | |
| const path = preferredPath ? '/' + preferredPath : preferredPath; | |
| this._model | |
| .cd(path) | |
| - .catch(error => | |
| - showErrorMessage(this._trans.__('Open Error'), error) | |
| - ); | |
| + .catch(error => showErrorMessage(this._trans.__('Open Error'), error)); | |
| // Stop the event propagation. | |
| event.preventDefault(); | |
| @@ -232,9 +230,7 @@ export class BreadCrumbs extends Widget { | |
| if (destination) { | |
| this._model | |
| .cd(destination) | |
| - .catch(error => | |
| - showErrorMessage(this._trans.__('Open Error'), error) | |
| - ); | |
| + .catch(error => showErrorMessage(this._trans.__('Open Error'), error)); | |
| } | |
| // Stop the event propagation. | |
| @@ -541,10 +537,7 @@ namespace Private { | |
| /** | |
| * Create a breadcrumb element for a path part. | |
| */ | |
| - function createBreadcrumbElement( | |
| - pathPart: string, | |
| - fullPath: string | |
| - ): HTMLElement { | |
| + function createBreadcrumbElement(pathPart: string, fullPath: string): HTMLElement { | |
| const elem = document.createElement('span'); | |
| elem.className = BREADCRUMB_ITEM_CLASS; | |
| elem.textContent = pathPart; | |
| diff --git a/packages/filebrowser/src/listing.ts b/packages/filebrowser/src/listing.ts | |
| index 09658aedbf..f7e15affa1 100644 | |
| --- a/packages/filebrowser/src/listing.ts | |
| +++ b/packages/filebrowser/src/listing.ts | |
| @@ -1,12 +1,7 @@ | |
| // Copyright (c) Jupyter Development Team. | |
| // Distributed under the terms of the Modified BSD License. | |
| -import { | |
| - Dialog, | |
| - DOMUtils, | |
| - showDialog, | |
| - showErrorMessage | |
| -} from '@jupyterlab/apputils'; | |
| +import { Dialog, DOMUtils, showDialog, showErrorMessage } from '@jupyterlab/apputils'; | |
| import { PageConfig, PathExt, Time } from '@jupyterlab/coreutils'; | |
| import type { IDocumentManager } from '@jupyterlab/docmanager'; | |
| import { isValidFileName, renameFile } from '@jupyterlab/docmanager'; | |
| @@ -421,10 +416,7 @@ export class DirListing extends Widget { | |
| return undefined; | |
| }) | |
| .catch(error => { | |
| - void showErrorMessage( | |
| - this._trans._p('showErrorMessage', 'Paste Error'), | |
| - error | |
| - ); | |
| + void showErrorMessage(this._trans._p('showErrorMessage', 'Paste Error'), error); | |
| }); | |
| } | |
| @@ -707,9 +699,8 @@ export class DirListing extends Widget { | |
| const items = this._sortedItems; | |
| return ( | |
| - Array.from( | |
| - filter(items, item => item.name === name && this.selection[item.path]) | |
| - ).length !== 0 | |
| + Array.from(filter(items, item => item.name === name && this.selection[item.path])) | |
| + .length !== 0 | |
| ); | |
| } | |
| @@ -1038,10 +1029,7 @@ export class DirListing extends Widget { | |
| } | |
| // add metadata to the node | |
| - node.setAttribute( | |
| - 'data-isdir', | |
| - item.type === 'directory' ? 'true' : 'false' | |
| - ); | |
| + node.setAttribute('data-isdir', item.type === 'directory' ? 'true' : 'false'); | |
| }); | |
| // Handle the selectors on the widget node. | |
| @@ -1103,10 +1091,7 @@ export class DirListing extends Widget { | |
| // Add any missing item nodes. | |
| while (nodes.length < items.length) { | |
| - const node = renderer.createItemNode( | |
| - this._hiddenColumns, | |
| - this._columnSizes | |
| - ); | |
| + const node = renderer.createItemNode(this._hiddenColumns, this._columnSizes); | |
| node.classList.add(ITEM_CLASS); | |
| nodes.push(node); | |
| content.appendChild(node); | |
| @@ -1174,16 +1159,12 @@ export class DirListing extends Widget { | |
| } | |
| onResize(msg: Widget.ResizeMessage): void { | |
| - const { width } = | |
| - msg.width === -1 ? this.node.getBoundingClientRect() : msg; | |
| + const { width } = msg.width === -1 ? this.node.getBoundingClientRect() : msg; | |
| this._width = this._computeContentWidth(width); | |
| this._updateColumnSizes(); | |
| } | |
| - setColumnVisibility( | |
| - name: DirListing.ToggleableColumn, | |
| - visible: boolean | |
| - ): void { | |
| + setColumnVisibility(name: DirListing.ToggleableColumn, visible: boolean): void { | |
| if (visible) { | |
| this._hiddenColumns.delete(name); | |
| } else { | |
| @@ -1254,9 +1235,7 @@ export class DirListing extends Widget { | |
| } | |
| return false; | |
| }); | |
| - const totalWeight = growColumns | |
| - .map(c => c.grow) | |
| - .reduce((a, b) => a + b, 0); | |
| + const totalWeight = growColumns.map(c => c.grow).reduce((a, b) => a + b, 0); | |
| for (const column of growColumns) { | |
| // The value of `growBy` will be negative when the down-sizing | |
| const growBy = (excess * column.grow) / totalWeight; | |
| @@ -1265,9 +1244,7 @@ export class DirListing extends Widget { | |
| } | |
| const resizeHandles = this.node.getElementsByClassName(RESIZE_HANDLE_CLASS); | |
| - const resizableColumns = visibleColumns.map(column => | |
| - Private.isResizable(column) | |
| - ); | |
| + const resizableColumns = visibleColumns.map(column => Private.isResizable(column)); | |
| // Write to DOM | |
| let i = 0; | |
| @@ -1275,8 +1252,7 @@ export class DirListing extends Widget { | |
| let size = this._columnSizes[column.id]; | |
| if (Private.isResizable(column) && size) { | |
| - size -= | |
| - (this._handleWidth * resizeHandles.length) / resizableColumns.length; | |
| + size -= (this._handleWidth * resizeHandles.length) / resizableColumns.length; | |
| // if this is first resizable or last resizable column | |
| if (i === 0 || i === resizableColumns.length - 1) { | |
| size += this._paddingWidth; | |
| @@ -1308,10 +1284,7 @@ export class DirListing extends Widget { | |
| ); | |
| } | |
| - private _setColumnSize( | |
| - name: DirListing.ResizableColumn, | |
| - size: number | null | |
| - ): void { | |
| + private _setColumnSize(name: DirListing.ResizableColumn, size: number | null): void { | |
| const previousSize = this._columnSizes[name]; | |
| if (previousSize && size && size > previousSize) { | |
| // check if we can resize up | |
| @@ -1328,8 +1301,7 @@ export class DirListing extends Widget { | |
| // add size as-is for columns before | |
| const element = DOMUtils.findElement(this.node, column.className); | |
| total += | |
| - this._columnSizes[column.id] ?? | |
| - element.getBoundingClientRect().width; | |
| + this._columnSizes[column.id] ?? element.getBoundingClientRect().width; | |
| } else { | |
| // add minimum acceptable size for columns after | |
| total += column.minWidth; | |
| @@ -1489,9 +1461,7 @@ export class DirListing extends Widget { | |
| | DirListing.ResizableColumn | |
| | undefined; | |
| if (!columnId) { | |
| - throw Error( | |
| - 'Column resize handle is missing data-column attribute' | |
| - ); | |
| + throw Error('Column resize handle is missing data-column attribute'); | |
| } | |
| const column = DirListing.columns.find(c => c.id === columnId); | |
| if (!column) { | |
| @@ -1624,10 +1594,7 @@ export class DirListing extends Widget { | |
| this._model | |
| .cd(`/${localPath}`) | |
| .catch(error => | |
| - showErrorMessage( | |
| - this._trans._p('showErrorMessage', 'Open directory'), | |
| - error | |
| - ) | |
| + showErrorMessage(this._trans._p('showErrorMessage', 'Open directory'), error) | |
| ); | |
| } else { | |
| const path = item.path; | |
| @@ -1873,9 +1840,7 @@ export class DirListing extends Widget { | |
| // Find a valid double click target. | |
| const target = event.target as HTMLElement; | |
| - const i = ArrayExt.findFirstIndex(this._items, node => | |
| - node.contains(target) | |
| - ); | |
| + const i = ArrayExt.findFirstIndex(this._items, node => node.contains(target)); | |
| if (i === -1) { | |
| return; | |
| } | |
| @@ -2149,12 +2114,7 @@ export class DirListing extends Widget { | |
| ref: prevWidget?.id, | |
| mode: 'tab-after' | |
| }; | |
| - prevWidget = this._manager.openOrReveal( | |
| - path, | |
| - void 0, | |
| - void 0, | |
| - options | |
| - ); | |
| + prevWidget = this._manager.openOrReveal(path, void 0, void 0, options); | |
| this._manager.openOrReveal(item!.path); | |
| }); | |
| }); | |
| @@ -2503,11 +2463,7 @@ export class DirListing extends Widget { | |
| /** | |
| * Select a given item. | |
| */ | |
| - private _selectItem( | |
| - index: number, | |
| - keepExisting: boolean, | |
| - focus: boolean = true | |
| - ) { | |
| + private _selectItem(index: number, keepExisting: boolean, focus: boolean = true) { | |
| // Selected the given row(s) | |
| const items = this._sortedItems; | |
| if (!keepExisting) { | |
| @@ -2563,10 +2519,7 @@ export class DirListing extends Widget { | |
| /** | |
| * Handle a `fileChanged` signal from the model. | |
| */ | |
| - private _onFileChanged( | |
| - sender: FilterFileBrowserModel, | |
| - args: Contents.IChangedArgs | |
| - ) { | |
| + private _onFileChanged(sender: FilterFileBrowserModel, args: Contents.IChangedArgs) { | |
| const newValue = args.newValue; | |
| if (!newValue) { | |
| return; | |
| @@ -2665,9 +2618,7 @@ export class DirListing extends Widget { | |
| private _width: number | null = null; | |
| private _state: IStateDB | null = null; | |
| private _contentScrollbarWidth: number = 0; | |
| - private _contentSizeObserver = new ResizeObserver( | |
| - this._onContentResize.bind(this) | |
| - ); | |
| + private _contentSizeObserver = new ResizeObserver(this._onContentResize.bind(this)); | |
| private _paddingWidth: number = 0; | |
| private _handleWidth: number = DEFAULT_HANDLE_WIDTH; | |
| private _lastRenderedState = new WeakMap<HTMLElement, string>(); | |
| @@ -3285,8 +3236,7 @@ export namespace DirListing { | |
| if (selected) { | |
| node.classList.add(SELECTED_CLASS); | |
| } | |
| - fileType = | |
| - fileType || DocumentRegistry.getDefaultTextFileType(translator); | |
| + fileType = fileType || DocumentRegistry.getDefaultTextFileType(translator); | |
| const { icon, iconClass, name } = fileType; | |
| translator = translator || nullTranslator; | |
| const trans = translator.load('jupyterlab'); | |
| @@ -3302,13 +3252,10 @@ export namespace DirListing { | |
| fileSize: model.size | |
| }); | |
| - const checkboxWrapper = DOMUtils.findElement( | |
| - node, | |
| - CHECKBOX_WRAPPER_CLASS | |
| - ); | |
| - const checkbox = checkboxWrapper?.querySelector( | |
| - 'input[type="checkbox"]' | |
| - ) as HTMLInputElement | undefined; | |
| + const checkboxWrapper = DOMUtils.findElement(node, CHECKBOX_WRAPPER_CLASS); | |
| + const checkbox = checkboxWrapper?.querySelector('input[type="checkbox"]') as | |
| + | HTMLInputElement | |
| + | undefined; | |
| if (checkbox) checkbox.checked = selected ?? false; | |
| @@ -3368,10 +3315,7 @@ export namespace DirListing { | |
| if (fileSize) { | |
| fileSize.textContent = fileSizeText; | |
| } | |
| - hoverText += trans.__( | |
| - '\nSize: %1', | |
| - formatFileSize(model.size, 1, 1024) | |
| - ); | |
| + hoverText += trans.__('\nSize: %1', formatFileSize(model.size, 1, 1024)); | |
| } else if (fileSize) { | |
| fileSize.textContent = ''; | |
| } | |
| @@ -3385,10 +3329,7 @@ export namespace DirListing { | |
| } | |
| } | |
| if (model.created) { | |
| - hoverText += trans.__( | |
| - '\nCreated: %1', | |
| - Time.format(new Date(model.created)) | |
| - ); | |
| + hoverText += trans.__('\nCreated: %1', Time.format(new Date(model.created))); | |
| } | |
| if (model.last_modified) { | |
| hoverText += trans.__( | |
| @@ -3487,9 +3428,7 @@ export namespace DirListing { | |
| * @returns The checkbox node. | |
| */ | |
| getCheckboxNode(node: HTMLElement): HTMLInputElement | null { | |
| - return node.querySelector( | |
| - `.${CHECKBOX_WRAPPER_CLASS} input[type=checkbox]` | |
| - ); | |
| + return node.querySelector(`.${CHECKBOX_WRAPPER_CLASS} input[type=checkbox]`); | |
| } | |
| /** | |
| @@ -3513,9 +3452,7 @@ export namespace DirListing { | |
| const icon = DOMUtils.findElement(dragImage, ITEM_ICON_CLASS); | |
| // Hide additional columns from the drag image to keep it unobtrusive. | |
| - const extraColumns = DirListing.columns.filter( | |
| - column => column.id !== 'name' | |
| - ); | |
| + const extraColumns = DirListing.columns.filter(column => column.id !== 'name'); | |
| for (const extraColumn of extraColumns) { | |
| const columnElement = DOMUtils.findElement( | |
| dragImage, | |
| @@ -3600,10 +3537,7 @@ export namespace DirListing { | |
| icon.className = HEADER_ITEM_ICON_CLASS; | |
| for (let k of Object.keys(labels)) { | |
| const text = document.createElement('span'); | |
| - text.classList.add( | |
| - HEADER_ITEM_TEXT_CLASS, | |
| - HEADER_ITEM_TEXT_CLASS + '-' + k | |
| - ); | |
| + text.classList.add(HEADER_ITEM_TEXT_CLASS, HEADER_ITEM_TEXT_CLASS + '-' + k); | |
| text.textContent = labels[k]; | |
| node.appendChild(text); | |
| } | |
| @@ -3726,9 +3660,10 @@ namespace Private { | |
| // Wokaround for Chromium invalid language code on CI, see | |
| // https://github.com/jupyterlab/jupyterlab/issues/17079 | |
| const navigatorLanguage = navigator.language.split('@')[0]; | |
| - const languageCode = ( | |
| - translator.languageCode ?? navigatorLanguage | |
| - ).replace('_', '-'); | |
| + const languageCode = (translator.languageCode ?? navigatorLanguage).replace( | |
| + '_', | |
| + '-' | |
| + ); | |
| const localeOptions: Intl.CollatorOptions = { | |
| numeric: sortFileNamesNaturally, | |
| sensitivity: 'base' | |
| @@ -3743,9 +3678,7 @@ namespace Private { | |
| } | |
| } | |
| - function compare( | |
| - compare: (a: Contents.IModel, b: Contents.IModel) => number | |
| - ) { | |
| + function compare(compare: (a: Contents.IModel, b: Contents.IModel) => number) { | |
| return (a: Contents.IModel, b: Contents.IModel) => { | |
| // Group directory first, then notebooks, then files | |
| if (isPriorityOverridden(a, b)) { | |
| @@ -3768,8 +3701,7 @@ namespace Private { | |
| copy.sort( | |
| compare((a: Contents.IModel, b: Contents.IModel) => { | |
| return ( | |
| - new Date(a.last_modified).getTime() - | |
| - new Date(b.last_modified).getTime() | |
| + new Date(a.last_modified).getTime() - new Date(b.last_modified).getTime() | |
| ); | |
| }) | |
| ); | |
| @@ -3812,15 +3744,11 @@ namespace Private { | |
| /** | |
| * Get the index of the node at a client position, or `-1`. | |
| */ | |
| - export function hitTestNodes( | |
| - nodes: HTMLElement[], | |
| - event: MouseEvent | |
| - ): number { | |
| + export function hitTestNodes(nodes: HTMLElement[], event: MouseEvent): number { | |
| return ArrayExt.findFirstIndex( | |
| nodes, | |
| node => | |
| - ElementExt.hitTest(node, event.clientX, event.clientY) || | |
| - event.target === node | |
| + ElementExt.hitTest(node, event.clientX, event.clientY) || event.target === node | |
| ); | |
| } | |
| @@ -3874,15 +3802,11 @@ namespace Private { | |
| ): entry is FileSystemDirectoryEntry { | |
| return entry.isDirectory; | |
| } | |
| - export function isFileEntry( | |
| - entry: FileSystemEntry | |
| - ): entry is FileSystemFileEntry { | |
| + export function isFileEntry(entry: FileSystemEntry): entry is FileSystemFileEntry { | |
| return entry.isFile; | |
| } | |
| - export function defensiveGetAsEntry( | |
| - item: DataTransferItem | |
| - ): FileSystemEntry | null { | |
| + export function defensiveGetAsEntry(item: DataTransferItem): FileSystemEntry | null { | |
| if (item.webkitGetAsEntry) { | |
| return item.webkitGetAsEntry(); | |
| } | |
| @@ -3924,11 +3848,7 @@ namespace Private { | |
| /** | |
| * Format bytes to human readable string. | |
| */ | |
| -export function formatFileSize( | |
| - bytes: number, | |
| - decimalPoint: number, | |
| - k: number | |
| -): string { | |
| +export function formatFileSize(bytes: number, decimalPoint: number, k: number): string { | |
| // https://www.codexworld.com/how-to/convert-file-size-bytes-kb-mb-gb-javascript/ | |
| if (bytes === 0) { | |
| return '0 B'; | |
| diff --git a/packages/filebrowser/src/model.ts b/packages/filebrowser/src/model.ts | |
| index 7c2e720e82..e2c51f48ff 100644 | |
| --- a/packages/filebrowser/src/model.ts | |
| +++ b/packages/filebrowser/src/model.ts | |
| @@ -290,10 +290,7 @@ export class FileBrowserModel implements IDisposable { | |
| this._pendingPath = null; | |
| this._pending = null; | |
| if (error.response && error.response.status === 404 && path !== '/') { | |
| - error.message = this._trans.__( | |
| - 'Directory not found: "%1"', | |
| - this._model.path | |
| - ); | |
| + error.message = this._trans.__('Directory not found: "%1"', this._model.path); | |
| console.error(error); | |
| this._connectionFailure.emit(error); | |
| return this.cd('/'); | |
| @@ -474,8 +471,7 @@ export class FileBrowserModel implements IDisposable { | |
| uploadPath?: string | |
| ): Promise<Contents.IModel> { | |
| // Gather the file model parameters. | |
| - let path = | |
| - typeof uploadPath === 'undefined' ? this._model.path : uploadPath; | |
| + let path = typeof uploadPath === 'undefined' ? this._model.path : uploadPath; | |
| path = path ? path + '/' + file.name : file.name; | |
| const name = file.name; | |
| const type: Contents.ContentType = 'file'; | |
| @@ -490,8 +486,7 @@ export class FileBrowserModel implements IDisposable { | |
| reader.readAsDataURL(blob); | |
| await new Promise((resolve, reject) => { | |
| reader.onload = resolve; | |
| - reader.onerror = event => | |
| - reject(`Failed to upload "${file.name}":` + event); | |
| + reader.onerror = event => reject(`Failed to upload "${file.name}":` + event); | |
| }); | |
| await this._uploadCheckDisposed(); | |
| @@ -629,13 +624,9 @@ export class FileBrowserModel implements IDisposable { | |
| const { oldValue, newValue } = change; | |
| const prefix = this.driveName.length > 0 ? this.driveName + ':' : ''; | |
| const value = | |
| - oldValue && | |
| - oldValue.path && | |
| - prefix + PathExt.dirname(oldValue.path) === path | |
| + oldValue && oldValue.path && prefix + PathExt.dirname(oldValue.path) === path | |
| ? oldValue | |
| - : newValue && | |
| - newValue.path && | |
| - prefix + PathExt.dirname(newValue.path) === path | |
| + : newValue && newValue.path && prefix + PathExt.dirname(newValue.path) === path | |
| ? newValue | |
| : undefined; | |
| @@ -679,9 +670,7 @@ export class FileBrowserModel implements IDisposable { | |
| private _isDisposed = false; | |
| private _restored = new PromiseDelegate<void>(); | |
| private _uploads: IUploadModel[] = []; | |
| - private _uploadChanged = new Signal<this, IChangedArgs<IUploadModel | null>>( | |
| - this | |
| - ); | |
| + private _uploadChanged = new Signal<this, IChangedArgs<IUploadModel | null>>(this); | |
| private _unloadEventListener: (e: Event) => string | undefined; | |
| private _poll: Poll; | |
| } | |
| diff --git a/packages/filebrowser/src/opendialog.ts b/packages/filebrowser/src/opendialog.ts | |
| index 6269dea5d2..e268207c26 100644 | |
| --- a/packages/filebrowser/src/opendialog.ts | |
| +++ b/packages/filebrowser/src/opendialog.ts | |
| @@ -156,10 +156,7 @@ class OpenDialog extends Dialog<Contents.IModel[]> { | |
| /** | |
| * Open dialog widget | |
| */ | |
| -class OpenDialogBody | |
| - extends Widget | |
| - implements Dialog.IBodyWidget<Contents.IModel[]> | |
| -{ | |
| +class OpenDialogBody extends Widget implements Dialog.IBodyWidget<Contents.IModel[]> { | |
| constructor( | |
| manager: IDocumentManager, | |
| filter?: (value: Contents.IModel) => Partial<IScore> | null, | |
| @@ -244,10 +241,7 @@ class OpenDialogBody | |
| this._ready.resolve(); | |
| }) | |
| .catch(reason => { | |
| - console.error( | |
| - 'Error while creating file browser in open dialog', | |
| - reason | |
| - ); | |
| + console.error('Error while creating file browser in open dialog', reason); | |
| this._ready.reject(void 0); | |
| }); | |
| } | |
| diff --git a/packages/filebrowser/src/tokens.ts b/packages/filebrowser/src/tokens.ts | |
| index 005e47b6da..fd37cc76b6 100644 | |
| --- a/packages/filebrowser/src/tokens.ts | |
| +++ b/packages/filebrowser/src/tokens.ts | |
| @@ -51,10 +51,7 @@ export interface IFileBrowserFactory { | |
| * as the initial ID passed into the factory is used for only one file browser | |
| * instance. | |
| */ | |
| - createFileBrowser( | |
| - id: string, | |
| - options?: IFileBrowserFactory.IOptions | |
| - ): FileBrowser; | |
| + createFileBrowser(id: string, options?: IFileBrowserFactory.IOptions): FileBrowser; | |
| /** | |
| * The widget tracker used by the factory to track file browsers. | |
| diff --git a/packages/filebrowser/style/base.css b/packages/filebrowser/style/base.css | |
| index 0e6ae52e25..d0170eecc9 100644 | |
| --- a/packages/filebrowser/style/base.css | |
| +++ b/packages/filebrowser/style/base.css | |
| @@ -200,17 +200,13 @@ | |
| /* stylelint-disable */ | |
| @container (max-width: 300px) { | |
| /* stylelint-enable */ | |
| - .jp-DirListing-headerItem.jp-id-modified | |
| - > .jp-DirListing-headerItemText-small, | |
| - .jp-DirListing-headerItem.jp-id-filesize | |
| - > .jp-DirListing-headerItemText-small { | |
| + .jp-DirListing-headerItem.jp-id-modified > .jp-DirListing-headerItemText-small, | |
| + .jp-DirListing-headerItem.jp-id-filesize > .jp-DirListing-headerItemText-small { | |
| display: inline; | |
| } | |
| - .jp-DirListing-headerItem.jp-id-modified | |
| - > .jp-DirListing-headerItemText-large, | |
| - .jp-DirListing-headerItem.jp-id-filesize | |
| - > .jp-DirListing-headerItemText-large { | |
| + .jp-DirListing-headerItem.jp-id-modified > .jp-DirListing-headerItemText-large, | |
| + .jp-DirListing-headerItem.jp-id-filesize > .jp-DirListing-headerItemText-large { | |
| display: none; | |
| } | |
| } | |
| @@ -218,13 +214,11 @@ | |
| /* stylelint-disable */ | |
| @container (min-width: 300px) { | |
| /* stylelint-enable */ | |
| - .jp-DirListing-headerItem.jp-id-modified | |
| - > .jp-DirListing-headerItemText-small { | |
| + .jp-DirListing-headerItem.jp-id-modified > .jp-DirListing-headerItemText-small { | |
| display: none; | |
| } | |
| - .jp-DirListing-headerItem.jp-id-modified | |
| - > .jp-DirListing-headerItemText-large { | |
| + .jp-DirListing-headerItem.jp-id-modified > .jp-DirListing-headerItemText-large { | |
| display: inline; | |
| } | |
| } | |
| @@ -232,13 +226,11 @@ | |
| /* stylelint-disable */ | |
| @container (max-width: 100px) { | |
| /* stylelint-enable */ | |
| - .jp-DirListing-headerItem.jp-id-filesize | |
| - > .jp-DirListing-headerItemText-small { | |
| + .jp-DirListing-headerItem.jp-id-filesize > .jp-DirListing-headerItemText-small { | |
| display: inline; | |
| } | |
| - .jp-DirListing-headerItem.jp-id-filesize | |
| - > .jp-DirListing-headerItemText-large { | |
| + .jp-DirListing-headerItem.jp-id-filesize > .jp-DirListing-headerItemText-large { | |
| display: none; | |
| } | |
| } | |
| @@ -246,13 +238,11 @@ | |
| /* stylelint-disable */ | |
| @container (min-width: 100px) { | |
| /* stylelint-enable */ | |
| - .jp-DirListing-headerItem.jp-id-filesize | |
| - > .jp-DirListing-headerItemText-small { | |
| + .jp-DirListing-headerItem.jp-id-filesize > .jp-DirListing-headerItemText-small { | |
| display: none; | |
| } | |
| - .jp-DirListing-headerItem.jp-id-filesize | |
| - > .jp-DirListing-headerItemText-large { | |
| + .jp-DirListing-headerItem.jp-id-filesize > .jp-DirListing-headerItemText-large { | |
| display: inline; | |
| } | |
| } | |
| @@ -436,8 +426,7 @@ | |
| left: -8px; | |
| } | |
| -.jp-DirListing-item.jp-mod-running.jp-mod-selected | |
| - .jp-DirListing-itemIcon::before { | |
| +.jp-DirListing-item.jp-mod-running.jp-mod-selected .jp-DirListing-itemIcon::before { | |
| color: var(--jp-ui-inverse-font-color1); | |
| } | |
| diff --git a/packages/filebrowser/test/browser.spec.ts b/packages/filebrowser/test/browser.spec.ts | |
| index c79383dc75..004f4ae397 100644 | |
| --- a/packages/filebrowser/test/browser.spec.ts | |
| +++ b/packages/filebrowser/test/browser.spec.ts | |
| @@ -110,19 +110,15 @@ describe('filebrowser/browser', () => { | |
| await fileBrowser.selectItemByName(items[0].name); | |
| await selectionChanged; | |
| - const itemNodes = Array.from( | |
| - document.querySelectorAll(`.${ITEM_CLASS}`) | |
| - ); | |
| + const itemNodes = Array.from(document.querySelectorAll(`.${ITEM_CLASS}`)); | |
| expect(itemNodes.length).toBeGreaterThan(1); | |
| selectionChanged = signalToPromise(fileBrowser.selectionChanged); | |
| // Select the second item with shift key to select multiple items | |
| - simulate( | |
| - fileBrowser.node.querySelectorAll(`.${ITEM_CLASS}`)[1]!, | |
| - 'mousedown', | |
| - { shiftKey: true } | |
| - ); | |
| + simulate(fileBrowser.node.querySelectorAll(`.${ITEM_CLASS}`)[1]!, 'mousedown', { | |
| + shiftKey: true | |
| + }); | |
| await selectionChanged; | |
| // Verify that multiple items are selected | |
| @@ -154,10 +150,7 @@ describe('filebrowser/browser', () => { | |
| await fileBrowser.selectItemByName(items[1].name); | |
| - simulate( | |
| - fileBrowser.node.querySelectorAll(`.${ITEM_CLASS}`)[1]!, | |
| - 'mousedown' | |
| - ); | |
| + simulate(fileBrowser.node.querySelectorAll(`.${ITEM_CLASS}`)[1]!, 'mousedown'); | |
| let selectedItems = Array.from(fileBrowser.selectedItems()); | |
| expect(selectedItems.length).toBe(1); | |
| @@ -165,15 +158,11 @@ describe('filebrowser/browser', () => { | |
| const selectionChanged = signalToPromise(fileBrowser.selectionChanged); | |
| // Simulate Ctrl+Space on the focused item | |
| - simulate( | |
| - fileBrowser.node.querySelectorAll(`.${ITEM_CLASS}`)[1]!, | |
| - 'keydown', | |
| - { | |
| - ctrlKey: true, | |
| - key: ' ', | |
| - keyCode: 32 | |
| - } | |
| - ); | |
| + simulate(fileBrowser.node.querySelectorAll(`.${ITEM_CLASS}`)[1]!, 'keydown', { | |
| + ctrlKey: true, | |
| + key: ' ', | |
| + keyCode: 32 | |
| + }); | |
| await selectionChanged; | |
| @@ -190,11 +179,11 @@ describe('filebrowser/browser', () => { | |
| if (!editNode) { | |
| throw new Error('Edit node not found'); | |
| } | |
| - const itemNode = Array.from( | |
| - document.querySelectorAll(`.${ITEM_CLASS}`) | |
| - ).find(el => { | |
| - return el.contains(editNode); | |
| - }); | |
| + const itemNode = Array.from(document.querySelectorAll(`.${ITEM_CLASS}`)).find( | |
| + el => { | |
| + return el.contains(editNode); | |
| + } | |
| + ); | |
| if (!itemNode) { | |
| throw new Error('Item node not found'); | |
| } | |
| @@ -215,11 +204,11 @@ describe('filebrowser/browser', () => { | |
| if (!editNode) { | |
| throw new Error('Edit node not found'); | |
| } | |
| - const itemNode = Array.from( | |
| - document.querySelectorAll(`.${ITEM_CLASS}`) | |
| - ).find(el => { | |
| - return el.contains(editNode); | |
| - }); | |
| + const itemNode = Array.from(document.querySelectorAll(`.${ITEM_CLASS}`)).find( | |
| + el => { | |
| + return el.contains(editNode); | |
| + } | |
| + ); | |
| if (!itemNode) { | |
| throw new Error('Item node not found'); | |
| } | |
| @@ -280,11 +269,11 @@ describe('FileBrowser with Drives', () => { | |
| if (!editNode) { | |
| throw new Error('Edit node not found'); | |
| } | |
| - const itemNode = Array.from( | |
| - document.querySelectorAll(`.${ITEM_CLASS}`) | |
| - ).find(el => { | |
| - return el.contains(editNode); | |
| - }); | |
| + const itemNode = Array.from(document.querySelectorAll(`.${ITEM_CLASS}`)).find( | |
| + el => { | |
| + return el.contains(editNode); | |
| + } | |
| + ); | |
| if (!itemNode) { | |
| throw new Error('Item node not found'); | |
| } | |
| diff --git a/packages/filebrowser/test/crumbs.spec.ts b/packages/filebrowser/test/crumbs.spec.ts | |
| index af33d08aee..244aad4248 100644 | |
| --- a/packages/filebrowser/test/crumbs.spec.ts | |
| +++ b/packages/filebrowser/test/crumbs.spec.ts | |
| @@ -203,13 +203,9 @@ describe('filebrowser/model', () => { | |
| describe('#onAfterAttach()', () => { | |
| it('should post an update request', async () => { | |
| Widget.attach(crumbs, document.body); | |
| - expect(crumbs.methods).toEqual( | |
| - expect.arrayContaining(['onAfterAttach']) | |
| - ); | |
| + expect(crumbs.methods).toEqual(expect.arrayContaining(['onAfterAttach'])); | |
| await framePromise(); | |
| - expect(crumbs.methods).toEqual( | |
| - expect.arrayContaining(['onUpdateRequest']) | |
| - ); | |
| + expect(crumbs.methods).toEqual(expect.arrayContaining(['onUpdateRequest'])); | |
| }); | |
| it('should add event listeners', () => { | |
| @@ -252,9 +248,7 @@ describe('filebrowser/model', () => { | |
| await model.cd('..'); | |
| await framePromise(); | |
| - expect(crumbs.methods).toEqual( | |
| - expect.arrayContaining(['onUpdateRequest']) | |
| - ); | |
| + expect(crumbs.methods).toEqual(expect.arrayContaining(['onUpdateRequest'])); | |
| const items = crumbs.node.querySelectorAll(ITEM_QUERY); | |
| expect(items.length).toBe(3); | |
| model.dispose(); | |
| @@ -330,9 +324,7 @@ describe('filebrowser/model', () => { | |
| // Ellipsis | |
| expect(items[2].querySelector('svg')).not.toBeNull(); | |
| expect(items[3].textContent).toBe(third); | |
| - expect((items[3] as HTMLElement).title).toBe( | |
| - `${first}/${second}/${third}` | |
| - ); | |
| + expect((items[3] as HTMLElement).title).toBe(`${first}/${second}/${third}`); | |
| customCrumbs.minimumLeftItems = 0; | |
| customCrumbs.minimumRightItems = 0; | |
| diff --git a/packages/filebrowser/test/listing.spec.ts b/packages/filebrowser/test/listing.spec.ts | |
| index f530828870..25f9a95296 100644 | |
| --- a/packages/filebrowser/test/listing.spec.ts | |
| +++ b/packages/filebrowser/test/listing.spec.ts | |
| @@ -99,9 +99,7 @@ describe('filebrowser/listing', () => { | |
| it('should enable scrolling when dragging items', () => { | |
| const options = createOptionsForConstructor(); | |
| const dirListing = new DirListing(options); | |
| - expect( | |
| - dirListing.node.querySelector('[data-lm-dragscroll]') | |
| - ).toBeDefined(); | |
| + expect(dirListing.node.querySelector('[data-lm-dragscroll]')).toBeDefined(); | |
| }); | |
| }); | |
| @@ -283,14 +281,8 @@ describe('filebrowser/listing', () => { | |
| // - selected, unselected, unselected, selected | |
| const items = [...dirListing.sortedItems()]; | |
| expect(Object.keys(dirListing['selection'])).toHaveLength(2); | |
| - expect(dirListing['selection']).toHaveProperty( | |
| - [items[0].path], | |
| - true | |
| - ); | |
| - expect(dirListing['selection']).toHaveProperty( | |
| - [items[3].path], | |
| - true | |
| - ); | |
| + expect(dirListing['selection']).toHaveProperty([items[0].path], true); | |
| + expect(dirListing['selection']).toHaveProperty([items[3].path], true); | |
| }); | |
| }); | |
| @@ -312,14 +304,8 @@ describe('filebrowser/listing', () => { | |
| // - selected, unselected, unselected, selected | |
| const items = [...dirListing.sortedItems()]; | |
| expect(Object.keys(dirListing['selection'])).toHaveLength(2); | |
| - expect(dirListing['selection']).toHaveProperty( | |
| - [items[0].path], | |
| - true | |
| - ); | |
| - expect(dirListing['selection']).toHaveProperty( | |
| - [items[3].path], | |
| - true | |
| - ); | |
| + expect(dirListing['selection']).toHaveProperty([items[0].path], true); | |
| + expect(dirListing['selection']).toHaveProperty([items[3].path], true); | |
| }); | |
| }); | |
| @@ -469,14 +455,10 @@ describe('filebrowser/listing', () => { | |
| }); | |
| it('should select first item when nothing is selected', async () => { | |
| - simulate( | |
| - dirListing.node.querySelector(`.${ITEM_TEXT_CLASS}`)!, | |
| - 'keydown', | |
| - { | |
| - key: 'ArrowDown', | |
| - keyCode: 40 | |
| - } | |
| - ); | |
| + simulate(dirListing.node.querySelector(`.${ITEM_TEXT_CLASS}`)!, 'keydown', { | |
| + key: 'ArrowDown', | |
| + keyCode: 40 | |
| + }); | |
| await signalToPromise(dirListing.updated); | |
| const sortedItems = [...dirListing.sortedItems()]; | |
| const selectedItems = [...dirListing.selectedItems()]; | |
| @@ -486,14 +468,10 @@ describe('filebrowser/listing', () => { | |
| it('should select second item once first item is selected', async () => { | |
| dirListing['_selectItem'](0, false); | |
| - simulate( | |
| - dirListing.node.querySelector(`.${ITEM_TEXT_CLASS}`)!, | |
| - 'keydown', | |
| - { | |
| - key: 'ArrowDown', | |
| - keyCode: 40 | |
| - } | |
| - ); | |
| + simulate(dirListing.node.querySelector(`.${ITEM_TEXT_CLASS}`)!, 'keydown', { | |
| + key: 'ArrowDown', | |
| + keyCode: 40 | |
| + }); | |
| await signalToPromise(dirListing.updated); | |
| const sortedItems = [...dirListing.sortedItems()]; | |
| const selectedItems = [...dirListing.selectedItems()]; | |
| @@ -510,15 +488,11 @@ describe('filebrowser/listing', () => { | |
| // - selected, focussed | |
| // - selected | |
| await signalToPromise(dirListing.updated); | |
| - simulate( | |
| - dirListing.node.querySelector(`.${ITEM_TEXT_CLASS}`)!, | |
| - 'keydown', | |
| - { | |
| - key: 'ArrowDown', | |
| - keyCode: 40, | |
| - shiftKey: true | |
| - } | |
| - ); | |
| + simulate(dirListing.node.querySelector(`.${ITEM_TEXT_CLASS}`)!, 'keydown', { | |
| + key: 'ArrowDown', | |
| + keyCode: 40, | |
| + shiftKey: true | |
| + }); | |
| await signalToPromise(dirListing.updated); | |
| // Now it should be: | |
| // - unselected | |
| @@ -560,8 +534,7 @@ describe('filebrowser/listing', () => { | |
| describe('checkboxes', () => { | |
| const ariaSelectAll = 'Select all files and directories'; | |
| const ariaDeselectAll = 'Deselect all files and directories'; | |
| - const ariaSelectFile = (filename: string | null) => | |
| - `Select file "${filename}"`; | |
| + const ariaSelectFile = (filename: string | null) => `Select file "${filename}"`; | |
| const ariaDeselectFile = (filename: string | null) => | |
| `Deselect file "${filename}"`; | |
| @@ -572,9 +545,7 @@ describe('filebrowser/listing', () => { | |
| itemNode | |
| ) as HTMLInputElement; | |
| expect(checkbox.checked).toBe(false); | |
| - const nameNode = dirListing.renderer.getNameNode!( | |
| - itemNode | |
| - ) as HTMLElement; | |
| + const nameNode = dirListing.renderer.getNameNode!(itemNode) as HTMLElement; | |
| expect(checkbox.getAttribute('aria-label')).toBe( | |
| ariaSelectFile(nameNode.textContent) | |
| ); | |
| @@ -591,9 +562,7 @@ describe('filebrowser/listing', () => { | |
| const checkbox = dirListing.renderer.getCheckboxNode!( | |
| itemNode | |
| ) as HTMLInputElement; | |
| - const nameNode = dirListing.renderer.getNameNode!( | |
| - itemNode | |
| - ) as HTMLElement; | |
| + const nameNode = dirListing.renderer.getNameNode!(itemNode) as HTMLElement; | |
| dirListing.selectNext(); | |
| await signalToPromise(dirListing.updated); | |
| expect(checkbox.checked).toBe(true); | |
| @@ -759,9 +728,7 @@ describe('filebrowser/listing', () => { | |
| expect(headerCheckbox.checked).toBe(false); | |
| expect(headerCheckbox!.indeterminate).toBe(false); | |
| expect(Array.from(dirListing.selectedItems())).toHaveLength(0); | |
| - expect(headerCheckbox.getAttribute('aria-label')).toBe( | |
| - ariaSelectAll | |
| - ); | |
| + expect(headerCheckbox.getAttribute('aria-label')).toBe(ariaSelectAll); | |
| }; | |
| it('should check all', async () => { | |
| expectInitialConditions(); | |
| @@ -773,9 +740,7 @@ describe('filebrowser/listing', () => { | |
| expect(headerCheckbox.checked).toBe(true); | |
| expect(headerCheckbox.indeterminate).toBe(false); | |
| expect(Array.from(dirListing.selectedItems())).toHaveLength(4); | |
| - expect(headerCheckbox.getAttribute('aria-label')).toBe( | |
| - ariaDeselectAll | |
| - ); | |
| + expect(headerCheckbox.getAttribute('aria-label')).toBe(ariaDeselectAll); | |
| }); | |
| }); | |
| @@ -792,9 +757,7 @@ describe('filebrowser/listing', () => { | |
| expect(headerCheckbox.indeterminate).toBe(true); | |
| expect(headerCheckbox.checked).toBe(false); | |
| expect(Array.from(dirListing.selectedItems())).toHaveLength(1); | |
| - expect(headerCheckbox.getAttribute('aria-label')).toBe( | |
| - ariaDeselectAll | |
| - ); | |
| + expect(headerCheckbox.getAttribute('aria-label')).toBe(ariaDeselectAll); | |
| }; | |
| it('should uncheck all', async () => { | |
| expectInitialConditions(); | |
| @@ -806,9 +769,7 @@ describe('filebrowser/listing', () => { | |
| expect(headerCheckbox.checked).toBe(false); | |
| expect(headerCheckbox.indeterminate).toBe(false); | |
| expect(Array.from(dirListing.selectedItems())).toHaveLength(0); | |
| - expect(headerCheckbox.getAttribute('aria-label')).toBe( | |
| - ariaSelectAll | |
| - ); | |
| + expect(headerCheckbox.getAttribute('aria-label')).toBe(ariaSelectAll); | |
| }); | |
| }); | |
| diff --git a/packages/filebrowser/test/model.spec.ts b/packages/filebrowser/test/model.spec.ts | |
| index f5283c55b9..c86cdf255c 100644 | |
| --- a/packages/filebrowser/test/model.spec.ts | |
| +++ b/packages/filebrowser/test/model.spec.ts | |
| @@ -27,10 +27,7 @@ import { CHUNK_SIZE, FileBrowserModel, LARGE_FILE_SIZE } from '../src'; | |
| * in order to simulate out-of-order responses from the server. | |
| */ | |
| class DelayedContentsManager extends ContentsManagerMock { | |
| - get( | |
| - path: string, | |
| - options?: Contents.IFetchOptions | |
| - ): Promise<Contents.IModel> { | |
| + get(path: string, options?: Contents.IFetchOptions): Promise<Contents.IModel> { | |
| return new Promise<Contents.IModel>(resolve => { | |
| const delay = this._delay; | |
| this._delay -= 500; | |
| @@ -459,8 +456,7 @@ describe('filebrowser/model', () => { | |
| const file = new File([content], fname, { type: 'text/plain' }); | |
| await model.upload(file); | |
| // Ensure we get the file back. | |
| - const contentModel = | |
| - await model.manager.services.contents.get(fname); | |
| + const contentModel = await model.manager.services.contents.get(fname); | |
| expect(contentModel.content.length).toBeGreaterThan(0); | |
| }); | |
| } | |
| @@ -485,9 +481,7 @@ describe('filebrowser/model', () => { | |
| newValue: { path: fname, progress: 0 } | |
| } | |
| ]); | |
| - expect(Array.from(model.uploads())).toEqual([ | |
| - { path: fname, progress: 0 } | |
| - ]); | |
| + expect(Array.from(model.uploads())).toEqual([{ path: fname, progress: 0 }]); | |
| expect(await first).toEqual([ | |
| model, | |
| { | |
| @@ -496,9 +490,7 @@ describe('filebrowser/model', () => { | |
| newValue: { path: fname, progress: 0 } | |
| } | |
| ]); | |
| - expect(Array.from(model.uploads())).toEqual([ | |
| - { path: fname, progress: 0 } | |
| - ]); | |
| + expect(Array.from(model.uploads())).toEqual([{ path: fname, progress: 0 }]); | |
| expect(await second).toEqual([ | |
| model, | |
| { | |
| diff --git a/packages/filebrowser/test/openfiledialog.spec.ts b/packages/filebrowser/test/openfiledialog.spec.ts | |
| index 114815246f..9a1343c1fd 100644 | |
| --- a/packages/filebrowser/test/openfiledialog.spec.ts | |
| +++ b/packages/filebrowser/test/openfiledialog.spec.ts | |
| @@ -111,22 +111,17 @@ describe('@jupyterlab/filebrowser', () => { | |
| it('should respect the filter', async () => { | |
| const filteredModel = new FilterFileBrowserModel({ | |
| manager, | |
| - filter: (model: Contents.IModel) => | |
| - model.type === 'notebook' ? {} : null | |
| + filter: (model: Contents.IModel) => (model.type === 'notebook' ? {} : null) | |
| }); | |
| await filteredModel.cd(); | |
| const model = new FileBrowserModel({ manager }); | |
| await model.cd(); | |
| - const filteredItems = Array.from( | |
| - filteredModel.items() | |
| - ) as Contents.IModel[]; | |
| + const filteredItems = Array.from(filteredModel.items()) as Contents.IModel[]; | |
| const items = Array.from(model.items()); | |
| const shownItems = items.filter(item => item.type === 'notebook'); | |
| expect(filteredItems.length).toBe(shownItems.length); | |
| - const notebooks = filteredItems.filter( | |
| - item => item.type === 'notebook' | |
| - ); | |
| + const notebooks = filteredItems.filter(item => item.type === 'notebook'); | |
| expect(notebooks.length).toBeGreaterThan(0); | |
| }); | |
| }); | |
| @@ -155,8 +150,7 @@ describe('@jupyterlab/filebrowser', () => { | |
| manager, | |
| title: 'Select a notebook', | |
| host: node, | |
| - filter: (value: Contents.IModel) => | |
| - value.type === 'notebook' ? {} : null | |
| + filter: (value: Contents.IModel) => (value.type === 'notebook' ? {} : null) | |
| }); | |
| await acceptDialog(); | |
| @@ -179,8 +173,7 @@ describe('@jupyterlab/filebrowser', () => { | |
| manager, | |
| title: 'Select a notebook', | |
| host: node, | |
| - filter: (value: Contents.IModel) => | |
| - value.type === 'notebook' ? {} : null | |
| + filter: (value: Contents.IModel) => (value.type === 'notebook' ? {} : null) | |
| }); | |
| await waitForDialog(); | |
| @@ -225,8 +218,7 @@ describe('@jupyterlab/filebrowser', () => { | |
| manager, | |
| title: 'Select a notebook', | |
| host: node, | |
| - filter: (value: Contents.IModel) => | |
| - value.type === 'notebook' ? {} : null | |
| + filter: (value: Contents.IModel) => (value.type === 'notebook' ? {} : null) | |
| }); | |
| await waitForDialog(); | |
| @@ -289,8 +281,7 @@ describe('@jupyterlab/filebrowser', () => { | |
| title: 'Select a notebook', | |
| host: node, | |
| defaultPath: testDirectory, | |
| - filter: (value: Contents.IModel) => | |
| - value.type === 'notebook' ? {} : null | |
| + filter: (value: Contents.IModel) => (value.type === 'notebook' ? {} : null) | |
| }); | |
| await waitForDialog(); | |
| @@ -402,9 +393,7 @@ describe('@jupyterlab/filebrowser', () => { | |
| const files = result.value!; | |
| expect(files.length).toBe(1); | |
| expect(files[0].type).toBe('directory'); | |
| - expect(files[0].name).toEqual( | |
| - expect.stringMatching(/Untitled Folder( \d+)?/) | |
| - ); | |
| + expect(files[0].name).toEqual(expect.stringMatching(/Untitled Folder( \d+)?/)); | |
| document.body.removeChild(node); | |
| }); | |
| @@ -462,9 +451,7 @@ describe('@jupyterlab/filebrowser', () => { | |
| const files = result.value!; | |
| expect(files.length).toBe(1); | |
| expect(files[0].type).toBe('directory'); | |
| - expect(files[0].name).toEqual( | |
| - expect.stringMatching(/Untitled Folder( \d+)?/) | |
| - ); | |
| + expect(files[0].name).toEqual(expect.stringMatching(/Untitled Folder( \d+)?/)); | |
| const parentDirectory = PathExt.dirname(files[0].path); | |
| expect(parentDirectory).toEqual(testDirectory); | |
| diff --git a/packages/fileeditor-extension/src/commands.ts b/packages/fileeditor-extension/src/commands.ts | |
| index dfb04347c6..b11e74c3d2 100644 | |
| --- a/packages/fileeditor-extension/src/commands.ts | |
| +++ b/packages/fileeditor-extension/src/commands.ts | |
| @@ -10,10 +10,7 @@ import type { | |
| } from '@jupyterlab/apputils'; | |
| import { Clipboard, MainAreaWidget } from '@jupyterlab/apputils'; | |
| import type { CodeEditor, IEditorServices } from '@jupyterlab/codeeditor'; | |
| -import { | |
| - CodeViewerWidget, | |
| - IEditorMimeTypeService | |
| -} from '@jupyterlab/codeeditor'; | |
| +import { CodeViewerWidget, IEditorMimeTypeService } from '@jupyterlab/codeeditor'; | |
| import type { | |
| CodeMirrorEditor, | |
| IEditorExtensionRegistry, | |
| @@ -73,8 +70,7 @@ export namespace CommandIDs { | |
| export const matchBrackets = 'fileeditor:toggle-match-brackets'; | |
| - export const currentMatchBrackets = | |
| - 'fileeditor:toggle-current-match-brackets'; | |
| + export const currentMatchBrackets = 'fileeditor:toggle-current-match-brackets'; | |
| export const autoClosingBrackets = 'fileeditor:toggle-autoclosing-brackets'; | |
| @@ -174,8 +170,7 @@ export namespace Commands { | |
| settings: ISettingRegistry.ISettings, | |
| commands: CommandRegistry | |
| ): void { | |
| - config = | |
| - (settings.get('editorConfig').composite as Record<string, any>) ?? {}; | |
| + config = (settings.get('editorConfig').composite as Record<string, any>) ?? {}; | |
| scrollPastEnd = settings.get('scrollPastEnd').composite as boolean; | |
| // Trigger a refresh of the rendered commands | |
| @@ -235,16 +230,11 @@ export namespace Commands { | |
| execute: args => { | |
| const delta = Number(args['delta']); | |
| if (Number.isNaN(delta)) { | |
| - console.error( | |
| - `${CommandIDs.changeFontSize}: delta arg must be a number` | |
| - ); | |
| + console.error(`${CommandIDs.changeFontSize}: delta arg must be a number`); | |
| return; | |
| } | |
| const style = window.getComputedStyle(document.documentElement); | |
| - const cssSize = parseInt( | |
| - style.getPropertyValue('--jp-code-font-size'), | |
| - 10 | |
| - ); | |
| + const cssSize = parseInt(style.getPropertyValue('--jp-code-font-size'), 10); | |
| if (!config.customStyles) { | |
| config.customStyles = {}; | |
| } | |
| @@ -286,9 +276,7 @@ export namespace Commands { | |
| }, | |
| isMenu: { | |
| type: 'boolean', | |
| - description: trans.__( | |
| - 'Whether the command is called from a menu context' | |
| - ) | |
| + description: trans.__('Whether the command is called from a menu context') | |
| } | |
| }, | |
| required: ['delta'] | |
| @@ -311,8 +299,7 @@ export namespace Commands { | |
| } | |
| }, | |
| isEnabled, | |
| - isToggled: () => | |
| - config.lineNumbers ?? extensions.baseConfiguration.lineNumbers, | |
| + isToggled: () => config.lineNumbers ?? extensions.baseConfiguration.lineNumbers, | |
| label: trans.__('Show Line Numbers'), | |
| describedBy: { | |
| args: { | |
| @@ -337,9 +324,8 @@ export namespace Commands { | |
| isToggled: () => { | |
| const widget = tracker.currentWidget; | |
| return ( | |
| - (widget?.content.editor.getOption('lineNumbers') as | |
| - | boolean | |
| - | undefined) ?? false | |
| + (widget?.content.editor.getOption('lineNumbers') as boolean | undefined) ?? | |
| + false | |
| ); | |
| }, | |
| describedBy: { | |
| @@ -365,10 +351,7 @@ export namespace Commands { | |
| isEnabled, | |
| isToggled: args => { | |
| const lineWrap = args['mode'] ?? false; | |
| - return ( | |
| - lineWrap === | |
| - (config.lineWrap ?? extensions.baseConfiguration.lineWrap) | |
| - ); | |
| + return lineWrap === (config.lineWrap ?? extensions.baseConfiguration.lineWrap); | |
| }, | |
| label: trans.__('Word Wrap'), | |
| describedBy: { | |
| @@ -398,9 +381,7 @@ export namespace Commands { | |
| isEnabled, | |
| isToggled: () => { | |
| const widget = tracker.currentWidget; | |
| - return ( | |
| - (widget?.content.editor.getOption('lineWrap') as boolean) ?? false | |
| - ); | |
| + return (widget?.content.editor.getOption('lineWrap') as boolean) ?? false; | |
| }, | |
| describedBy: { | |
| args: { | |
| @@ -497,9 +478,8 @@ export namespace Commands { | |
| isToggled: () => { | |
| const widget = tracker.currentWidget; | |
| return ( | |
| - (widget?.content.editor.getOption('matchBrackets') as | |
| - | boolean | |
| - | undefined) ?? false | |
| + (widget?.content.editor.getOption('matchBrackets') as boolean | undefined) ?? | |
| + false | |
| ); | |
| }, | |
| describedBy: { | |
| @@ -530,17 +510,14 @@ export namespace Commands { | |
| }, | |
| label: trans.__('Auto Close Brackets in Text Editor'), | |
| isToggled: () => | |
| - config.autoClosingBrackets ?? | |
| - extensions.baseConfiguration.autoClosingBrackets, | |
| + config.autoClosingBrackets ?? extensions.baseConfiguration.autoClosingBrackets, | |
| describedBy: { | |
| args: { | |
| type: 'object', | |
| properties: { | |
| force: { | |
| type: 'boolean', | |
| - description: trans.__( | |
| - 'Force enable/disable auto closing brackets' | |
| - ) | |
| + description: trans.__('Force enable/disable auto closing brackets') | |
| } | |
| } | |
| } | |
| @@ -688,8 +665,7 @@ export namespace Commands { | |
| if (spec) { | |
| if (Array.isArray(spec.mime)) { | |
| widget.content.model.mimeType = | |
| - (spec.mime[0] as string) ?? | |
| - IEditorMimeTypeService.defaultMimeType; | |
| + (spec.mime[0] as string) ?? IEditorMimeTypeService.defaultMimeType; | |
| } else { | |
| widget.content.model.mimeType = spec.mime as string; | |
| } | |
| @@ -745,9 +721,7 @@ export namespace Commands { | |
| properties: { | |
| text: { | |
| type: 'string', | |
| - description: trans.__( | |
| - 'The text to replace the current selection with' | |
| - ) | |
| + description: trans.__('The text to replace the current selection with') | |
| } | |
| } | |
| } | |
| @@ -942,9 +916,7 @@ export namespace Commands { | |
| }, | |
| isVisible: () => { | |
| const widget = tracker.currentWidget; | |
| - return ( | |
| - (widget && PathExt.extname(widget.context.path) === '.md') || false | |
| - ); | |
| + return (widget && PathExt.extname(widget.context.path) === '.md') || false; | |
| }, | |
| icon: markdownIcon, | |
| label: trans.__('Show Markdown Preview'), | |
| @@ -968,8 +940,7 @@ export namespace Commands { | |
| } | |
| return (args.launcherLabel as string) ?? trans.__('Text File'); | |
| }, | |
| - caption: args => | |
| - (args.caption as string) ?? trans.__('Create a new text file'), | |
| + caption: args => (args.caption as string) ?? trans.__('Create a new text file'), | |
| icon: args => | |
| args.isPalette | |
| ? undefined | |
| @@ -978,11 +949,7 @@ export namespace Commands { | |
| }), | |
| execute: args => { | |
| const cwd = args.cwd || (defaultBrowser?.model.path ?? '.'); | |
| - return createNew( | |
| - commands, | |
| - cwd as string, | |
| - (args.fileExt as string) ?? 'txt' | |
| - ); | |
| + return createNew(commands, cwd as string, (args.fileExt as string) ?? 'txt'); | |
| }, | |
| describedBy: { | |
| args: { | |
| @@ -1027,9 +994,7 @@ export namespace Commands { | |
| */ | |
| commands.addCommand(CommandIDs.createNewMarkdown, { | |
| label: args => | |
| - args['isPalette'] | |
| - ? trans.__('New Markdown File') | |
| - : trans.__('Markdown File'), | |
| + args['isPalette'] ? trans.__('New Markdown File') : trans.__('Markdown File'), | |
| caption: trans.__('Create a new markdown file'), | |
| icon: args => (args['isPalette'] ? undefined : markdownIcon), | |
| execute: args => { | |
| @@ -1306,8 +1271,7 @@ export namespace Commands { | |
| commands.addCommand(CommandIDs.invokeCompleter, { | |
| label: trans.__('Display the completion helper.'), | |
| execute: () => { | |
| - const id = | |
| - editorTracker.currentWidget && editorTracker.currentWidget.id; | |
| + const id = editorTracker.currentWidget && editorTracker.currentWidget.id; | |
| if (id) { | |
| return manager.invoke(id); | |
| } | |
| @@ -1323,8 +1287,7 @@ export namespace Commands { | |
| commands.addCommand(CommandIDs.selectCompleter, { | |
| label: trans.__('Select the completion suggestion.'), | |
| execute: () => { | |
| - const id = | |
| - editorTracker.currentWidget && editorTracker.currentWidget.id; | |
| + const id = editorTracker.currentWidget && editorTracker.currentWidget.id; | |
| if (id) { | |
| return manager.select(id); | |
| } | |
| @@ -1753,9 +1716,7 @@ export namespace Commands { | |
| }, | |
| extension: { | |
| type: 'string', | |
| - description: trans.__( | |
| - 'The file extension to derive MIME type from' | |
| - ) | |
| + description: trans.__('The file extension to derive MIME type from') | |
| }, | |
| widgetId: { | |
| type: 'string', | |
| diff --git a/packages/fileeditor-extension/src/index.ts b/packages/fileeditor-extension/src/index.ts | |
| index 9689cb3698..695038fcb7 100644 | |
| --- a/packages/fileeditor-extension/src/index.ts | |
| +++ b/packages/fileeditor-extension/src/index.ts | |
| @@ -5,10 +5,7 @@ | |
| * @module fileeditor-extension | |
| */ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { ILayoutRestorer } from '@jupyterlab/application'; | |
| import type { MainAreaWidget } from '@jupyterlab/apputils'; | |
| import { | |
| @@ -30,10 +27,7 @@ import { | |
| } from '@jupyterlab/codemirror'; | |
| import { ICompletionProviderManager } from '@jupyterlab/completer'; | |
| import { IConsoleTracker } from '@jupyterlab/console'; | |
| -import type { | |
| - DocumentRegistry, | |
| - IDocumentWidget | |
| -} from '@jupyterlab/docregistry'; | |
| +import type { DocumentRegistry, IDocumentWidget } from '@jupyterlab/docregistry'; | |
| import { getAvailableKernelFileTypes } from '@jupyterlab/docregistry'; | |
| import { ISearchProviderRegistry } from '@jupyterlab/documentsearch'; | |
| import { IDefaultFileBrowser } from '@jupyterlab/filebrowser'; | |
| @@ -170,12 +164,7 @@ export const tabSpaceStatus: JupyterFrontEndPlugin<void> = { | |
| id: '@jupyterlab/fileeditor-extension:tab-space-status', | |
| description: 'Adds a file editor indentation status widget.', | |
| autoStart: true, | |
| - requires: [ | |
| - IEditorTracker, | |
| - IEditorExtensionRegistry, | |
| - ISettingRegistry, | |
| - ITranslator | |
| - ], | |
| + requires: [IEditorTracker, IEditorExtensionRegistry, ISettingRegistry, ITranslator], | |
| optional: [IStatusBar], | |
| activate: ( | |
| app: JupyterFrontEnd, | |
| @@ -227,19 +216,14 @@ export const tabSpaceStatus: JupyterFrontEndPlugin<void> = { | |
| }); | |
| // Add the status item. | |
| - statusBar.registerStatusItem( | |
| - '@jupyterlab/fileeditor-extension:tab-space-status', | |
| - { | |
| - item, | |
| - align: 'right', | |
| - rank: 1, | |
| - isActive: () => { | |
| - return ( | |
| - !!shell.currentWidget && editorTracker.has(shell.currentWidget) | |
| - ); | |
| - } | |
| + statusBar.registerStatusItem('@jupyterlab/fileeditor-extension:tab-space-status', { | |
| + item, | |
| + align: 'right', | |
| + rank: 1, | |
| + isActive: () => { | |
| + return !!shell.currentWidget && editorTracker.has(shell.currentWidget); | |
| } | |
| - ); | |
| + }); | |
| } | |
| }; | |
| @@ -342,8 +326,7 @@ function activate( | |
| ): IEditorTracker { | |
| const id = plugin.id; | |
| const translator = translator_ ?? nullTranslator; | |
| - const sessionDialogs = | |
| - sessionDialogs_ ?? new SessionContextDialogs({ translator }); | |
| + const sessionDialogs = sessionDialogs_ ?? new SessionContextDialogs({ translator }); | |
| const trans = translator.load('jupyterlab'); | |
| const namespace = 'editor'; | |
| @@ -352,16 +335,13 @@ function activate( | |
| namespace | |
| }); | |
| const isEnabled = () => | |
| - tracker.currentWidget !== null && | |
| - tracker.currentWidget === shell.currentWidget; | |
| + tracker.currentWidget !== null && tracker.currentWidget === shell.currentWidget; | |
| let launcherDisposables: IDisposable | null = null; | |
| let paletteDisposables: IDisposable | null = null; | |
| let menuDisposables: IDisposable | null = null; | |
| - const updateKernelFileTypeComponents = ( | |
| - fileTypes: Set<IRenderMime.IFileType> | |
| - ) => { | |
| + const updateKernelFileTypeComponents = (fileTypes: Set<IRenderMime.IFileType>) => { | |
| // Dispose of previous entries if they exist | |
| if (launcherDisposables) { | |
| launcherDisposables.dispose(); | |
| @@ -395,11 +375,7 @@ function activate( | |
| } | |
| if (menu) { | |
| - menuDisposables = Commands.addKernelLanguageMenuItems( | |
| - menu, | |
| - trans, | |
| - fileTypes | |
| - ); | |
| + menuDisposables = Commands.addKernelLanguageMenuItems(menu, trans, fileTypes); | |
| } | |
| }; | |
| @@ -478,8 +454,7 @@ function activate( | |
| // Add go to line capabilities to the edit menu. | |
| menu.editMenu.goToLiners.add({ | |
| id: CommandIDs.goToLine, | |
| - isEnabled: (w: Widget) => | |
| - tracker.currentWidget !== null && tracker.has(w) | |
| + isEnabled: (w: Widget) => tracker.currentWidget !== null && tracker.has(w) | |
| }); | |
| } | |
| @@ -536,9 +511,9 @@ function activate( | |
| app.shell | |
| ); | |
| - const codeViewerTracker = new WidgetTracker<MainAreaWidget<CodeViewerWidget>>( | |
| - { namespace: 'codeviewer' } | |
| - ); | |
| + const codeViewerTracker = new WidgetTracker<MainAreaWidget<CodeViewerWidget>>({ | |
| + namespace: 'codeviewer' | |
| + }); | |
| // Handle state restoration for code viewers | |
| if (restorer) { | |
| @@ -554,12 +529,7 @@ function activate( | |
| }); | |
| } | |
| - Commands.addOpenCodeViewerCommand( | |
| - app, | |
| - editorServices, | |
| - codeViewerTracker, | |
| - trans | |
| - ); | |
| + Commands.addOpenCodeViewerCommand(app, editorServices, codeViewerTracker, trans); | |
| // Add a launcher item if the launcher is available. | |
| if (launcher) { | |
| @@ -603,12 +573,7 @@ function activateFileEditorCompleterService( | |
| return; | |
| } | |
| - Commands.addCompleterCommands( | |
| - app.commands, | |
| - editorTracker, | |
| - manager, | |
| - translator | |
| - ); | |
| + Commands.addCompleterCommands(app.commands, editorTracker, manager, translator); | |
| const sessionManager = app.serviceManager.sessions; | |
| const sanitizer = appSanitizer ?? new Sanitizer(); | |
| const _activeSessions = new Map<string, Session.ISessionConnection>(); | |
| @@ -622,10 +587,7 @@ function activateFileEditorCompleterService( | |
| }; | |
| await manager.updateCompleter(completerContext); | |
| - const onRunningChanged = ( | |
| - _: Session.IManager, | |
| - models: Session.IModel[] | |
| - ) => { | |
| + const onRunningChanged = (_: Session.IManager, models: Session.IModel[]) => { | |
| const oldSession = _activeSessions.get(widget.id); | |
| // Search for a matching path. | |
| const model = find(models, m => m.path === widget.context.path); | |
| diff --git a/packages/fileeditor-extension/src/syntaxstatus.ts b/packages/fileeditor-extension/src/syntaxstatus.ts | |
| index c25e5ef842..ba44a490e5 100644 | |
| --- a/packages/fileeditor-extension/src/syntaxstatus.ts | |
| +++ b/packages/fileeditor-extension/src/syntaxstatus.ts | |
| @@ -3,10 +3,7 @@ | |
| * Distributed under the terms of the Modified BSD License. | |
| */ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { ILabShell } from '@jupyterlab/application'; | |
| import { IEditorLanguageRegistry } from '@jupyterlab/codemirror'; | |
| import type { IDocumentWidget } from '@jupyterlab/docregistry'; | |
| @@ -44,9 +41,7 @@ export const editorSyntaxStatus: JupyterFrontEndPlugin<void> = { | |
| labShell.currentChanged.connect(() => { | |
| const current = labShell.currentWidget; | |
| if (current && tracker.has(current) && item.model) { | |
| - item.model.editor = ( | |
| - current as IDocumentWidget<FileEditor> | |
| - ).content.editor; | |
| + item.model.editor = (current as IDocumentWidget<FileEditor>).content.editor; | |
| } | |
| }); | |
| statusBar.registerStatusItem(editorSyntaxStatus.id, { | |
| diff --git a/packages/fileeditor/src/fileeditorlspadapter.ts b/packages/fileeditor/src/fileeditorlspadapter.ts | |
| index 8c5a02e460..9a983db4cf 100644 | |
| --- a/packages/fileeditor/src/fileeditorlspadapter.ts | |
| +++ b/packages/fileeditor/src/fileeditorlspadapter.ts | |
| @@ -3,15 +3,8 @@ | |
| import { IEditorMimeTypeService } from '@jupyterlab/codeeditor'; | |
| import type { CodeMirrorEditor } from '@jupyterlab/codemirror'; | |
| -import type { | |
| - DocumentRegistry, | |
| - IDocumentWidget | |
| -} from '@jupyterlab/docregistry'; | |
| -import type { | |
| - Document, | |
| - IAdapterOptions, | |
| - IVirtualPosition | |
| -} from '@jupyterlab/lsp'; | |
| +import type { DocumentRegistry, IDocumentWidget } from '@jupyterlab/docregistry'; | |
| +import type { Document, IAdapterOptions, IVirtualPosition } from '@jupyterlab/lsp'; | |
| import { VirtualDocument, WidgetLSPAdapter } from '@jupyterlab/lsp'; | |
| import { PromiseDelegate } from '@lumino/coreutils'; | |
| @@ -24,9 +17,7 @@ export interface IFileEditorAdapterOptions extends IAdapterOptions { | |
| docRegistry: DocumentRegistry; | |
| } | |
| -export class FileEditorAdapter extends WidgetLSPAdapter< | |
| - IDocumentWidget<FileEditor> | |
| -> { | |
| +export class FileEditorAdapter extends WidgetLSPAdapter<IDocumentWidget<FileEditor>> { | |
| constructor( | |
| editorWidget: IDocumentWidget<FileEditor>, | |
| options: IFileEditorAdapterOptions | |
| diff --git a/packages/fileeditor/src/searchprovider.ts b/packages/fileeditor/src/searchprovider.ts | |
| index f24f500936..aea756e30b 100644 | |
| --- a/packages/fileeditor/src/searchprovider.ts | |
| +++ b/packages/fileeditor/src/searchprovider.ts | |
| @@ -61,10 +61,7 @@ export class FileEditorSearchProvider | |
| return this.widget.content.model; | |
| } | |
| - async startQuery( | |
| - query: RegExp, | |
| - filters: IFilters | undefined | |
| - ): Promise<void> { | |
| + async startQuery(query: RegExp, filters: IFilters | undefined): Promise<void> { | |
| this._searchActive = true; | |
| await super.startQuery(query, filters); | |
| await this.highlightNext(true, { | |
| @@ -109,10 +106,7 @@ export class FileEditorSearchProvider | |
| * | |
| * @returns The search provider on the widget | |
| */ | |
| - static createNew( | |
| - widget: FileEditorPanel, | |
| - translator?: ITranslator | |
| - ): ISearchProvider { | |
| + static createNew(widget: FileEditorPanel, translator?: ITranslator): ISearchProvider { | |
| return new FileEditorSearchProvider(widget); | |
| } | |
| diff --git a/packages/fileeditor/src/tabspacestatus.tsx b/packages/fileeditor/src/tabspacestatus.tsx | |
| index 7cecebfea9..d3111390a2 100644 | |
| --- a/packages/fileeditor/src/tabspacestatus.tsx | |
| +++ b/packages/fileeditor/src/tabspacestatus.tsx | |
| @@ -46,9 +46,7 @@ function TabSpaceComponent( | |
| const translator = props.translator || nullTranslator; | |
| const trans = translator.load('jupyterlab'); | |
| const description = | |
| - typeof props.tabSpace === 'number' | |
| - ? trans.__('Spaces') | |
| - : trans.__('Tab Indent'); | |
| + typeof props.tabSpace === 'number' ? trans.__('Spaces') : trans.__('Tab Indent'); | |
| return ( | |
| <TextItem | |
| role="button" | |
| @@ -92,9 +90,7 @@ export class TabSpaceStatus extends VDomRenderer<TabSpaceStatus.Model> { | |
| return null; | |
| } else { | |
| const tabSpace = | |
| - this.model.indentUnit === 'Tab' | |
| - ? null | |
| - : parseInt(this.model.indentUnit, 10); | |
| + this.model.indentUnit === 'Tab' ? null : parseInt(this.model.indentUnit, 10); | |
| return ( | |
| <TabSpaceComponent | |
| tabSpace={tabSpace} | |
| diff --git a/packages/fileeditor/src/toc/factory.ts b/packages/fileeditor/src/toc/factory.ts | |
| index 9a477f7452..ff90094ab1 100644 | |
| --- a/packages/fileeditor/src/toc/factory.ts | |
| +++ b/packages/fileeditor/src/toc/factory.ts | |
| @@ -1,10 +1,7 @@ | |
| // Copyright (c) Jupyter Development Team. | |
| // Distributed under the terms of the Modified BSD License. | |
| -import type { | |
| - DocumentRegistry, | |
| - IDocumentWidget | |
| -} from '@jupyterlab/docregistry'; | |
| +import type { DocumentRegistry, IDocumentWidget } from '@jupyterlab/docregistry'; | |
| import type { TableOfContents, TableOfContentsModel } from '@jupyterlab/toc'; | |
| import { TableOfContentsFactory } from '@jupyterlab/toc'; | |
| import type { FileEditor } from '../widget'; | |
| diff --git a/packages/fileeditor/src/toc/latex.ts b/packages/fileeditor/src/toc/latex.ts | |
| index 29fa90a5ef..fedc95d45e 100644 | |
| --- a/packages/fileeditor/src/toc/latex.ts | |
| +++ b/packages/fileeditor/src/toc/latex.ts | |
| @@ -1,10 +1,7 @@ | |
| // Copyright (c) Jupyter Development Team. | |
| // Distributed under the terms of the Modified BSD License. | |
| -import type { | |
| - DocumentRegistry, | |
| - IDocumentWidget | |
| -} from '@jupyterlab/docregistry'; | |
| +import type { DocumentRegistry, IDocumentWidget } from '@jupyterlab/docregistry'; | |
| import type { TableOfContents } from '@jupyterlab/toc'; | |
| import { TableOfContentsModel, TableOfContentsUtils } from '@jupyterlab/toc'; | |
| import type { Widget } from '@lumino/widgets'; | |
| @@ -84,17 +81,12 @@ export class LaTeXTableOfContentsModel extends TableOfContentsModel< | |
| if (match) { | |
| const level = LATEX_LEVELS[match[1]]; | |
| if (level <= this.configuration.maximalDepth) { | |
| - const prefix = TableOfContentsUtils.getPrefix( | |
| - level, | |
| - previousLevel, | |
| - levels, | |
| - { | |
| - ...this.configuration, | |
| - // Force base numbering and numbering first level | |
| - baseNumbering: 1, | |
| - numberingH1: true | |
| - } | |
| - ); | |
| + const prefix = TableOfContentsUtils.getPrefix(level, previousLevel, levels, { | |
| + ...this.configuration, | |
| + // Force base numbering and numbering first level | |
| + baseNumbering: 1, | |
| + numberingH1: true | |
| + }); | |
| previousLevel = level; | |
| headings.push({ | |
| diff --git a/packages/fileeditor/src/toc/markdown.ts b/packages/fileeditor/src/toc/markdown.ts | |
| index ea3ca7d2aa..aa1cb3670d 100644 | |
| --- a/packages/fileeditor/src/toc/markdown.ts | |
| +++ b/packages/fileeditor/src/toc/markdown.ts | |
| @@ -2,10 +2,7 @@ | |
| // Distributed under the terms of the Modified BSD License. | |
| import type { WidgetTracker } from '@jupyterlab/apputils'; | |
| -import type { | |
| - DocumentRegistry, | |
| - IDocumentWidget | |
| -} from '@jupyterlab/docregistry'; | |
| +import type { DocumentRegistry, IDocumentWidget } from '@jupyterlab/docregistry'; | |
| import type { IMarkdownParser } from '@jupyterlab/rendermime'; | |
| import type { TableOfContents } from '@jupyterlab/toc'; | |
| import { TableOfContentsModel, TableOfContentsUtils } from '@jupyterlab/toc'; | |
| diff --git a/packages/fileeditor/src/toc/python.ts b/packages/fileeditor/src/toc/python.ts | |
| index 8f86bc5b4c..c0f96546cc 100644 | |
| --- a/packages/fileeditor/src/toc/python.ts | |
| +++ b/packages/fileeditor/src/toc/python.ts | |
| @@ -3,10 +3,7 @@ | |
| /*eslint no-invalid-regexp: ["error", { "allowConstructorFlags": ["d"] }]*/ | |
| -import type { | |
| - DocumentRegistry, | |
| - IDocumentWidget | |
| -} from '@jupyterlab/docregistry'; | |
| +import type { DocumentRegistry, IDocumentWidget } from '@jupyterlab/docregistry'; | |
| import type { TableOfContents } from '@jupyterlab/toc'; | |
| import { TableOfContentsModel } from '@jupyterlab/toc'; | |
| import type { Widget } from '@lumino/widgets'; | |
| @@ -73,8 +70,7 @@ export class PythonTableOfContentsModel extends TableOfContentsModel< | |
| if (KEYWORDS.flags.includes('d')) { | |
| hasKeyword = KEYWORDS.exec(line); | |
| } else { | |
| - const { default: execWithIndices } = | |
| - await import('regexp-match-indices'); | |
| + const { default: execWithIndices } = await import('regexp-match-indices'); | |
| hasKeyword = execWithIndices(KEYWORDS, line); | |
| } | |
| if (hasKeyword) { | |
| @@ -123,10 +119,7 @@ export class PythonTableOfContentsFactory extends EditorTableOfContentsFactory { | |
| if (isApplicable) { | |
| let mime = (widget as any).content?.model?.mimeType; | |
| - return ( | |
| - mime && | |
| - (mime === 'application/x-python-code' || mime === 'text/x-python') | |
| - ); | |
| + return mime && (mime === 'application/x-python-code' || mime === 'text/x-python'); | |
| } | |
| return false; | |
| } | |
| diff --git a/packages/fileeditor/src/tokens.ts b/packages/fileeditor/src/tokens.ts | |
| index 432c9e1cf3..79ac1f8d2e 100644 | |
| --- a/packages/fileeditor/src/tokens.ts | |
| +++ b/packages/fileeditor/src/tokens.ts | |
| @@ -9,9 +9,7 @@ import type { FileEditor, FileEditorFactory } from './widget'; | |
| /** | |
| * A class that tracks editor widgets. | |
| */ | |
| -export interface IEditorTracker extends IWidgetTracker< | |
| - IDocumentWidget<FileEditor> | |
| -> {} | |
| +export interface IEditorTracker extends IWidgetTracker<IDocumentWidget<FileEditor>> {} | |
| /** | |
| * The editor tracker token. | |
| diff --git a/packages/fileeditor/src/widget.ts b/packages/fileeditor/src/widget.ts | |
| index 35f9a692dc..ead3f047eb 100644 | |
| --- a/packages/fileeditor/src/widget.ts | |
| +++ b/packages/fileeditor/src/widget.ts | |
| @@ -7,10 +7,7 @@ import type { | |
| IEditorServices | |
| } from '@jupyterlab/codeeditor'; | |
| import { CodeEditorWrapper } from '@jupyterlab/codeeditor'; | |
| -import type { | |
| - DocumentRegistry, | |
| - IDocumentWidget | |
| -} from '@jupyterlab/docregistry'; | |
| +import type { DocumentRegistry, IDocumentWidget } from '@jupyterlab/docregistry'; | |
| import { ABCWidgetFactory, DocumentWidget } from '@jupyterlab/docregistry'; | |
| import { textEditorIcon } from '@jupyterlab/ui-components'; | |
| import { PromiseDelegate } from '@lumino/coreutils'; | |
| @@ -161,8 +158,7 @@ export class FileEditor extends Widget { | |
| const editor = this.editor; | |
| const localPath = this._context.localPath; | |
| - editor.model.mimeType = | |
| - this._mimeTypeService.getMimeTypeByFilePath(localPath); | |
| + editor.model.mimeType = this._mimeTypeService.getMimeTypeByFilePath(localPath); | |
| } | |
| model: CodeEditor.IModel; | |
| @@ -299,9 +295,7 @@ export namespace FileEditorFactory { | |
| /** | |
| * The factory options associated with the factory. | |
| */ | |
| - factoryOptions: DocumentRegistry.IWidgetFactoryOptions< | |
| - IDocumentWidget<FileEditor> | |
| - >; | |
| + factoryOptions: DocumentRegistry.IWidgetFactoryOptions<IDocumentWidget<FileEditor>>; | |
| } | |
| /** | |
| diff --git a/packages/fileeditor/test/searchprovider.spec.ts b/packages/fileeditor/test/searchprovider.spec.ts | |
| index 683fdd754b..5d19f83fad 100644 | |
| --- a/packages/fileeditor/test/searchprovider.spec.ts | |
| +++ b/packages/fileeditor/test/searchprovider.spec.ts | |
| @@ -66,9 +66,7 @@ describe('@jupyterlab/fileeditor', () => { | |
| mimeTypeService, | |
| context | |
| }); | |
| - provider = new FileEditorSearchProvider( | |
| - new MainAreaWidget({ content: widget }) | |
| - ); | |
| + provider = new FileEditorSearchProvider(new MainAreaWidget({ content: widget })); | |
| await context.initialize(true); | |
| await context.ready; | |
| widget.context.model.fromString('test test\ntest'); | |
| diff --git a/packages/fileeditor/test/widget.spec.ts b/packages/fileeditor/test/widget.spec.ts | |
| index 76911e2ffd..160f5ef2da 100644 | |
| --- a/packages/fileeditor/test/widget.spec.ts | |
| +++ b/packages/fileeditor/test/widget.spec.ts | |
| @@ -7,11 +7,7 @@ import { | |
| EditorLanguageRegistry | |
| } from '@jupyterlab/codemirror'; | |
| import type { DocumentRegistry } from '@jupyterlab/docregistry'; | |
| -import { | |
| - Context, | |
| - DocumentWidget, | |
| - TextModelFactory | |
| -} from '@jupyterlab/docregistry'; | |
| +import { Context, DocumentWidget, TextModelFactory } from '@jupyterlab/docregistry'; | |
| import { | |
| FileEditor, | |
| FileEditorFactory, | |
| diff --git a/packages/help-extension/src/index.tsx b/packages/help-extension/src/index.tsx | |
| index 1819fa53eb..ba860a96db 100644 | |
| --- a/packages/help-extension/src/index.tsx | |
| +++ b/packages/help-extension/src/index.tsx | |
| @@ -5,10 +5,7 @@ | |
| * @module help-extension | |
| */ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { ILabShell, ILayoutRestorer } from '@jupyterlab/application'; | |
| import { | |
| Dialog, | |
| @@ -21,11 +18,7 @@ import { URLExt } from '@jupyterlab/coreutils'; | |
| import { IMainMenu } from '@jupyterlab/mainmenu'; | |
| import type { Kernel, KernelMessage, Session } from '@jupyterlab/services'; | |
| import { ITranslator, nullTranslator } from '@jupyterlab/translation'; | |
| -import { | |
| - IFrame, | |
| - jupyterIcon, | |
| - jupyterlabWordmarkIcon | |
| -} from '@jupyterlab/ui-components'; | |
| +import { IFrame, jupyterIcon, jupyterlabWordmarkIcon } from '@jupyterlab/ui-components'; | |
| import type { Menu } from '@lumino/widgets'; | |
| import * as React from 'react'; | |
| @@ -314,8 +307,7 @@ const open: JupyterFrontEndPlugin<void> = { | |
| commands.addCommand(CommandIDs.open, { | |
| label: args => | |
| - (args['text'] as string) ?? | |
| - trans.__('Open the provided `url` in a tab.'), | |
| + (args['text'] as string) ?? trans.__('Open the provided `url` in a tab.'), | |
| describedBy: { | |
| args: { | |
| type: 'object', | |
| @@ -423,10 +415,7 @@ const resources: JupyterFrontEndPlugin<void> = { | |
| helpMenu.addGroup(resourcesGroup, 10); | |
| // Generate a cache of the kernel help links. | |
| - const kernelInfoCache = new Map< | |
| - string, | |
| - KernelMessage.IInfoReplyMsg['content'] | |
| - >(); | |
| + const kernelInfoCache = new Map<string, KernelMessage.IInfoReplyMsg['content']>(); | |
| const onSessionRunningChanged = ( | |
| m: Session.IManager, | |
| @@ -439,10 +428,7 @@ const resources: JupyterFrontEndPlugin<void> = { | |
| return; | |
| } | |
| const sessionModel = sessions[sessions.length - 1]; | |
| - if ( | |
| - !sessionModel.kernel || | |
| - kernelInfoCache.has(sessionModel.kernel.name) | |
| - ) { | |
| + if (!sessionModel.kernel || kernelInfoCache.has(sessionModel.kernel.name)) { | |
| return; | |
| } | |
| const session = serviceManager.sessions.connectTo({ | |
| @@ -478,10 +464,7 @@ const resources: JupyterFrontEndPlugin<void> = { | |
| }; | |
| // Set the status for the current widget | |
| onCurrentChanged().catch(error => { | |
| - console.error( | |
| - 'Failed to get the kernel for the current widget.', | |
| - error | |
| - ); | |
| + console.error('Failed to get the kernel for the current widget.', error); | |
| }); | |
| if (labShell) { | |
| // Update status when current widget changes | |
| diff --git a/packages/htmlviewer-extension/src/index.tsx b/packages/htmlviewer-extension/src/index.tsx | |
| index 5a80175843..424bcb633f 100644 | |
| --- a/packages/htmlviewer-extension/src/index.tsx | |
| +++ b/packages/htmlviewer-extension/src/index.tsx | |
| @@ -7,10 +7,7 @@ | |
| * @module htmlviewer-extension | |
| */ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { ILayoutRestorer } from '@jupyterlab/application'; | |
| import { | |
| createToolbarFactory, | |
| diff --git a/packages/htmlviewer/src/widget.tsx b/packages/htmlviewer/src/widget.tsx | |
| index 463e788a98..00f088ff9a 100644 | |
| --- a/packages/htmlviewer/src/widget.tsx | |
| +++ b/packages/htmlviewer/src/widget.tsx | |
| @@ -4,10 +4,7 @@ | |
| |----------------------------------------------------------------------------*/ | |
| import { ActivityMonitor } from '@jupyterlab/coreutils'; | |
| -import type { | |
| - DocumentRegistry, | |
| - IDocumentWidget | |
| -} from '@jupyterlab/docregistry'; | |
| +import type { DocumentRegistry, IDocumentWidget } from '@jupyterlab/docregistry'; | |
| import { ABCWidgetFactory, DocumentWidget } from '@jupyterlab/docregistry'; | |
| import type { ITranslator } from '@jupyterlab/translation'; | |
| import { nullTranslator } from '@jupyterlab/translation'; | |
| @@ -206,10 +203,7 @@ export class HTMLViewer | |
| if (!this.trusted) { | |
| const trans = this.translator.load('jupyterlab'); | |
| const warning = trans.__('Action disabled as the file is not trusted.'); | |
| - doc.body.insertAdjacentHTML( | |
| - 'beforeend', | |
| - UNTRUSTED_LINK_STYLE({ warning }) | |
| - ); | |
| + doc.body.insertAdjacentHTML('beforeend', UNTRUSTED_LINK_STYLE({ warning })); | |
| } | |
| return doc.documentElement.innerHTML; | |
| } | |
| @@ -217,8 +211,7 @@ export class HTMLViewer | |
| protected translator: ITranslator; | |
| private _renderPending = false; | |
| private _parser = new DOMParser(); | |
| - private _monitor: ActivityMonitor<DocumentRegistry.IModel, void> | null = | |
| - null; | |
| + private _monitor: ActivityMonitor<DocumentRegistry.IModel, void> | null = null; | |
| private _objectUrl: string = ''; | |
| private _trustedChanged = new Signal<this, boolean>(this); | |
| } | |
| @@ -237,9 +230,7 @@ export class HTMLViewerFactory extends ABCWidgetFactory<HTMLViewer> { | |
| /** | |
| * Default factory for toolbar items to be added after the widget is created. | |
| */ | |
| - protected defaultToolbarFactory( | |
| - widget: HTMLViewer | |
| - ): DocumentRegistry.IToolbarItem[] { | |
| + protected defaultToolbarFactory(widget: HTMLViewer): DocumentRegistry.IToolbarItem[] { | |
| return [ | |
| // Make a refresh button for the toolbar. | |
| { | |
| @@ -294,10 +285,7 @@ export namespace ToolbarItems { | |
| translator: ITranslator | |
| ): Widget { | |
| return ReactWidget.create( | |
| - <Private.TrustButtonComponent | |
| - htmlDocument={document} | |
| - translator={translator} | |
| - /> | |
| + <Private.TrustButtonComponent htmlDocument={document} translator={translator} /> | |
| ); | |
| } | |
| } | |
| @@ -319,10 +307,7 @@ namespace Private { | |
| /** | |
| * Sandbox exceptions for trusted HTML. | |
| */ | |
| - export const trusted: IFrame.SandboxExceptions[] = [ | |
| - 'allow-scripts', | |
| - 'allow-popups' | |
| - ]; | |
| + export const trusted: IFrame.SandboxExceptions[] = ['allow-scripts', 'allow-popups']; | |
| /** | |
| * Namespace for TrustedButton. | |
| @@ -359,9 +344,7 @@ namespace Private { | |
| {() => ( | |
| <ToolbarButtonComponent | |
| className="" | |
| - onClick={() => | |
| - (props.htmlDocument.trusted = !props.htmlDocument.trusted) | |
| - } | |
| + onClick={() => (props.htmlDocument.trusted = !props.htmlDocument.trusted)} | |
| tooltip={trans.__(`Whether the HTML file is trusted. | |
| Trusting the file allows opening pop-ups and running scripts | |
| which may result in security risks. | |
| diff --git a/packages/hub-extension/test/hub.spec.ts b/packages/hub-extension/test/hub.spec.ts | |
| index e3c7c2e649..f3e655a0aa 100644 | |
| --- a/packages/hub-extension/test/hub.spec.ts | |
| +++ b/packages/hub-extension/test/hub.spec.ts | |
| @@ -88,10 +88,7 @@ describe('@jupyterlab/hub-extension', () => { | |
| }); | |
| await commands.execute(CommandIDs.restart); | |
| - expect(windowOpenSpy).toHaveBeenCalledWith( | |
| - `${hubPrefix}/spawn`, | |
| - '_blank' | |
| - ); | |
| + expect(windowOpenSpy).toHaveBeenCalledWith(`${hubPrefix}/spawn`, '_blank'); | |
| }); | |
| it('should set correct hub home URL', async () => { | |
| diff --git a/packages/imageviewer-extension/src/index.ts b/packages/imageviewer-extension/src/index.ts | |
| index ea6902f7b5..bb91ea0b2c 100644 | |
| --- a/packages/imageviewer-extension/src/index.ts | |
| +++ b/packages/imageviewer-extension/src/index.ts | |
| @@ -5,16 +5,10 @@ | |
| * @module imageviewer-extension | |
| */ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { ILayoutRestorer } from '@jupyterlab/application'; | |
| import { ICommandPalette, WidgetTracker } from '@jupyterlab/apputils'; | |
| -import type { | |
| - DocumentRegistry, | |
| - IDocumentWidget | |
| -} from '@jupyterlab/docregistry'; | |
| +import type { DocumentRegistry, IDocumentWidget } from '@jupyterlab/docregistry'; | |
| import type { ImageViewer } from '@jupyterlab/imageviewer'; | |
| import { IImageTracker, ImageViewerFactory } from '@jupyterlab/imageviewer'; | |
| import { ITranslator } from '@jupyterlab/translation'; | |
| @@ -147,9 +141,7 @@ function activate( | |
| command: 'docmanager:open', | |
| args: widget => ({ | |
| path: widget.context.path, | |
| - factory: TEXT_FILE_REGEX.test(widget.context.path) | |
| - ? TEXT_FACTORY | |
| - : FACTORY | |
| + factory: TEXT_FILE_REGEX.test(widget.context.path) ? TEXT_FACTORY : FACTORY | |
| }), | |
| name: widget => widget.context.path | |
| }); | |
| @@ -192,8 +184,7 @@ function addCommands( | |
| */ | |
| function isEnabled(): boolean { | |
| return ( | |
| - tracker.currentWidget !== null && | |
| - tracker.currentWidget === shell.currentWidget | |
| + tracker.currentWidget !== null && tracker.currentWidget === shell.currentWidget | |
| ); | |
| } | |
| diff --git a/packages/imageviewer/src/tokens.ts b/packages/imageviewer/src/tokens.ts | |
| index e8f7335718..9732d50b09 100644 | |
| --- a/packages/imageviewer/src/tokens.ts | |
| +++ b/packages/imageviewer/src/tokens.ts | |
| @@ -12,9 +12,7 @@ import type { ImageViewer } from './widget'; | |
| /** | |
| * A class that tracks image widgets. | |
| */ | |
| -export interface IImageTracker extends IWidgetTracker< | |
| - IDocumentWidget<ImageViewer> | |
| -> {} | |
| +export interface IImageTracker extends IWidgetTracker<IDocumentWidget<ImageViewer>> {} | |
| /** | |
| * The image tracker token. | |
| diff --git a/packages/imageviewer/src/widget.ts b/packages/imageviewer/src/widget.ts | |
| index cede60888a..da28f9aa2b 100644 | |
| --- a/packages/imageviewer/src/widget.ts | |
| +++ b/packages/imageviewer/src/widget.ts | |
| @@ -5,10 +5,7 @@ import { PathExt } from '@jupyterlab/coreutils'; | |
| import { Printing } from '@jupyterlab/apputils'; | |
| -import type { | |
| - DocumentRegistry, | |
| - IDocumentWidget | |
| -} from '@jupyterlab/docregistry'; | |
| +import type { DocumentRegistry, IDocumentWidget } from '@jupyterlab/docregistry'; | |
| import { ABCWidgetFactory, DocumentWidget } from '@jupyterlab/docregistry'; | |
| import { PromiseDelegate } from '@lumino/coreutils'; | |
| @@ -123,10 +120,7 @@ export class ImageViewer extends Widget implements Printing.IPrintable { | |
| * Rotate the image counter-clockwise (left). | |
| */ | |
| rotateCounterclockwise(): void { | |
| - this._matrix = Private.prod( | |
| - this._matrix, | |
| - Private.rotateCounterclockwiseMatrix | |
| - ); | |
| + this._matrix = Private.prod(this._matrix, Private.rotateCounterclockwiseMatrix); | |
| this._updateStyle(); | |
| } | |
| @@ -222,9 +216,7 @@ export class ImageViewer extends Widget implements Printing.IPrintable { | |
| /** | |
| * A widget factory for images. | |
| */ | |
| -export class ImageViewerFactory extends ABCWidgetFactory< | |
| - IDocumentWidget<ImageViewer> | |
| -> { | |
| +export class ImageViewerFactory extends ABCWidgetFactory<IDocumentWidget<ImageViewer>> { | |
| /** | |
| * Create a new widget given a context. | |
| */ | |
| diff --git a/packages/imageviewer/test/widget.spec.ts b/packages/imageviewer/test/widget.spec.ts | |
| index fee07eb473..50308e41d9 100644 | |
| --- a/packages/imageviewer/test/widget.spec.ts | |
| +++ b/packages/imageviewer/test/widget.spec.ts | |
| @@ -2,11 +2,7 @@ | |
| // Distributed under the terms of the Modified BSD License. | |
| import type { DocumentRegistry } from '@jupyterlab/docregistry'; | |
| -import { | |
| - Base64ModelFactory, | |
| - Context, | |
| - DocumentWidget | |
| -} from '@jupyterlab/docregistry'; | |
| +import { Base64ModelFactory, Context, DocumentWidget } from '@jupyterlab/docregistry'; | |
| import { createFileContext } from '@jupyterlab/docregistry/lib/testutils'; | |
| import { ImageViewer, ImageViewerFactory } from '@jupyterlab/imageviewer'; | |
| import type { Contents, ServiceManager } from '@jupyterlab/services'; | |
| diff --git a/packages/inspector-extension/src/index.ts b/packages/inspector-extension/src/index.ts | |
| index 3f36aef26a..6e65e39d93 100644 | |
| --- a/packages/inspector-extension/src/index.ts | |
| +++ b/packages/inspector-extension/src/index.ts | |
| @@ -5,16 +5,9 @@ | |
| * @module inspector-extension | |
| */ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { ILayoutRestorer } from '@jupyterlab/application'; | |
| -import { | |
| - ICommandPalette, | |
| - MainAreaWidget, | |
| - WidgetTracker | |
| -} from '@jupyterlab/apputils'; | |
| +import { ICommandPalette, MainAreaWidget, WidgetTracker } from '@jupyterlab/apputils'; | |
| import { IConsoleTracker } from '@jupyterlab/console'; | |
| import { | |
| IInspector, | |
| @@ -56,9 +49,7 @@ const inspector: JupyterFrontEndPlugin<IInspector> = { | |
| ): IInspector => { | |
| const trans = translator.load('jupyterlab'); | |
| const { commands, shell } = app; | |
| - const caption = trans.__( | |
| - 'Live updating code documentation from the active kernel' | |
| - ); | |
| + const caption = trans.__('Live updating code documentation from the active kernel'); | |
| const openedLabel = trans.__('Contextual Help'); | |
| const namespace = 'inspector'; | |
| const datasetKey = 'jpInspector'; | |
| diff --git a/packages/inspector/src/inspector.ts b/packages/inspector/src/inspector.ts | |
| index b31d9d917c..f967753c91 100644 | |
| --- a/packages/inspector/src/inspector.ts | |
| +++ b/packages/inspector/src/inspector.ts | |
| @@ -26,10 +26,7 @@ const DEFAULT_CONTENT_CLASS = 'jp-Inspector-placeholderContent'; | |
| /** | |
| * A panel which contains a set of inspectors. | |
| */ | |
| -export class InspectorPanel | |
| - extends Panel | |
| - implements IInspector, Printing.IPrintable | |
| -{ | |
| +export class InspectorPanel extends Panel implements IInspector, Printing.IPrintable { | |
| /** | |
| * Construct an inspector. | |
| */ | |
| @@ -114,10 +111,7 @@ export class InspectorPanel | |
| /** | |
| * Handle inspector update signals. | |
| */ | |
| - protected onInspectorUpdate( | |
| - sender: any, | |
| - args: IInspector.IInspectorUpdate | |
| - ): void { | |
| + protected onInspectorUpdate(sender: any, args: IInspector.IInspectorUpdate): void { | |
| const { content } = args; | |
| // Update the content of the inspector widget. | |
| diff --git a/packages/inspector/src/kernelconnector.ts b/packages/inspector/src/kernelconnector.ts | |
| index 208785c007..b663bab957 100644 | |
| --- a/packages/inspector/src/kernelconnector.ts | |
| +++ b/packages/inspector/src/kernelconnector.ts | |
| @@ -29,9 +29,7 @@ export class KernelConnector extends DataConnector< | |
| * | |
| * @param request - The inspection request text and details. | |
| */ | |
| - fetch( | |
| - request: InspectionHandler.IRequest | |
| - ): Promise<InspectionHandler.IReply> { | |
| + fetch(request: InspectionHandler.IRequest): Promise<InspectionHandler.IReply> { | |
| const kernel = this._sessionContext.session?.kernel; | |
| if (!kernel) { | |
| diff --git a/packages/inspector/test/inspector.spec.ts b/packages/inspector/test/inspector.spec.ts | |
| index dc8cc3b0c7..951ec972ba 100644 | |
| --- a/packages/inspector/test/inspector.spec.ts | |
| +++ b/packages/inspector/test/inspector.spec.ts | |
| @@ -9,10 +9,7 @@ import { Widget } from '@lumino/widgets'; | |
| class TestInspectorPanel extends InspectorPanel { | |
| methods: string[] = []; | |
| - protected onInspectorUpdate( | |
| - sender: any, | |
| - args: IInspector.IInspectorUpdate | |
| - ): void { | |
| + protected onInspectorUpdate(sender: any, args: IInspector.IInspectorUpdate): void { | |
| super.onInspectorUpdate(sender, args); | |
| this.methods.push('onInspectorUpdate'); | |
| } | |
| @@ -92,9 +89,7 @@ describe('inspector/index', () => { | |
| expect.not.arrayContaining(['onInspectorUpdate']) | |
| ); | |
| (widget.source.inspected as any).emit({ content: new Widget() }); | |
| - expect(widget.methods).toEqual( | |
| - expect.arrayContaining(['onInspectorUpdate']) | |
| - ); | |
| + expect(widget.methods).toEqual(expect.arrayContaining(['onInspectorUpdate'])); | |
| }); | |
| }); | |
| }); | |
| diff --git a/packages/json-extension/src/index.tsx b/packages/json-extension/src/index.tsx | |
| index 5e0839ae9a..d17ac9b8b7 100644 | |
| --- a/packages/json-extension/src/index.tsx | |
| +++ b/packages/json-extension/src/index.tsx | |
| @@ -65,9 +65,7 @@ export class RenderedJSON | |
| // handle if json-lines format | |
| if (MIME_TYPES_JSONL.indexOf(this._mimeType) >= 0) { | |
| // convert into proper json | |
| - const lines = ((model.data[this._mimeType] || '') as string) | |
| - .trim() | |
| - .split(/\n/); | |
| + const lines = ((model.data[this._mimeType] || '') as string).trim().split(/\n/); | |
| data = JSON.parse(`[${lines.join(',')}]`); | |
| } else { | |
| data = (model.data[this._mimeType] || {}) as NonNullable<JSONValue>; | |
| diff --git a/packages/launcher-extension/src/index.ts b/packages/launcher-extension/src/index.ts | |
| index a4027199a4..a5db8c01d4 100644 | |
| --- a/packages/launcher-extension/src/index.ts | |
| +++ b/packages/launcher-extension/src/index.ts | |
| @@ -5,10 +5,7 @@ | |
| * @module launcher-extension | |
| */ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { ILabShell } from '@jupyterlab/application'; | |
| import { ICommandPalette, MainAreaWidget } from '@jupyterlab/apputils'; | |
| import type { FileBrowserModel } from '@jupyterlab/filebrowser'; | |
| @@ -72,9 +69,7 @@ function activate( | |
| }, | |
| toolbar: { | |
| type: 'boolean', | |
| - description: trans.__( | |
| - 'Whether the command is executed from a toolbar' | |
| - ) | |
| + description: trans.__('Whether the command is executed from a toolbar') | |
| }, | |
| activate: { | |
| type: 'boolean', | |
| @@ -142,20 +137,18 @@ function activate( | |
| }); | |
| if (labShell) { | |
| - void Promise.all([app.restored, defaultBrowser?.model.restored]).then( | |
| - () => { | |
| - function maybeCreate() { | |
| - // Create a launcher if there are no open items. | |
| - if (labShell!.isEmpty('main')) { | |
| - void commands.execute(CommandIDs.create); | |
| - } | |
| + void Promise.all([app.restored, defaultBrowser?.model.restored]).then(() => { | |
| + function maybeCreate() { | |
| + // Create a launcher if there are no open items. | |
| + if (labShell!.isEmpty('main')) { | |
| + void commands.execute(CommandIDs.create); | |
| } | |
| - // When layout is modified, create a launcher if there are no open items. | |
| - labShell.layoutModified.connect(() => { | |
| - maybeCreate(); | |
| - }); | |
| } | |
| - ); | |
| + // When layout is modified, create a launcher if there are no open items. | |
| + labShell.layoutModified.connect(() => { | |
| + maybeCreate(); | |
| + }); | |
| + }); | |
| } | |
| if (palette) { | |
| @@ -170,8 +163,7 @@ function activate( | |
| labShell.addRequested.connect((sender: DockPanel, arg: TabBar<Widget>) => { | |
| // Get the ref for the current tab of the tabbar which the add button was clicked | |
| const ref = | |
| - arg.currentTitle?.owner.id || | |
| - arg.titles[arg.titles.length - 1].owner.id; | |
| + arg.currentTitle?.owner.id || arg.titles[arg.titles.length - 1].owner.id; | |
| return commands.execute(CommandIDs.create, { ref }); | |
| }); | |
| diff --git a/packages/launcher-extension/style/base.css b/packages/launcher-extension/style/base.css | |
| index e3411d2f7c..7e5585b4d8 100644 | |
| --- a/packages/launcher-extension/style/base.css | |
| +++ b/packages/launcher-extension/style/base.css | |
| @@ -3,8 +3,7 @@ | |
| * Distributed under the terms of the Modified BSD License. | |
| */ | |
| -.jp-FileBrowser-toolbar | |
| - .jp-ToolbarButtonComponent[data-command='launcher:create'] { | |
| +.jp-FileBrowser-toolbar .jp-ToolbarButtonComponent[data-command='launcher:create'] { | |
| width: 72px; | |
| background: var(--jp-accept-color-normal, var(--jp-brand-color1)); | |
| } | |
| diff --git a/packages/launcher/src/widget.tsx b/packages/launcher/src/widget.tsx | |
| index c89eb91688..72e0bd8195 100644 | |
| --- a/packages/launcher/src/widget.tsx | |
| +++ b/packages/launcher/src/widget.tsx | |
| @@ -4,12 +4,7 @@ | |
| import { showErrorMessage } from '@jupyterlab/apputils'; | |
| import type { ITranslator, TranslationBundle } from '@jupyterlab/translation'; | |
| import { nullTranslator } from '@jupyterlab/translation'; | |
| -import { | |
| - classes, | |
| - LabIcon, | |
| - VDomModel, | |
| - VDomRenderer | |
| -} from '@jupyterlab/ui-components'; | |
| +import { classes, LabIcon, VDomModel, VDomRenderer } from '@jupyterlab/ui-components'; | |
| import { ArrayExt, map } from '@lumino/algorithm'; | |
| import type { CommandRegistry } from '@lumino/commands'; | |
| import type { IDisposable } from '@lumino/disposable'; | |
| @@ -114,10 +109,7 @@ export class Launcher extends VDomRenderer<ILauncher.IModel> { | |
| this._trans.__('Console'), | |
| this._trans.__('Other') | |
| ]; | |
| - const kernelCategories = [ | |
| - this._trans.__('Notebook'), | |
| - this._trans.__('Console') | |
| - ]; | |
| + const kernelCategories = [this._trans.__('Notebook'), this._trans.__('Console')]; | |
| // First group-by categories | |
| const categories = Object.create(null); | |
| @@ -304,9 +296,7 @@ function Card( | |
| alt={title} | |
| /> | |
| ) : ( | |
| - <div className="jp-LauncherCard-noKernelIcon"> | |
| - {label[0].toUpperCase()} | |
| - </div> | |
| + <div className="jp-LauncherCard-noKernelIcon">{label[0].toUpperCase()}</div> | |
| ) | |
| ) : ( | |
| <LabIcon.resolveReact | |
| @@ -335,10 +325,7 @@ namespace Private { | |
| /** | |
| * An attached property for an item's key. | |
| */ | |
| - export const keyProperty = new AttachedProperty< | |
| - ILauncher.IItemOptions, | |
| - number | |
| - >({ | |
| + export const keyProperty = new AttachedProperty<ILauncher.IItemOptions, number>({ | |
| name: 'key', | |
| create: () => id++ | |
| }); | |
| @@ -346,9 +333,7 @@ namespace Private { | |
| /** | |
| * Create a fully specified item given item options. | |
| */ | |
| - export function createItem( | |
| - options: ILauncher.IItemOptions | |
| - ): ILauncher.IItemOptions { | |
| + export function createItem(options: ILauncher.IItemOptions): ILauncher.IItemOptions { | |
| return { | |
| ...options, | |
| category: options.category || '', | |
| diff --git a/packages/logconsole-extension/src/index.tsx b/packages/logconsole-extension/src/index.tsx | |
| index 837bb8c1fb..d8b26decf3 100644 | |
| --- a/packages/logconsole-extension/src/index.tsx | |
| +++ b/packages/logconsole-extension/src/index.tsx | |
| @@ -5,10 +5,7 @@ | |
| * @module logconsole-extension | |
| */ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { ILabShell, ILayoutRestorer } from '@jupyterlab/application'; | |
| import { | |
| createToolbarFactory, | |
| @@ -330,9 +327,7 @@ function activateLogConsole( | |
| // Set source only after app is restored in order to allow restorer to | |
| // restore previous source first, which may set the renderer | |
| if (labShell) { | |
| - labShell.currentPathChanged.connect((_, { newValue }) => | |
| - setSource(newValue) | |
| - ); | |
| + labShell.currentPathChanged.connect((_, { newValue }) => setSource(newValue)); | |
| setSource(labShell.currentPath ?? null); | |
| } else { | |
| setSource(getCurrentWidgetPath()); | |
| @@ -341,8 +336,7 @@ function activateLogConsole( | |
| if (settingRegistry) { | |
| const updateSettings = (settings: ISettingRegistry.ISettings): void => { | |
| - loggerRegistry.maxLength = settings.get('maxLogEntries') | |
| - .composite as number; | |
| + loggerRegistry.maxLength = settings.get('maxLogEntries').composite as number; | |
| status.model.flashEnabled = settings.get('flash').composite as boolean; | |
| loggerRegistry.defaultLogLevel = settings.get('defaultLogLevel') | |
| .composite as LogLevel; | |
| @@ -424,9 +418,7 @@ export class LogLevelSwitcher extends ReactWidget { | |
| <label | |
| htmlFor={this._id} | |
| className={ | |
| - logger === null | |
| - ? 'jp-LogConsole-toolbarLogLevel-disabled' | |
| - : undefined | |
| + logger === null ? 'jp-LogConsole-toolbarLogLevel-disabled' : undefined | |
| } | |
| > | |
| {this._trans.__('Log Level:')} | |
| diff --git a/packages/logconsole-extension/src/status.tsx b/packages/logconsole-extension/src/status.tsx | |
| index 37f30d4aa1..05b90f8e58 100644 | |
| --- a/packages/logconsole-extension/src/status.tsx | |
| +++ b/packages/logconsole-extension/src/status.tsx | |
| @@ -1,11 +1,7 @@ | |
| // Copyright (c) Jupyter Development Team. | |
| // Distributed under the terms of the Modified BSD License. | |
| -import type { | |
| - IContentChange, | |
| - ILogger, | |
| - ILoggerRegistry | |
| -} from '@jupyterlab/logconsole'; | |
| +import type { IContentChange, ILogger, ILoggerRegistry } from '@jupyterlab/logconsole'; | |
| import { GroupItem, TextItem } from '@jupyterlab/statusbar'; | |
| import type { ITranslator } from '@jupyterlab/translation'; | |
| import { nullTranslator } from '@jupyterlab/translation'; | |
| @@ -185,10 +181,7 @@ export namespace LogConsoleStatus { | |
| super(); | |
| this._loggerRegistry = loggerRegistry; | |
| - this._loggerRegistry.registryChanged.connect( | |
| - this._handleLogRegistryChange, | |
| - this | |
| - ); | |
| + this._loggerRegistry.registryChanged.connect(this._handleLogRegistryChange, this); | |
| this._handleLogRegistryChange(); | |
| } | |
| @@ -332,10 +325,7 @@ export namespace LogConsoleStatus { | |
| } | |
| } | |
| - private _handleLogContentChange( | |
| - { source }: ILogger, | |
| - change: IContentChange | |
| - ) { | |
| + private _handleLogContentChange({ source }: ILogger, change: IContentChange) { | |
| if (source === this._source) { | |
| this.stateChanged.emit(); | |
| } | |
| diff --git a/packages/logconsole/src/tokens.ts b/packages/logconsole/src/tokens.ts | |
| index dd116dbefe..0fd89eeef4 100644 | |
| --- a/packages/logconsole/src/tokens.ts | |
| +++ b/packages/logconsole/src/tokens.ts | |
| @@ -119,11 +119,7 @@ export type ILogPayload = ITextLog | IHtmlLog | IOutputLog; | |
| export type IContentChange = 'append' | 'clear'; | |
| export type IStateChange = | |
| - | IChangedArgs< | |
| - IRenderMimeRegistry | null, | |
| - IRenderMimeRegistry | null, | |
| - 'rendermime' | |
| - > | |
| + | IChangedArgs<IRenderMimeRegistry | null, IRenderMimeRegistry | null, 'rendermime'> | |
| | IChangedArgs<LogLevel, LogLevel, 'level'>; | |
| export interface ILoggerOutputAreaModel extends IOutputAreaModel { | |
| diff --git a/packages/logconsole/src/widget.ts b/packages/logconsole/src/widget.ts | |
| index 500da891dd..ee557053da 100644 | |
| --- a/packages/logconsole/src/widget.ts | |
| +++ b/packages/logconsole/src/widget.ts | |
| @@ -292,9 +292,7 @@ export class LogConsolePanel extends StackedPanel { | |
| */ | |
| get sourceVersion(): number | null { | |
| const source = this.source; | |
| - return source !== null | |
| - ? this._loggerRegistry.getLogger(source).version | |
| - : null; | |
| + return source !== null ? this._loggerRegistry.getLogger(source).version : null; | |
| } | |
| /** | |
| @@ -367,22 +365,20 @@ export class LogConsolePanel extends StackedPanel { | |
| // If the source is null, pick a unique name so all output areas hide. | |
| const viewId = source === null ? 'null source' : `source:${source}`; | |
| - this._outputAreas.forEach( | |
| - (outputArea: LogConsoleOutputArea, name: string) => { | |
| - // Show/hide the output area parents, the scrolling windows. | |
| - if (outputArea.id === viewId) { | |
| - outputArea.parent?.show(); | |
| - if (outputArea.isVisible) { | |
| - this._sourceDisplayed.emit({ | |
| - source: this.source, | |
| - version: this.sourceVersion | |
| - }); | |
| - } | |
| - } else { | |
| - outputArea.parent?.hide(); | |
| + this._outputAreas.forEach((outputArea: LogConsoleOutputArea, name: string) => { | |
| + // Show/hide the output area parents, the scrolling windows. | |
| + if (outputArea.id === viewId) { | |
| + outputArea.parent?.show(); | |
| + if (outputArea.isVisible) { | |
| + this._sourceDisplayed.emit({ | |
| + source: this.source, | |
| + version: this.sourceVersion | |
| + }); | |
| } | |
| + } else { | |
| + outputArea.parent?.hide(); | |
| } | |
| - ); | |
| + }); | |
| const title = | |
| source === null | |
| @@ -394,9 +390,7 @@ export class LogConsolePanel extends StackedPanel { | |
| private _handlePlaceholder() { | |
| if (this.source === null) { | |
| - this._placeholder.node.textContent = this._trans.__( | |
| - 'No source selected.' | |
| - ); | |
| + this._placeholder.node.textContent = this._trans.__('No source selected.'); | |
| this._placeholder.show(); | |
| } else if (this._loggerRegistry.getLogger(this.source).length === 0) { | |
| this._placeholder.node.textContent = this._trans.__('No log messages.'); | |
| diff --git a/packages/logconsole/test/logger.spec.ts b/packages/logconsole/test/logger.spec.ts | |
| index 80d23a675e..d0dc3a8ba4 100644 | |
| --- a/packages/logconsole/test/logger.spec.ts | |
| +++ b/packages/logconsole/test/logger.spec.ts | |
| @@ -117,13 +117,7 @@ describe('Logger', () => { | |
| }); | |
| describe('#level', () => { | |
| - const levels: LogLevel[] = [ | |
| - 'critical', | |
| - 'error', | |
| - 'warning', | |
| - 'info', | |
| - 'debug' | |
| - ]; | |
| + const levels: LogLevel[] = ['critical', 'error', 'warning', 'info', 'debug']; | |
| it('should default to "warning"', () => { | |
| expect(logger.level).toEqual('warning'); | |
| }); | |
| diff --git a/packages/lsp-extension/src/index.ts b/packages/lsp-extension/src/index.ts | |
| index 7962d8956c..ecaba59965 100644 | |
| --- a/packages/lsp-extension/src/index.ts | |
| +++ b/packages/lsp-extension/src/index.ts | |
| @@ -68,32 +68,31 @@ const settingsPlugin: JupyterFrontEndPlugin<void> = { | |
| autoStart: true | |
| }; | |
| -const codeExtractorManagerPlugin: JupyterFrontEndPlugin<ILSPCodeExtractorsManager> = | |
| - { | |
| - id: '@jupyterlab/lsp-extension:code-extractor-manager', | |
| - autoStart: true, | |
| - description: 'Provides the code extractor manager.', | |
| - provides: ILSPCodeExtractorsManager, | |
| - activate: app => { | |
| - const extractorManager = new CodeExtractorsManager(); | |
| +const codeExtractorManagerPlugin: JupyterFrontEndPlugin<ILSPCodeExtractorsManager> = { | |
| + id: '@jupyterlab/lsp-extension:code-extractor-manager', | |
| + autoStart: true, | |
| + description: 'Provides the code extractor manager.', | |
| + provides: ILSPCodeExtractorsManager, | |
| + activate: app => { | |
| + const extractorManager = new CodeExtractorsManager(); | |
| - const markdownCellExtractor = new TextForeignCodeExtractor({ | |
| - language: 'markdown', | |
| - isStandalone: false, | |
| - file_extension: 'md', | |
| - cellType: ['markdown'] | |
| - }); | |
| - extractorManager.register(markdownCellExtractor, null); | |
| - const rawCellExtractor = new TextForeignCodeExtractor({ | |
| - language: 'text', | |
| - isStandalone: false, | |
| - file_extension: 'txt', | |
| - cellType: ['raw'] | |
| - }); | |
| - extractorManager.register(rawCellExtractor, null); | |
| - return extractorManager; | |
| - } | |
| - }; | |
| + const markdownCellExtractor = new TextForeignCodeExtractor({ | |
| + language: 'markdown', | |
| + isStandalone: false, | |
| + file_extension: 'md', | |
| + cellType: ['markdown'] | |
| + }); | |
| + extractorManager.register(markdownCellExtractor, null); | |
| + const rawCellExtractor = new TextForeignCodeExtractor({ | |
| + language: 'text', | |
| + isStandalone: false, | |
| + file_extension: 'txt', | |
| + cellType: ['raw'] | |
| + }); | |
| + extractorManager.register(rawCellExtractor, null); | |
| + return extractorManager; | |
| + } | |
| +}; | |
| /** | |
| * Activate the lsp plugin. | |
| @@ -114,11 +113,7 @@ function activate( | |
| // Add a sessions manager if the running extension is available | |
| if (runningSessionManagers) { | |
| - addRunningSessionManager( | |
| - runningSessionManagers, | |
| - connectionManager, | |
| - translator | |
| - ); | |
| + addRunningSessionManager(runningSessionManagers, connectionManager, translator); | |
| } | |
| return connectionManager; | |
| @@ -151,10 +146,7 @@ function activateSettings( | |
| // TODO: if priorities changed reset connections | |
| connectionManager.updateConfiguration(languageServerSettings); | |
| connectionManager.updateServerConfigurations(languageServerSettings); | |
| - connectionManager.updateLogging( | |
| - options.logAllCommunication, | |
| - options.setTrace | |
| - ); | |
| + connectionManager.updateLogging(options.logAllCommunication, options.setTrace); | |
| }; | |
| settingRegistry.transform(plugin.id, { | |
| @@ -221,18 +213,12 @@ function activateSettings( | |
| return renderServerSetting(props, translator); | |
| } | |
| }; | |
| - settingRendererRegistry.addRenderer( | |
| - `${plugin.id}.${LANGUAGE_SERVERS}`, | |
| - renderer | |
| - ); | |
| + settingRendererRegistry.addRenderer(`${plugin.id}.${LANGUAGE_SERVERS}`, renderer); | |
| } | |
| } | |
| export class RunningLanguageServer implements IRunningSessions.IRunningItem { | |
| - constructor( | |
| - connection: ILSPConnection, | |
| - manager: ILSPDocumentConnectionManager | |
| - ) { | |
| + constructor(connection: ILSPConnection, manager: ILSPDocumentConnectionManager) { | |
| this._connection = new WeakSet([connection]); | |
| this._manager = manager; | |
| this._serverIdentifier = connection.serverIdentifier; | |
| diff --git a/packages/lsp-extension/src/renderer.tsx b/packages/lsp-extension/src/renderer.tsx | |
| index 94e654fac0..0f0b95dc08 100644 | |
| --- a/packages/lsp-extension/src/renderer.tsx | |
| +++ b/packages/lsp-extension/src/renderer.tsx | |
| @@ -76,8 +76,7 @@ function BuildSettingForm(props: ISettingFormProps): JSX.Element { | |
| ...otherSettings | |
| } = props.settings; | |
| - const [currentServerName, setCurrentServerName] = | |
| - useState<string>(serverName); | |
| + const [currentServerName, setCurrentServerName] = useState<string>(serverName); | |
| /** | |
| * Callback on server name field change event | |
| @@ -101,9 +100,8 @@ function BuildSettingForm(props: ISettingFormProps): JSX.Element { | |
| serverSettingWithType[UUID.uuid4()] = newProps; | |
| }); | |
| - const [propertyMap, setPropertyMap] = useState<ISettingPropertyMap>( | |
| - serverSettingWithType | |
| - ); | |
| + const [propertyMap, setPropertyMap] = | |
| + useState<ISettingPropertyMap>(serverSettingWithType); | |
| const defaultOtherSettings: TDict = {}; | |
| @@ -121,11 +119,7 @@ function BuildSettingForm(props: ISettingFormProps): JSX.Element { | |
| /** | |
| * Callback on additional setting field change event | |
| */ | |
| - const onOtherSettingsChange = ( | |
| - property: string, | |
| - value: any, | |
| - type: string | |
| - ) => { | |
| + const onOtherSettingsChange = (property: string, value: any, type: string) => { | |
| let settingValue = value; | |
| if (type === 'number') { | |
| settingValue = parseFloat(value); | |
| @@ -204,9 +198,7 @@ function BuildSettingForm(props: ISettingFormProps): JSX.Element { | |
| any, | |
| [hash: string, property: ISettingProperty] | |
| >(setProperty); | |
| - const textInputId = useRef<string>( | |
| - DOMUtils.createDomID() + '-line-number-input' | |
| - ); | |
| + const textInputId = useRef<string>(DOMUtils.createDomID() + '-line-number-input'); | |
| return ( | |
| <div className="array-item"> | |
| <div className="form-group "> | |
| @@ -245,41 +237,32 @@ function BuildSettingForm(props: ISettingFormProps): JSX.Element { | |
| </div> | |
| </div> | |
| </div> | |
| - {Object.entries(otherSettingsSchema).map( | |
| - ([property, value], idx) => { | |
| - return ( | |
| - <div | |
| - key={`${idx}-${property}`} | |
| - className="form-group small-field" | |
| - > | |
| - <div className="jp-FormGroup-content"> | |
| - <h3 className="jp-FormGroup-fieldLabel jp-FormGroup-contentItem"> | |
| - {value.title} | |
| - </h3> | |
| - <div className="jp-inputFieldWrapper jp-FormGroup-contentItem"> | |
| - <input | |
| - className="form-control" | |
| - placeholder="" | |
| - type={value.type} | |
| - value={otherSettingsComposite[property]} | |
| - onChange={e => | |
| - onOtherSettingsChange( | |
| - property, | |
| - e.target.value, | |
| - value.type | |
| - ) | |
| - } | |
| - /> | |
| - </div> | |
| - <div className="jp-FormGroup-description"> | |
| - {value.description} | |
| - </div> | |
| - <div className="validationErrors"></div> | |
| + {Object.entries(otherSettingsSchema).map(([property, value], idx) => { | |
| + return ( | |
| + <div key={`${idx}-${property}`} className="form-group small-field"> | |
| + <div className="jp-FormGroup-content"> | |
| + <h3 className="jp-FormGroup-fieldLabel jp-FormGroup-contentItem"> | |
| + {value.title} | |
| + </h3> | |
| + <div className="jp-inputFieldWrapper jp-FormGroup-contentItem"> | |
| + <input | |
| + className="form-control" | |
| + placeholder="" | |
| + type={value.type} | |
| + value={otherSettingsComposite[property]} | |
| + onChange={e => | |
| + onOtherSettingsChange(property, e.target.value, value.type) | |
| + } | |
| + /> | |
| + </div> | |
| + <div className="jp-FormGroup-description"> | |
| + {value.description} | |
| </div> | |
| + <div className="validationErrors"></div> | |
| </div> | |
| - ); | |
| - } | |
| - )} | |
| + </div> | |
| + ); | |
| + })} | |
| <fieldset> | |
| <legend>{serverSettingsSchema['title']}</legend> | |
| {Object.entries(propertyMap).map(([hash, property]) => { | |
| @@ -337,10 +320,7 @@ function PropertyFrom(props: { | |
| setState(newState); | |
| }; | |
| - const changeValue = ( | |
| - newValue: any, | |
| - type: 'string' | 'boolean' | 'number' | |
| - ) => { | |
| + const changeValue = (newValue: any, type: 'string' | 'boolean' | 'number') => { | |
| let value = newValue; | |
| if (type === 'number') { | |
| value = parseFloat(newValue); | |
| @@ -380,9 +360,7 @@ function PropertyFrom(props: { | |
| <select | |
| className="form-control" | |
| value={state.type} | |
| - onChange={e => | |
| - changeType(e.target.value as 'boolean' | 'string' | 'number') | |
| - } | |
| + onChange={e => changeType(e.target.value as 'boolean' | 'string' | 'number')} | |
| > | |
| <option value="string">String</option> | |
| <option value="number">Number</option> | |
| diff --git a/packages/lsp/schema.js b/packages/lsp/schema.js | |
| index 8aa4459022..a700e9c957 100644 | |
| --- a/packages/lsp/schema.js | |
| +++ b/packages/lsp/schema.js | |
| @@ -86,10 +86,7 @@ async function verifyFile() { | |
| const schemaContentString = await schemaContent; | |
| const pluginContentString = await pluginContent; | |
| - return ( | |
| - currentSchema === schemaContentString && | |
| - currentPlugin === pluginContentString | |
| - ); | |
| + return currentSchema === schemaContentString && currentPlugin === pluginContentString; | |
| } | |
| if (require.main === module) { | |
| diff --git a/packages/lsp/src/adapters/adapter.ts b/packages/lsp/src/adapters/adapter.ts | |
| index 562ba5bce2..24a49033fd 100644 | |
| --- a/packages/lsp/src/adapters/adapter.ts | |
| +++ b/packages/lsp/src/adapters/adapter.ts | |
| @@ -4,10 +4,7 @@ | |
| import mergeWith from 'lodash.mergewith'; | |
| import { Dialog, showDialog } from '@jupyterlab/apputils'; | |
| -import type { | |
| - DocumentRegistry, | |
| - IDocumentWidget | |
| -} from '@jupyterlab/docregistry'; | |
| +import type { DocumentRegistry, IDocumentWidget } from '@jupyterlab/docregistry'; | |
| import type { ITranslator, TranslationBundle } from '@jupyterlab/translation'; | |
| import { nullTranslator } from '@jupyterlab/translation'; | |
| import type { JSONObject } from '@lumino/coreutils'; | |
| @@ -152,10 +149,7 @@ export abstract class WidgetLSPAdapter< | |
| /** | |
| * Signal emitted when the adapter is connected. | |
| */ | |
| - get adapterConnected(): ISignal< | |
| - WidgetLSPAdapter<T>, | |
| - IDocumentConnectionData | |
| - > { | |
| + get adapterConnected(): ISignal<WidgetLSPAdapter<T>, IDocumentConnectionData> { | |
| return this._adapterConnected; | |
| } | |
| @@ -341,19 +335,14 @@ export abstract class WidgetLSPAdapter< | |
| } | |
| // TODO only send the difference, using connection.sendSelectiveChange() | |
| - let connection = this.connectionManager.connections.get( | |
| - virtualDocument.uri | |
| - ); | |
| + let connection = this.connectionManager.connections.get(virtualDocument.uri); | |
| if (!connection?.isReady) { | |
| console.log('Skipping document update signal: connection not ready'); | |
| return; | |
| } | |
| - connection.sendFullTextChange( | |
| - virtualDocument.value, | |
| - virtualDocument.documentInfo | |
| - ); | |
| + connection.sendFullTextChange(virtualDocument.value, virtualDocument.documentInfo); | |
| } | |
| /** | |
| @@ -426,9 +415,7 @@ export abstract class WidgetLSPAdapter< | |
| const documentsToSave = [this.virtualDocument]; | |
| for (let virtualDocument of documentsToSave) { | |
| - let connection = this.connectionManager.connections.get( | |
| - virtualDocument.uri | |
| - ); | |
| + let connection = this.connectionManager.connections.get(virtualDocument.uri); | |
| if (!connection) { | |
| continue; | |
| } | |
| @@ -459,16 +446,14 @@ export abstract class WidgetLSPAdapter< | |
| // refresh the document on the LSP server | |
| this.documentChanged(virtualDocument, virtualDocument, true); | |
| - data.connection.serverNotifications['$/logTrace'].connect( | |
| - (connection, message) => { | |
| - console.log( | |
| - data.connection.serverIdentifier, | |
| - 'trace', | |
| - virtualDocument.uri, | |
| - message | |
| - ); | |
| - } | |
| - ); | |
| + data.connection.serverNotifications['$/logTrace'].connect((connection, message) => { | |
| + console.log( | |
| + data.connection.serverIdentifier, | |
| + 'trace', | |
| + virtualDocument.uri, | |
| + message | |
| + ); | |
| + }); | |
| data.connection.serverNotifications['window/logMessage'].connect( | |
| (connection, message) => { | |
| @@ -496,8 +481,7 @@ export abstract class WidgetLSPAdapter< | |
| }) | |
| : [createButton({ label: this.trans.__('Dismiss') })]; | |
| const result = await showDialog<IButton>({ | |
| - title: | |
| - this.trans.__('Message from ') + data.connection.serverIdentifier, | |
| + title: this.trans.__('Message from ') + data.connection.serverIdentifier, | |
| body: params.message, | |
| buttons: buttons | |
| }); | |
| @@ -525,20 +509,13 @@ export abstract class WidgetLSPAdapter< | |
| virtualDocument: VirtualDocument, | |
| sendOpen = false | |
| ): Promise<void> { | |
| - virtualDocument.foreignDocumentOpened.connect( | |
| - this.onForeignDocumentOpened, | |
| - this | |
| - ); | |
| - const connectionContext = await this._connect(virtualDocument).catch( | |
| - console.error | |
| - ); | |
| + virtualDocument.foreignDocumentOpened.connect(this.onForeignDocumentOpened, this); | |
| + const connectionContext = await this._connect(virtualDocument).catch(console.error); | |
| if (connectionContext && connectionContext.connection) { | |
| virtualDocument.changed.connect(this.documentChanged, this); | |
| if (sendOpen) { | |
| - connectionContext.connection.sendOpenWhenReady( | |
| - virtualDocument.documentInfo | |
| - ); | |
| + connectionContext.connection.sendOpenWhenReady(virtualDocument.documentInfo); | |
| } | |
| } | |
| } | |
| @@ -568,33 +545,27 @@ export abstract class WidgetLSPAdapter< | |
| await this.connectDocument(foreignDocument, true); | |
| - foreignDocument.foreignDocumentClosed.connect( | |
| - this._onForeignDocumentClosed, | |
| - this | |
| - ); | |
| + foreignDocument.foreignDocumentClosed.connect(this._onForeignDocumentClosed, this); | |
| } | |
| /** | |
| * Signal emitted when the adapter is connected. | |
| */ | |
| - protected _adapterConnected: Signal< | |
| - WidgetLSPAdapter<T>, | |
| - IDocumentConnectionData | |
| - > = new Signal(this); | |
| + protected _adapterConnected: Signal<WidgetLSPAdapter<T>, IDocumentConnectionData> = | |
| + new Signal(this); | |
| /** | |
| * Signal emitted when the active editor have changed. | |
| */ | |
| - protected _activeEditorChanged: Signal< | |
| - WidgetLSPAdapter<T>, | |
| - IEditorChangedData | |
| - > = new Signal(this); | |
| + protected _activeEditorChanged: Signal<WidgetLSPAdapter<T>, IEditorChangedData> = | |
| + new Signal(this); | |
| /** | |
| * Signal emitted when an editor is changed. | |
| */ | |
| - protected _editorAdded: Signal<WidgetLSPAdapter<T>, IEditorChangedData> = | |
| - new Signal(this); | |
| + protected _editorAdded: Signal<WidgetLSPAdapter<T>, IEditorChangedData> = new Signal( | |
| + this | |
| + ); | |
| /** | |
| * Signal emitted when an editor is removed. | |
| @@ -744,8 +715,7 @@ export abstract class WidgetLSPAdapter< | |
| private _shouldUpdateVirtualDocument(): boolean { | |
| const { languageServerManager } = this.connectionManager; | |
| return ( | |
| - languageServerManager.isEnabled && | |
| - this.options.featureManager.features.length > 0 | |
| + languageServerManager.isEnabled && this.options.featureManager.features.length > 0 | |
| ); | |
| } | |
| diff --git a/packages/lsp/src/adapters/editorAdapter.ts b/packages/lsp/src/adapters/editorAdapter.ts | |
| index eb72957dda..ad21f6b36b 100644 | |
| --- a/packages/lsp/src/adapters/editorAdapter.ts | |
| +++ b/packages/lsp/src/adapters/editorAdapter.ts | |
| @@ -111,9 +111,7 @@ export namespace EditorAdapter { | |
| * @param options | |
| * @returns The extension builder or null if the extension is not active for that document | |
| */ | |
| - readonly factory: ( | |
| - options: IFactoryOptions | |
| - ) => IConfigurableExtension<any> | null; | |
| + readonly factory: (options: IFactoryOptions) => IConfigurableExtension<any> | null; | |
| } | |
| export interface IFactoryOptions extends IEditorExtensionFactory.IOptions { | |
| diff --git a/packages/lsp/src/connection.ts b/packages/lsp/src/connection.ts | |
| index 8d2ad570ac..d4d99c4ddc 100644 | |
| --- a/packages/lsp/src/connection.ts | |
| +++ b/packages/lsp/src/connection.ts | |
| @@ -190,14 +190,12 @@ export class LSPConnection extends LspWsConnection implements ILSPConnection { | |
| this.serverIdentifier = options.serverIdentifier; | |
| this.serverLanguage = options.languageId; | |
| this.documentsToOpen = []; | |
| - this.clientNotifications = | |
| - this.constructNotificationHandlers<ClientNotifications>( | |
| - Method.ClientNotification | |
| - ); | |
| - this.serverNotifications = | |
| - this.constructNotificationHandlers<ServerNotifications>( | |
| - Method.ServerNotification | |
| - ); | |
| + this.clientNotifications = this.constructNotificationHandlers<ClientNotifications>( | |
| + Method.ClientNotification | |
| + ); | |
| + this.serverNotifications = this.constructNotificationHandlers<ServerNotifications>( | |
| + Method.ServerNotification | |
| + ); | |
| } | |
| /** | |
| @@ -253,10 +251,7 @@ export class LSPConnection extends LspWsConnection implements ILSPConnection { | |
| /** | |
| * Signal emitted when the connection is initialized. | |
| */ | |
| - get serverInitialized(): ISignal< | |
| - ILSPConnection, | |
| - lsp.ServerCapabilities<any> | |
| - > { | |
| + get serverInitialized(): ISignal<ILSPConnection, lsp.ServerCapabilities<any>> { | |
| return this._serverInitialized; | |
| } | |
| @@ -269,9 +264,7 @@ export class LSPConnection extends LspWsConnection implements ILSPConnection { | |
| } | |
| if (this.serverRequests) { | |
| // `serverRequests` may be undefined if dispose is called during initialization sequence | |
| - Object.values(this.serverRequests).forEach(request => | |
| - request.clearHandler() | |
| - ); | |
| + Object.values(this.serverRequests).forEach(request => request.clearHandler()); | |
| } | |
| this.close(); | |
| super.dispose(); | |
| @@ -382,9 +375,7 @@ export class LSPConnection extends LspWsConnection implements ILSPConnection { | |
| */ | |
| protected constructNotificationHandlers< | |
| T extends ServerNotifications | ClientNotifications | |
| - >( | |
| - methods: typeof Method.ServerNotification | typeof Method.ClientNotification | |
| - ): T { | |
| + >(methods: typeof Method.ServerNotification | typeof Method.ClientNotification): T { | |
| const factory = () => new Signal<any, any>(this); | |
| return createMethodMap<T, Signal<any, any>>(methods, factory); | |
| } | |
| @@ -398,8 +389,7 @@ export class LSPConnection extends LspWsConnection implements ILSPConnection { | |
| >(methods: typeof Method.ClientRequest): T { | |
| return createMethodMap<T, IClientRequestHandler>( | |
| methods, | |
| - method => | |
| - new ClientRequestHandler(this.connection, method as U as any, this) | |
| + method => new ClientRequestHandler(this.connection, method as U as any, this) | |
| ); | |
| } | |
| @@ -412,8 +402,7 @@ export class LSPConnection extends LspWsConnection implements ILSPConnection { | |
| >(methods: typeof Method.ServerRequest): T { | |
| return createMethodMap<T, IServerRequestHandler>( | |
| methods, | |
| - method => | |
| - new ServerRequestHandler(this.connection, method as U as any, this) | |
| + method => new ServerRequestHandler(this.connection, method as U as any, this) | |
| ); | |
| } | |
| @@ -486,25 +475,23 @@ export class LSPConnection extends LspWsConnection implements ILSPConnection { | |
| this.serverRequests['client/registerCapability'].setHandler( | |
| async (params: lsp.RegistrationParams) => { | |
| - params.registrations.forEach( | |
| - (capabilityRegistration: lsp.Registration) => { | |
| - try { | |
| - const updatedCapabilities = registerServerCapability( | |
| - this.serverCapabilities, | |
| - capabilityRegistration | |
| + params.registrations.forEach((capabilityRegistration: lsp.Registration) => { | |
| + try { | |
| + const updatedCapabilities = registerServerCapability( | |
| + this.serverCapabilities, | |
| + capabilityRegistration | |
| + ); | |
| + if (updatedCapabilities === null) { | |
| + console.error( | |
| + `Failed to register server capability: ${capabilityRegistration}` | |
| ); | |
| - if (updatedCapabilities === null) { | |
| - console.error( | |
| - `Failed to register server capability: ${capabilityRegistration}` | |
| - ); | |
| - return; | |
| - } | |
| - this.serverCapabilities = updatedCapabilities; | |
| - } catch (err) { | |
| - console.error(err); | |
| + return; | |
| } | |
| + this.serverCapabilities = updatedCapabilities; | |
| + } catch (err) { | |
| + console.error(err); | |
| } | |
| - ); | |
| + }); | |
| } | |
| ); | |
| @@ -542,10 +529,8 @@ export class LSPConnection extends LspWsConnection implements ILSPConnection { | |
| private _closeSignal: Signal<ILSPConnection, boolean> = new Signal(this); | |
| private _errorSignal: Signal<ILSPConnection, any> = new Signal(this); | |
| - private _serverInitialized: Signal< | |
| - ILSPConnection, | |
| - lsp.ServerCapabilities<any> | |
| - > = new Signal(this); | |
| + private _serverInitialized: Signal<ILSPConnection, lsp.ServerCapabilities<any>> = | |
| + new Signal(this); | |
| /** | |
| * Send the document changed data to the server. | |
| diff --git a/packages/lsp/src/connection_manager.ts b/packages/lsp/src/connection_manager.ts | |
| index 1b74afd57f..63b18bd3ef 100644 | |
| --- a/packages/lsp/src/connection_manager.ts | |
| +++ b/packages/lsp/src/connection_manager.ts | |
| @@ -75,30 +75,21 @@ export class DocumentConnectionManager implements ILSPDocumentConnectionManager | |
| /** | |
| * Signal emitted when the manager is initialized. | |
| */ | |
| - get initialized(): ISignal< | |
| - ILSPDocumentConnectionManager, | |
| - IDocumentConnectionData | |
| - > { | |
| + get initialized(): ISignal<ILSPDocumentConnectionManager, IDocumentConnectionData> { | |
| return this._initialized; | |
| } | |
| /** | |
| * Signal emitted when the manager is connected to the server | |
| */ | |
| - get connected(): ISignal< | |
| - ILSPDocumentConnectionManager, | |
| - IDocumentConnectionData | |
| - > { | |
| + get connected(): ISignal<ILSPDocumentConnectionManager, IDocumentConnectionData> { | |
| return this._connected; | |
| } | |
| /** | |
| * Connection temporarily lost or could not be fully established; a re-connection will be attempted; | |
| */ | |
| - get disconnected(): ISignal< | |
| - ILSPDocumentConnectionManager, | |
| - IDocumentConnectionData | |
| - > { | |
| + get disconnected(): ISignal<ILSPDocumentConnectionManager, IDocumentConnectionData> { | |
| return this._disconnected; | |
| } | |
| @@ -108,10 +99,7 @@ export class DocumentConnectionManager implements ILSPDocumentConnectionManager | |
| * - user closed the connection, | |
| * - re-connection attempts exceeded, | |
| */ | |
| - get closed(): ISignal< | |
| - ILSPDocumentConnectionManager, | |
| - IDocumentConnectionData | |
| - > { | |
| + get closed(): ISignal<ILSPDocumentConnectionManager, IDocumentConnectionData> { | |
| return this._closed; | |
| } | |
| @@ -139,15 +127,9 @@ export class DocumentConnectionManager implements ILSPDocumentConnectionManager | |
| * @param virtualDocument - virtual document to be connected. | |
| */ | |
| connectDocumentSignals(virtualDocument: VirtualDocument): void { | |
| - virtualDocument.foreignDocumentOpened.connect( | |
| - this.onForeignDocumentOpened, | |
| - this | |
| - ); | |
| + virtualDocument.foreignDocumentOpened.connect(this.onForeignDocumentOpened, this); | |
| - virtualDocument.foreignDocumentClosed.connect( | |
| - this.onForeignDocumentClosed, | |
| - this | |
| - ); | |
| + virtualDocument.foreignDocumentClosed.connect(this.onForeignDocumentClosed, this); | |
| this.documents.set(virtualDocument.uri, virtualDocument); | |
| this._documentsChanged.emit(this.documents); | |
| } | |
| @@ -158,10 +140,7 @@ export class DocumentConnectionManager implements ILSPDocumentConnectionManager | |
| * | |
| * @param virtualDocument - virtual document to be disconnected. | |
| */ | |
| - disconnectDocumentSignals( | |
| - virtualDocument: VirtualDocument, | |
| - emit = true | |
| - ): void { | |
| + disconnectDocumentSignals(virtualDocument: VirtualDocument, emit = true): void { | |
| virtualDocument.foreignDocumentOpened.disconnect( | |
| this.onForeignDocumentOpened, | |
| this | |
| @@ -246,9 +225,7 @@ export class DocumentConnectionManager implements ILSPDocumentConnectionManager | |
| * | |
| * This function should be called **after** initialization of servers. | |
| */ | |
| - updateServerConfigurations( | |
| - allServerSettings: TLanguageServerConfigurations | |
| - ): void { | |
| + updateServerConfigurations(allServerSettings: TLanguageServerConfigurations): void { | |
| let languageServerId: TServerKeys; | |
| for (languageServerId in allServerSettings) { | |
| @@ -346,9 +323,7 @@ export class DocumentConnectionManager implements ILSPDocumentConnectionManager | |
| console.warn(e); | |
| }); | |
| - console.log( | |
| - 'will attempt to re-connect in ' + interval / 1000 + ' seconds' | |
| - ); | |
| + console.log('will attempt to re-connect in ' + interval / 1000 + ' seconds'); | |
| await sleep(interval); | |
| // gradually increase the time delay, up to 5 sec | |
| @@ -394,11 +369,7 @@ export class DocumentConnectionManager implements ILSPDocumentConnectionManager | |
| `Connection to ${virtualDocument.uri} timed out after ${firstTimeoutSeconds} seconds, will continue retrying for another ${secondTimeoutMinutes} minutes` | |
| ); | |
| try { | |
| - await untilReady( | |
| - () => connection!.isReady, | |
| - 60 * secondTimeoutMinutes, | |
| - 1000 | |
| - ); | |
| + await untilReady(() => connection!.isReady, 60 * secondTimeoutMinutes, 1000); | |
| } catch { | |
| console.log( | |
| `Connection to ${virtualDocument.uri} timed out again after ${secondTimeoutMinutes} minutes, giving up` | |
| @@ -466,8 +437,7 @@ export class DocumentConnectionManager implements ILSPDocumentConnectionManager | |
| }); | |
| // for now use only the server with the highest rank. | |
| - const languageServerId = | |
| - matchingServers.length === 0 ? null : matchingServers[0]; | |
| + const languageServerId = matchingServers.length === 0 ? null : matchingServers[0]; | |
| // lazily load 1) the underlying library (1.5mb) and/or 2) a live WebSocket- | |
| // like connection: either already connected or potentially in the process | |
| @@ -497,10 +467,7 @@ export class DocumentConnectionManager implements ILSPDocumentConnectionManager | |
| connection: ILSPConnection, | |
| callback: (virtualDocument: VirtualDocument) => void | |
| ) { | |
| - for (const [ | |
| - virtualDocumentUri, | |
| - currentConnection | |
| - ] of this.connections.entries()) { | |
| + for (const [virtualDocumentUri, currentConnection] of this.connections.entries()) { | |
| if (connection !== currentConnection) { | |
| continue; | |
| } | |
| @@ -508,25 +475,19 @@ export class DocumentConnectionManager implements ILSPDocumentConnectionManager | |
| } | |
| } | |
| - private _initialized: Signal< | |
| - ILSPDocumentConnectionManager, | |
| - IDocumentConnectionData | |
| - > = new Signal(this); | |
| + private _initialized: Signal<ILSPDocumentConnectionManager, IDocumentConnectionData> = | |
| + new Signal(this); | |
| - private _connected: Signal< | |
| - ILSPDocumentConnectionManager, | |
| - IDocumentConnectionData | |
| - > = new Signal(this); | |
| + private _connected: Signal<ILSPDocumentConnectionManager, IDocumentConnectionData> = | |
| + new Signal(this); | |
| private _disconnected: Signal< | |
| ILSPDocumentConnectionManager, | |
| IDocumentConnectionData | |
| > = new Signal(this); | |
| - private _closed: Signal< | |
| - ILSPDocumentConnectionManager, | |
| - IDocumentConnectionData | |
| - > = new Signal(this); | |
| + private _closed: Signal<ILSPDocumentConnectionManager, IDocumentConnectionData> = | |
| + new Signal(this); | |
| private _documentsChanged: Signal< | |
| ILSPDocumentConnectionManager, | |
| @@ -572,8 +533,7 @@ export namespace DocumentConnectionManager { | |
| language | |
| }; | |
| const matchingServers = serverManager.getMatchingServers(serverOptions); | |
| - const languageServerId = | |
| - matchingServers.length === 0 ? null : matchingServers[0]; | |
| + const languageServerId = matchingServers.length === 0 ? null : matchingServers[0]; | |
| if (languageServerId === null) { | |
| return; | |
| @@ -582,9 +542,7 @@ export namespace DocumentConnectionManager { | |
| const specs = serverManager.getMatchingSpecs(serverOptions); | |
| const spec = specs.get(languageServerId); | |
| if (!spec) { | |
| - console.warn( | |
| - `Specification not available for server ${languageServerId}` | |
| - ); | |
| + console.warn(`Specification not available for server ${languageServerId}`); | |
| } | |
| const requiresOnDiskFiles = spec?.requires_documents_on_disk ?? true; | |
| const supportsInMemoryFiles = !requiresOnDiskFiles; | |
| @@ -596,10 +554,7 @@ export namespace DocumentConnectionManager { | |
| // workaround url-parse bug(s) (see https://github.com/jupyter-lsp/jupyterlab-lsp/issues/595) | |
| let documentUri = URLExt.join(baseUri, virtualDocument.uri); | |
| - if ( | |
| - !documentUri.startsWith('file:///') && | |
| - documentUri.startsWith('file://') | |
| - ) { | |
| + if (!documentUri.startsWith('file:///') && documentUri.startsWith('file://')) { | |
| documentUri = documentUri.replace('file://', 'file:///'); | |
| if ( | |
| documentUri.startsWith('file:///users/') && | |
| diff --git a/packages/lsp/src/extractors/manager.ts b/packages/lsp/src/extractors/manager.ts | |
| index 6f32a23fc4..2e633aad8b 100644 | |
| --- a/packages/lsp/src/extractors/manager.ts | |
| +++ b/packages/lsp/src/extractors/manager.ts | |
| @@ -9,10 +9,7 @@ import type { IForeignCodeExtractor } from './types'; | |
| */ | |
| export class CodeExtractorsManager implements ILSPCodeExtractorsManager { | |
| constructor() { | |
| - this._extractorMap = new Map< | |
| - string, | |
| - Map<string, IForeignCodeExtractor[]> | |
| - >(); | |
| + this._extractorMap = new Map<string, Map<string, IForeignCodeExtractor[]>>(); | |
| this._extractorMapAnyLanguage = new Map<string, IForeignCodeExtractor[]>(); | |
| } | |
| @@ -42,10 +39,7 @@ export class CodeExtractorsManager implements ILSPCodeExtractorsManager { | |
| /** | |
| * Register an extractor to extract foreign code from host documents of specified language. | |
| */ | |
| - register( | |
| - extractor: IForeignCodeExtractor, | |
| - hostLanguage: string | null | |
| - ): void { | |
| + register(extractor: IForeignCodeExtractor, hostLanguage: string | null): void { | |
| const cellType = extractor.cellType; | |
| if (hostLanguage) { | |
| cellType.forEach(type => { | |
| diff --git a/packages/lsp/src/feature.ts b/packages/lsp/src/feature.ts | |
| index d0ebbd146b..817c9057e1 100644 | |
| --- a/packages/lsp/src/feature.ts | |
| +++ b/packages/lsp/src/feature.ts | |
| @@ -33,9 +33,7 @@ export class FeatureManager implements ILSPFeatureManager { | |
| */ | |
| register(feature: IFeature): void { | |
| if (this.features.some(ft => ft.id === feature.id)) { | |
| - console.warn( | |
| - `Feature with id ${feature.id} is already registered, skipping.` | |
| - ); | |
| + console.warn(`Feature with id ${feature.id} is already registered, skipping.`); | |
| } else { | |
| this.features.push(feature); | |
| this._featureRegistered.emit(feature); | |
| diff --git a/packages/lsp/src/manager.ts b/packages/lsp/src/manager.ts | |
| index 378f88b347..786df3d2c6 100644 | |
| --- a/packages/lsp/src/manager.ts | |
| +++ b/packages/lsp/src/manager.ts | |
| @@ -154,9 +154,7 @@ export class LanguageServerManager implements ILanguageServerManager { | |
| /** | |
| * Get matching language server spec for input language option. | |
| */ | |
| - getMatchingSpecs( | |
| - options: ILanguageServerManager.IGetServerIdOptions | |
| - ): TSpecsMap { | |
| + getMatchingSpecs(options: ILanguageServerManager.IGetServerIdOptions): TSpecsMap { | |
| const result: TSpecsMap = new Map(); | |
| for (const [key, specification] of this._specs.entries()) { | |
| @@ -339,9 +337,7 @@ export class LanguageServerManager implements ILanguageServerManager { | |
| /** | |
| * Signal emitted when a language server session is changed | |
| */ | |
| - private _sessionsChanged: Signal<ILanguageServerManager, void> = new Signal( | |
| - this | |
| - ); | |
| + private _sessionsChanged: Signal<ILanguageServerManager, void> = new Signal(this); | |
| private _isDisposed = false; | |
| diff --git a/packages/lsp/src/positioning.ts b/packages/lsp/src/positioning.ts | |
| index 085b0979c4..8cd1dcad64 100644 | |
| --- a/packages/lsp/src/positioning.ts | |
| +++ b/packages/lsp/src/positioning.ts | |
| @@ -110,10 +110,7 @@ export namespace ProtocolCoordinates { | |
| * @param position - position in form of line and character number. | |
| * @param range - range in from of start and end position. | |
| */ | |
| - export function isWithinRange( | |
| - position: lsp.Position, | |
| - range: lsp.Range | |
| - ): boolean { | |
| + export function isWithinRange(position: lsp.Position, range: lsp.Range): boolean { | |
| const { line, character } = position; | |
| return ( | |
| line >= range.start.line && | |
| diff --git a/packages/lsp/src/tokens.ts b/packages/lsp/src/tokens.ts | |
| index 9cb9bf7cb5..f259d47f02 100644 | |
| --- a/packages/lsp/src/tokens.ts | |
| +++ b/packages/lsp/src/tokens.ts | |
| @@ -153,9 +153,7 @@ export interface ILanguageServerManager extends IDisposable { | |
| * | |
| * A list of all known matching specs (whether detected or not). | |
| */ | |
| - getMatchingSpecs( | |
| - options: ILanguageServerManager.IGetServerIdOptions | |
| - ): TSpecsMap; | |
| + getMatchingSpecs(options: ILanguageServerManager.IGetServerIdOptions): TSpecsMap; | |
| /** | |
| * @alpha | |
| @@ -436,9 +434,7 @@ export interface ILSPDocumentConnectionManager { | |
| * | |
| * This function should be called **after** initialization of servers. | |
| */ | |
| - updateServerConfigurations( | |
| - allServerSettings: TLanguageServerConfigurations | |
| - ): void; | |
| + updateServerConfigurations(allServerSettings: TLanguageServerConfigurations): void; | |
| /** | |
| * Retry to connect to the server each `reconnectDelay` seconds | |
| @@ -546,10 +542,7 @@ export interface ILSPCodeExtractorsManager { | |
| /** | |
| * Get the foreign code extractors. | |
| */ | |
| - getExtractors( | |
| - cellType: string, | |
| - hostLanguage: string | null | |
| - ): IForeignCodeExtractor[]; | |
| + getExtractors(cellType: string, hostLanguage: string | null): IForeignCodeExtractor[]; | |
| /** | |
| * Register the extraction rules to be applied in documents with language `host_language`. | |
| @@ -658,11 +651,10 @@ export interface IWidgetLSPAdapterTracker< | |
| * document and LS connection of opened documents. | |
| * | |
| */ | |
| -export const ILSPDocumentConnectionManager = | |
| - new Token<ILSPDocumentConnectionManager>( | |
| - '@jupyterlab/lsp:ILSPDocumentConnectionManager', | |
| - 'Provides the virtual documents and language server connections service.' | |
| - ); | |
| +export const ILSPDocumentConnectionManager = new Token<ILSPDocumentConnectionManager>( | |
| + '@jupyterlab/lsp:ILSPDocumentConnectionManager', | |
| + 'Provides the virtual documents and language server connections service.' | |
| +); | |
| /** | |
| * @alpha | |
| diff --git a/packages/lsp/src/virtual/document.ts b/packages/lsp/src/virtual/document.ts | |
| index d93014d3f8..b3d7465cbd 100644 | |
| --- a/packages/lsp/src/virtual/document.ts | |
| +++ b/packages/lsp/src/virtual/document.ts | |
| @@ -130,10 +130,7 @@ export class VirtualDocumentInfo implements IDocumentInfo { | |
| * value before using it. | |
| */ | |
| get uri(): string { | |
| - const uris = DocumentConnectionManager.solveUris( | |
| - this._document, | |
| - this.languageId | |
| - ); | |
| + const uris = DocumentConnectionManager.solveUris(this._document, this.languageId); | |
| if (!uris) { | |
| return ''; | |
| } | |
| @@ -237,9 +234,7 @@ export class VirtualDocument implements IDisposable { | |
| this.standalone = options.standalone || false; | |
| this.instanceId = VirtualDocument.instancesCount; | |
| VirtualDocument.instancesCount += 1; | |
| - this.unusedStandaloneDocuments = new DefaultMap( | |
| - () => new Array<VirtualDocument>() | |
| - ); | |
| + this.unusedStandaloneDocuments = new DefaultMap(() => new Array<VirtualDocument>()); | |
| this._remainingLifetime = 6; | |
| this.documentInfo = new VirtualDocumentInfo(this); | |
| @@ -339,20 +334,14 @@ export class VirtualDocument implements IDisposable { | |
| /** | |
| * Signal emitted when the foreign document is closed | |
| */ | |
| - get foreignDocumentClosed(): ISignal< | |
| - VirtualDocument, | |
| - Document.IForeignContext | |
| - > { | |
| + get foreignDocumentClosed(): ISignal<VirtualDocument, Document.IForeignContext> { | |
| return this._foreignDocumentClosed; | |
| } | |
| /** | |
| * Signal emitted when the foreign document is opened | |
| */ | |
| - get foreignDocumentOpened(): ISignal< | |
| - VirtualDocument, | |
| - Document.IForeignContext | |
| - > { | |
| + get foreignDocumentOpened(): ISignal<VirtualDocument, Document.IForeignContext> { | |
| return this._foreignDocumentOpened; | |
| } | |
| @@ -416,8 +405,7 @@ export class VirtualDocument implements IDisposable { | |
| * Get the last line in the virtual document | |
| */ | |
| get lastLine(): string { | |
| - const linesInLastBlock = | |
| - this.lineBlocks[this.lineBlocks.length - 1].split('\n'); | |
| + const linesInLastBlock = this.lineBlocks[this.lineBlocks.length - 1].split('\n'); | |
| return linesInLastBlock[linesInLastBlock.length - 1]; | |
| } | |
| @@ -496,19 +484,14 @@ export class VirtualDocument implements IDisposable { | |
| column: position.ch | |
| }; | |
| - for (let [ | |
| - range, | |
| - { virtualDocument: document } | |
| - ] of sourceLine.foreignDocumentsMap) { | |
| + for (let [range, { virtualDocument: document }] of sourceLine.foreignDocumentsMap) { | |
| if (isWithinRange(sourcePositionCe, range)) { | |
| let sourcePositionCm = { | |
| line: sourcePositionCe.line - range.start.line, | |
| ch: sourcePositionCe.column - range.start.column | |
| }; | |
| - return document.documentAtSourcePosition( | |
| - sourcePositionCm as ISourcePosition | |
| - ); | |
| + return document.documentAtSourcePosition(sourcePositionCm as ISourcePosition); | |
| } | |
| } | |
| @@ -586,9 +569,7 @@ export class VirtualDocument implements IDisposable { | |
| ch: sourcePositionCe.column - range.start.column | |
| }; | |
| if (document.isWithinForeign(sourcePositionCm as ISourcePosition)) { | |
| - return this.virtualPositionAtDocument( | |
| - sourcePositionCm as ISourcePosition | |
| - ); | |
| + return this.virtualPositionAtDocument(sourcePositionCm as ISourcePosition); | |
| } else { | |
| // where in this block in the entire foreign document? | |
| sourcePositionCm.line += virtualLine; | |
| @@ -625,10 +606,7 @@ export class VirtualDocument implements IDisposable { | |
| return; | |
| } | |
| let sourceCellLines = cellCode.split('\n'); | |
| - let { lines, foreignDocumentsMap } = this.prepareCodeBlock( | |
| - block, | |
| - editorShift | |
| - ); | |
| + let { lines, foreignDocumentsMap } = this.prepareCodeBlock(block, editorShift); | |
| for (let i = 0; i < lines.length; i++) { | |
| this.virtualLines.set(this.lastVirtualLine + i, { | |
| @@ -722,10 +700,7 @@ export class VirtualDocument implements IDisposable { | |
| this.language | |
| ); | |
| - for (let extractor of [ | |
| - ...extractorsForAnyLang, | |
| - ...extractorsForCurrentLang | |
| - ]) { | |
| + for (let extractor of [...extractorsForAnyLang, ...extractorsForCurrentLang]) { | |
| if (!extractor.hasForeignCode(cellCode, block.type)) { | |
| continue; | |
| } | |
| @@ -866,9 +841,7 @@ export class VirtualDocument implements IDisposable { | |
| * to the virtual document and those do not exist in the source document | |
| * and thus they are absent in the editor. | |
| */ | |
| - transformVirtualToEditor( | |
| - virtualPosition: IVirtualPosition | |
| - ): IEditorPosition | null { | |
| + transformVirtualToEditor(virtualPosition: IVirtualPosition): IEditorPosition | null { | |
| let sourcePosition = this.transformVirtualToSource(virtualPosition); | |
| if (sourcePosition == null) { | |
| return null; | |
| @@ -965,10 +938,7 @@ export class VirtualDocument implements IDisposable { | |
| protected sourceLines: Map<number, ISourceLine>; | |
| protected lineBlocks: Array<string>; | |
| - protected unusedStandaloneDocuments: DefaultMap< | |
| - language, | |
| - Array<VirtualDocument> | |
| - >; | |
| + protected unusedStandaloneDocuments: DefaultMap<language, Array<VirtualDocument>>; | |
| private _isDisposed = false; | |
| private _remainingLifetime: number; | |
| @@ -982,9 +952,7 @@ export class VirtualDocument implements IDisposable { | |
| /** | |
| * Get the foreign document that can be opened with the input extractor. | |
| */ | |
| - private _chooseForeignDocument( | |
| - extractor: IForeignCodeExtractor | |
| - ): VirtualDocument { | |
| + private _chooseForeignDocument(extractor: IForeignCodeExtractor): VirtualDocument { | |
| let foreignDocument: VirtualDocument; | |
| // if not standalone, try to append to existing document | |
| let foreignExists = this.foreignDocuments.has(extractor.language); | |
| @@ -993,9 +961,7 @@ export class VirtualDocument implements IDisposable { | |
| } else { | |
| // if (previous document does not exists) or (extractor produces standalone documents | |
| // and no old standalone document could be reused): create a new document | |
| - let unusedStandalone = this.unusedStandaloneDocuments.get( | |
| - extractor.language | |
| - ); | |
| + let unusedStandalone = this.unusedStandaloneDocuments.get(extractor.language); | |
| if (extractor.standalone && unusedStandalone.length > 0) { | |
| foreignDocument = unusedStandalone.pop()!; | |
| } else { | |
| @@ -1157,13 +1123,10 @@ export class UpdateManager implements IDisposable { | |
| constructor(private virtualDocument: VirtualDocument) { | |
| this._blockAdded = new Signal<UpdateManager, IBlockAddedInfo>(this); | |
| this._documentUpdated = new Signal<UpdateManager, VirtualDocument>(this); | |
| - this._updateBegan = new Signal<UpdateManager, Document.ICodeBlockOptions[]>( | |
| + this._updateBegan = new Signal<UpdateManager, Document.ICodeBlockOptions[]>(this); | |
| + this._updateFinished = new Signal<UpdateManager, Document.ICodeBlockOptions[]>( | |
| this | |
| ); | |
| - this._updateFinished = new Signal< | |
| - UpdateManager, | |
| - Document.ICodeBlockOptions[] | |
| - >(this); | |
| this.documentUpdated.connect(this._onUpdated, this); | |
| } | |
| diff --git a/packages/lsp/src/ws-connection/ws-connection.ts b/packages/lsp/src/ws-connection/ws-connection.ts | |
| index 802976e77a..2cde89f308 100644 | |
| --- a/packages/lsp/src/ws-connection/ws-connection.ts | |
| +++ b/packages/lsp/src/ws-connection/ws-connection.ts | |
| @@ -144,16 +144,14 @@ export class LspWsConnection implements ILspConnection { | |
| const message: protocol.InitializeParams = this.initializeParams(); | |
| - this.connection | |
| - .sendRequest<protocol.InitializeResult>('initialize', message) | |
| - .then( | |
| - params => { | |
| - this.onServerInitialized(params); | |
| - }, | |
| - e => { | |
| - console.warn('LSP websocket connection initialization failure', e); | |
| - } | |
| - ); | |
| + this.connection.sendRequest<protocol.InitializeResult>('initialize', message).then( | |
| + params => { | |
| + this.onServerInitialized(params); | |
| + }, | |
| + e => { | |
| + console.warn('LSP websocket connection initialization failure', e); | |
| + } | |
| + ); | |
| } | |
| /** | |
| diff --git a/packages/lsp/test/adapters.spec.ts b/packages/lsp/test/adapters.spec.ts | |
| index 66e06ccafa..b437c32b5c 100644 | |
| --- a/packages/lsp/test/adapters.spec.ts | |
| +++ b/packages/lsp/test/adapters.spec.ts | |
| @@ -5,11 +5,7 @@ | |
| import { LabShell } from '@jupyterlab/application'; | |
| import { CodeEditor } from '@jupyterlab/codeeditor'; | |
| import { CodeMirrorEditor } from '@jupyterlab/codemirror'; | |
| -import type { | |
| - Document, | |
| - IAdapterOptions, | |
| - IVirtualPosition | |
| -} from '@jupyterlab/lsp'; | |
| +import type { Document, IAdapterOptions, IVirtualPosition } from '@jupyterlab/lsp'; | |
| import { | |
| CodeExtractorsManager, | |
| DocumentConnectionManager, | |
| @@ -243,14 +239,8 @@ describe('@jupyterlab/lsp', () => { | |
| it('should disconnect signals on disposing', async () => { | |
| const { widgetAdapter, connectionManager, featureManager } = | |
| await await createMockAdapter(adapterTracker); | |
| - const editorAddedSpy = jest.spyOn( | |
| - widgetAdapter.editorAdded, | |
| - 'disconnect' | |
| - ); | |
| - const editorRemovedSpy = jest.spyOn( | |
| - widgetAdapter.editorRemoved, | |
| - 'disconnect' | |
| - ); | |
| + const editorAddedSpy = jest.spyOn(widgetAdapter.editorAdded, 'disconnect'); | |
| + const editorRemovedSpy = jest.spyOn(widgetAdapter.editorRemoved, 'disconnect'); | |
| const sessionsChangedSpy = jest.spyOn( | |
| connectionManager.languageServerManager.sessionsChanged, | |
| 'disconnect' | |
| @@ -272,10 +262,7 @@ describe('@jupyterlab/lsp', () => { | |
| const { widgetAdapter } = await createMockAdapter(adapterTracker); | |
| const { model } = widgetAdapter.widget.context; | |
| - const contentChangedConnectSpy = jest.spyOn( | |
| - model.contentChanged, | |
| - 'connect' | |
| - ); | |
| + const contentChangedConnectSpy = jest.spyOn(model.contentChanged, 'connect'); | |
| const contentChangedDisconnectSpy = jest.spyOn( | |
| model.contentChanged, | |
| 'disconnect' | |
| @@ -289,10 +276,7 @@ describe('@jupyterlab/lsp', () => { | |
| await createMockAdapter(adapterTracker); | |
| const { model } = widgetAdapter.widget.context; | |
| - const contentChangedConnectSpy = jest.spyOn( | |
| - model.contentChanged, | |
| - 'connect' | |
| - ); | |
| + const contentChangedConnectSpy = jest.spyOn(model.contentChanged, 'connect'); | |
| const contentChangedDisconnectSpy = jest.spyOn( | |
| model.contentChanged, | |
| 'disconnect' | |
| @@ -315,10 +299,7 @@ describe('@jupyterlab/lsp', () => { | |
| await createMockAdapter(adapterTracker); | |
| const { model } = widgetAdapter.widget.context; | |
| - const contentChangedConnectSpy = jest.spyOn( | |
| - model.contentChanged, | |
| - 'connect' | |
| - ); | |
| + const contentChangedConnectSpy = jest.spyOn(model.contentChanged, 'connect'); | |
| const contentChangedDisconnectSpy = jest.spyOn( | |
| model.contentChanged, | |
| 'disconnect' | |
| diff --git a/packages/lsp/test/document.spec.ts b/packages/lsp/test/document.spec.ts | |
| index 9784736933..181e4a4a80 100644 | |
| --- a/packages/lsp/test/document.spec.ts | |
| +++ b/packages/lsp/test/document.spec.ts | |
| @@ -193,50 +193,46 @@ describe('@jupyterlab/lsp', () => { | |
| }); | |
| describe('#extractForeignCode', () => { | |
| it('should prepare a code block', () => { | |
| - const { cellCodeKept, foreignDocumentsMap } = | |
| - document.extractForeignCode( | |
| - { | |
| - value: 'new line', | |
| - ceEditor: {} as Document.IEditor, | |
| - type: 'code' | |
| - }, | |
| - { line: 0, column: 0 } | |
| - ); | |
| + const { cellCodeKept, foreignDocumentsMap } = document.extractForeignCode( | |
| + { | |
| + value: 'new line', | |
| + ceEditor: {} as Document.IEditor, | |
| + type: 'code' | |
| + }, | |
| + { line: 0, column: 0 } | |
| + ); | |
| expect(cellCodeKept).toEqual('new line'); | |
| expect(foreignDocumentsMap.size).toEqual(0); | |
| }); | |
| it('should prepare a markdown block', () => { | |
| - const { cellCodeKept, foreignDocumentsMap } = | |
| - document.extractForeignCode( | |
| - { | |
| - value: 'new line', | |
| - ceEditor: {} as Document.IEditor, | |
| - type: 'markdown' | |
| - }, | |
| - { line: 0, column: 0 } | |
| - ); | |
| + const { cellCodeKept, foreignDocumentsMap } = document.extractForeignCode( | |
| + { | |
| + value: 'new line', | |
| + ceEditor: {} as Document.IEditor, | |
| + type: 'markdown' | |
| + }, | |
| + { line: 0, column: 0 } | |
| + ); | |
| expect(cellCodeKept).toEqual(''); | |
| expect(foreignDocumentsMap.size).toEqual(1); | |
| }); | |
| it('should prepare a raw text block', () => { | |
| - const { cellCodeKept, foreignDocumentsMap } = | |
| - document.extractForeignCode( | |
| - { | |
| - value: 'new line', | |
| - ceEditor: {} as Document.IEditor, | |
| - type: 'raw' | |
| - }, | |
| - { line: 0, column: 0 } | |
| - ); | |
| + const { cellCodeKept, foreignDocumentsMap } = document.extractForeignCode( | |
| + { | |
| + value: 'new line', | |
| + ceEditor: {} as Document.IEditor, | |
| + type: 'raw' | |
| + }, | |
| + { line: 0, column: 0 } | |
| + ); | |
| expect(cellCodeKept).toEqual(''); | |
| expect(foreignDocumentsMap.size).toEqual(1); | |
| }); | |
| }); | |
| describe('#_chooseForeignDocument', () => { | |
| it('should select the foreign document for markdown cell', () => { | |
| - const md: VirtualDocument = document['_chooseForeignDocument']( | |
| - markdownCellExtractor | |
| - ); | |
| + const md: VirtualDocument = | |
| + document['_chooseForeignDocument'](markdownCellExtractor); | |
| expect(md.uri).toBe('test.ipynb.python-markdown.md'); | |
| }); | |
| it('should select the foreign document for raw cell', () => { | |
| @@ -252,18 +248,16 @@ describe('@jupyterlab/lsp', () => { | |
| }); | |
| document.clear(); | |
| expect( | |
| - document['unusedStandaloneDocuments'].get( | |
| - standaloneCellExtractor.language | |
| - ).length | |
| + document['unusedStandaloneDocuments'].get(standaloneCellExtractor.language) | |
| + .length | |
| ).toEqual(1); | |
| const openForeignSpy = jest.spyOn(document as any, 'openForeign'); | |
| document['_chooseForeignDocument'](standaloneCellExtractor); | |
| expect( | |
| - document['unusedStandaloneDocuments'].get( | |
| - standaloneCellExtractor.language | |
| - ).length | |
| + document['unusedStandaloneDocuments'].get(standaloneCellExtractor.language) | |
| + .length | |
| ).toEqual(0); | |
| expect(openForeignSpy).toHaveBeenCalledTimes(0); | |
| }); | |
| @@ -298,11 +292,7 @@ describe('@jupyterlab/lsp', () => { | |
| }); | |
| describe('#openForeign', () => { | |
| it('should create a new foreign document', () => { | |
| - const doc: VirtualDocument = document['openForeign']( | |
| - 'javascript', | |
| - false, | |
| - 'js' | |
| - ); | |
| + const doc: VirtualDocument = document['openForeign']('javascript', false, 'js'); | |
| expect(doc.uri).toBe('test.ipynb.python-javascript.js'); | |
| expect(doc.parent).toBe(document); | |
| expect(document.foreignDocuments.has(doc.virtualId)).toEqual(true); | |
| @@ -312,16 +302,14 @@ describe('@jupyterlab/lsp', () => { | |
| it('should emit the `foreignDocumentClosed` signal', () => { | |
| const cb = jest.fn(); | |
| document.foreignDocumentClosed.connect(cb); | |
| - const md: VirtualDocument = document['_chooseForeignDocument']( | |
| - markdownCellExtractor | |
| - ); | |
| + const md: VirtualDocument = | |
| + document['_chooseForeignDocument'](markdownCellExtractor); | |
| document.closeForeign(md); | |
| expect(cb).toHaveBeenCalled(); | |
| }); | |
| it('should close correctly foreign documents', () => { | |
| - const md: VirtualDocument = document['_chooseForeignDocument']( | |
| - markdownCellExtractor | |
| - ); | |
| + const md: VirtualDocument = | |
| + document['_chooseForeignDocument'](markdownCellExtractor); | |
| md.closeAllForeignDocuments = jest.fn(); | |
| document.closeForeign(md); | |
| expect(document.foreignDocuments.has(md.virtualId)).toEqual(false); | |
| @@ -344,9 +332,7 @@ describe('@jupyterlab/lsp', () => { | |
| it('should get the markdown content of the document', () => { | |
| const md = document['_chooseForeignDocument'](markdownCellExtractor); | |
| - expect(md.value).toContain( | |
| - 'test line in markdown 1\ntest line in markdown 2' | |
| - ); | |
| + expect(md.value).toContain('test line in markdown 1\ntest line in markdown 2'); | |
| }); | |
| }); | |
| describe('#transformSourceToEditor', () => { | |
| diff --git a/packages/lsp/test/extractor_manager.spec.ts b/packages/lsp/test/extractor_manager.spec.ts | |
| index 552f654169..2545e0cb74 100644 | |
| --- a/packages/lsp/test/extractor_manager.spec.ts | |
| +++ b/packages/lsp/test/extractor_manager.spec.ts | |
| @@ -4,10 +4,7 @@ | |
| */ | |
| import type { IForeignCodeExtractor } from '@jupyterlab/lsp'; | |
| -import { | |
| - CodeExtractorsManager, | |
| - TextForeignCodeExtractor | |
| -} from '@jupyterlab/lsp'; | |
| +import { CodeExtractorsManager, TextForeignCodeExtractor } from '@jupyterlab/lsp'; | |
| describe('@jupyterlab/lsp', () => { | |
| describe('CodeExtractorsManager', () => { | |
| @@ -31,9 +28,9 @@ describe('@jupyterlab/lsp', () => { | |
| }); | |
| it('should register the extractor for specified language', () => { | |
| manager.register(extractor, 'python'); | |
| - expect( | |
| - manager['_extractorMap'].get('markdown').get('python') | |
| - ).toContain(extractor); | |
| + expect(manager['_extractorMap'].get('markdown').get('python')).toContain( | |
| + extractor | |
| + ); | |
| }); | |
| }); | |
| describe('#getExtractors', () => { | |
| @@ -43,9 +40,7 @@ describe('@jupyterlab/lsp', () => { | |
| }); | |
| it('should get the extractor for specified language', () => { | |
| manager.register(extractor, 'python'); | |
| - expect(manager.getExtractors('markdown', 'python')).toContain( | |
| - extractor | |
| - ); | |
| + expect(manager.getExtractors('markdown', 'python')).toContain(extractor); | |
| }); | |
| }); | |
| }); | |
| diff --git a/packages/lsp/test/manager.spec.ts b/packages/lsp/test/manager.spec.ts | |
| index cca2eb3557..a708b5d8c6 100644 | |
| --- a/packages/lsp/test/manager.spec.ts | |
| +++ b/packages/lsp/test/manager.spec.ts | |
| @@ -58,10 +58,7 @@ describe('@jupyterlab/lsp', () => { | |
| describe('#compareRanks', () => { | |
| it('should raise warning if two server have the same rank', async () => { | |
| console.warn = jest.fn(); | |
| - const value = manager['compareRanks']( | |
| - 'pylsp', | |
| - 'unified-language-server' | |
| - ); | |
| + const value = manager['compareRanks']('pylsp', 'unified-language-server'); | |
| expect((console.warn as jest.Mock).mock.calls[0][0]).toEqual( | |
| 'Two matching servers: pylsp and unified-language-server have the same rank; choose which one to use by changing the rank in Advanced Settings Editor' | |
| ); | |
| diff --git a/packages/mainmenu-extension/src/index.ts b/packages/mainmenu-extension/src/index.ts | |
| index 58a148424e..0fe377993f 100644 | |
| --- a/packages/mainmenu-extension/src/index.ts | |
| +++ b/packages/mainmenu-extension/src/index.ts | |
| @@ -5,21 +5,9 @@ | |
| * @module mainmenu-extension | |
| */ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| -import { | |
| - addSemanticCommand, | |
| - ILabShell, | |
| - IRouter | |
| -} from '@jupyterlab/application'; | |
| -import { | |
| - Dialog, | |
| - ICommandPalette, | |
| - MenuFactory, | |
| - showDialog | |
| -} from '@jupyterlab/apputils'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| +import { addSemanticCommand, ILabShell, IRouter } from '@jupyterlab/application'; | |
| +import { Dialog, ICommandPalette, MenuFactory, showDialog } from '@jupyterlab/apputils'; | |
| import { PageConfig, URLExt } from '@jupyterlab/coreutils'; | |
| import type { | |
| IEditMenu, | |
| @@ -121,8 +109,7 @@ export namespace CommandIDs { | |
| export const activateById = 'tabsmenu:activate-by-id'; | |
| - export const activatePreviouslyUsedTab = | |
| - 'tabsmenu:activate-previously-used-tab'; | |
| + export const activatePreviouslyUsedTab = 'tabsmenu:activate-previously-used-tab'; | |
| export const openSettings = 'settingsmenu:open'; | |
| @@ -516,11 +503,7 @@ function createFileMenu( | |
| console.log(`Failed to shutdown sessions and terminals: ${e}`); | |
| } | |
| - return ServerConnection.makeRequest( | |
| - apiURL, | |
| - { method: 'POST' }, | |
| - setting | |
| - ) | |
| + return ServerConnection.makeRequest(apiURL, { method: 'POST' }, setting) | |
| .then(result => { | |
| if (result.ok) { | |
| // Close this window if the shutdown request has been successful | |
| @@ -648,10 +631,7 @@ function createKernelMenu( | |
| id: CommandIDs.restartKernelAndClear, | |
| commands, | |
| shell, | |
| - semanticCommands: [ | |
| - menu.kernelUsers.restartKernel, | |
| - menu.kernelUsers.clearWidget | |
| - ], | |
| + semanticCommands: [menu.kernelUsers.restartKernel, menu.kernelUsers.clearWidget], | |
| default: { | |
| label: trans.__('Restart Kernel and Clear…') | |
| }, | |
| @@ -1040,10 +1020,7 @@ namespace Private { | |
| body: trans.__( | |
| 'Menu customization has changed. You will need to reload JupyterLab to see the changes.' | |
| ), | |
| - buttons: [ | |
| - Dialog.cancelButton(), | |
| - Dialog.okButton({ label: trans.__('Reload') }) | |
| - ] | |
| + buttons: [Dialog.cancelButton(), Dialog.okButton({ label: trans.__('Reload') })] | |
| }); | |
| if (result.button.accept) { | |
| diff --git a/packages/mainmenu-extension/src/recents.ts b/packages/mainmenu-extension/src/recents.ts | |
| index 6e12d11824..9c3a6912ce 100644 | |
| --- a/packages/mainmenu-extension/src/recents.ts | |
| +++ b/packages/mainmenu-extension/src/recents.ts | |
| @@ -3,10 +3,7 @@ | |
| * Distributed under the terms of the Modified BSD License. | |
| */ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { PathExt } from '@jupyterlab/coreutils'; | |
| import { showErrorMessage } from '@jupyterlab/apputils'; | |
| import type { RecentDocument } from '@jupyterlab/docmanager'; | |
| @@ -187,9 +184,7 @@ export const recentsMenuPlugin: JupyterFrontEndPlugin<void> = { | |
| if (recent) { | |
| return PathExt.joinWithLeadingSlash(recent.root, recent.path); | |
| } else { | |
| - return trans.__( | |
| - 'Open a Recent Document (given by `recent` argument)' | |
| - ); | |
| + return trans.__('Open a Recent Document (given by `recent` argument)'); | |
| } | |
| }, | |
| isEnabled: args => | |
| diff --git a/packages/mainmenu/src/mainmenu.ts b/packages/mainmenu/src/mainmenu.ts | |
| index 780923b78c..0e5c4c31cb 100644 | |
| --- a/packages/mainmenu/src/mainmenu.ts | |
| +++ b/packages/mainmenu/src/mainmenu.ts | |
| @@ -326,10 +326,7 @@ export class MainMenu extends MenuBar implements IMainMenu { | |
| */ | |
| private _onMenuDisposed(menu: Menu): void { | |
| this.removeMenu(menu); | |
| - const index = ArrayExt.findFirstIndex( | |
| - this._items, | |
| - item => item.menu === menu | |
| - ); | |
| + const index = ArrayExt.findFirstIndex(this._items, item => item.menu === menu); | |
| if (index !== -1) { | |
| ArrayExt.removeAt(this._items, index); | |
| } | |
| diff --git a/packages/markdownviewer-extension/src/index.ts b/packages/markdownviewer-extension/src/index.ts | |
| index 4528ae081a..30d8f83883 100644 | |
| --- a/packages/markdownviewer-extension/src/index.ts | |
| +++ b/packages/markdownviewer-extension/src/index.ts | |
| @@ -5,10 +5,7 @@ | |
| * @module markdownviewer-extension | |
| */ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { ILayoutRestorer } from '@jupyterlab/application'; | |
| import { ISanitizer, WidgetTracker } from '@jupyterlab/apputils'; | |
| import { PathExt } from '@jupyterlab/coreutils'; | |
| @@ -20,10 +17,7 @@ import { | |
| MarkdownViewerTableOfContentsFactory | |
| } from '@jupyterlab/markdownviewer'; | |
| import type { IRenderMime } from '@jupyterlab/rendermime'; | |
| -import { | |
| - IRenderMimeRegistry, | |
| - markdownRendererFactory | |
| -} from '@jupyterlab/rendermime'; | |
| +import { IRenderMimeRegistry, markdownRendererFactory } from '@jupyterlab/rendermime'; | |
| import { ISettingRegistry } from '@jupyterlab/settingregistry'; | |
| import { ITableOfContentsRegistry } from '@jupyterlab/toc'; | |
| import { ITranslator } from '@jupyterlab/translation'; | |
| @@ -50,12 +44,7 @@ const plugin: JupyterFrontEndPlugin<IMarkdownViewerTracker> = { | |
| description: 'Adds markdown file viewer and provides its tracker.', | |
| provides: IMarkdownViewerTracker, | |
| requires: [IRenderMimeRegistry, ITranslator], | |
| - optional: [ | |
| - ILayoutRestorer, | |
| - ISettingRegistry, | |
| - ITableOfContentsRegistry, | |
| - ISanitizer | |
| - ], | |
| + optional: [ILayoutRestorer, ISettingRegistry, ITableOfContentsRegistry, ISanitizer], | |
| autoStart: true | |
| }; | |
| @@ -194,9 +183,7 @@ function activate( | |
| }, | |
| isVisible: () => { | |
| const widget = tracker.currentWidget; | |
| - return ( | |
| - (widget && PathExt.extname(widget.context.path) === '.md') || false | |
| - ); | |
| + return (widget && PathExt.extname(widget.context.path) === '.md') || false; | |
| }, | |
| label: trans.__('Show Markdown Editor'), | |
| describedBy: { | |
| diff --git a/packages/markdownviewer/src/toc.ts b/packages/markdownviewer/src/toc.ts | |
| index f0c5b69490..8c7ffcd501 100644 | |
| --- a/packages/markdownviewer/src/toc.ts | |
| +++ b/packages/markdownviewer/src/toc.ts | |
| @@ -120,10 +120,7 @@ export class MarkdownViewerTableOfContentsFactory extends TableOfContentsFactory | |
| configuration | |
| ); | |
| - let headingToElement = new WeakMap< | |
| - IMarkdownViewerHeading, | |
| - Element | null | |
| - >(); | |
| + let headingToElement = new WeakMap<IMarkdownViewerHeading, Element | null>(); | |
| const onActiveHeadingChanged = ( | |
| model: TableOfContentsModel<IMarkdownViewerHeading, MarkdownDocument>, | |
| @@ -136,10 +133,7 @@ export class MarkdownViewerTableOfContentsFactory extends TableOfContentsFactory | |
| const widgetBox = widget.content.node.getBoundingClientRect(); | |
| const elementBox = el.getBoundingClientRect(); | |
| - if ( | |
| - elementBox.top > widgetBox.bottom || | |
| - elementBox.bottom < widgetBox.top | |
| - ) { | |
| + if (elementBox.top > widgetBox.bottom || elementBox.bottom < widgetBox.top) { | |
| el.scrollIntoView({ block: 'center' }); | |
| } | |
| } else { | |
| @@ -175,9 +169,7 @@ export class MarkdownViewerTableOfContentsFactory extends TableOfContentsFactory | |
| return; | |
| } | |
| const attribute = | |
| - (this.sanitizer.allowNamedProperties ?? false) | |
| - ? 'id' | |
| - : 'data-jupyter-id'; | |
| + (this.sanitizer.allowNamedProperties ?? false) ? 'id' : 'data-jupyter-id'; | |
| const selector = `h${heading.level}[${attribute}="${CSS.escape(elementId)}"]`; | |
| headingToElement.set( | |
| diff --git a/packages/markdownviewer/src/widget.ts b/packages/markdownviewer/src/widget.ts | |
| index ea96a1d5f3..d4efcd60bc 100644 | |
| --- a/packages/markdownviewer/src/widget.ts | |
| +++ b/packages/markdownviewer/src/widget.ts | |
| @@ -314,9 +314,7 @@ export class MarkdownViewerFactory extends ABCWidgetFactory<MarkdownDocument> { | |
| /** | |
| * Create a new widget given a context. | |
| */ | |
| - protected createNewWidget( | |
| - context: DocumentRegistry.Context | |
| - ): MarkdownDocument { | |
| + protected createNewWidget(context: DocumentRegistry.Context): MarkdownDocument { | |
| const rendermime = this._rendermime.clone({ | |
| resolver: context.urlResolver | |
| }); | |
| diff --git a/packages/markedparser-extension/src/index.ts b/packages/markedparser-extension/src/index.ts | |
| index 2545bfd4d8..0421616a6b 100644 | |
| --- a/packages/markedparser-extension/src/index.ts | |
| +++ b/packages/markedparser-extension/src/index.ts | |
| @@ -9,10 +9,7 @@ | |
| import { PromiseDelegate } from '@lumino/coreutils'; | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { LruCache } from '@jupyterlab/coreutils'; | |
| import { IEditorLanguageRegistry } from '@jupyterlab/codemirror'; | |
| import { IMarkdownParser } from '@jupyterlab/rendermime'; | |
| @@ -130,9 +127,7 @@ namespace Private { | |
| // order blocks by `rank` | |
| _blocks = options?.blocks || []; | |
| - _blocks = _blocks.sort( | |
| - (a, b) => (a.rank ?? Infinity) - (b.rank ?? Infinity) | |
| - ); | |
| + _blocks = _blocks.sort((a, b) => (a.rank ?? Infinity) - (b.rank ?? Infinity)); | |
| _initializing = new PromiseDelegate(); | |
| diff --git a/packages/mathjax-extension/src/index.ts b/packages/mathjax-extension/src/index.ts | |
| index a83276342a..d3ef712c97 100644 | |
| --- a/packages/mathjax-extension/src/index.ts | |
| +++ b/packages/mathjax-extension/src/index.ts | |
| @@ -7,10 +7,7 @@ | |
| import { PromiseDelegate } from '@lumino/coreutils'; | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { ILatexTypesetter } from '@jupyterlab/rendermime'; | |
| @@ -146,9 +143,7 @@ export default mathJaxPlugin; | |
| namespace Private { | |
| let _loading: PromiseDelegate<MathDocument<any, any, any>> | null = null; | |
| - export async function ensureMathDocument(): Promise< | |
| - MathDocument<any, any, any> | |
| - > { | |
| + export async function ensureMathDocument(): Promise<MathDocument<any, any, any>> { | |
| if (!_loading) { | |
| _loading = new PromiseDelegate(); | |
| diff --git a/packages/mermaid-extension/src/index.ts b/packages/mermaid-extension/src/index.ts | |
| index 9d92da7075..3dd8604d21 100644 | |
| --- a/packages/mermaid-extension/src/index.ts | |
| +++ b/packages/mermaid-extension/src/index.ts | |
| @@ -6,10 +6,7 @@ | |
| * @module mermaid-extension | |
| */ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { IThemeManager } from '@jupyterlab/apputils'; | |
| import { | |
| IMermaidManager, | |
| @@ -73,8 +70,7 @@ const contextCommands: JupyterFrontEndPlugin<void> = { | |
| mermaid: IMermaidManager, | |
| translator: ITranslator | null | |
| ) => { | |
| - const isMermaid = (node: HTMLElement) => | |
| - node.classList.contains(MERMAID_CLASS); | |
| + const isMermaid = (node: HTMLElement) => node.classList.contains(MERMAID_CLASS); | |
| const trans = (translator ?? nullTranslator).load('jupyterlab'); | |
| app.commands.addCommand(CommandIDs.copySource, { | |
| diff --git a/packages/mermaid/src/manager.ts b/packages/mermaid/src/manager.ts | |
| index 4628271819..94dfb73e0d 100644 | |
| --- a/packages/mermaid/src/manager.ts | |
| +++ b/packages/mermaid/src/manager.ts | |
| @@ -206,10 +206,7 @@ export class MermaidManager implements IMermaidManager { | |
| const img = document.createElement('img'); | |
| figure.appendChild(img); | |
| - img.setAttribute( | |
| - 'src', | |
| - `data:image/svg+xml,${encodeURIComponent(info.svg)}` | |
| - ); | |
| + img.setAttribute('src', `data:image/svg+xml,${encodeURIComponent(info.svg)}`); | |
| // add dimension information | |
| if (info.width) { | |
| @@ -277,9 +274,7 @@ namespace Private { | |
| /** | |
| * (Re-)initialize mermaid with lab-specific theme information | |
| */ | |
| - export function initMermaid( | |
| - mermaid: typeof MermaidType | null = null | |
| - ): boolean { | |
| + export function initMermaid(mermaid: typeof MermaidType | null = null): boolean { | |
| mermaid = _mermaid; | |
| if (!mermaid) { | |
| diff --git a/packages/mermaid/test/clean.spec.ts b/packages/mermaid/test/clean.spec.ts | |
| index 5894cfaef3..ce7101fb54 100644 | |
| --- a/packages/mermaid/test/clean.spec.ts | |
| +++ b/packages/mermaid/test/clean.spec.ts | |
| @@ -17,9 +17,7 @@ describe('@jupyterlab/mermaid', () => { | |
| for (const element of VOID_ELEMENTS) { | |
| it(`should clean void element ${element}`, () => { | |
| const variants = makeElementVariants(element); | |
| - const raw = [...SVG_XHTML_HEADER, ...variants, ...SVG_XHTML_FOOTER].join( | |
| - '\n' | |
| - ); | |
| + const raw = [...SVG_XHTML_HEADER, ...variants, ...SVG_XHTML_FOOTER].join('\n'); | |
| const clean = MermaidManager.cleanMermaidSvg(raw); | |
| const parsed = parser.parseFromString(clean, SVG_MIME); | |
| diff --git a/packages/metadataform-extension/src/index.ts b/packages/metadataform-extension/src/index.ts | |
| index 954f6b2865..4f54cd6e12 100644 | |
| --- a/packages/metadataform-extension/src/index.ts | |
| +++ b/packages/metadataform-extension/src/index.ts | |
| @@ -5,10 +5,7 @@ | |
| * @module metadataform-extension | |
| */ | |
| -import type { | |
| - JupyterFrontEnd, | |
| - JupyterFrontEndPlugin | |
| -} from '@jupyterlab/application'; | |
| +import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; | |
| import { INotebookTools } from '@jupyterlab/notebook'; | |
| import { ISettingRegistry } from '@jupyterlab/settingregistry'; | |
| import { ITranslator } from '@jupyterlab/translation'; | |
| @@ -73,15 +70,13 @@ namespace Private { | |
| for (let [metadataKey, properties] of Object.entries( | |
| value.metadataSchema.properties | |
| )) { | |
| - metadataForm.metadataSchema.properties[metadataKey] = | |
| - properties; | |
| + metadataForm.metadataSchema.properties[metadataKey] = properties; | |
| } | |
| // Includes required fields. | |
| if (value.metadataSchema.required) { | |
| if (!metadataForm.metadataSchema.required) { | |
| - metadataForm.metadataSchema.required = | |
| - value.metadataSchema.required; | |
| + metadataForm.metadataSchema.required = value.metadataSchema.required; | |
| } else { | |
| metadataForm.metadataSchema.required.concat( | |
| value.metadataSchema.required | |
| @@ -92,12 +87,9 @@ namespace Private { | |
| // Includes allOf array in the existing metadataSchema. | |
| if (value.metadataSchema.allOf) { | |
| if (!metadataForm.metadataSchema.allOf) { | |
| - metadataForm.metadataSchema.allOf = | |
| - value.metadataSchema.allOf; | |
| + metadataForm.metadataSchema.allOf = value.metadataSchema.allOf; | |
| } else { | |
| - metadataForm.metadataSchema.allOf.concat( | |
| - value.metadataSchema.allOf | |
| - ); | |
| + metadataForm.metadataSchema.allOf.concat(value.metadataSchema.allOf); | |
| } | |
| } | |
| @@ -113,8 +105,7 @@ namespace Private { | |
| // Includes metadataOptions in the existing uiSchema. | |
| // Overwrites if options already exists for that metadataKey. | |
| if (value.metadataOptions) { | |
| - if (!metadataForm.metadataOptions) | |
| - metadataForm.metadataOptions = {}; | |
| + if (!metadataForm.metadataOptions) metadataForm.metadataOptions = {}; | |
| for (let [metadataKey, options] of Object.entries( | |
| value.metadataOptions | |
| )) { | |
| @@ -138,8 +129,7 @@ namespace Private { | |
| populate(canonical); | |
| } | |
| const defaults = | |
| - (canonical.properties?.metadataforms?.default as PartialJSONArray) ?? | |
| - []; | |
| + (canonical.properties?.metadataforms?.default as PartialJSONArray) ?? []; | |
| const user = { | |
| metadataforms: plugin.data.user.metadataforms ?? [] | |
| }; | |
| @@ -187,9 +177,7 @@ namespace Private { | |
| uiSchema = JSONExt.deepCopy(schema.uiSchema) as MetadataForm.IUiSchema; | |
| } | |
| - for (let [metadataKey, properties] of Object.entries( | |
| - metadataSchema.properties | |
| - )) { | |
| + for (let [metadataKey, properties] of Object.entries(metadataSchema.properties)) { | |
| if (properties.default) { | |
| if (!metaInformation[metadataKey]) metaInformation[metadataKey] = {}; | |
| metaInformation[metadataKey].default = properties.default; | |
| @@ -197,27 +185,22 @@ namespace Private { | |
| } | |
| if (schema.metadataOptions) { | |
| - for (let [metadataKey, options] of Object.entries( | |
| - schema.metadataOptions | |
| - )) { | |
| + for (let [metadataKey, options] of Object.entries(schema.metadataOptions)) { | |
| // Optionally links key to cell type. | |
| if (options.cellTypes) { | |
| - if (!metaInformation[metadataKey]) | |
| - metaInformation[metadataKey] = {}; | |
| + if (!metaInformation[metadataKey]) metaInformation[metadataKey] = {}; | |
| metaInformation[metadataKey].cellTypes = options.cellTypes; | |
| } | |
| // Optionally links key to metadata level. | |
| if (options.metadataLevel) { | |
| - if (!metaInformation[metadataKey]) | |
| - metaInformation[metadataKey] = {}; | |
| + if (!metaInformation[metadataKey]) metaInformation[metadataKey] = {}; | |
| metaInformation[metadataKey].level = options.metadataLevel; | |
| } | |
| // Optionally set the writeDefault flag. | |
| if (options.writeDefault !== undefined) { | |
| - if (!metaInformation[metadataKey]) | |
| - metaInformation[metadataKey] = {}; | |
| + if (!metaInformation[metadataKey]) metaInformation[metadataKey] = {}; | |
| metaInformation[metadataKey].writeDefault = options.writeDefault; | |
| } | |
| @@ -273,12 +256,7 @@ const metadataForm: JupyterFrontEndPlugin<IMetadataFormProvider> = { | |
| id: PLUGIN_ID, | |
| description: 'Provides the metadata form registry.', | |
| autoStart: true, | |
| - requires: [ | |
| - INotebookTools, | |
| - ITranslator, | |
| - IFormRendererRegistry, | |
| - ISettingRegistry | |
| - ], | |
| + requires: [INotebookTools, ITranslator, IFormRendererRegistry, ISettingRegistry], | |
| provides: IMetadataFormProvider, | |
| activate: async ( | |
| app: JupyterFrontEnd, | |
| diff --git a/packages/metadataform/src/metadataform.ts b/packages/metadataform/src/metadataform.ts | |
| index 38b1729d2f..551f7171ae 100644 | |
| --- a/packages/metadataform/src/metadataform.ts | |
| +++ b/packages/metadataform/src/metadataform.ts | |
| @@ -85,8 +85,7 @@ export class MetadataFormWidget | |
| let properties = (conditional.then as PartialJSONObject) | |
| .properties as PartialJSONObject; | |
| for (let metadataKey of Object.keys(properties)) { | |
| - if (!metadataKeys.includes(metadataKey)) | |
| - metadataKeys.push(metadataKey); | |
| + if (!metadataKeys.includes(metadataKey)) metadataKeys.push(metadataKey); | |
| } | |
| } | |
| } | |
| @@ -96,8 +95,7 @@ export class MetadataFormWidget | |
| let properties = (conditional.else as PartialJSONObject) | |
| .properties as PartialJSONObject; | |
| for (let metadataKey of Object.keys(properties)) { | |
| - if (!metadataKeys.includes(metadataKey)) | |
| - metadataKeys.push(metadataKey); | |
| + if (!metadataKeys.includes(metadataKey)) metadataKeys.push(metadataKey); | |
| } | |
| } | |
| } | |
| @@ -112,9 +110,7 @@ export class MetadataFormWidget | |
| * @param metadataKey - metadataKey (string). | |
| */ | |
| getProperties(metadataKey: string): PartialJSONObject | null { | |
| - return ( | |
| - JSONExt.deepCopy(this._metadataSchema.properties[metadataKey]) || null | |
| - ); | |
| + return JSONExt.deepCopy(this._metadataSchema.properties[metadataKey]) || null; | |
| } | |
| /** | |
| @@ -142,10 +138,7 @@ export class MetadataFormWidget | |
| * in metadata before performing update. | |
| * It uses an arrow function to allow using 'this' properly when called from a custom field. | |
| */ | |
| - updateMetadata = ( | |
| - formData: ReadonlyPartialJSONObject, | |
| - reload?: boolean | |
| - ): void => { | |
| + updateMetadata = (formData: ReadonlyPartialJSONObject, reload?: boolean): void => { | |
| if (this.notebookTools == undefined) return; | |
| const notebook = this.notebookTools.activeNotebookPanel; | |
| @@ -175,9 +168,7 @@ export class MetadataFormWidget | |
| // Continue if the metadataKey is not applicable to the cell type. | |
| if ( | |
| this._metaInformation[metadataKey]?.cellTypes && | |
| - !this._metaInformation[metadataKey]?.cellTypes?.includes( | |
| - cell.model.type | |
| - ) | |
| + !this._metaInformation[metadataKey]?.cellTypes?.includes(cell.model.type) | |
| ) { | |
| continue; | |
| } | |
| @@ -196,10 +187,7 @@ export class MetadataFormWidget | |
| } | |
| // Remove first and last '/' if necessary and split the path. | |
| - let nestedKey = metadataKey | |
| - .replace(/^\/+/, '') | |
| - .replace(/\/+$/, '') | |
| - .split('/'); | |
| + let nestedKey = metadataKey.replace(/^\/+/, '').replace(/\/+$/, '').split('/'); | |
| let baseMetadataKey = nestedKey[0]; | |
| if (baseMetadataKey == undefined) continue; | |
| @@ -211,8 +199,7 @@ export class MetadataFormWidget | |
| // If metadata key is at root of metadata no need to go further. | |
| if (nestedKey.length == 1) { | |
| - if (writeFinalData) | |
| - metadataObject[baseMetadataKey] = value as PartialJSONValue; | |
| + if (writeFinalData) metadataObject[baseMetadataKey] = value as PartialJSONValue; | |
| else metadataObject[baseMetadataKey] = undefined; | |
| continue; | |
| } | |
| @@ -260,10 +247,7 @@ export class MetadataFormWidget | |
| metadataObject[baseMetadataKey] as PartialJSONObject, | |
| nestedKey.slice(1) | |
| ); | |
| - if ( | |
| - !Object.keys(metadataObject[baseMetadataKey] as PartialJSONObject) | |
| - .length | |
| - ) | |
| + if (!Object.keys(metadataObject[baseMetadataKey] as PartialJSONObject).length) | |
| metadataObject[baseMetadataKey] = undefined; | |
| } | |
| } | |
| @@ -278,8 +262,7 @@ export class MetadataFormWidget | |
| if (!this._notebookModelNull) { | |
| for (let [key, value] of Object.entries(notebookMetadataObject)) { | |
| if (value === undefined) notebook!.model!.deleteMetadata(key); | |
| - else | |
| - notebook!.model!.setMetadata(key, value as ReadonlyPartialJSONValue); | |
| + else notebook!.model!.setMetadata(key, value as ReadonlyPartialJSONValue); | |
| } | |
| } | |
| @@ -382,9 +365,7 @@ export class MetadataFormWidget | |
| // Do not display the field if the active cell's type is not involved. | |
| if ( | |
| this._metaInformation[metadataKey]?.cellTypes && | |
| - !this._metaInformation[metadataKey]?.cellTypes?.includes( | |
| - cell.model.type | |
| - ) | |
| + !this._metaInformation[metadataKey]?.cellTypes?.includes(cell.model.type) | |
| ) { | |
| delete formProperties.properties![metadataKey]; | |
| continue; | |
| @@ -393,10 +374,7 @@ export class MetadataFormWidget | |
| let workingObject: PartialJSONObject; | |
| // Remove the first and last '/' if exist, nad split the path. | |
| - let nestedKeys = metadataKey | |
| - .replace(/^\/+/, '') | |
| - .replace(/\/+$/, '') | |
| - .split('/'); | |
| + let nestedKeys = metadataKey.replace(/^\/+/, '').replace(/\/+$/, '').split('/'); | |
| // Associates the correct metadata object to the working object. | |
| if (this._metaInformation[metadataKey]?.level === 'notebook') { | |
| diff --git a/packages/metadataform/src/token.ts b/packages/metadataform/src/token.ts | |
| index 2931dce3db..d8586ad33f 100644 | |
| --- a/packages/metadataform/src/token.ts | |
| +++ b/packages/metadataform/src/token.ts | |
| @@ -7,10 +7,7 @@ | |
| import type { CellType } from '@jupyterlab/nbformat'; | |
| import type { NotebookTools } from '@jupyterlab/notebook'; | |
| -import type { | |
| - BaseSettings, | |
| - ISettingRegistry | |
| -} from '@jupyterlab/settingregistry'; | |
| +import type { BaseSettings, ISettingRegistry } from '@jupyterlab/settingregistry'; | |
| import type { ITranslator } from '@jupyterlab/translation'; | |
| import type { PartialJSONObject, ReadonlyJSONObject } from '@lumino/coreutils'; | |
| import { Token } from '@lumino/coreutils'; | |
| diff --git a/packages/metadataform/test/metadataFormWidget.spec.ts b/packages/metadataform/test/metadataFormWidget.spec.ts | |
| index 9fc2b1ac19..65bd1dbf9b 100644 | |
| --- a/packages/metadataform/test/metadataFormWidget.spec.ts | |
| +++ b/packages/metadataform/test/metadataFormWidget.spec.ts | |
| @@ -7,10 +7,7 @@ import { JSONExt } from '@lumino/coreutils'; | |
| import type { Context } from '@jupyterlab/docregistry'; | |
| import type { INotebookModel, NotebookPanel } from '@jupyterlab/notebook'; | |
| import { NotebookTools, NotebookTracker } from '@jupyterlab/notebook'; | |
| -import { | |
| - initNotebookContext, | |
| - NBTestUtils | |
| -} from '@jupyterlab/notebook/lib/testutils'; | |
| +import { initNotebookContext, NBTestUtils } from '@jupyterlab/notebook/lib/testutils'; | |
| import { JupyterServer, sleep } from '@jupyterlab/testing'; | |
| import type { MetadataForm } from '../src'; | |
| import { MetadataFormWidget } from '../src'; | |
| @@ -105,17 +102,12 @@ describe('metadataform/form simple', () => { | |
| const node = metadataForm.node as HTMLElement; | |
| expect(node.children).toHaveLength(1); | |
| const formNode = node.children[0]; | |
| - expect(formNode.className.split(' ')).toContain( | |
| - 'jp-MetadataForm-placeholder' | |
| - ); | |
| + expect(formNode.className.split(' ')).toContain('jp-MetadataForm-placeholder'); | |
| }); | |
| it('should return the metadataKeys', async () => { | |
| const metadataForm = await buildForm(); | |
| - expect(metadataForm.metadataKeys).toEqual([ | |
| - '/cell-metadata', | |
| - '/notebook-metadata' | |
| - ]); | |
| + expect(metadataForm.metadataKeys).toEqual(['/cell-metadata', '/notebook-metadata']); | |
| }); | |
| it('should return the properties', async () => { | |
| @@ -164,20 +156,14 @@ describe('metadataform/form simple', () => { | |
| expect(formNode.children[0].className).toBe('rjsf'); | |
| // Expect 2 inputs in the form. | |
| - expect( | |
| - formNode.getElementsByClassName('jp-inputFieldWrapper') | |
| - ).toHaveLength(2); | |
| + expect(formNode.getElementsByClassName('jp-inputFieldWrapper')).toHaveLength(2); | |
| }); | |
| it('should update cell metadata', async () => { | |
| const metadataForm = await buildForm(); | |
| - expect( | |
| - tracker.activeCell?.model.getMetadata('cell-metadata') | |
| - ).toBeUndefined(); | |
| + expect(tracker.activeCell?.model.getMetadata('cell-metadata')).toBeUndefined(); | |
| metadataForm.updateMetadata({ '/cell-metadata': 'test value' }); | |
| - expect(tracker.activeCell?.model.getMetadata('cell-metadata')).toBe( | |
| - 'test value' | |
| - ); | |
| + expect(tracker.activeCell?.model.getMetadata('cell-metadata')).toBe('test value'); | |
| }); | |
| it('should update notebook metadata', async () => { | |
| @@ -193,13 +179,9 @@ describe('metadataform/form simple', () => { | |
| it('should not update cell metadata if metadataKey is not in schema', async () => { | |
| const metadataForm = await buildForm(); | |
| - expect( | |
| - tracker.activeCell?.model.getMetadata('fake-metadata') | |
| - ).toBeUndefined(); | |
| + expect(tracker.activeCell?.model.getMetadata('fake-metadata')).toBeUndefined(); | |
| metadataForm.updateMetadata({ '/fake-metadata': 'test value' }); | |
| - expect( | |
| - tracker.activeCell?.model.getMetadata('fake-metadata') | |
| - ).toBeUndefined(); | |
| + expect(tracker.activeCell?.model.getMetadata('fake-metadata')).toBeUndefined(); | |
| }); | |
| it('should not update the cell metadata if the cell type is not a valid one', async () => { | |
| @@ -208,13 +190,9 @@ describe('metadataform/form simple', () => { | |
| // Switch to a markdown cell. | |
| tracker.currentWidget!.content.activeCellIndex++; | |
| - expect( | |
| - tracker.activeCell?.model.getMetadata('cell-metadata') | |
| - ).toBeUndefined(); | |
| + expect(tracker.activeCell?.model.getMetadata('cell-metadata')).toBeUndefined(); | |
| metadataForm.updateMetadata({ '/cell-metadata': 'test value' }); | |
| - expect( | |
| - tracker.activeCell?.model.getMetadata('cell-metadata') | |
| - ).toBeUndefined(); | |
| + expect(tracker.activeCell?.model.getMetadata('cell-metadata')).toBeUndefined(); | |
| }); | |
| it('should not update the form if it is not visible', async () => { | |
| diff --git a/packages/metapackage/test/completer/handler.spec.ts b/packages/metapackage/test/completer/handler.spec.ts | |
| index ffd017479f..722d6bdb3d 100644 | |
| --- a/packages/metapackage/test/completer/handler.spec.ts | |
| +++ b/packages/metapackage/test/completer/handler.spec.ts | |
| @@ -4,10 +4,7 @@ | |
| import type { ISessionContext, SessionContext } from '@jupyterlab/apputils'; | |
| import type { CodeEditorWrapper } from '@jupyterlab/codeeditor'; | |
| import type { Signal } from '@lumino/signaling'; | |
| -import type { | |
| - ICompletionContext, | |
| - ICompletionProvider | |
| -} from '@jupyterlab/completer'; | |
| +import type { ICompletionContext, ICompletionProvider } from '@jupyterlab/completer'; | |
| import { | |
| Completer, | |
| CompleterModel, | |
| @@ -201,13 +198,9 @@ describe('@jupyterlab/completer', () => { | |
| completer: new Completer({ editor: null }) | |
| }); | |
| handler.editor = createEditorWidget().editor; | |
| - expect(handler.methods).toEqual( | |
| - expect.not.arrayContaining(['onTextChanged']) | |
| - ); | |
| + expect(handler.methods).toEqual(expect.not.arrayContaining(['onTextChanged'])); | |
| handler.editor.model.sharedModel.setSource('foo'); | |
| - expect(handler.methods).toEqual( | |
| - expect.arrayContaining(['onTextChanged']) | |
| - ); | |
| + expect(handler.methods).toEqual(expect.arrayContaining(['onTextChanged'])); | |
| }); | |
| it('should call model change handler if model exists', () => { | |
| @@ -220,17 +213,13 @@ describe('@jupyterlab/completer', () => { | |
| const model = completer.model as TestCompleterModel; | |
| handler.editor = editor; | |
| - expect(model.methods).toEqual( | |
| - expect.not.arrayContaining(['handleTextChange']) | |
| - ); | |
| + expect(model.methods).toEqual(expect.not.arrayContaining(['handleTextChange'])); | |
| editor.model.sharedModel.setSource('bar'); | |
| editor.setCursorPosition({ line: 0, column: 2 }); | |
| - ( | |
| - editor.model.sharedModel.changed as Signal<ISharedText, SourceChange> | |
| - ).emit({ sourceChange: {} as any }); | |
| - expect(model.methods).toEqual( | |
| - expect.arrayContaining(['handleTextChange']) | |
| - ); | |
| + (editor.model.sharedModel.changed as Signal<ISharedText, SourceChange>).emit({ | |
| + sourceChange: {} as any | |
| + }); | |
| + expect(model.methods).toEqual(expect.arrayContaining(['handleTextChange'])); | |
| }); | |
| }); | |
| @@ -257,9 +246,7 @@ describe('@jupyterlab/completer', () => { | |
| const model = completer.model as TestCompleterModel; | |
| handler.editor = createEditorWidget().editor; | |
| - expect(model.methods).toEqual( | |
| - expect.not.arrayContaining(['createPatch']) | |
| - ); | |
| + expect(model.methods).toEqual(expect.not.arrayContaining(['createPatch'])); | |
| (completer.selected as any).emit('foo'); | |
| expect(model.methods).toEqual(expect.arrayContain |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment