Skip to content

Commit

Permalink
Lint - updates from the new version of prettier.
Browse files Browse the repository at this point in the history
I added two prettier config options to minimize the churn - we can remove them when we decide we can deal with the churn they introduce (quite a lot).

The decision to add a space after function names also introduces quite a bit of churn, but there is no option to disable it. See prettier/prettier#3903 (where there was quite a lot of support for adding such an option to minimize needless churn, but was decided against by the prettier team, which was disappointing to me.)
  • Loading branch information
jasongrout committed Aug 27, 2020
1 parent 3652da3 commit 52d4413
Show file tree
Hide file tree
Showing 58 changed files with 119 additions and 116 deletions.
4 changes: 3 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"singleQuote": true
"singleQuote": true,
"trailingComma": "none",
"arrowParens": "avoid"
}
5 changes: 1 addition & 4 deletions buildutils/src/add-sibling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion buildutils/src/ensure-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion buildutils/src/update-dependency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ commander
}
);

commander.on('--help', function() {
commander.on('--help', function () {
console.debug(`
Examples
--------
Expand Down
12 changes: 3 additions & 9 deletions buildutils/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()!;
}

/**
Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions dev_mode/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion docs/scripts/graph-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion examples/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion examples/app/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down
2 changes: 1 addition & 1 deletion examples/federated/core_package/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down
2 changes: 1 addition & 1 deletion examples/federated/md_package/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/federated/middle_package/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion examples/federated/phosphor_package/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
12 changes: 1 addition & 11 deletions examples/filebrowser/sample.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions jupyterlab/staging/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion jupyterlab/tests/mock_packages/extension/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion jupyterlab/tests/mock_packages/incompat/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion jupyterlab/tests/mock_packages/mimeextension/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var factory = {
safe: true,
mimeTypes: ['text/plain'],
defaultRank: 1000,
createRenderer: function() {
createRenderer: function () {
return new Widget();
}
};
Expand Down
2 changes: 1 addition & 1 deletion packages/application/src/connectionlost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions packages/apputils-extension/src/workspacesplugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion packages/apputils/src/mainareawidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T extends Widget = Widget> extends Widget
export class MainAreaWidget<T extends Widget = Widget>
extends Widget
implements Printing.IPrintable {
/**
* Construct a new main area widget.
Expand Down
5 changes: 3 additions & 2 deletions packages/cells/src/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1463,8 +1463,9 @@ export class MarkdownCell extends AttachmentsCell<IMarkdownCellModel> {
attachmentName: string,
URI?: string
) {
const textToBeAppended = `![${attachmentName}](attachment:${URI ??
attachmentName})`;
const textToBeAppended = `![${attachmentName}](attachment:${
URI ?? attachmentName
})`;
this.editor.replaceSelection?.(textToBeAppended);
}

Expand Down
6 changes: 5 additions & 1 deletion packages/cells/test/model.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions packages/codemirror/src/mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,13 @@ export namespace Mode {
},
{
// Fetch the mode asynchronously.
loader: function(spec) {
loader: function (spec) {
return new Promise<boolean>((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);
});
});
Expand Down
3 changes: 2 additions & 1 deletion packages/console/src/panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion packages/console/src/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion packages/console/test/foreign.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/coreutils/src/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 7 additions & 4 deletions packages/docregistry/src/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<T> implements IDocumentWidget<T, U> {
T extends Widget = Widget,
U extends DocumentRegistry.IModel = DocumentRegistry.IModel
>
extends MainAreaWidget<T>
implements IDocumentWidget<T, U> {
constructor(options: DocumentWidget.IOptions<T, U>) {
// Include the context ready promise in the widget reveal promise
options.reveal = Promise.all([options.reveal, options.context.ready]);
Expand Down
7 changes: 1 addition & 6 deletions packages/docregistry/src/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down
3 changes: 2 additions & 1 deletion packages/filebrowser/src/opendialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ export namespace FileDialog {
/**
* Open dialog widget
*/
class OpenDialog extends Widget
class OpenDialog
extends Widget
implements Dialog.IBodyWidget<Contents.IModel[]> {
constructor(
manager: IDocumentManager,
Expand Down
Loading

0 comments on commit 52d4413

Please sign in to comment.