Skip to content

Commit

Permalink
feat: update jsx default config (#281)
Browse files Browse the repository at this point in the history
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
  • Loading branch information
promise96319 and antfu committed Oct 10, 2023
1 parent 4314f91 commit 987b9d8
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 35 deletions.
5 changes: 5 additions & 0 deletions fixtures/input/tsx.tsx
Expand Up @@ -12,5 +12,10 @@ export function jsx2() {
<Component1>
Block Text
</Component1>
<div>
Mixed
<div>Foo</div>
Text<b > Bar</b>
</div>
</ a >
}
30 changes: 20 additions & 10 deletions fixtures/output/all/tsx.tsx
Expand Up @@ -4,14 +4,24 @@ export function Component1() {

export function jsx2() {
const props = { a: 1, b: 2 }
return (<a foo="bar" bar={`foo`} >
<div
{...props}
a={1}
b="2"
>Inline Text</div>
<Component1>
Block Text
</Component1>
</a >)
return (
<a foo="bar" bar="foo">
<div
{...props}
a={1}
b="2"
>
Inline Text
</div>
<Component1>
Block Text
</Component1>
<div>
Mixed
<div>Foo</div>
Text
<b> Bar</b>
</div>
</a>
)
}
30 changes: 20 additions & 10 deletions fixtures/output/tab-double-quotes/tsx.tsx
Expand Up @@ -4,14 +4,24 @@ export function Component1() {

export function jsx2() {
const props = { a: 1, b: 2 }
return (<a foo="bar" bar={`foo`} >
<div
{...props}
a={1}
b="2"
>Inline Text</div>
<Component1>
Block Text
</Component1>
</a >)
return (
<a foo="bar" bar="foo">
<div
{...props}
a={1}
b="2"
>
Inline Text
</div>
<Component1>
Block Text
</Component1>
<div>
Mixed
<div>Foo</div>
Text
<b> Bar</b>
</div>
</a>
)
}
30 changes: 20 additions & 10 deletions fixtures/output/ts-override/tsx.tsx
Expand Up @@ -4,14 +4,24 @@ export function Component1() {

export function jsx2() {
const props = { a: 1, b: 2 }
return (<a foo="bar" bar={`foo`} >
<div
{...props}
a={1}
b="2"
>Inline Text</div>
<Component1>
Block Text
</Component1>
</a >)
return (
<a foo="bar" bar="foo">
<div
{...props}
a={1}
b="2"
>
Inline Text
</div>
<Component1>
Block Text
</Component1>
<div>
Mixed
<div>Foo</div>
Text
<b> Bar</b>
</div>
</a>
)
}
33 changes: 28 additions & 5 deletions src/configs/stylistic.ts
Expand Up @@ -128,16 +128,39 @@ export function stylistic(options: StylisticConfig = {}): ConfigItem[] {
...jsx
? {
'style/jsx-child-element-spacing': 'error',
'style/jsx-closing-bracket-location': ['error', 'line-aligned'],
'style/jsx-closing-bracket-location': 'error',
'style/jsx-closing-tag-location': 'error',
'style/jsx-curly-brace-presence': ['error', { propElementValues: 'always' }],
'style/jsx-curly-newline': 'error',
'style/jsx-curly-spacing': ['error', 'never', { allowMultiline: true }],
'style/jsx-curly-spacing': ['error', 'never'],
'style/jsx-equals-spacing': 'error',
'style/jsx-first-prop-new-line': 'error',
'style/jsx-indent': ['error', indent],
'style/jsx-indent': ['error', indent, { checkAttributes: true, indentLogicalExpressions: true }],
'style/jsx-indent-props': ['error', indent],
'style/jsx-max-props-per-line': ['error', { maximum: 1, when: 'multiline' }],
'style/jsx-one-expression-per-line': ['error', { allow: 'single-child' }],
'style/jsx-quotes': 'error',
'style/jsx-tag-spacing': 'error',
'style/jsx-wrap-multilines': 'error',
'style/jsx-tag-spacing': [
'error',
{
afterOpening: 'never',
beforeClosing: 'never',
beforeSelfClosing: 'always',
closingSlash: 'never',
},
],
'style/jsx-wrap-multilines': [
'error',
{
arrow: 'parens-new-line',
assignment: 'parens-new-line',
condition: 'parens-new-line',
declaration: 'parens-new-line',
logical: 'parens-new-line',
prop: 'parens-new-line',
return: 'parens-new-line',
},
],
}
: {},
},
Expand Down

0 comments on commit 987b9d8

Please sign in to comment.