lib/bundleLocator.js
function (bundle) {
        var name = (bundle.options && bundle.options.ruleset) || DEFAULT_RULESET,
            cacheKey = name + '@' + bundle.baseDirectory,
            rulesetsPath,
            rulesets,
            dir,
            rules;

        rules = this._cacheRules[cacheKey];
        if (rules) {
            return rules;
        }
        if (bundle.options && bundle.options.rulesets) {
            try {
                rulesetsPath = libpath.resolve(bundle.baseDirectory, bundle.options.rulesets);
                rulesets = require(rulesetsPath);
            } catch (errLocal) {
                if ('MODULE_NOT_FOUND' !== errLocal.code) {
                    throw errLocal;
                }
            }
            if (!rulesets) {
                dir = bundle.baseDirectory;
                while (dir) {
                    try {
                        rulesetsPath = libpath.resolve(dir, bundle.options.rulesets);
                        rulesets = require(rulesetsPath);
                        break;
                    } catch (errDir) {
                        if ('MODULE_NOT_FOUND' !== errDir.code) {
                            throw errDir;
                        }
                    }
                    try {
                        rulesetsPath = libpath.resolve(dir, 'node_modules', bundle.options.rulesets);
                        rulesets = require(rulesetsPath);
                        break;
                    } catch (errDep) {
                        if ('MODULE_NOT_FOUND' !== errDep.code) {
                            throw errDep;
                        }
                    }

                    // not found, iterate
                    dir = libpath.dirname(dir);
                    if ('node_modules' === libpath.basename(dir)) {
                        dir = libpath.dirname(dir);
                    }
                    if (this._rootDirectory && dir.length < this._rootDirectory.length) {
                        // if we can find the ruleset anywhere near in the filesystem
                        // we should try to rely on npm lookup process
                        try {
                            rulesetsPath = Module._resolveFilename(bundle.options.rulesets,
                                    Module._cache[__filename]);
                            rulesets = require(rulesetsPath);
                        } catch (errLocalMod) {
                            return;
                        }
                    }
                }
            }
            // a ruleset pkg can contain multiple rulesets
            rules = rulesets[name];
        } else if (this._options.rulesetFn) {
            // using the rulesetFn() hook to produce custom rules
            rules = this._options.rulesetFn(bundle);
        } else {
            rules = DEFAULT_RULESETS[name];
        }
        if (rules) {
            rules._name = name;
            this._cacheRules[cacheKey] = rules;
        }
        return rules;
    }
function (bundle) {
        var name = (bundle.options && bundle.options.ruleset) || DEFAULT_RULESET,
            cacheKey = name + '@' + bundle.baseDirectory,
            rulesetsPath,
            rulesets,
            dir,
            rules;

        rules = this._cacheRules[cacheKey];
        if (rules) {
            return rules;
        }
        if (bundle.options && bundle.options.rulesets) {
            try {
                rulesetsPath = libpath.resolve(bundle.baseDirectory, bundle.options.rulesets);
                rulesets = require(rulesetsPath);
            } catch (errLocal) {
                if ('MODULE_NOT_FOUND' !== errLocal.code) {
                    throw errLocal;
                }
            }
            if (!rulesets) {
                dir = bundle.baseDirectory;
                while (dir) {
                    try {
                        rulesetsPath = libpath.resolve(dir, bundle.options.rulesets);
                        rulesets = require(rulesetsPath);
                        break;
                    } catch (errDir) {
                        if ('MODULE_NOT_FOUND' !== errDir.code) {
                            throw errDir;
                        }
                    }
                    try {
                        rulesetsPath = libpath.resolve(dir, 'node_modules', bundle.options.rulesets);
                        rulesets = require(rulesetsPath);
                        break;
                    } catch (errDep) {
                        if ('MODULE_NOT_FOUND' !== errDep.code) {
                            throw errDep;
                        }
                    }

                    // not found, iterate
                    dir = libpath.dirname(dir);
                    if ('node_modules' === libpath.basename(dir)) {
                        dir = libpath.dirname(dir);
                    }
                    if (this._rootDirectory && dir.length < this._rootDirectory.length) {
                        // if we can find the ruleset anywhere near in the filesystem
                        // we should try to rely on npm lookup process
                        try {
                            rulesetsPath = Module._resolveFilename(bundle.options.rulesets,
                                    Module._cache[__filename]);
                            rulesets = require(rulesetsPath);
                        } catch (errLocalMod) {
                            return;
                        }
                    }
                }
            }
            // a ruleset pkg can contain multiple rulesets
            rules = rulesets[name];
        } else if (this._options.rulesetFn) {
            // using the rulesetFn() hook to produce custom rules
            rules = this._options.rulesetFn(bundle);
        } else {
            rules = DEFAULT_RULESETS[name];
        }
        if (rules) {
            rules._name = name;
            this._cacheRules[cacheKey] = rules;
        }
        return rules;
    }
Loads the rulesets for the bundle (or seed).
@private
@method _loadRuleset
@param {Bundle|object} bundle The bundle (or bundle seed, see _makeBundleSeed())
to load the ruleset for.
@return {object} The ruleset, or undefined if we couldn't load it.