Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

carbon-codemod

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

carbon-codemod - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

7

CHANGELOG.md

@@ -0,1 +1,8 @@

### [1.1.1](https://github.com/Sage/carbon-codemod/compare/v1.1.0...v1.1.1) (2020-03-10)
### Bug Fixes
* **button-destructive:** use buttonType prop instead of type ([975b4c6](https://github.com/Sage/carbon-codemod/commit/975b4c64f00385f392af9ac567ab699521574a5b))
## [1.1.0](https://github.com/Sage/carbon-codemod/compare/v1.0.0...v1.1.0) (2020-03-09)

@@ -2,0 +9,0 @@

2

package.json
{
"name": "carbon-codemod",
"version": "1.1.0",
"version": "1.1.1",
"description": "carbon-codemod",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -1,2 +0,2 @@

# carbon-codemod [![Travis Status](https://travis-ci.org/Sage/carbon-codemod.svg?branch=master)](https://travis-ci.org/Sage/carbon) [![npm](https://img.shields.io/npm/v/carbon-codemod.svg)](https://www.npmjs.com/package/carbon-codemod)
# carbon-codemod [![Travis Status](https://travis-ci.org/Sage/carbon-codemod.svg?branch=master)](https://travis-ci.org/Sage/carbon-codemod) [![npm](https://img.shields.io/npm/v/carbon-codemod.svg)](https://www.npmjs.com/package/carbon-codemod)

@@ -46,7 +46,7 @@ This is a collection of codemods that help you upgrade to a new version of `carbon-react`.

- This project publishes using `semantic-release`.
- It follows `conventional-changelog`.
- This project publishes using [`semantic-release`](https://semantic-release.gitbook.io/semantic-release/).
- It follows [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/).
- When a pull request is merged to master [Travis CI](https://travis-ci.org/Sage/carbon-codemod) will run `semantic-release`.
- `semantic-release` will decide, based on the commits that have been merged, if a new release
is required.
- If a new release is required, a new version will be published to npm and GitHub releases.
- If a new release is required, a new version will be published to [npm](https://www.npmjs.com/package/carbon-codemod) and [GitHub releases](https://github.com/Sage/carbon-codemod/releases).
/**
* Convert all <Button type="destructive"/> to <Button type="primary" destructive />
* Convert all <Button buttonType="destructive"/> to <Button buttonType="primary" destructive />
*/

@@ -15,3 +15,3 @@ import registerMethods from "../registerMethods";

/*
<Button type="destructive" />
<Button buttonType="destructive" />
*/

@@ -21,3 +21,3 @@ const LiteralReplacement = attribute => {

attribute.replaceWith(
j.jsxAttribute(j.jsxIdentifier("type"), j.literal("primary"))
j.jsxAttribute(j.jsxIdentifier("buttonType"), j.literal("primary"))
);

@@ -31,3 +31,3 @@ addDestructiveProp(attribute);

const buttonType = "destructive";
export default () => <Button type={buttonType} />;
export default () => <Button buttonType={buttonType} />;
*/

@@ -50,3 +50,3 @@ const JSXExpressionVariableReplacement = IdentifierExpression => {

export const one = (buttonType = "destructive") => {
return <Button type={buttonType} />;
return <Button buttonType={buttonType} />;
}

@@ -66,3 +66,3 @@ */

/*
<Button type={buttonType}/>
<Button buttonType={buttonType}/>
*/

@@ -89,3 +89,3 @@ const JSXExpressionReplacement = attribute => {

/*
<Button {...{{type: 'destructive'}}} />
<Button {...{{buttonType: 'destructive'}}} />
*/

@@ -95,3 +95,3 @@ const ObjectExpressionsLiteralReplacement = attribute => {

kind: "init",
key: { name: "type" },
key: { name: "buttonType" },
value: { value: "destructive" }

@@ -102,3 +102,3 @@ });

results.replaceWith(
j.property("init", j.identifier("type"), j.literal("primary"))
j.property("init", j.identifier("buttonType"), j.literal("primary"))
);

@@ -119,4 +119,4 @@

/*
<Button {...{type}} />
<Button {...{type: buttonType}} />
<Button {...{buttonType}} />
<Button {...{buttonType: buttonType}} />
*/

@@ -126,3 +126,3 @@ const ObjectExpressionsIdentifierReplacement = argument => {

kind: "init",
key: { name: "type" },
key: { name: "buttonType" },
value: { type: "Identifier" }

@@ -204,3 +204,3 @@ });

kind: "init",
key: { name: "type" },
key: { name: "buttonType" },
value: { value: "destructive" }

@@ -211,3 +211,3 @@ });

results.replaceWith(
j.property("init", j.identifier("type"), j.literal("primary"))
j.property("init", j.identifier("buttonType"), j.literal("primary"))
);

@@ -229,3 +229,3 @@

/*
<Button type= />
<Button buttonType= />
*/

@@ -236,8 +236,8 @@ const JSXAttributeReplacement = button => {

type: "JSXIdentifier",
name: "type"
name: "buttonType"
}
});
// Remove all but the last type prop
// e.g. <Button type="primary" type="secondary" />
// Remove all but the last buttonType prop
// e.g. <Button buttonType="primary" buttonType="secondary" />
typeAttributes.trimLeft();

@@ -244,0 +244,0 @@

# button-destructive
In order to add secondary and tertiary buttons to carbon-react, the `destructive` type has been replaced with a dedicated prop.
In order to add secondary and tertiary buttons to carbon-react, the `destructive` buttonType has been replaced with a dedicated prop.
```diff
- <Button type="destructive">My Button</Button>
+ <Button type="primary" destructive>My Button</Button>
- <Button buttonType="destructive">My Button</Button>
+ <Button buttonType="primary" destructive>My Button</Button>
```

@@ -13,11 +13,11 @@

```js
<Button type="destructive">My Button</Button>
<Button buttonType="destructive">My Button</Button>
```
```js
<Button type={"destructive"}>My Button</Button>
<Button buttonType={"destructive"}>My Button</Button>
```
```js
<Button type={buttonType}>My Button</Button>
<Button buttonType={buttonType}>My Button</Button>
```

@@ -30,11 +30,11 @@

```js
<Button {...{ type: "destructive" }}>My Button</Button>
<Button {...{ buttonType: "destructive" }}>My Button</Button>
```
```js
<Button {...{ type }}>My Button</Button>
<Button {...{ buttonType }}>My Button</Button>
```
```js
<Button {...{ type: buttonType }}>My Button</Button>
<Button {...{ buttonType: type }}>My Button</Button>
```

@@ -41,0 +41,0 @@

@@ -6,2 +6,5 @@ import assert from "assert";

j.registerMethods({
/*
Find the VariableDeclaration for the expressionName, optionally filtered by init value
*/
findVariableDeclaration: function(expressionName, init) {

@@ -23,2 +26,3 @@ const declarationScope = this.findDeclarationScope(expressionName);

},
/**

@@ -25,0 +29,0 @@ * Finds all JSXElements by package name. Given

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc