Skip to content

oxlint/lsp: does not fix code if same 'block' or 'line' has more than 1 jsPlugin rule violation #20379

@brokenmass

Description

@brokenmass

If the same block of code has more than one rule violation , where the rule(s) is(are) provided by a js plugin(s), then vscode extension does not fix the block.

Sometimes instead the fix seems to go torugh a race condition and the generated code is invalid, like if the 2 fixes got merged.

this problem does not appear for 'native' rules.

example using perfectionis sort-enums (but apply to any jsPlugin rule, even if the 2 errors come from different plugins

config:

{
  "plugins": [],
  "jsPlugins": [
    {"name": "perfectionist", "specifier": "eslint-plugin-perfectionist"}
  ],
  "rules": {
    "perfectionist/sort-enums": ["error", {"type": "natural"}],
   }
}
export type SomeUnion = string | number | boolean;
Image

correctly highlight the error but does not fix them on save

extension trace
2026-03-09 20:58:50.722 [info] [Trace - 20:58:50] Sending notification 'textDocument/didOpen'.
2026-03-09 20:58:50.722 [info] Params: {
    "textDocument": {
        "uri": "file:///some/fs/path/test.ts",
        "languageId": "typescript",
        "version": 1,
        "text": "export type SomeUnion = string | number | boolean;\n"
    }
}


2026-03-09 20:58:50.722 [info] [Trace - 20:58:50] Sending request 'textDocument/diagnostic - (22)'.
2026-03-09 20:58:50.722 [info] Params: {
    "textDocument": {
        "uri": "file:///some/fs/path/test.ts"
    }
}


2026-03-09 20:58:50.725 [info] [Trace - 20:58:50] Sending request 'textDocument/codeAction - (23)'.
2026-03-09 20:58:50.725 [info] Params: {
    "textDocument": {
        "uri": "file:///some/fs/path/test.ts"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 0,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [],
        "triggerKind": 2
    }
}


2026-03-09 20:58:50.734 [info] [Trace - 20:58:50] Received response 'textDocument/diagnostic - (22)' in 12ms.
2026-03-09 20:58:50.734 [info] Result: {
    "kind": "full",
    "items": [
        {
            "range": {
                "start": {
                    "line": 0,
                    "character": 33
                },
                "end": {
                    "line": 0,
                    "character": 39
                }
            },
            "severity": 1,
            "code": "perfectionist(sort-union-types)",
            "source": "oxc",
            "message": "Expected \"number\" to come before \"string\".",
            "relatedInformation": [
                {
                    "location": {
                        "uri": "file:///some/fs/path/test.ts",
                        "range": {
                            "start": {
                                "line": 0,
                                "character": 33
                            },
                            "end": {
                                "line": 0,
                                "character": 39
                            }
                        }
                    },
                    "message": ""
                }
            ]
        },
        {
            "range": {
                "start": {
                    "line": 0,
                    "character": 42
                },
                "end": {
                    "line": 0,
                    "character": 49
                }
            },
            "severity": 1,
            "code": "perfectionist(sort-union-types)",
            "source": "oxc",
            "message": "Expected \"boolean\" to come before \"number\".",
            "relatedInformation": [
                {
                    "location": {
                        "uri": "file:///some/fs/path/test.ts",
                        "range": {
                            "start": {
                                "line": 0,
                                "character": 42
                            },
                            "end": {
                                "line": 0,
                                "character": 49
                            }
                        }
                    },
                    "message": ""
                }
            ]
        }
    ]
}


2026-03-09 20:58:50.738 [info] [Trace - 20:58:50] Received response 'textDocument/codeAction - (23)' in 13ms.
2026-03-09 20:58:50.738 [info] No result returned.


2026-03-09 20:58:50.830 [info] [Trace - 20:58:50] Sending request 'textDocument/codeAction - (24)'.
2026-03-09 20:58:50.830 [info] Params: {
    "textDocument": {
        "uri": "file:///some/fs/path/test.ts"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 42
        },
        "end": {
            "line": 0,
            "character": 49
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 0,
                        "character": 42
                    },
                    "end": {
                        "line": 0,
                        "character": 49
                    }
                },
                "message": "Expected \"boolean\" to come before \"number\".",
                "code": "perfectionist(sort-union-types)",
                "severity": 1,
                "relatedInformation": [
                    {
                        "message": "",
                        "location": {
                            "uri": "file:///some/fs/path/test.ts",
                            "range": {
                                "start": {
                                    "line": 0,
                                    "character": 42
                                },
                                "end": {
                                    "line": 0,
                                    "character": 49
                                }
                            }
                        }
                    }
                ],
                "source": "oxc"
            }
        ],
        "triggerKind": 2
    }
}


2026-03-09 20:58:50.830 [info] [Trace - 20:58:50] Received response 'textDocument/codeAction - (24)' in 0ms.
2026-03-09 20:58:50.830 [info] Result: [
    {
        "title": "Fix this Expected \"boolean\" to come before \"number\". problem",
        "kind": "quickfix",
        "edit": {
            "changes": {
                "file:///some/fs/path/test.ts": [
                    {
                        "range": {
                            "start": {
                                "line": 0,
                                "character": 24
                            },
                            "end": {
                                "line": 0,
                                "character": 49
                            }
                        },
                        "newText": "boolean | number | string"
                    }
                ]
            }
        },
        "isPreferred": true
    },
    {
        "title": "Disable perfectionist/sort-union-types for this line",
        "kind": "quickfix",
        "edit": {
            "changes": {
                "file:///some/fs/path/test.ts": [
                    {
                        "range": {
                            "start": {
                                "line": 0,
                                "character": 0
                            },
                            "end": {
                                "line": 0,
                                "character": 0
                            }
                        },
                        "newText": "// oxlint-disable-next-line perfectionist/sort-union-types\n"
                    }
                ]
            }
        },
        "isPreferred": false
    },
    {
        "title": "Disable perfectionist/sort-union-types for this whole file",
        "kind": "quickfix",
        "edit": {
            "changes": {
                "file:///some/fs/path/test.ts": [
                    {
                        "range": {
                            "start": {
                                "line": 0,
                                "character": 0
                            },
                            "end": {
                                "line": 0,
                                "character": 0
                            }
                        },
                        "newText": "// oxlint-disable perfectionist/sort-union-types\n"
                    }
                ]
            }
        },
        "isPreferred": false
    }
]


2026-03-09 20:58:51.008 [info] [Trace - 20:58:51] Sending request 'textDocument/codeAction - (25)'.
2026-03-09 20:58:51.008 [info] Params: {
    "textDocument": {
        "uri": "file:///some/fs/path/test.ts"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 42
        },
        "end": {
            "line": 0,
            "character": 49
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 0,
                        "character": 42
                    },
                    "end": {
                        "line": 0,
                        "character": 49
                    }
                },
                "message": "Expected \"boolean\" to come before \"number\".",
                "code": "perfectionist(sort-union-types)",
                "severity": 1,
                "relatedInformation": [
                    {
                        "message": "",
                        "location": {
                            "uri": "file:///some/fs/path/test.ts",
                            "range": {
                                "start": {
                                    "line": 0,
                                    "character": 42
                                },
                                "end": {
                                    "line": 0,
                                    "character": 49
                                }
                            }
                        }
                    }
                ],
                "source": "oxc"
            }
        ],
        "triggerKind": 2
    }
}


2026-03-09 20:58:51.008 [info] [Trace - 20:58:51] Received response 'textDocument/codeAction - (25)' in 0ms.
2026-03-09 20:58:51.008 [info] Result: [
    {
        "title": "Fix this Expected \"boolean\" to come before \"number\". problem",
        "kind": "quickfix",
        "edit": {
            "changes": {
                "file:///some/fs/path/test.ts": [
                    {
                        "range": {
                            "start": {
                                "line": 0,
                                "character": 24
                            },
                            "end": {
                                "line": 0,
                                "character": 49
                            }
                        },
                        "newText": "boolean | number | string"
                    }
                ]
            }
        },
        "isPreferred": true
    },
    {
        "title": "Disable perfectionist/sort-union-types for this line",
        "kind": "quickfix",
        "edit": {
            "changes": {
                "file:///some/fs/path/test.ts": [
                    {
                        "range": {
                            "start": {
                                "line": 0,
                                "character": 0
                            },
                            "end": {
                                "line": 0,
                                "character": 0
                            }
                        },
                        "newText": "// oxlint-disable-next-line perfectionist/sort-union-types\n"
                    }
                ]
            }
        },
        "isPreferred": false
    },
    {
        "title": "Disable perfectionist/sort-union-types for this whole file",
        "kind": "quickfix",
        "edit": {
            "changes": {
                "file:///some/fs/path/test.ts": [
                    {
                        "range": {
                            "start": {
                                "line": 0,
                                "character": 0
                            },
                            "end": {
                                "line": 0,
                                "character": 0
                            }
                        },
                        "newText": "// oxlint-disable perfectionist/sort-union-types\n"
                    }
                ]
            }
        },
        "isPreferred": false
    }
]

this instead

export type SomeUnion = string | number;

show the error and autofix on save

extension trace

2026-03-09 21:05:24.291 [info] [Trace - 21:05:24] Sending notification 'textDocument/didOpen'.
2026-03-09 21:05:24.291 [info] Params: {
    "textDocument": {
        "uri": "file:///some/fs/path/test.ts",
        "languageId": "typescript",
        "version": 9,
        "text": "export type SomeUnion = string | number;\n"
    }
}


2026-03-09 21:05:24.291 [info] [Trace - 21:05:24] Sending request 'textDocument/codeAction - (59)'.
2026-03-09 21:05:24.291 [info] Params: {
    "textDocument": {
        "uri": "file:///some/fs/path/test.ts"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 0,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [],
        "triggerKind": 2
    }
}


2026-03-09 21:05:24.293 [info] [Trace - 21:05:24] Sending request 'textDocument/diagnostic - (60)'.
2026-03-09 21:05:24.293 [info] Params: {
    "textDocument": {
        "uri": "file:///some/fs/path/test.ts"
    }
}


2026-03-09 21:05:24.298 [info] [Trace - 21:05:24] Received response 'textDocument/codeAction - (59)' in 7ms.
2026-03-09 21:05:24.298 [info] No result returned.


2026-03-09 21:05:24.298 [info] [Trace - 21:05:24] Received response 'textDocument/diagnostic - (60)' in 5ms.
2026-03-09 21:05:24.298 [info] Result: {
    "kind": "full",
    "items": [
        {
            "range": {
                "start": {
                    "line": 0,
                    "character": 33
                },
                "end": {
                    "line": 0,
                    "character": 39
                }
            },
            "severity": 1,
            "code": "perfectionist(sort-union-types)",
            "source": "oxc",
            "message": "Expected \"number\" to come before \"string\".",
            "relatedInformation": [
                {
                    "location": {
                        "uri": "file:///some/fs/path/test.ts",
                        "range": {
                            "start": {
                                "line": 0,
                                "character": 33
                            },
                            "end": {
                                "line": 0,
                                "character": 39
                            }
                        }
                    },
                    "message": ""
                }
            ]
        }
    ]
}


2026-03-09 21:05:24.389 [info] [Trace - 21:05:24] Sending request 'textDocument/codeAction - (61)'.
2026-03-09 21:05:24.389 [info] Params: {
    "textDocument": {
        "uri": "file:///some/fs/path/test.ts"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 39
        },
        "end": {
            "line": 0,
            "character": 39
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 0,
                        "character": 33
                    },
                    "end": {
                        "line": 0,
                        "character": 39
                    }
                },
                "message": "Expected \"number\" to come before \"string\".",
                "code": "perfectionist(sort-union-types)",
                "severity": 1,
                "relatedInformation": [
                    {
                        "message": "",
                        "location": {
                            "uri": "file:///some/fs/path/test.ts",
                            "range": {
                                "start": {
                                    "line": 0,
                                    "character": 33
                                },
                                "end": {
                                    "line": 0,
                                    "character": 39
                                }
                            }
                        }
                    }
                ],
                "source": "oxc"
            }
        ],
        "triggerKind": 2
    }
}


2026-03-09 21:05:24.390 [info] [Trace - 21:05:24] Received response 'textDocument/codeAction - (61)' in 1ms.
2026-03-09 21:05:24.390 [info] Result: [
    {
        "title": "Fix this Expected \"number\" to come before \"string\". problem",
        "kind": "quickfix",
        "edit": {
            "changes": {
                "file:///some/fs/path/test.ts": [
                    {
                        "range": {
                            "start": {
                                "line": 0,
                                "character": 24
                            },
                            "end": {
                                "line": 0,
                                "character": 39
                            }
                        },
                        "newText": "number | string"
                    }
                ]
            }
        },
        "isPreferred": true
    },
    {
        "title": "Disable perfectionist/sort-union-types for this line",
        "kind": "quickfix",
        "edit": {
            "changes": {
                "file:///some/fs/path/test.ts": [
                    {
                        "range": {
                            "start": {
                                "line": 0,
                                "character": 0
                            },
                            "end": {
                                "line": 0,
                                "character": 0
                            }
                        },
                        "newText": "// oxlint-disable-next-line perfectionist/sort-union-types\n"
                    }
                ]
            }
        },
        "isPreferred": false
    },
    {
        "title": "Disable perfectionist/sort-union-types for this whole file",
        "kind": "quickfix",
        "edit": {
            "changes": {
                "file:///some/fs/path/test.ts": [
                    {
                        "range": {
                            "start": {
                                "line": 0,
                                "character": 0
                            },
                            "end": {
                                "line": 0,
                                "character": 0
                            }
                        },
                        "newText": "// oxlint-disable perfectionist/sort-union-types\n"
                    }
                ]
            }
        },
        "isPreferred": false
    }
]


2026-03-09 21:05:24.574 [info] [Trace - 21:05:24] Sending request 'textDocument/codeAction - (62)'.
2026-03-09 21:05:24.574 [info] Params: {
    "textDocument": {
        "uri": "file:///some/fs/path/test.ts"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 39
        },
        "end": {
            "line": 0,
            "character": 39
        }
    },
    "context": {
        "diagnostics": [
            {
                "range": {
                    "start": {
                        "line": 0,
                        "character": 33
                    },
                    "end": {
                        "line": 0,
                        "character": 39
                    }
                },
                "message": "Expected \"number\" to come before \"string\".",
                "code": "perfectionist(sort-union-types)",
                "severity": 1,
                "relatedInformation": [
                    {
                        "message": "",
                        "location": {
                            "uri": "file:///some/fs/path/test.ts",
                            "range": {
                                "start": {
                                    "line": 0,
                                    "character": 33
                                },
                                "end": {
                                    "line": 0,
                                    "character": 39
                                }
                            }
                        }
                    }
                ],
                "source": "oxc"
            }
        ],
        "triggerKind": 2
    }
}


2026-03-09 21:05:24.575 [info] [Trace - 21:05:24] Received response 'textDocument/codeAction - (62)' in 1ms.
2026-03-09 21:05:24.575 [info] Result: [
    {
        "title": "Fix this Expected \"number\" to come before \"string\". problem",
        "kind": "quickfix",
        "edit": {
            "changes": {
                "file:///some/fs/path/test.ts": [
                    {
                        "range": {
                            "start": {
                                "line": 0,
                                "character": 24
                            },
                            "end": {
                                "line": 0,
                                "character": 39
                            }
                        },
                        "newText": "number | string"
                    }
                ]
            }
        },
        "isPreferred": true
    },
    {
        "title": "Disable perfectionist/sort-union-types for this line",
        "kind": "quickfix",
        "edit": {
            "changes": {
                "file:///some/fs/path/test.ts": [
                    {
                        "range": {
                            "start": {
                                "line": 0,
                                "character": 0
                            },
                            "end": {
                                "line": 0,
                                "character": 0
                            }
                        },
                        "newText": "// oxlint-disable-next-line perfectionist/sort-union-types\n"
                    }
                ]
            }
        },
        "isPreferred": false
    },
    {
        "title": "Disable perfectionist/sort-union-types for this whole file",
        "kind": "quickfix",
        "edit": {
            "changes": {
                "file:///some/fs/path/test.ts": [
                    {
                        "range": {
                            "start": {
                                "line": 0,
                                "character": 0
                            },
                            "end": {
                                "line": 0,
                                "character": 0
                            }
                        },
                        "newText": "// oxlint-disable perfectionist/sort-union-types\n"
                    }
                ]
            }
        },
        "isPreferred": false
    }
]


Metadata

Metadata

Assignees

Labels

A-editorArea - Editor and Language ServerA-linterArea - Linter

Type

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions