chore: Enforce array type styles in TypeScript (#5765)

This change enforces how we type arrays, e.g. choosing between:

* `string[]`
* `Array<string>`

I've gone for the `array-simple` option [1] which enforces that:

* primitive types and type references use `X[]`
* complex types use `Array<X>`

For example, we'd type an array of strings as `string[]`, but an array
of a union type as `Array<SomeUnionType>`.

[1]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/array-type.md
This commit is contained in:
Jack Franklin 2020-04-28 15:06:43 +01:00 committed by GitHub
parent 1ccfbcb684
commit d69fbb9974
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -120,7 +120,10 @@ module.exports = {
"@typescript-eslint/no-empty-function": 0, "@typescript-eslint/no-empty-function": 0,
"@typescript-eslint/no-use-before-define": 0, "@typescript-eslint/no-use-before-define": 0,
// We know it's bad and use it very sparingly but it's needed :( // We know it's bad and use it very sparingly but it's needed :(
"@typescript-eslint/ban-ts-ignore": 0 "@typescript-eslint/ban-ts-ignore": 0,
"@typescript-eslint/array-type": [2, {
"default": "array-simple"
}]
} }
} }
] ]

View File

@ -48,7 +48,7 @@ interface SerializedAXNode {
haspopup?: string; haspopup?: string;
invalid?: string; invalid?: string;
orientation?: string; orientation?: string;
children?: Array<SerializedAXNode>; children?: SerializedAXNode[];
} }
export class Accessibility { export class Accessibility {