Skip to content

Commit

Permalink
fix(eslint-plugin): array-type mark `AST_NODE_TYPES.TSBigIntKeyword…
Browse files Browse the repository at this point in the history
…` as simple (#4274)
  • Loading branch information
jonahsnider committed Dec 15, 2021
1 parent 72c2e41 commit 74e544e
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/eslint-plugin/src/rules/array-type.ts
Expand Up @@ -15,6 +15,7 @@ function isSimpleType(node: TSESTree.Node): boolean {
case AST_NODE_TYPES.TSBooleanKeyword:
case AST_NODE_TYPES.TSNeverKeyword:
case AST_NODE_TYPES.TSNumberKeyword:
case AST_NODE_TYPES.TSBigIntKeyword:
case AST_NODE_TYPES.TSObjectKeyword:
case AST_NODE_TYPES.TSStringKeyword:
case AST_NODE_TYPES.TSSymbolKeyword:
Expand Down
120 changes: 120 additions & 0 deletions packages/eslint-plugin/tests/rules/array-type.test.ts
Expand Up @@ -202,6 +202,35 @@ ruleTester.run('array-type', rule, {
code: 'let a: ReadonlyArray<string | number> = [];',
options: [{ default: 'generic', readonly: 'array-simple' }],
},
{
code: 'let a: Array<bigint> = [];',
options: [{ default: 'generic', readonly: 'array' }],
},
{
code: 'let a: readonly bigint[] = [];',
options: [{ default: 'generic', readonly: 'array' }],
},
{
code: 'let a: readonly (string | bigint)[] = [];',
options: [{ default: 'generic', readonly: 'array' }],
},
{
code: 'let a: Array<bigint> = [];',
options: [{ default: 'generic', readonly: 'array-simple' }],
},
{
code: 'let a: Array<string | bigint> = [];',
options: [{ default: 'generic', readonly: 'array-simple' }],
},
{
code: 'let a: readonly bigint[] = [];',
options: [{ default: 'generic', readonly: 'array-simple' }],
},
{
code: 'let a: ReadonlyArray<string | bigint> = [];',
options: [{ default: 'generic', readonly: 'array-simple' }],
},

// End of base cases

{
Expand Down Expand Up @@ -1088,6 +1117,97 @@ function bazFunction(baz: Arr<ArrayClass<String>>) {
},
],
},
{
code: 'let a: bigint[] = [];',
output: 'let a: Array<bigint> = [];',
options: [{ default: 'generic', readonly: 'array-simple' }],
errors: [
{
messageId: 'errorStringGeneric',
data: { className: 'Array', readonlyPrefix: '', type: 'bigint' },
line: 1,
column: 8,
},
],
},
{
code: 'let a: (string | bigint)[] = [];',
output: 'let a: Array<string | bigint> = [];',
options: [{ default: 'generic', readonly: 'array-simple' }],
errors: [
{
messageId: 'errorStringGeneric',
data: { className: 'Array', readonlyPrefix: '', type: 'T' },
line: 1,
column: 8,
},
],
},
{
code: 'let a: ReadonlyArray<bigint> = [];',
output: 'let a: readonly bigint[] = [];',
options: [{ default: 'generic', readonly: 'array-simple' }],
errors: [
{
messageId: 'errorStringArraySimple',
data: {
className: 'ReadonlyArray',
readonlyPrefix: 'readonly ',
type: 'bigint',
},
line: 1,
column: 8,
},
],
},
{
code: 'let a: (string | bigint)[] = [];',
output: 'let a: Array<string | bigint> = [];',
options: [{ default: 'generic', readonly: 'generic' }],
errors: [
{
messageId: 'errorStringGeneric',
data: { className: 'Array', readonlyPrefix: '', type: 'T' },
line: 1,
column: 8,
},
],
},
{
code: 'let a: readonly bigint[] = [];',
output: 'let a: ReadonlyArray<bigint> = [];',
options: [{ default: 'generic', readonly: 'generic' }],
errors: [
{
messageId: 'errorStringGeneric',
data: {
className: 'ReadonlyArray',
readonlyPrefix: 'readonly ',
type: 'bigint',
},
line: 1,
column: 8,
},
],
},
{
code: 'let a: readonly (string | bigint)[] = [];',
output: 'let a: ReadonlyArray<string | bigint> = [];',
options: [{ default: 'generic', readonly: 'generic' }],
errors: [
{
messageId: 'errorStringGeneric',
data: {
className: 'ReadonlyArray',
readonlyPrefix: 'readonly ',
type: 'T',
},
line: 1,
column: 8,
},
],
},

// End of base cases

{
Expand Down

0 comments on commit 74e544e

Please sign in to comment.