chore: eslint add sonar (#17989)

This commit is contained in:
Joel
2025-04-14 15:28:20 +08:00
committed by GitHub
parent 8f9cbe1c49
commit d80f4c7d3b
38 changed files with 157 additions and 180 deletions

View File

@@ -84,7 +84,7 @@ const CodeEditor: FC<Props> = ({
const getUniqVarName = (varName: string) => {
if (varList.find(v => v.variable === varName)) {
const match = varName.match(/_([0-9]+)$/)
const match = varName.match(/_(\d+)$/)
const index = (() => {
if (match)
@@ -92,7 +92,7 @@ const CodeEditor: FC<Props> = ({
return 1
})()
return getUniqVarName(`${varName.replace(/_([0-9]+)$/, '')}_${index}`)
return getUniqVarName(`${varName.replace(/_(\d+)$/, '')}_${index}`)
}
return varName
}

View File

@@ -278,6 +278,7 @@ const formatItem = (
break
}
// eslint-disable-next-line sonarjs/no-duplicated-branches
case BlockEnum.VariableAggregator: {
const {
output_type,
@@ -466,7 +467,7 @@ const formatItem = (
res.vars = res.vars.filter((v) => {
const isCurrentMatched = filterVar(v, (() => {
const variableArr = v.variable.split('.')
const [first, ..._other] = variableArr
const [first] = variableArr
if (first === 'sys' || first === 'env' || first === 'conversation')
return variableArr
@@ -611,6 +612,7 @@ const getLoopItemType = ({
}: {
valueSelector: ValueSelector
beforeNodesOutputVars: NodeOutPutVar[]
// eslint-disable-next-line sonarjs/no-identical-functions
}): VarType => {
const outputVarNodeId = valueSelector[0]
const isSystem = isSystemVar(valueSelector)
@@ -1243,6 +1245,7 @@ export const updateNodeVars = (oldNode: Node, oldVarSelector: ValueSelector, new
}
break
}
// eslint-disable-next-line sonarjs/no-duplicated-branches
case BlockEnum.VariableAggregator: {
const payload = data as VariableAssignerNodeType
if (payload.variables) {

View File

@@ -64,7 +64,7 @@ const Item: FC<ItemProps> = ({
const isChatVar = itemData.variable.startsWith('conversation.')
const itemRef = useRef<HTMLDivElement>(null)
const [isItemHovering, setIsItemHovering] = useState(false)
const _ = useHover(itemRef, {
useHover(itemRef, {
onChange: (hovering) => {
if (hovering) {
setIsItemHovering(true)
@@ -185,7 +185,7 @@ const ObjectChildren: FC<ObjectChildrenProps> = ({
const currObjPath = objPath
const itemRef = useRef<HTMLDivElement>(null)
const [isItemHovering, setIsItemHovering] = useState(false)
const _ = useHover(itemRef, {
useHover(itemRef, {
onChange: (hovering) => {
if (hovering) {
setIsItemHovering(true)