Skip to content

Commit 09dd4c5

Browse files
authored
chore: consolidate imports to flux-lsp-browser (#6257)
There is currently a shim for both `parse` and `format_from_js_file` for using those functions in a node environment. However, not all call to `parse` or `format_from_js_file` use that shim. This patch fixes that. _Why is this needed?_, you may ask yourself. Well, it's not, but it certainlys makes it easier toidentify places that need to be ported over to the (in progress) async versions of both of those functions. We'll know we got all the places it's used when we can delete `parse` and `format_from_js_file` and nothing breaks.
1 parent fb6c804 commit 09dd4c5

File tree

11 files changed

+36
-16
lines changed

11 files changed

+36
-16
lines changed

src/flows/pipes/Notification/ExportTask.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import React, {FC, useContext, useCallback} from 'react'
22
import {useDispatch} from 'react-redux'
3-
import {parse, format_from_js_file} from '@influxdata/flux-lsp-browser'
3+
import {
4+
parse,
5+
format_from_js_file,
6+
} from 'src/languageSupport/languages/flux/parser'
47

58
// Components
69
import ExportTaskButton from 'src/flows/pipes/Schedule/ExportTaskButton'
@@ -94,7 +97,7 @@ ${ENDPOINT_DEFINITIONS[data.endpoint]?.generateImports()}`)
9497
}, {})
9598
).sort((a: ImportDeclaration, b: ImportDeclaration) =>
9699
b.path.value.toLowerCase().localeCompare(a.path.value.toLowerCase())
97-
)
100+
) as ImportDeclaration[]
98101

99102
ast.imports = []
100103

@@ -231,7 +234,7 @@ ${ENDPOINT_DEFINITIONS[data.endpoint]?.generateImports()}`)
231234
}, {})
232235
).sort((a: ImportDeclaration, b: ImportDeclaration) =>
233236
b.path.value.toLowerCase().localeCompare(a.path.value.toLowerCase())
234-
)
237+
) as ImportDeclaration[]
235238

236239
ast.imports = []
237240

src/flows/pipes/Notification/view.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import React, {
1010
useEffect,
1111
} from 'react'
1212
import {useDispatch, useSelector} from 'react-redux'
13-
import {parse} from '@influxdata/flux-lsp-browser'
13+
import {parse} from 'src/languageSupport/languages/flux/parser'
1414
import {
1515
ComponentStatus,
1616
Form,

src/flows/pipes/RawFluxEditor/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import {parse, format_from_js_file} from '@influxdata/flux-lsp-browser'
1+
import {
2+
parse,
3+
format_from_js_file,
4+
} from 'src/languageSupport/languages/flux/parser'
25
import {find} from 'src/shared/contexts/query'
36
import View from './view'
47
import ReadOnly from './readOnly'

src/flows/pipes/Schedule/view.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ import {
1010
IconFont,
1111
ComponentSize,
1212
} from '@influxdata/clockface'
13-
import {parse, format_from_js_file} from '@influxdata/flux-lsp-browser'
13+
import {
14+
parse,
15+
format_from_js_file,
16+
} from 'src/languageSupport/languages/flux/parser'
1417
import ExportTaskButton from 'src/flows/pipes/Schedule/ExportTaskButton'
1518
import {patchTask, TaskUpdateRequest} from 'src/client'
1619

src/flows/pipes/Table/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import View from './view'
2-
import {parse, format_from_js_file} from '@influxdata/flux-lsp-browser'
2+
import {
3+
parse,
4+
format_from_js_file,
5+
} from 'src/languageSupport/languages/flux/parser'
36
import {parseQuery} from 'src/shared/contexts/query'
47
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
58

src/flows/pipes/Visualization/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import View from './view'
22
import './style.scss'
3-
import {parse} from '@influxdata/flux-lsp-browser'
3+
import {parse} from 'src/languageSupport/languages/flux/parser'
44
import {parseQuery} from 'src/shared/contexts/query'
55
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
66

src/flows/templates/types/task.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import {DEFAULT_TIME_RANGE} from 'src/shared/constants/timeRanges'
22
import {AUTOREFRESH_DEFAULT} from 'src/shared/constants'
3-
import {parse, format_from_js_file} from '@influxdata/flux-lsp-browser'
3+
import {
4+
parse,
5+
format_from_js_file,
6+
} from 'src/languageSupport/languages/flux/parser'
47
import {remove} from 'src/shared/contexts/query'
58

69
export default register =>

src/languageSupport/languages/flux/lsp/connection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import isEqual from 'lodash/isEqual'
22
import * as MonacoTypes from 'monaco-editor/esm/vs/editor/editor.api'
3-
import {format_from_js_file} from '@influxdata/flux-lsp-browser'
3+
import {format_from_js_file} from 'src/languageSupport/languages/flux/parser'
44

55
// handling variables
66
import {EditorType, Variable} from 'src/types'

src/languageSupport/languages/flux/parser/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
a node environment (this is only for handling tests). If a test requires a specific AST result
99
then you will need to mock that out in the test.
1010
*/
11-
export const parse = (script): File => {
11+
export const parse = (script: string): File => {
1212
if (window) {
1313
return flux_parse(script)
1414
} else {
@@ -27,10 +27,10 @@ export const parse = (script): File => {
2727
}
2828
}
2929

30-
export const format_from_js_file = (script): string => {
30+
export const format_from_js_file = (script: File): string => {
3131
if (window) {
3232
return flux_format_from_js_file(script)
3333
} else {
34-
return script
34+
return ''
3535
}
3636
}

src/shared/contexts/query/preprocessing.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import {parse, format_from_js_file} from '@influxdata/flux-lsp-browser'
1+
import {
2+
parse,
3+
format_from_js_file,
4+
} from 'src/languageSupport/languages/flux/parser'
25

36
import {propertyTime} from 'src/shared/utils/getMinDurationFromAST'
47
import {isFlagEnabled} from 'src/shared/utils/featureFlag'

0 commit comments

Comments
 (0)