-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Issues when multiple plugins use multiple parsers #13450
Comments
Can you share the full configuration? Or at least a minimal valid config? It's hard to tell with the snippets. In particular, it would be helpful to see what overrides you are using. |
Hey @kaicataldo , {
"plugins": [
"no-secrets",
"json",
],
"rules": {
"no-secrets/no-secrets": "error",
"json/undefined":"error"
}
} |
Any chance you can share the relevant part of the code where you use |
Hey @kaicataldo, const CLIEngine = require("eslint7").CLIEngine;
const assert = require('assert');
const TESTS = {
'./staging.config.js':[
{
name:'Should not detect non-secrets',
file:'./staging/has-no-secret.json',
errorCount: 0
},
{
name:'Should detect secrets in json files',
file:'./staging/has-secret.json',
errorCount: 1
}
]
}
describe('JSON compat testing',() => {
const configs = Object.entries(TESTS);
for(const [config,tests] of configs){
const cli = new CLIEngine(require(config));
const files = tests.map(test => test.file);
const {results} = cli.executeOnFiles(files);
describe(config,() => {
for(let i=0;i < tests.length;i++){
const test = tests[i];
const report = results[i];
it(test.name,() => {
assert.strictEqual(test.errorCount,report.errorCount);
});
}
});
}
}); |
So, a few questions/things to check:
|
If none of that works, would you be able to make a repo with the minimal reproduction case for this? Easier for us to debug it this way :) |
For your second comment: Do you want me to create one branch where everything works, and another where it doesn't? |
Just having one that doesn't work would be fine! |
Hey @kaicataldo, |
Alrighty, so it looks like the issue is plugin ordering. When I switch the two elements in this array to "plugins": [
"json",
"self",
], the tests pass. My guess is that the JSON plugin has some overrides that are overriding the configuration set in |
To clarify a bit more, plugins are processed in the order in which they occur, so later plugins can override previous plugins in the |
Hey @kaicataldo, |
Looking at #11035, I don't think we allow for a processor chain or for two separate processors to be run on the same file, but this isn't a part of the codebase I'm deeply knowledgeable about. This would require re-reading the file (if autofixes are performed...Otherwise, we could just keep it cached in memory), running the processor to extract the text to be linted, and running all the rules for each processor specified. ESLint was originally designed to just lint JavaScript, and this feels like a limitation (or just a feature that wasn't necessary at the time ESLint was created) of the time in which it was created. Seems like there are two possible ways forward:
|
This would be ideal, however, some of these processors don't return js, and sometimes they return nothing. |
Hey @kaicataldo , |
|
Unfortunately, it looks like there wasn't enough interest from the team Thanks for contributing to ESLint and we appreciate your understanding. |
Hey ESLint Team,
I maintain a plugin eslint-plugin-no-secrets that uses the parser feature to detect if secure token are in JSON files and JS files so they don't accidentally get committed. I user of mine recently ran into this issue where if multiple plugins use multiple parsers, weird things happen. Currently this behavior appears when used with eslint-plugin-json and eslint-plugin-json-format. The issues are different for each plugin, but I think they have same root cause. If you want me to file multiple issues, let me know.
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using?
None
Please show your full configuration:
Configuration
Multiple, since this is a pluginWhat did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
has-secrets.json
I'm using
CLIEngine
to perform e2e testing, but I think the equvialent command would beWhat did you expect to happen?
This should of been detected by eslint-plugin-no-secrets as a high entropy string
What actually happened? Please include the actual, raw output from ESLint.
If I include the plugin
eslint-plugin-json
, it doesn't detect any high entropy strings.Are you willing to submit a pull request to fix this bug?
If I can get some help debugging this, of course!
The text was updated successfully, but these errors were encountered: