Skip to content

Commit e556df5

Browse files
committedMay 23, 2022
chore: eslint and prettier and husky
1 parent 7dbc1e5 commit e556df5

File tree

18 files changed

+5166
-2326
lines changed

18 files changed

+5166
-2326
lines changed
 

Diff for: ‎.husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx lint-staged

Diff for: ‎.prettierignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/dist
2+
plugins/*/dist
3+
plugins/*/mdist

Diff for: ‎package-lock.json

+4,894-2,114
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ‎package.json

+47
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,70 @@
2828
"build:electron:all": "KUI_KEEP_NODE_MODULE=\"$(cat mw-node-modules.txt)\" KUI_HEADLESS_WEBPACK=true KUI_LAUNCHER=$PWD/bin/codeflare kui-build-electron",
2929
"build": "npm run compile && webpack --mode production",
3030
"postinstall": "npm run compile",
31+
"format": "prettier --write '**/*.{scss,css,html,js,json,md,ts,tsx}'",
32+
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
3133
"open": "electron . shell",
3234
"start": "WATCH_ARGS='-open' npm run watch",
3335
"test": "echo \"Error: no test specified\" && exit 1"
3436
},
3537
"keywords": [],
3638
"author": "@starpit",
3739
"license": "Apache-2.0",
40+
"eslintConfig": {
41+
"parser": "@typescript-eslint/parser",
42+
"plugins": [
43+
"@typescript-eslint"
44+
],
45+
"env": {
46+
"browser": true,
47+
"node": true
48+
},
49+
"rules": {
50+
"@typescript-eslint/no-unused-vars": "error"
51+
},
52+
"extends": [
53+
"eslint:recommended",
54+
"plugin:@typescript-eslint/recommended"
55+
]
56+
},
57+
"eslintIgnore": [
58+
"mdist",
59+
"dist",
60+
".#*",
61+
"*~"
62+
],
63+
"lint-staged": {
64+
"**/*.{scss,css,html,js,json,md,ts,tsx}": [
65+
"prettier --write",
66+
"git add"
67+
],
68+
"**/*.{js,ts,tsx}": [
69+
"eslint --fix",
70+
"git add"
71+
]
72+
},
73+
"prettier": {
74+
"semi": false,
75+
"printWidth": 120
76+
},
3877
"devDependencies": {
3978
"@kui-shell/builder": "11.5.0-dev-20220523-155545",
4079
"@kui-shell/proxy": "11.5.0-dev-20220523-155545",
4180
"@kui-shell/react": "11.5.0-dev-20220523-155545",
4281
"@kui-shell/webpack": "11.5.0-dev-20220523-155545",
82+
"@types/debug": "^4.1.7",
4383
"@types/node": "14.11.8",
4484
"@types/react": "17.0.39",
4585
"@types/react-dom": "17.0.11",
86+
"@types/uuid": "^8.3.4",
87+
"@typescript-eslint/eslint-plugin": "^5.25.0",
88+
"@typescript-eslint/parser": "^5.25.0",
4689
"concurrently": "7.2.0",
4790
"electron": "18.2.4",
91+
"eslint": "^8.15.0",
92+
"husky": "^8.0.1",
93+
"lint-staged": "^12.4.1",
94+
"prettier": "^2.6.2",
4895
"typescript": "4.6.4"
4996
},
5097
"dependencies": {

Diff for: ‎plugins/plugin-client-default/config.d/exec.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
{
2-
}
1+
{}
+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
22
"label": "Notebooks",
3-
"submenu": [
4-
]
3+
"submenu": []
54
}

Diff for: ‎plugins/plugin-client-default/src/index.tsx

+9-10
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@
1414
* limitations under the License.
1515
*/
1616

17-
import React from 'react'
17+
import React from "react"
1818

19-
import { Capabilities } from '@kui-shell/core'
20-
import { Kui, KuiProps, ContextWidgets, MeterWidgets, CurrentWorkingDirectory, SpaceFiller } from '@kui-shell/plugin-client-common'
19+
import { Capabilities } from "@kui-shell/core"
20+
import { Kui, KuiProps, ContextWidgets, MeterWidgets } from "@kui-shell/plugin-client-common"
2121

22-
import { CurrentContext, CurrentNamespace } from '@kui-shell/plugin-kubectl/components'
23-
import { Search } from '@kui-shell/plugin-electron-components'
22+
import { CurrentContext, CurrentNamespace } from "@kui-shell/plugin-kubectl/components"
23+
import { Search } from "@kui-shell/plugin-electron-components"
2424

25-
import { version } from '@kui-shell/client/package.json'
26-
import guidebooks from '@kui-shell/client/config.d/notebooks.json'
27-
import { productName } from '@kui-shell/client/config.d/name.json'
25+
import { version } from "@kui-shell/client/package.json"
26+
import guidebooks from "@kui-shell/client/config.d/notebooks.json"
27+
import { productName } from "@kui-shell/client/config.d/name.json"
2828

2929
/**
3030
* We will set this bit when the user dismisses the Welcome to Kui
@@ -56,8 +56,7 @@ export default function renderMain(props: KuiProps) {
5656
toplevel={!Capabilities.inBrowser() && <Search />}
5757
guidebooks={guidebooks.submenu}
5858
>
59-
<ContextWidgets>
60-
</ContextWidgets>
59+
<ContextWidgets></ContextWidgets>
6160

6261
<MeterWidgets>
6362
<CurrentContext />

Diff for: ‎plugins/plugin-codeflare/src/plugin.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { Registrar } from '@kui-shell/core'
17+
// import { Registrar } from '@kui-shell/core'
1818

1919
/** Register Kui Commands */
20-
export default function registerCodeflareCommands(registrar: Registrar) {
20+
export default function registerCodeflareCommands(/* registrar: Registrar */) {
2121
/* e.g. this command will executable as "run"
2222
registrar.listen('/run', args => {
2323
})

Diff for: ‎plugins/plugin-madwizard/src/components/Guide.tsx

+63-59
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
* limitations under the License.
1515
*/
1616

17-
import React from 'react'
18-
import { v4 } from 'uuid'
19-
import { i18n, Tab } from '@kui-shell/core'
20-
import { Markdown, Card, CardResponse, Icons } from '@kui-shell/plugin-client-common'
21-
import { Chip, ChipGroup, Grid, GridItem, Progress, Tile, WizardStep } from '@patternfly/react-core'
17+
import React from "react"
18+
import { v4 } from "uuid"
19+
import { i18n, Tab } from "@kui-shell/core"
20+
import { Markdown, Card, CardResponse, Icons } from "@kui-shell/plugin-client-common"
21+
import { Chip, ChipGroup, Grid, GridItem, Progress, Tile, WizardStep } from "@patternfly/react-core"
2222

2323
import {
2424
Choice,
@@ -40,16 +40,16 @@ import {
4040
ChoiceStep,
4141
isChoiceStep,
4242
TaskStep,
43-
isTaskStep
44-
} from 'madwizard'
43+
isTaskStep,
44+
} from "madwizard"
4545

46-
import read from '../read'
47-
import Wizard, { Props as WizardProps } from './Wizard/KWizard'
48-
import { statusToClassName, statusToIcon } from './StatusUI'
46+
import read from "../read"
47+
import Wizard, { Props as WizardProps } from "./Wizard/KWizard"
48+
import { statusToClassName, statusToIcon } from "./StatusUI"
4949

50-
import '@kui-shell/plugin-client-common/web/scss/components/Wizard/Guide.scss'
50+
import "@kui-shell/plugin-client-common/web/scss/components/Wizard/Guide.scss"
5151

52-
const strings = i18n('plugin-client-common', 'code')
52+
const strings = i18n("plugin-client-common", "code")
5353

5454
export type Props = Choices &
5555
Partial<Title> &
@@ -103,7 +103,7 @@ export default class Guide extends React.PureComponent<Props, State> {
103103
frontier: undefined,
104104
wizard: undefined,
105105
wizardStepStatus: undefined,
106-
choices: props.choices
106+
choices: props.choices,
107107
}
108108
setTimeout(() => this.init(props))
109109
}
@@ -112,14 +112,14 @@ export default class Guide extends React.PureComponent<Props, State> {
112112
* TODO move to a more common location?
113113
*/
114114
private static isValidFrontier(frontier: ReturnType<typeof findChoiceFrontier>): boolean {
115-
return frontier.length > 0 && frontier.every(_ => _.prereqs.length > 0 || !!_.choice)
115+
return frontier.length > 0 && frontier.every((_) => _.prereqs.length > 0 || !!_.choice)
116116
}
117117

118-
private async init(props: Props, useTheseChoices?: State['choices']) {
118+
private async init(props: Props, useTheseChoices?: State["choices"]) {
119119
const choices = useTheseChoices || props.choices
120-
const newGraph = await compile(props.blocks, choices, undefined, 'sequence', props.title, props.description)
120+
const newGraph = await compile(props.blocks, choices, undefined, "sequence", props.title, props.description)
121121

122-
this.setState(state => {
122+
this.setState((state) => {
123123
const noChangeToGraph = state && sameGraph(state.graph, newGraph)
124124

125125
const graph = noChangeToGraph ? state.graph : order(newGraph)
@@ -154,14 +154,14 @@ export default class Guide extends React.PureComponent<Props, State> {
154154
}
155155

156156
/** @return a UI component to visualize the given markdown source */
157-
private renderContent(source: TaskStep['step']['content']) {
157+
private renderContent(source: TaskStep["step"]["content"]) {
158158
return (
159159
source &&
160160
this.stepContent(
161161
<Markdown
162162
tab={this.props.tab}
163163
nested
164-
source={typeof source === 'string' ? source : source()}
164+
source={typeof source === "string" ? source : source()}
165165
choices={this.state.choices}
166166
executeImmediately={this.state.isRunning}
167167
/>
@@ -183,16 +183,16 @@ export default class Guide extends React.PureComponent<Props, State> {
183183
* `this.onChoiceFromAbove()`
184184
*/
185185
private readonly onChoice = (evt: React.MouseEvent) => {
186-
const group = evt.currentTarget.getAttribute('data-choice-group')
187-
const title = evt.currentTarget.getAttribute('data-choice-title')
186+
const group = evt.currentTarget.getAttribute("data-choice-group")
187+
const title = evt.currentTarget.getAttribute("data-choice-title")
188188
this.props.choices.set(group, title)
189189
}
190190

191191
/** @return UI that offers the user a choice */
192192
private tilesForChoice(choice: Choice) {
193193
return this.stepContent(
194194
<Grid hasGutter span={4}>
195-
{choice.choices.map(_ => {
195+
{choice.choices.map((_) => {
196196
return (
197197
<GridItem key={_.title}>
198198
<Tile
@@ -214,12 +214,12 @@ export default class Guide extends React.PureComponent<Props, State> {
214214
)
215215
}
216216

217-
private withStatus(name: WizardStep['name'], status: Status) {
217+
private withStatus(name: WizardStep["name"], status: Status) {
218218
const icon = status && statusToIcon(status)
219219
if (icon) {
220220
return (
221221
<React.Fragment>
222-
{name} <span className={statusToClassName(status).join(' ') + ' kui--validator'}>{icon}</span>
222+
{name} <span className={statusToClassName(status).join(" ") + " kui--validator"}>{icon}</span>
223223
</React.Fragment>
224224
)
225225
} else {
@@ -249,9 +249,9 @@ export default class Guide extends React.PureComponent<Props, State> {
249249
stepNavItemProps: isFirstChoice && {
250250
children: this.wizardStepDescription(
251251
<span className="sub-text">{this.choiceIcon1} This step requires you to choose how to proceed</span>
252-
)
253-
}
254-
})
252+
),
253+
},
254+
}),
255255
}
256256
}
257257

@@ -261,12 +261,12 @@ export default class Guide extends React.PureComponent<Props, State> {
261261
status,
262262
graph,
263263
step: {
264-
name: step.name === 'Missing title' ? <span className="red-text">{step.name}</span> : step.name,
264+
name: step.name === "Missing title" ? <span className="red-text">{step.name}</span> : step.name,
265265
component: this.renderContent(step.content),
266266
stepNavItemProps: {
267-
children: this.wizardStepDescription(extractDescription(graph))
268-
}
269-
}
267+
children: this.wizardStepDescription(extractDescription(graph)),
268+
},
269+
},
270270
}
271271
}
272272

@@ -294,29 +294,29 @@ export default class Guide extends React.PureComponent<Props, State> {
294294
private validateStepsIfNeeded(steps: ReturnType<typeof this.wizardSteps>): WizardStep[] {
295295
Promise.all(
296296
steps.map(async (_, idx) => {
297-
if (!this.state.wizardStepStatus[idx] || this.state.wizardStepStatus[idx] === 'blank') {
297+
if (!this.state.wizardStepStatus[idx] || this.state.wizardStepStatus[idx] === "blank") {
298298
const status = await validate(_.graph, { validator: (cmdline: string) => this.props.tab.REPL.qexec(cmdline) })
299299
if (status !== this.state.wizardStepStatus[idx]) {
300-
this.setState(curState => ({
300+
this.setState((curState) => ({
301301
wizardStepStatus: [
302302
...curState.wizardStepStatus.slice(0, idx),
303303
status,
304-
...curState.wizardStepStatus.slice(idx + 1)
305-
]
304+
...curState.wizardStepStatus.slice(idx + 1),
305+
],
306306
}))
307307
}
308308
}
309309
})
310310
)
311311

312-
return steps.map(_ => _.step)
312+
return steps.map((_) => _.step)
313313
}
314314

315315
/** User clicked to remove a chip */
316316
private readonly removeChip = (evt: React.MouseEvent) => {
317317
const node = evt.currentTarget.parentElement
318318
if (node) {
319-
const key = node.getAttribute('data-ouia-component-id')
319+
const key = node.getAttribute("data-ouia-component-id")
320320
if (key) {
321321
this.state.choices.remove(key)
322322
}
@@ -348,15 +348,15 @@ export default class Guide extends React.PureComponent<Props, State> {
348348
*/
349349
private progress(steps: WizardStep[]) {
350350
const nTotal = steps.length
351-
const nError = this.state.wizardStepStatus.filter(_ => _ === 'error').length
352-
const nDone = this.state.wizardStepStatus.filter(_ => _ === 'success').length
351+
const nError = this.state.wizardStepStatus.filter((_) => _ === "error").length
352+
const nDone = this.state.wizardStepStatus.filter((_) => _ === "success").length
353353

354354
const label =
355355
nError > 0
356-
? strings(nError === 1 ? 'xOfyFailingz' : 'xOfyFailingsz', nDone, nError, nTotal)
357-
: strings('xOfy', nDone, nTotal)
356+
? strings(nError === 1 ? "xOfyFailingz" : "xOfyFailingsz", nDone, nError, nTotal)
357+
: strings("xOfy", nDone, nTotal)
358358

359-
const variant = nDone === nTotal ? 'success' : nError > 0 ? 'danger' : undefined
359+
const variant = nDone === nTotal ? "success" : nError > 0 ? "danger" : undefined
360360

361361
return (
362362
<Progress
@@ -365,7 +365,7 @@ export default class Guide extends React.PureComponent<Props, State> {
365365
min={0}
366366
max={nTotal}
367367
value={nDone}
368-
title={strings('Completed Tasks')}
368+
title={strings("Completed Tasks")}
369369
label={label}
370370
valueText={label}
371371
size="sm"
@@ -390,19 +390,19 @@ export default class Guide extends React.PureComponent<Props, State> {
390390
}
391391

392392
private hasRemainingChoices() {
393-
return !!this.state.frontier.find(_ => _.choice !== undefined)
393+
return !!this.state.frontier.find((_) => _.choice !== undefined)
394394
}
395395

396396
/** Commence automated execution of code blocks */
397397
private readonly startRun = () => {
398-
this.setState(curState => {
399-
const firstNotDoneStepIdx = curState.wizardStepStatus.findIndex(_ => _ !== 'success')
398+
this.setState((curState) => {
399+
const firstNotDoneStepIdx = curState.wizardStepStatus.findIndex((_) => _ !== "success")
400400

401401
return {
402402
isRunning: true,
403403

404404
// remember that startAtStep is 1-indexed
405-
startAtStep: firstNotDoneStepIdx < 0 ? curState.startAtStep : firstNotDoneStepIdx + 1
405+
startAtStep: firstNotDoneStepIdx < 0 ? curState.startAtStep : firstNotDoneStepIdx + 1,
406406
}
407407
})
408408
}
@@ -412,18 +412,18 @@ export default class Guide extends React.PureComponent<Props, State> {
412412
this.setState({ isRunning: false })
413413
}
414414

415-
private runAction(): WizardProps['rightButtons'][any] {
415+
private runAction(): WizardProps["rightButtons"][number] {
416416
return (
417417
!this.hasRemainingChoices() && {
418-
className: 'kui--guidebook-run',
418+
className: "kui--guidebook-run",
419419
onClick: this.state.isRunning ? this.stopRun : this.startRun,
420-
children: strings(this.state.isRunning ? 'Stop' : 'Run'),
421-
isDisabled: this.hasRemainingChoices() // ??? this does not seem to take...
420+
children: strings(this.state.isRunning ? "Stop" : "Run"),
421+
isDisabled: this.hasRemainingChoices(), // ??? this does not seem to take...
422422
}
423423
)
424424
}
425425

426-
private actions(): Partial<WizardProps['rightButtons']> {
426+
private actions(): Partial<WizardProps["rightButtons"]> {
427427
// return [this.runAction()].filter(Boolean)
428428
return undefined
429429
}
@@ -432,7 +432,7 @@ export default class Guide extends React.PureComponent<Props, State> {
432432
const steps = this.validateStepsIfNeeded(this.wizardSteps()).map(this.addCommonWizardStepProperties)
433433

434434
return steps.length === 0 ? (
435-
'Nothing to do!'
435+
"Nothing to do!"
436436
) : (
437437
<div className="kui--guide">
438438
<div className="kui--wizard">
@@ -456,15 +456,15 @@ export default class Guide extends React.PureComponent<Props, State> {
456456
}
457457

458458
private allDoneWithChoices() {
459-
return 'all done with choices'
459+
return "all done with choices"
460460
}
461461

462462
public render() {
463463
try {
464464
if (!this.state || !this.state.frontier) {
465465
return <React.Fragment />
466466
} else if (this.state.error) {
467-
return 'Internal error'
467+
return "Internal error"
468468
} else if (this.state.frontier.length === 0) {
469469
return this.allDoneWithChoices()
470470
} else {
@@ -473,16 +473,20 @@ export default class Guide extends React.PureComponent<Props, State> {
473473
} catch (error) {
474474
console.error(error)
475475
this.setState({ error })
476-
return 'Internal Error'
476+
return "Internal Error"
477477
}
478478
}
479479
}
480480

481-
export async function guide(filepath: string, props: Pick<Props, 'tab' | 'title' | 'description'>) {
481+
export async function guide(filepath: string, props: Pick<Props, "tab" | "title" | "description">) {
482482
try {
483-
return <CardResponse><Guide {...props} {...await read(filepath)} uuid={v4()}/></CardResponse>
483+
return (
484+
<CardResponse>
485+
<Guide {...props} {...await read(filepath)} uuid={v4()} />
486+
</CardResponse>
487+
)
484488
} catch (err) {
485489
console.error(err)
486-
return 'Internal Error'
490+
return "Internal Error"
487491
}
488492
}

Diff for: ‎plugins/plugin-madwizard/src/components/LeftRightSplit.tsx

+10-10
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17-
import React from 'react'
18-
import { v4 } from 'uuid'
19-
import { Tab } from '@kui-shell/core'
20-
import { CardResponse, SplitInjector } from '@kui-shell/plugin-client-common'
17+
import React from "react"
18+
import { v4 } from "uuid"
19+
import { Tab } from "@kui-shell/core"
20+
import { CardResponse, SplitInjector } from "@kui-shell/plugin-client-common"
2121

2222
/** TODO we should probably mvoe this into @kui-shell/plugin-client-common */
2323

@@ -26,10 +26,10 @@ interface Props {
2626
tab: Tab
2727

2828
/** The left and right nodes, respectively */
29-
children: [ React.ReactNode, React.ReactNode]
29+
children: [React.ReactNode, React.ReactNode]
3030

3131
/** Whether the left-hand content is to be a thin strip, or a normal-width split. [default: 'left-strip'] */
32-
left?: 'left-strip' | 'default'
32+
left?: "left-strip" | "default"
3333
}
3434

3535
/**
@@ -51,13 +51,13 @@ export default class LeftRightSplit extends React.PureComponent<Props> {
5151
uuid: v4(),
5252
count: 1,
5353
node: this.left,
54-
position: this.props.left || 'left-strip' as const,
55-
opts: { inverseColors: true }
54+
position: this.props.left || ("left-strip" as const),
55+
opts: { inverseColors: true },
5656
}
57-
57+
5858
return (
5959
<SplitInjector.Consumer>
60-
{injector => {
60+
{(injector) => {
6161
setTimeout(() => injector.inject([left]))
6262
return injector.modify(this.props.tab.uuid, this.right, { maximized: true })
6363
}}

Diff for: ‎plugins/plugin-madwizard/src/components/Plan.tsx

+52-52
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
* limitations under the License.
1515
*/
1616

17-
import Debug from 'debug'
18-
import React from 'react'
19-
import { TreeView, TreeViewProps } from '@patternfly/react-core'
20-
import { encodeComponent, pexecInCurrentTab } from '@kui-shell/core'
21-
import { CardResponse, Markdown, Icons, SupportedIcon } from '@kui-shell/plugin-client-common'
17+
import Debug from "debug"
18+
import React from "react"
19+
import { TreeView, TreeViewProps } from "@patternfly/react-core"
20+
import { encodeComponent, pexecInCurrentTab } from "@kui-shell/core"
21+
import { CardResponse, Markdown, Icons, SupportedIcon } from "@kui-shell/plugin-client-common"
2222

2323
import {
2424
sameGraph,
@@ -32,15 +32,15 @@ import {
3232
Choices,
3333
Decoration,
3434
Treeifier,
35-
UI
36-
} from 'madwizard'
35+
UI,
36+
} from "madwizard"
3737

38-
import read from '../read'
38+
import read from "../read"
3939

40-
import '@kui-shell/plugin-client-common/web/scss/components/Tree/_index.scss'
41-
import '@kui-shell/plugin-client-common/web/scss/components/Wizard/Imports.scss'
40+
import "@kui-shell/plugin-client-common/web/scss/components/Tree/_index.scss"
41+
import "@kui-shell/plugin-client-common/web/scss/components/Wizard/Imports.scss"
4242

43-
const debug = Debug('plugins/plugin-madwizard/components/Plan')
43+
const debug = Debug("plugins/plugin-madwizard/components/Plan")
4444

4545
class ReactUI implements UI<React.ReactNode> {
4646
public markdown(body: string) {
@@ -52,25 +52,25 @@ class ReactUI implements UI<React.ReactNode> {
5252
return content
5353
} else {
5454
const className = decorations
55-
.map(decoration =>
56-
decoration === 'blue'
57-
? 'color-base0D'
58-
: decoration === 'red'
59-
? 'color-base08'
60-
: decoration === 'magenta'
61-
? 'color-base0E'
62-
: decoration === 'cyan'
63-
? 'color-base0C'
64-
: decoration === 'yellow'
65-
? 'color-base09'
66-
: decoration === 'dim'
67-
? 'sub-text'
68-
: ''
55+
.map((decoration) =>
56+
decoration === "blue"
57+
? "color-base0D"
58+
: decoration === "red"
59+
? "color-base08"
60+
: decoration === "magenta"
61+
? "color-base0E"
62+
: decoration === "cyan"
63+
? "color-base0C"
64+
: decoration === "yellow"
65+
? "color-base09"
66+
: decoration === "dim"
67+
? "sub-text"
68+
: ""
6969
)
7070
.filter(Boolean)
71-
.join(' ')
71+
.join(" ")
7272

73-
if (decorations.includes('bold')) {
73+
if (decorations.includes("bold")) {
7474
return <strong className={className}>{content}</strong>
7575
} else {
7676
return <span className={className}>{content}</span>
@@ -92,7 +92,7 @@ class ReactUI implements UI<React.ReactNode> {
9292

9393
public statusToIcon(status: Status) {
9494
switch (status) {
95-
case 'success':
95+
case "success":
9696
return <Icons className="pf-m-success" icon="Checkmark" />
9797
}
9898
}
@@ -104,12 +104,12 @@ class ReactUI implements UI<React.ReactNode> {
104104
{title.map((_, idx, A) => (
105105
<span key={idx}>
106106
{this.title(_, status)}
107-
{idx < A.length - 1 ? ' ' : ''}
107+
{idx < A.length - 1 ? " " : ""}
108108
</span>
109109
))}
110110
</React.Fragment>
111111
)
112-
} else if (status === 'error') {
112+
} else if (status === "error") {
113113
return <span className="red-text">{title}</span>
114114
} else {
115115
return title
@@ -121,7 +121,7 @@ class ReactUI implements UI<React.ReactNode> {
121121
<button
122122
className="kui--tree-action pf-c-button pf-m-plain"
123123
onClick={() => {
124-
debug('drilling down to notebook', filepath)
124+
debug("drilling down to notebook", filepath)
125125
pexecInCurrentTab(`replay ${encodeComponent(filepath)}`, undefined, true, true)
126126
}}
127127
>
@@ -137,13 +137,13 @@ type Props = Choices &
137137
blocks: CodeBlockProps[]
138138
}
139139

140-
type Progress = { nDone: number; nError: number; nTotal: number }
140+
// type Progress = { nDone: number; nError: number; nTotal: number }
141141

142142
/** Map from treeModel node ID to the cumulative progress of that subtree */
143-
type ProgressMap = Record<string, Progress>
143+
// type ProgressMap = Record<string, Progress> */
144144

145145
type State = Choices &
146-
Pick<TreeViewProps, 'data'> & {
146+
Pick<TreeViewProps, "data"> & {
147147
error?: Error
148148

149149
graph: OrderedGraph
@@ -160,15 +160,15 @@ export default class Plan extends React.PureComponent<Props, State> {
160160
data: null,
161161
graph: undefined,
162162
choices: props.choices,
163-
codeBlockStatus: undefined
163+
codeBlockStatus: undefined,
164164
}
165165
}
166166

167-
private async init(props: Props, useTheseChoices?: State['choices']) {
167+
private async init(props: Props, useTheseChoices?: State["choices"]) {
168168
const choices = useTheseChoices || props.choices
169-
const newGraph = await compile(props.blocks, choices, undefined, 'sequence', props.title, props.description)
169+
const newGraph = await compile(props.blocks, choices, undefined, "sequence", props.title, props.description)
170170

171-
this.setState(state => {
171+
this.setState((state) => {
172172
const noChange = state && sameGraph(state.graph, newGraph)
173173

174174
const graph = noChange ? state.graph : order(newGraph)
@@ -182,7 +182,7 @@ export default class Plan extends React.PureComponent<Props, State> {
182182
choices,
183183
graph,
184184
error: undefined,
185-
codeBlockStatus
185+
codeBlockStatus,
186186
}
187187
})
188188
}
@@ -218,12 +218,12 @@ export default class Plan extends React.PureComponent<Props, State> {
218218
imports = this.state.graph,
219219
status = this.state.codeBlockStatus,
220220
doValidate = true
221-
): Pick<State, 'data'> {
221+
): Pick<State, "data"> {
222222
try {
223223
return {
224224
data: new Treeifier<React.ReactNode>(new ReactUI(), status, doValidate && this.validate.bind(this)).toTree(
225225
imports
226-
)
226+
),
227227
}
228228
} catch (error) {
229229
console.error(error)
@@ -232,25 +232,25 @@ export default class Plan extends React.PureComponent<Props, State> {
232232
}
233233

234234
private async validate(props: CodeBlockProps) {
235-
const status = this.state.codeBlockStatus ? this.state.codeBlockStatus[props.id] : 'blank'
235+
const status = this.state.codeBlockStatus ? this.state.codeBlockStatus[props.id] : "blank"
236236

237-
if (props.validate && status !== 'in-progress' && status !== 'success') {
237+
if (props.validate && status !== "in-progress" && status !== "success") {
238238
try {
239-
this.onValidate(props.id, 'in-progress')
239+
this.onValidate(props.id, "in-progress")
240240
// emitLinkUpdate(this.props.codeBlockId, 'in-progress')
241241
await pexecInCurrentTab(props.validate.toString(), undefined, true, true)
242-
this.onValidate(props.id, 'success')
242+
this.onValidate(props.id, "success")
243243
// emitLinkUpdate(this.props.codeBlockId, 'success')
244244
} catch (err) {
245-
this.onValidate(props.id, 'blank')
245+
this.onValidate(props.id, "blank")
246246
// this.setState({ status: 'blank' })
247247
// emitLinkUpdate(this.props.codeBlockId, 'blank')
248248
}
249249
}
250250
}
251251

252252
private readonly onValidate = (id: string, status: Status) => {
253-
this.setState(curState => {
253+
this.setState((curState) => {
254254
const codeBlockStatus = Object.assign({}, curState.codeBlockStatus, { [id]: status })
255255
const { data } = this.computeTreeModel(curState.graph, codeBlockStatus, false)
256256
return { data, codeBlockStatus }
@@ -259,7 +259,7 @@ export default class Plan extends React.PureComponent<Props, State> {
259259

260260
public render() {
261261
if (this.state.error) {
262-
return 'Internal Error'
262+
return "Internal Error"
263263
}
264264

265265
return !this.state.data ? (
@@ -300,12 +300,12 @@ class LabelWithStatus extends React.PureComponent<LabelWithStatusProps> {
300300
}
301301
} */
302302

303-
export async function plan(filepath: string, props: Pick<Props, 'title' | 'description'> = {}) {
303+
export async function plan(filepath: string, props: Pick<Props, "title" | "description"> = {}) {
304304
return (
305305
<CardResponse>
306-
<div className="padding-content marked-content page-content" data-is-nested>
307-
<Plan {...props} {...await read(filepath)}/>
308-
</div>
306+
<div className="padding-content marked-content page-content" data-is-nested>
307+
<Plan {...props} {...await read(filepath)} />
308+
</div>
309309
</CardResponse>
310310
)
311311
}

Diff for: ‎plugins/plugin-madwizard/src/components/PlanAndGuide.tsx

+10-10
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,28 @@
1414
* limitations under the License.
1515
*/
1616

17-
import React from 'react'
18-
import { v4 } from 'uuid'
17+
import React from "react"
18+
import { v4 } from "uuid"
1919

20-
import Plan from './Plan'
21-
import Guide, { Props as GuideProps } from './Guide'
20+
import Plan from "./Plan"
21+
import Guide, { Props as GuideProps } from "./Guide"
2222

23-
import read from '../read'
24-
import LeftRightSplit from './LeftRightSplit'
23+
import read from "../read"
24+
import LeftRightSplit from "./LeftRightSplit"
2525

26-
export async function planAndGuide(filepath: string, props: Pick<GuideProps, 'tab' | 'title' | 'description'>) {
26+
export async function planAndGuide(filepath: string, props: Pick<GuideProps, "tab" | "title" | "description">) {
2727
try {
2828
const uuid = v4()
2929
const data = await read(filepath)
3030

3131
return (
3232
<LeftRightSplit tab={props.tab}>
33-
<Plan {...props} {...data}/>
34-
<Guide {...props} {...data} uuid={uuid}/>
33+
<Plan {...props} {...data} />
34+
<Guide {...props} {...data} uuid={uuid} />
3535
</LeftRightSplit>
3636
)
3737
} catch (err) {
3838
console.error(err)
39-
return 'Internal Error'
39+
return "Internal Error"
4040
}
4141
}

Diff for: ‎plugins/plugin-madwizard/src/components/StatusUI.tsx

+13-13
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@
1414
* limitations under the License.
1515
*/
1616

17-
import React from 'react'
18-
import { Status } from 'madwizard'
19-
import { Icons, SupportedIcon } from '@kui-shell/plugin-client-common'
17+
import React from "react"
18+
import { Status } from "madwizard"
19+
import { Icons, SupportedIcon } from "@kui-shell/plugin-client-common"
2020

2121
export function statusToClassName(status: Status) {
2222
return [`pf-m-${status}`]
2323
}
2424

25-
const icons: Record<Status, { icon: SupportedIcon | ''; className?: string }> = {
26-
info: { icon: 'Info' },
27-
minor: { icon: '' },
28-
blank: { icon: '' },
29-
success: { icon: 'Checkmark' },
30-
warning: { icon: 'Warning', className: 'yellow-text' },
31-
error: { icon: 'Error', className: 'red-text' },
32-
unknown: { icon: 'Unknown', className: 'yellow-text' },
33-
current: { icon: 'Current' },
25+
const icons: Record<Status, { icon: SupportedIcon | ""; className?: string }> = {
26+
info: { icon: "Info" },
27+
minor: { icon: "" },
28+
blank: { icon: "" },
29+
success: { icon: "Checkmark" },
30+
warning: { icon: "Warning", className: "yellow-text" },
31+
error: { icon: "Error", className: "red-text" },
32+
unknown: { icon: "Unknown", className: "yellow-text" },
33+
current: { icon: "Current" },
3434
pending: { icon: undefined },
35-
'in-progress': { icon: 'InProgress', className: 'kui--spin-animation yellow-text' }
35+
"in-progress": { icon: "InProgress", className: "kui--spin-animation yellow-text" },
3636
}
3737

3838
export function statusToIcon(status: Status) {

Diff for: ‎plugins/plugin-madwizard/src/components/Wizard/Footer.tsx

+12-12
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828
* - @starpit 20220412 Added `leftActions` and `rightContent` properties
2929
*/
3030

31-
import React from 'react'
32-
import { css } from '@patternfly/react-styles'
33-
import styles from '@patternfly/react-styles/css/components/Wizard/wizard'
34-
import { WizardStep } from '@patternfly/react-core'
35-
import { Button, ButtonProps } from '@kui-shell/plugin-client-common'
31+
import React from "react"
32+
import { css } from "@patternfly/react-styles"
33+
import styles from "@patternfly/react-styles/css/components/Wizard/wizard"
34+
import { WizardStep } from "@patternfly/react-core"
35+
import { Button, ButtonProps } from "@kui-shell/plugin-client-common"
3636

37-
import '@kui-shell/plugin-client-common/web/scss/components/Wizard/Footer.scss'
37+
import "@kui-shell/plugin-client-common/web/scss/components/Wizard/Footer.scss"
3838

3939
export type KuiFooterExtraProps = {
4040
/** Add a box shadow effect? [default: false] */
@@ -60,9 +60,9 @@ export type KuiFooterExtraProps = {
6060
}
6161

6262
export interface WizardFooterInternalProps extends KuiFooterExtraProps {
63-
onNext: any
64-
onBack: any
65-
onClose: any
63+
onNext: () => void
64+
onBack: () => void
65+
onClose: () => void
6666
isValid: boolean
6767
firstStep: boolean
6868
activeStep: WizardStep
@@ -85,9 +85,9 @@ export const WizardFooterInternal: React.FunctionComponent<WizardFooterInternalP
8585
boxShadow,
8686
leftButtons,
8787
rightButtons,
88-
topContent
88+
topContent,
8989
}: WizardFooterInternalProps) => (
90-
<footer className={css(styles.wizardFooter) + ' kui--wizard-footer'} data-has-box-shadow={boxShadow || undefined}>
90+
<footer className={css(styles.wizardFooter) + " kui--wizard-footer"} data-has-box-shadow={boxShadow || undefined}>
9191
{topContent && <span className="kui--wizard-footer--top">{topContent}</span>}
9292

9393
<span className="kui--wizard-footer--bottom">
@@ -117,6 +117,6 @@ export const WizardFooterInternal: React.FunctionComponent<WizardFooterInternalP
117117
</span>
118118
</footer>
119119
)
120-
WizardFooterInternal.displayName = 'WizardFooterInternal'
120+
WizardFooterInternal.displayName = "WizardFooterInternal"
121121

122122
export default WizardFooterInternal

Diff for: ‎plugins/plugin-madwizard/src/components/Wizard/KWizard.tsx

+19-19
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@
2222
*
2323
*/
2424

25-
import React from 'react'
26-
import { i18n } from '@kui-shell/core'
27-
import { Title, TitleSizes, Wizard, WizardProps } from '@patternfly/react-core'
28-
import { Icons } from '@kui-shell/plugin-client-common'
25+
import React from "react"
26+
import { i18n } from "@kui-shell/core"
27+
import { Title, TitleSizes, Wizard, WizardProps } from "@patternfly/react-core"
28+
import { Icons } from "@kui-shell/plugin-client-common"
2929

30-
import Footer, { KuiFooterExtraProps } from './Footer'
30+
import Footer, { KuiFooterExtraProps } from "./Footer"
3131

32-
import '@kui-shell/plugin-client-common/web/scss/components/Wizard/PatternFly.scss'
32+
import "@kui-shell/plugin-client-common/web/scss/components/Wizard/PatternFly.scss"
3333

34-
const strings = i18n('plugin-client-common')
34+
const strings = i18n("plugin-client-common")
3535

3636
type HeaderState = {
3737
/** Is the wizard in "collapsed" mode, where we only show the title and progress bar? */
@@ -42,7 +42,7 @@ type FooterState = {
4242
activeStep: number
4343
}
4444

45-
export type Props = Omit<WizardProps, 'title'> &
45+
export type Props = Omit<WizardProps, "title"> &
4646
KuiFooterExtraProps &
4747
Partial<HeaderState> & {
4848
title: React.ReactNode
@@ -57,18 +57,18 @@ export default class KWizard extends React.PureComponent<Props, State> {
5757

5858
this.state = {
5959
activeStep: props.startAtStep || 1,
60-
collapsedHeader: props.collapsedHeader || false
60+
collapsedHeader: props.collapsedHeader || false,
6161
}
6262
}
6363

6464
private readonly _toggleCollapsedHeader = () =>
65-
this.setState(curState => ({ collapsedHeader: !curState.collapsedHeader }))
65+
this.setState((curState) => ({ collapsedHeader: !curState.collapsedHeader }))
6666

6767
private headerActions() {
6868
return (
6969
<div className="kui--wizard-header-action-buttons">
7070
<a className="kui--wizard-collapse-button kui--block-action" onClick={this._toggleCollapsedHeader}>
71-
<Icons icon={this.state.collapsedHeader ? 'WindowMaximize' : 'WindowMinimize'} />
71+
<Icons icon={this.state.collapsedHeader ? "WindowMaximize" : "WindowMinimize"} />
7272
</a>
7373
</div>
7474
)
@@ -79,9 +79,9 @@ export default class KWizard extends React.PureComponent<Props, State> {
7979
return (
8080
<Title
8181
headingLevel="h2"
82-
size={TitleSizes['3xl']}
82+
size={TitleSizes["3xl"]}
8383
className="kui--wizard-header-title pf-c-wizard__title"
84-
aria-label={typeof label === 'string' ? label : 'wizard title'}
84+
aria-label={typeof label === "string" ? label : "wizard title"}
8585
>
8686
{label}
8787
</Title>
@@ -105,9 +105,9 @@ export default class KWizard extends React.PureComponent<Props, State> {
105105
)
106106
}
107107

108-
private readonly onBack = () => this.setState(curState => ({ activeStep: Math.max(1, curState.activeStep - 1) }))
108+
private readonly onBack = () => this.setState((curState) => ({ activeStep: Math.max(1, curState.activeStep - 1) }))
109109
private readonly onNext = () =>
110-
this.setState(curState => ({ activeStep: Math.min(this.props.steps.length, curState.activeStep + 1) }))
110+
this.setState((curState) => ({ activeStep: Math.min(this.props.steps.length, curState.activeStep + 1) }))
111111

112112
private readonly onClose = () => {
113113
/* noop */
@@ -127,9 +127,9 @@ export default class KWizard extends React.PureComponent<Props, State> {
127127
isValid={this.state.activeStep < this.props.steps.length}
128128
firstStep={this.state.activeStep === 1}
129129
activeStep={this.props.steps[this.state.activeStep - 1]}
130-
nextButtonText={strings('Next')}
131-
backButtonText={strings('Back')}
132-
cancelButtonText={strings('Cancel')}
130+
nextButtonText={strings("Next")}
131+
backButtonText={strings("Back")}
132+
cancelButtonText={strings("Cancel")}
133133
boxShadow={this.props.boxShadow}
134134
leftButtons={this.props.leftButtons}
135135
rightButtons={this.props.rightButtons}
@@ -153,7 +153,7 @@ export default class KWizard extends React.PureComponent<Props, State> {
153153
<div className="kui--wizard-main-content">
154154
<Wizard
155155
key={this.state.activeStep}
156-
steps={steps.length === 0 ? [{ name: '', component: '' }] : steps}
156+
steps={steps.length === 0 ? [{ name: "", component: "" }] : steps}
157157
startAtStep={this.state.activeStep}
158158
footer={this.footer()}
159159
/>

Diff for: ‎plugins/plugin-madwizard/src/plugin.ts

+22-16
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,40 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { Registrar } from '@kui-shell/core'
18-
import { setTabReadonly } from './util'
17+
import { Registrar } from "@kui-shell/core"
18+
import { setTabReadonly } from "./util"
1919

2020
/** Register Kui Commands */
2121
export default function registerMadwizardCommands(registrar: Registrar) {
22-
registrar.listen('/guide', async ({ tab, argvNoOptions }) => {
23-
const filepath = argvNoOptions[1]
24-
setTabReadonly({ tab })
25-
return {
26-
react: await import('./components/PlanAndGuide').then(_ => _.planAndGuide(filepath, { tab }))
27-
}
28-
}, { outputOnly: true })
22+
registrar.listen(
23+
"/guide",
24+
async ({ tab, argvNoOptions }) => {
25+
const filepath = argvNoOptions[1]
26+
setTabReadonly({ tab })
27+
return {
28+
react: await import("./components/PlanAndGuide").then((_) => _.planAndGuide(filepath, { tab })),
29+
}
30+
},
31+
{ outputOnly: true }
32+
)
2933

30-
registrar.listen('/wizard', async ({ tab, argvNoOptions }) => {
34+
registrar.listen("/wizard", async ({ tab, argvNoOptions }) => {
3135
const filepath = argvNoOptions[1]
3236
setTabReadonly({ tab })
3337
return {
34-
react: await import('./components/Guide').then(_ => _.guide(filepath, {
35-
tab
36-
}))
38+
react: await import("./components/Guide").then((_) =>
39+
_.guide(filepath, {
40+
tab,
41+
})
42+
),
3743
}
3844
})
39-
40-
registrar.listen('/plan', async ({ tab, argvNoOptions }) => {
45+
46+
registrar.listen("/plan", async ({ tab, argvNoOptions }) => {
4147
const filepath = argvNoOptions[1]
4248
setTabReadonly({ tab })
4349
return {
44-
react: await import('./components/Plan').then(_ => _.plan(filepath))
50+
react: await import("./components/Plan").then((_) => _.plan(filepath)),
4551
}
4652
})
4753
}

Diff for: ‎plugins/plugin-madwizard/src/read.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
*/
1616

1717
export default async function read(filepath: string) {
18-
const { blockify, reader } = await import('madwizard')
18+
const { blockify, reader } = await import("madwizard")
1919
return blockify(filepath, await reader())
2020
}

Diff for: ‎plugins/plugin-madwizard/src/util.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { Arguments, Events, getPrimaryTabId } from '@kui-shell/core'
17+
import { Arguments, Events, getPrimaryTabId } from "@kui-shell/core"
1818

1919
/** TODO: move to core Tab api? */
20-
export function setTabReadonly({ tab }: Pick<Arguments, 'tab'>) {
21-
Events.eventBus.emitWithTabId('/kui/tab/edit/unset', getPrimaryTabId(tab))
20+
export function setTabReadonly({ tab }: Pick<Arguments, "tab">) {
21+
Events.eventBus.emitWithTabId("/kui/tab/edit/unset", getPrimaryTabId(tab))
2222
}
23-

0 commit comments

Comments
 (0)
Please sign in to comment.