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

Actualize sort-comp for supporting more selectors like static-variables, static-methods, getters, setters etc #310

Open
wants to merge 2 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React from 'react/addons';

// comment above class
export class MyComponent extends React.Component {
componentDidMount() {

}

static defaultProps = {
foo: 42,
};

// comment related to render method
// this will be attached to render method
render() {
return <div />;
}

// comment on constructor
constructor(props, context) {
super(props, context);
}

static someStaticThing() {
// should bundle with other statics
}

// should be before defaultProps
static propTypes = {

};

myOwnMethod(foo) {
// comment within method
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React from 'react/addons';

// comment above class
export class MyComponent extends React.Component {
static someStaticThing() {
// should bundle with other statics
}

// should be before defaultProps
static propTypes = {

};

static defaultProps = {
foo: 42,
};

// comment on constructor
constructor(props, context) {
super(props, context);
}

componentDidMount() {

}

myOwnMethod(foo) {
// comment within method
}

// comment related to render method
// this will be attached to render method
render() {
return <div />;
}
}

76 changes: 76 additions & 0 deletions transforms/__testfixtures__/sort-comp/sort-comp-full.input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import React from 'react';

export class SortCompExample extends React.Component {
model = new Date();

static y = 8;

static x = 42;

static propTypes = {};

componentDidMount() {
console.log('componentDidMount');
}

constructor(props, context) {
super(props, context);

console.log(this);
}

static defaultProps = {
disabled: false,
};

someMethod2 = () => {};

state = {
isDataReady: false,
};

onBar() {}

handleBar = () => {
};

set foo(value) {
this.xx = value;
}

handleBar2() {}

handleFoo() {}

handleFoo1 = () => {};

onBar1 = () => {};

renderFoo() {}

onFoo() {}

onFoo1 = () => {};

get foo() {
return 42;
}

static track() {}

setRef = (comp) => {
this.panelRef = comp;
};

methodFoo = () => {};

someMethod1() {
return 42;
}

renderBar() {}

render() {
return (<div ref={this.setRef}>X</div>);
}
}
76 changes: 76 additions & 0 deletions transforms/__testfixtures__/sort-comp/sort-comp-full.output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import React from 'react';

export class SortCompExample extends React.Component {
static x = 42;

static y = 8;

static track() {}

model = new Date();

static propTypes = {};

static defaultProps = {
disabled: false,
};

constructor(props, context) {
super(props, context);

console.log(this);
}

state = {
isDataReady: false,
};

componentDidMount() {
console.log('componentDidMount');
}

handleBar = () => {
};

handleBar2() {}

handleFoo() {}

handleFoo1 = () => {};

onBar() {}

onBar1 = () => {};

onFoo() {}

onFoo1 = () => {};

get foo() {
return 42;
}

set foo(value) {
this.xx = value;
}

setRef = (comp) => {
this.panelRef = comp;
};

methodFoo = () => {};

someMethod2 = () => {};

someMethod1() {
return 42;
}

renderBar() {}

renderFoo() {}

render() {
return (<div ref={this.setRef}>X</div>);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import React from 'react/addons';

// comment above class
export class MyComponent extends React.PureComponent {
// comment related to render method
// this will be attached to render method
render() {
return <div />;
}

// comment on componentDidMount
componentDidMount() {
}

// foo getter comment
get foo() {
return 42;
}

set foo(value) {
this.instanceVariable = value;
}

static someStaticThing() {
// should bundle with other statics
}

get bar() {

}

set bar(value) {

}

renderFoo() {
// other render* function
}

instanceVariable;

renderBar() {
// should come before renderFoo
}

static aStaticThing() {
// should come first
}

myOwnMethod(foo) {
// comment within method
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import React from 'react/addons';

// comment above class
export class MyComponent extends React.PureComponent {
static aStaticThing() {
// should come first
}

static someStaticThing() {
// should bundle with other statics
}

instanceVariable;

// comment on componentDidMount
componentDidMount() {
}

get bar() {

}

// foo getter comment
get foo() {
return 42;
}

set bar(value) {

}

set foo(value) {
this.instanceVariable = value;
}

myOwnMethod(foo) {
// comment within method
}

renderBar() {
// should come before renderFoo
}

renderFoo() {
// other render* function
}

// comment related to render method
// this will be attached to render method
render() {
return <div />;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React from 'react/addons';

// comment above class
export class MyComponent extends React.Component {

// comment related to render method
// this will be attached to render method
render() {
return <div />;
}

// comment on componentDidMount
componentDidMount() {
}

static someStaticThing() {
// should bundle with other statics
}

renderFoo() {
// other render* function
}

foo;

bar = null;

renderBar() {
// should come before renderFoo
}

model = new Date();

static aStaticThing() {
// should come first
}

myOwnMethod(foo) {
// comment within method
}

}

Loading