style: [skip ci] lint code snippets in md (#5379)
This commit is contained in:
@@ -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", {
|
||||
|
||||
@@ -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", {
|
||||
|
||||
@@ -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", {
|
||||
|
||||
@@ -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", {
|
||||
|
||||
@@ -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", {
|
||||
|
||||
@@ -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", {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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", {
|
||||
|
||||
@@ -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", {
|
||||
|
||||
@@ -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", {
|
||||
|
||||
@@ -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", {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user