Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

30 changes: 15 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ repos:
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: requirements-txt-fixer
- repo: https://github.com/pre-commit/mirrors-eslint
rev: 9158d5162f915488785c296b5d08d6d18be10d32 # frozen: v10.3.0
hooks:
- id: eslint
files: \.[jt]sx?$ # *.js, *.jsx, *.ts and *.tsx
exclude: ipyparallel/nbextension/.*
types: [file]
additional_dependencies:
- "@typescript-eslint/eslint-plugin@2.27.0"
- "@typescript-eslint/parser@2.27.0"
- eslint@^6.0.0
- eslint-config-prettier@6.10.1
- eslint-plugin-prettier@3.1.4
- eslint-plugin-react@7.21.5
- typescript@4.1.3
# - repo: https://github.com/pre-commit/mirrors-eslint
# rev: 9158d5162f915488785c296b5d08d6d18be10d32 # frozen: v10.3.0
# hooks:
# - id: eslint
# files: \.[jt]sx?$ # *.js, *.jsx, *.ts and *.tsx
# exclude: ipyparallel/nbextension/.*
# types: [file]
# additional_dependencies:
# - "@typescript-eslint/eslint-plugin@8.59.2"
# - "@typescript-eslint/parser@2.27.0"
# - eslint@^6.0.0
# - eslint-config-prettier@6.10.1
# - eslint-plugin-prettier@3.1.4
# - eslint-plugin-react@7.21.5
# - typescript@4.1.3
65 changes: 65 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import js from "@eslint/js";
import { defineConfig } from "eslint/config";
import tseslint from "typescript-eslint";
import prettierRecommended from "eslint-plugin-prettier/recommended";
import globals from "globals";
import jupyterPlugin from "@jupyter/eslint-plugin";

// workaround: plugin recommended config doesn't enable itself
for (var cfg of jupyterPlugin.configs.recommended) {
cfg.plugins = {
jupyter: jupyterPlugin,
};
}

export default defineConfig([
{
ignores: ["node_modules", "dist", "coverage", "**/*.js", "**/*.d.ts"],
},
js.configs.recommended,
tseslint.configs.recommended,
jupyterPlugin.configs.recommended,
{
files: ["**/*.ts", "**/*.tsx"],
plugins: {
jupyter: jupyterPlugin,
},
languageOptions: {
globals: {
...globals.browser,
...globals.es2015,
...globals.node,
},
parserOptions: {
project: "tsconfig.eslint.json",
sourceType: "module",
},
},
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",
},
},
prettierRecommended,
]);
18 changes: 9 additions & 9 deletions lab/src/clusters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ export class ClusterManager extends Widget {
*/
protected onAfterAttach(msg: Message): void {
super.onAfterAttach(msg);
let node = this._clusterListing.node;
const node = this._clusterListing.node;
node.addEventListener("p-dragenter", this);
node.addEventListener("p-dragleave", this);
node.addEventListener("p-dragover", this);
Expand All @@ -293,7 +293,7 @@ export class ClusterManager extends Widget {
* Handle `before-detach` messages for the widget.
*/
protected onBeforeDetach(msg: Message): void {
let node = this._clusterListing.node;
const node = this._clusterListing.node;
node.removeEventListener("p-dragenter", this);
node.removeEventListener("p-dragleave", this);
node.removeEventListener("p-dragover", this);
Expand Down Expand Up @@ -378,13 +378,13 @@ export class ClusterManager extends Widget {
* Handle the `'mousemove'` event for the widget.
*/
private _evtMouseMove(event: MouseEvent): void {
let data = this._dragData;
const data = this._dragData;
if (!data) {
return;
}
// Check for a drag initialization.
let dx = Math.abs(event.clientX - data.pressX);
let dy = Math.abs(event.clientY - data.pressY);
const dx = Math.abs(event.clientX - data.pressX);
const dy = Math.abs(event.clientY - data.pressY);
if (dx >= DRAG_THRESHOLD || dy >= DRAG_THRESHOLD) {
event.preventDefault();
event.stopPropagation();
Expand Down Expand Up @@ -641,7 +641,7 @@ export namespace ClusterManager {
* A React component for a launcher button listing.
*/
function ClusterListing(props: IClusterListingProps) {
let listing = props.clusters.map((cluster) => {
const listing = props.clusters.map((cluster) => {
return (
<ClusterListingItem
isActive={cluster.id === props.activeClusterId}
Expand Down Expand Up @@ -716,13 +716,13 @@ function ClusterListingItem(props: IClusterListingItemProps) {
let cluster_state = "Stopped";
if (cluster.controller) {
cluster_state = cluster.controller.state.state;
if (cluster_state == "after") {
if (cluster_state === "after") {
cluster_state = "Stopped";
}
}

// stop action is 'delete' for already-stopped clusters
let STOP = cluster_state === "Stopped" ? "DELETE" : "STOP";
const STOP = cluster_state === "Stopped" ? "DELETE" : "STOP";

return (
<li
Expand All @@ -749,7 +749,7 @@ function ClusterListingItem(props: IClusterListingItemProps) {
/>
<button
className={`ipp-ClusterListingItem-button ipp-ClusterListingItem-start jp-mod-styled ${
cluster_state == "Stopped" ? "" : "ipp-hidden"
cluster_state === "Stopped" ? "" : "ipp-hidden"
}`}
onClick={async (evt) => {
evt.stopPropagation();
Expand Down
7 changes: 3 additions & 4 deletions lab/src/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ export class NewCluster extends React.Component<
*/
constructor(props: NewCluster.IProps) {
super(props);
let model: INewCluster;
model = props.initialModel;
const model: INewCluster = props.initialModel;

this.state = { model };
}
Expand All @@ -74,7 +73,7 @@ export class NewCluster extends React.Component<
* be sent as the result of the dialog.
*/
componentDidUpdate(): void {
let model: INewCluster = { ...this.state.model };
const model: INewCluster = { ...this.state.model };
this.props.stateEscapeHatch(model);
}

Expand Down Expand Up @@ -171,7 +170,7 @@ export class NewCluster extends React.Component<
*
* @param model: the initial model.
*
* @returns a promse that resolves with the user-selected Dialogs for the
* @returns a promise that resolves with the user-selected Dialogs for the
* cluster model. If they pressed the cancel button, it resolves with
* the original model.
*/
Expand Down
3 changes: 3 additions & 0 deletions lab/src/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare module "*.css" {}

declare module "*.svg" {}
19 changes: 10 additions & 9 deletions lab/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const plugin: JupyterFrontEndPlugin<void> = {
activate,
id: PLUGIN_ID,
requires: [IConsoleTracker, INotebookTracker, ISettingRegistry, IStateDB],
description: "Manage IPython Parallel clusters from the JupyterLab sidebar.",
optional: [ILabShell],
autoStart: true,
};
Expand All @@ -76,7 +77,7 @@ async function activate(
const id = "ipp-cluster-launcher";

const isLab = !!labShell;
const isRetroTree = PageConfig.getOption("retroPage") == "tree";
const isRetroTree = PageConfig.getOption("retroPage") === "tree";

const clientCodeInjector = async (model: IClusterModel) => {
const editor = await Private.getCurrentEditor(
Expand Down Expand Up @@ -177,7 +178,7 @@ async function activate(

// Whether the cluster clients should aggressively inject themselves
// into the current session.
let autoStartClient: boolean = false;
const autoStartClient: boolean = false;

// Update the existing trackers and signals in light of a change to the
// settings system. In particular, this reacts to a change in the setting
Expand Down Expand Up @@ -246,6 +247,7 @@ async function activate(
// If either is not found, it bails.
app.commands.addCommand(CommandIDs.injectClientCode, {
label: "Inject IPython Client Connection Code",
describedBy: {},
execute: async () => {
const cluster = Private.clusterFromClick(app, sidebar.clusterManager);
if (!cluster) {
Expand All @@ -258,6 +260,7 @@ async function activate(
// Add a command to launch a new cluster.
app.commands.addCommand(CommandIDs.newCluster, {
label: (args) => (args["isPalette"] ? "Create New Cluster" : "NEW"),
describedBy: {},
execute: () => sidebar.clusterManager.create(),
iconClass: (args) =>
args["isPalette"] ? "" : "jp-AddIcon jp-Icon jp-Icon-16",
Expand All @@ -273,6 +276,7 @@ async function activate(
// Add a command to launch a new cluster.
app.commands.addCommand(CommandIDs.startCluster, {
label: "Start Cluster",
describedBy: {},
execute: () => {
const cluster = Private.clusterFromClick(app, sidebar.clusterManager);
if (!cluster) {
Expand All @@ -285,6 +289,7 @@ async function activate(
// Add a command to stop a cluster.
app.commands.addCommand(CommandIDs.stopCluster, {
label: "Shutdown Cluster",
describedBy: {},
execute: () => {
const cluster = Private.clusterFromClick(app, sidebar.clusterManager);
if (!cluster) {
Expand All @@ -297,6 +302,7 @@ async function activate(
// Add a command to resize a cluster.
app.commands.addCommand(CommandIDs.scaleCluster, {
label: "Scale Cluster…",
describedBy: {},
execute: () => {
const cluster = Private.clusterFromClick(app, sidebar.clusterManager);
if (!cluster) {
Expand Down Expand Up @@ -361,11 +367,6 @@ async function activate(
}

namespace Private {
/**
* A private counter for ids.
*/
export let id = 0;

/**
* Whether a kernel should be used. Only evaluates to true
* if it is valid and in python.
Expand Down Expand Up @@ -438,7 +439,7 @@ rc`;
): Kernel.IKernelConnection | null | undefined {
// Get a handle on the most relevant kernel,
// whether it is attached to a notebook or a console.
let current = shell.currentWidget;
const current = shell.currentWidget;
let kernel: Kernel.IKernelConnection | null | undefined;
if (current && notebookTracker.has(current)) {
kernel = (current as NotebookPanel).sessionContext.session?.kernel;
Expand Down Expand Up @@ -467,7 +468,7 @@ rc`;
): Promise<CodeEditor.IEditor | null | undefined> {
// Get a handle on the most relevant kernel,
// whether it is attached to a notebook or a console.
let current = app.shell.currentWidget;
const current = app.shell.currentWidget;
let editor: CodeEditor.IEditor | null | undefined;
if (current && notebookTracker.has(current)) {
NotebookActions.insertAbove((current as NotebookPanel).content);
Expand Down
2 changes: 1 addition & 1 deletion lab/src/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class Sidebar extends Widget {
constructor(options: Sidebar.IOptions) {
super();
this.addClass("ipp-Sidebar");
let layout = (this.layout = new PanelLayout());
const layout = (this.layout = new PanelLayout());

const injectClientCodeForCluster = options.clientCodeInjector;
const getClientCodeForCluster = options.clientCodeGetter;
Expand Down
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,23 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@eslint/js": "^9.0.0",
"@jupyter/eslint-plugin": "^1.0.0",
"@jupyterlab/builder": "^4.5.7",
"@types/react": "^18.0.26",
"@types/react-dom": "~18.3.7",
"@typescript-eslint/eslint-plugin": "^8.59.2",
"@typescript-eslint/parser": "^8.59.2",
"eslint": "^10.2.1",
"eslint-config-prettier": "^10.1.8",
"eslint": "^9.7",
"eslint-config-prettier": "^9",
"eslint-plugin-prettier": "^5.5.5",
"eslint-plugin-react": "^7.37.5",
"jsonc-eslint-parser": "^3.1.0",
"npm-run-all2": "^8.0.4",
"prettier": "^3.8.3",
"rimraf": "^6.1.3",
"typescript": "~5.9.3"
"typescript": "~6.0.3",
"typescript-eslint": "^8.59.3"
},
"resolutions": {
"@types/react": "^18.0.26"
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"jsx": "react",
"module": "esnext",
"moduleResolution": "node",
"moduleResolution": "bundler",
"noEmitOnError": true,
"noImplicitAny": true,
"noUnusedLocals": true,
Expand Down
Loading
Loading