diff --git a/.eslintrc.js b/.eslintrc.js index 45e00d3155f77b1..b5a63b2f4adaa04 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -2,49 +2,291 @@ module.exports = { env: { browser: true, es6: true, - jest: true, - node: true + node: true, }, extends: 'eslint:recommended', + parser: 'babel-eslint', parserOptions: { - ecmaVersion: 8 + ecmaVersion: 6, + sourceType: 'script', }, rules: { - 'no-global-assign': 2, - indent: [2, 4], - 'linebreak-style': [2, 'unix'], - quotes: [2, 'single'], - semi: [2, 'always'], - curly: [2, 'all'], - camelcase: [ - 2, + 'brace-style': ['error', '1tbs', { 'allowSingleLine': true }], + 'camelcase': [ + 'error', { - properties: 'always' - } + properties: 'always', + }, ], - eqeqeq: [2, 'smart'], + 'comma-spacing': 'error', + 'comma-style': 'error', + 'curly': ['error', 'all'], + 'eol-last': 'error', + 'eqeqeq': ['error', 'smart'], + 'func-call-spacing': 'error', + 'new-cap': 'warn', + 'no-array-constructor': 'error', 'no-console': [ 'error', { - allow: ['log', 'error'] + allow: ['log', 'error'], + }, + ], + 'no-new-object': 'error', + 'indent': [ + 'error', + 2, + { + 'SwitchCase': 1, } ], - 'one-var-declaration-per-line': [2, 'always'], - 'new-cap': 2 + 'key-spacing': 'error', + 'keyword-spacing': 'error', + 'linebreak-style': ['error', 'unix'], + 'no-control-regex': 'error', + 'no-else-return': 'error', + 'no-global-assign': 'error', + 'no-multiple-empty-lines': 'error', + 'no-prototype-builtins': 'off', + 'no-trailing-spaces': 'error', + 'no-var': 'error', + 'object-curly-spacing': ['error', 'always'], + 'one-var-declaration-per-line': ['error', 'always'], + 'prefer-arrow-callback': 'error', + 'prefer-template': 'error', + 'quotes': ['error', 'single'], + 'semi': ['error', 'always'], + 'space-before-function-paren': ['error', 'never'], + 'space-infix-ops': 'error', }, globals: { - Clipboard: true, - CodeMirror: true, - console: true, - expect: true, - exports: true, + SharedArrayBuffer: true, + Atomics: true, + BigInt: true, getShadowRoot: true, - module: true, - page: true, - Prism: true, - require: true, - ShadyCSS: true, - ShadyDOM: true, - test: true - } + globalThis: true, // will be supported in eslint 7.0 + }, + overrides: [ + { + files: ['**/arraybuffer/arraybuffer-isview.js'], + rules: { + 'no-unused-vars': 'off', + }, + }, + { + files: ['**/expressions/expressions-comparisonoperators.js'], + rules: { + 'eqeqeq': 'off', + }, + }, + { + files: ['**/expressions/expressions-destructuringassignment.js'], + rules: { + 'one-var-declaration-per-line': 'off', + }, + }, + { + files: ['**/expressions/expressions-newtarget.js'], + rules: { + 'new-cap': 'off', + }, + }, + { + files: ['**/expressions/expressions-operatorprecedence.js'], + rules: { + 'no-unused-vars': 'off', + }, + }, + { + files: ['**/expressions/expressions-voidoperator.js'], + rules: { + 'no-undef': 'off', + }, + }, + { + files: ['**/function/function-length.js'], + rules: { + 'no-unused-vars': 'off', + }, + }, + { + files: ['**/functions/functions-arguments.js'], + rules: { + 'no-unused-vars': 'off', + }, + }, + { + files: ['**/map/map-prototype-foreach.js'], + rules: { + 'no-unused-vars': 'off', + }, + }, + { + files: ['**/object/object-prototype-isprototypeof.js'], + rules: { + 'new-cap': 'off', + }, + }, + { + files: ['**/promise/promise-all.js'], + rules: { + 'no-unused-vars': 'off', + }, + }, + { + files: ['**/promise/promise-catch.js'], + rules: { + 'no-unused-vars': 'off', + }, + }, + { + files: ['**/promise/promise-constructor.js'], + rules: { + 'no-unused-vars': 'off', + }, + }, + { + files: ['**/promise/promise-race.js'], + rules: { + 'no-unused-vars': 'off', + }, + }, + { + files: ['**/promise/promise-reject.js'], + rules: { + 'no-unused-vars': 'off', + }, + }, + { + files: ['**/promise/promise-then.js'], + rules: { + 'no-unused-vars': 'off', + }, + }, + { + files: ['**/proxyhandler/proxyhandler-construct.js'], + rules: { + 'new-cap': 'off', + }, + }, + { + files: ['**/proxyhandler/proxyhandler-defineproperty.js'], + rules: { + 'no-unused-vars': 'off', + }, + }, + { + files: ['**/proxyhandler/proxyhandler-get.js'], + rules: { + 'no-unused-vars': 'off', + }, + }, + { + files: ['**/proxyhandler/proxyhandler-getprototypeof.js'], + rules: { + 'no-unused-vars': 'off', + }, + }, + { + files: ['**/proxyhandler/proxyhandler-setprototypeof.js'], + rules: { + 'no-unused-vars': 'off', + }, + }, + { + files: ['**/reflect/reflect-construct.js'], + rules: { + 'new-cap': 'off', + }, + }, + { + files: ['**/regexp/regexp-prototype-source.js'], + rules: { + 'no-control-regex': 'off', + }, + }, + { + files: ['**/regexp/regexp-prototype-tostring.js'], + rules: { + 'no-control-regex': 'off', + }, + }, + { + files: ['**/set/set-prototype-foreach.js'], + rules: { + 'no-unused-vars': 'off', + }, + }, + { + files: ['**/statement/statement-block.js'], + rules: { + 'no-constant-condition': 'off', + 'no-redeclare': 'off', + 'no-unused-vars': 'off', + 'no-var': 'off', + }, + }, + { + files: ['**/statement/statement-const.js'], + rules: { + 'no-const-assign': 'off', + }, + }, + { + files: ['**/statement/statement-empty.js'], + rules: { + 'curly': 'off', + }, + }, + { + files: ['**/statement/statement-trycatch.js'], + rules: { + 'no-undef': 'off', + }, + }, + { + files: ['**/statement/statement-var.js'], + rules: { + 'no-redeclare': 'off', + 'no-var': 'off', + }, + }, + { + files: ['**/symbol/symbol-unscopables.js'], + rules: { + 'no-with': 'off', + 'no-undef': 'off', + }, + }, + { + files: ['**/typedarray/typedarray-every.js'], + rules: { + 'no-unused-vars': 'off', + }, + }, + { + files: ['**/typedarray/typedarray-filter.js'], + rules: { + 'no-unused-vars': 'off', + }, + }, + { + files: ['**/typedarray/typedarray-find.js'], + rules: { + 'no-unused-vars': 'off', + }, + }, + { + files: ['**/typedarray/typedarray-findindex.js'], + rules: { + 'no-unused-vars': 'off', + }, + }, + { + files: ['**/typedarray/typedarray-some.js'], + rules: { + 'no-unused-vars': 'off', + }, + }, + ], }; diff --git a/.travis.yml b/.travis.yml index 5fddfcf1ae74966..295b9097607c34d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ branches: only: - master before_script: + - npm run lint:js - npm run build - sleep 3 # give build some time to complete deploy: diff --git a/JS-Example-Style-Guide.md b/JS-Example-Style-Guide.md index e0762036bc8316d..03e76cba07b3453 100644 --- a/JS-Example-Style-Guide.md +++ b/JS-Example-Style-Guide.md @@ -14,11 +14,11 @@ One way we could maintain a certain consistency is to use the type of the object For example: -``` +```js object1 = {}; -var string1 = “a string”; -var array1 = ['a', 'b', 'c']; -var array2 = [1, 2, 3]; +const string1 = 'a string'; +const array1 = ['a', 'b', 'c']; +const array2 = [1, 2, 3]; ``` Note that even if there is only one instance of that object, it should be suffixed with a `1`. @@ -27,7 +27,7 @@ Also note that, although we could use the same name for multiple instances, it's For example: -``` +```js const array1 = ['a', 'b', 'c']; console.log(array1); @@ -45,14 +45,14 @@ An alternative to using numerical suffixes could be to use more descriptive suff This may make more sense in the context of the following example: -``` +```js const collatorDe = new Intl.Collator('de', { usage: 'search', sensitivity: 'base' }); const collatorFr = new Intl.Collator('fr', { usage: 'search', sensitivity: 'base' }); ``` We can also use content-descriptive variable names that don't mention the type of object that they represent, for example: -``` +```js const beasts = ['ant', 'bison', 'camel', 'duck', 'bison']; ``` @@ -60,14 +60,13 @@ const beasts = ['ant', 'bison', 'camel', 'duck', 'bison']; The aim is to try and fit examples into 12 lines of code, only if it's not possible to create a useful example in 12 should we write longer examples. - ### Tangible examples When illustrating a programming concept, it is beneficial to mimic real world examples as much as possible. Once you have chosen your real world theme, stick to the theme throughout the specific example. For example: -``` +```js function monster1(disposition) { this.disposition = disposition; } @@ -87,20 +86,19 @@ console.log(new proxy1('fierce').disposition); // expected output: "fierce" ``` - ### Providing context Where possible, it is useful to provide examples showing how a method could be used in the context of a function or class. In instances where a succinct example is not possible, a series of `console.log` statements can also be a valid way of illustrating an example. ### Indicating console.log output -To indicate the ouput we expect, we place a comment `// expected output:` on the line below each `console.log`. +To indicate the output we expect, we place a comment `// expected output:` on the line below each `console.log`. ### Representing browser differences Occasionally browsers will produce different results, in these cases we can denote the varying output like so: -``` +```js console.log(matchesDe); // expected output (Chrome / Firefox): Array ["Bären"] // expected output (Safari): Array ["Bären", "Baren"] @@ -112,7 +110,7 @@ Writing code that will throw an error can be useful way to illustrate an example If you wish to use an error to illustrate a method, wrap it in a `try/catch` block for example: -``` +```js try { Intl.getCanonicalLocales('EN_US'); } catch (err) { @@ -123,30 +121,46 @@ try { ## JavaScript coding style -### Language choice (ES6) +We use ESLint to help guarantee a consistent code style. We define our configuration in /.eslintrc.js. Sometimes individual examples may need to disable certain rules: to do that use the overrides key in the configuration file. -According to the general [MDN JS guideline](https://developer.mozilla.org/en-US/docs/MDN/Contribute/Guidelines/Code_guidelines/JavaScript#Use_ES6_features), aim to use ES6 to illustrate examples. +For example, in the comparison operators' example we have to show how the `==` operator works, but our eslint configuration would throw an error. In this case, we can turn off the rule for the given file by adding the following override to the `.eslintrc.js` file + +```js +... + overrides: [ + ... + { + files: ['**/expressions/expressions-comparisonoperators.js'], + rules: { + 'eqeqeq': 'off', + }, + }, + ... + ], +... +``` -ES6 examples should use: +You can validate your example anytime by running the following npm script: -- `let` and `const` instead of `var` -- Arrow functions (`=>`) for Anonymous Functions (see below) -- Template literals (``string text ${expression} string text``) -- Spread syntax (`myFunction(...iterableObj);`) +```sh +npm run lint:js +``` + +In the rest of this section we'll describe additional conventions, not enforced using ESLint but instead using code review. -### Semi-colons +### Language choice (ES6) -There are valid arguments for and against using semi-colons. We use them. +According to the general [MDN JS guideline](https://developer.mozilla.org/en-US/docs/MDN/Contribute/Guidelines/Code_guidelines/JavaScript#Use_ES6_features), aim to use ES6 to illustrate examples. ### Line spacing -To fit the space available we try and keep examples as compact as possible, using blank lines sparingly to increase readability. +To fit the space available we try and keep examples as compact as possible, using blank lines sparingly to increase readability. One place we use a blank line is immediately preceding a `console.log` statement unless it is the first line in a block. For example: -``` +```js construct: (target, args) => { console.log('monster1 constructor called'); // expected output: " constructor called" @@ -156,184 +170,9 @@ construct: (target, args) => { ``` and -``` +```js const proxy1 = new Proxy(monster1, handler1); console.log(new proxy1('fierce').disposition); // expected output: "fierce" ``` - -### Indentation - -In order to keep things as concise as reasonably possible we indent with two spaces. - -### Instantiating an object - -Most objects are instantiated in the normal way, for example: -``` -const date1 = new Date(); -``` - -The exception being `Object` in which case we instantiate like so: - -``` -const object1 = {}; -``` - -### Instantiating an array - -We instantiate arrays in the following way: - -``` -const array1 = [2, 5, 7, 9]; -``` - -Note the spacing after the commas. - -### Passing parameters - -We use a space after commas when passing parameters to a function, but do not pad the parenthesis: i.e. - -``` -calcAngle(8, 10); -``` - -### Single quotes - -We use Single quotes to denote strings: - -``` -setTimeout(resolve, 100, 'foo'); -``` - -### Property definition - -We chose clarity over brevity when defining object properties, for example: - -``` -const object1 = { - property1: 42, - property2: 'foo' -}; -``` - -(Note the space after the colon.) - -Please do NOT put the definition on one single line: - -``` -const object1 = {property1: 42, property2: 'foo'}; -``` - -### Spaces between operators - -For example: - -``` -const a = 1 + 2; - -if (a > b) { - return a; -} -``` - -### Function definition - -Generally functions are defined with the `function` keyword at the beginning and the function name starts with a lowercase letter and can be camelCased: - -``` -function sum(a, b) { - return a + b; -} -``` - -Note the space before the opening curly brace. - -### Anonymous function definition - -Where ES6 predates the method or object we're illustrating we use the arrow function: - -``` -const sum = array1.reduce((a, b) => a + b); -``` - -rather than: - -``` -const sum = array1.reduce(function(a, b) { - return a + b; -}); -``` - -### Class definition - -As classes were introduced with ES6, we can use other ES6 concepts when defining them such as `const`. We also need to be aware of the changing scope of `this`. - -Class names should be capitalised and camelCased, for example: - -``` -class Employee { - constructor() { - this.alive = true; - } - - setSkills(skills=[]) { - const defaultSkills = ['JavaScript']; - this.skills = skills.concat(defaultSkills); - } -} -``` - -### Return early from if statements - -Only use an `else` if the preceding `if` clause doesn't return. - -For example: - -``` -if (a > b) { - return a; -} -return b; -``` - -rather than: - -``` -if (a > b) { - return a; -} else { - return b; -} -``` - -### Formatting switch statements - -``` -const expr = 'Pears'; -switch (expr) { - case 'Oranges': - console.log('Oranges are $0.59 a pound.'); - break; - case 'Apples': - console.log('Apples are $0.32 a pound.'); - break; - default: - console.log('Sorry, we are out of ' + expr + '.'); - // expected output: "Sorry, we are out of Pears." -} -``` - -### Testing for equality - -When testing for equality use Strict Equality Comparison, for example: - -``` -if (a === b) { - return a + b; -} - -if (a !== b) { - return a - b; -} -``` diff --git a/live-examples/js-examples/array/array-sort.js b/live-examples/js-examples/array/array-sort.js index fa2b34d54fccf4f..a9ffeb4c6716f97 100644 --- a/live-examples/js-examples/array/array-sort.js +++ b/live-examples/js-examples/array/array-sort.js @@ -6,4 +6,4 @@ console.log(months); const array1 = [1, 30, 4, 21, 100000]; array1.sort(); console.log(array1); -// expected output: Array [1, 100000, 21, 30, 4] +// expected output: Array [1, 100000, 21, 30, 4] diff --git a/live-examples/js-examples/array/array-tolocalestring.js b/live-examples/js-examples/array/array-tolocalestring.js index 934b027a6f57ad5..87161ce63ed153d 100644 --- a/live-examples/js-examples/array/array-tolocalestring.js +++ b/live-examples/js-examples/array/array-tolocalestring.js @@ -1,5 +1,5 @@ const array1 = [1, 'a', new Date('21 Dec 1997 14:12:00 UTC')]; -const localeString = array1.toLocaleString('en', {timeZone: "UTC"}); +const localeString = array1.toLocaleString('en', { timeZone: 'UTC' }); console.log(localeString); // expected output: "1,a,12/21/1997, 2:12:00 PM", diff --git a/live-examples/js-examples/arraybuffer/arraybuffer-slice.js b/live-examples/js-examples/arraybuffer/arraybuffer-slice.js index bc5c4fa5c34d9e3..f06ff20a6104cfc 100644 --- a/live-examples/js-examples/arraybuffer/arraybuffer-slice.js +++ b/live-examples/js-examples/arraybuffer/arraybuffer-slice.js @@ -4,7 +4,7 @@ const int32View = new Int32Array(buffer); // produces Int32Array [0, 0, 0, 0] int32View[1] = 42; -const sliced = new Int32Array(buffer.slice(4,12)); +const sliced = new Int32Array(buffer.slice(4, 12)); // produces Int32Array [42, 0] console.log(sliced[0]); diff --git a/live-examples/js-examples/bigint/bigint-asintn.js b/live-examples/js-examples/bigint/bigint-asintn.js index 4d1866117d77741..d0fbe2f91089eed 100644 --- a/live-examples/js-examples/bigint/bigint-asintn.js +++ b/live-examples/js-examples/bigint/bigint-asintn.js @@ -2,7 +2,7 @@ const max = 2n ** (64n - 1n) - 1n; function check64bit(number) { (number > max) ? - console.log("Number doesn't fit in signed 64-bit integer!") : + console.log('Number doesn\'t fit in signed 64-bit integer!') : console.log(BigInt.asIntN(64, number)); } diff --git a/live-examples/js-examples/bigint/bigint-asuintn.js b/live-examples/js-examples/bigint/bigint-asuintn.js index ba4a314b5fdcdc3..7fa13d4e3d9ffa8 100644 --- a/live-examples/js-examples/bigint/bigint-asuintn.js +++ b/live-examples/js-examples/bigint/bigint-asuintn.js @@ -2,7 +2,7 @@ const max = 2n ** 64n - 1n; function check64bit(number) { (number > max) ? - console.log("Number doesn't fit in unsigned 64-bit integer!") : + console.log('Number doesn\'t fit in unsigned 64-bit integer!') : console.log(BigInt.asUintN(64, number)); } diff --git a/live-examples/js-examples/boolean/boolean-valueof.js b/live-examples/js-examples/boolean/boolean-valueof.js index fb71f3c3232e9cb..7421e07c78658fc 100644 --- a/live-examples/js-examples/boolean/boolean-valueof.js +++ b/live-examples/js-examples/boolean/boolean-valueof.js @@ -3,7 +3,7 @@ const x = new Boolean(); console.log(x.valueOf()); // expected output: false -const y = new Boolean("Mozilla"); +const y = new Boolean('Mozilla'); console.log(y.valueOf()); // expected output: true diff --git a/live-examples/js-examples/classes/classes-constructor.js b/live-examples/js-examples/classes/classes-constructor.js index 8bc526cf42f660e..614db8d7d04fc18 100644 --- a/live-examples/js-examples/classes/classes-constructor.js +++ b/live-examples/js-examples/classes/classes-constructor.js @@ -1,6 +1,6 @@ class Polygon { constructor() { - this.name = "Polygon"; + this.name = 'Polygon'; } } diff --git a/live-examples/js-examples/classes/classes-extends.js b/live-examples/js-examples/classes/classes-extends.js index c7119e7e254d7ef..61fc5fc9c5b5487 100644 --- a/live-examples/js-examples/classes/classes-extends.js +++ b/live-examples/js-examples/classes/classes-extends.js @@ -1,12 +1,12 @@ -class formatDate extends Date { +class DateFormatter extends Date { getFormattedDate() { const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', - 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; + 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; return `${this.getDate()}-${months[this.getMonth()]}-${this.getFullYear()}`; } } -console.log(new formatDate('August 19, 1975 23:15:30').getFormattedDate()); +console.log(new DateFormatter('August 19, 1975 23:15:30').getFormattedDate()); // expected output: "19-Aug-1975" diff --git a/live-examples/js-examples/dataview/dataview-bytelength.js b/live-examples/js-examples/dataview/dataview-bytelength.js index bec451ead5ee782..e73e2bfb11424cf 100644 --- a/live-examples/js-examples/dataview/dataview-bytelength.js +++ b/live-examples/js-examples/dataview/dataview-bytelength.js @@ -2,7 +2,7 @@ const buffer = new ArrayBuffer(16); const view1 = new DataView(buffer); -const view2 = new DataView(buffer,12,4); //from byte 12 for the next 4 bytes +const view2 = new DataView(buffer, 12, 4); //from byte 12 for the next 4 bytes console.log(view1.byteLength + view2.byteLength); // 16 + 4 // expected output: 20 diff --git a/live-examples/js-examples/dataview/dataview-byteoffset.js b/live-examples/js-examples/dataview/dataview-byteoffset.js index 250a7820765c4ca..7079be583d885ec 100644 --- a/live-examples/js-examples/dataview/dataview-byteoffset.js +++ b/live-examples/js-examples/dataview/dataview-byteoffset.js @@ -1,7 +1,7 @@ // create an ArrayBuffer with a size in bytes const buffer = new ArrayBuffer(16); -const view = new DataView(buffer,12,4); //from byte 12 for the next 4 bytes +const view = new DataView(buffer, 12, 4); //from byte 12 for the next 4 bytes console.log(view.byteOffset); // expected output: 12 diff --git a/live-examples/js-examples/dataview/dataview-constructor.js b/live-examples/js-examples/dataview/dataview-constructor.js index 76c46c5084a0641..e436ce99a9fbab7 100644 --- a/live-examples/js-examples/dataview/dataview-constructor.js +++ b/live-examples/js-examples/dataview/dataview-constructor.js @@ -3,7 +3,7 @@ const buffer = new ArrayBuffer(16); // Create a couple of views const view1 = new DataView(buffer); -const view2 = new DataView(buffer,12,4); //from byte 12 for the next 4 bytes +const view2 = new DataView(buffer, 12, 4); //from byte 12 for the next 4 bytes view1.setInt8(12, 42); // put 42 in slot 12 console.log(view2.getInt8(0)); diff --git a/live-examples/js-examples/dataview/dataview-getbigint64.js b/live-examples/js-examples/dataview/dataview-getbigint64.js index 55d2042fc97acf3..d36e7524c904be2 100644 --- a/live-examples/js-examples/dataview/dataview-getbigint64.js +++ b/live-examples/js-examples/dataview/dataview-getbigint64.js @@ -2,7 +2,7 @@ const buffer = new ArrayBuffer(16); // Highest possible BigInt value that fits in a signed 64-bit integer -const max = 2n ** (64n -1n) - 1n; +const max = 2n ** (64n - 1n) - 1n; const view = new DataView(buffer); view.setBigInt64(1, max); diff --git a/live-examples/js-examples/dataview/dataview-setbigint64.js b/live-examples/js-examples/dataview/dataview-setbigint64.js index 55d2042fc97acf3..d36e7524c904be2 100644 --- a/live-examples/js-examples/dataview/dataview-setbigint64.js +++ b/live-examples/js-examples/dataview/dataview-setbigint64.js @@ -2,7 +2,7 @@ const buffer = new ArrayBuffer(16); // Highest possible BigInt value that fits in a signed 64-bit integer -const max = 2n ** (64n -1n) - 1n; +const max = 2n ** (64n - 1n) - 1n; const view = new DataView(buffer); view.setBigInt64(1, max); diff --git a/live-examples/js-examples/date/date-now.js b/live-examples/js-examples/date/date-now.js index 979948b3c2a5a01..0c71d894605e92c 100644 --- a/live-examples/js-examples/date/date-now.js +++ b/live-examples/js-examples/date/date-now.js @@ -7,6 +7,6 @@ console.log('starting timer...'); setTimeout(() => { const millis = Date.now() - start; - console.log(`seconds elapsed = ${Math.floor(millis/1000)}`); + console.log(`seconds elapsed = ${Math.floor(millis / 1000)}`); // expected output : seconds elapsed = 2 }, 2000); diff --git a/live-examples/js-examples/date/date-sethours.js b/live-examples/js-examples/date/date-sethours.js index 607b2b40f35bf24..3f0a4ae461fb9e4 100644 --- a/live-examples/js-examples/date/date-sethours.js +++ b/live-examples/js-examples/date/date-sethours.js @@ -5,7 +5,7 @@ console.log(event); // expected output: Tue Aug 19 1975 20:15:30 GMT+0200 (CEST) // (note: your timezone may vary) -event.setHours(20,21,22); +event.setHours(20, 21, 22); console.log(event); // expected output: Tue Aug 19 1975 20:21:22 GMT+0200 (CEST) diff --git a/live-examples/js-examples/date/date-toprimitive.js b/live-examples/js-examples/date/date-toprimitive.js index c3365d8c1293250..31edc4c4a08bd87 100644 --- a/live-examples/js-examples/date/date-toprimitive.js +++ b/live-examples/js-examples/date/date-toprimitive.js @@ -6,5 +6,3 @@ console.log(date[Symbol.toPrimitive]('string')); console.log(date[Symbol.toPrimitive]('number')); // expected output: 1576833480000 - - \ No newline at end of file diff --git a/live-examples/js-examples/expressions/expressions-classexpression.js b/live-examples/js-examples/expressions/expressions-classexpression.js index e007214462051d7..c656c3612ac9f74 100644 --- a/live-examples/js-examples/expressions/expressions-classexpression.js +++ b/live-examples/js-examples/expressions/expressions-classexpression.js @@ -6,7 +6,7 @@ const Rectangle = class { area() { return this.height * this.width; } -} +}; -console.log(new Rectangle(5,8).area()); +console.log(new Rectangle(5, 8).area()); // expected output: 40 diff --git a/live-examples/js-examples/expressions/expressions-deleteoperator.js b/live-examples/js-examples/expressions/expressions-deleteoperator.js index a4dbfeb4c8e3152..8803e0f0688ff94 100644 --- a/live-examples/js-examples/expressions/expressions-deleteoperator.js +++ b/live-examples/js-examples/expressions/expressions-deleteoperator.js @@ -1,7 +1,7 @@ const Employee = { firstname: 'John', lastname: 'Doe' -} +}; console.log(Employee.firstname); // expected output: "John" diff --git a/live-examples/js-examples/expressions/expressions-functionexpression.js b/live-examples/js-examples/expressions/expressions-functionexpression.js index 9efdc0724187bbf..946fad822b988ff 100644 --- a/live-examples/js-examples/expressions/expressions-functionexpression.js +++ b/live-examples/js-examples/expressions/expressions-functionexpression.js @@ -1,6 +1,6 @@ const getRectArea = function(width, height) { return width * height; -} +}; -console.log(getRectArea(3,4)); +console.log(getRectArea(3, 4)); // expected output: 12 diff --git a/live-examples/js-examples/expressions/expressions-inoperator.js b/live-examples/js-examples/expressions/expressions-inoperator.js index 9b205caea0aa5bf..856a8e699580b75 100644 --- a/live-examples/js-examples/expressions/expressions-inoperator.js +++ b/live-examples/js-examples/expressions/expressions-inoperator.js @@ -1,4 +1,4 @@ -const car = {make: 'Honda', model: 'Accord', year: 1998}; +const car = { make: 'Honda', model: 'Accord', year: 1998 }; console.log('make' in car); // expected output: true diff --git a/live-examples/js-examples/expressions/expressions-newtarget.js b/live-examples/js-examples/expressions/expressions-newtarget.js index 8228cb39b28198b..763e6b0723505f7 100644 --- a/live-examples/js-examples/expressions/expressions-newtarget.js +++ b/live-examples/js-examples/expressions/expressions-newtarget.js @@ -1,11 +1,10 @@ function Foo() { - if (!new.target) throw 'Foo() must be called with new'; + if (!new.target) { throw 'Foo() must be called with new'; } } try { Foo(); -} -catch(e) { +} catch (e) { console.log(e); // expected output: "Foo() must be called with new" } diff --git a/live-examples/js-examples/expressions/expressions-objectinitializer.js b/live-examples/js-examples/expressions/expressions-objectinitializer.js index b6cd767391f4dcf..530ee93f13e8698 100644 --- a/live-examples/js-examples/expressions/expressions-objectinitializer.js +++ b/live-examples/js-examples/expressions/expressions-objectinitializer.js @@ -1,4 +1,4 @@ -const object1 = {a: 'foo', b: 42, c: {}}; +const object1 = { a: 'foo', b: 42, c: {} }; console.log(object1.a); // expected output: "foo" @@ -6,12 +6,12 @@ console.log(object1.a); const a = 'foo'; const b = 42; const c = {}; -const object2 = {a: a, b: b, c: c}; +const object2 = { a: a, b: b, c: c }; console.log(object2.b); // expected output: 42 -const object3 = {a, b, c}; +const object3 = { a, b, c }; console.log(object3.a); // expected output: "foo" diff --git a/live-examples/js-examples/expressions/expressions-optionalchainingoperator.js b/live-examples/js-examples/expressions/expressions-optionalchainingoperator.js index 9411a5e70c30e5a..7de691474acd4e9 100644 --- a/live-examples/js-examples/expressions/expressions-optionalchainingoperator.js +++ b/live-examples/js-examples/expressions/expressions-optionalchainingoperator.js @@ -9,5 +9,5 @@ const dogName = adventurer.dog?.name; console.log(dogName); // expected output: undefined -console.log(adventurer.someNonExistentMethod?.()) +console.log(adventurer.someNonExistentMethod?.()); // expected output: undefined diff --git a/live-examples/js-examples/expressions/expressions-voidoperator.js b/live-examples/js-examples/expressions/expressions-voidoperator.js index bfeb9d2c69f8ee8..b88f4307c5606ea 100644 --- a/live-examples/js-examples/expressions/expressions-voidoperator.js +++ b/live-examples/js-examples/expressions/expressions-voidoperator.js @@ -5,8 +5,7 @@ void function test() { try { test(); -} -catch(e) { +} catch (e) { console.log(e); // expected output: ReferenceError: test is not defined } diff --git a/live-examples/js-examples/function/function-bind.js b/live-examples/js-examples/function/function-bind.js index d9f243a2f6461a0..e5e1022d9ebabbb 100644 --- a/live-examples/js-examples/function/function-bind.js +++ b/live-examples/js-examples/function/function-bind.js @@ -3,7 +3,7 @@ const module = { getX: function() { return this.x; } -} +}; const unboundGetX = module.getX; console.log(unboundGetX()); // The function gets invoked at the global scope diff --git a/live-examples/js-examples/function/function-name.js b/live-examples/js-examples/function/function-name.js index d975e0c97bc71b4..89ed87b1130dd53 100644 --- a/live-examples/js-examples/function/function-name.js +++ b/live-examples/js-examples/function/function-name.js @@ -1,8 +1,8 @@ -const func1 = function() {} - +const func1 = function() {}; + const object = { func2: function() {} -} +}; console.log(func1.name); // expected output: "func1" diff --git a/live-examples/js-examples/functions/functions-definitions.js b/live-examples/js-examples/functions/functions-definitions.js index 3c1f499288aa2a0..7d099e93a4abda4 100644 --- a/live-examples/js-examples/functions/functions-definitions.js +++ b/live-examples/js-examples/functions/functions-definitions.js @@ -2,7 +2,7 @@ const obj = { foo() { return 'bar'; } -} +}; console.log(obj.foo()); // expected output: "bar" diff --git a/live-examples/js-examples/functions/functions-getter.js b/live-examples/js-examples/functions/functions-getter.js index 7d62e553fe7ec46..d0419054ada369d 100644 --- a/live-examples/js-examples/functions/functions-getter.js +++ b/live-examples/js-examples/functions/functions-getter.js @@ -1,12 +1,12 @@ const obj = { log: ['a', 'b', 'c'], get latest() { - if (this.log.length == 0) { + if (this.log.length === 0) { return undefined; } return this.log[this.log.length - 1]; } -} +}; console.log(obj.latest); // expected output: "c" diff --git a/live-examples/js-examples/functions/functions-setter.js b/live-examples/js-examples/functions/functions-setter.js index 34e9e442f1412b7..6380cca39488e38 100644 --- a/live-examples/js-examples/functions/functions-setter.js +++ b/live-examples/js-examples/functions/functions-setter.js @@ -3,7 +3,7 @@ const language = { this.log.push(name); }, log: [] -} +}; language.current = 'EN'; language.current = 'FA'; diff --git a/live-examples/js-examples/globalprops/globalprops-decodeuri.js b/live-examples/js-examples/globalprops/globalprops-decodeuri.js index 98d63e32aa597bc..15a27119cf165d6 100644 --- a/live-examples/js-examples/globalprops/globalprops-decodeuri.js +++ b/live-examples/js-examples/globalprops/globalprops-decodeuri.js @@ -6,6 +6,6 @@ console.log(encoded); try { console.log(decodeURI(encoded)); // expected output: "https://mozilla.org/?x=шеллы" -} catch(e) { // catches a malformed URI +} catch (e) { // catches a malformed URI console.error(e); } diff --git a/live-examples/js-examples/globalprops/globalprops-encodeuri.js b/live-examples/js-examples/globalprops/globalprops-encodeuri.js index ae736e516096a30..233198668d55d11 100644 --- a/live-examples/js-examples/globalprops/globalprops-encodeuri.js +++ b/live-examples/js-examples/globalprops/globalprops-encodeuri.js @@ -6,7 +6,7 @@ console.log(encoded); try { console.log(decodeURI(encoded)); // expected output: "https://mozilla.org/?x=шеллы" -} catch(e) { // catches a malformed URI +} catch (e) { // catches a malformed URI console.error(e); } diff --git a/live-examples/js-examples/globalprops/globalprops-globalthis.js b/live-examples/js-examples/globalprops/globalprops-globalthis.js index 194641fbd1824dd..be2980ca8b93c15 100644 --- a/live-examples/js-examples/globalprops/globalprops-globalthis.js +++ b/live-examples/js-examples/globalprops/globalprops-globalthis.js @@ -1,5 +1,5 @@ function canMakeHTTPRequest() { - return typeof globalThis.XMLHttpRequest === 'function'; + return typeof globalThis.XMLHttpRequest === 'function'; } console.log(canMakeHTTPRequest()); diff --git a/live-examples/js-examples/globalprops/globalprops-infinity.js b/live-examples/js-examples/globalprops/globalprops-infinity.js index f54dd620a6cfac8..48799689b7ed63e 100644 --- a/live-examples/js-examples/globalprops/globalprops-infinity.js +++ b/live-examples/js-examples/globalprops/globalprops-infinity.js @@ -1,7 +1,7 @@ const maxNumber = Math.pow(10, 1000); // max positive number if (maxNumber === Infinity) { - console.log("Let's call it Infinity!"); + console.log('Let\'s call it Infinity!'); // expected output: "Let's call it Infinity!" } diff --git a/live-examples/js-examples/globalprops/globalprops-isfinite.js b/live-examples/js-examples/globalprops/globalprops-isfinite.js index f84f0479cc8da91..06337dc9f109e70 100644 --- a/live-examples/js-examples/globalprops/globalprops-isfinite.js +++ b/live-examples/js-examples/globalprops/globalprops-isfinite.js @@ -2,7 +2,7 @@ function div(x) { if (isFinite(1000 / x)) { return 'Number is NOT Infinity.'; } - return "Number is Infinity!"; + return 'Number is Infinity!'; } console.log(div(0)); diff --git a/live-examples/js-examples/globalprops/globalprops-parseint.js b/live-examples/js-examples/globalprops/globalprops-parseint.js index 051e40d050dc7cd..c677598f4bcce9d 100644 --- a/live-examples/js-examples/globalprops/globalprops-parseint.js +++ b/live-examples/js-examples/globalprops/globalprops-parseint.js @@ -1,6 +1,6 @@ function roughScale(x, base) { const parsed = parseInt(x, base); - if (isNaN(parsed)) { return 0 } + if (isNaN(parsed)) { return 0; } return parsed * 100; } diff --git a/live-examples/js-examples/globalprops/globalprops-undefined.js b/live-examples/js-examples/globalprops/globalprops-undefined.js index 0c8d25331ac7831..338067f4a307581 100644 --- a/live-examples/js-examples/globalprops/globalprops-undefined.js +++ b/live-examples/js-examples/globalprops/globalprops-undefined.js @@ -1,6 +1,6 @@ function test(t) { if (t === undefined) { - return 'Undefined value!'; + return 'Undefined value!'; } return t; } diff --git a/live-examples/js-examples/intl/intl-collator.js b/live-examples/js-examples/intl/intl-collator.js index 10117e86f5eb1c0..ac05fecdedec3ac 100644 --- a/live-examples/js-examples/intl/intl-collator.js +++ b/live-examples/js-examples/intl/intl-collator.js @@ -3,8 +3,8 @@ function letterSort(lang, letters) { return letters; } -console.log(letterSort('de', ['a','z','ä'])); +console.log(letterSort('de', ['a', 'z', 'ä'])); // expected output: Array ["a", "ä", "z"] -console.log(letterSort('sv', ['a','z','ä'])); +console.log(letterSort('sv', ['a', 'z', 'ä'])); // expected output: Array ["a", "z", "ä"] diff --git a/live-examples/js-examples/intl/intl-datetimeformat-prototype-format.js b/live-examples/js-examples/intl/intl-datetimeformat-prototype-format.js index d4d931f993e11e2..0f7adbcbf524a9c 100644 --- a/live-examples/js-examples/intl/intl-datetimeformat-prototype-format.js +++ b/live-examples/js-examples/intl/intl-datetimeformat-prototype-format.js @@ -1,5 +1,5 @@ const options1 = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }; -const date1 = new Date(2012, 05); +const date1 = new Date(2012, 5); const dateTimeFormat1 = new Intl.DateTimeFormat('sr-RS', options1); console.log(dateTimeFormat1.format(date1)); diff --git a/live-examples/js-examples/intl/intl-datetimeformat-prototype-formatrangetoparts.js b/live-examples/js-examples/intl/intl-datetimeformat-prototype-formatrangetoparts.js index 8069b4dfe6cd565..891366e15bd9c85 100644 --- a/live-examples/js-examples/intl/intl-datetimeformat-prototype-formatrangetoparts.js +++ b/live-examples/js-examples/intl/intl-datetimeformat-prototype-formatrangetoparts.js @@ -1,9 +1,9 @@ const startDate = new Date(Date.UTC(2007, 0, 10, 10, 0, 0)); // > 'Wed, 10 Jan 2007 10:00:00 GMT' const endDate = new Date(Date.UTC(2007, 0, 10, 11, 0, 0)); // > 'Wed, 10 Jan 2007 11:00:00 GMT' -const dateTimeFormat = new Intl.DateTimeFormat("en", { - hour: 'numeric', - minute: 'numeric' +const dateTimeFormat = new Intl.DateTimeFormat('en', { + hour: 'numeric', + minute: 'numeric' }); const parts = dateTimeFormat.formatRangeToParts(startDate, endDate); diff --git a/live-examples/js-examples/intl/intl-locale-prototype-maximize.js b/live-examples/js-examples/intl/intl-locale-prototype-maximize.js index 4c0e1fcd5ba715f..86e89f3b95ca8df 100644 --- a/live-examples/js-examples/intl/intl-locale-prototype-maximize.js +++ b/live-examples/js-examples/intl/intl-locale-prototype-maximize.js @@ -9,4 +9,4 @@ console.log(korean.maximize().baseName); // expected output: "ko-Kore-KR" console.log(arabic.maximize().baseName); -// expected output: "ar-Arab-EG" \ No newline at end of file +// expected output: "ar-Arab-EG" diff --git a/live-examples/js-examples/intl/intl-locale-prototype-minimize.js b/live-examples/js-examples/intl/intl-locale-prototype-minimize.js index 1db840660f66210..acf2b7eceff5085 100644 --- a/live-examples/js-examples/intl/intl-locale-prototype-minimize.js +++ b/live-examples/js-examples/intl/intl-locale-prototype-minimize.js @@ -10,4 +10,3 @@ console.log(korean.minimize().baseName); console.log(arabic.minimize().baseName); // expected output: "ar" - diff --git a/live-examples/js-examples/intl/intl-locale-prototype-tostring.js b/live-examples/js-examples/intl/intl-locale-prototype-tostring.js index 91a92821ec44838..ef2cf15fb6e4df6 100644 --- a/live-examples/js-examples/intl/intl-locale-prototype-tostring.js +++ b/live-examples/js-examples/intl/intl-locale-prototype-tostring.js @@ -4,5 +4,5 @@ const korean = new Intl.Locale('ko-Kore-KR', { numeric: true, caseFirst: 'upper' console.log(french.toString()); // expected output: "fr-Latn-FR-u-ca-gregory-hc-h24" -console.log(korean.toString()) -//expected output: "ko-Kore-KR-u-kf-upper-kn" \ No newline at end of file +console.log(korean.toString()); +//expected output: "ko-Kore-KR-u-kf-upper-kn" diff --git a/live-examples/js-examples/intl/intl-locale.js b/live-examples/js-examples/intl/intl-locale.js index ab3889c1b665236..f6c9f2664da5564 100644 --- a/live-examples/js-examples/intl/intl-locale.js +++ b/live-examples/js-examples/intl/intl-locale.js @@ -8,4 +8,4 @@ console.log(korean.baseName, japanese.baseName); // expected output: "ko-Kore-KR" "ja-Jpan-JP" console.log(korean.hourCycle, japanese.hourCycle); -// expected output: "h24" "h12" \ No newline at end of file +// expected output: "h24" "h12" diff --git a/live-examples/js-examples/math/math-e.js b/live-examples/js-examples/math/math-e.js index 8acf84c73fa9345..2b47fab5207c734 100644 --- a/live-examples/js-examples/math/math-e.js +++ b/live-examples/js-examples/math/math-e.js @@ -5,7 +5,7 @@ function compoundOneYear(interestRate, currentVal) { console.log(Math.E); // expected output: 2.718281828459045 -console.log((1 + (1/1000000)) ** 1000000); +console.log((1 + (1 / 1000000)) ** 1000000); // expected output: 2.718280469 (approximately) console.log(compoundOneYear(0.05, 100)); diff --git a/live-examples/js-examples/math/math-sqrt.js b/live-examples/js-examples/math/math-sqrt.js index 6808b6ec9dd9d4f..3d5de80dc4d17cb 100644 --- a/live-examples/js-examples/math/math-sqrt.js +++ b/live-examples/js-examples/math/math-sqrt.js @@ -1,5 +1,5 @@ function calcHypotenuse(a, b) { - return(Math.sqrt((a * a) + (b * b))); + return (Math.sqrt((a * a) + (b * b))); } console.log(calcHypotenuse(3, 4)); diff --git a/live-examples/js-examples/math/math-tan.js b/live-examples/js-examples/math/math-tan.js index 20e63e9dc7f0a35..8ff930635df2844 100644 --- a/live-examples/js-examples/math/math-tan.js +++ b/live-examples/js-examples/math/math-tan.js @@ -1,5 +1,5 @@ function getTanFromDegrees(degrees) { - return Math.tan(degrees * Math.PI/180); + return Math.tan(degrees * Math.PI / 180); } console.log(getTanFromDegrees(0)); diff --git a/live-examples/js-examples/number/number-isfinite.js b/live-examples/js-examples/number/number-isfinite.js index 7236325e2ffa365..aba775f673a8956 100644 --- a/live-examples/js-examples/number/number-isfinite.js +++ b/live-examples/js-examples/number/number-isfinite.js @@ -1,8 +1,8 @@ -console.log(Number.isFinite(1/0)); +console.log(Number.isFinite(1 / 0)); // expected output: false -console.log(Number.isFinite(10/5)); +console.log(Number.isFinite(10 / 5)); // expected output: true -console.log(Number.isFinite(0/0)); +console.log(Number.isFinite(0 / 0)); // expected output: false diff --git a/live-examples/js-examples/number/number-max-value.js b/live-examples/js-examples/number/number-max-value.js index 2d76c3d41d7ab04..133453b7ccf43ab 100644 --- a/live-examples/js-examples/number/number-max-value.js +++ b/live-examples/js-examples/number/number-max-value.js @@ -1,6 +1,6 @@ function multiply(x, y) { if (x * y > Number.MAX_VALUE) { - return ("Process as Infinity"); + return ('Process as Infinity'); } return (x * y); } diff --git a/live-examples/js-examples/number/number-min-value.js b/live-examples/js-examples/number/number-min-value.js index 424062990a78262..64cf144b09a41d5 100644 --- a/live-examples/js-examples/number/number-min-value.js +++ b/live-examples/js-examples/number/number-min-value.js @@ -1,6 +1,6 @@ function multiply(x, y) { if (x * y < Number.MIN_VALUE) { - return "Process as -Infinity"; + return 'Process as -Infinity'; } return (x * y); } diff --git a/live-examples/js-examples/number/number-tolocalestring.js b/live-examples/js-examples/number/number-tolocalestring.js index 108053afcb2b3f8..29de443a733e341 100644 --- a/live-examples/js-examples/number/number-tolocalestring.js +++ b/live-examples/js-examples/number/number-tolocalestring.js @@ -5,7 +5,7 @@ function eArabic(x){ console.log(eArabic(123456.789)); // expected output: "١٢٣٬٤٥٦٫٧٨٩" -console.log(eArabic("123456.789")); +console.log(eArabic('123456.789')); // expected output: "123456.789" console.log(eArabic(NaN)); diff --git a/live-examples/js-examples/object/object-create.js b/live-examples/js-examples/object/object-create.js index 3a8f0357cb653bd..71da4aa4d6d84b2 100644 --- a/live-examples/js-examples/object/object-create.js +++ b/live-examples/js-examples/object/object-create.js @@ -1,13 +1,13 @@ const person = { isHuman: false, - printIntroduction: function () { + printIntroduction: function() { console.log(`My name is ${this.name}. Am I human? ${this.isHuman}`); } }; const me = Object.create(person); -me.name = "Matthew"; // "name" is a property set on "me", but not on "person" +me.name = 'Matthew'; // "name" is a property set on "me", but not on "person" me.isHuman = true; // inherited properties can be overwritten me.printIntroduction(); diff --git a/live-examples/js-examples/object/object-getownpropertydescriptor.js b/live-examples/js-examples/object/object-getownpropertydescriptor.js index 2e59689f21d4b9b..9dbb54d885d1e4b 100644 --- a/live-examples/js-examples/object/object-getownpropertydescriptor.js +++ b/live-examples/js-examples/object/object-getownpropertydescriptor.js @@ -1,6 +1,6 @@ const object1 = { property1: 42 -} +}; const descriptor1 = Object.getOwnPropertyDescriptor(object1, 'property1'); diff --git a/live-examples/js-examples/object/object-prototype-hasownproperty.js b/live-examples/js-examples/object/object-prototype-hasownproperty.js index e19ae797e1534e0..1333811f78fbc10 100644 --- a/live-examples/js-examples/object/object-prototype-hasownproperty.js +++ b/live-examples/js-examples/object/object-prototype-hasownproperty.js @@ -1,4 +1,4 @@ -const object1 = new Object(); +const object1 = {}; object1.property1 = 42; console.log(object1.hasOwnProperty('property1')); diff --git a/live-examples/js-examples/object/object-prototype-tostring.js b/live-examples/js-examples/object/object-prototype-tostring.js index f59cf77ebd48a9f..7a1d804a60f1dc6 100644 --- a/live-examples/js-examples/object/object-prototype-tostring.js +++ b/live-examples/js-examples/object/object-prototype-tostring.js @@ -5,8 +5,8 @@ function Dog(name) { const dog1 = new Dog('Gabby'); Dog.prototype.toString = function dogToString() { - return '' + this.name; -} + return `${this.name}`; +}; console.log(dog1.toString()); // expected output: "Gabby" diff --git a/live-examples/js-examples/promise/promise-all.js b/live-examples/js-examples/promise/promise-all.js index 03112fc7bc51d4f..501bbcf20ad75ef 100644 --- a/live-examples/js-examples/promise/promise-all.js +++ b/live-examples/js-examples/promise/promise-all.js @@ -1,10 +1,10 @@ const promise1 = Promise.resolve(3); const promise2 = 42; -const promise3 = new Promise(function(resolve, reject) { +const promise3 = new Promise((resolve, reject) => { setTimeout(resolve, 100, 'foo'); }); -Promise.all([promise1, promise2, promise3]).then(function(values) { +Promise.all([promise1, promise2, promise3]).then((values) => { console.log(values); }); // expected output: Array [3, 42, "foo"] diff --git a/live-examples/js-examples/promise/promise-catch.js b/live-examples/js-examples/promise/promise-catch.js index d3cd55370828444..459636b1f93e32a 100644 --- a/live-examples/js-examples/promise/promise-catch.js +++ b/live-examples/js-examples/promise/promise-catch.js @@ -1,8 +1,8 @@ -const promise1 = new Promise(function(resolve, reject) { +const promise1 = new Promise((resolve, reject) => { throw 'Uh-oh!'; }); -promise1.catch(function(error) { +promise1.catch((error) => { console.error(error); }); // expected output: Uh-oh! diff --git a/live-examples/js-examples/promise/promise-constructor.js b/live-examples/js-examples/promise/promise-constructor.js index 2298717d7f54ae1..e8a9ac7c5a00d9f 100644 --- a/live-examples/js-examples/promise/promise-constructor.js +++ b/live-examples/js-examples/promise/promise-constructor.js @@ -1,10 +1,10 @@ -const promise1 = new Promise(function(resolve, reject) { - setTimeout(function() { +const promise1 = new Promise((resolve, reject) => { + setTimeout(() => { resolve('foo'); }, 300); }); -promise1.then(function(value) { +promise1.then((value) => { console.log(value); // expected output: "foo" }); diff --git a/live-examples/js-examples/promise/promise-race.js b/live-examples/js-examples/promise/promise-race.js index 83d117b4cd067f5..fe4b964e7be804e 100644 --- a/live-examples/js-examples/promise/promise-race.js +++ b/live-examples/js-examples/promise/promise-race.js @@ -1,12 +1,12 @@ -const promise1 = new Promise(function(resolve, reject) { - setTimeout(resolve, 500, 'one'); +const promise1 = new Promise((resolve, reject) => { + setTimeout(resolve, 500, 'one'); }); -const promise2 = new Promise(function(resolve, reject) { - setTimeout(resolve, 100, 'two'); +const promise2 = new Promise((resolve, reject) => { + setTimeout(resolve, 100, 'two'); }); -Promise.race([promise1, promise2]).then(function(value) { +Promise.race([promise1, promise2]).then((value) => { console.log(value); // Both resolve, but promise2 is faster }); diff --git a/live-examples/js-examples/promise/promise-resolve.js b/live-examples/js-examples/promise/promise-resolve.js index d3bf7ee7a05f178..89481201a1115c4 100644 --- a/live-examples/js-examples/promise/promise-resolve.js +++ b/live-examples/js-examples/promise/promise-resolve.js @@ -1,6 +1,6 @@ const promise1 = Promise.resolve(123); -promise1.then(function(value) { +promise1.then((value) => { console.log(value); // expected output: 123 }); diff --git a/live-examples/js-examples/promise/promise-then.js b/live-examples/js-examples/promise/promise-then.js index c47c36a05aa7e60..ee93852fc69599c 100644 --- a/live-examples/js-examples/promise/promise-then.js +++ b/live-examples/js-examples/promise/promise-then.js @@ -1,8 +1,8 @@ -const promise1 = new Promise(function(resolve, reject) { +const promise1 = new Promise((resolve, reject) => { resolve('Success!'); }); -promise1.then(function(value) { +promise1.then((value) => { console.log(value); // expected output: "Success!" }); diff --git a/live-examples/js-examples/proxyhandler/proxyhandler-get.js b/live-examples/js-examples/proxyhandler/proxyhandler-get.js index 365043801fb9b69..fdac0547cf93849 100644 --- a/live-examples/js-examples/proxyhandler/proxyhandler-get.js +++ b/live-examples/js-examples/proxyhandler/proxyhandler-get.js @@ -7,9 +7,8 @@ const handler1 = { get: function(target, prop, receiver) { if (prop === 'secret') { return `${target.secret.substr(0, 4)} ... shhhh!`; - } else { - return Reflect.get(...arguments); } + return Reflect.get(...arguments); } }; diff --git a/live-examples/js-examples/proxyhandler/proxyhandler-getprototypeof.js b/live-examples/js-examples/proxyhandler/proxyhandler-getprototypeof.js index 4acfc142a92a431..ca6bc5015b08374 100644 --- a/live-examples/js-examples/proxyhandler/proxyhandler-getprototypeof.js +++ b/live-examples/js-examples/proxyhandler/proxyhandler-getprototypeof.js @@ -3,7 +3,7 @@ const monster1 = { }; const monsterPrototype = { - eyeCount : 2 + eyeCount: 2 }; const handler = { diff --git a/live-examples/js-examples/proxyhandler/proxyhandler-has.js b/live-examples/js-examples/proxyhandler/proxyhandler-has.js index 65239696236565b..92eeadb8fb26c85 100644 --- a/live-examples/js-examples/proxyhandler/proxyhandler-has.js +++ b/live-examples/js-examples/proxyhandler/proxyhandler-has.js @@ -1,5 +1,5 @@ const handler1 = { - has (target, key) { + has(target, key) { if (key[0] === '_') { return false; } diff --git a/live-examples/js-examples/proxyhandler/proxyhandler-ownkeys.js b/live-examples/js-examples/proxyhandler/proxyhandler-ownkeys.js index d02489cd8c47626..b9460d1e827bc32 100644 --- a/live-examples/js-examples/proxyhandler/proxyhandler-ownkeys.js +++ b/live-examples/js-examples/proxyhandler/proxyhandler-ownkeys.js @@ -2,13 +2,13 @@ const monster1 = { _age: 111, [Symbol('secret')]: 'I am scared!', eyeCount: 4 -} +}; const handler1 = { - ownKeys (target) { - return Reflect.ownKeys(target) + ownKeys(target) { + return Reflect.ownKeys(target); } -} +}; const proxy1 = new Proxy(monster1, handler1); diff --git a/live-examples/js-examples/proxyhandler/proxyhandler-setprototypeof.js b/live-examples/js-examples/proxyhandler/proxyhandler-setprototypeof.js index 28e8e86deb5e03f..0724523916ef8b1 100644 --- a/live-examples/js-examples/proxyhandler/proxyhandler-setprototypeof.js +++ b/live-examples/js-examples/proxyhandler/proxyhandler-setprototypeof.js @@ -7,7 +7,7 @@ const handler1 = { const monsterProto = {}; const monster1 = { - geneticallyModified : false + geneticallyModified: false }; const proxy1 = new Proxy(monster1, handler1); diff --git a/live-examples/js-examples/reflect/reflect-defineproperty.js b/live-examples/js-examples/reflect/reflect-defineproperty.js index 59c231f866f366a..e55771b8d7b98a9 100644 --- a/live-examples/js-examples/reflect/reflect-defineproperty.js +++ b/live-examples/js-examples/reflect/reflect-defineproperty.js @@ -1,6 +1,6 @@ const object1 = {}; -if (Reflect.defineProperty(object1, 'property1', {value: 42})) { +if (Reflect.defineProperty(object1, 'property1', { value: 42 })) { console.log('property1 created!'); // expected output: "property1 created!" } else { diff --git a/live-examples/js-examples/regexp/regexp-assertions.js b/live-examples/js-examples/regexp/regexp-assertions.js index 5acbd9b916ba7ea..3d8dd69d271ea63 100644 --- a/live-examples/js-examples/regexp/regexp-assertions.js +++ b/live-examples/js-examples/regexp/regexp-assertions.js @@ -1,4 +1,4 @@ -const text = "A quick fox"; +const text = 'A quick fox'; const regexpLastWord = /\w+$/; console.log(text.match(regexpLastWord)); diff --git a/live-examples/js-examples/regexp/regexp-character-classes.js b/live-examples/js-examples/regexp/regexp-character-classes.js index b044b2f290e8f34..4c362954c847bdc 100644 --- a/live-examples/js-examples/regexp/regexp-character-classes.js +++ b/live-examples/js-examples/regexp/regexp-character-classes.js @@ -1,11 +1,9 @@ -const chessStory = "He played the King in a8 and she moved her Queen in c2."; +const chessStory = 'He played the King in a8 and she moved her Queen in c2.'; const regexpCoordinates = /\w\d/g; console.log(chessStory.match(regexpCoordinates)); // expected output: Array [ 'a8', 'c2'] -const moods = "happy 🙂, confused 😕, sad 😢"; +const moods = 'happy 🙂, confused 😕, sad 😢'; const regexpEmoticons = /[\u{1F600}-\u{1F64F}]/gu; console.log(moods.match(regexpEmoticons)); // expected output: Array ['🙂', '😕', '😢'] - - \ No newline at end of file diff --git a/live-examples/js-examples/regexp/regexp-getregexp-@@species.js b/live-examples/js-examples/regexp/regexp-getregexp-@@species.js index 50b290c022c195d..4079a815fb3f454 100644 --- a/live-examples/js-examples/regexp/regexp-getregexp-@@species.js +++ b/live-examples/js-examples/regexp/regexp-getregexp-@@species.js @@ -5,7 +5,7 @@ class MyRegExp extends RegExp { } } -const regex1 = new MyRegExp('foo','g'); +const regex1 = new MyRegExp('foo', 'g'); console.log(regex1.test('football')); // expected output: true diff --git a/live-examples/js-examples/regexp/regexp-groups-ranges.js b/live-examples/js-examples/regexp/regexp-groups-ranges.js index a8af7895d39d78a..54940de80b03ca4 100644 --- a/live-examples/js-examples/regexp/regexp-groups-ranges.js +++ b/live-examples/js-examples/regexp/regexp-groups-ranges.js @@ -1,9 +1,9 @@ -const aliceExcerpt = "The Caterpillar and Alice looked at each other"; +const aliceExcerpt = 'The Caterpillar and Alice looked at each other'; const regexpWithoutE = /\b[a-df-z]+\b/ig; console.log(aliceExcerpt.match(regexpWithoutE)); // expected output: Array ["and", "at"] -const imageDescription = "This image has a resolution of 1440×900 pixels."; +const imageDescription = 'This image has a resolution of 1440×900 pixels.'; const regexpSize = /([0-9]+)×([0-9]+)/; const match = imageDescription.match(regexpSize); console.log(`Width: ${match[1]} / Height: ${match[2]}.`); diff --git a/live-examples/js-examples/regexp/regexp-lastindex.js b/live-examples/js-examples/regexp/regexp-lastindex.js index ce6edd8d079bac4..18aa79d4af12ab9 100644 --- a/live-examples/js-examples/regexp/regexp-lastindex.js +++ b/live-examples/js-examples/regexp/regexp-lastindex.js @@ -1,4 +1,4 @@ -const regex1 = new RegExp( "foo", "g" ); +const regex1 = new RegExp( 'foo', 'g' ); const str1 = 'table football, foosball'; regex1.test(str1); diff --git a/live-examples/js-examples/regexp/regexp-prototype-@@matchall.js b/live-examples/js-examples/regexp/regexp-prototype-@@matchall.js index 6d6fea95c9d0468..92d8f0031779c99 100644 --- a/live-examples/js-examples/regexp/regexp-prototype-@@matchall.js +++ b/live-examples/js-examples/regexp/regexp-prototype-@@matchall.js @@ -1,11 +1,11 @@ class MyRegExp extends RegExp { - [Symbol.matchAll](str) { - let result = RegExp.prototype[Symbol.matchAll].call(this, str); - if (!result) { - return null; - } - return Array.from(result); + [Symbol.matchAll](str) { + let result = RegExp.prototype[Symbol.matchAll].call(this, str); + if (!result) { + return null; } + return Array.from(result); + } } let re = new MyRegExp('-[0-9]+', 'g'); diff --git a/live-examples/js-examples/regexp/regexp-prototype-@@search.js b/live-examples/js-examples/regexp/regexp-prototype-@@search.js index c78460c39421127..a60b7183bbed0e0 100644 --- a/live-examples/js-examples/regexp/regexp-prototype-@@search.js +++ b/live-examples/js-examples/regexp/regexp-prototype-@@search.js @@ -1,6 +1,6 @@ class RegExp1 extends RegExp { constructor(str) { - super(str) + super(str); this.pattern = str; } [Symbol.search](str) { diff --git a/live-examples/js-examples/regexp/regexp-prototype-@@split.js b/live-examples/js-examples/regexp/regexp-prototype-@@split.js index a2ce9bf6557d7e8..d5246a4c79f3c68 100644 --- a/live-examples/js-examples/regexp/regexp-prototype-@@split.js +++ b/live-examples/js-examples/regexp/regexp-prototype-@@split.js @@ -1,7 +1,7 @@ class RegExp1 extends RegExp { [Symbol.split](str, limit) { const result = RegExp.prototype[Symbol.split].call(this, str, limit); - return result.map(x => "(" + x + ")"); + return result.map(x => `(${x})`); } } diff --git a/live-examples/js-examples/regexp/regexp-prototype-exec.js b/live-examples/js-examples/regexp/regexp-prototype-exec.js index de7792ef84e724f..70335437568cbeb 100644 --- a/live-examples/js-examples/regexp/regexp-prototype-exec.js +++ b/live-examples/js-examples/regexp/regexp-prototype-exec.js @@ -1,4 +1,4 @@ -const regex1 = RegExp('foo*','g'); +const regex1 = RegExp('foo*', 'g'); const str1 = 'table football, foosball'; let array1; diff --git a/live-examples/js-examples/regexp/regexp-prototype-sticky.js b/live-examples/js-examples/regexp/regexp-prototype-sticky.js index d8cd1de6515c332..6954eeb6e40ef5e 100644 --- a/live-examples/js-examples/regexp/regexp-prototype-sticky.js +++ b/live-examples/js-examples/regexp/regexp-prototype-sticky.js @@ -1,5 +1,5 @@ const str1 = 'table football'; -const regex1 = new RegExp('foo','y'); +const regex1 = new RegExp('foo', 'y'); regex1.lastIndex = 6; diff --git a/live-examples/js-examples/regexp/regexp-prototype-test.js b/live-examples/js-examples/regexp/regexp-prototype-test.js index b0e70e460741deb..52eaa7851a396c5 100644 --- a/live-examples/js-examples/regexp/regexp-prototype-test.js +++ b/live-examples/js-examples/regexp/regexp-prototype-test.js @@ -1,7 +1,7 @@ const str = 'table football'; const regex = RegExp('foo*'); -const globalRegex = RegExp('foo*','g'); +const globalRegex = RegExp('foo*', 'g'); console.log(regex.test(str)); // expected output: true diff --git a/live-examples/js-examples/regexp/regexp-prototype-tostring.js b/live-examples/js-examples/regexp/regexp-prototype-tostring.js index 6c68dd23461204a..b4f3ba0854705c1 100644 --- a/live-examples/js-examples/regexp/regexp-prototype-tostring.js +++ b/live-examples/js-examples/regexp/regexp-prototype-tostring.js @@ -8,7 +8,7 @@ console.log(new RegExp('bar', 'g').toString()); // expected output: "/bar/g" console.log(new RegExp('\n', 'g').toString()); -// expected output (if your browser supports escaping): "/\n/g" +// expected output (if your browser supports escaping): "/\n/g" console.log(new RegExp('\\n', 'g').toString()); // expected output: "/\n/g" diff --git a/live-examples/js-examples/regexp/regexp-quantifiers.js b/live-examples/js-examples/regexp/regexp-quantifiers.js index 7d2c5b316cf3ab8..4168e682c1b58a8 100644 --- a/live-examples/js-examples/regexp/regexp-quantifiers.js +++ b/live-examples/js-examples/regexp/regexp-quantifiers.js @@ -1,13 +1,13 @@ -const ghostSpeak = "booh boooooooh"; +const ghostSpeak = 'booh boooooooh'; const regexpSpooky = /bo{3,}h/; console.log(ghostSpeak.match(regexpSpooky)); // expected output: Array ["boooooooh"] -const modifiedQuote = "[He] ha[s] to go read this novel [Alice in Wonderland]." +const modifiedQuote = '[He] ha[s] to go read this novel [Alice in Wonderland].'; const regexpModifications = /\[.*?\]/g; console.log(modifiedQuote.match(regexpModifications)); // expected output: Array ["[He]", "[s]", "[Alice in Wonderland]"] -const regexpTooGreedy = /\[.*\]/g +const regexpTooGreedy = /\[.*\]/g; console.log(modifiedQuote.match(regexpTooGreedy)); // expected output: Array ["[He] ha[s] to go read this novel [Alice in Wonderland]."] diff --git a/live-examples/js-examples/regexp/regexp-unicode-property-escapes.js b/live-examples/js-examples/regexp/regexp-unicode-property-escapes.js index 3862d05a97d8b97..2b954765e683beb 100644 --- a/live-examples/js-examples/regexp/regexp-unicode-property-escapes.js +++ b/live-examples/js-examples/regexp/regexp-unicode-property-escapes.js @@ -1,4 +1,4 @@ -const sentence = "A ticket to 大阪 costs ¥2000 👌."; +const sentence = 'A ticket to 大阪 costs ¥2000 👌.'; const regexpEmojiPresentation = /\p{Emoji_Presentation}/gu; console.log(sentence.match(regexpEmojiPresentation)); diff --git a/live-examples/js-examples/set/set-prototype-delete.js b/live-examples/js-examples/set/set-prototype-delete.js index 6922fa1d5100390..cd61d290fbe26fb 100644 --- a/live-examples/js-examples/set/set-prototype-delete.js +++ b/live-examples/js-examples/set/set-prototype-delete.js @@ -1,8 +1,8 @@ const set1 = new Set(); -set1.add({x: 10, y: 20}).add({x: 20, y: 30}); +set1.add({ x: 10, y: 20 }).add({ x: 20, y: 30 }); // Delete any point with `x > 10`. -set1.forEach(function(point){ +set1.forEach((point) => { if (point.x > 10) { set1.delete(point); } diff --git a/live-examples/js-examples/set/set-prototype-foreach.js b/live-examples/js-examples/set/set-prototype-foreach.js index aa52f834b11cfc5..d17f0a96cfe80f3 100644 --- a/live-examples/js-examples/set/set-prototype-foreach.js +++ b/live-examples/js-examples/set/set-prototype-foreach.js @@ -1,5 +1,5 @@ function logSetElements(value1, value2, set) { - console.log('s[' + value1 + '] = ' + value2); + console.log(`s[${value1}] = ${value2}`); } new Set(['foo', 'bar', undefined]).forEach(logSetElements); diff --git a/live-examples/js-examples/set/set-prototype-size.js b/live-examples/js-examples/set/set-prototype-size.js index fa0492d44f837bd..3b0a7f667f73c11 100644 --- a/live-examples/js-examples/set/set-prototype-size.js +++ b/live-examples/js-examples/set/set-prototype-size.js @@ -1,5 +1,5 @@ const set1 = new Set(); -const object1 = new Object(); +const object1 = {}; set1.add(42); set1.add('forty two'); diff --git a/live-examples/js-examples/sharedarraybuffer/sharedarraybuffer-slice.js b/live-examples/js-examples/sharedarraybuffer/sharedarraybuffer-slice.js index cf1a455a52721e2..65fe94209e18c3f 100644 --- a/live-examples/js-examples/sharedarraybuffer/sharedarraybuffer-slice.js +++ b/live-examples/js-examples/sharedarraybuffer/sharedarraybuffer-slice.js @@ -4,7 +4,7 @@ const int32View = new Int32Array(buffer); // create the view // produces Int32Array [0, 0, 0, 0] int32View[1] = 42; -const sliced = new Int32Array(buffer.slice(4,12)); +const sliced = new Int32Array(buffer.slice(4, 12)); console.log(sliced); // expected output: Int32Array [42, 0] diff --git a/live-examples/js-examples/statement/statement-async-function-asterisk.js b/live-examples/js-examples/statement/statement-async-function-asterisk.js index b5b3401bedb7638..771aa926dc79d3d 100644 --- a/live-examples/js-examples/statement/statement-async-function-asterisk.js +++ b/live-examples/js-examples/statement/statement-async-function-asterisk.js @@ -1,7 +1,7 @@ async function* randomNumbers() { const url = 'https://www.random.org/decimal-fractions/?num=1&dec=10&col=1&format=plain&rnd=new'; - console.log("Print randomly generated numbers until reset is clicked, or the random number exceeds 0.95"); + console.log('Print randomly generated numbers until reset is clicked, or the random number exceeds 0.95'); while (true) { const response = await fetch(url); const text = await response.text(); diff --git a/live-examples/js-examples/statement/statement-class.js b/live-examples/js-examples/statement/statement-class.js index b9973e12c2d8367..158d20c198814c6 100644 --- a/live-examples/js-examples/statement/statement-class.js +++ b/live-examples/js-examples/statement/statement-class.js @@ -4,5 +4,5 @@ class Polygon { } } -console.log(new Polygon(4,3).area); +console.log(new Polygon(4, 3).area); // expected output: 12 diff --git a/live-examples/js-examples/statement/statement-const.js b/live-examples/js-examples/statement/statement-const.js index ae126595bbf4a6c..17331d619bd3235 100644 --- a/live-examples/js-examples/statement/statement-const.js +++ b/live-examples/js-examples/statement/statement-const.js @@ -2,7 +2,7 @@ const number = 42; try { number = 99; -} catch(err) { +} catch (err) { console.log(err); // expected output: TypeError: invalid assignment to const `number' // Note - error messages will vary depending on browser diff --git a/live-examples/js-examples/statement/statement-continue.js b/live-examples/js-examples/statement/statement-continue.js index 1f0a8ea083658df..3bb0a0b6d61ddcc 100644 --- a/live-examples/js-examples/statement/statement-continue.js +++ b/live-examples/js-examples/statement/statement-continue.js @@ -1,4 +1,4 @@ -let text = ""; +let text = ''; for (let i = 0; i < 10; i++) { if (i === 3) { diff --git a/live-examples/js-examples/statement/statement-default.js b/live-examples/js-examples/statement/statement-default.js index 5a1ad8fef03fca1..94e0eb171538233 100644 --- a/live-examples/js-examples/statement/statement-default.js +++ b/live-examples/js-examples/statement/statement-default.js @@ -1,12 +1,12 @@ const expr = 'Pears'; -switch(expr) { +switch (expr) { case 'Oranges': console.log('Oranges are $0.59 a pound.'); - break; + break; case 'Apples': console.log('Apples are $0.32 a pound.'); - break; + break; default: - console.log('Sorry, we are out of ' + expr + '.'); + console.log(`Sorry, we are out of ${expr}.`); // expected output: "Sorry, we are out of Pears." } diff --git a/live-examples/js-examples/statement/statement-dowhile.js b/live-examples/js-examples/statement/statement-dowhile.js index 1e79422b7e34d7d..b6ef7b1f60ac7a1 100644 --- a/live-examples/js-examples/statement/statement-dowhile.js +++ b/live-examples/js-examples/statement/statement-dowhile.js @@ -1,4 +1,4 @@ -let result = ""; +let result = ''; let i = 0; do { diff --git a/live-examples/js-examples/statement/statement-empty.js b/live-examples/js-examples/statement/statement-empty.js index 306b26a26505bd4..5a666a5f400e322 100644 --- a/live-examples/js-examples/statement/statement-empty.js +++ b/live-examples/js-examples/statement/statement-empty.js @@ -1,7 +1,7 @@ const array1 = [1, 2, 3]; // Assign all array values to 0 -for (let i = 0; i < array1.length; array1[i++] = 0) /* empty statement */ ; +for (let i = 0; i < array1.length; array1[i++] = 0) /* empty statement */; console.log(array1); // expected output: Array [0, 0, 0] diff --git a/live-examples/js-examples/statement/statement-for.js b/live-examples/js-examples/statement/statement-for.js index 226a2ac61ce9acb..f4e21d7108acc09 100644 --- a/live-examples/js-examples/statement/statement-for.js +++ b/live-examples/js-examples/statement/statement-for.js @@ -1,4 +1,4 @@ -let str = ""; +let str = ''; for (let i = 0; i < 9; i++) { str = str + i; diff --git a/live-examples/js-examples/statement/statement-forin.js b/live-examples/js-examples/statement/statement-forin.js index ad21603110d48f3..1d234695adccc49 100644 --- a/live-examples/js-examples/statement/statement-forin.js +++ b/live-examples/js-examples/statement/statement-forin.js @@ -1,4 +1,4 @@ -const object = {a: 1, b: 2, c: 3}; +const object = { a: 1, b: 2, c: 3 }; for (const property in object) { console.log(`${property}: ${object[property]}`); diff --git a/live-examples/js-examples/statement/statement-ifelse.js b/live-examples/js-examples/statement/statement-ifelse.js index ee4da635d5130e7..54880bd6b06c922 100644 --- a/live-examples/js-examples/statement/statement-ifelse.js +++ b/live-examples/js-examples/statement/statement-ifelse.js @@ -1,9 +1,11 @@ function testNum(a) { + let result; if (a > 0) { - return "positive"; + result = 'positive'; } else { - return "NOT positive"; + result = 'NOT positive'; } + return result; } console.log(testNum(-5)); diff --git a/live-examples/js-examples/statement/statement-label.js b/live-examples/js-examples/statement/statement-label.js index 68b0831e20b987a..c1af8a95ac995b3 100644 --- a/live-examples/js-examples/statement/statement-label.js +++ b/live-examples/js-examples/statement/statement-label.js @@ -1,4 +1,4 @@ -let str = ""; +let str = ''; loop1: for (let i = 0; i < 5; i++) { diff --git a/live-examples/js-examples/statement/statement-switch.js b/live-examples/js-examples/statement/statement-switch.js index 88df23f55afc7b5..39a4acc6432a5c1 100644 --- a/live-examples/js-examples/statement/statement-switch.js +++ b/live-examples/js-examples/statement/statement-switch.js @@ -9,5 +9,5 @@ switch (expr) { // expected output: "Mangoes and papayas are $2.79 a pound." break; default: - console.log('Sorry, we are out of ' + expr + '.'); + console.log(`Sorry, we are out of ${expr}.`); } diff --git a/live-examples/js-examples/statement/statement-throw.js b/live-examples/js-examples/statement/statement-throw.js index 4fdb2110716271f..9904b8e32d304bb 100644 --- a/live-examples/js-examples/statement/statement-throw.js +++ b/live-examples/js-examples/statement/statement-throw.js @@ -1,13 +1,12 @@ function getRectArea(width, height) { if (isNaN(width) || isNaN(height)) { - throw "Parameter is not a number!"; + throw 'Parameter is not a number!'; } } try { getRectArea(3, 'A'); -} -catch(e) { +} catch (e) { console.error(e); // expected output: "Parameter is not a number!" } diff --git a/live-examples/js-examples/statement/statement-trycatch.js b/live-examples/js-examples/statement/statement-trycatch.js index 00edf99c167867d..6782f1d26eb9e48 100644 --- a/live-examples/js-examples/statement/statement-trycatch.js +++ b/live-examples/js-examples/statement/statement-trycatch.js @@ -1,7 +1,6 @@ try { nonExistentFunction(); -} -catch(error) { +} catch (error) { console.error(error); // expected output: ReferenceError: nonExistentFunction is not defined // Note - error messages will vary depending on browser diff --git a/live-examples/js-examples/string/string-charat.js b/live-examples/js-examples/string/string-charat.js index 71e7bf8319f4bba..0543303ab803195 100644 --- a/live-examples/js-examples/string/string-charat.js +++ b/live-examples/js-examples/string/string-charat.js @@ -2,5 +2,5 @@ const sentence = 'The quick brown fox jumps over the lazy dog.'; const index = 4; -console.log('The character at index ' + index + ' is ' + sentence.charAt(index)); +console.log(`The character at index ${index} is ${sentence.charAt(index)}`); // expected output: "The character at index 4 is q" diff --git a/live-examples/js-examples/string/string-charcodeat.js b/live-examples/js-examples/string/string-charcodeat.js index 8e83135f08aca3b..cd34ee5d39323a3 100644 --- a/live-examples/js-examples/string/string-charcodeat.js +++ b/live-examples/js-examples/string/string-charcodeat.js @@ -2,5 +2,5 @@ const sentence = 'The quick brown fox jumps over the lazy dog.'; const index = 4; -console.log('The character code ' + sentence.charCodeAt(index) + ' is equal to ' + sentence.charAt(index)); +console.log(`The character code ${sentence.charCodeAt(index)} is equal to ${sentence.charAt(index)}`); // expected output: "The character code 113 is equal to q" diff --git a/live-examples/js-examples/string/string-includes.js b/live-examples/js-examples/string/string-includes.js index 6ac145357fbfce1..0d6ef2e8af97d9d 100644 --- a/live-examples/js-examples/string/string-includes.js +++ b/live-examples/js-examples/string/string-includes.js @@ -2,5 +2,5 @@ const sentence = 'The quick brown fox jumps over the lazy dog.'; const word = 'fox'; -console.log(`The word "${word}" ${sentence.includes(word)? 'is' : 'is not'} in the sentence`); +console.log(`The word "${word}" ${sentence.includes(word) ? 'is' : 'is not'} in the sentence`); // expected output: "The word "fox" is in the sentence" diff --git a/live-examples/js-examples/string/string-indexof.js b/live-examples/js-examples/string/string-indexof.js index 0e98bc86dfc68c1..49fa1ab01e54246 100644 --- a/live-examples/js-examples/string/string-indexof.js +++ b/live-examples/js-examples/string/string-indexof.js @@ -3,8 +3,8 @@ const paragraph = 'The quick brown fox jumps over the lazy dog. If the dog barke const searchTerm = 'dog'; const indexOfFirst = paragraph.indexOf(searchTerm); -console.log('The index of the first "' + searchTerm + '" from the beginning is ' + indexOfFirst); +console.log(`The index of the first "${searchTerm}" from the beginning is ${indexOfFirst}`); // expected output: "The index of the first "dog" from the beginning is 40" -console.log('The index of the 2nd "' + searchTerm + '" is ' + paragraph.indexOf(searchTerm, (indexOfFirst + 1))); +console.log(`The index of the 2nd "${searchTerm}" is ${paragraph.indexOf(searchTerm, (indexOfFirst + 1))}`); // expected output: "The index of the 2nd "dog" is 52" diff --git a/live-examples/js-examples/string/string-iterator.js b/live-examples/js-examples/string/string-iterator.js index 46b32237dfee821..438d10e63c65760 100644 --- a/live-examples/js-examples/string/string-iterator.js +++ b/live-examples/js-examples/string/string-iterator.js @@ -3,10 +3,10 @@ const str = 'The quick red fox jumped over the lazy dog\'s back.'; let iterator = str[Symbol.iterator](); let theChar = iterator.next(); -while(!theChar.done && theChar.value !== ' ') { +while (!theChar.done && theChar.value !== ' ') { console.log(theChar.value); theChar = iterator.next(); // expected output: "T" // "h" // "e" -} +} diff --git a/live-examples/js-examples/string/string-lastindexof.js b/live-examples/js-examples/string/string-lastindexof.js index c307058811ba6af..f4bbb71f6fc36b8 100644 --- a/live-examples/js-examples/string/string-lastindexof.js +++ b/live-examples/js-examples/string/string-lastindexof.js @@ -2,5 +2,5 @@ const paragraph = 'The quick brown fox jumps over the lazy dog. If the dog barke const searchTerm = 'dog'; -console.log('The index of the first "' + searchTerm + '" from the end is ' + paragraph.lastIndexOf(searchTerm)); +console.log(`The index of the first "${searchTerm}" from the end is ${paragraph.lastIndexOf(searchTerm)}`); // expected output: "The index of the first "dog" from the end is 52" diff --git a/live-examples/js-examples/string/string-length.js b/live-examples/js-examples/string/string-length.js index d8aabe3fb62c961..53f90717a2dddc6 100644 --- a/live-examples/js-examples/string/string-length.js +++ b/live-examples/js-examples/string/string-length.js @@ -1,4 +1,4 @@ const str = 'Life, the universe and everything. Answer:'; -console.log(str + ' ' + str.length); +console.log(`${str} ${str.length}`); // expected output: "Life, the universe and everything. Answer: 42" diff --git a/live-examples/js-examples/string/string-localecompare.js b/live-examples/js-examples/string/string-localecompare.js index d7e47c7ac15bd02..05ba235b3f71e98 100644 --- a/live-examples/js-examples/string/string-localecompare.js +++ b/live-examples/js-examples/string/string-localecompare.js @@ -3,5 +3,5 @@ const b = 'RESERVE'; // no accents, uppercase console.log(a.localeCompare(b)); // expected output: 1 -console.log(a.localeCompare(b, 'en', {sensitivity: 'base'})); +console.log(a.localeCompare(b, 'en', { sensitivity: 'base' })); // expected output: 0 diff --git a/live-examples/js-examples/string/string-match.js b/live-examples/js-examples/string/string-match.js index fe82b846aa6b18a..27206e9ffefa6d2 100644 --- a/live-examples/js-examples/string/string-match.js +++ b/live-examples/js-examples/string/string-match.js @@ -3,4 +3,4 @@ const regex = /[A-Z]/g; const found = paragraph.match(regex); console.log(found); -// expected output: Array ["T", "I"] \ No newline at end of file +// expected output: Array ["T", "I"] diff --git a/live-examples/js-examples/string/string-normalize.js b/live-examples/js-examples/string/string-normalize.js index e26f8f5b46fbaf6..b58b57c45608f91 100644 --- a/live-examples/js-examples/string/string-normalize.js +++ b/live-examples/js-examples/string/string-normalize.js @@ -16,4 +16,4 @@ console.log(`${name1NFC}, ${name2NFC}`); console.log(name1NFC === name2NFC); // expected output: true console.log(name1NFC.length === name2NFC.length); -// expected output: true \ No newline at end of file +// expected output: true diff --git a/live-examples/js-examples/string/string-raw.js b/live-examples/js-examples/string/string-raw.js index bc222723682543e..87a0905969fd172 100644 --- a/live-examples/js-examples/string/string-raw.js +++ b/live-examples/js-examples/string/string-raw.js @@ -3,5 +3,5 @@ // path without escaping the backslashes: const filePath = String.raw`C:\Development\profile\aboutme.html`; -console.log('The file was uploaded from: ' + filePath); +console.log(`The file was uploaded from: ${filePath}`); // expected output: "The file was uploaded from: C:\Development\profile\aboutme.html" diff --git a/live-examples/js-examples/string/string-repeat.js b/live-examples/js-examples/string/string-repeat.js index 0dc10b5dfa0ca75..2d7e27142f9953b 100644 --- a/live-examples/js-examples/string/string-repeat.js +++ b/live-examples/js-examples/string/string-repeat.js @@ -1,5 +1,5 @@ const chorus = 'Because I\'m happy. '; -console.log('Chorus lyrics for "Happy": ' + chorus.repeat(27)); +console.log(`Chorus lyrics for "Happy": ${chorus.repeat(27)}`); -// expected output: "Chorus lyrics for "Happy": Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. " \ No newline at end of file +// expected output: "Chorus lyrics for "Happy": Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. Because I'm happy. " diff --git a/live-examples/js-examples/string/string-tolocalelowercase.js b/live-examples/js-examples/string/string-tolocalelowercase.js index 5c15cb7ed4f443b..0b569bd78ee5b80 100644 --- a/live-examples/js-examples/string/string-tolocalelowercase.js +++ b/live-examples/js-examples/string/string-tolocalelowercase.js @@ -1,7 +1,7 @@ const dotted = 'İstanbul'; -console.log('EN-US: ' + dotted.toLocaleLowerCase('en-US')); +console.log(`EN-US: ${dotted.toLocaleLowerCase('en-US')}`); // expected output: "i̇stanbul" -console.log('TR: ' + dotted.toLocaleLowerCase('tr')); +console.log(`TR: ${dotted.toLocaleLowerCase('tr')}`); // expected output: "istanbul" diff --git a/live-examples/js-examples/string/string-tostring.js b/live-examples/js-examples/string/string-tostring.js index e4629b5053bc3ab..061e7fb5e491a6b 100644 --- a/live-examples/js-examples/string/string-tostring.js +++ b/live-examples/js-examples/string/string-tostring.js @@ -1,4 +1,4 @@ -const stringObj = new String("foo"); +const stringObj = new String('foo'); console.log(stringObj); // expected output: String { "foo" } diff --git a/live-examples/js-examples/string/string-valueof.js b/live-examples/js-examples/string/string-valueof.js index 5d230d589563c60..859f3f48eb81c4d 100644 --- a/live-examples/js-examples/string/string-valueof.js +++ b/live-examples/js-examples/string/string-valueof.js @@ -1,4 +1,4 @@ -const stringObj = new String("foo"); +const stringObj = new String('foo'); console.log(stringObj); // expected output: String { "foo" } diff --git a/live-examples/js-examples/symbol/symbol-constructor.js b/live-examples/js-examples/symbol/symbol-constructor.js index 0b26876615af9eb..d8c0758162c6bb6 100644 --- a/live-examples/js-examples/symbol/symbol-constructor.js +++ b/live-examples/js-examples/symbol/symbol-constructor.js @@ -5,6 +5,9 @@ const symbol3 = Symbol('foo'); console.log(typeof symbol1); // expected output: "symbol" +console.log(symbol2 === 42); +// expected output: false + console.log(symbol3.toString()); // expected output: "Symbol(foo)" diff --git a/live-examples/js-examples/symbol/symbol-iterator.js b/live-examples/js-examples/symbol/symbol-iterator.js index 1536ebdf14c6cc5..569a4dab1c59105 100644 --- a/live-examples/js-examples/symbol/symbol-iterator.js +++ b/live-examples/js-examples/symbol/symbol-iterator.js @@ -1,4 +1,4 @@ -const iterable1 = new Object(); +const iterable1 = {}; iterable1[Symbol.iterator] = function* () { yield 1; diff --git a/live-examples/js-examples/symbol/symbol-prototype-description.js b/live-examples/js-examples/symbol/symbol-prototype-description.js index bc85f05e552eaed..06ac4164529c5ec 100644 --- a/live-examples/js-examples/symbol/symbol-prototype-description.js +++ b/live-examples/js-examples/symbol/symbol-prototype-description.js @@ -7,5 +7,5 @@ console.log(Symbol.iterator.description); console.log(Symbol.for('foo').description); // expected output: "foo" -console.log(Symbol('foo').description + 'bar'); +console.log(`${Symbol('foo').description}bar`); // expected output: "foobar" diff --git a/live-examples/js-examples/symbol/symbol-split.js b/live-examples/js-examples/symbol/symbol-split.js index abb3ecce5ad197d..36621ebce78fd91 100644 --- a/live-examples/js-examples/symbol/symbol-split.js +++ b/live-examples/js-examples/symbol/symbol-split.js @@ -4,8 +4,7 @@ class Split1 { } [Symbol.split](string) { const index = string.indexOf(this.value); - return this.value + string.substr(0, index) + "/" - + string.substr(index + this.value.length); + return `${this.value}${string.substr(0, index)}/${string.substr(index + this.value.length)}`; } } diff --git a/live-examples/js-examples/symbol/symbol-toprimitive.js b/live-examples/js-examples/symbol/symbol-toprimitive.js index 61fee480a1ff784..e58497c434684c8 100644 --- a/live-examples/js-examples/symbol/symbol-toprimitive.js +++ b/live-examples/js-examples/symbol/symbol-toprimitive.js @@ -1,6 +1,6 @@ const object1 = { [Symbol.toPrimitive](hint) { - if (hint == 'number') { + if (hint === 'number') { return 42; } return null; diff --git a/live-examples/js-examples/typedarray/typedarray-bytelength.js b/live-examples/js-examples/typedarray/typedarray-bytelength.js index ca10ca29c6aa25a..e078e814a442b4b 100644 --- a/live-examples/js-examples/typedarray/typedarray-bytelength.js +++ b/live-examples/js-examples/typedarray/typedarray-bytelength.js @@ -2,5 +2,5 @@ const buffer = new ArrayBuffer(8); const uint8 = new Uint8Array(buffer, 2); -console.log (uint8.byteLength); +console.log(uint8.byteLength); // expected output: 6 diff --git a/live-examples/js-examples/typedarray/typedarray-entries.js b/live-examples/js-examples/typedarray/typedarray-entries.js index 4516089261453fe..5362cf7a5c5b78c 100644 --- a/live-examples/js-examples/typedarray/typedarray-entries.js +++ b/live-examples/js-examples/typedarray/typedarray-entries.js @@ -1,5 +1,5 @@ const uint8 = new Uint8Array([10, 20, 30, 40, 50]); -eArr = uint8.entries(); +const eArr = uint8.entries(); eArr.next(); eArr.next(); diff --git a/live-examples/js-examples/typedarray/typedarray-length.js b/live-examples/js-examples/typedarray/typedarray-length.js index a7fb6288551f513..e623e45f772007c 100644 --- a/live-examples/js-examples/typedarray/typedarray-length.js +++ b/live-examples/js-examples/typedarray/typedarray-length.js @@ -2,5 +2,5 @@ const buffer = new ArrayBuffer(8); const uint8 = new Uint8Array(buffer, 2); -console.log (uint8.length); +console.log(uint8.length); // expected output: 6 diff --git a/live-examples/js-examples/typedarray/typedarray-of.js b/live-examples/js-examples/typedarray/typedarray-of.js index 15899ee8669877c..2843c788fd85233 100644 --- a/live-examples/js-examples/typedarray/typedarray-of.js +++ b/live-examples/js-examples/typedarray/typedarray-of.js @@ -1,5 +1,5 @@ let uint16 = new Int16Array; -uint16 = Int16Array.of('10', '20', '30', '40' ,'50'); +uint16 = Int16Array.of('10', '20', '30', '40', '50'); console.log(uint16); // expected output: Int16Array [10, 20, 30, 40, 50] diff --git a/live-examples/js-examples/typedarray/typedarray-values.js b/live-examples/js-examples/typedarray/typedarray-values.js index 1beb1392e297ad7..ac1e398b3936d11 100644 --- a/live-examples/js-examples/typedarray/typedarray-values.js +++ b/live-examples/js-examples/typedarray/typedarray-values.js @@ -4,5 +4,5 @@ const array1 = uint8.values(); array1.next(); array1.next(); -console.log(array1.next().value); +console.log(array1.next().value); // expected output: 30 diff --git a/live-examples/js-examples/weakset/weakset-prototype-add.js b/live-examples/js-examples/weakset/weakset-prototype-add.js index c89bd2278acbb15..a43e6a28fd15773 100644 --- a/live-examples/js-examples/weakset/weakset-prototype-add.js +++ b/live-examples/js-examples/weakset/weakset-prototype-add.js @@ -7,7 +7,7 @@ console.log(weakset1.has(object1)); try { weakset1.add(1); -} catch(error) { +} catch (error) { console.log(error); // expected output: "Error: Invalid value used in weak set" in Chrome // expected output: "TypeError: WeakSet value must be an object, got the number 1" in Firefox diff --git a/package-lock.json b/package-lock.json index f2eedf2cc7463c2..205ea0b1d4092b7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1371,7 +1371,7 @@ }, "autoprefixer": { "version": "7.2.6", - "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-7.2.6.tgz", + "resolved": "http://registry.npmjs.org/autoprefixer/-/autoprefixer-7.2.6.tgz", "integrity": "sha512-Iq8TRIB+/9eQ8rbGhcP7ct5cYb/3qjNYAR2SnzLCEcwF6rvVOax8+9+fccgXk4bEhQGjOZd5TLhsksmAdsbGqQ==", "dev": true, "requires": { @@ -1504,6 +1504,31 @@ } } }, + "babel-eslint": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/babel-eslint/-/babel-eslint-10.1.0.tgz", + "integrity": "sha512-ifWaTHQ0ce+448CYop8AdrQiBsGrnC+bMgfyKFdi6EsPLTAWG+QfyDeM6OH+FmWnKvEq5NnBMLvlBUPKQZoDSg==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "@babel/parser": "^7.7.0", + "@babel/traverse": "^7.7.0", + "@babel/types": "^7.7.0", + "eslint-visitor-keys": "^1.0.0", + "resolve": "^1.12.0" + }, + "dependencies": { + "resolve": { + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.16.1.tgz", + "integrity": "sha512-rmAglCSqWWMrrBv/XM6sW0NuRFiKViw/W4d9EbC4pt+49H8JwHy+mcGmALTEg504AUDcLTvb1T2q3E9AnmY+ig==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + } + } + }, "babel-generator": { "version": "6.26.1", "resolved": "https://registry.npmjs.org/babel-generator/-/babel-generator-6.26.1.tgz", @@ -2554,7 +2579,7 @@ "dependencies": { "callsites": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz", + "resolved": "http://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz", "integrity": "sha1-BuuE8A7qQT2oav/vrL/7Ngk7PFA=", "dev": true } @@ -2583,7 +2608,7 @@ }, "camelcase-keys": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", + "resolved": "http://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=", "dev": true, "requires": { @@ -3055,7 +3080,7 @@ }, "convert-source-map": { "version": "1.1.3", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.1.3.tgz", + "resolved": "http://registry.npmjs.org/convert-source-map/-/convert-source-map-1.1.3.tgz", "integrity": "sha1-SCnId+n+SbMWHzvzZziI4gRpmGA=", "dev": true }, @@ -4559,7 +4584,7 @@ }, "get-stream": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=", "dev": true }, @@ -5311,7 +5336,7 @@ "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", "dev": true, "requires": { - "builtin-modules": "1.1.1" + "builtin-modules": "^1.0.0" } }, "is-callable": { @@ -6128,7 +6153,7 @@ }, "meow": { "version": "3.7.0", - "resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz", + "resolved": "http://registry.npmjs.org/meow/-/meow-3.7.0.tgz", "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", "dev": true, "requires": { @@ -6146,7 +6171,7 @@ "dependencies": { "minimist": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true } @@ -6181,7 +6206,7 @@ "mime": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", - "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "integrity": "sha1-Ms2eXGRVO9WNGaVor0Uqz/BJgbE=", "dev": true }, "mime-db": { @@ -6240,7 +6265,7 @@ }, "minimist": { "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", "dev": true }, @@ -10688,7 +10713,7 @@ }, "minimist": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true }, @@ -10827,7 +10852,7 @@ }, "table": { "version": "4.0.3", - "resolved": "https://registry.npmjs.org/table/-/table-4.0.3.tgz", + "resolved": "http://registry.npmjs.org/table/-/table-4.0.3.tgz", "integrity": "sha512-S7rnFITmBH1EnyKcvxBh1LjYeQMmnZtCXSEbHcH6S0NoKit24ZuFO/T1vDcLdYsLQkM188PVVhQmzKIuThNkKg==", "dev": true, "requires": { @@ -11052,7 +11077,7 @@ "dependencies": { "minimist": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true } @@ -11100,7 +11125,7 @@ }, "load-json-file": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", + "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", "dev": true, "requires": { @@ -11142,7 +11167,7 @@ }, "pify": { "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "dev": true }, @@ -14201,7 +14226,7 @@ }, "acorn-jsx": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz", + "resolved": "http://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz", "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=", "dev": true, "requires": { @@ -14210,7 +14235,7 @@ "dependencies": { "acorn": { "version": "3.3.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", + "resolved": "http://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=", "dev": true } diff --git a/package.json b/package.json index db23204fe7a989b..de4b300cb5e93fc 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ "contributors:generate": "all-contributors generate", "start-server": "http-server -p 9090 ./docs", "start-watch": "chokidar '**/{*.js,*.css,*.html,*.json}' -i 'package.json' -i 'docs/**' -i 'node_modules/**' -i 'js/editor-*.js' -c 'npm run build' --initial --silent", - "start": "npm-run-all --parallel start-watch start-server" + "start": "npm-run-all --parallel start-watch start-server", + "lint:js": "eslint ./live-examples/js-examples" }, "keywords": [ "javascript", @@ -31,6 +32,7 @@ "devDependencies": { "ajv": "6.12.2", "all-contributors-cli": "6.14.2", + "babel-eslint": "^10.1.0", "chokidar-cli": "2.1.0", "eslint": "6.8.0", "http-server": "0.12.1",