Skip to content

Commit

Permalink
chore: Enforce array type styles in TypeScript (#5765)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jackfranklin committed Apr 28, 2020
1 parent 1ccfbcb commit d69fbb9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.js
Expand Up @@ -120,7 +120,10 @@ module.exports = {
"@typescript-eslint/no-empty-function": 0,
"@typescript-eslint/no-use-before-define": 0,
// 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"
}]
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion src/Accessibility.ts
Expand Up @@ -48,7 +48,7 @@ interface SerializedAXNode {
haspopup?: string;
invalid?: string;
orientation?: string;
children?: Array<SerializedAXNode>;
children?: SerializedAXNode[];
}

export class Accessibility {
Expand Down

0 comments on commit d69fbb9

Please sign in to comment.