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
Gensite fails while building formatters page #8791
Gensite fails while building formatters page #8791
Comments
Simplified reproduction case: const eslint = require("eslint");
const cliEngine = new eslint.CLIEngine({ baseConfig: { extends: "eslint:recommended" } });
console.log(cliEngine.executeOnText("foo")); Expected output{
"results": [
{
"filePath": "<text>",
"messages": [
{
"ruleId": "strict",
"severity": 2,
"message": "Use the global form of 'use strict'.",
"line": 1,
"column": 1,
"nodeType": "Program",
"source": "foo"
},
{
"ruleId": "no-unused-expressions",
"severity": 2,
"message": "Expected an assignment or function call and instead saw an expression.",
"line": 1,
"column": 1,
"nodeType": "ExpressionStatement",
"source": "foo"
},
{
"ruleId": "no-undef",
"severity": 2,
"message": "'foo' is not defined.",
"line": 1,
"column": 1,
"nodeType": "Identifier",
"source": "foo"
},
{
"ruleId": "eol-last",
"severity": 2,
"message": "Newline required at end of file but not found.",
"line": 1,
"column": 4,
"nodeType": "Program",
"source": "foo",
"fix": {
"range": [
3,
3
],
"text": "\n"
}
},
{
"ruleId": "semi",
"severity": 2,
"message": "Missing semicolon.",
"line": 1,
"column": 4,
"nodeType": "ExpressionStatement",
"source": "foo",
"fix": {
"range": [
3,
3
],
"text": ";"
}
}
],
"errorCount": 5,
"warningCount": 0,
"fixableErrorCount": 2,
"fixableWarningCount": 0,
"source": "foo"
}
],
"errorCount": 5,
"warningCount": 0,
"fixableErrorCount": 2,
"fixableWarningCount": 0
} This crashes with the same stack trace as above. |
Unit tests for this error is in config.js: it("should create config object when using baseConfig with extends", () => {
const customBaseConfig = { extends: path.resolve(__dirname, "..", "fixtures", "config-extends", "array", ".eslintrc") },
configHelper = new Config({ baseConfig: customBaseConfig }, linter);
assert.equal(configHelper.baseConfig.rules["no-empty"], 2);
}); However, I still can't figure out what should be the right behavior. We keep trying to deal with configCache while loading extends, but at that point, it still hasn't been created. |
Does it make sense to store the |
Right, but it goes through the same code as other configs do as well. I tried to change the logic in the morning by adding checks for empty configContext, but I think something else is wrong, since the extends doesn't get resolved correctly. |
Due to a bug, an invalid Config instance was getting used when applying extensions to a `baseConfig` object. This updates the `Config` constructor to use the correct context, and to make sure the config cache exists when the `baseConfig` is evaluated.
During release today, release script failed while generating formatters page for the site. It looks like glob-based configs introduced a regression for configs that use
extend
withbaseConfig
. This branch of code is not covered by unit tests, and it wasn't clear how to fix it during the release. So we skipped generation of formatter page and decided to fix it over the weekend.We traced the error to this line of code:
eslint/lib/config/config-file.js
Line 567 in 7d9e3be
Also config is passing two properties here:
eslint/lib/config.js
Line 70 in 7d9e3be
loadObject
function only accepts one. Even when I changed the code locally to accept two arguments and passconfigContext
as second parameter intoapplyExtends
it failed with the same error, because we only addconfigCache
after we callloadObject
.Error message is below:
The text was updated successfully, but these errors were encountered: