Skip to content

Commit

Permalink
feat: support matching dot files (#132)
Browse files Browse the repository at this point in the history
Co-authored-by: JounQin <admin@1stg.me>
  • Loading branch information
u3u and JounQin committed Aug 25, 2022
1 parent 625a7fe commit 4561a79
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 9 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,15 @@
"code",
"maintenance"
]
},
{
"login": "u3u",
"name": "さくら",
"avatar_url": "https://avatars2.githubusercontent.com/u/20062482?v=4",
"profile": "https://qwq.cat",
"contributions": [
"code"
]
}
],
"repoType": "github",
Expand Down
5 changes: 5 additions & 0 deletions .changeset/blue-parents-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"prettier-eslint-cli": minor
---

feat: support matching dot files
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ Options:
--list-different Print filenames of files that are different from
Prettier + Eslint formatting.
[boolean] [default: false]
--include-dot-files Include files that start with a dot in the search.
[boolean] [default: false]
--eslint-path The path to the eslint module to use
[default: "./node_modules/eslint"]
--eslint-config-path Path to the eslint config to use for eslint --fix
Expand Down Expand Up @@ -283,6 +285,7 @@ Thanks goes to these people ([emoji key][emojis]):
<td align="center"><a href="https://campcode.dev/"><img src="https://avatars.githubusercontent.com/u/10620169?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Rebecca Vest</b></sub></a><br /><a href="https://github.com/prettier/prettier-eslint-cli/commits?author=idahogurl" title="Code">💻</a></td>
<td align="center"><a href="https://www.1stg.me/"><img src="https://avatars.githubusercontent.com/u/8336744?v=4?s=100" width="100px;" alt=""/><br /><sub><b>JounQin</b></sub></a><br /><a href="#question-JounQin" title="Answering Questions">💬</a> <a href="https://github.com/prettier/prettier-eslint-cli/commits?author=JounQin" title="Code">💻</a> <a href="#design-JounQin" title="Design">🎨</a> <a href="https://github.com/prettier/prettier-eslint-cli/commits?author=JounQin" title="Documentation">📖</a> <a href="#ideas-JounQin" title="Ideas, Planning, & Feedback">🤔</a> <a href="#infra-JounQin" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#maintenance-JounQin" title="Maintenance">🚧</a> <a href="#plugin-JounQin" title="Plugin/utility libraries">🔌</a> <a href="#projectManagement-JounQin" title="Project Management">📆</a> <a href="https://github.com/prettier/prettier-eslint-cli/pulls?q=is%3Apr+reviewed-by%3AJounQin" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/prettier/prettier-eslint-cli/commits?author=JounQin" title="Tests">⚠️</a> <a href="#tool-JounQin" title="Tools">🔧</a></td>
<td align="center"><a href="https://github.com/dorser"><img src="https://avatars2.githubusercontent.com/u/20969462?v=4?s=100" width="100px;" alt=""/><br /><sub><b>dorser</b></sub></a><br /><a href="https://github.com/prettier/prettier-eslint-cli/commits?author=dorser" title="Code">💻</a> <a href="#maintenance-dorser" title="Maintenance">🚧</a></td>
<td align="center"><a href="https://qwq.cat"><img src="https://avatars2.githubusercontent.com/u/20062482?v=4?s=100" width="100px;" alt=""/><br /><sub><b>さくら</b></sub></a><br /><a href="https://github.com/prettier/prettier-eslint-cli/commits?author=u3u" title="Code">💻</a></td>
</tr>
</table>

Expand Down
22 changes: 13 additions & 9 deletions src/format-files.js
Original file line number Diff line number Diff line change
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 = { 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
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ const parser = yargs
from Prettier + Eslint formatting.
`
},
'include-dot-files': {
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 4561a79

Please sign in to comment.