From 270da9ce9e967992479865181ce12c787856d6f1 Mon Sep 17 00:00:00 2001 From: Kai Cataldo Date: Wed, 12 Feb 2020 20:25:31 -0500 Subject: [PATCH] Change public API from getter methods to static property --- espree.js | 4 ++-- tests/lib/supported-ecmaversions.js | 18 +++++------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/espree.js b/espree.js index dcc60c3a..d8069528 100644 --- a/espree.js +++ b/espree.js @@ -172,6 +172,6 @@ exports.VisitorKeys = (function() { return require("eslint-visitor-keys").KEYS; }()); -exports.getLatestEcmaVersion = getLatestEcmaVersion; +exports.latestEcmaVersion = getLatestEcmaVersion(); -exports.getSupportedEcmaVersions = getSupportedEcmaVersions; +exports.supportedEcmaVersions = getSupportedEcmaVersions(); diff --git a/tests/lib/supported-ecmaversions.js b/tests/lib/supported-ecmaversions.js index bdcd6c06..2285bc6d 100644 --- a/tests/lib/supported-ecmaversions.js +++ b/tests/lib/supported-ecmaversions.js @@ -1,5 +1,5 @@ /** - * @fileoverview Tests for getLatestEcmaVersion() & getSupportedEcmaVersions(). + * @fileoverview Tests for latestEcmaVersion & supportedEcmaVersions. * @author Kai Cataldo */ @@ -16,25 +16,17 @@ const assert = require("assert"), // Tests //------------------------------------------------------------------------------ -describe("getLatestEcmaVersion()", () => { +describe("latestEcmaVersion", () => { it("should return the latest supported ecmaVersion", () => { - assert.strictEqual(espree.getLatestEcmaVersion(), 11); + assert.strictEqual(espree.latestEcmaVersion, 11); }); }); -describe("getSupportedEcmaVersions()", () => { +describe("supportedEcmaVersions", () => { it("should return an array of all supported versions", () => { assert.deepStrictEqual( - espree.getSupportedEcmaVersions(), + espree.supportedEcmaVersions, [3, 5, 6, 7, 8, 9, 10, 11] ); }); - - it("the array of supported versions should not be mutable by reference", () => { - const supportedVersions = espree.getSupportedEcmaVersions(); - const originalValue = [...supportedVersions]; - - supportedVersions.push("a", "b", "c"); - assert.deepStrictEqual(espree.getSupportedEcmaVersions(), originalValue); - }); });