This file contains 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
module.exports = context => { | |
return { | |
Literal: (node) => { | |
if(node.value.match(/fuck/)) { | |
context.report({ | |
node, | |
message: 'Don\'t use the F word!' | |
}) | |
} | |
} |
This file contains 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
#!/usr/bin/env node | |
const path = require('path') | |
const execa = require('execa'); | |
const problemPackage = 'cowsay'; | |
const {devDependencies, dependencies} = require(path.resolve(__dirname, 'package.json')); | |
const problemPackageVersion = {...devDependencies, ...dependencies}[problemPackage] |
This file contains 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
const start = performance.now(); | |
interface Member { | |
name: string; | |
birthday: Date | null; | |
url: string | null; | |
instrument: string | null; | |
} | |
const john: Member = { | |
name: 'John Lennon', |
This file contains 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
<!doctype html> | |
<html> | |
<head> | |
</head> | |
<body> | |
<div id="info"></div> | |
<script> | |
const markerNameA = "example-marker-a" | |
const markerNameB = "example-marker-b" |
This file contains 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
type SupportedDomains = "google.com" | "amazon.com" | "google.co.jp" | "amazon.co.jp" | |
type USDomains = "google.com" | "amazon.com" | "facebook.com" | |
// "google.com" | "amazon.com" | |
type SupportedUSDomains = Extract<SupportedDomains, USDomains> | |
// "google.co.jp" | "amazon.co.jp" | |
type UnsupportedUSDomains = Exclude<SupportedDomains, USDomains> | |
const domain1: SupportedDomains = "google.co.jp" |
This file contains 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
console.log(Symbol('desc').description); | |
// expected output: "desc" | |
console.log(Symbol.iterator.description); | |
// expected output: "Symbol.iterator" |
This file contains 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
const regexp = /t(e)(st(\d?))/g; | |
const str = 'test1test2'; | |
const array = [...str.matchAll(regexp)]; | |
console.log(array[0]) | |
// ['test1', 'e', 'st1', '1', index: 0, input: 'test1test2', groups: undefined] | |
console.log(array[1]) | |
// ['test2', 'e', 'st2', '2', index: 5, input: 'test1test2', groups: undefined] |
This file contains 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
const entries = new Map([ | |
['foo', 'bar'], | |
['baz', 42] | |
]); | |
const obj = Object.fromEntries(entries); | |
console.log(obj); | |
// expected output: Object { foo: "bar", baz: 42 } |
This file contains 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 rtf1 = new Intl.RelativeTimeFormat('en', { style: 'narrow' }); | |
console.log(rtf1.format(3, 'quarter')); | |
//expected output: "in 3 qtrs." | |
console.log(rtf1.format(-1, 'day')); | |
//expected output: "1 day ago" | |
var rtf2 = new Intl.RelativeTimeFormat('ja', { numeric: 'auto' }); |
This file contains 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 loc = new Intl.Locale("pl-u-hc-h12", { | |
calendar: 'gregory' | |
}); | |
console.log(loc.language); // "pl" | |
console.log(loc.hourCycle); // "h12" | |
console.log(loc.calendar); // "gregory" | |
console.log(loc.toString()); // "pl-u-ca-gregory-hc-h12" |