style: [skip ci] lint code snippets in md (#5379)

This commit is contained in:
Sven SAULEAU
2017-02-25 18:19:29 +01:00
committed by Henry Zhu
parent 6614a63b3b
commit eb9d699ce9
14 changed files with 77 additions and 38 deletions

View File

@@ -34,13 +34,17 @@ npm install --save-dev babel-plugin-transform-async-to-module-method
**.babelrc**
```js
// without options
Without options:
```json
{
"plugins": ["transform-async-to-module-method"]
}
```
// with options
With options:
```json
{
"plugins": [
["transform-async-to-module-method", {

View File

@@ -57,13 +57,17 @@ npm install --save-dev babel-plugin-transform-es2015-computed-properties
**.babelrc**
```js
// without options
Without options:
```json
{
"plugins": ["transform-es2015-computed-properties"]
}
```
// with options
With options:
```json
{
"plugins": [
["transform-es2015-computed-properties", {

View File

@@ -49,13 +49,17 @@ npm install --save-dev babel-plugin-transform-es2015-for-of
**.babelrc**
Without options:
```js
// without options
{
"plugins": ["transform-es2015-for-of"]
}
```
// with options
With options:
```json
{
"plugins": [
["transform-es2015-for-of", {

View File

@@ -35,13 +35,17 @@ npm install --save-dev babel-plugin-transform-es2015-modules-systemjs
**.babelrc**
```javascript
// without options
Without options:
```json
{
"plugins": ["transform-es2015-modules-systemjs"]
}
```
// with options
With options:
```json
{
"plugins": [
["transform-es2015-modules-systemjs", {

View File

@@ -48,13 +48,17 @@ npm install --save-dev babel-plugin-transform-es2015-spread
**.babelrc**
```js
// without options
Without options:
```json
{
"plugins": ["transform-es2015-spread"]
}
```
// with options
With options:
```json
{
"plugins": [
["transform-es2015-spread", {

View File

@@ -28,13 +28,17 @@ npm install --save-dev babel-plugin-transform-es2015-template-literals
**.babelrc**
```js
// without options
Without options:
```json
{
"plugins": ["transform-es2015-template-literals"]
}
```
// with options
With options:
```json
{
"plugins": [
["transform-es2015-template-literals", {

View File

@@ -41,13 +41,15 @@ This plugin will use babel's `extends` helper, which will polyfill `Object.assig
* `useBuiltIns` - Do not use Babel's helper's and just transform to use the built-in method (Disabled by default).
```js
```json
{
"plugins": [
["transform-object-rest-spread", { "useBuiltIns": true }]
]
}
```
```js
// source
z = { x, ...y };
// compiled

View File

@@ -64,12 +64,17 @@ npm install --save-dev babel-plugin-transform-react-jsx
**.babelrc**
```js
// without options
Without options:
```json
{
"plugins": ["transform-react-jsx"]
}
// with options
```
With options:
```json
{
"plugins": [
["transform-react-jsx", {

View File

@@ -40,13 +40,17 @@ The transformation plugin is typically used only in development, but the runtime
Add the following line to your `.babelrc` file:
```js
// without options
Without options:
```json
{
"plugins": ["transform-runtime"]
}
```
// with options
With options:
```json
{
"plugins": [
["transform-runtime", {

View File

@@ -34,13 +34,17 @@ npm install --save-dev babel-plugin-transform-strict-mode
**.babelrc**
```js
// without options
Without options:
```json
{
"plugins": ["transform-strict-mode"]
}
```
// with options
With options:
```json
{
"plugins": [
["transform-strict-mode", {

View File

@@ -42,7 +42,7 @@ require("babel-core").transform("code", {
Toggles including plugins from the [es2015 preset](https://babeljs.io/docs/plugins/preset-es2015/).
```js
```json
{
"presets": [
["latest", {
@@ -54,7 +54,7 @@ Toggles including plugins from the [es2015 preset](https://babeljs.io/docs/plugi
You can also pass options down to the `es2015` preset.
```js
```json
{
"presets": [
["latest", {

View File

@@ -53,7 +53,7 @@ require("babel-register")({
// Ignore can also be specified as a function.
ignore: function(filename) {
if (filename === '/path/to/es6-file.js') {
if (filename === "/path/to/es6-file.js") {
return false;
} else {
return true;

View File

@@ -13,24 +13,24 @@ npm install --save-dev babel-template
## Usage
```js
import template from 'babel-template';
import generate from 'babel-generator';
import * as t from 'babel-types';
import template from "babel-template";
import generate from "babel-generator";
import * as t from "babel-types";
const buildRequire = template(`
var IMPORT_NAME = require(SOURCE);
`);
const ast = buildRequire({
IMPORT_NAME: t.identifier('myModule'),
SOURCE: t.stringLiteral('my-module')
IMPORT_NAME: t.identifier("myModule"),
SOURCE: t.stringLiteral("my-module")
});
console.log(generate(ast).code);
```
```js
var myModule = require('my-module');
const myModule = require("my-module");
```
## API