Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit 244de06

Browse files
committed
Misc: Make an exception for esnext/verbose since they are removed (#2208)
Fixes #2220
1 parent 4a935aa commit 244de06

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

lib/config/configuration.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,30 @@ Configuration.prototype._getOptionsFromConfig = function(config) {
378378
}, {});
379379
};
380380

381+
Configuration.prototype._errorOnRemovedOptions = function(config) {
382+
var errors = ['Config values to remove in 3.0:'];
383+
384+
if (config.hasOwnProperty('esprima')) {
385+
errors.push('The `esprima` option since CST uses babylon (the babel parser) under the hood');
386+
}
387+
388+
if (config.hasOwnProperty('esprimaOptions')) {
389+
errors.push('The `esprimaOptions` option.');
390+
}
391+
392+
if (config.hasOwnProperty('esnext')) {
393+
errors.push('The `esnext` option is enabled by default.');
394+
}
395+
396+
if (config.hasOwnProperty('verbose')) {
397+
errors.push('The `verbose` option is enabled by default.');
398+
}
399+
400+
if (errors.length > 1) {
401+
throw new Error(errors.join('\n'));
402+
}
403+
};
404+
381405
/**
382406
* Processes configuration and returns config options.
383407
*
@@ -393,6 +417,8 @@ Configuration.prototype._processConfig = function(config) {
393417
// Override the properties
394418
copyConfiguration(overrides, currentConfig);
395419

420+
this._errorOnRemovedOptions(currentConfig);
421+
396422
// NOTE: options is a separate object to ensure that future options must be added
397423
// to BUILTIN_OPTIONS to work, which also assures they aren't mistaken for a rule
398424
var options = this._getOptionsFromConfig(currentConfig);

test/specs/config/configuration.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,5 +782,24 @@ describe('config/configuration', function() {
782782
expect(configuration.getFileExtensions().length).to.equal(1);
783783
expect(configuration.getFileExtensions()[0]).to.equal('.js');
784784
});
785+
786+
it('should error on removed options in 3.0', function() {
787+
try {
788+
configuration.load({
789+
esprima: true,
790+
esprimaOptions: true,
791+
verbose: true,
792+
esnext: true
793+
});
794+
} catch (e) {
795+
expect(e.message).to.equal([
796+
'Config values to remove in 3.0:',
797+
'The `esprima` option since CST uses babylon (the babel parser) under the hood',
798+
'The `esprimaOptions` option.',
799+
'The `esnext` option is enabled by default.',
800+
'The `verbose` option is enabled by default.'
801+
].join('\n'));
802+
}
803+
});
785804
});
786805
});

0 commit comments

Comments
 (0)