Skip to content

linter: consistent-type-definitions rule does not skip over comments and will highlight comments instead of keywords #14833

@bradzacher

Description

@bradzacher

What version of Oxlint are you using?

playground

What command did you run?

https://playground.oxc.rs/#eNptUk2P00AM/SuVj6uuFpCQUBEnlkor8SWEuBAOsxMnzDIZj2yn7SrKf8eTNlMOnJJ5/np+zxN42EGLPjrGzd3NRp8zbm7uzt/vm3ebaX7bpCbBFgh2E/CYyieGpLBTHnELHfHgVJFh17ko/yIPV0zZJSmBigSh6BTb+2W600BJavD4OyhKdh4rNLjUx+vT05AZ5VoinrKFz6TkeXikuL5811/S5i1kx1LIToAnxSQ21zRQOdmOLkY6fkMdOX0ZVUKL+zH5Qm1tVWYiH/CrCVb4ntGl7sebh6QcrKOvAUGjrcF/YCa+oMah6Hfm4Cl1wdjB1ECOY2/lDex+NlAcEM8hawO/tg1406onDljiluyJGb0mk8CABqjrGpgtkcd4zTEyYkvqbWl322IXUliUXmqOjpMVzVZ3NejMSx33aB4DyqsXL1+bNqPgfanHPfH76ET2AWNbN8VTRg6DzXLRLCVztG5s0SFoRT+hutapq3L8/xQmEJMzm6jIyZmZq4OeWuxxOcRUTq36/CQt2UFfPEmJdOm1IhH7NXfpsh7QZK/1umxzyh/xgLXpH8T82Q24XtpSakZT3JvppeKA/EiynmbZJz2ZNSVU/2aDF/mXGfVvLniRed1p/gsblUdw

What does your .oxlintrc.json config file look like?

consistent-type-definitions: 'error'

What happened?

Input:

declare /* type */ type T = {};

Expected:

declare /* type */ type T = {};
                   ^^^^ error here

Actual:

declare /* type */ type T = {};
           ^^^^ error here

Because oxc/oxlint doesn't work with tokens it is unable to distinguish between comment text and code text.


Side note that I suspect that if I had a bit of a poke around I could find a few bugs like this. It's the major weaknesses of relying on String::find on top of source code instead of having a CST to inspect.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions