From 5fdcd7a340ef2300ac2316b37df0a95cd73bf90f Mon Sep 17 00:00:00 2001 From: Dou Du Date: Thu, 16 May 2024 15:27:25 +0200 Subject: [PATCH] fix format by lint fix --- README.md | 6 +- package.json | 394 +++++++++++----------- src/index.ts | 47 +-- src/preview.tsx | 10 +- style/index.css | 2 +- style/variables.css | 8 +- ui-tests/tests/appmode_jupyterlab.spec.ts | 4 +- 7 files changed, 236 insertions(+), 235 deletions(-) diff --git a/README.md b/README.md index 1fcd7a3..9f107e6 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,13 @@ ![Github Actions Status](https://github.com/osscar-org/appmode-jupyterlab/workflows/Build/badge.svg) -A JupyterLab extension for Appmode (https://github.com/oschuett/appmode). +A JupyterLab extension for Appmode (https://github.com/oschuett/appmode). This extension is created from the modification of the voila JupyterLab extension code (https://github.com/voila-dashboards/voila). - - ## Requirements -* JupyterLab >= 4.0 +- JupyterLab >= 4.0 ## Install diff --git a/package.json b/package.json index 471399e..14943fc 100644 --- a/package.json +++ b/package.json @@ -1,205 +1,205 @@ { - "name": "@osscar/appmode-jupyterlab", - "version": "1.0.0", - "description": "A JupyterLab extension for Appmode.", - "keywords": [ - "jupyter", - "jupyterlab", - "jupyterlab-extension" - ], - "homepage": "https://github.com/osscar-org/appmode-jupyterlab", - "bugs": { - "url": "https://github.com/osscar-org/appmode-jupyterlab/issues" - }, - "license": "BSD-3-Clause", - "author": "Dou Du", - "files": [ - "lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}", - "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}", - "src/**/*.{ts,tsx}", - "schema/*.json" - ], - "main": "lib/index.js", - "types": "lib/index.d.ts", - "style": "style/index.css", - "repository": { - "type": "git", - "url": "https://github.com/osscar-org/appmode-jupyterlab.git" - }, - "scripts": { - "build": "jlpm build:lib && jlpm build:labextension:dev", - "build:prod": "jlpm clean && jlpm build:lib:prod && jlpm build:labextension", - "build:labextension": "jupyter labextension build .", - "build:labextension:dev": "jupyter labextension build --development True .", - "build:lib": "tsc --sourceMap", - "build:lib:prod": "tsc", - "clean": "jlpm clean:lib", - "clean:lib": "rimraf lib tsconfig.tsbuildinfo", - "clean:lintcache": "rimraf .eslintcache .stylelintcache", - "clean:labextension": "rimraf appmode_jupyterlab/labextension appmode_jupyterlab/_version.py", - "clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache", - "eslint": "jlpm eslint:check --fix", - "eslint:check": "eslint . --cache --ext .ts,.tsx", - "install:extension": "jlpm build", - "lint": "jlpm stylelint && jlpm prettier && jlpm eslint", - "lint:check": "jlpm stylelint:check && jlpm prettier:check && jlpm eslint:check", - "prettier": "jlpm prettier:base --write --list-different", - "prettier:base": "prettier \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"", - "prettier:check": "jlpm prettier:base --check", - "stylelint": "jlpm stylelint:check --fix", - "stylelint:check": "stylelint --cache \"style/**/*.css\"", - "test": "jest --coverage", - "watch": "run-p watch:src watch:labextension", - "watch:src": "tsc -w --sourceMap", - "watch:labextension": "jupyter labextension watch ." - }, - "dependencies": { - "@jupyterlab/application": "^4.0.0", - "@jupyterlab/apputils": "^4.0.0", - "@jupyterlab/docregistry": "^4.0.0", - "@jupyterlab/fileeditor": "^4.0.0", - "@jupyterlab/mainmenu": "^4.0.0", - "@jupyterlab/notebook": "^4.0.0", - "@jupyterlab/settingregistry": "^4.0.0", - "react": "~18.2.0", - "react-dom": "~18.2.0" - }, - "devDependencies": { - "@jupyterlab/builder": "^4.0.0", - "@jupyterlab/testutils": "^4.0.0", - "@types/jest": "^29.2.0", - "@types/json-schema": "^7.0.11", - "@types/react": "^18.0.26", - "@types/react-addons-linked-state-mixin": "^0.14.22", - "@types/react-dom": "~18.2.23", - "@typescript-eslint/eslint-plugin": "^6.1.0", - "@typescript-eslint/parser": "^6.1.0", - "css-loader": "^6.7.1", - "eslint": "^8.36.0", - "eslint-config-prettier": "^8.8.0", - "eslint-plugin-prettier": "^5.0.0", - "jest": "^29.2.0", - "npm-run-all": "^4.1.5", - "prettier": "^3.0.0", - "rimraf": "^5.0.1", - "source-map-loader": "^1.0.2", - "style-loader": "^3.3.1", - "stylelint": "^15.10.1", - "stylelint-config-recommended": "^13.0.0", - "stylelint-config-standard": "^34.0.0", - "stylelint-csstree-validator": "^3.0.0", - "stylelint-prettier": "^4.0.0", - "typescript": "~5.0.2", - "yjs": "^13.5.0" - }, - "sideEffects": [ - "style/*.css", - "style/index.js" - ], - "styleModule": "style/index.js", - "publishConfig": { - "access": "public" - }, - "jupyterlab": { - "extension": true, - "outputDir": "appmode_jupyterlab/labextension", - "schemaDir": "schema" - }, - "directories": { - "lib": "lib" - }, - "eslintIgnore": [ - "node_modules", - "dist", - "coverage", - "**/*.d.ts", - "tests", - "**/__tests__", - "ui-tests" - ], - "eslintConfig": { - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended", - "plugin:prettier/recommended" + "name": "@osscar/appmode-jupyterlab", + "version": "1.0.0", + "description": "A JupyterLab extension for Appmode.", + "keywords": [ + "jupyter", + "jupyterlab", + "jupyterlab-extension" ], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": "tsconfig.json", - "sourceType": "module" + "homepage": "https://github.com/osscar-org/appmode-jupyterlab", + "bugs": { + "url": "https://github.com/osscar-org/appmode-jupyterlab/issues" }, - "plugins": [ - "@typescript-eslint" + "license": "BSD-3-Clause", + "author": "Dou Du", + "files": [ + "lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}", + "style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}", + "src/**/*.{ts,tsx}", + "schema/*.json" ], - "rules": { - "@typescript-eslint/naming-convention": [ - "error", - { - "selector": "interface", - "format": [ - "PascalCase" - ], - "custom": { - "regex": "^I[A-Z]", - "match": true - } - } - ], - "@typescript-eslint/no-unused-vars": [ - "warn", - { - "args": "none" - } - ], - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-namespace": "off", - "@typescript-eslint/no-use-before-define": "off", - "@typescript-eslint/quotes": [ - "error", - "single", - { - "avoidEscape": true, - "allowTemplateLiterals": false - } - ], - "curly": [ - "error", - "all" - ], - "eqeqeq": "error", - "prefer-arrow-callback": "error" - } - }, - "prettier": { - "singleQuote": true, - "trailingComma": "none", - "arrowParens": "avoid", - "endOfLine": "auto", - "overrides": [ - { - "files": "package.json", - "options": { - "tabWidth": 4 - } - } - ] - }, - "stylelint": { - "extends": [ - "stylelint-config-recommended", - "stylelint-config-standard", - "stylelint-prettier/recommended" + "main": "lib/index.js", + "types": "lib/index.d.ts", + "style": "style/index.css", + "repository": { + "type": "git", + "url": "https://github.com/osscar-org/appmode-jupyterlab.git" + }, + "scripts": { + "build": "jlpm build:lib && jlpm build:labextension:dev", + "build:prod": "jlpm clean && jlpm build:lib:prod && jlpm build:labextension", + "build:labextension": "jupyter labextension build .", + "build:labextension:dev": "jupyter labextension build --development True .", + "build:lib": "tsc --sourceMap", + "build:lib:prod": "tsc", + "clean": "jlpm clean:lib", + "clean:lib": "rimraf lib tsconfig.tsbuildinfo", + "clean:lintcache": "rimraf .eslintcache .stylelintcache", + "clean:labextension": "rimraf appmode_jupyterlab/labextension appmode_jupyterlab/_version.py", + "clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache", + "eslint": "jlpm eslint:check --fix", + "eslint:check": "eslint . --cache --ext .ts,.tsx", + "install:extension": "jlpm build", + "lint": "jlpm stylelint && jlpm prettier && jlpm eslint", + "lint:check": "jlpm stylelint:check && jlpm prettier:check && jlpm eslint:check", + "prettier": "jlpm prettier:base --write --list-different", + "prettier:base": "prettier \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"", + "prettier:check": "jlpm prettier:base --check", + "stylelint": "jlpm stylelint:check --fix", + "stylelint:check": "stylelint --cache \"style/**/*.css\"", + "test": "jest --coverage", + "watch": "run-p watch:src watch:labextension", + "watch:src": "tsc -w --sourceMap", + "watch:labextension": "jupyter labextension watch ." + }, + "dependencies": { + "@jupyterlab/application": "^4.0.0", + "@jupyterlab/apputils": "^4.0.0", + "@jupyterlab/docregistry": "^4.0.0", + "@jupyterlab/fileeditor": "^4.0.0", + "@jupyterlab/mainmenu": "^4.0.0", + "@jupyterlab/notebook": "^4.0.0", + "@jupyterlab/settingregistry": "^4.0.0", + "react": "~18.2.0", + "react-dom": "~18.2.0" + }, + "devDependencies": { + "@jupyterlab/builder": "^4.0.0", + "@jupyterlab/testutils": "^4.0.0", + "@types/jest": "^29.2.0", + "@types/json-schema": "^7.0.11", + "@types/react": "^18.0.26", + "@types/react-addons-linked-state-mixin": "^0.14.22", + "@types/react-dom": "~18.2.23", + "@typescript-eslint/eslint-plugin": "^6.1.0", + "@typescript-eslint/parser": "^6.1.0", + "css-loader": "^6.7.1", + "eslint": "^8.36.0", + "eslint-config-prettier": "^8.8.0", + "eslint-plugin-prettier": "^5.0.0", + "jest": "^29.2.0", + "npm-run-all": "^4.1.5", + "prettier": "^3.0.0", + "rimraf": "^5.0.1", + "source-map-loader": "^1.0.2", + "style-loader": "^3.3.1", + "stylelint": "^15.10.1", + "stylelint-config-recommended": "^13.0.0", + "stylelint-config-standard": "^34.0.0", + "stylelint-csstree-validator": "^3.0.0", + "stylelint-prettier": "^4.0.0", + "typescript": "~5.0.2", + "yjs": "^13.5.0" + }, + "sideEffects": [ + "style/*.css", + "style/index.js" ], - "plugins": [ - "stylelint-csstree-validator" + "styleModule": "style/index.js", + "publishConfig": { + "access": "public" + }, + "jupyterlab": { + "extension": true, + "outputDir": "appmode_jupyterlab/labextension", + "schemaDir": "schema" + }, + "directories": { + "lib": "lib" + }, + "eslintIgnore": [ + "node_modules", + "dist", + "coverage", + "**/*.d.ts", + "tests", + "**/__tests__", + "ui-tests" ], - "rules": { - "csstree/validator": true, - "property-no-vendor-prefix": null, - "selector-class-pattern": "^([a-z][A-z\\d]*)(-[A-z\\d]+)*$", - "selector-no-vendor-prefix": null, - "value-no-vendor-prefix": null + "eslintConfig": { + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended", + "plugin:prettier/recommended" + ], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "project": "tsconfig.json", + "sourceType": "module" + }, + "plugins": [ + "@typescript-eslint" + ], + "rules": { + "@typescript-eslint/naming-convention": [ + "error", + { + "selector": "interface", + "format": [ + "PascalCase" + ], + "custom": { + "regex": "^I[A-Z]", + "match": true + } + } + ], + "@typescript-eslint/no-unused-vars": [ + "warn", + { + "args": "none" + } + ], + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-namespace": "off", + "@typescript-eslint/no-use-before-define": "off", + "@typescript-eslint/quotes": [ + "error", + "single", + { + "avoidEscape": true, + "allowTemplateLiterals": false + } + ], + "curly": [ + "error", + "all" + ], + "eqeqeq": "error", + "prefer-arrow-callback": "error" + } + }, + "prettier": { + "singleQuote": true, + "trailingComma": "none", + "arrowParens": "avoid", + "endOfLine": "auto", + "overrides": [ + { + "files": "package.json", + "options": { + "tabWidth": 4 + } + } + ] + }, + "stylelint": { + "extends": [ + "stylelint-config-recommended", + "stylelint-config-standard", + "stylelint-prettier/recommended" + ], + "plugins": [ + "stylelint-csstree-validator" + ], + "rules": { + "csstree/validator": true, + "property-no-vendor-prefix": null, + "selector-class-pattern": "^([a-z][A-z\\d]*)(-[A-z\\d]+)*$", + "selector-no-vendor-prefix": null, + "value-no-vendor-prefix": null + } } - } } diff --git a/src/index.ts b/src/index.ts index 269b26f..48f49c4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,13 +1,13 @@ import { JupyterFrontEnd, JupyterFrontEndPlugin, - ILayoutRestorer, + ILayoutRestorer } from '@jupyterlab/application'; import { ICommandPalette, WidgetTracker, - ToolbarButton, + ToolbarButton } from '@jupyterlab/apputils'; import { ISettingRegistry } from '@jupyterlab/settingregistry'; @@ -21,7 +21,7 @@ import { IMainMenu } from '@jupyterlab/mainmenu'; import { INotebookTracker, NotebookPanel, - INotebookModel, + INotebookModel } from '@jupyterlab/notebook'; import { CommandRegistry } from '@lumino/commands'; @@ -34,7 +34,7 @@ import { APPMODE_ICON_CLASS, AppmodePreview, IAppmodePreviewTracker, - AppmodePreviewFactory, + AppmodePreviewFactory } from './preview'; import '../style/index.css'; @@ -52,7 +52,8 @@ export namespace CommandIDs { * A notebook widget extension that adds a appmode preview button to the toolbar. */ class AppmodeRenderButton - implements DocumentRegistry.IWidgetExtension { + implements DocumentRegistry.IWidgetExtension +{ /** * Instantiate a new AppmodeRenderButton. * @param commands The command registry. @@ -71,7 +72,7 @@ class AppmodeRenderButton iconClass: APPMODE_ICON_CLASS, onClick: () => { this._commands.execute(CommandIDs.appmodeOpen); - }, + } }); panel.toolbar.insertAfter('cellType', 'appmodeRender', button); return button; @@ -99,18 +100,18 @@ const extension: JupyterFrontEndPlugin = { ) => { // Create a widget tracker for VoilĂ  Previews. const tracker = new WidgetTracker({ - namespace: 'appmode-preview', + namespace: 'appmode-preview' }); if (restorer) { restorer.restore(tracker, { command: 'docmanager:open', - args: (panel) => ({ + args: panel => ({ path: panel.context.path, - factory: factory.name, + factory: factory.name }), - name: (panel) => panel.context.path, - when: app.serviceManager.ready, + name: panel => panel.context.path, + when: app.serviceManager.ready }); } @@ -140,7 +141,7 @@ const extension: JupyterFrontEndPlugin = { const factory = new AppmodePreviewFactory(getAppmodeUrl, { name: 'Appmode-preview', fileTypes: ['notebook'], - modelName: 'notebook', + modelName: 'notebook' }); factory.widgetCreated.connect((sender, widget) => { @@ -174,7 +175,7 @@ const extension: JupyterFrontEndPlugin = { commands.addCommand(CommandIDs.appmodeRender, { label: 'Render Notebook with Appmode', - execute: async (args) => { + execute: async args => { const current = getCurrent(args); let context: DocumentRegistry.IContext; if (current) { @@ -185,17 +186,17 @@ const extension: JupyterFrontEndPlugin = { path: context.path, factory: 'Appmode-preview', options: { - mode: 'split-right', - }, + mode: 'split-right' + } }); } }, - isEnabled, + isEnabled }); commands.addCommand(CommandIDs.appmodeOpen, { label: 'Open with Appmode in New Browser Tab', - execute: async (args) => { + execute: async args => { const current = getCurrent(args); if (!current) { return; @@ -204,12 +205,12 @@ const extension: JupyterFrontEndPlugin = { const appmodeUrl = getAppmodeUrl(current.context.path); window.open(appmodeUrl); }, - isEnabled, + isEnabled }); if (palette) { const category = 'Notebook Operations'; - [CommandIDs.appmodeRender, CommandIDs.appmodeOpen].forEach((command) => { + [CommandIDs.appmodeRender, CommandIDs.appmodeOpen].forEach(command => { palette.addItem({ command, category }); }); } @@ -218,11 +219,11 @@ const extension: JupyterFrontEndPlugin = { menu.viewMenu.addGroup( [ { - command: CommandIDs.appmodeRender, + command: CommandIDs.appmodeRender }, { - command: CommandIDs.appmodeOpen, - }, + command: CommandIDs.appmodeOpen + } ], 1000 ); @@ -232,7 +233,7 @@ const extension: JupyterFrontEndPlugin = { docRegistry.addWidgetExtension('Notebook', appmodeButton); return tracker; - }, + } }; export default extension; diff --git a/src/preview.tsx b/src/preview.tsx index 5beb52c..7144de1 100644 --- a/src/preview.tsx +++ b/src/preview.tsx @@ -2,13 +2,13 @@ import { IFrame, ToolbarButton, ReactWidget, - IWidgetTracker, + IWidgetTracker } from '@jupyterlab/apputils'; import { ABCWidgetFactory, DocumentRegistry, - DocumentWidget, + DocumentWidget } from '@jupyterlab/docregistry'; import { INotebookModel } from '@jupyterlab/notebook'; @@ -47,7 +47,7 @@ export class AppmodePreview extends DocumentWidget { constructor(options: AppmodePreview.IOptions) { super({ ...options, - content: new IFrame({ sandbox: ['allow-same-origin', 'allow-scripts'] }), + content: new IFrame({ sandbox: ['allow-same-origin', 'allow-scripts'] }) }); window.onmessage = (event: any) => { @@ -92,7 +92,7 @@ export class AppmodePreview extends DocumentWidget { tooltip: 'Reload Preview', onClick: () => { this.reload(); - }, + } }); const renderOnSaveCheckbox = ReactWidget.create( @@ -202,7 +202,7 @@ export class AppmodePreviewFactory extends ABCWidgetFactory< return new AppmodePreview({ context, getAppmodeUrl: this.getAppmodeUrl, - renderOnSave: this.defaultRenderOnSave, + renderOnSave: this.defaultRenderOnSave }); } } diff --git a/style/index.css b/style/index.css index 60bd776..72f5623 100644 --- a/style/index.css +++ b/style/index.css @@ -1,4 +1,4 @@ -@import "variables.css"; +@import url('variables.css'); .jp-AppmodeIcon { background-image: var(--jp-icon-appmode); diff --git a/style/variables.css b/style/variables.css index 2d324cd..9e787dc 100644 --- a/style/variables.css +++ b/style/variables.css @@ -1,7 +1,7 @@ -[data-jp-theme-light="true"] { - --jp-icon-appmode: url("./gears.svg"); +[data-jp-theme-light='true'] { + --jp-icon-appmode: url('./gears.svg'); } -[data-jp-theme-light="false"] { - --jp-icon-appmode: url("./gears.svg"); +[data-jp-theme-light='false'] { + --jp-icon-appmode: url('./gears.svg'); } diff --git a/ui-tests/tests/appmode_jupyterlab.spec.ts b/ui-tests/tests/appmode_jupyterlab.spec.ts index d0d13cb..1af0327 100644 --- a/ui-tests/tests/appmode_jupyterlab.spec.ts +++ b/ui-tests/tests/appmode_jupyterlab.spec.ts @@ -16,6 +16,8 @@ test('should emit an activation console message', async ({ page }) => { await page.goto(); expect( - logs.filter(s => s === 'JupyterLab extension appmode-jupyterlab is activated!') + logs.filter( + s => s === 'JupyterLab extension appmode-jupyterlab is activated!' + ) ).toHaveLength(1); });