Skip to content
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

Lack of information about violated rule provided to postprocess function for a custom plugin processor #9683

Closed
ppatotski opened this issue Dec 4, 2017 · 8 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion

Comments

@ppatotski
Copy link

ESLint version: Latest version

Implementation:
Custom eslint plugin processor that traverses reported error messages (postprocess function). Problem: Lack of information about violated rule

Actual: Each message includes information about violated rule

Expect: Violated rule message includes a 'target' property in cases where it makes sense

Example: 'no-undef' rule has the following message:

{ ruleId: 'no-undef',
  severity: 2,
  message: '\'undefinedFunction\' is not defined.',
  line: 1,
  column: 1,
  nodeType: 'Identifier',
  source: 'undefinedFunction();' }

Expect:

{ ruleId: 'no-undef',
  severity: 2,
  message: '\'undefinedFunction\' is not defined.',
  target: 'undefinedFunction'
  line: 1,
  column: 1,
  nodeType: 'Identifier',
  source: 'undefinedFunction();' }

Current workaround is to regex message text in order to extract name of undefined function. However, it is not a reliable way since message format is not a strongly defined api.

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Dec 4, 2017
@not-an-aardvark
Copy link
Member

Could you elaborate on why you need to extract the name of the undefined function?

Also, #6740 and #9165 seem related.

@ppatotski
Copy link
Author

I have a whitelist of 'undefined' function/var names and I would like to filter out errors based on it. The whitelist is very dynamic, so I cannot leverage globals or eslint-disable-line. Let me look into related items.

@platinumazure platinumazure added core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Dec 20, 2017
@platinumazure
Copy link
Member

@ppatotski Is this still an issue?

@ilyavolodin
Copy link
Member

This doesn't seem unique to processors. Our errors in general do not report things like that, because there are so many cases where it's not clear what is the target element that caused this error. We do report AST nodes in some of the rules, but they are normalized to line/column combination, since we assume that consumers might not have access to AST.

@ppatotski
Copy link
Author

Looking at OOB rules I see a lot of rules report errors in the following way (example):

                context.report({
                    node,
                    message: "Unexpected '{{matchedTerm}}' comment.",
                    data: {
                        matchedTerm
                    }
                });

I wonder if there is a way to enable access to data for processors.

@not-an-aardvark
Copy link
Member

Thanks for your interest in improving ESLint. Unfortunately, it looks like this issue didn't get consensus from the team, so I'm closing it. We define consensus as having three 👍s from team members, as well as a team member willing to champion the proposal. This is a high bar by design -- we can't realistically accept and maintain every feature request in the long term, so we only accept feature requests which are useful enough that there is consensus among the team that they're worth adding.

Since ESLint is pluggable and can load custom rules at runtime, the lack of consensus among the ESLint team doesn't need to be a blocker for you using this in your project, if you'd find it useful. It just means that you would need to implement the rule yourself, rather than using a bundled rule that is packaged with ESLint.

@ppatotski
Copy link
Author

Well...Thanks for your time anyway.

@ppatotski
Copy link
Author

I submitted PR (#9871) for consideration just in case you change your mind.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jul 19, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jul 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion
Projects
None yet
Development

No branches or pull requests

4 participants