function main( context ) {
	var options;
	var order;
	var fun;

	options = context.options[ 0 ];
	order = DEFAULTS.order;
	if ( hasOwnProp( options, 'order' ) ) {
		order = options.order;
	}
	switch ( order ) {
	case 'increasing':
		fun = isGreaterOrEqual;
		break;
	case 'decreasing':
	default:
		fun = isSmallerOrEqual;
		break;
	}

	/**
	* Sorts the variable declarations by name length.
	*
	* @private
	* @param {Object} a - input object
	* @param {Object} b - comparison object
	* @returns {number} number indicating sort order
	*/
	function sortVars( a, b ) {
		if ( fun( a.name.length, b.name.length ) ) {
			return 1;
		}
		return -1;
	}

	/**
	* Reports the error message.
	*
	* @private
	* @param {string} msg - error message
	* @param {ASTNode} node - node to fix
	*/
	function report( msg, node ) {
		context.report({
			'node': null,
			'message': msg,
			'loc': node.loc,
			'fix': fix
		});

		/**
		* Fixes the lint error by reordering the variable declarations inside of the function.
		*
		* @private
		* @param {Function} fixer - ESLint fixer
		* @returns {(Object|null)} fix or null
		*/
		function fix( fixer ) {
			var replacingText;
			var declarations;
			var startRange;
			var endRange;
			var source;
			var elem;
			var body;
			var i;
			var j;

			declarations = [];
			replacingText = '';
			body = node.body.body;
			source = context.getSourceCode();

			for ( i = 0; i < body.length; i++ ) {
				elem = body[ i ];
				if ( elem.type === 'VariableDeclaration' && elem.kind === 'var' ) {
					declarations.push({
						'text': source.getText( elem ),
						'name': elem.declarations[ 0 ].id.name,
						'col': elem.loc.start.column
					});
					if ( declarations.length === 1 ) {
						startRange = elem.range[ 0 ] - elem.loc.start.column;
					}
					endRange = elem.range[ 1 ];
				}
			}

			declarations.sort( sortVars );

			for ( i = 0; i < declarations.length; i++ ) {
				for ( j = 0; j < declarations[ i ].col; j++ ) {
					replacingText += '\t';
				}
				replacingText += declarations[ i ].text;
				if ( i !== declarations.length -1 ) {
					replacingText += '\n';
				}
			}

			return fixer.replaceTextRange( [ startRange, endRange ], replacingText ); // eslint-disable-line max-len
		}
	}

	/**
	* Checks whether the variable declarations inside of the supplied node are ordered.
	*
	* @private
	* @param {ASTNode} node - node to examine
	* @returns {void}
	*/
	function validate( node ) {
		var prevLength;
		var body;
		var elem;
		var name;
		var i;

		body = node.body.body;
		prevLength = null;
		for ( i = 0; i < body.length; i++ ) {
			elem = body[ i ];
			if ( elem.type === 'VariableDeclaration' && elem.kind === 'var' ) {
				name = elem.declarations[ 0 ].id.name;
				if ( prevLength && !fun( name.length, prevLength ) ) {
					return report( 'Variable declarations inside of function are not ordered by length (in '+ order +' order)', node );
				}
				prevLength = name.length;
			}
		}
	}

	return {
		'FunctionDeclaration': validate,
		'FunctionExpression': validate
	};
}
Rule enforcing variable declarations inside of functions to be ordered by length.

@param {Object} context - ESLint context
@returns {Object} validators