Put decorators on the same line (#459)

Mobx is the only popular JavaScript library that I know about which uses decorators. They put things on the same line so we should follow their conventions.

The logic implemented here is the following: if there is one decorator, it's on the same line. If there is more than one, they are each on their own line.

Fixes #325
This commit is contained in:
Christopher Chedeau authored and James Long committed 2017-01-25 16:30:09 -05:00
1 parent 1334dbc781
commit 888c7a52dd
6 files changed
+94 -1

No files matched your search

@@ -0,0 +1,64 @@
exports[`test mobx.js 1`] = `
"import {observable} from \"mobx\";
@observer class OrderLine {
@observable price:number = 0;
@observable amount:number = 1;
constructor(price) {
this.price = price;
}
@computed get total() {
return this.price * this.amount;
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import { observable } from \"mobx\";
@observer class OrderLine {
@observable price: number = 0;
@observable amount: number = 1;
constructor(price) {
this.price = price;
}
@computed get total() {
return this.price * this.amount;
}
}
"
`;
exports[`test multiple.js 1`] = `
"const dog = {
@readonly
@nonenumerable
@doubledValue
legs: 4
};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const dog = {
@readonly
@nonenumerable
@doubledValue
legs: 4
};
"
`;
exports[`test redux.js 1`] = `
"@connect(mapStateToProps, mapDispatchToProps)
export class MyApp extends React.Component {}
@connect(state => ({ todos: state.todos }))
export class Home extends React.Component {}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@connect(mapStateToProps, mapDispatchToProps)
export class MyApp extends React.Component {}
@connect(state => ({ todos: state.todos }))
export class Home extends React.Component {}
"
`;
+1
View File
@@ -0,0 +1 @@
run_spec(__dirname, {parser: 'babylon'});
+14
View File
@@ -0,0 +1,14 @@
import {observable} from "mobx";
@observer class OrderLine {
@observable price:number = 0;
@observable amount:number = 1;
constructor(price) {
this.price = price;
}
@computed get total() {
return this.price * this.amount;
}
}
+6
View File
@@ -0,0 +1,6 @@
const dog = {
@readonly
@nonenumerable
@doubledValue
legs: 4
};
+5
View File
@@ -0,0 +1,5 @@
@connect(mapStateToProps, mapDispatchToProps)
export class MyApp extends React.Component {}
@connect(state => ({ todos: state.todos }))
export class Home extends React.Component {}