2016-10-06 02:17:46 +03:00
[
{
"language" : "javascript" ,
2016-10-28 04:42:46 +03:00
"fileExt" : ".js" ,
2016-11-01 18:50:54 +03:00
"repoUrl" : "https://github.com/diff-fixtures/javascript.git" ,
2016-10-06 02:17:46 +03:00
"syntaxes" : [
{
"syntax" : "object" ,
"insert" : "{ \"key1\": \"value1\" };" ,
"replacement" : "{ \"key1\": \"value1\", \"key2\": \"value2\", \"key3\": \"3.0\" };"
} ,
{
"syntax" : "anonymous-function" ,
"insert" : "function(a,b) { return a + b; }" ,
"replacement" : "function(b,c) { return b * c; }"
} ,
{
"syntax" : "anonymous-parameterless-function" ,
"insert" : "function() { return 'hi'; }" ,
"replacement" : "function() { return 'hello'; }"
} ,
{
"syntax" : "objects-with-methods" ,
"insert" : "{ add(a, b) { return a + b; } };" ,
"replacement" : "{ subtract(a, b) { return a - b; } };"
} ,
{
"syntax" : "string" ,
2016-10-06 21:42:21 +03:00
"insert" : "'A string with \"double\" quotes';" ,
2016-10-28 04:42:46 +03:00
"replacement" : "'A different string with \"double\" quotes';"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "number" ,
"insert" : "101" ,
2016-10-28 04:42:46 +03:00
"replacement" : "102"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "variable" ,
"insert" : "theVar;" ,
2016-10-28 04:42:46 +03:00
"replacement" : "theVar2"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "identifier" ,
"insert" : "theVar;" ,
2016-10-28 04:42:46 +03:00
"replacement" : "theVar2"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "this-expression" ,
"insert" : "this;" ,
2016-10-28 04:42:46 +03:00
"replacement" : "return this;"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "null" ,
"insert" : "null;" ,
2016-10-28 04:42:46 +03:00
"replacement" : "return null;"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "undefined" ,
"insert" : "undefined;" ,
2016-10-28 04:42:46 +03:00
"replacement" : "return undefined;"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "true" ,
"insert" : "true;" ,
2016-10-28 04:42:46 +03:00
"replacement" : "return true;"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "false" ,
"insert" : "false;" ,
2016-10-28 04:42:46 +03:00
"replacement" : "return false;"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "class" ,
"insert" : "class Foo { static one(a) { return a; }; two(b) { return b; } three(c) { return c; } }" ,
2016-10-28 04:42:46 +03:00
"replacement" : "class Foo { static foo(a) { return a; }; bar(b) { return b; } baz(c) { return c; } }"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "array" ,
"insert" : "[ \"item1\" ];" ,
2016-10-28 04:42:46 +03:00
"replacement" : "[ \"item1\", \"item2\" ];"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "function" ,
"insert" : "function(arg1, arg2) { arg2; };" ,
2016-10-28 04:42:46 +03:00
"replacement" : "function(arg1, arg2) { arg1; };"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "arrow-function" ,
"insert" : "(f, g) => { return h; };" ,
2016-10-28 04:42:46 +03:00
"replacement" : "(f, g) => { return g; };"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "generator-function" ,
"insert" : "function *generateStuff(arg1, arg2) { yield; yield arg2; };" ,
2016-10-28 04:42:46 +03:00
"replacement" : "function *generateNewStuff(arg1, arg2) { yield; yield arg2; };"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "named-function" ,
"insert" : "function myFunction(arg1, arg2) { arg2; };" ,
2016-10-28 04:42:46 +03:00
"replacement" : "function anotherFunction() { return false; };"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "member-access" ,
"insert" : "x.someProperty;" ,
2016-10-28 04:42:46 +03:00
"replacement" : "x.someOtherProperty"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "subscript-access-variable" ,
"insert" : "x[someVariable];" ,
2016-10-28 04:42:46 +03:00
"replacement" : "x[someOtherVariable];"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "subscript-access-string" ,
"insert" : "x[\"some-string\"];" ,
2016-10-28 04:42:46 +03:00
"replacement" : "x[\"some-other-string\"];"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "chained-property-access" ,
"insert" : "return returned.promise().done( newDefer.resolve ).fail( newDefer.reject )" ,
2016-10-28 04:42:46 +03:00
"replacement" : "return returned.promise().done( otherDefer.resolve ).fail( otherDefer.reject )"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "chained-callbacks" ,
"insert" : "this.map(function (a) { return a.b; })" ,
2016-10-28 04:42:46 +03:00
"replacement" : "this.reduce(function (a) { return b.a; })"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "function-call" ,
"insert" : "someFunction(arg1, \"arg2\");" ,
2016-10-28 04:42:46 +03:00
"replacement" : "someFunction(arg1, \"arg3\");"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "method-call" ,
"insert" : "object.someMethod(arg1, \"arg2\");" ,
2016-10-28 04:42:46 +03:00
"replacement" : "object.someMethod(arg1, \"arg3\");"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "function-call-args" ,
"insert" : "someFunction(1, \"string\", function(a,b) { console.log(a); return b; }, true)" ,
2016-10-28 04:42:46 +03:00
"replacement" : "someFunction(1, \"otherString\", function(b,c) { console.log(b); return c; }, false)"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "constructor-call" ,
"insert" : "new module.Klass(1, \"two\");" ,
2016-10-28 04:42:46 +03:00
"replacement" : "new module.Klass(1, \"three\");"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "math-operator" ,
"insert" : "i + j * 3 - j % 5;" ,
2016-10-28 04:42:46 +03:00
"replacement" : "i + j * 2 - j % 4;"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "boolean-operator" ,
"insert" : "i || j;" ,
2016-10-28 04:42:46 +03:00
"replacement" : "i && j;"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "bitwise-operator" ,
"insert" : "i >> j;" ,
2016-10-28 04:42:46 +03:00
"replacement" : "i >> k;"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "relational-operator" ,
"insert" : "x < y;" ,
2016-10-28 04:42:46 +03:00
"replacement" : "x <= y;"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "for-statement" ,
"insert" : "for (i = 0, init(); i < 10; i++) { log(i); }" ,
2016-10-28 04:42:46 +03:00
"replacement" : "for (i = 0, init(); i < 100; i++) { log(i); }"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "assignment" ,
"insert" : "x = 0;" ,
2016-10-28 04:42:46 +03:00
"replacement" : "x = 1;"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "member-access-assignment" ,
"insert" : "y.x = 0;" ,
2016-10-28 04:42:46 +03:00
"replacement" : "y.x = 1;"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "subscript-access-assignment" ,
"insert" : "y[\"x\"] = 0;" ,
2016-10-28 04:42:46 +03:00
"replacement" : "y[\"x\"] = 1;"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "comma-operator" ,
"insert" : "a = 1, b = 2;" ,
2016-10-28 04:42:46 +03:00
"replacement" : "c = {d: (3, 4 + 5, 6)};"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "ternary" ,
"insert" : "condition ? case1 : case2;" ,
2016-10-28 04:42:46 +03:00
"replacement" : "x.y = some.condition ? some.case : some.other.case;"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "type-operator" ,
"insert" : "typeof x;" ,
2016-10-28 04:42:46 +03:00
"replacement" : "x instanceof String;"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "delete-operator" ,
"insert" : "delete thing['prop'];" ,
2016-10-28 04:42:46 +03:00
"replacement" : "delete thing.prop"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "void-operator" ,
"insert" : "void b()" ,
2016-10-28 04:42:46 +03:00
"replacement" : "void c()"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "math-assignment-operator" ,
"insert" : "x += 1;" ,
2016-10-28 04:42:46 +03:00
"replacement" : "x += 2;"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "for-loop-with-in-statement" ,
"insert" : "for (key in something && i = 0; i < n; i++) { doSomething(); }" ,
2016-10-28 04:42:46 +03:00
"replacement" : "for (otherKey in something && i = 0; i < n; i++) { doOtherSomething(); }"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "for-of-statement" ,
"insert" : "for (let item of items) { process(item); };" ,
2016-10-28 04:42:46 +03:00
"replacement" : "for (let thing of things) { process(thing); };"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "while-statement" ,
"insert" : "while (a) { b(); };" ,
2016-10-28 04:42:46 +03:00
"replacement" : "while (b) { a(); };"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "do-while-statement" ,
"insert" : "do { console.log(insert); } while (true);" ,
2016-10-28 04:42:46 +03:00
"replacement" : "do { console.log(replacement); } while (false);"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "return-statement" ,
"insert" : "return 5;" ,
2016-10-28 04:42:46 +03:00
"replacement" : "return;"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "var-declaration" ,
"insert" : "var x = 1;" ,
2016-10-28 04:42:46 +03:00
"replacement" : "var x, y = {}, z;"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "comment" ,
"insert" : "// This is a property" ,
2016-10-28 04:42:46 +03:00
"replacement" : "/*\n * This is a method\n*/"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "switch-statement" ,
"insert" : "switch (1) { case 1: 1; case 2: 1; case 3: 3; };" ,
2016-10-28 04:42:46 +03:00
"replacement" : "switch (2) { case 1: 1; case 2: 2; case 3: 3; };"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "throw-statement" ,
"insert" : "throw new Error(\"uh oh\");" ,
2016-10-28 04:42:46 +03:00
"replacement" : "throw new Error(\"oooooops\");"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "try-statement" ,
"insert" : "try { f; } catch { g; } finally { h; };" ,
2016-10-28 04:42:46 +03:00
"replacement" : "try { f; } catch { h; } finally { g; };"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "regex" ,
"insert" : "/one/g;" ,
2016-10-28 04:42:46 +03:00
"replacement" : "/on[^/]afe/gim;"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "if" ,
"insert" : "if (x) { log(y); }" ,
"replacement" : "if (a.b) { log(c); d; }"
} ,
{
"syntax" : "if-else" ,
2016-10-12 22:55:59 +03:00
"insert" : "if (x) y; else if (a) b; else if (c) d; else if (e) f; else g" ,
2016-10-28 04:42:46 +03:00
"replacement" : "if (g) h; else if (i) { j; } else if (k) l; else if (m) { n; } else o"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "template-string" ,
"insert" : "`one line`" ,
2016-10-28 04:42:46 +03:00
"replacement" : "`multi line`"
2016-10-06 02:17:46 +03:00
} ,
{
"syntax" : "for-in-statement" ,
"insert" : "for (thing in things) { thing(); }" ,
2016-10-28 04:42:46 +03:00
"replacement" : "for (item in items) { item(); }"
2016-10-06 18:45:04 +03:00
} ,
{
"syntax" : "nested-functions" ,
"insert" : "function parent (arg1, arg2) { function child (arg3, arg4) { console.log(arg3); console.log(arg4); } }" ,
2016-10-28 04:42:46 +03:00
"replacement" : "function parent (arg1, arg2) { function child (arg3, arg4) { console.log(arg1); console.log(arg2); } }"
2016-10-06 18:45:04 +03:00
} ,
{
"syntax" : "nested-do-while-in-function" ,
"insert" : "function f(arg1, arg2) { do { something(arg1); } while (arg2); }" ,
2016-10-28 04:42:46 +03:00
"replacement" : "function f(arg1, arg2) { do { something(arg2); } while (arg1); }"
2016-10-07 18:20:11 +03:00
} ,
{
"syntax" : "import" ,
"insert" : "import defaultMember from \"foo\";\nimport * as name from \"aardvark\";\nimport { member } from \"ant\";\nimport { member1 , member2 } from \"antelope\";\nimport { member1 , member2 as alias2 } from \"ant-eater\";\nimport defaultMember, { member1, member2 as alias2 } from \"anaconda\";\nimport defaultMember, * as name from \"alligator\";\nimport \"arctic-tern\";" ,
"replacement" : "import defaultMember from \"babirusa\";\nimport * as otherName from \"baboon\";\nimport { element } from \"badger\";\nimport { element1 , element2 } from \"bald-eagle\";\nimport { element1 , element2 as elementAlias2 } from \"bandicoot\";\nimport defaultMember, { element1, element2 as elementAlias2 } from \"banteng\";\nimport defaultMember, * as element from \"barbet\";\nimport \"basilisk\";"
} ,
{
"syntax" : "export" ,
"insert" : "export { name1, name2, name3, nameN };\nexport { variable1 as name1, variable2 as name2, nameN };\nexport let name1, name2, nameN;\nexport let name1 = value1, name2 = value2, name3, nameN;\nexport default namedFunction;\nexport default function () { };\nexport default function name1() { };\nexport { name1 as default };\nexport * from 'foo';\nexport { name1, name2, nameN } from 'foo';\nexport { import1 as name1, import2 as name2, nameN } from 'bar';" ,
2016-10-14 21:40:07 +03:00
"replacement" : "export { name4, name5, name6, nameZ };\nexport { variable2 as name2, variable3 as name3, nameY };\nexport let name3, name4, nameT;\nexport let name2 = value2, name3 = value3, name4, nameO;\nexport default otherNamedFunction;\nexport default function newName1() {};\nexport default function () {};\nexport { name2 as statement };\nexport * from 'baz';\nexport { name7, name8, nameP } from 'buzz';\nexport { import6 as name6, import7 as name7, nameB } from 'fizz';"
2016-12-01 03:19:10 +03:00
} ,
{
"syntax" : "break" ,
"insert" : "break;" ,
"replacement" : "continue;" ,
"template" : "for (i = 0; i < 10; i++) { if (i === 4) { {0} }; i }"
} ,
{
"syntax" : "continue" ,
"insert" : "continue;" ,
"replacement" : "break;" ,
"template" : "for (i = 0; i < 10; i++) { if (i === 4) { {0} }; i }"
} ,
{
"syntax" : "yield" ,
"insert" : "yield i;" ,
"replacement" : "yield i++;" ,
"template" : "function* foo(){ var index = 0; {0} }"
2016-10-06 02:17:46 +03:00
}
]
}
]