diff --git a/.prettierrc b/.prettierrc index 92cde390acff..1950328e59aa 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,3 +1,5 @@ { - "singleQuote": true + "singleQuote": true, + "trailingComma": "none", + "arrowParens": "avoid" } \ No newline at end of file diff --git a/buildutils/src/add-sibling.ts b/buildutils/src/add-sibling.ts index a731d40831b8..1ca60a02deb5 100755 --- a/buildutils/src/add-sibling.ts +++ b/buildutils/src/add-sibling.ts @@ -38,10 +38,7 @@ if (fs.existsSync(packagePath)) { packagePath = newPackagePath; } else { // Otherwise treat it as a git reposotory and try to add it. - packageDirName = target - .split('/') - .pop()! - .split('.')[0]; + packageDirName = target.split('/').pop()!.split('.')[0]; packagePath = path.join(basePath, 'packages', packageDirName); utils.run('git clone ' + target + ' ' + packagePath); } diff --git a/buildutils/src/ensure-package.ts b/buildutils/src/ensure-package.ts index 56e255dfc268..9df4b446355c 100644 --- a/buildutils/src/ensure-package.ts +++ b/buildutils/src/ensure-package.ts @@ -152,7 +152,7 @@ export async function ensurePackage( } let names: string[] = Array.from(new Set(imports)).sort(); - names = names.map(function(name) { + names = names.map(function (name) { const parts = name.split('/'); if (name.indexOf('@') === 0) { return parts[0] + '/' + parts[1]; diff --git a/buildutils/src/update-dependency.ts b/buildutils/src/update-dependency.ts index 00c4849ff039..4ef87c42242d 100755 --- a/buildutils/src/update-dependency.ts +++ b/buildutils/src/update-dependency.ts @@ -227,7 +227,7 @@ commander } ); -commander.on('--help', function() { +commander.on('--help', function () { console.debug(` Examples -------- diff --git a/buildutils/src/utils.ts b/buildutils/src/utils.ts index d41f937bcf8c..a3d06383fd9f 100644 --- a/buildutils/src/utils.ts +++ b/buildutils/src/utils.ts @@ -60,10 +60,7 @@ export function getCorePaths(): string[] { */ export function writePackageData(pkgJsonPath: string, data: any): boolean { const text = JSON.stringify(sortPackageJson(data), null, 2) + '\n'; - const orig = fs - .readFileSync(pkgJsonPath, 'utf8') - .split('\r\n') - .join('\n'); + const orig = fs.readFileSync(pkgJsonPath, 'utf8').split('\r\n').join('\n'); if (text !== orig) { fs.writeFileSync(pkgJsonPath, text, 'utf8'); return true; @@ -346,10 +343,7 @@ export function ensureUnixPathSep(source: string) { * @returns the last part of the path, sans extension. */ export function stem(pathArg: string): string { - return path - .basename(pathArg) - .split('.') - .shift()!; + return path.basename(pathArg).split('.').shift()!; } /** @@ -364,7 +358,7 @@ export function stem(pathArg: string): string { * @returns the camel case version of the input string. */ export function camelCase(str: string, upper: boolean = false): string { - return str.replace(/(?:^\w|[A-Z]|\b\w|\s+|-+|_+)/g, function(match, index) { + return str.replace(/(?:^\w|[A-Z]|\b\w|\s+|-+|_+)/g, function (match, index) { if (+match === 0 || match[0] === '-') { return ''; } else if (index === 0 && !upper) { diff --git a/dev_mode/webpack.config.js b/dev_mode/webpack.config.js index 6fe91ba670a5..87eb3325d54c 100644 --- a/dev_mode/webpack.config.js +++ b/dev_mode/webpack.config.js @@ -106,7 +106,7 @@ fs.writeFileSync(entryPoint, bootstrap); // Set up variables for the watch mode ignore plugins const watched = {}; const ignoreCache = Object.create(null); -Object.keys(jlab.linkedPackages).forEach(function(name) { +Object.keys(jlab.linkedPackages).forEach(function (name) { if (name in watched) { return; } @@ -134,7 +134,7 @@ function maybeSync(localPath, name, rest) { if (source === fs.realpathSync(localPath)) { return; } - fs.watchFile(source, { interval: 500 }, function(curr) { + fs.watchFile(source, { interval: 500 }, function (curr) { if (!curr || curr.nlink === 0) { return; } diff --git a/docs/scripts/graph-dependencies.js b/docs/scripts/graph-dependencies.js index 037be16ada10..a1b9e1779b14 100644 --- a/docs/scripts/graph-dependencies.js +++ b/docs/scripts/graph-dependencies.js @@ -11,7 +11,7 @@ const packages = glob.sync(path.join(basePath, 'packages/*')); // Begin the graph specification let text = ['digraph G {', 'ratio = 0.6;', 'rankdir=LR;']; -packages.forEach(function(packagePath) { +packages.forEach(function (packagePath) { // Load the package.json data. const dataPath = path.join(packagePath, 'package.json'); let data; diff --git a/examples/app/index.js b/examples/app/index.js index 6625d6b58577..8d8d20d23973 100644 --- a/examples/app/index.js +++ b/examples/app/index.js @@ -9,7 +9,7 @@ __webpack_public_path__ = PageConfig.getOption('fullStaticUrl') + '/'; // This cannot be extracted because the public path is dynamic. require('./build/imports.css'); -window.addEventListener('load', async function() { +window.addEventListener('load', async function () { const JupyterLab = require('@jupyterlab/application').JupyterLab; const mods = [ diff --git a/examples/app/webpack.config.js b/examples/app/webpack.config.js index af409d65db43..e9be465397fd 100644 --- a/examples/app/webpack.config.js +++ b/examples/app/webpack.config.js @@ -4,7 +4,7 @@ const data = require('./package.json'); const webpack = require('webpack'); const Build = require('@jupyterlab/builder').Build; -const names = Object.keys(data.dependencies).filter(function(name) { +const names = Object.keys(data.dependencies).filter(function (name) { const packageData = require(name + '/package.json'); return packageData.jupyterlab !== undefined; }); diff --git a/examples/federated/core_package/webpack.config.js b/examples/federated/core_package/webpack.config.js index 7a7701a171d4..43f633b46ec9 100644 --- a/examples/federated/core_package/webpack.config.js +++ b/examples/federated/core_package/webpack.config.js @@ -10,7 +10,7 @@ const fs = require('fs-extra'); const path = require('path'); const Handlebars = require('handlebars'); -const names = Object.keys(data.dependencies).filter(function(name) { +const names = Object.keys(data.dependencies).filter(function (name) { const packageData = require(path.join(name, 'package.json')); return packageData.jupyterlab !== undefined; }); diff --git a/examples/federated/md_package/index.js b/examples/federated/md_package/index.js index 0547eabc927c..7135ce18b0f3 100644 --- a/examples/federated/md_package/index.js +++ b/examples/federated/md_package/index.js @@ -19,7 +19,7 @@ import { IMiddleToken } from '@jupyterlab/example-federated-middle'; * The command IDs used by the markdownviewer plugin. */ let CommandIDs; -(function(CommandIDs) { +(function (CommandIDs) { CommandIDs.markdownPreview = 'markdownviewer:open'; CommandIDs.markdownEditor = 'markdownviewer:edit'; })(CommandIDs || (CommandIDs = {})); diff --git a/examples/federated/middle_package/extension.js b/examples/federated/middle_package/extension.js index 68f42131256d..16aab6dc4fdd 100644 --- a/examples/federated/middle_package/extension.js +++ b/examples/federated/middle_package/extension.js @@ -8,7 +8,7 @@ module.exports = [ id: '@jupyterlab/example-federated-middle', autoStart: true, provides: IMiddleToken, - activate: function(app) { + activate: function (app) { console.log('JupyterLab extension middle is activated!'); console.log(app.commands); return 'hello'; diff --git a/examples/federated/phosphor_package/index.js b/examples/federated/phosphor_package/index.js index 3d6e20ea4b2a..a8841957ea20 100644 --- a/examples/federated/phosphor_package/index.js +++ b/examples/federated/phosphor_package/index.js @@ -8,7 +8,7 @@ const plugins = [ { id: '@jupyterlab/example-federated-phosphor', autoStart: true, - activate: function(app) { + activate: function (app) { const mywidget = new Widget(); mywidget.node.textContent = 'Phosphor extension'; mywidget.id = '@jupyterlab/example-federated-phosphor'; diff --git a/examples/filebrowser/sample.md b/examples/filebrowser/sample.md index ea5351b6a4fc..19586ddc6490 100644 --- a/examples/filebrowser/sample.md +++ b/examples/filebrowser/sample.md @@ -38,17 +38,7 @@ You can look at different level of nested unordered list ljbakjn arsvlasc asc as - level 1 Ordered list -1. level 1 - 2. level 1 - 3. level 1 - 4. level 1 - 1. level 1 - 1. level 1 - 2. level 1 - 3. level 1 - 4. level 1 - 1. level 1 - 1. level 1 +1. level 1 2. level 1 3. level 1 4. level 1 1. level 1 1. level 1 2. level 1 3. level 1 4. level 1 1. level 1 1. level 1 2. level 1 3. level 1 some Horizontal line diff --git a/jupyterlab/staging/webpack.config.js b/jupyterlab/staging/webpack.config.js index 0211e7a1b11d..c39a9703354a 100644 --- a/jupyterlab/staging/webpack.config.js +++ b/jupyterlab/staging/webpack.config.js @@ -107,7 +107,7 @@ fs.writeFileSync(entryPoint, bootstrap); // Set up variables for the watch mode ignore plugins const watched = {}; const ignoreCache = Object.create(null); -Object.keys(jlab.linkedPackages).forEach(function(name) { +Object.keys(jlab.linkedPackages).forEach(function (name) { if (name in watched) { return; } @@ -135,7 +135,7 @@ function maybeSync(localPath, name, rest) { if (source === fs.realpathSync(localPath)) { return; } - fs.watchFile(source, { interval: 500 }, function(curr) { + fs.watchFile(source, { interval: 500 }, function (curr) { if (!curr || curr.nlink === 0) { return; } diff --git a/jupyterlab/tests/mock_packages/extension/index.js b/jupyterlab/tests/mock_packages/extension/index.js index e069c30c40b0..4897a4b77f50 100644 --- a/jupyterlab/tests/mock_packages/extension/index.js +++ b/jupyterlab/tests/mock_packages/extension/index.js @@ -8,7 +8,7 @@ module.exports = [ id: 'mockextension', requires: [ILauncher], autoStart: true, - activate: function(application, launcher) { + activate: function (application, launcher) { // eslint-disable-next-line no-console console.log('mock extension activated', launcher); window.commands = application.commands; diff --git a/jupyterlab/tests/mock_packages/incompat/index.js b/jupyterlab/tests/mock_packages/incompat/index.js index 848e028282fe..ac0f4caf36ba 100644 --- a/jupyterlab/tests/mock_packages/incompat/index.js +++ b/jupyterlab/tests/mock_packages/incompat/index.js @@ -5,7 +5,7 @@ module.exports = [ { id: 'mockextension', autoStart: true, - activate: function(application) { + activate: function (application) { // eslint-disable-next-line no-console console.log('mock extension activated'); window.commands = application.commands; diff --git a/jupyterlab/tests/mock_packages/mimeextension/index.js b/jupyterlab/tests/mock_packages/mimeextension/index.js index 861820cf3418..b04b4df029bd 100644 --- a/jupyterlab/tests/mock_packages/mimeextension/index.js +++ b/jupyterlab/tests/mock_packages/mimeextension/index.js @@ -7,7 +7,7 @@ var factory = { safe: true, mimeTypes: ['text/plain'], defaultRank: 1000, - createRenderer: function() { + createRenderer: function () { return new Widget(); } }; diff --git a/packages/application/src/connectionlost.ts b/packages/application/src/connectionlost.ts index 2241aae8591b..ee648218f4e4 100644 --- a/packages/application/src/connectionlost.ts +++ b/packages/application/src/connectionlost.ts @@ -12,7 +12,7 @@ import { IConnectionLost } from './tokens'; /** * A default connection lost handler, which brings up an error dialog. */ -export const ConnectionLost: IConnectionLost = async function( +export const ConnectionLost: IConnectionLost = async function ( manager: ServiceManager.IManager, err: ServerConnection.NetworkError, translator?: ITranslator diff --git a/packages/apputils-extension/src/workspacesplugin.ts b/packages/apputils-extension/src/workspacesplugin.ts index 9ca8675e48e4..765b13fd1338 100644 --- a/packages/apputils-extension/src/workspacesplugin.ts +++ b/packages/apputils-extension/src/workspacesplugin.ts @@ -180,10 +180,7 @@ namespace Private { if (lastSave === undefined) { defaultName = 'new-workspace'; } else { - defaultName = (lastSave as string) - .split('/') - .pop() - ?.split('.')[0]; + defaultName = (lastSave as string).split('/').pop()?.split('.')[0]; } const defaultPath = browser.model.path + '/' + defaultName + WORKSPACE_EXT; diff --git a/packages/apputils/src/mainareawidget.ts b/packages/apputils/src/mainareawidget.ts index e355e35c2384..6c72dc60912f 100644 --- a/packages/apputils/src/mainareawidget.ts +++ b/packages/apputils/src/mainareawidget.ts @@ -24,7 +24,8 @@ import { Printing } from './printing'; * This widget is automatically disposed when closed. * This widget ensures its own focus when activated. */ -export class MainAreaWidget extends Widget +export class MainAreaWidget + extends Widget implements Printing.IPrintable { /** * Construct a new main area widget. diff --git a/packages/cells/src/widget.ts b/packages/cells/src/widget.ts index 0b5c9ff7479b..a5fcf730d840 100644 --- a/packages/cells/src/widget.ts +++ b/packages/cells/src/widget.ts @@ -1463,8 +1463,9 @@ export class MarkdownCell extends AttachmentsCell { attachmentName: string, URI?: string ) { - const textToBeAppended = `![${attachmentName}](attachment:${URI ?? - attachmentName})`; + const textToBeAppended = `![${attachmentName}](attachment:${ + URI ?? attachmentName + })`; this.editor.replaceSelection?.(textToBeAppended); } diff --git a/packages/cells/test/model.spec.ts b/packages/cells/test/model.spec.ts index fb194bd146a0..3723f17c2458 100644 --- a/packages/cells/test/model.spec.ts +++ b/packages/cells/test/model.spec.ts @@ -304,7 +304,11 @@ describe('cells/model', () => { // Setting `collapsed` works model = new CodeCellModel({ - cell: { cell_type: 'code', source: '', metadata: { collapsed: true } } + cell: { + cell_type: 'code', + source: '', + metadata: { collapsed: true } + } }); expect(model.metadata.get('collapsed')).toBe(true); jupyter = model.metadata.get('jupyter') as JSONObject; diff --git a/packages/codemirror/src/mode.ts b/packages/codemirror/src/mode.ts index 5b95c362e693..ba49bc301be4 100644 --- a/packages/codemirror/src/mode.ts +++ b/packages/codemirror/src/mode.ts @@ -69,11 +69,13 @@ export namespace Mode { }, { // Fetch the mode asynchronously. - loader: function(spec) { + loader: function (spec) { return new Promise((resolve, reject) => { // An arrow function below seems to miscompile in our current webpack to // invalid js. - require([`codemirror/mode/${spec.mode}/${spec.mode}.js`], function() { + require([ + `codemirror/mode/${spec.mode}/${spec.mode}.js` + ], function () { resolve(true); }); }); diff --git a/packages/console/src/panel.ts b/packages/console/src/panel.ts index 44c51f690c9d..18be5becb9ca 100644 --- a/packages/console/src/panel.ts +++ b/packages/console/src/panel.ts @@ -252,7 +252,8 @@ export namespace ConsolePanel { /** * Default implementation of `IContentFactory`. */ - export class ContentFactory extends CodeConsole.ContentFactory + export class ContentFactory + extends CodeConsole.ContentFactory implements IContentFactory { /** * Create a new console panel. diff --git a/packages/console/src/widget.ts b/packages/console/src/widget.ts index 2265689f3492..93da1105de11 100644 --- a/packages/console/src/widget.ts +++ b/packages/console/src/widget.ts @@ -892,7 +892,8 @@ export namespace CodeConsole { /** * Default implementation of `IContentFactory`. */ - export class ContentFactory extends Cell.ContentFactory + export class ContentFactory + extends Cell.ContentFactory implements IContentFactory { /** * Create a new code cell widget. diff --git a/packages/console/test/foreign.spec.ts b/packages/console/test/foreign.spec.ts index 408716ae9df6..ee24c7aaa219 100644 --- a/packages/console/test/foreign.spec.ts +++ b/packages/console/test/foreign.spec.ts @@ -116,7 +116,7 @@ describe('@jupyterlab/console', () => { content: { wait: false } }); - beforeAll(async function() { + beforeAll(async function () { const path = UUID.uuid4(); const kernel0 = new Mock.KernelMock({}); const kernel1 = Mock.cloneKernel(kernel0); diff --git a/packages/coreutils/src/text.ts b/packages/coreutils/src/text.ts index 2b037622f7f6..03c2d378b5e7 100644 --- a/packages/coreutils/src/text.ts +++ b/packages/coreutils/src/text.ts @@ -83,7 +83,7 @@ export namespace Text { * @returns the camel case version of the input string. */ export function camelCase(str: string, upper: boolean = false): string { - return str.replace(/^(\w)|[\s-_:]+(\w)/g, function(match, p1, p2) { + return str.replace(/^(\w)|[\s-_:]+(\w)/g, function (match, p1, p2) { if (p2) { return p2.toUpperCase(); } else { diff --git a/packages/docregistry/src/default.ts b/packages/docregistry/src/default.ts index c839f4f4d366..329ba78a4ad2 100644 --- a/packages/docregistry/src/default.ts +++ b/packages/docregistry/src/default.ts @@ -26,7 +26,8 @@ import { DocumentRegistry, IDocumentWidget } from './index'; /** * The default implementation of a document model. */ -export class DocumentModel extends CodeEditor.Model +export class DocumentModel + extends CodeEditor.Model implements DocumentRegistry.ICodeModel { /** * Construct a new document model. @@ -464,9 +465,11 @@ const DIRTY_CLASS = 'jp-mod-dirty'; * A document widget implementation. */ export class DocumentWidget< - T extends Widget = Widget, - U extends DocumentRegistry.IModel = DocumentRegistry.IModel -> extends MainAreaWidget implements IDocumentWidget { + T extends Widget = Widget, + U extends DocumentRegistry.IModel = DocumentRegistry.IModel + > + extends MainAreaWidget + implements IDocumentWidget { constructor(options: DocumentWidget.IOptions) { // Include the context ready promise in the widget reveal promise options.reveal = Promise.all([options.reveal, options.context.ready]); diff --git a/packages/docregistry/src/registry.ts b/packages/docregistry/src/registry.ts index db280b6f279c..52816d6ceae0 100644 --- a/packages/docregistry/src/registry.ts +++ b/packages/docregistry/src/registry.ts @@ -676,12 +676,7 @@ export class DocumentRegistry implements IDisposable { if (ft) { fts.push(ft); } - ext = - '.' + - ext - .split('.') - .slice(2) - .join('.'); + ext = '.' + ext.split('.').slice(2).join('.'); } return fts; } diff --git a/packages/extensionmanager-extension/examples/listings/index.js b/packages/extensionmanager-extension/examples/listings/index.js index d59a0f1ff106..090c558b1e68 100644 --- a/packages/extensionmanager-extension/examples/listings/index.js +++ b/packages/extensionmanager-extension/examples/listings/index.js @@ -9,7 +9,7 @@ __webpack_public_path__ = PageConfig.getOption('fullStaticUrl') + '/'; // This cannot be extracted because the public path is dynamic. require('./build/imports.css'); -window.addEventListener('load', async function() { +window.addEventListener('load', async function () { var JupyterLab = require('@jupyterlab/application').JupyterLab; var mods = [ diff --git a/packages/extensionmanager-extension/examples/listings/webpack.config.js b/packages/extensionmanager-extension/examples/listings/webpack.config.js index 8ed9e4bbee20..ca2700574377 100644 --- a/packages/extensionmanager-extension/examples/listings/webpack.config.js +++ b/packages/extensionmanager-extension/examples/listings/webpack.config.js @@ -3,7 +3,7 @@ var data = require('./package.json'); var Build = require('@jupyterlab/builder').Build; -var names = Object.keys(data.dependencies).filter(function(name) { +var names = Object.keys(data.dependencies).filter(function (name) { var packageData = require(name + '/package.json'); return packageData.jupyterlab !== undefined; }); diff --git a/packages/filebrowser/src/opendialog.ts b/packages/filebrowser/src/opendialog.ts index 01596aed3e22..43799077fa83 100644 --- a/packages/filebrowser/src/opendialog.ts +++ b/packages/filebrowser/src/opendialog.ts @@ -117,7 +117,8 @@ export namespace FileDialog { /** * Open dialog widget */ -class OpenDialog extends Widget +class OpenDialog + extends Widget implements Dialog.IBodyWidget { constructor( manager: IDocumentManager, diff --git a/packages/htmlviewer/src/index.tsx b/packages/htmlviewer/src/index.tsx index 845f7fac3ed5..05572dabe9b0 100644 --- a/packages/htmlviewer/src/index.tsx +++ b/packages/htmlviewer/src/index.tsx @@ -65,7 +65,8 @@ const CSS_CLASS = 'jp-HTMLViewer'; * requests, so that local HTML documents can access CSS, images, * etc from the files system. */ -export class HTMLViewer extends DocumentWidget