Skip to content

Commit

Permalink
feat(eslint-plugin):[comma-spacing]add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
islandryu committed Apr 20, 2023
1 parent 25dfe74 commit 9e4e9aa
Showing 1 changed file with 49 additions and 2 deletions.
51 changes: 49 additions & 2 deletions packages/eslint-plugin/tests/rules/comma-spacing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,55 @@ ruleTester.run('comma-spacing', rule, {
'interface Foo<T, T1,>{}',
'interface A<> {}',
'let foo,',
"['value', 'value2', ]",
"const obj = {value1: '',};",
'const arr = [,];',
'const arr = [ ,];',
'const arr = [ , ];',
'const arr = [1,];',
'const arr = [ , 2];',
'const arr = [,,];',
'const arr = [ ,,];',
'const arr = [, ,];',
'const arr = [,, ];',
'const arr = [ , ,];',
'const arr = [ ,, ];',
'const arr = [ , , ];',
'const arr = [,, 3];',
'const arr = [1, 2, 3,];',
'const arr = [1, 2, 3, ];',
"const obj = {'foo':'bar', 'baz':'qur', };",
"const obj = {'foo':'bar', 'baz':'qur',};",
{ code: 'const arr = [ ,];', options: [{ before: true, after: false }] },
{ code: 'const arr = [, ];', options: [{ before: true, after: false }] },
{ code: 'const arr = [ , ];', options: [{ before: true, after: false }] },
{ code: 'const arr = [ ,,];', options: [{ before: true, after: false }] },
{ code: 'const arr = [, ,];', options: [{ before: true, after: false }] },
{ code: 'const arr = [,, ];', options: [{ before: true, after: false }] },
{ code: 'const arr = [ , ,];', options: [{ before: true, after: false }] },
{ code: 'const arr = [ ,, ];', options: [{ before: true, after: false }] },
{ code: 'const arr = [, , ];', options: [{ before: true, after: false }] },
{ code: 'const arr = [ , , ];', options: [{ before: true, after: false }] },
{
code: 'const arr = [ , , ];',
options: [{ before: false, after: false }],
},
{ code: 'const [a, b,] = [1, 2];', parserOptions: { ecmaVersion: 6 } },
{
code: '<a>Hello, world</a>',
options: [{ before: true, after: false }],
parserOptions: { ecmaVersion: 6, ecmaFeatures: { jsx: true } },
},
{ code: '[a, /**/ , ]', options: [{ before: false, after: true }] },
{ code: '[a , /**/, ]', options: [{ before: true, after: true }] },
{
code: '[a, /**/ , ] = foo',
options: [{ before: false, after: true }],
parserOptions: { ecmaVersion: 6 },
},
{
code: '[a , /**/, ] = foo',
options: [{ before: true, after: true }],
parserOptions: { ecmaVersion: 6 },
},
],

invalid: [
Expand Down

0 comments on commit 9e4e9aa

Please sign in to comment.