Skip to content

Commit

Permalink
feat: support matching dot files
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin committed Aug 25, 2022
1 parent 5c6b7dd commit d6421d3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/format-files.js
Expand Up @@ -54,6 +54,7 @@ function formatFilesFromArgv({
prettierIgnore: applyPrettierIgnore = true,
eslintConfigPath,
prettierLast,
includeDotFiles,
...prettierOptions
}) {
logger.setLevel(logLevel);
Expand All @@ -71,7 +72,7 @@ function formatFilesFromArgv({
};
}

const cliOptions = { write, listDifferent };
const cliOptions = { write, listDifferent, includeDotFiles };
if (stdin) {
return formatStdin({ filePath: stdinFilepath, ...prettierESLintOptions });
} else {
Expand Down Expand Up @@ -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
),
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/parser.js
Expand Up @@ -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',
Expand Down

0 comments on commit d6421d3

Please sign in to comment.