$> node_modules/eslint/bin/eslint.js --version
v5.15.0
$> cat foo.js
"use strict";
var x = y => foo(y);
$> cat .eslintrc.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function somethingThatReturnsAPromise(x,y,z) { .. } | |
function myCallback(err,v) { | |
if (err) { | |
console.error(err); | |
} | |
else { | |
console.log(v); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fizzbuzz() { | |
for (let i = 1; i <= 100; i++) { | |
let div3 = i % 3 == 0; | |
let div5 = i % 5 == 0; | |
if (div3 && div5) { | |
console.log("FizzBuzz"); | |
} | |
else if (div3) { | |
console.log("Fizz"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let names = people.map(personToGetNameFrom => personToGetNameFrom.name); | |
// ****************** | |
let getName = person => person.name; | |
let names = people.map(getName); | |
// ****************** | |
function getName(person) { return person.name; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// function copySession(sess) { | |
// return { ...sess }; | |
// } | |
var copySession = compose( | |
reduce( | |
compose( | |
flip, | |
binary, | |
uncurry, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Foo() { | |
var [x,setX] = useState(0); | |
var [y,setY] = useState(1); | |
var cb = useCallback( | |
function printXYIfChanged() { console.log(x,y); }, | |
[x,y] | |
); | |
useEffect( | |
function pollingXY(){ | |
var intv = setInterval(cb,100); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a = "j"; // "j" | |
var b = "\\j"; // "\j" | |
var c = "\\\\j"; // "\\j" | |
var d = "\\\\\\j"; // "\\\j" | |
var e = "\\\\\\\\j"; // "\\\\j" | |
var f = "\\\\\\\\\\j"; // "\\\\\j" | |
var just_j = nonescapedRE("j"); | |
just_j.test(a); // true | |
just_j.test(b); // false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data = [ | |
{ a: 4, b: 12, c: "elderberry" }, | |
{ a: 2, b: 10, c: "cherry", d: 4 }, | |
{ a: 4, b: 12, c: "durian" }, | |
{ a: 2, b: 10, c: "cherry", }, | |
{ a: 3, b: 12, c: "durian" }, | |
{ a: 1, b: 10, c: "apple", }, | |
{ a: 1, b: 11, c: "apple", }, | |
{ a: 1, b: 11, c: "banana", }, | |
{ a: 2, b: 10, c: "banana", }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
[foo,bar] = TNG(foo,bar); | |
// NOTE: intentionally not TNG(..) wrapping useBaz(), so that it's | |
// basically like a "custom hook" that can be called only from other | |
// TNG-wrapped functions | |
function foo(origX,origY) { | |
var [x,setX] = useState(origX); | |
var [y,setY] = useState(origY); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo { | |
constructor(x) { this.foo = x; } | |
hello() { console.log(this.foo); } | |
} | |
class Bar extends Foo { | |
constructor(x) { super(x); this.bar = x * 100; } | |
world() { console.log(this.bar); } | |
} |