Skip to content

Commit 4561a79

Browse files
u3uJounQin
andauthored
feat: support matching dot files (#132)
Co-authored-by: JounQin <[email protected]>
1 parent 625a7fe commit 4561a79

File tree

5 files changed

+37
-9
lines changed

5 files changed

+37
-9
lines changed

.all-contributorsrc

+9
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,15 @@
279279
"code",
280280
"maintenance"
281281
]
282+
},
283+
{
284+
"login": "u3u",
285+
"name": "さくら",
286+
"avatar_url": "https://avatars2.githubusercontent.com/u/20062482?v=4",
287+
"profile": "https://qwq.cat",
288+
"contributions": [
289+
"code"
290+
]
282291
}
283292
],
284293
"repoType": "github",

.changeset/blue-parents-fail.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"prettier-eslint-cli": minor
3+
---
4+
5+
feat: support matching dot files

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ Options:
9999
--list-different Print filenames of files that are different from
100100
Prettier + Eslint formatting.
101101
[boolean] [default: false]
102+
--include-dot-files Include files that start with a dot in the search.
103+
[boolean] [default: false]
102104
--eslint-path The path to the eslint module to use
103105
[default: "./node_modules/eslint"]
104106
--eslint-config-path Path to the eslint config to use for eslint --fix
@@ -283,6 +285,7 @@ Thanks goes to these people ([emoji key][emojis]):
283285
<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>
284286
<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>
285287
<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>
288+
<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>
286289
</tr>
287290
</table>
288291

src/format-files.js

+13-9
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ function formatFilesFromArgv({
5454
prettierIgnore: applyPrettierIgnore = true,
5555
eslintConfigPath,
5656
prettierLast,
57+
includeDotFiles,
5758
...prettierOptions
5859
}) {
5960
logger.setLevel(logLevel);
@@ -71,7 +72,7 @@ function formatFilesFromArgv({
7172
};
7273
}
7374

74-
const cliOptions = { write, listDifferent };
75+
const cliOptions = { write, listDifferent, includeDotFiles };
7576
if (stdin) {
7677
return formatStdin({ filePath: stdinFilepath, ...prettierESLintOptions });
7778
} else {
@@ -122,12 +123,14 @@ function formatFilesFromGlobs({
122123
from(fileGlobs)
123124
.pipe(
124125
mergeMap(
125-
getFilesFromGlob.bind(
126-
null,
127-
ignoreGlobs,
128-
applyEslintIgnore,
129-
applyPrettierIgnore
130-
),
126+
fileGlob =>
127+
getFilesFromGlob(
128+
ignoreGlobs,
129+
applyEslintIgnore,
130+
applyPrettierIgnore,
131+
fileGlob,
132+
cliOptions
133+
),
131134
null,
132135
concurrentGlobs
133136
),
@@ -207,9 +210,10 @@ function getFilesFromGlob(
207210
ignoreGlobs,
208211
applyEslintIgnore,
209212
applyPrettierIgnore,
210-
fileGlob
213+
fileGlob,
214+
cliOptions
211215
) {
212-
const globOptions = { ignore: ignoreGlobs };
216+
const globOptions = { dot: cliOptions.includeDotFiles, ignore: ignoreGlobs };
213217
if (!fileGlob.includes('node_modules')) {
214218
// basically, we're going to protect you from doing something
215219
// not smart unless you explicitly include it in your glob

src/parser.js

+7
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ const parser = yargs
5656
from Prettier + Eslint formatting.
5757
`
5858
},
59+
'include-dot-files': {
60+
default: false,
61+
type: 'boolean',
62+
describe: oneLine`
63+
Include files that start with a dot in the search.
64+
`
65+
},
5966
// allow `--eslint-path` and `--eslintPath`
6067
'eslint-path': {
6168
describe: 'The path to the eslint module to use',

0 commit comments

Comments
 (0)