Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with recursive lookup #445

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/utils/setConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,19 @@ var setConfig = function( configpath ) {
* @param {string} cwd [relative path to current directory being walked]
* @return {?Object|?Function} [config if found, recurse if not. null if failed]
*/
var initialCwd

var _recurseDirectories = function( files, level, cwd ) {
// A little flag to make sure we don't go two levels down.
initialCwd = initialCwd || cwd

// parse stylintrc if found, stop recursion
if ( files.indexOf( '.stylintrc' ) !== -1 ) {
return _parseConfig( cwd + '/.stylintrc' )
}

// only go up to user home directory, stop recursion
if ( userHome ) return null
if ( initialCwd === userHome ) return null

// next dir level
var nextLevel = level + 1
Expand All @@ -72,7 +77,7 @@ var setConfig = function( configpath ) {
// ie, level = 1, pathArr = [ cwd, '..' ]
// ie, level = 2, pathArr = [ cwd, '..', '..' ]
// and so on
var pathArr = [ cwd ]
var pathArr = [ initialCwd ]

// push '..' for each dir level
while ( level-- ) {
Expand Down