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

Deterministic Output #7794

Closed
thechriswalker opened this issue Mar 19, 2020 · 1 comment
Closed

Deterministic Output #7794

thechriswalker opened this issue Mar 19, 2020 · 1 comment
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.

Comments

@thechriswalker
Copy link

I haven't found a way of doing this, nor an issue regarding it - so I may be in the minority here. I love the idea of prettier, and have always loved go fmt for the same reasons - but the Golang tool takes it a step further and I am looking for a tool to emulate this in the JS ecosystem.

The idea is that for a given source AST, irrespective of source formatting, we get a given output. Currently prettier allows the source formatting to inform the output formatting.

I kinda want this to completely eliminate any author style on the resultant code, but have prettier enforce all style decisions.

The simplest example I can think of is the following, where the 2 declarations could each fit on a single line, but prettier does not force the first one to be a one-liner.

Prettier 1.19.1
Playground link

--parser babel

Input:

const obj1 = {
  a: 1
}

const obj2 = { a: 1};

Output:

const obj1 = {
  a: 1
};

const obj2 = { a: 1 };

Example deterministic behavior:

const obj1 = { a: 1 };
const obj2 = { a: 1 };
@alexander-akait
Copy link
Member

It is expected, because we repsect user input in some cases, you need the --pure option. Duplicate of #2068

@github-actions github-actions bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Jun 26, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.
Projects
None yet
Development

No branches or pull requests

2 participants