var assert = require('assert');

var OPTION_NAME = 'disallowQuotedKeysInObjects';

module.exports = function() {};

module.exports.prototype = {

    configure: function(disallow) {
        assert(
            typeof disallow === 'boolean',
            OPTION_NAME + ' options requires boolean value'
        );
    },

    getOptionName: function() {
        return OPTION_NAME;
    },

    check: function(file, errors) {
        var KEY_NAME_RE = /^([0-9]+|[a-zA-Z_$]+[\w$]*)$/; // number or identifier
        file.iterateNodesByType('ObjectExpression', function(node) {
            node.properties.forEach(function(prop) {
                var key = prop.key;
                if (key.type === 'Literal' &&
                    typeof key.value === 'string' &&
                    KEY_NAME_RE.test(key.value)
                ) {
                    errors.add('Extra qoutes for key', prop.loc.start);
                }
            });
        });
    }

};

@@ -171,16 +171,35 @@
 disallow
+QuotedKeysInObjects
 ) %7B%0A    
@@ -237,16 +237,35 @@
 disallow
+QuotedKeysInObjects
  === 'bo
@@ -343,16 +343,183 @@
      );%0A
+        assert(%0A            disallowQuotedKeysInObjects === true,%0A            'disallowQuotedKeysInObjects option requires true value or should be removed'%0A        );%0A
     %7D,%0A%0A

add configuration assert for option disallowQuotedKeysInObjects