Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating readme / fixing ExportNamedDeclaration bug #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion README

This file was deleted.

35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# babel-plugin-transform-react-es6-displayname

Automatically add `displayName` to React components instantiated in ES6 style inheriting from React.Component (ex: `class ComponentName extends React.Component`)

## Installation

```sh
$ npm install babel-plugin-transform-react-es6-displayname
```

## Usage

### Via `.babelrc` (Recommended)

**.babelrc**

```js
{
"plugins": ["transform-react-es6-displayname"]
}
```

### Via CLI

```sh
$ babel --plugins transform-react-es6-displayname script.js
```

### Via Node API

```javascript
require("babel-core").transform("code", {
plugins: ["transform-react-es6-displayname"]
});
```
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function addDisplayName (t) {
)
)
) {
this.insertAfter([
(t.isExportNamedDeclaration(this.parentPath.node) ? this.parentPath : this).insertAfter([
t.expressionStatement(t.assignmentExpression(
'=',
t.memberExpression(this.node.id, t.identifier('displayName')),
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "babel-plugin-transform-react-es6-displayname",
"version": "1.0.0-beta1.3",
"version": "1.0.0-beta1.4",
"description": "Babel transform to add the displayName property to component classes",
"main": "index.js",
"scripts": {
Expand All @@ -18,7 +18,10 @@
"react",
"displayName"
],
"author": "Nathan Marks <info@nathanmarks.io> (http://nathanmarks.io)",
"authors": [
"Nathan Marks <info@nathanmarks.io> (http://nathanmarks.io)",
"Dmitri Farkov <dmitri.farkov@gmail.com> (http://github.com/dmitrif)"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/nathanmarks/babel-plugin-transform-react-es6-displayname/issues"
Expand Down