function main( context ) {
	var requires;
	var packages;
	var filename;
	var excludes;
	var source;
	var match;
	var arr;
	var dir;
	var i;

	source = context.getSourceCode();
	if ( !contains( source.text, ORDER_COMMENT ) ) {
		return {};
	}
	match = RE_CUSTOM_EXCLUDES.exec( source.text );
	if ( match ) {
		excludes = EXCLUDE_LIST.slice();
		arr = match[ 1 ].split( ',' );
		for ( i = 0; i < arr.length; i++ ) {
			excludes.push( trim( arr[ i ] ) );
		}
	} else {
		excludes = EXCLUDE_LIST;
	}
	filename = context.getFilename();
	if ( !filename || !endsWith( filename, 'index.js' ) ) {
		return {};
	}
	dir = join( dirname( filename ), '..' );
	packages = packageDirectories( readDir( dir ) );
	requires = [];

	/**
	* Checks for existence of require paths in the current program and registers them.
	*
	* @private
	* @param {ASTNode} node - node to examine
	*/
	function validate( node ) {
		var requirePath;
		var pkg;
		if ( node.callee.name === 'require' ) {
			requirePath = node.arguments[ 0 ].value;
			if ( isString( requirePath ) ) {
				pkg = basename( requirePath );
				if ( !contains( requires, pkg ) ) {
					requires.push( pkg );
				}
			}
		}
	}

	/**
	* Callback invoked upon program exit.
	*
	* @private
	* @param {Object} node - AST node
	*/
	function finish( node ) {
		var errs;
		var i;

		errs = [];
		for ( i = 0; i < packages.length; i++ ) {
			if ( !contains( requires, packages[ i ] ) ) {
				errs.push( packages[ i ] );
			}
		}
		if ( errs.length ) {
			report( errs, node );
		}
		requires.length = 0; // reset the require cache
	}

	/**
	* Reports a rule violation.
	*
	* @private
	* @param {string} pkg - package missing from the namespace `index.js`
	* @param {Object} node - AST node
	*/
	function reportPkg( pkg, node ) {
		var msg = '`' + pkg + '` should be exported from namespace `index.js`';
		context.report({
			'node': node,
			'message': msg,
			'suggest': [
				{
					'desc': 'Add `' + pkg + '` to the namespace `index.js`',
					'fix': fix
				}
			],
			'fix': fix
		});

		/**
		* Fixes the error message.
		*
		* @private
		* @param {Function} fixer - ESLint fixer
		* @returns {Object} fix
		*/
		function fix( fixer ) {
			var nsPath;
			var entry;
			var match;
			var pos;
			var ns;
			var re;
			var i;

			nsPath = replace( relative( LIB_DIR, dir ), '\\', '/' );
			match = RE_NS_VAR.exec( source.text );
			if ( !match ) {
				return null;
			}
			ns = match[ 1 ];
			entry = [
				'/**',
				'* @name <<alias>>',
				'* @memberof <<ns>>',
				'* @readonly',
				'* @type {Function}',
				'* @see {@link module:<<pkg>>}',
				'*/',
				'setReadOnly( <<ns>>, \'<<alias>>\', require( \'<<pkg>>\' ) );'
			].join( '\n' );
			entry = entry.replace( /<<pkg>>/g, nsPath + '/' + pkg );
			entry = entry.replace( /<<alias>>/g, camelcase( pkg ) );
			entry = entry.replace( /<<ns>>/g, ns );

			// Find position where to insert the entry (packages are listed in alphabetical order according to module name):
			pos = source.text.indexOf( 'var '+ns+' = {};' );
			for ( i = 0; i < packages.length; i++ ) {
				if ( pkg.localeCompare( packages[ i ], 'en', OPTS_COMPARE ) < 0 ) {
					break;
				}
				re = new RegExp( 'require\\( \'' + nsPath + '\\/' + packages[ i ] + '\' \\) \\);' );
				if ( re.test( source.text ) ) {
					pos = source.text.search( re );
				}
			}
			pos = source.text.indexOf( '\n', pos );
			return fixer.insertTextAfterRange( [ pos, pos ], '\n\n'+entry );
		}
	}

	/**
	* Reports error messages.
	*
	* @private
	* @param {StringArray} errs - array of packages not exported from `index.js`
	* @param {ASTNode} node - AST node
	*/
	function report( errs, node ) {
		var pkg;
		var i;
		for ( i = 0; i < errs.length; i++ ) {
			pkg = errs[ i ];
			reportPkg( pkg, node );
		}
	}

	/**
	* Filters out any non-package directories from a list of directory contents.
	*
	* @private
	* @param {Array} contents - directory contents
	* @returns {Array} namespace package directories
	*/
	function packageDirectories( contents ) {
		var content;
		var out;
		var i;

		out = [];
		for ( i = 0; i < contents.length; i++ ) {
			content = contents[ i ];
			if (
				isDirectory( join( dir, content ) ) &&
				!contains( excludes, content )
			) {
				out.push( content );
			}
		}
		return out;
	}

	return {
		'CallExpression': validate,
		'Program:exit': finish
	};
}
Rule for validating that a namespace `index.js` exports all packages in the respective namespace directory.

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