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

Replace Prettier's jsxBracketSameLine option with bracketSameLine #609

Merged
merged 1 commit into from Oct 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/options-manager.js
Expand Up @@ -424,7 +424,7 @@ const mergeWithPrettierConfig = (options, prettierOptions) => {
{
singleQuote: true,
bracketSpacing: false,
jsxBracketSameLine: false,
bracketSameLine: false,
trailingComma: 'all',
tabWidth: normalizeSpaces(options),
useTabs: !options.space,
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Expand Up @@ -228,7 +228,7 @@ The [Prettier options](https://prettier.io/docs/en/options.html) will be read fr
- [trailingComma](https://prettier.io/docs/en/options.html#trailing-commas): `all`
- [singleQuote](https://prettier.io/docs/en/options.html#quotes): `true`
- [bracketSpacing](https://prettier.io/docs/en/options.html#bracket-spacing): `false`
- [jsxBracketSameLine](https://prettier.io/docs/en/options.html#jsx-brackets): `false`
- [bracketSameLine](https://prettier.io/docs/en/options.html#bracket-line): `false`

If contradicting options are set for both Prettier and XO an error will be thrown.

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/prettier/package.json
Expand Up @@ -4,7 +4,7 @@
"semi": false,
"tabWidth": 4,
"bracketSpacing": false,
"jsxBracketSameLine": false,
"bracketSameLine": false,
"singleQuote": false,
"trailingComma": "all"
}
Expand Down
22 changes: 11 additions & 11 deletions test/options-manager.js
Expand Up @@ -89,11 +89,11 @@ test('buildConfig: prettier: true', t => {

t.deepEqual(config.baseConfig.plugins, ['prettier']);
// Sets the `semi`, `useTabs` and `tabWidth` options in `prettier/prettier` based on the XO `space` and `semicolon` options
// Sets `singleQuote`, `trailingComma`, `bracketSpacing` and `jsxBracketSameLine` with XO defaults
// Sets `singleQuote`, `trailingComma`, `bracketSpacing` and `bracketSameLine` with XO defaults
t.deepEqual(config.baseConfig.rules['prettier/prettier'], ['error', {
useTabs: true,
bracketSpacing: false,
jsxBracketSameLine: false,
bracketSameLine: false,
semi: true,
singleQuote: true,
tabWidth: 2,
Expand All @@ -114,11 +114,11 @@ test('buildConfig: prettier: true, typescript file', t => {

t.deepEqual(config.baseConfig.plugins, ['prettier']);
// Sets the `semi`, `useTabs` and `tabWidth` options in `prettier/prettier` based on the XO `space` and `semicolon` options
// Sets `singleQuote`, `trailingComma`, `bracketSpacing` and `jsxBracketSameLine` with XO defaults
// Sets `singleQuote`, `trailingComma`, `bracketSpacing` and `bracketSameLine` with XO defaults
t.deepEqual(config.baseConfig.rules['prettier/prettier'], ['error', {
useTabs: true,
bracketSpacing: false,
jsxBracketSameLine: false,
bracketSameLine: false,
semi: true,
singleQuote: true,
tabWidth: 2,
Expand All @@ -144,7 +144,7 @@ test('buildConfig: prettier: true, semicolon: false', t => {
t.deepEqual(config.baseConfig.rules['prettier/prettier'], ['error', {
useTabs: true,
bracketSpacing: false,
jsxBracketSameLine: false,
bracketSameLine: false,
semi: false,
singleQuote: true,
tabWidth: 2,
Expand All @@ -165,7 +165,7 @@ test('buildConfig: prettier: true, space: 4', t => {
t.deepEqual(config.baseConfig.rules['prettier/prettier'], ['error', {
useTabs: false,
bracketSpacing: false,
jsxBracketSameLine: false,
bracketSameLine: false,
semi: true,
singleQuote: true,
tabWidth: 4,
Expand All @@ -186,7 +186,7 @@ test('buildConfig: prettier: true, space: true', t => {
t.deepEqual(config.baseConfig.rules['prettier/prettier'], ['error', {
useTabs: false,
bracketSpacing: false,
jsxBracketSameLine: false,
bracketSameLine: false,
semi: true,
singleQuote: true,
tabWidth: 2,
Expand Down Expand Up @@ -271,12 +271,12 @@ test('buildConfig: nodeVersion: >=8', t => {
t.deepEqual(config.baseConfig.rules['node/no-unsupported-features/node-builtins'], ['error', {version: '>=8'}]);
});

test('mergeWithPrettierConfig: use `singleQuote`, `trailingComma`, `bracketSpacing` and `jsxBracketSameLine` from `prettier` config if defined', t => {
test('mergeWithPrettierConfig: use `singleQuote`, `trailingComma`, `bracketSpacing` and `bracketSameLine` from `prettier` config if defined', t => {
const prettierOptions = {
singleQuote: false,
trailingComma: 'none',
bracketSpacing: false,
jsxBracketSameLine: false,
bracketSameLine: false,
};
const result = manager.mergeWithPrettierConfig({}, prettierOptions);
const expected = {
Expand All @@ -298,7 +298,7 @@ test('mergeWithPrettierConfig: determine `tabWidth`, `useTabs`, `semi` from xo c
const result = manager.mergeWithPrettierConfig({space: 4, semicolon: false}, {});
const expected = {
bracketSpacing: false,
jsxBracketSameLine: false,
bracketSameLine: false,
singleQuote: true,
trailingComma: 'all',
...prettierOptions,
Expand All @@ -315,7 +315,7 @@ test('mergeWithPrettierConfig: determine `tabWidth`, `useTabs`, `semi` from pret
const result = manager.mergeWithPrettierConfig({}, prettierOptions);
const expected = {
bracketSpacing: false,
jsxBracketSameLine: false,
bracketSameLine: false,
singleQuote: true,
trailingComma: 'all',
...prettierOptions,
Expand Down