From e847424b961c664ba6e71780f3839691ff56f657 Mon Sep 17 00:00:00 2001 From: Sylvain STEPHANT Date: Fri, 22 Feb 2019 16:46:16 +0100 Subject: [PATCH] Drop JSON5 support --- .gitignore | 1 - docs/index.md | 4 +--- lib/cli/config.js | 4 ---- package-lock.json | 15 --------------- package.json | 1 - test/integration/config.spec.js | 2 -- test/integration/fixtures/config/mocharc.jsonc | 7 ------- test/node-unit/cli/config.spec.js | 16 ++-------------- 8 files changed, 3 insertions(+), 47 deletions(-) delete mode 100644 test/integration/fixtures/config/mocharc.jsonc diff --git a/.gitignore b/.gitignore index 3ab9de9814..02634697bf 100644 --- a/.gitignore +++ b/.gitignore @@ -79,7 +79,6 @@ Session.vim out/ .idea_modules/ atlassian-ide-plugin.xml -mocha.iml # SourceTree *_BACKUP_* diff --git a/docs/index.md b/docs/index.md index 517c3a95b9..34dd8973a0 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1627,8 +1627,7 @@ In addition to supporting the legacy [`mocha.opts`](#mochaopts) run-control form - **JavaScript**: Create a `.mocharc.js` in your project's root directory, and export an object (`module.exports = {/* ... */}`) containing your configuration. - **YAML**: Create a `.mocharc.yaml` (or `.mocharc.yml`) in your project's root directory. -- **JSON**: Create a `.mocharc.json` in your project's root directory. Comments — while not valid JSON — are allowed in this file, and will be ignored by Mocha. -- **[JSON5](https://json5.org/)**: Create a `.mocharc.jsonc` (or `.mocharc.json5`) in your project's root directory. +- **JSON**: Create a `.mocharc.json` (or `.mocharc.jsonc`) in your project's root directory. Comments — while not valid JSON — are allowed in this file, and will be ignored by Mocha. - **`package.json`**: Create a `mocha` property in your project's `package.json`. Mocha suggests using one of the above strategies for configuration instead of the legacy `mocha.opts` format. @@ -1651,7 +1650,6 @@ If no custom path was given, and if there are multiple configuration files in th 1. `.mocharc.yaml` 1. `.mocharc.yml` 1. `.mocharc.jsonc` -1. `.mocharc.json5` 1. `.mocharc.json` ### Merging diff --git a/lib/cli/config.js b/lib/cli/config.js index 46d194ecca..dd8f987ca1 100644 --- a/lib/cli/config.js +++ b/lib/cli/config.js @@ -25,7 +25,6 @@ exports.CONFIG_FILES = [ '.mocharc.yaml', '.mocharc.yml', '.mocharc.jsonc', - '.mocharc.json5', '.mocharc.json' ]; @@ -37,7 +36,6 @@ const parsers = (exports.parsers = { yaml: filepath => require('js-yaml').safeLoad(fs.readFileSync(filepath, 'utf8')), js: filepath => require(filepath), - json5: filepath => require('json5').parse(fs.readFileSync(filepath, 'utf8')), json: filepath => JSON.parse( require('strip-json-comments')(fs.readFileSync(filepath, 'utf8')) @@ -59,8 +57,6 @@ exports.loadConfig = filepath => { config = parsers.yaml(filepath); } else if (ext === '.js') { config = parsers.js(filepath); - } else if (/\.json[5c]/.test(ext)) { - config = parsers.json5(filepath); } else { config = parsers.json(filepath); } diff --git a/package-lock.json b/package-lock.json index 368074be9f..700ad24086 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10360,21 +10360,6 @@ "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", "dev": true }, - "json5": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.0.tgz", - "integrity": "sha512-8Mh9h6xViijj36g7Dxi+Y4S6hNGV96vcJZr/SrlHh1LR/pEn/8j/+qIBbs44YKl69Lrfctp4QD+AdWLTMqEZAQ==", - "requires": { - "minimist": "^1.2.0" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" - } - } - }, "jsonfile": { "version": "2.4.0", "resolved": "http://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", diff --git a/package.json b/package.json index 499e357700..0f430d8cc5 100644 --- a/package.json +++ b/package.json @@ -502,7 +502,6 @@ "growl": "1.10.5", "he": "1.2.0", "js-yaml": "3.12.0", - "json5": "2.1.0", "log-symbols": "2.2.0", "minimatch": "3.0.4", "mkdirp": "0.5.1", diff --git a/test/integration/config.spec.js b/test/integration/config.spec.js index 636bcec363..76a4a718d4 100644 --- a/test/integration/config.spec.js +++ b/test/integration/config.spec.js @@ -11,10 +11,8 @@ describe('config', function() { var configDir = path.join(__dirname, 'fixtures', 'config'); var js = loadConfig(path.join(configDir, 'mocharc.js')); var json = loadConfig(path.join(configDir, 'mocharc.json')); - var jsonc = loadConfig(path.join(configDir, 'mocharc.jsonc')); var yaml = loadConfig(path.join(configDir, 'mocharc.yaml')); expect(js, 'to equal', json); expect(json, 'to equal', yaml); - expect(yaml, 'to equal', jsonc); }); }); diff --git a/test/integration/fixtures/config/mocharc.jsonc b/test/integration/fixtures/config/mocharc.jsonc deleted file mode 100644 index 60d8316ed3..0000000000 --- a/test/integration/fixtures/config/mocharc.jsonc +++ /dev/null @@ -1,7 +0,0 @@ -// Comment -{ - require: ["foo", "bar"], - "bail": true, - "reporter": /* 📋 */ "dot", - "slow": +60, -} diff --git a/test/node-unit/cli/config.spec.js b/test/node-unit/cli/config.spec.js index 691cb4392f..295cd845dc 100644 --- a/test/node-unit/cli/config.spec.js +++ b/test/node-unit/cli/config.spec.js @@ -21,7 +21,6 @@ describe('cli/config', function() { beforeEach(function() { sandbox.stub(parsers, 'yaml').returns(config); sandbox.stub(parsers, 'json').returns(config); - sandbox.stub(parsers, 'json5').returns(config); sandbox.stub(parsers, 'js').returns(config); }); @@ -61,20 +60,9 @@ describe('cli/config', function() { describe('when supplied a filepath with .jsonc extension', function() { const filepath = 'foo.jsonc'; - it('should use the JSON5 parser', function() { + it('should use the JSON parser', function() { loadConfig('foo.jsonc'); - expect(parsers.json5, 'to have calls satisfying', [ - {args: [filepath], returned: config} - ]).and('was called times', 1); - }); - }); - - describe('when supplied a filepath with .json5 extension', function() { - const filepath = 'foo.json5'; - - it('should use the JSON5 parser', function() { - loadConfig('foo.json5'); - expect(parsers.json5, 'to have calls satisfying', [ + expect(parsers.json, 'to have calls satisfying', [ {args: [filepath], returned: config} ]).and('was called times', 1); });