Skip to content

Commit

Permalink
feat(cli): add the --stdin-filepath option
Browse files Browse the repository at this point in the history
This option is really usefull when using prettier-eslint-cli inside text
editor plugins, to let prettier-eslint discover the correct eslintrc
configuration for the given file.

Related:
* prettier#95
* sbdchd/neoformat#112
* prettier/prettier-emacs#10 (comment)
  • Loading branch information
BenoitZugmeyer committed Sep 27, 2017
1 parent d28c5ef commit a1a21f1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/format-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function formatFilesFromArgv({
logLevel = logger.getLevel(),
listDifferent,
stdin,
stdinFilepath,
write,
eslintPath,
prettierPath,
Expand Down Expand Up @@ -63,7 +64,7 @@ function formatFilesFromArgv({

const cliOptions = {write, listDifferent}
if (stdin) {
return formatStdin(prettierESLintOptions)
return formatStdin({filePath: stdinFilepath, ...prettierESLintOptions})
} else {
return formatFilesFromGlobs(
fileGlobs,
Expand Down
4 changes: 4 additions & 0 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ const parser = yargs
describe: 'Read input via stdin',
type: 'boolean',
},
'stdin-filepath': {
describe: 'Path to the file to pretend that stdin comes from.',
coerce: coercePath,
},
'eslint-ignore': {
default: true,
type: 'boolean',
Expand Down

0 comments on commit a1a21f1

Please sign in to comment.