This repository was archived by the owner on Mar 23, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff 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 ) ;
Original file line number Diff line number Diff 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} ) ;
You can’t perform that action at this time.
0 commit comments