text: /**
  * @license Apache-2.0
  *
  * Copyright (c) 2018 The Stdlib Authors.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *    http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
  
  'use strict';
  
  // MODULES //
  
  var logger = require( 'debug' );
  var readFile = require( '@stdlib/fs/read-file' );
  var isValid = require( '@stdlib/_tools/repl-txt/validate' );
  
  
  // VARIABLES //
  
  var debug = logger( 'lint:repl-txt:linter' );
  var OPTS = {
  	'encoding': 'utf8'
  };
  
  
  // MAIN //
  
  /**
  * Reads and lints `repl.txt` files.
  *
  * @private
  * @param {StringArray} files - list of `repl.txt` files
  * @param {Callback} clbk - callback to invoke upon completion
  */
  function lint( files, clbk ) {
  	var total;
  	var out;
  	var i;
  
  	total = files.length;
  	out = [];
  	i = -1;
  
  	next();
  
  	/**
  	* Processes the next `repl.txt` file.
  	*
  	* @private
  	*/
  	function next() {
  		i += 1;
  		debug( 'Processing file %d of %d: %s', i+1, total, files[ i ] );
  		readFile( files[ i ], OPTS, onRead );
  	}
  
  	/**
  	* Callback invoked upon reading a `repl.txt` file.
  	*
  	* @private
  	* @param {(Error|null)} error - error object
  	* @param {string} repl - `repl.txt` contents
  	* @returns {void}
  	*/
  	function onRead( error, repl ) {
  		var bool;
  		var j;
  		j = i + 1;
  		if ( error ) {
  			debug( 'Encountered an error reading file: %s (%d of %d). Error: %s', files[ i ], j, total, error.message );
  			out.push({
  				'file': files[ i ],
  				'errors': [
  					{
  						'message': error.message
  					}
  				]
  			});
  		} else {
  			debug( 'Successfully read file: %s (%d of %d).', files[ i ], j, total );
  
  			debug( 'Validating file.' );
  			bool = isValid( repl, {
  				'filepath': files[ i ]
  			});
  			if ( bool ) {
  				debug( 'File is valid.' );
  			} else {
  				debug( 'File is invalid: %s.', JSON.stringify( isValid.errors ) );
  				out.push({
  					'file': files[ i ],
  					'errors': isValid.errors
  				});
  			}
  		}
  		if ( j < total ) {
  			debug( 'Processed %d of %d files.', j, total );
  			return next();
  		}
  		debug( 'Processed all files.' );
  		return done();
  	}
  
  	/**
  	* Callback invoked upon completion.
  	*
  	* @private
  	*/
  	function done() {
  		if ( out.length ) {
  			clbk( null, out );
  		} else {
  			clbk( null, null );
  		}
  	}
  }
  
  
  // EXPORTS //
  
  module.exports = lint;
  