From d69fbb99743950e155fa273c223b9017b9aafca2 Mon Sep 17 00:00:00 2001 From: Jack Franklin Date: Tue, 28 Apr 2020 15:06:43 +0100 Subject: [PATCH] chore: Enforce array type styles in TypeScript (#5765) This change enforces how we type arrays, e.g. choosing between: * `string[]` * `Array` I've gone for the `array-simple` option [1] which enforces that: * primitive types and type references use `X[]` * complex types use `Array` For example, we'd type an array of strings as `string[]`, but an array of a union type as `Array`. [1]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/array-type.md --- .eslintrc.js | 5 ++++- src/Accessibility.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 527cb9ffed100..2cf2cc9e02bfe 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -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" + }] } } ] diff --git a/src/Accessibility.ts b/src/Accessibility.ts index 3a17825551a19..e609c056cefaf 100644 --- a/src/Accessibility.ts +++ b/src/Accessibility.ts @@ -48,7 +48,7 @@ interface SerializedAXNode { haspopup?: string; invalid?: string; orientation?: string; - children?: Array; + children?: SerializedAXNode[]; } export class Accessibility {