New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature] Add custom data
into LintMessage
#14198
Comments
@aladdin-add please only move to triaging if you have left a comment. @JounQin can you explain your use case? We intentionally don’t allow extra data to pass through to our results, so we need an idea about why you are requesting this. |
https://github.com/mdx-js/eslint-mdx/blob/master/packages/eslint-plugin-mdx/src/rules/remark.ts#L78 I'm writing a plugin which emits reporting from other tools like For now, I have to hack to use the message property with |
Sorry, I’m having a hard time understanding what it is you’re trying to do and how it relates to custom data in our lint messages. Can you please provide a full description of your use case? More than one or two sentences would be great. |
I don't know if my English and good enough to explain clearly, but I'll try! When I write rule For now, no It works well too. But it would be better to add |
Ah okay, thank you. I understand now. You’re looking for a way to pass data from the rules into the processor to determine how to represent the errors better. That’s an interesting idea. I’m not sure if adding such data would be a breaking change, so I’ll run this by the team and see what they think. @btmills as our resident processor expert, what do you think? |
@eslint/eslint-tsc still looking for feedback on this. |
I won't say it as a BREAKING CHANGE, because the plugin authors control |
To make sure I understand, @JounQin: you've figured out how to wrap ESLint as a runner around another (non-JS) linter by combining a rule and a processor. It would be more convenient if the rule could pass data to the processor without serialization. Is that correct? That's a creative solution. Passing data from a rule through messages to a processor isn't the API I'd come up with if we wanted to implement support for wrapping other linters as a first-class feature, but I'm not opposed to doing this little thing to enable it using otherwise existing API. If it's possible for another processor to sit in between your rule and processor, this might be breaking. For example, if your |
@btmills The But it's still fine to me if you'd like to mark this as BREAKING.
Then do you have any better solution to implement this? Current implementation is really poor because we can not use |
I'll elaborate a bit on my hypothetical breaking change scenario so we can see if it has any holes:
If
To clarify my meaning a bit, I said that because I'm impressed that you've come up with something that works without any support from a first-class API. Linting non-JS code in ESLint is a relatively unexplored concept. RFC56 showed a way to write ESLint rules to run on non-ESTree syntax trees. This is the first time we've talked about using ESLint to wrap another linter as a black box of sorts. With RFC56, ESLint would still be calling the parser, traversing the AST, and calling rules. With what you've figured out, ESLint isn't even aware that there's another linter. That means |
@btmills Wow, I'm getting sidetracked by your example. 😅
But is that true that I was thinking that And |
Yeah, that scenario was dense, but you got the exact point I'm trying to figure out. I think if a |
I think BREAKING means it breaks current runnable codes, now that there is no |
I agree it's at the very edge of what might be considered breaking. In the strictest sense, any change that adds a requirement to third-party code or weakens a guarantee that we previously made third-party code is breaking. Here, we'd add a new requirement that processors preserve |
@JounQin I haven’t really gotten comfortable with the API we’ve been discussing in this issue. However, #14745 looks to be an adjacent use case, and it gave me an idea: Right now, ESLint either lints a file XOR runs it through a processor and lints its blocks. This issue and #14745 want to lint both a file and chunks within that file. What if we changed the processor API to allow both? Would that solve your use case here? |
This already allowed with But this issue is not same as that one exactly. This issue is about reporting better message when integrating with 3rd party linters/tools. |
Oops! It looks like we lost track of this issue. @eslint/eslint-tsc what do we want to do here? This issue will auto-close in 7 days without an update. |
ping |
Oops! It looks like we lost track of this issue. What do we want to do here? This issue will auto-close in 7 days without an update. |
This only auto-closed because I forgot to self-assign. Sorry about that. |
hello, I am working on https://github.com/SonarSource/SonarJS which is a static analyzer based on ESLint used in SonarQube/SonarCloud/SonarLint. We would be also interested in the API which would allow passing additional data when reporting the problem from the rule. In Sonar ecosystem we have the concept of additional locations in the source code which helps to understand more complex problems (imagine taint analysis). Here is one example which shows dataflow in SQL injection issue in juice shop https://sonarcloud.io/project/issues?id=saberduck_juice-shop&issues=AX6N9VGbKcvyCvHU0eOA&open=AX6N9VGbKcvyCvHU0eOA Currently, we have implemented a similar hack, we encode JSON object in the rule message. However this is ugly and we can't use messageIds properly, so I would like to migrate from this. I will be more than happy to help with the implementation if we can agree together on the design. |
Current status of this: we are looking for someone to create an RFC for this feature. If anyone is interested, please comment here. |
@nzakas I would like to give it a try. I can try to allocate some time by the end of August. Could you pls provide some pointers about RFC process? How RFC should look like? |
@saberduck check out https://github.com/eslint/rfcs. There's a README and you can also read through previous RFCs. |
The version of ESLint you are using.
v7.21.0
The problem you want to solve.
I want to get custom data which reported with
context.report({ data })
info inLintMessage
inpostprocess
.Your take on the correct solution to problem.
For now, we got no way to get the custom data, I have to hack to use the
message
property withJSON.stringify/parse
instead.Are you willing to submit a pull request to implement this change?
Yes
The text was updated successfully, but these errors were encountered: