Skip to content

Commit

Permalink
feat: Change default array notation for simple types to "verbose"
Browse files Browse the repository at this point in the history
  • Loading branch information
pnevyk committed Sep 29, 2017
1 parent 4a6f03d commit 687f82b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .README/rules/array-style-simple-type.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ If it is `'verbose'` then a problem is raised when using `Type[]` instead of `Ar

If it is `'shorthand'` then a problem is raised when using `Array<Type>` instead of `Type[]`.

The default value is `'shorthand'`.
The default value is `'verbose'`.

<!-- assertions arrayStyleSimpleType -->
2 changes: 1 addition & 1 deletion src/rules/arrayStyleSimpleType.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ const verboseHandler = (isSimpleType, verbose, context, node, fix) => {
}
};

export default makeArrayStyleRule('shorthand', shorthandHandler, verboseHandler);
export default makeArrayStyleRule('verbose', shorthandHandler, verboseHandler);
60 changes: 31 additions & 29 deletions tests/rules/assertions/arrayStyleSimpleType.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export default {
invalid: [
{
code: 'type X = Array<string>',
errors: [{message: 'Use "SimpleType[]", not "Array<SimpleType>"'}],
output: 'type X = string[]'
code: 'type X = string[]',
errors: [{message: 'Use "Array<SimpleType>", not "SimpleType[]"'}],
output: 'type X = Array<string>'
},
{
code: 'type X = string[]',
Expand All @@ -18,44 +18,46 @@ export default {
output: 'type X = string[]'
},
{
code: 'type X = Array<Date>',
errors: [{message: 'Use "SimpleType[]", not "Array<SimpleType>"'}],
output: 'type X = Date[]'
code: 'type X = Date[]',
errors: [{message: 'Use "Array<SimpleType>", not "SimpleType[]"'}],
output: 'type X = Array<Date>'
},
{
code: 'type X = Array<Promise<string>>',
errors: [{message: 'Use "SimpleType[]", not "Array<SimpleType>"'}],
output: 'type X = Promise<string>[]'
code: 'type X = Promise<string>[]',
errors: [{message: 'Use "Array<SimpleType>", not "SimpleType[]"'}],
output: 'type X = Array<Promise<string>>'
},
{
code: 'type X = Array<$Keys<{ foo: string }>>',
errors: [{message: 'Use "SimpleType[]", not "Array<SimpleType>"'}],
output: 'type X = $Keys<{ foo: string }>[]'
code: 'type X = $Keys<{ foo: string }>[]',
errors: [{message: 'Use "Array<SimpleType>", not "SimpleType[]"'}],
output: 'type X = Array<$Keys<{ foo: string }>>'
},
{
code: 'type X = Array<any>',
errors: [{message: 'Use "SimpleType[]", not "Array<SimpleType>"'}],
output: 'type X = any[]'
code: 'type X = any[]',
errors: [{message: 'Use "Array<SimpleType>", not "SimpleType[]"'}],
output: 'type X = Array<any>'
},
{
code: 'type X = Array<mixed>',
errors: [{message: 'Use "SimpleType[]", not "Array<SimpleType>"'}],
output: 'type X = mixed[]'
code: 'type X = mixed[]',
errors: [{message: 'Use "Array<SimpleType>", not "SimpleType[]"'}],
output: 'type X = Array<mixed>'
},
{
code: 'type X = Array<void>',
errors: [{message: 'Use "SimpleType[]", not "Array<SimpleType>"'}],
output: 'type X = void[]'
code: 'type X = void[]',
errors: [{message: 'Use "Array<SimpleType>", not "SimpleType[]"'}],
output: 'type X = Array<void>'
},
{
code: 'type X = Array<null>',
errors: [{message: 'Use "SimpleType[]", not "Array<SimpleType>"'}],
output: 'type X = null[]'
code: 'type X = null[]',
errors: [{message: 'Use "Array<SimpleType>", not "SimpleType[]"'}],
output: 'type X = Array<null>'
},
{
code: 'type X = Array<string[]>',
errors: [{message: 'Use "SimpleType[]", not "Array<SimpleType>"'}],
output: 'type X = string[][]'
code: 'type X = string[][]',
errors: [
{message: 'Use "Array<SimpleType>", not "SimpleType[]"'},
{message: 'Use "Array<SimpleType>", not "SimpleType[]"'}
]
}
],
misconfigured: [
Expand Down Expand Up @@ -91,7 +93,7 @@ export default {
],
valid: [
{
code: 'type X = string[]'
code: 'type X = Array<string>'
},
{
code: 'type X = Array<string>',
Expand All @@ -102,7 +104,7 @@ export default {
options: ['shorthand']
},
{
code: 'type X = string[][]'
code: 'type X = Array<Array<string>>'
},
{
code: 'type X = (?string)[]',
Expand Down

0 comments on commit 687f82b

Please sign in to comment.