From d6421d3f10a7482ec0b6a57c83c47211f1348227 Mon Sep 17 00:00:00 2001 From: JounQin Date: Thu, 25 Aug 2022 20:37:35 +0800 Subject: [PATCH] feat: support matching dot files --- src/format-files.js | 22 +++++++++++++--------- src/parser.js | 7 +++++++ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/format-files.js b/src/format-files.js index d2c9ff2..4f79e3b 100644 --- a/src/format-files.js +++ b/src/format-files.js @@ -54,6 +54,7 @@ function formatFilesFromArgv({ prettierIgnore: applyPrettierIgnore = true, eslintConfigPath, prettierLast, + includeDotFiles, ...prettierOptions }) { logger.setLevel(logLevel); @@ -71,7 +72,7 @@ function formatFilesFromArgv({ }; } - const cliOptions = { write, listDifferent }; + const cliOptions = { write, listDifferent, includeDotFiles }; if (stdin) { return formatStdin({ filePath: stdinFilepath, ...prettierESLintOptions }); } else { @@ -122,12 +123,14 @@ function formatFilesFromGlobs({ from(fileGlobs) .pipe( mergeMap( - getFilesFromGlob.bind( - null, - ignoreGlobs, - applyEslintIgnore, - applyPrettierIgnore - ), + fileGlob => + getFilesFromGlob( + ignoreGlobs, + applyEslintIgnore, + applyPrettierIgnore, + fileGlob, + cliOptions + ), null, concurrentGlobs ), @@ -207,9 +210,10 @@ function getFilesFromGlob( ignoreGlobs, applyEslintIgnore, applyPrettierIgnore, - fileGlob + fileGlob, + cliOptions ) { - const globOptions = { dot: true, ignore: ignoreGlobs }; + const globOptions = { dot: cliOptions.includeDotFiles, ignore: ignoreGlobs }; if (!fileGlob.includes('node_modules')) { // basically, we're going to protect you from doing something // not smart unless you explicitly include it in your glob diff --git a/src/parser.js b/src/parser.js index 07212f9..c69b6d7 100644 --- a/src/parser.js +++ b/src/parser.js @@ -56,6 +56,13 @@ const parser = yargs from Prettier + Eslint formatting. ` }, + includeDotFiles: { + default: false, + type: 'boolean', + describe: oneLine` + Include files that start with a dot in the search. + ` + }, // allow `--eslint-path` and `--eslintPath` 'eslint-path': { describe: 'The path to the eslint module to use',