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 join = require( 'path' ).join;
  var tape = require( 'tape' );
  var proxyquire = require( 'proxyquire' );
  var noop = require( '@stdlib/utils/noop' );
  var IS_BROWSER = require( '@stdlib/assert/is-browser' );
  var isEmptyArray = require( '@stdlib/assert/is-empty-array' );
  var isObjectArray = require( '@stdlib/assert/is-plain-object-array' );
  var lint = require( './../lib/main.js' );
  
  
  // VARIABLES //
  
  var opts = {
  	'skip': IS_BROWSER
  };
  
  
  // TESTS //
  
  tape( 'main export is a function', opts, function test( t ) {
  	t.ok( true, __filename );
  	t.strictEqual( typeof lint, 'function', 'main export is a function' );
  	t.end();
  });
  
  tape( 'the function throws an error if provided an invalid option', opts, function test( t ) {
  	t.throws( foo, TypeError, 'throws error' );
  	t.end();
  	function foo() {
  		var opts = {
  			'dir': null
  		};
  		lint( opts, noop );
  	}
  });
  
  tape( 'if provided a callback argument which is not a function, the function throws an error (no options)', opts, function test( t ) {
  	var values;
  	var i;
  
  	values = [
  		'5',
  		5,
  		NaN,
  		true,
  		false,
  		null,
  		void 0,
  		[],
  		{}
  	];
  
  	for ( i = 0; i < values.length; i++ ) {
  		t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] );
  	}
  	t.end();
  
  	function badValue( value ) {
  		return function badValue() {
  			lint( value );
  		};
  	}
  });
  
  tape( 'if provided a callback argument which is not a function, the function throws an error (options)', opts, function test( t ) {
  	var values;
  	var i;
  
  	values = [
  		'5',
  		5,
  		NaN,
  		true,
  		false,
  		null,
  		void 0,
  		[],
  		{}
  	];
  
  	for ( i = 0; i < values.length; i++ ) {
  		t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] );
  	}
  	t.end();
  
  	function badValue( value ) {
  		return function badValue() {
  			lint( {}, value );
  		};
  	}
  });
  
  tape( 'the function returns an error to a provided callback if an error is encountered while searching a directory', opts, function test( t ) {
  	var lint = proxyquire( './../lib/main.js', {
  		'glob': glob
  	});
  
  	lint( clbk );
  
  	function glob() {
  		var cb = arguments[ arguments.length-1 ];
  		setTimeout( onTimeout, 0 );
  		function onTimeout() {
  			cb( new Error( 'beep' ) );
  		}
  	}
  
  	function clbk( error ) {
  		t.ok( error, 'returns an error' );
  		t.end();
  	}
  });
  
  tape( 'the function returns an error to a provided callback if an error is encountered while linting a file', opts, function test( t ) {
  	var lint;
  	var opts;
  
  	lint = proxyquire( './../lib/main.js', {
  		'@stdlib/_tools/lint/license-header-file-list': mock
  	});
  
  	opts = {
  		'dir': join( __dirname, 'fixtures', 'good' ),
  		'ignore': [
  			'node_modules/**' // Note: we need to explicitly set `ignore` to ensure that test coverage can run in a "build" directory. Because we explicitly set the `dir` option, searching a large directory tree is not an issue.
  		]
  	};
  
  	lint( opts, clbk );
  
  	function mock() {
  		var cb = arguments[ arguments.length-1 ];
  		setTimeout( onTimeout, 0 );
  		function onTimeout() {
  			cb( new Error( 'beep' ) );
  		}
  	}
  
  	function clbk( error ) {
  		t.ok( error, 'returns an error' );
  		t.end();
  	}
  });
  
  tape( 'the function returns an empty array if all files are valid', opts, function test( t ) {
  	var opts = {
  		'dir': join( __dirname, 'fixtures', 'good' ),
  		'ignore': [
  			'node_modules/**' // Note: we need to explicitly set `ignore` to ensure that test coverage can run in a "build" directory. Because we explicitly set the `dir` option, searching a large directory tree is not an issue.
  		]
  	};
  	lint( opts, clbk );
  
  	function clbk( error, errs ) {
  		if ( error ) {
  			t.ok( false, error.message );
  		}
  		t.strictEqual( isEmptyArray( errs ), true, 'returns an empty array' );
  		t.end();
  	}
  });
  
  tape( 'the function returns an object array if files are not valid', opts, function test( t ) {
  	var opts = {
  		'dir': join( __dirname, 'fixtures', 'bad' ),
  		'ignore': [
  			'node_modules/**' // Note: we need to explicitly set `ignore` to ensure that test coverage can run in a "build" directory. Because we explicitly set the `dir` option, searching a large directory tree is not an issue.
  		]
  	};
  	lint( opts, clbk );
  
  	function clbk( error, errs ) {
  		if ( error ) {
  			t.ok( false, error.message );
  		}
  		t.strictEqual( isObjectArray( errs ), true, 'returns an object array' );
  		t.end();
  	}
  });
  
  tape( 'the function returns an object array if files are not valid (multiple headers)', opts, function test( t ) {
  	var opts = {
  		'dir': join( __dirname, 'fixtures', 'multiple' ),
  		'ignore': [
  			'node_modules/**' // Note: we need to explicitly set `ignore` to ensure that test coverage can run in a "build" directory. Because we explicitly set the `dir` option, searching a large directory tree is not an issue.
  		]
  	};
  	lint( opts, clbk );
  
  	function clbk( error, errs ) {
  		if ( error ) {
  			t.ok( false, error.message );
  		}
  		t.strictEqual( isObjectArray( errs ), true, 'returns an object array' );
  		t.strictEqual( errs.length, 1, 'has expected length' );
  		t.end();
  	}
  });
  
  tape( 'the function returns an object array if files are not valid (start location)', opts, function test( t ) {
  	var opts = {
  		'dir': join( __dirname, 'fixtures', 'start-location' ),
  		'ignore': [
  			'node_modules/**' // Note: we need to explicitly set `ignore` to ensure that test coverage can run in a "build" directory. Because we explicitly set the `dir` option, searching a large directory tree is not an issue.
  		]
  	};
  	lint( opts, clbk );
  
  	function clbk( error, errs ) {
  		if ( error ) {
  			t.ok( false, error.message );
  		}
  		t.strictEqual( isObjectArray( errs ), true, 'returns an object array' );
  		t.strictEqual( errs.length, 1, 'has expected length' );
  		t.end();
  	}
  });
  
  tape( 'the function supports specifying a filename pattern (valid)', opts, function test( t ) {
  	var opts = {
  		'dir': join( __dirname, 'fixtures', 'good' ),
  		'pattern': '**/*.js',
  		'ignore': [
  			'node_modules/**' // Note: we need to explicitly set `ignore` to ensure that test coverage can run in a "build" directory. Because we explicitly set the `dir` option, searching a large directory tree is not an issue.
  		]
  	};
  	lint( opts, clbk );
  
  	function clbk( error, errs ) {
  		if ( error ) {
  			t.ok( false, error.message );
  		}
  		t.strictEqual( isEmptyArray( errs ), true, 'returns an empty array' );
  		t.end();
  	}
  });
  
  tape( 'the function supports specifying a filename pattern (invalid)', opts, function test( t ) {
  	var opts = {
  		'dir': join( __dirname, 'fixtures', 'bad' ),
  		'pattern': '**/*.js',
  		'ignore': [
  			'node_modules/**' // Note: we need to explicitly set `ignore` to ensure that test coverage can run in a "build" directory. Because we explicitly set the `dir` option, searching a large directory tree is not an issue.
  		]
  	};
  	lint( opts, clbk );
  
  	function clbk( error, errs ) {
  		if ( error ) {
  			t.ok( false, error.message );
  		}
  		t.strictEqual( isObjectArray( errs ), true, 'returns an object array' );
  		t.end();
  	}
  });
  
  tape( 'the function supports specifying a list of glob patterns to exclude matches', opts, function test( t ) {
  	var opts;
  	var dir;
  
  	dir = join( __dirname, 'fixtures', 'bad' );
  	opts = {
  		'dir': dir,
  		'ignore': [ dir+'/**' ] // We are ignoring the directory we are supposed to search!
  	};
  	lint( opts, clbk );
  
  	function clbk( error, errs ) {
  		if ( error ) {
  			t.ok( false, error.message );
  		}
  		t.strictEqual( isEmptyArray( errs ), true, 'returns an empty array' );
  		t.end();
  	}
  });
  
  tape( 'the function supports specifying a license header string to lint against', opts, function test( t ) {
  	var opts = {
  		'dir': join( __dirname, 'fixtures', 'good' ),
  		'pattern': '**/*.js',
  		'ignore': [
  			'node_modules/**' // Note: we need to explicitly set `ignore` to ensure that test coverage can run in a "build" directory. Because we explicitly set the `dir` option, searching a large directory tree is not an issue.
  		],
  		'header': '// This file is licensed under Apache-2.0.'
  	};
  	lint( opts, clbk );
  
  	function clbk( error, errs ) {
  		if ( error ) {
  			t.ok( false, error.message );
  		}
  		t.strictEqual( isObjectArray( errs ), true, 'returns an object array' );
  		t.end();
  	}
  });
  
  tape( 'the function supports specifying a license header regular expression to lint against', opts, function test( t ) {
  	var opts = {
  		'dir': join( __dirname, 'fixtures', 'good' ),
  		'pattern': '**/*.js',
  		'ignore': [
  			'node_modules/**' // Note: we need to explicitly set `ignore` to ensure that test coverage can run in a "build" directory. Because we explicitly set the `dir` option, searching a large directory tree is not an issue.
  		],
  		'header': /\/\/ This file is licensed under Apache-2\.0\./
  	};
  	lint( opts, clbk );
  
  	function clbk( error, errs ) {
  		if ( error ) {
  			t.ok( false, error.message );
  		}
  		t.strictEqual( isObjectArray( errs ), true, 'returns an object array' );
  		t.end();
  	}
  });
  
  tape( 'the function supports specifying a license header object mapping strings and/or regular expressions to filename extensions', opts, function test( t ) {
  	var opts = {
  		'dir': join( __dirname, 'fixtures', 'good' ),
  		'pattern': '**/*.js',
  		'ignore': [
  			'node_modules/**' // Note: we need to explicitly set `ignore` to ensure that test coverage can run in a "build" directory. Because we explicitly set the `dir` option, searching a large directory tree is not an issue.
  		],
  		'header': {
  			'js': /\/\/ This file is licensed under Apache-2\.0\./,
  			'awk': '# This file is licensed under Apache-2.0.'
  		}
  	};
  	lint( opts, clbk );
  
  	function clbk( error, errs ) {
  		if ( error ) {
  			t.ok( false, error.message );
  		}
  		t.strictEqual( isObjectArray( errs ), true, 'returns an object array' );
  		t.end();
  	}
  });
  
  tape( 'the function supports specifying an empty license header object', opts, function test( t ) {
  	var opts = {
  		'dir': join( __dirname, 'fixtures', 'good' ),
  		'pattern': '**/*.js',
  		'ignore': [
  			'node_modules/**' // Note: we need to explicitly set `ignore` to ensure that test coverage can run in a "build" directory. Because we explicitly set the `dir` option, searching a large directory tree is not an issue.
  		],
  		'header': {}
  	};
  	lint( opts, clbk );
  
  	function clbk( error, errs ) {
  		if ( error ) {
  			t.ok( false, error.message );
  		}
  		t.strictEqual( isEmptyArray( errs ), true, 'returns an empty array' );
  		t.end();
  	}
  });
  
  tape( 'the function supports specifying a default license header when providing an object mapping strings and/or regular expressions to filename extensions (valid)', opts, function test( t ) {
  	var opts = {
  		'dir': join( __dirname, 'fixtures', 'good' ),
  		'pattern': '**/*.js',
  		'ignore': [
  			'node_modules/**' // Note: we need to explicitly set `ignore` to ensure that test coverage can run in a "build" directory. Because we explicitly set the `dir` option, searching a large directory tree is not an issue.
  		],
  		'header': {
  			'default': /(?:[#!*] |)@license Apache-2\.0/
  		}
  	};
  	lint( opts, clbk );
  
  	function clbk( error, errs ) {
  		if ( error ) {
  			t.ok( false, error.message );
  		}
  		t.strictEqual( isEmptyArray( errs ), true, 'returns an empty array' );
  		t.end();
  	}
  });
  
  tape( 'the function supports specifying a default license header when providing an object mapping strings and/or regular expressions to filename extensions (invalid)', opts, function test( t ) {
  	var opts = {
  		'dir': join( __dirname, 'fixtures', 'bad' ),
  		'pattern': '**/*.js',
  		'ignore': [
  			'node_modules/**' // Note: we need to explicitly set `ignore` to ensure that test coverage can run in a "build" directory. Because we explicitly set the `dir` option, searching a large directory tree is not an issue.
  		],
  		'header': {
  			'default': /(?:[#!*] |)@license Apache-2\.0/
  		}
  	};
  	lint( opts, clbk );
  
  	function clbk( error, errs ) {
  		if ( error ) {
  			t.ok( false, error.message );
  		}
  		t.strictEqual( isObjectArray( errs ), true, 'returns an object array' );
  		t.end();
  	}
  });
  