Skip to content

Commit

Permalink
[prettierx] cover standard ternary inconsistency (#42)
Browse files Browse the repository at this point in the history
in tests/standard & docs

as reported in #40

(this should have been part of the proposal in prettier/prettier#5723)

Note that this inconsistency is resolved by #41
which is to be included in an upcoming merge.

Co-authored-by: Christopher J. Brody <chris.brody@gmail.com>
Co-authored-by: Mohit Singh <mohit@mohitsingh.in>
Co-authored-by: Adam Stankiewicz <sheerun@sher.pl>
  • Loading branch information
3 people committed Jan 22, 2019
1 parent ae7889f commit 5c53b1d
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -38,6 +38,8 @@ The following options should be used to _format_ the code according to [standard
- `--no-semi` (`semi: false`)
- `--yield-star-spacing` (`yieldStarSpacing: true`)

Known conflict with `standard` in ternary returning objects ([brodybits/prettierx#40](https://github.com/brodybits/prettierx/issues/40))

Note that this tool does _not_ follow any of the other [standard js](https://standardjs.com/) rules. It is recommended to use this tool together with eslint, in some form, to achive correct formatting according to [standard js](https://standardjs.com/).

<!-- - FUTURE TBD prettierx vs prettier (???):
Expand Down
56 changes: 56 additions & 0 deletions tests/standard/__snapshots__/jsfmt.spec.js.snap
Expand Up @@ -1069,6 +1069,33 @@ function*generator() {
// "jsx-quotes": ["error", "prefer-single"],
;() => <div foo="bar" />
// "indent": [
// "error",
// 2,
// {
// "SwitchCase": 1,
// "VariableDeclarator": 1,
// "outerIIFEBody": 1,
// "MemberExpression": 1,
// "FunctionDeclaration": { "parameters": 1, "body": 1 },
// "FunctionExpression": { "parameters": 1, "body": 1 },
// "CallExpression": { "arguments": 1 },
// "ArrayExpression": 1,
// "ObjectExpression": 1,
// "ImportDeclaration": 1,
// "flatTernaryExpressions": false,
// "ignoreComments": false
// }
// ],
let isSpace = false
const dress = isSpace ? {
spaceSuit: 3,
oxygenCylinders: 6
} : {
shirts: 3,
paints: 3
}
=====================================output=====================================
// "arrow-spacing": ["error", { "before": true, "after": true }]
Expand Down Expand Up @@ -1421,5 +1448,34 @@ function * generator () {
// "jsx-quotes": ["error", "prefer-single"],
;() => <div foo='bar' />
// "indent": [
// "error",
// 2,
// {
// "SwitchCase": 1,
// "VariableDeclarator": 1,
// "outerIIFEBody": 1,
// "MemberExpression": 1,
// "FunctionDeclaration": { "parameters": 1, "body": 1 },
// "FunctionExpression": { "parameters": 1, "body": 1 },
// "CallExpression": { "arguments": 1 },
// "ArrayExpression": 1,
// "ObjectExpression": 1,
// "ImportDeclaration": 1,
// "flatTernaryExpressions": false,
// "ignoreComments": false
// }
// ],
let isSpace = false
const dress = isSpace
? {
spaceSuit: 3,
oxygenCylinders: 6
}
: {
shirts: 3,
paints: 3
}
================================================================================
`;
27 changes: 27 additions & 0 deletions tests/standard/incorrect.js
Expand Up @@ -352,3 +352,30 @@ function*generator() {

// "jsx-quotes": ["error", "prefer-single"],
;() => <div foo="bar" />

// "indent": [
// "error",
// 2,
// {
// "SwitchCase": 1,
// "VariableDeclarator": 1,
// "outerIIFEBody": 1,
// "MemberExpression": 1,
// "FunctionDeclaration": { "parameters": 1, "body": 1 },
// "FunctionExpression": { "parameters": 1, "body": 1 },
// "CallExpression": { "arguments": 1 },
// "ArrayExpression": 1,
// "ObjectExpression": 1,
// "ImportDeclaration": 1,
// "flatTernaryExpressions": false,
// "ignoreComments": false
// }
// ],
let isSpace = false
const dress = isSpace ? {
spaceSuit: 3,
oxygenCylinders: 6
} : {
shirts: 3,
paints: 3
}

0 comments on commit 5c53b1d

Please sign in to comment.