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

Fix: don't pass default parserOptions to custom parsers (fixes #8744) #8745

Merged
merged 1 commit into from Jun 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 1 addition & 5 deletions conf/default-config-options.js
Expand Up @@ -25,9 +25,5 @@ module.exports = deepFreeze({
rules: {},
settings: {},
parser: "espree",
parserOptions: {
ecmaVersion: 5,
sourceType: "script",
ecmaFeatures: {}
}
parserOptions: {}
});
4 changes: 2 additions & 2 deletions lib/linter.js
Expand Up @@ -455,8 +455,8 @@ function normalizeEcmaVersion(ecmaVersion, isModule) {
*/
function prepareConfig(config, envContext) {
config.globals = config.globals || {};
const copiedRules = Object.assign({}, defaultConfig.rules);
let parserOptions = Object.assign({}, defaultConfig.parserOptions);
const copiedRules = {};
let parserOptions = {};

if (typeof config.rules === "object") {
Object.keys(config.rules).forEach(k => {
Expand Down
10 changes: 10 additions & 0 deletions tests/fixtures/parsers/throws-with-options.js
@@ -0,0 +1,10 @@
"use strict";

const espree = require("espree");

exports.parse = (sourceText, options) => {
if (options.ecmaVersion) {
throw new Error("Expected no parserOptions to be used");
}
return espree.parse(sourceText, options);
};
7 changes: 7 additions & 0 deletions tests/lib/linter.js
Expand Up @@ -3905,6 +3905,13 @@ describe("eslint", () => {
assert.equal(messages[0].message, errorPrefix + require(parser).expectedError);
});

it("should not pass any default parserOptions to the parser", () => {
const parser = path.join(parserFixtures, "throws-with-options.js");

const messages = linter.verify(";", { parser }, "filename");

assert.strictEqual(messages.length, 0);
});
});
}

Expand Down