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) {
378
378
} , { } ) ;
379
379
} ;
380
380
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
+
381
405
/**
382
406
* Processes configuration and returns config options.
383
407
*
@@ -393,6 +417,8 @@ Configuration.prototype._processConfig = function(config) {
393
417
// Override the properties
394
418
copyConfiguration ( overrides , currentConfig ) ;
395
419
420
+ this . _errorOnRemovedOptions ( currentConfig ) ;
421
+
396
422
// NOTE: options is a separate object to ensure that future options must be added
397
423
// to BUILTIN_OPTIONS to work, which also assures they aren't mistaken for a rule
398
424
var options = this . _getOptionsFromConfig ( currentConfig ) ;
Original file line number Diff line number Diff line change @@ -782,5 +782,24 @@ describe('config/configuration', function() {
782
782
expect ( configuration . getFileExtensions ( ) . length ) . to . equal ( 1 ) ;
783
783
expect ( configuration . getFileExtensions ( ) [ 0 ] ) . to . equal ( '.js' ) ;
784
784
} ) ;
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
+ } ) ;
785
804
} ) ;
786
805
} ) ;
You can’t perform that action at this time.
0 commit comments