Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Chore: use espree.latestEcmaVersion in config-initializer (#13157)
  • Loading branch information
kaicataldo committed Apr 23, 2020
1 parent e4f57b7 commit e13256e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
6 changes: 2 additions & 4 deletions lib/init/config-initializer.js
Expand Up @@ -15,6 +15,7 @@ const util = require("util"),
inquirer = require("inquirer"),
ProgressBar = require("progress"),
semver = require("semver"),
espree = require("espree"),
recConfig = require("../../conf/eslint-recommended"),
ConfigOps = require("../shared/config-ops"),
log = require("../shared/logging"),
Expand All @@ -31,8 +32,6 @@ const debug = require("debug")("eslint:config-initializer");
// Private
//------------------------------------------------------------------------------

const DEFAULT_ECMA_VERSION = 2018;

/* istanbul ignore next: hard to test fs function */
/**
* Create .eslintrc file in the current working directory
Expand Down Expand Up @@ -265,8 +264,7 @@ function processAnswers(answers) {
extends: []
};

// set the latest ECMAScript version
config.parserOptions.ecmaVersion = DEFAULT_ECMA_VERSION;
config.parserOptions.ecmaVersion = espree.latestEcmaVersion;
config.env.es6 = true;
config.globals = {
Atomics: "readonly",
Expand Down
7 changes: 4 additions & 3 deletions tests/lib/init/config-initializer.js
Expand Up @@ -15,6 +15,7 @@ const assert = require("chai").assert,
os = require("os"),
sinon = require("sinon"),
sh = require("shelljs"),
espree = require("espree"),
autoconfig = require("../../../lib/init/autoconfig"),
npmUtils = require("../../../lib/init/npm-utils");

Expand Down Expand Up @@ -138,7 +139,7 @@ describe("configInitializer", () => {
assert.strictEqual(config.env.es6, true);
assert.strictEqual(config.globals.Atomics, "readonly");
assert.strictEqual(config.globals.SharedArrayBuffer, "readonly");
assert.strictEqual(config.parserOptions.ecmaVersion, 2018);
assert.strictEqual(config.parserOptions.ecmaVersion, espree.latestEcmaVersion);
assert.strictEqual(config.parserOptions.sourceType, "module");
assert.strictEqual(config.env.browser, true);
assert.strictEqual(config.extends, "eslint:recommended");
Expand All @@ -156,15 +157,15 @@ describe("configInitializer", () => {
const config = init.processAnswers(answers);

assert.strictEqual(config.parserOptions.ecmaFeatures.jsx, true);
assert.strictEqual(config.parserOptions.ecmaVersion, 2018);
assert.strictEqual(config.parserOptions.ecmaVersion, espree.latestEcmaVersion);
assert.deepStrictEqual(config.plugins, ["react"]);
});

it("should enable vue plugin", () => {
answers.framework = "vue";
const config = init.processAnswers(answers);

assert.strictEqual(config.parserOptions.ecmaVersion, 2018);
assert.strictEqual(config.parserOptions.ecmaVersion, espree.latestEcmaVersion);
assert.deepStrictEqual(config.plugins, ["vue"]);
assert.deepStrictEqual(config.extends, ["eslint:recommended", "plugin:vue/essential"]);
});
Expand Down

0 comments on commit e13256e

Please sign in to comment.