Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document passings args to formatters #4688

Merged
merged 2 commits into from
Apr 9, 2020
Merged

Document passings args to formatters #4688

merged 2 commits into from
Apr 9, 2020

Conversation

jeddy3
Copy link
Member

@jeddy3 jeddy3 commented Apr 4, 2020

Which issue, if any, is this issue related to?

Closes #4668

Is there anything in the PR that needs further explanation?

Keeps it simple. We can always expand on it later if there's a need.

@jeddy3 jeddy3 mentioned this pull request Apr 7, 2020
10 tasks
To pass arguments, you can:

- use environmental variables
- pipe the output from the JSON formatter into another program
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear for me how piping output is passing arguments to formatter. Piping happens after formatter was ran.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. It's not clear that the second approach is a separate formatting program rather than a stylelint formatter. I've updated the docs to hopefully illustrate that.


Example formatting program:

// my-program-that-reads-JSON.js
const getStdin = require("get-stdin");
(async () => {
  const jsonString = await getStdin();
  const object = JSON.parse(jsonString);
  let colors = false;
  if (process.argv[2] && process.argv[2] === "-c") colors = true;
  console.dir(object, { depth: null, colors });
})();
stylelint -f json "*.css" | my-program-that-reads-JSON --c

This just (optionally) colourises and indents the JSON, but a formatting program could do anything with the data.

@jeddy3 jeddy3 merged commit 011548b into master Apr 9, 2020
@jeddy3 jeddy3 deleted the doc-formatter-args branch April 9, 2020 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Document passing arguments to custom formatters
2 participants