/* eslint-disable no-console */
import _ from 'lodash'

/**
 * Show a deprecated warning for component props.
 * @param {object} context A reference to the component instance (`this`).
 * @param {object} deprecated Keys/values are deprecated props/warning messages.
 *   The component name and "is deprecated" is automatically added.
 *   Only add help messages as values.
 */
export const deprecateProps = (context, deprecated) => {
  if (process.env.NODE_ENV === 'production') return
  const warnings = _.pick(deprecated, _.keys(context.props))
  _.each(warnings, (val, key) => {
    console.warn(`Stardust ${context.constructor.name} prop "${key}" is deprecated. ${val}`)
  })
}

/**
 * Show a deprecated warning for Stardust components.
 * @param {String} name Name of the component being deprecated.
 * @param {String} warning Message to display to the user.
 * @param {String} Replacement Component to be returned in its place.
 * @returns {DeprecatedComponent}
 */
export const deprecateComponent = (name, warning, Replacement) => {
  return class DeprecatedComponent extends Replacement {
    constructor(...args) {
      super(...args)
      console.warn(warning
        ? `Stardust component "${name}" is deprecated. ${warning}`
        : `"${name}" will be removed in future versions. ${warning}`
      )
    }
  }
}

@@ -1,43 +1,34 @@
-/* eslint-disable no-console */
+import _ from 'lodash'
 %0Aimport 
 _ fr
@@ -23,30 +23,33 @@
 %0Aimport 
-_
+React
  from '
-lodash
+react
 '%0A%0A/**%0A 
@@ -586,16 +586,57 @@
 le.warn(
+ // eslint-disable-line no-console%0A      
 %60Stardus
@@ -637,16 +637,18 @@
 tardust 
+%5C%60
 $%7Bcontex
@@ -670,22 +670,26 @@
 ame%7D
+%5C%60
  prop 
-%22
+%5C%60
 $%7Bkey%7D
-%22
+%5C%60
  is 
@@ -707,16 +707,21 @@
  $%7Bval%7D%60
+%0A    
 )%0A  %7D)%0A%7D
@@ -1092,13 +1092,16 @@
 urn 
-class
+function
  Dep
@@ -1120,115 +1120,75 @@
 nent
- extends Replacement %7B%0A    constructor(...args) %7B%0A      super(...args)%0A      console.warn(warning%0A   
+(props) %7B%0A    console.warn( // eslint-disable-line no-console%0A
      
-?
  %60St
@@ -1204,25 +1204,27 @@
 mponent 
-%22
+%5C%60
 $%7Bname%7D
-%22
+%5C%60
  is depr
@@ -1233,42 +1233,12 @@
 ated
-. $%7Bwarning%7D%60%0A        : %60%22$%7Bname%7D%22
+ and
  wil
@@ -1290,17 +1290,48 @@
     
-  
 )
+%0A
 %0A    
-%7D
+return %3CReplacement %7B...props%7D /%3E
 %0A  %7D

handle functional components (#494)