Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(eslint-plugin): array-type mark AST_NODE_TYPES.TSBigIntKeyword as simple #4274

Merged
merged 3 commits into from Dec 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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