* Prevent wrapping object properties with short keys * Update src/language-js/print/assignment.js Co-authored-by: Sosuke Suzuki <aosukeke@gmail.com> * Use getStringWidth instead of .length Co-authored-by: Sosuke Suzuki <aosukeke@gmail.com>
174 lines
7.4 KiB
Plaintext
174 lines
7.4 KiB
Plaintext
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
exports[`comment.js format 1`] = `
|
|
====================================options=====================================
|
|
parsers: ["babel", "flow", "typescript"]
|
|
printWidth: 80
|
|
| printWidth
|
|
=====================================input======================================
|
|
function foo() {
|
|
return {
|
|
// this comment causes the problem
|
|
bar: baz() + 1
|
|
};
|
|
}
|
|
|
|
=====================================output=====================================
|
|
function foo() {
|
|
return {
|
|
// this comment causes the problem
|
|
bar: baz() + 1,
|
|
};
|
|
}
|
|
|
|
================================================================================
|
|
`;
|
|
|
|
exports[`long-value.js format 1`] = `
|
|
====================================options=====================================
|
|
parsers: ["babel", "flow", "typescript"]
|
|
printWidth: 80
|
|
| printWidth
|
|
=====================================input======================================
|
|
const x = {
|
|
"ABC": "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
|
|
};
|
|
|
|
=====================================output=====================================
|
|
const x = {
|
|
ABC: "12345678901234567890123456789012345678901234567890123456789012345678901234567890",
|
|
};
|
|
|
|
================================================================================
|
|
`;
|
|
|
|
exports[`short-keys.js format 1`] = `
|
|
====================================options=====================================
|
|
parsers: ["babel", "flow", "typescript"]
|
|
printWidth: 80
|
|
| printWidth
|
|
=====================================input======================================
|
|
var obj = {
|
|
// an entry with a very long string
|
|
x: "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
|
|
url: 'http://example.com/12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890',
|
|
longName: "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
|
|
[i]: "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
|
|
[prop]: "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
|
|
'x': "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
|
|
a: "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
|
|
ab: "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
|
|
abc: "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
|
|
abcd: "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
|
|
abcde: "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
|
|
abcdef: "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
|
|
'古': 'https://prettier.io/docs/en/rationale.html#what-prettier-is-concerned-about',
|
|
'古今': 'https://prettier.io/docs/en/rationale.html#what-prettier-is-concerned-about',
|
|
'古体诗': 'https://prettier.io/docs/en/rationale.html#what-prettier-is-concerned-about',
|
|
};
|
|
|
|
=====================================output=====================================
|
|
var obj = {
|
|
// an entry with a very long string
|
|
x: "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
|
|
url: "http://example.com/12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
|
|
longName:
|
|
"12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
|
|
[i]: "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
|
|
[prop]:
|
|
"12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
|
|
x: "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
|
|
a: "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
|
|
ab: "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
|
|
abc: "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
|
|
abcd: "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
|
|
abcde:
|
|
"12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
|
|
abcdef:
|
|
"12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
|
|
古: "https://prettier.io/docs/en/rationale.html#what-prettier-is-concerned-about",
|
|
古今: "https://prettier.io/docs/en/rationale.html#what-prettier-is-concerned-about",
|
|
古体诗:
|
|
"https://prettier.io/docs/en/rationale.html#what-prettier-is-concerned-about",
|
|
};
|
|
|
|
================================================================================
|
|
`;
|
|
|
|
exports[`test.js format 1`] = `
|
|
====================================options=====================================
|
|
parsers: ["babel", "flow", "typescript"]
|
|
printWidth: 80
|
|
| printWidth
|
|
=====================================input======================================
|
|
const a = classnames({
|
|
"some-prop": this.state.longLongLongLongLongLongLongLongLongTooLongProp
|
|
});
|
|
|
|
const b = classnames({
|
|
"some-prop": this.state.longLongLongLongLongLongLongLongLongTooLongProp === true
|
|
});
|
|
|
|
const c = classnames({
|
|
"some-prop": [ "foo", "bar", "foo", "bar", "foo", "bar", "foo", "bar", "foo" ]
|
|
});
|
|
|
|
const d = classnames({
|
|
"some-prop": () => {}
|
|
});
|
|
|
|
const e = classnames({
|
|
"some-prop": function bar() {}
|
|
});
|
|
|
|
const f = classnames({
|
|
"some-prop": { foo: "bar", bar: "foo", foo: "bar", bar: "foo", foo: "bar" }
|
|
});
|
|
|
|
const g = classnames({
|
|
"some-prop": longLongLongLongLongLongLongLongLongLongLongLongLongTooLongVar || 1337
|
|
});
|
|
|
|
const h = { foo: "bar", baz: \`Lorem
|
|
ipsum\` }
|
|
|
|
=====================================output=====================================
|
|
const a = classnames({
|
|
"some-prop": this.state.longLongLongLongLongLongLongLongLongTooLongProp,
|
|
});
|
|
|
|
const b = classnames({
|
|
"some-prop":
|
|
this.state.longLongLongLongLongLongLongLongLongTooLongProp === true,
|
|
});
|
|
|
|
const c = classnames({
|
|
"some-prop": ["foo", "bar", "foo", "bar", "foo", "bar", "foo", "bar", "foo"],
|
|
});
|
|
|
|
const d = classnames({
|
|
"some-prop": () => {},
|
|
});
|
|
|
|
const e = classnames({
|
|
"some-prop": function bar() {},
|
|
});
|
|
|
|
const f = classnames({
|
|
"some-prop": { foo: "bar", bar: "foo", foo: "bar", bar: "foo", foo: "bar" },
|
|
});
|
|
|
|
const g = classnames({
|
|
"some-prop":
|
|
longLongLongLongLongLongLongLongLongLongLongLongLongTooLongVar || 1337,
|
|
});
|
|
|
|
const h = {
|
|
foo: "bar",
|
|
baz: \`Lorem
|
|
ipsum\`,
|
|
};
|
|
|
|
================================================================================
|
|
`;
|