Skip to content

Commit

Permalink
Change public API from getter methods to static property
Browse files Browse the repository at this point in the history
  • Loading branch information
kaicataldo committed Feb 13, 2020
1 parent d8f0fa7 commit 270da9c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
4 changes: 2 additions & 2 deletions espree.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
18 changes: 5 additions & 13 deletions tests/lib/supported-ecmaversions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @fileoverview Tests for getLatestEcmaVersion() & getSupportedEcmaVersions().
* @fileoverview Tests for latestEcmaVersion & supportedEcmaVersions.
* @author Kai Cataldo
*/

Expand All @@ -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);
});
});

0 comments on commit 270da9c

Please sign in to comment.