diff --git a/.all-contributorsrc b/.all-contributorsrc
index 012e447..ed84e56 100644
--- a/.all-contributorsrc
+++ b/.all-contributorsrc
@@ -131,6 +131,15 @@
"bug",
"code"
]
+ },
+ {
+ "login": "jackfranklin",
+ "name": "Jack Franklin",
+ "avatar_url": "https://avatars0.githubusercontent.com/u/193238?v=3",
+ "profile": "http://www.jackfranklin.co.uk",
+ "contributions": [
+ "code"
+ ]
}
]
}
diff --git a/README.md b/README.md
index 1aa9c85..c3b6f67 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@ CLI for [`prettier-eslint`][prettier-eslint]
[![downloads][downloads-badge]][npm-stat]
[![MIT License][license-badge]][LICENSE]
-[![All Contributors](https://img.shields.io/badge/all_contributors-13-orange.svg?style=flat-square)](#contributors)
+[![All Contributors](https://img.shields.io/badge/all_contributors-14-orange.svg?style=flat-square)](#contributors)
[![PRs Welcome][prs-badge]][prs]
[![Donate][donate-badge]][donate]
[![Code of Conduct][coc-badge]][coc]
@@ -183,7 +183,7 @@ Thanks goes to these people ([emoji key][emojis]):
| [
Kent C. Dodds](https://kentcdodds.com)
[๐ป](https://github.com/prettier/prettier-eslint-cli/commits?author=kentcdodds "Code") [๐](https://github.com/prettier/prettier-eslint-cli/commits?author=kentcdodds "Documentation") [๐](#infra-kentcdodds "Infrastructure (Hosting, Build-Tools, etc)") [โ ๏ธ](https://github.com/prettier/prettier-eslint-cli/commits?author=kentcdodds "Tests") | [
Adam Harris](https://github.com/aharris88)
[๐ป](https://github.com/prettier/prettier-eslint-cli/commits?author=aharris88 "Code") [๐](https://github.com/prettier/prettier-eslint-cli/commits?author=aharris88 "Documentation") [๐](#review-aharris88 "Reviewed Pull Requests") | [
Eric McCormick](https://ericmccormick.io)
[๐](#review-edm00se "Reviewed Pull Requests") | [
Joel Sequeira](https://github.com/joelseq)
[๐](https://github.com/prettier/prettier-eslint-cli/commits?author=joelseq "Documentation") | [
Frank Taillandier](https://frank.taillandier.me)
| [
Adam Stankiewicz](http://sheerun.net)
[๐ป](https://github.com/prettier/prettier-eslint-cli/commits?author=sheerun "Code") | [
Stephen John Sorensen](http://www.stephenjohnsorensen.com/)
[๐ป](https://github.com/prettier/prettier-eslint-cli/commits?author=spudly "Code") |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
-| [
Gandem](https://github.com/Gandem)
[๐ป](https://github.com/prettier/prettier-eslint-cli/commits?author=Gandem "Code") [โ ๏ธ](https://github.com/prettier/prettier-eslint-cli/commits?author=Gandem "Tests") | [
Matteo Ronchi](https://github.com/cef62)
[๐](https://github.com/prettier/prettier-eslint-cli/issues?q=author%3Acef62 "Bug reports") [๐ป](https://github.com/prettier/prettier-eslint-cli/commits?author=cef62 "Code") | [
Benoรฎt Zugmeyer](https://github.com/BenoitZugmeyer)
[๐ป](https://github.com/prettier/prettier-eslint-cli/commits?author=BenoitZugmeyer "Code") [โ ๏ธ](https://github.com/prettier/prettier-eslint-cli/commits?author=BenoitZugmeyer "Tests") | [
Charlike Mike Reagent](https://i.am.charlike.online)
[๐ป](https://github.com/prettier/prettier-eslint-cli/commits?author=tunnckoCore "Code") [โ ๏ธ](https://github.com/prettier/prettier-eslint-cli/commits?author=tunnckoCore "Tests") | [
Dion Dirza](https://github.com/diondirza)
[๐](https://github.com/prettier/prettier-eslint-cli/issues?q=author%3Adiondirza "Bug reports") | [
mrm007](https://github.com/mrm007)
[๐](https://github.com/prettier/prettier-eslint-cli/issues?q=author%3Amrm007 "Bug reports") [๐ป](https://github.com/prettier/prettier-eslint-cli/commits?author=mrm007 "Code") |
+| [
Gandem](https://github.com/Gandem)
[๐ป](https://github.com/prettier/prettier-eslint-cli/commits?author=Gandem "Code") [โ ๏ธ](https://github.com/prettier/prettier-eslint-cli/commits?author=Gandem "Tests") | [
Matteo Ronchi](https://github.com/cef62)
[๐](https://github.com/prettier/prettier-eslint-cli/issues?q=author%3Acef62 "Bug reports") [๐ป](https://github.com/prettier/prettier-eslint-cli/commits?author=cef62 "Code") | [
Benoรฎt Zugmeyer](https://github.com/BenoitZugmeyer)
[๐ป](https://github.com/prettier/prettier-eslint-cli/commits?author=BenoitZugmeyer "Code") [โ ๏ธ](https://github.com/prettier/prettier-eslint-cli/commits?author=BenoitZugmeyer "Tests") | [
Charlike Mike Reagent](https://i.am.charlike.online)
[๐ป](https://github.com/prettier/prettier-eslint-cli/commits?author=tunnckoCore "Code") [โ ๏ธ](https://github.com/prettier/prettier-eslint-cli/commits?author=tunnckoCore "Tests") | [
Dion Dirza](https://github.com/diondirza)
[๐](https://github.com/prettier/prettier-eslint-cli/issues?q=author%3Adiondirza "Bug reports") | [
mrm007](https://github.com/mrm007)
[๐](https://github.com/prettier/prettier-eslint-cli/issues?q=author%3Amrm007 "Bug reports") [๐ป](https://github.com/prettier/prettier-eslint-cli/commits?author=mrm007 "Code") | [
Jack Franklin](http://www.jackfranklin.co.uk)
[๐ป](https://github.com/prettier/prettier-eslint-cli/commits?author=jackfranklin "Code") |
This project follows the [all-contributors][all-contributors] specification. Contributions of any kind welcome!
diff --git a/src/format-files.js b/src/format-files.js
index 5b9805e..2412913 100644
--- a/src/format-files.js
+++ b/src/format-files.js
@@ -126,7 +126,13 @@ function formatFilesFromGlobs(
}
function onComplete() {
- if (successes.length) {
+ const isNotSilent = logger.getLevel() !== logger.levels.SILENT
+
+ /* use console.error directly here because
+ * - we don't want these messages prefixed
+ * - we want them to go to stderr, not stdout
+ */
+ if (successes.length && isNotSilent) {
console.error(
messages.success({
success: chalk.green('success'),
@@ -135,7 +141,7 @@ function formatFilesFromGlobs(
}),
)
}
- if (failures.length) {
+ if (failures.length && isNotSilent) {
process.exitCode = 1
console.error(
messages.failure({
@@ -145,7 +151,7 @@ function formatFilesFromGlobs(
}),
)
}
- if (unchanged.length) {
+ if (unchanged.length && isNotSilent) {
console.error(
messages.unchanged({
unchanged: chalk.gray('unchanged'),
diff --git a/src/format-files.test.js b/src/format-files.test.js
index edb1dc6..895960c 100644
--- a/src/format-files.test.js
+++ b/src/format-files.test.js
@@ -4,6 +4,7 @@ import findUpMock from 'find-up'
import formatMock from 'prettier-eslint'
import globMock from 'glob'
import mockGetStdin from 'get-stdin'
+import getLogger from 'loglevel-colored-level-prefix'
import formatFiles from './format-files'
jest.mock('fs')
@@ -123,6 +124,18 @@ test('logs errors to the console if something goes wrong', async () => {
)
})
+test('does not log anything to the console if logLevel is silent', async () => {
+ const log = getLogger()
+ const globs = ['eslint-config-error/*.js', 'src/**/2*.js']
+ await formatFiles({
+ _: globs,
+ write: true,
+ logLevel: log.levels.SILENT,
+ })
+ expect(fsMock.writeFile).toHaveBeenCalledTimes(4)
+ expect(console.error).not.toHaveBeenCalled()
+})
+
test('forwards logLevel onto prettier-eslint', async () => {
await formatFiles({_: ['src/**/1*.js'], logLevel: 'debug'})
const options = expect.objectContaining({logLevel: 'debug'})