2019-07-24 06:17:16 +02:00
|
|
|
import { RuleTester } from "./support/RuleTester";
|
|
|
|
import rule = require("../rules/object-literal-surrounding-space");
|
|
|
|
|
|
|
|
const ruleTester = new RuleTester({
|
|
|
|
parserOptions: {
|
|
|
|
warnOnUnsupportedTypeScriptVersion: false,
|
|
|
|
},
|
|
|
|
parser: require.resolve("@typescript-eslint/parser"),
|
|
|
|
});
|
|
|
|
|
|
|
|
ruleTester.run("object-literal-surrounding-space", rule, {
|
2019-08-04 07:43:27 +02:00
|
|
|
valid: [
|
|
|
|
{
|
|
|
|
code: `const prop = {}`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
code: `const prop = { }`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
code: `const prop = { x: 1 }`,
|
|
|
|
},
|
|
|
|
],
|
2019-07-24 06:17:16 +02:00
|
|
|
|
2019-08-04 07:43:27 +02:00
|
|
|
invalid: [
|
|
|
|
{
|
|
|
|
code: `const prop = {x: 1}`,
|
|
|
|
errors: [
|
|
|
|
{ messageId: "leadingStringError" },
|
|
|
|
{ messageId: "trailingStringError" }
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
code: `const prop = { x: 1 }`,
|
|
|
|
errors: [{ messageId: "leadingExcessStringError" }],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
code: `const prop = { x: 1 }`,
|
|
|
|
errors: [{ messageId: "trailingExcessStringError" }],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
code: `const prop = { x: 1}`,
|
|
|
|
errors: [{ messageId: "trailingStringError" }],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
code: `const prop = {x: 1 }`,
|
|
|
|
errors: [{ messageId: "leadingStringError" }],
|
|
|
|
},
|
|
|
|
],
|
2019-07-24 06:17:16 +02:00
|
|
|
});
|