Skip to content

Commit a203952

Browse files
committed
Fix svelte-check errors
Signed-off-by: Andrey Sobolev <[email protected]>
1 parent 32f083c commit a203952

File tree

23 files changed

+155
-125
lines changed

23 files changed

+155
-125
lines changed

common/scripts/svelte-check-show.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
3+
roots=$(rush list -p --json | grep "path" | cut -f 2 -d ':' | cut -f 2 -d '"')
4+
files="svelte-check.log svelte-check-err.log"
5+
for file in $roots; do
6+
for check in $files; do
7+
f="$file/.svelte-check/$check"
8+
if [ -f $f ]; then
9+
if grep -q "error" "$f"; then
10+
if ! grep -q "0 errors" "$f"; then
11+
if ! grep -q "error.ts" "$f"; then
12+
echo "\nErrors in $f\n"
13+
cat "$f" | grep -B1 "Error:" | grep -v "^--$" | sed "s/Error:/$(echo '\033[31m')Error:$(echo '\033[0m')/"
14+
fi
15+
fi
16+
fi
17+
fi
18+
done
19+
done

packages/platform-rig/bin/do-svelte-check.js

Lines changed: 54 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,47 @@
1-
const { join, dirname } = require("path")
1+
const { join, dirname } = require('path')
22
const { readFileSync, existsSync, mkdirSync, createWriteStream } = require('fs')
33
const { spawn } = require('child_process')
44

5+
function parseSvelteCheckLog(logContent) {
6+
const lines = logContent.split('\n')
7+
const errors = []
8+
let currentError = null
9+
10+
let pline = ''
11+
for (const line of lines) {
12+
if (line.includes('Error:')) {
13+
// Start of a new error
14+
if (currentError) {
15+
errors.push(currentError)
16+
}
17+
currentError = {
18+
file: pline,
19+
message: line.split('Error:')[1].trim()
20+
}
21+
} else if (line.includes('====================================')) {
22+
// End of log, push last error if exists
23+
if (currentError) {
24+
errors.push(currentError)
25+
}
26+
break
27+
}
28+
pline = line
29+
}
30+
31+
// Print errors
32+
if (errors.length === 0) {
33+
console.log('No errors found')
34+
} else {
35+
errors.forEach((error) => {
36+
console.log(`File: ${error.file}`)
37+
console.log(`Message: \x1b[31m ${error.message} \x1b[0m\n`)
38+
})
39+
}
40+
}
41+
542
async function execProcess(cmd, logFile, args, useConsole) {
643
let compileRoot = dirname(dirname(process.argv[1]))
7-
console.log("Svelte check...\n", process.cwd(), args)
44+
console.log('Svelte check...\n')
845

946
if (!existsSync(join(process.cwd(), '.svelte-check'))) {
1047
mkdirSync(join(process.cwd(), '.svelte-check'))
@@ -15,16 +52,15 @@ async function execProcess(cmd, logFile, args, useConsole) {
1552
const stdoutFilePath = `.svelte-check/${logFile}.log`
1653
const stderrFilePath = `.svelte-check/${logFile}-err.log`
1754

18-
1955
const outPromise = new Promise((resolve) => {
2056
if (compileOut.stdout != null) {
2157
let outPipe = createWriteStream(stdoutFilePath)
2258
compileOut.stdout.pipe(outPipe)
2359
compileOut.stdout.on('end', function (data) {
2460
outPipe.close()
25-
if( useConsole ) {
26-
console.log(readFileSync(stdoutFilePath).toString())
27-
console.log(readFileSync(stderrFilePath).toString())
61+
if (useConsole) {
62+
const data = readFileSync(stdoutFilePath).toString() + readFileSync(stderrFilePath).toString()
63+
parseSvelteCheckLog(data)
2864
}
2965
resolve()
3066
})
@@ -47,7 +83,7 @@ async function execProcess(cmd, logFile, args, useConsole) {
4783
})
4884

4985
let editCode = 0
50-
const closePromise = new Promise(resolve => {
86+
const closePromise = new Promise((resolve) => {
5187
compileOut.on('close', (code) => {
5288
editCode = code
5389
resolve()
@@ -61,30 +97,26 @@ async function execProcess(cmd, logFile, args, useConsole) {
6197
await Promise.all([outPromise, errPromise, closePromise])
6298

6399
if (editCode !== 0) {
64-
const data = readFileSync(stdoutFilePath)
65-
const errData = readFileSync(stderrFilePath)
66-
console.error('\n' + data.toString() + '\n' + errData.toString())
100+
if( !useConsole) {
101+
const data = readFileSync(stdoutFilePath).toString()
102+
const errData = readFileSync(stderrFilePath).toString()
103+
parseSvelteCheckLog(data)
104+
console.error('\n' + errData.toString())
105+
}
67106
process.exit(editCode)
68107
}
69108
}
70109

71110
let args = [] // process.argv.slice(2)
72111
let useConsole = false
73-
for(const a of process.argv.slice(2)) {
74-
if( a === '--console') {
112+
for (const a of process.argv.slice(2)) {
113+
if (a === '--console') {
75114
useConsole = true
76115
} else {
77116
args.push(a)
78117
}
79118
}
80119
let st = performance.now()
81-
execProcess(
82-
'svelte-check',
83-
'svelte-check', [
84-
'--output', 'human',
85-
...args
86-
], useConsole)
87-
.then(() => {
88-
console.log("Svelte check time: ", Math.round((performance.now() - st) * 100) / 100)
89-
})
90-
120+
execProcess('svelte-check', 'svelte-check', ['--output', 'human', ...args], useConsole).then(() => {
121+
console.log('Svelte check time: ', Math.round((performance.now() - st) * 100) / 100)
122+
})

plugins/attachment-resources/src/components/FileBrowser.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
]}
117117
selected={isListDisplayMode ? 'table' : 'card'}
118118
on:select={(result) => {
119-
if (result.detail !== undefined) isListDisplayMode = result.detail === 'table' ?? false
119+
if (result.detail !== undefined) isListDisplayMode = result.detail === 'table'
120120
}}
121121
/>
122122
</div>

plugins/diffview-resources/src/components/InlineDiffView.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ index 3aa8590..6b64999 100644
2929
+++ b/${fileName}
3030
`
3131
32-
$: diffFiles = parseDiff(prefix + patch ?? '')
32+
$: diffFiles = parseDiff(prefix + patch)
3333
</script>
3434

3535
{#each diffFiles as diffFile}

plugins/gmail-resources/src/components/FullMessage.svelte

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,11 @@
2424
import attachment, { Attachment } from '@hcengineering/attachment'
2525
import { AttachmentPresenter } from '@hcengineering/attachment-resources'
2626
import { getEmbeddedLabel } from '@hcengineering/platform'
27-
import core, { Ref } from '@hcengineering/core'
27+
import { Ref } from '@hcengineering/core'
2828
2929
export let currentMessage: SharedMessage
3030
export let newMessage: boolean
3131
32-
let editor: HTMLDivElement
33-
$: if (editor) editor.innerHTML = currentMessage.content
34-
3532
const dispatch = createEventDispatcher()
3633
const hasError = (currentMessage as unknown as NewMessage)?.status === 'error'
3734

plugins/gmail-resources/src/components/Message.svelte

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,8 @@
6363
{/if}
6464
{#if isError}
6565
<div class="error-color top-divider mt-2 pt-2">
66-
Error: {errorMessage?.error
67-
? JSON.parse(errorMessage.error)?.data?.error_description
68-
: undefined ?? 'unknown error'}
66+
Error: {(errorMessage?.error ? JSON.parse(errorMessage.error)?.data?.error_description : undefined) ??
67+
'unknown error'}
6968
</div>
7069
{/if}
7170
</div>

plugins/love-resources/src/components/Settings.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
<div class="flex-row-center flex-gap-4">
7070
<Label label={love.string.StartWithMutedMic} />
7171
<Toggle
72-
on={!$myPreferences?.micEnabled ?? false}
72+
on={!($myPreferences?.micEnabled ?? false)}
7373
on:change={(e) => {
7474
saveMicPreference($myPreferences, e.detail)
7575
}}
@@ -78,7 +78,7 @@
7878
<div class="flex-row-center flex-gap-4">
7979
<Label label={love.string.StartWithoutVideo} />
8080
<Toggle
81-
on={!$myPreferences?.camEnabled ?? false}
81+
on={!($myPreferences?.camEnabled ?? false)}
8282
on:change={(e) => {
8383
saveCamPreference($myPreferences, e.detail)
8484
}}

plugins/tags-resources/src/components/TagsView.svelte

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@
9292
}
9393
)
9494
const countSorting = (a: Doc, b: Doc) =>
95-
(tagElements?.get(b._id as Ref<TagElement>)?.count ?? 0) -
96-
(tagElements?.get(a._id as Ref<TagElement>)?.count ?? 0) ?? 0
95+
(tagElements?.get(b._id as Ref<TagElement>)?.count ?? 0) - (tagElements?.get(a._id as Ref<TagElement>)?.count ?? 0)
9796
9897
let visibleCategories: TagCategory[] = []
9998
</script>

plugins/test-management-resources/src/components/test-case/EditTestCase.svelte

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@
5252
}
5353
}
5454
55-
let content: HTMLElement
56-
5755
$: if (oldLabel !== object?.name) {
5856
oldLabel = object?.name
5957
rawLabel = object?.name
@@ -102,7 +100,6 @@
102100
bind:this={descriptionBox}
103101
identifier={object?._id}
104102
placeholder={testManagement.string.DescriptionPlaceholder}
105-
boundary={content}
106103
/>
107104
</div>
108105

plugins/test-management-resources/src/components/test-result/TestResultAside.svelte

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737
3838
let descriptionBox: AttachmentStyleBoxCollabEditor
3939
40-
let content: HTMLElement
41-
4240
$: descriptionKey = hierarchy.getAttribute(testManagement.class.TestResult, 'description')
4341
4442
onMount(() => dispatch('open', { ignoreKeys: [] }))
@@ -57,7 +55,6 @@
5755
bind:this={descriptionBox}
5856
identifier={object?._id}
5957
placeholder={testManagement.string.DescriptionPlaceholder}
60-
boundary={content}
6158
/>
6259
</div>
6360
{#if !withoutActivity}
@@ -67,8 +64,7 @@
6764
props={{
6865
object,
6966
showCommenInput: true,
70-
focusIndex: 1000,
71-
boundary: content
67+
focusIndex: 1000
7268
}}
7369
/>
7470
</div>

plugins/test-management-resources/src/components/test-run/EditTestRun.svelte

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@
5151
}
5252
}
5353
54-
let content: HTMLElement
55-
5654
$: if (oldLabel !== object?.name) {
5755
oldLabel = object?.name
5856
rawLabel = object?.name
@@ -98,7 +96,6 @@
9896
bind:this={descriptionBox}
9997
identifier={object?._id}
10098
placeholder={testManagement.string.DescriptionPlaceholder}
101-
boundary={content}
10299
/>
103100
</div>
104101

plugins/text-editor-resources/src/components/CollaboratorEditor.svelte

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@
4848
export let requestSideSpace: ((width: number) => void) | undefined = undefined
4949
export let enableInlineComments: boolean = true
5050
51-
let element: HTMLElement
52-
5351
let collaborativeEditor: CollaborativeTextEditor
5452
5553
export function commands (): TextEditorCommandHandler | undefined {
@@ -68,7 +66,7 @@
6866
const { idx, focusManager } = registerFocus(focusIndex, {
6967
focus: () => {
7068
focus()
71-
return element !== null
69+
return true
7270
},
7371
isFocus: () => isFocused(),
7472
canBlur: () => false

plugins/tracker-resources/src/components/issues/StatusEditor.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
id: s._id,
125125
component: StatusPresenter,
126126
props: { value: s, size: 'small', space: value.space },
127-
isSelected: selectedStatus?._id === s._id ?? false
127+
isSelected: selectedStatus?._id === s._id
128128
}
129129
})
130130
$: smallgap = size === 'inline' || size === 'small'

plugins/tracker-resources/src/components/issues/StatusSelector.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
id: s._id,
107107
component: StatusPresenter,
108108
props: { value: s, size: 'small' },
109-
isSelected: selectedStatus?._id === s._id ?? false
109+
isSelected: selectedStatus?._id === s._id
110110
}
111111
}) ?? []
112112
const handleStatusEditorOpened = (event: MouseEvent) => {

plugins/tracker-resources/src/components/milestones/MilestoneBrowser.svelte

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@
5858
asideFloat = false
5959
asideShown = false
6060
}
61-
let docWidth: number
62-
let docSize: boolean = false
63-
$: if (docWidth <= 900 && !docSize) docSize = true
64-
$: if (docWidth > 900 && docSize) docSize = false
6561
6662
const handleViewModeChanged = (newMode: MilestoneViewMode) => {
6763
if (newMode === undefined || newMode === mode) {

plugins/view-resources/src/components/filter/FilterSection.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
}
4949
}
5050
const targetClass = getTargetClass()
51-
$: isState = targetClass === core.class.Status ?? false
51+
$: isState = targetClass === core.class.Status
5252
const dispatch = createEventDispatcher()
5353
5454
async function getCountStates (ids: Array<Ref<Doc>>): Promise<number> {

server-plugins/activity-resources/src/__tests__/references.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414
//
1515

16-
import { Class, Doc, Ref } from '@hcengineering/core'
16+
import { type Class, type Doc, type Ref } from '@hcengineering/core'
1717
import { EmptyMarkup, MarkupNodeType, jsonToMarkup } from '@hcengineering/text-core'
1818

1919
import { getReferencesData } from '../references'

server-plugins/activity-resources/src/index.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,32 @@
1414
//
1515

1616
import activity, {
17-
ActivityMessage,
18-
ActivityMessageControl,
19-
DocAttributeUpdates,
20-
DocUpdateMessage,
21-
Reaction
17+
type ActivityMessage,
18+
type ActivityMessageControl,
19+
type DocAttributeUpdates,
20+
type DocUpdateMessage,
21+
type Reaction
2222
} from '@hcengineering/activity'
2323
import core, {
24-
PersonId,
25-
AttachedDoc,
26-
Class,
27-
Collection,
28-
Data,
29-
Doc,
30-
Hierarchy,
24+
type PersonId,
25+
type AttachedDoc,
26+
type Class,
27+
type Collection,
28+
type Data,
29+
type Doc,
30+
type Hierarchy,
3131
matchQuery,
32-
MeasureContext,
33-
Ref,
34-
Space,
35-
Tx,
36-
TxCreateDoc,
37-
TxCUD,
32+
type MeasureContext,
33+
type Ref,
34+
type Space,
35+
type Tx,
36+
type TxCreateDoc,
37+
type TxCUD,
3838
TxProcessor
3939
} from '@hcengineering/core'
40-
import notification, { NotificationContent } from '@hcengineering/notification'
40+
import notification, { type NotificationContent } from '@hcengineering/notification'
4141
import { getResource, translate } from '@hcengineering/platform'
42-
import { ActivityControl, DocObjectCache } from '@hcengineering/server-activity'
42+
import { type ActivityControl, type DocObjectCache } from '@hcengineering/server-activity'
4343
import type { TriggerControl } from '@hcengineering/server-core'
4444
import {
4545
createCollabDocInfo,

0 commit comments

Comments
 (0)