|
|
@@ -235,31 +235,100 @@ ruleTester.run("comma-dangle", rule, { |
|
|
options: ["only-multiline"], |
|
|
parserOptions: { ecmaVersion: 6, sourceType: "module" } |
|
|
}, |
|
|
|
|
|
|
|
|
// trailing comma in functions -- ignore by default |
|
|
{ |
|
|
code: "function foo(a,) {}", |
|
|
code: "function foo(a) {}", |
|
|
options: ["always"] |
|
|
}, |
|
|
{ |
|
|
code: "foo(a)", |
|
|
options: ["always"] |
|
|
}, |
|
|
{ |
|
|
code: "function foo(a) {}", |
|
|
options: ["never"] |
|
|
}, |
|
|
{ |
|
|
code: "foo(a)", |
|
|
options: ["never"] |
|
|
}, |
|
|
{ |
|
|
code: "function foo(a,\nb) {}", |
|
|
options: ["always-multiline"] |
|
|
}, |
|
|
{ |
|
|
code: "foo(a,\nb)", |
|
|
options: ["always-multiline"] |
|
|
}, |
|
|
{ |
|
|
code: "function foo(a,\nb) {}", |
|
|
options: ["only-multiline"] |
|
|
}, |
|
|
{ |
|
|
code: "foo(a,\nb)", |
|
|
options: ["only-multiline"] |
|
|
}, |
|
|
{ |
|
|
code: "function foo(a) {}", |
|
|
options: ["always"], |
|
|
parserOptions: { ecmaVersion: 7 } |
|
|
}, |
|
|
{ |
|
|
code: "foo(a)", |
|
|
options: ["always"], |
|
|
parserOptions: { ecmaVersion: 7 } |
|
|
}, |
|
|
{ |
|
|
code: "function foo(a) {}", |
|
|
options: ["never"], |
|
|
parserOptions: { ecmaVersion: 7 } |
|
|
}, |
|
|
{ |
|
|
code: "foo(a)", |
|
|
options: ["never"], |
|
|
parserOptions: { ecmaVersion: 7 } |
|
|
}, |
|
|
{ |
|
|
code: "function foo(a,\nb) {}", |
|
|
options: ["always-multiline"], |
|
|
parserOptions: { ecmaVersion: 7 } |
|
|
}, |
|
|
{ |
|
|
code: "foo(a,\nb)", |
|
|
options: ["always-multiline"], |
|
|
parserOptions: { ecmaVersion: 7 } |
|
|
}, |
|
|
{ |
|
|
code: "function foo(a,\nb) {}", |
|
|
options: ["only-multiline"], |
|
|
parserOptions: { ecmaVersion: 7 } |
|
|
}, |
|
|
{ |
|
|
code: "foo(a,\nb)", |
|
|
options: ["only-multiline"], |
|
|
parserOptions: { ecmaVersion: 7 } |
|
|
}, |
|
|
{ |
|
|
code: "function foo(a) {}", |
|
|
options: ["never"], |
|
|
parserOptions: { ecmaVersion: 8 } |
|
|
}, |
|
|
{ |
|
|
code: "foo(a,)", |
|
|
code: "foo(a)", |
|
|
options: ["never"], |
|
|
parserOptions: { ecmaVersion: 8 } |
|
|
}, |
|
|
{ |
|
|
code: "function foo(a) {}", |
|
|
code: "function foo(a,) {}", |
|
|
options: ["always"], |
|
|
parserOptions: { ecmaVersion: 8 } |
|
|
}, |
|
|
{ |
|
|
code: "foo(a)", |
|
|
code: "foo(a,)", |
|
|
options: ["always"], |
|
|
parserOptions: { ecmaVersion: 8 } |
|
|
}, |
|
|
{ |
|
|
code: "function foo(\na,\nb\n) {}", |
|
|
code: "function foo(\na,\nb,\n) {}", |
|
|
options: ["always-multiline"], |
|
|
parserOptions: { ecmaVersion: 8 } |
|
|
}, |
|
|
@@ -269,22 +338,22 @@ ruleTester.run("comma-dangle", rule, { |
|
|
parserOptions: { ecmaVersion: 8 } |
|
|
}, |
|
|
{ |
|
|
code: "function foo(a,b,) {}", |
|
|
code: "function foo(a,b) {}", |
|
|
options: ["always-multiline"], |
|
|
parserOptions: { ecmaVersion: 8 } |
|
|
}, |
|
|
{ |
|
|
code: "foo(a,b,)", |
|
|
code: "foo(a,b)", |
|
|
options: ["always-multiline"], |
|
|
parserOptions: { ecmaVersion: 8 } |
|
|
}, |
|
|
{ |
|
|
code: "function foo(a,b,) {}", |
|
|
code: "function foo(a,b) {}", |
|
|
options: ["only-multiline"], |
|
|
parserOptions: { ecmaVersion: 8 } |
|
|
}, |
|
|
{ |
|
|
code: "foo(a,b,)", |
|
|
code: "foo(a,b)", |
|
|
options: ["only-multiline"], |
|
|
parserOptions: { ecmaVersion: 8 } |
|
|
}, |
|
|
@@ -315,6 +384,11 @@ ruleTester.run("comma-dangle", rule, { |
|
|
options: [{ functions: "always" }], |
|
|
parserOptions: { ecmaVersion: 8 } |
|
|
}, |
|
|
{ |
|
|
code: "foo(a,)", |
|
|
options: [{ functions: "always" }], |
|
|
parserOptions: { ecmaVersion: 9 } |
|
|
}, |
|
|
{ |
|
|
code: "bar(...a,)", |
|
|
options: [{ functions: "always" }], |
|
|
@@ -1283,6 +1357,208 @@ ruleTester.run("comma-dangle", rule, { |
|
|
parserOptions: { ecmaVersion: 8 }, |
|
|
errors: [{ messageId: "unexpected", type: "SpreadElement" }] |
|
|
}, |
|
|
{ |
|
|
code: "function foo(a,) {}", |
|
|
output: "function foo(a) {}", |
|
|
options: ["never"], |
|
|
parserOptions: { ecmaVersion: 8 }, |
|
|
errors: [{ messageId: "unexpected", type: "Identifier" }] |
|
|
}, |
|
|
{ |
|
|
code: "(function foo(a,) {})", |
|
|
output: "(function foo(a) {})", |
|
|
options: ["never"], |
|
|
parserOptions: { ecmaVersion: 8 }, |
|
|
errors: [{ messageId: "unexpected", type: "Identifier" }] |
|
|
}, |
|
|
{ |
|
|
code: "(a,) => a", |
|
|
output: "(a) => a", |
|
|
options: ["never"], |
|
|
parserOptions: { ecmaVersion: 8 }, |
|
|
errors: [{ messageId: "unexpected", type: "Identifier" }] |
|
|
}, |
|
|
{ |
|
|
code: "(a,) => (a)", |
|
|
output: "(a) => (a)", |
|
|
options: ["never"], |
|
|
parserOptions: { ecmaVersion: 8 }, |
|
|
errors: [{ messageId: "unexpected", type: "Identifier" }] |
|
|
}, |
|
|
{ |
|
|
code: "({foo(a,) {}})", |
|
|
output: "({foo(a) {}})", |
|
|
options: ["never"], |
|
|
parserOptions: { ecmaVersion: 8 }, |
|
|
errors: [{ messageId: "unexpected", type: "Identifier" }] |
|
|
}, |
|
|
{ |
|
|
code: "class A {foo(a,) {}}", |
|
|
output: "class A {foo(a) {}}", |
|
|
options: ["never"], |
|
|
parserOptions: { ecmaVersion: 8 }, |
|
|
errors: [{ messageId: "unexpected", type: "Identifier" }] |
|
|
}, |
|
|
{ |
|
|
code: "foo(a,)", |
|
|
output: "foo(a)", |
|
|
options: ["never"], |
|
|
parserOptions: { ecmaVersion: 8 }, |
|
|
errors: [{ messageId: "unexpected", type: "Identifier" }] |
|
|
}, |
|
|
{ |
|
|
code: "foo(...a,)", |
|
|
output: "foo(...a)", |
|
|
options: ["never"], |
|
|
parserOptions: { ecmaVersion: 8 }, |
|
|
errors: [{ messageId: "unexpected", type: "SpreadElement" }] |
|
|
}, |
|
|
|
|
|
{ |
|
|
code: "function foo(a) {}", |
|
|
output: "function foo(a,) {}", |
|
|
options: ["always"], |
|
|
parserOptions: { ecmaVersion: 8 }, |
|
|
errors: [{ messageId: "missing", type: "Identifier" }] |
|
|
}, |
|
|
{ |
|
|
code: "(function foo(a) {})", |
|
|
output: "(function foo(a,) {})", |
|
|
options: ["always"], |
|
|
parserOptions: { ecmaVersion: 8 }, |
|
|
errors: [{ messageId: "missing", type: "Identifier" }] |
|
|
}, |
|
|
{ |
|
|
code: "(a) => a", |
|
|
output: "(a,) => a", |
|
|
options: ["always"], |
|
|
parserOptions: { ecmaVersion: 8 }, |
|
|
errors: [{ messageId: "missing", type: "Identifier" }] |
|
|
}, |
|
|
{ |
|
|
code: "(a) => (a)", |
|
|
output: "(a,) => (a)", |
|
|
options: ["always"], |
|
|
parserOptions: { ecmaVersion: 8 }, |
|
|
errors: [{ messageId: "missing", type: "Identifier" }] |
|
|
}, |
|
|
{ |
|
|
code: "({foo(a) {}})", |
|
|
output: "({foo(a,) {},})", |
|
|
options: ["always"], |
|
|
parserOptions: { ecmaVersion: 8 }, |
|
|
errors: [ |
|
|
{ messageId: "missing", type: "Identifier" }, |
|
|
{ messageId: "missing", type: "Property" } |
|
|
] |
|
|
}, |
|
|
{ |
|
|
code: "class A {foo(a) {}}", |
|
|
output: "class A {foo(a,) {}}", |
|
|
options: ["always"], |
|
|
parserOptions: { ecmaVersion: 8 }, |
|
|
errors: [{ messageId: "missing", type: "Identifier" }] |
|
|
}, |
|
|
{ |
|
|
code: "foo(a)", |
|
|
output: "foo(a,)", |
|
|
options: ["always"], |
|
|
parserOptions: { ecmaVersion: 8 }, |
|
|
errors: [{ messageId: "missing", type: "Identifier" }] |
|
|
}, |
|
|
{ |
|
|
code: "foo(...a)", |
|
|
output: "foo(...a,)", |
|
|
options: ["always"], |
|
|
parserOptions: { ecmaVersion: 8 }, |
|
|
errors: [{ messageId: "missing", type: "SpreadElement" }] |
|
|
}, |
|
|
|
|
|
{ |
|
|
code: "function foo(a,) {}", |
|
|
output: "function foo(a) {}", |
|
|
options: ["always-multiline"], |
|
|
parserOptions: { ecmaVersion: 8 }, |
|
|
errors: [{ messageId: "unexpected", type: "Identifier" }] |
|
|
}, |
|
|
{ |
|
|
code: "(function foo(a,) {})", |
|
|
output: "(function foo(a) {})", |
|
|
options: ["always-multiline"], |
|
|
parserOptions: { ecmaVersion: 8 }, |
|
|
errors: [{ messageId: "unexpected", type: "Identifier" }] |
|
|
}, |
|
|
{ |
|
|
code: "foo(a,)", |
|
|
output: "foo(a)", |
|
|
options: ["always-multiline"], |
|
|
parserOptions: { ecmaVersion: 8 }, |
|
|
errors: [{ messageId: "unexpected", type: "Identifier" }] |
|
|
}, |
|
|
{ |
|
|
code: "foo(...a,)", |
|
|
output: "foo(...a)", |
|
|
options: ["always-multiline"], |
|
|
parserOptions: { ecmaVersion: 8 }, |
|
|
errors: [{ messageId: "unexpected", type: "SpreadElement" }] |
|
|
}, |
|
|
{ |
|
|
code: "function foo(\na,\nb\n) {}", |
|
|
output: "function foo(\na,\nb,\n) {}", |
|
|
options: ["always-multiline"], |
|
|
parserOptions: { ecmaVersion: 8 }, |
|
|
errors: [{ messageId: "missing", type: "Identifier" }] |
|
|
}, |
|
|
{ |
|
|
code: "foo(\na,\nb\n)", |
|
|
output: "foo(\na,\nb,\n)", |
|
|
options: ["always-multiline"], |
|
|
parserOptions: { ecmaVersion: 8 }, |
|
|
errors: [{ messageId: "missing", type: "Identifier" }] |
|
|
}, |
|
|
{ |
|
|
code: "foo(\n...a,\n...b\n)", |
|
|
output: "foo(\n...a,\n...b,\n)", |
|
|
options: ["always-multiline"], |
|
|
parserOptions: { ecmaVersion: 8 }, |
|
|
errors: [{ messageId: "missing", type: "SpreadElement" }] |
|
|
}, |
|
|
|
|
|
{ |
|
|
code: "function foo(a,) {}", |
|
|
output: "function foo(a) {}", |
|
|
options: ["only-multiline"], |
|
|
parserOptions: { ecmaVersion: 8 }, |
|
|
errors: [{ messageId: "unexpected", type: "Identifier" }] |
|
|
}, |
|
|
{ |
|
|
code: "(function foo(a,) {})", |
|
|
output: "(function foo(a) {})", |
|
|
options: ["only-multiline"], |
|
|
parserOptions: { ecmaVersion: 8 }, |
|
|
errors: [{ messageId: "unexpected", type: "Identifier" }] |
|
|
}, |
|
|
{ |
|
|
code: "foo(a,)", |
|
|
output: "foo(a)", |
|
|
options: ["only-multiline"], |
|
|
parserOptions: { ecmaVersion: 8 }, |
|
|
errors: [{ messageId: "unexpected", type: "Identifier" }] |
|
|
}, |
|
|
{ |
|
|
code: "foo(...a,)", |
|
|
output: "foo(...a)", |
|
|
options: ["only-multiline"], |
|
|
parserOptions: { ecmaVersion: 8 }, |
|
|
errors: [{ messageId: "unexpected", type: "SpreadElement" }] |
|
|
}, |
|
|
{ |
|
|
code: "function foo(a) {}", |
|
|
output: "function foo(a,) {}", |
|
|
options: ["always"], |
|
|
parserOptions: { ecmaVersion: 9 }, |
|
|
errors: [{ messageId: "missing", type: "Identifier" }] |
|
|
}, |
|
|
|
|
|
// separated options |
|
|
{ |
|
|
|