lib/util/glob-utils.js
function listFilesToProcess(globPatterns, providedOptions) {
    const options = providedOptions || { ignore: true };
    const cwd = options.cwd || process.cwd();

    const getIgnorePaths = lodash.memoize(
        optionsObj =>
            new IgnoredPaths(optionsObj)
    );

    /*
     * The test "should use default options if none are provided" (source-code-utils.js) checks that 'module.exports.resolveFileGlobPatterns' was called.
     * So it cannot use the local function "resolveFileGlobPatterns".
     */
    const resolvedGlobPatterns = module.exports.resolveFileGlobPatterns(globPatterns, options);

    debug("Creating list of files to process.");
    const resolvedPathsByGlobPattern = resolvedGlobPatterns.map(pattern => {
        if (pattern === "") {
            return [{
                filename: "",
                behavior: SILENTLY_IGNORE
            }];
        }

        const file = path.resolve(cwd, pattern);

        if (options.globInputPaths === false || (fs.existsSync(file) && fs.statSync(file).isFile())) {
            const ignoredPaths = getIgnorePaths(options);
            const fullPath = options.globInputPaths === false ? file : fs.realpathSync(file);

            return [{
                filename: fullPath,
                behavior: testFileAgainstIgnorePatterns(fullPath, options, true, ignoredPaths)
            }];
        }

        // regex to find .hidden or /.hidden patterns, but not ./relative or ../relative
        const globIncludesDotfiles = dotfilesPattern.test(pattern);
        let newOptions = options;

        if (!options.dotfiles) {
            newOptions = Object.assign({}, options, { dotfiles: globIncludesDotfiles });
        }

        const ignoredPaths = getIgnorePaths(newOptions);
        const shouldIgnore = ignoredPaths.getIgnoredFoldersGlobChecker();
        const globOptions = {
            nodir: true,
            dot: true,
            cwd
        };

        return new GlobSync(pattern, globOptions, shouldIgnore).found.map(globMatch => {
            const relativePath = path.resolve(cwd, globMatch);

            return {
                filename: relativePath,
                behavior: testFileAgainstIgnorePatterns(relativePath, options, false, ignoredPaths)
            };
        });
    });

    const allPathDescriptors = resolvedPathsByGlobPattern.reduce((pathsForAllGlobs, pathsForCurrentGlob, index) => {
        if (pathsForCurrentGlob.every(pathDescriptor => pathDescriptor.behavior === SILENTLY_IGNORE && pathDescriptor.filename !== "")) {
            throw new (pathsForCurrentGlob.length ? AllFilesIgnoredError : NoFilesFoundError)(globPatterns[index]);
        }

        pathsForCurrentGlob.forEach(pathDescriptor => {
            switch (pathDescriptor.behavior) {
                case NORMAL_LINT:
                    pathsForAllGlobs.push({ filename: pathDescriptor.filename, ignored: false });
                    break;
                case IGNORE_AND_WARN:
                    pathsForAllGlobs.push({ filename: pathDescriptor.filename, ignored: true });
                    break;
                case SILENTLY_IGNORE:

                    // do nothing
                    break;

                default:
                    throw new Error(`Unexpected file behavior for ${pathDescriptor.filename}`);
            }
        });

        return pathsForAllGlobs;
    }, []);

    return lodash.uniqBy(allPathDescriptors, pathDescriptor => pathDescriptor.filename);
}
function listFilesToProcess(globPatterns, providedOptions) {
    const options = providedOptions || { ignore: true };
    const cwd = options.cwd || process.cwd();

    const getIgnorePaths = lodash.memoize(
        optionsObj =>
            new IgnoredPaths(optionsObj)
    );

    /*
     * The test "should use default options if none are provided" (source-code-utils.js) checks that 'module.exports.resolveFileGlobPatterns' was called.
     * So it cannot use the local function "resolveFileGlobPatterns".
     */
    const resolvedGlobPatterns = module.exports.resolveFileGlobPatterns(globPatterns, options);

    debug("Creating list of files to process.");
    const resolvedPathsByGlobPattern = resolvedGlobPatterns.map(pattern => {
        if (pattern === "") {
            return [{
                filename: "",
                behavior: SILENTLY_IGNORE
            }];
        }

        const file = path.resolve(cwd, pattern);

        if (options.globInputPaths === false || (fs.existsSync(file) && fs.statSync(file).isFile())) {
            const ignoredPaths = getIgnorePaths(options);
            const fullPath = options.globInputPaths === false ? file : fs.realpathSync(file);

            return [{
                filename: fullPath,
                behavior: testFileAgainstIgnorePatterns(fullPath, options, true, ignoredPaths)
            }];
        }

        // regex to find .hidden or /.hidden patterns, but not ./relative or ../relative
        const globIncludesDotfiles = dotfilesPattern.test(pattern);
        let newOptions = options;

        if (!options.dotfiles) {
            newOptions = Object.assign({}, options, { dotfiles: globIncludesDotfiles });
        }

        const ignoredPaths = getIgnorePaths(newOptions);
        const shouldIgnore = ignoredPaths.getIgnoredFoldersGlobChecker();
        const globOptions = {
            nodir: true,
            dot: true,
            cwd
        };

        return new GlobSync(pattern, globOptions, shouldIgnore).found.map(globMatch => {
            const relativePath = path.resolve(cwd, globMatch);

            return {
                filename: relativePath,
                behavior: testFileAgainstIgnorePatterns(relativePath, options, false, ignoredPaths)
            };
        });
    });

    const allPathDescriptors = resolvedPathsByGlobPattern.reduce((pathsForAllGlobs, pathsForCurrentGlob, index) => {
        if (pathsForCurrentGlob.every(pathDescriptor => pathDescriptor.behavior === SILENTLY_IGNORE && pathDescriptor.filename !== "")) {
            throw new (pathsForCurrentGlob.length ? AllFilesIgnoredError : NoFilesFoundError)(globPatterns[index]);
        }

        pathsForCurrentGlob.forEach(pathDescriptor => {
            switch (pathDescriptor.behavior) {
                case NORMAL_LINT:
                    pathsForAllGlobs.push({ filename: pathDescriptor.filename, ignored: false });
                    break;
                case IGNORE_AND_WARN:
                    pathsForAllGlobs.push({ filename: pathDescriptor.filename, ignored: true });
                    break;
                case SILENTLY_IGNORE:

                    // do nothing
                    break;

                default:
                    throw new Error(`Unexpected file behavior for ${pathDescriptor.filename}`);
            }
        });

        return pathsForAllGlobs;
    }, []);

    return lodash.uniqBy(allPathDescriptors, pathDescriptor => pathDescriptor.filename);
}
function listFilesToProcess ( globPatterns , providedOptions ) { const options = providedOptions || { ignore : true } ; const cwd = options . cwd || process . cwd ( ) ; const getIgnorePaths = lodash . memoize ( optionsObj => new IgnoredPaths ( optionsObj ) ) ; /*
     * The test "should use default options if none are provided" (source-code-utils.js) checks that 'module.exports.resolveFileGlobPatterns' was called.
     * So it cannot use the local function "resolveFileGlobPatterns".
     */ const resolvedGlobPatterns = module . exports . resolveFileGlobPatterns ( globPatterns , options ) ; debug ( "Creating list of files to process." ) ; const resolvedPathsByGlobPattern = resolvedGlobPatterns . map ( pattern => { if ( pattern === "" ) { return [ { filename : "" , behavior : SILENTLY_IGNORE } ] ; } const file = path . resolve ( cwd , pattern ) ; if ( options . globInputPaths === false || ( fs . existsSync ( file ) && fs . statSync ( file ) . isFile ( ) ) ) { const ignoredPaths = getIgnorePaths ( options ) ; const fullPath = options . globInputPaths === false ? file : fs . realpathSync ( file ) ; return [ { filename : fullPath , behavior : testFileAgainstIgnorePatterns ( fullPath , options , true , ignoredPaths ) } ] ; } // regex to find .hidden or /.hidden patterns, but not ./relative or ../relative const globIncludesDotfiles = dotfilesPattern . test ( pattern ) ; let newOptions = options ; if ( ! options . dotfiles ) { newOptions = Object . assign ( { } , options , { dotfiles : globIncludesDotfiles } ) ; } const ignoredPaths = getIgnorePaths ( newOptions ) ; const shouldIgnore = ignoredPaths . getIgnoredFoldersGlobChecker ( ) ; const globOptions = { nodir : true , dot : true , cwd } ; return new GlobSync ( pattern , globOptions , shouldIgnore ) . found . map ( globMatch => { const relativePath = path . resolve ( cwd , globMatch ) ; return { filename : relativePath , behavior : testFileAgainstIgnorePatterns ( relativePath , options , false , ignoredPaths ) } ; } ) ; } ) ; const allPathDescriptors = resolvedPathsByGlobPattern . reduce ( ( pathsForAllGlobs , pathsForCurrentGlob , index ) => { if ( pathsForCurrentGlob . every ( pathDescriptor => pathDescriptor . behavior === SILENTLY_IGNORE && pathDescriptor . filename !== "" ) ) { throw new ( pathsForCurrentGlob . length ? AllFilesIgnoredError : NoFilesFoundError ) ( globPatterns [ index ] ) ; } pathsForCurrentGlob . forEach ( pathDescriptor => { switch ( pathDescriptor . behavior ) { case NORMAL_LINT : pathsForAllGlobs . push ( { filename : pathDescriptor . filename , ignored : false } ) ; break ; case IGNORE_AND_WARN : pathsForAllGlobs . push ( { filename : pathDescriptor . filename , ignored : true } ) ; break ; case SILENTLY_IGNORE : // do nothing break ; default : throw new Error ( ` ${ pathDescriptor . filename } ` ) ; } } ) ; return pathsForAllGlobs ; } , [ ] ) ; return lodash . uniqBy ( allPathDescriptors , pathDescriptor => pathDescriptor . filename ) ; }
Build a list of absolute filesnames on which ESLint will act.
Ignored files are excluded from the results, as are duplicates.

@param   {string[]} globPatterns                     Glob patterns.
@param   {Object}   [providedOptions]                An options object.
@param   {string}   [providedOptions.cwd]            CWD (considered for relative filenames)
@param   {boolean}  [providedOptions.ignore]         False disables use of .eslintignore.
@param   {string}   [providedOptions.ignorePath]     The ignore file to use instead of .eslintignore.
@param   {string}   [providedOptions.ignorePattern]  A pattern of files to ignore.
@param   {string}   [providedOptions.globInputPaths] False disables glob resolution.
@returns {string[]} Resolved absolute filenames.
Build a list of absolute filesnames on which ESLint will act . Ignored files are excluded from the results as are duplicates .