chore: add command to format markdown files

This commit is contained in:
Yangshun 2023-04-13 10:25:35 +08:00
parent 282f82221b
commit 506786c054
7 changed files with 13 additions and 10 deletions

View File

@ -1,4 +1,7 @@
{
"scripts": {
"format-mdx": "prettier --write \"packages/**/en-US.{md,mdx}\""
},
"devDependencies": {
"prettier": "^2.7.1"
}

View File

@ -30,8 +30,8 @@ console.log(b); // 1
```js
// Variable assignment.
const o = { p: 42, q: true };
const { p, q } = o;
const o = {p: 42, q: true};
const {p, q} = o;
console.log(p); // 42
console.log(q); // true

View File

@ -5,7 +5,7 @@ title: ES2015 Template Literals offer a lot of flexibility in generating strings
Template literals help make it simple to do string interpolation, or to include variables in a string. Before ES2015, it was common to do something like this:
```js
var person = { name: 'Tyler', age: 28 };
var person = {name: 'Tyler', age: 28};
console.log(
'Hi, my name is ' + person.name + ' and I am ' + person.age + ' years old!',
);
@ -15,7 +15,7 @@ console.log(
With template literals, you can now create that same output like this instead:
```js
const person = { name: 'Tyler', age: 28 };
const person = {name: 'Tyler', age: 28};
console.log(`Hi, my name is ${person.name} and I am ${person.age} years old!`);
// 'Hi, my name is Tyler and I am 28 years old!'
```
@ -50,7 +50,7 @@ This is line two.`);
Another use case of template literals would be to use as a substitute for templating libraries for simple variable interpolations:
```js
const person = { name: 'Tyler', age: 28 };
const person = {name: 'Tyler', age: 28};
document.body.innerHTML = `
<div>
<p>Name: ${person.name}</p>

View File

@ -24,7 +24,7 @@ console.log(unboundGetAge()); // undefined
const boundGetAge = john.getAge.bind(john);
console.log(boundGetAge()); // 42
const mary = { age: 21 };
const mary = {age: 21};
const boundGetAgeMary = john.getAge.bind(mary);
console.log(boundGetAgeMary()); // 21
```

View File

@ -19,7 +19,7 @@ JSONP works by making a request to a cross-origin domain via a `<script>` tag an
```js
// File loaded from https://example.com?callback=printData
printData({ name: 'John Doe' });
printData({name: 'John Doe'});
```
The client has to have the `printData` function in its global scope and the function will be executed by the client when the response from the cross-origin domain is received.

View File

@ -16,7 +16,7 @@ const person = {
age: 29,
};
const copyOfTodd = { ...person };
const copyOfTodd = {...person};
```
ES2015's rest syntax offers a shorthand for including an arbitrary number of arguments to be passed to a function. It is like an inverse of the spread syntax, taking data and stuffing it into an array rather than unpacking an array of data, and it works in function arguments, as well as in array and object destructuring assignments.
@ -30,7 +30,7 @@ const result = addFiveToABunchOfNumbers(4, 5, 6, 7, 8, 9, 10); // [9, 10, 11, 12
const [a, b, ...rest] = [1, 2, 3, 4]; // a: 1, b: 2, rest: [3, 4]
const { e, f, ...others } = {
const {e, f, ...others} = {
e: 1,
f: 2,
g: 3,

View File

@ -76,4 +76,4 @@ baz = 'qux';
## Notes
- Since most browsers support `let` and `const` these days, using `var` is no longer recommended. If you need to target older browsers, write your code using `let`, and use a transpiler like Babel to compile your code to older syntax.
- Since most browsers support `let` and `const` these days, using `var` is no longer recommended. If you need to target older browsers, write your code using `let`, and use a transpiler like Babel to compile your code to older syntax.