-
Notifications
You must be signed in to change notification settings - Fork 11
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
extend genericSpacing
to cover funtion annotations
#25
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,4 +56,4 @@ | |
"onlyFilesWithFlowAnnotation": false | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,7 +1,6 @@ | ||||||
export default { | ||||||
invalid: [ | ||||||
// Never | ||||||
|
||||||
{ | ||||||
code: 'type X = Promise< string>', | ||||||
errors: [{ message: 'There must be no space at start of "Promise" generic type annotation' }], | ||||||
|
@@ -91,6 +90,68 @@ export default { | |||||
options: ['always'], | ||||||
output: 'type X = Promise< (foo), bar, (((baz))) >', | ||||||
}, | ||||||
|
||||||
// Type annotations | ||||||
{ | ||||||
code: 'const [state, setState] = useState<?string >(null)', | ||||||
errors: [{ message: 'There must be no space at start of type annotations' }], | ||||||
output: 'const [state, setState] = useState<?string>(null)', | ||||||
}, | ||||||
{ | ||||||
code: 'const [state, setState] = useState<?string > (null)', | ||||||
errors: [{ message: 'There must be no space at start of type annotations' }], | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
output: 'const [state, setState] = useState<?string>(null)', | ||||||
}, | ||||||
{ | ||||||
code: 'const [state, setState] = useState< ?string>(null)', | ||||||
errors: [{ message: 'There must be no space at start of type annotations' }], | ||||||
output: 'const [state, setState] = useState<?string>(null)', | ||||||
}, | ||||||
{ | ||||||
code: 'const [state, setState] = useState < ?string>(null)', | ||||||
errors: [{ message: 'There must be no space at start of type annotations' }], | ||||||
output: 'const [state, setState] = useState<?string>(null)', | ||||||
}, | ||||||
{ | ||||||
code: 'const [state, setState] = useState<? string>(null)', | ||||||
errors: [{ message: 'There must be no space at start of type annotations' }], | ||||||
output: 'const [state, setState] = useState<?string>(null)', | ||||||
}, | ||||||
{ | ||||||
code: 'const [state, setState] = useState< ? string>(null)', | ||||||
errors: [{ message: 'There must be no space at start of type annotations' }], | ||||||
output: 'const [state, setState] = useState<?string>(null)', | ||||||
}, | ||||||
{ | ||||||
code: 'const [state, setState] = useState< ? string >(null)', | ||||||
errors: [{ message: 'There must be no space at start of type annotations' }], | ||||||
output: 'const [state, setState] = useState<?string>(null)', | ||||||
}, | ||||||
{ | ||||||
code: 'const [state, setState] = useState < ? string > (null)', | ||||||
errors: [{ message: 'There must be no space at start of type annotations' }], | ||||||
output: 'const [state, setState] = useState<?string>(null)', | ||||||
}, | ||||||
{ | ||||||
code: 'const [state, setState] = useState < ? string > ()', | ||||||
errors: [{ message: 'There must be no space at start of type annotations' }], | ||||||
output: 'const [state, setState] = useState<?string>(null)', | ||||||
}, | ||||||
{ | ||||||
code: 'useState<string >(null)', | ||||||
errors: [{ message: 'There must be no space at start of type annotations' }], | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should say |
||||||
output: 'useState<string>(null)', | ||||||
}, | ||||||
{ | ||||||
code: 'useState< string>(null)', | ||||||
errors: [{ message: 'There must be no space at start of type annotations' }], | ||||||
output: 'useState<string>(null)', | ||||||
}, | ||||||
{ | ||||||
code: 'useState< string >(null)', | ||||||
errors: [{ message: 'There must be no space at start of type annotations' }], | ||||||
output: 'useState<string>(null)', | ||||||
}, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add a test that's something like the following if it doesn't already exist elsewhere I'm interested to know if it strips all spaces blindly or only when it's between maybe types
|
||||||
], | ||||||
misconfigured: [ | ||||||
{ | ||||||
|
@@ -131,7 +192,7 @@ export default { | |||||
{ code: 'type X = Promise<(foo), bar, (((baz)))>' }, | ||||||
{ | ||||||
code: | ||||||
`type X = Promise< | ||||||
`type X = Promise< | ||||||
(foo), | ||||||
bar, | ||||||
(((baz))) | ||||||
|
@@ -153,5 +214,43 @@ export default { | |||||
code: 'type X = Promise< (foo), bar, (((baz))) >', | ||||||
options: ['always'], | ||||||
}, | ||||||
{ | ||||||
code: 'const [state, setState] = useState< string >("")', | ||||||
options: ['always'], | ||||||
}, | ||||||
{ | ||||||
code: 'const [state, setState] = useState< ?string >(null)', | ||||||
options: ['always'], | ||||||
}, | ||||||
{ | ||||||
code: 'const [state, setState] = useState< string | null >(null)', | ||||||
options: ['always'], | ||||||
}, | ||||||
{ | ||||||
code: 'const [state, setState] = useState< string | number >(2)', | ||||||
options: ['always'], | ||||||
}, | ||||||
|
||||||
// Never | ||||||
{ | ||||||
code: 'const [state, setState] = useState(null)', | ||||||
options: ['never'], | ||||||
}, | ||||||
{ | ||||||
code: 'const [state, setState] = useState<string>("")', | ||||||
options: ['never'], | ||||||
}, | ||||||
{ | ||||||
code: 'const [state, setState] = useState<?string>(null)', | ||||||
options: ['never'], | ||||||
}, | ||||||
{ | ||||||
code: 'const [state, setState] = useState<string | null>(null)', | ||||||
options: ['never'], | ||||||
}, | ||||||
{ | ||||||
code: 'const [state, setState] = useState<string | number>(2)', | ||||||
options: ['never'], | ||||||
}, | ||||||
], | ||||||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.