Always use unpad (babel/babel-eslint#535)
This commit is contained in:
parent
f43062ebbb
commit
090269e5a0
@ -61,6 +61,7 @@ function lookup(obj, keypath, backwardsDepth) {
|
||||
}
|
||||
|
||||
function parseAndAssertSame(code) {
|
||||
code = unpad(code);
|
||||
var esAST = espree.parse(code, {
|
||||
ecmaFeatures: {
|
||||
// enable JSX parsing
|
||||
@ -177,8 +178,7 @@ describe("babylon-to-esprima", () => {
|
||||
});
|
||||
|
||||
it("template also with braces #96", () => {
|
||||
parseAndAssertSame(
|
||||
unpad(`
|
||||
parseAndAssertSame(`
|
||||
export default function f1() {
|
||||
function f2(foo) {
|
||||
const bar = 3;
|
||||
@ -186,21 +186,18 @@ describe("babylon-to-esprima", () => {
|
||||
}
|
||||
return f2;
|
||||
}
|
||||
`)
|
||||
);
|
||||
`);
|
||||
});
|
||||
|
||||
it("template with destructuring #31", () => {
|
||||
parseAndAssertSame(
|
||||
unpad(`
|
||||
parseAndAssertSame(`
|
||||
module.exports = {
|
||||
render() {
|
||||
var {name} = this.props;
|
||||
return Math.max(null, \`Name: \${name}, Name: \${name}\`);
|
||||
}
|
||||
};
|
||||
`)
|
||||
);
|
||||
`);
|
||||
});
|
||||
});
|
||||
|
||||
@ -301,31 +298,26 @@ describe("babylon-to-esprima", () => {
|
||||
});
|
||||
|
||||
it("line comments", () => {
|
||||
parseAndAssertSame(
|
||||
unpad(`
|
||||
parseAndAssertSame(`
|
||||
// single comment
|
||||
var foo = 15; // comment next to statement
|
||||
// second comment after statement
|
||||
`)
|
||||
);
|
||||
`);
|
||||
});
|
||||
|
||||
it("block comments", () => {
|
||||
parseAndAssertSame(
|
||||
unpad(`
|
||||
parseAndAssertSame(`
|
||||
/* single comment */
|
||||
var foo = 15; /* comment next to statement */
|
||||
/*
|
||||
* multiline
|
||||
* comment
|
||||
*/
|
||||
`)
|
||||
);
|
||||
`);
|
||||
});
|
||||
|
||||
it("block comments #124", () => {
|
||||
parseAndAssertSame(
|
||||
unpad(`
|
||||
parseAndAssertSame(`
|
||||
React.createClass({
|
||||
render() {
|
||||
// return (
|
||||
@ -333,8 +325,7 @@ describe("babylon-to-esprima", () => {
|
||||
// ); // <-- this is the line that is reported
|
||||
}
|
||||
});
|
||||
`)
|
||||
);
|
||||
`);
|
||||
});
|
||||
|
||||
it("null", () => {
|
||||
@ -374,8 +365,7 @@ describe("babylon-to-esprima", () => {
|
||||
});
|
||||
|
||||
it("jsdoc", () => {
|
||||
parseAndAssertSame(
|
||||
unpad(`
|
||||
parseAndAssertSame(`
|
||||
/**
|
||||
* @param {object} options
|
||||
* @return {number}
|
||||
@ -384,13 +374,11 @@ describe("babylon-to-esprima", () => {
|
||||
return a + b + c;
|
||||
};
|
||||
module.exports = test;
|
||||
`)
|
||||
);
|
||||
`);
|
||||
});
|
||||
|
||||
it("empty block with comment", () => {
|
||||
parseAndAssertSame(
|
||||
unpad(`
|
||||
parseAndAssertSame(`
|
||||
function a () {
|
||||
try {
|
||||
b();
|
||||
@ -398,19 +386,16 @@ describe("babylon-to-esprima", () => {
|
||||
// asdf
|
||||
}
|
||||
}
|
||||
`)
|
||||
);
|
||||
`);
|
||||
});
|
||||
|
||||
describe("babel tests", () => {
|
||||
it("MethodDefinition", () => {
|
||||
parseAndAssertSame(
|
||||
unpad(`
|
||||
parseAndAssertSame(`
|
||||
export default class A {
|
||||
a() {}
|
||||
}
|
||||
`)
|
||||
);
|
||||
`);
|
||||
});
|
||||
|
||||
it("MethodDefinition 2", () => {
|
||||
@ -420,30 +405,25 @@ describe("babylon-to-esprima", () => {
|
||||
});
|
||||
|
||||
it("ClassMethod", () => {
|
||||
parseAndAssertSame(
|
||||
unpad(`
|
||||
parseAndAssertSame(`
|
||||
class A {
|
||||
constructor() {
|
||||
}
|
||||
}
|
||||
`)
|
||||
);
|
||||
`);
|
||||
});
|
||||
|
||||
it("ClassMethod multiple params", () => {
|
||||
parseAndAssertSame(
|
||||
unpad(`
|
||||
parseAndAssertSame(`
|
||||
class A {
|
||||
constructor(a, b, c) {
|
||||
}
|
||||
}
|
||||
`)
|
||||
);
|
||||
`);
|
||||
});
|
||||
|
||||
it("ClassMethod multiline", () => {
|
||||
parseAndAssertSame(
|
||||
unpad(`
|
||||
parseAndAssertSame(`
|
||||
class A {
|
||||
constructor (
|
||||
a,
|
||||
@ -455,8 +435,7 @@ describe("babylon-to-esprima", () => {
|
||||
|
||||
}
|
||||
}
|
||||
`)
|
||||
);
|
||||
`);
|
||||
});
|
||||
|
||||
it("ClassMethod oneline", () => {
|
||||
@ -464,14 +443,12 @@ describe("babylon-to-esprima", () => {
|
||||
});
|
||||
|
||||
it("ObjectMethod", () => {
|
||||
parseAndAssertSame(
|
||||
unpad(`
|
||||
parseAndAssertSame(`
|
||||
var a = {
|
||||
b(c) {
|
||||
}
|
||||
}
|
||||
`)
|
||||
);
|
||||
`);
|
||||
});
|
||||
|
||||
it("do not allow import export everywhere", () => {
|
||||
@ -496,8 +473,7 @@ describe("babylon-to-esprima", () => {
|
||||
|
||||
it("getters and setters", () => {
|
||||
parseAndAssertSame("class A { get x ( ) { ; } }");
|
||||
parseAndAssertSame(
|
||||
unpad(`
|
||||
parseAndAssertSame(`
|
||||
class A {
|
||||
get x(
|
||||
)
|
||||
@ -505,11 +481,9 @@ describe("babylon-to-esprima", () => {
|
||||
;
|
||||
}
|
||||
}
|
||||
`)
|
||||
);
|
||||
`);
|
||||
parseAndAssertSame("class A { set x (a) { ; } }");
|
||||
parseAndAssertSame(
|
||||
unpad(`
|
||||
parseAndAssertSame(`
|
||||
class A {
|
||||
set x(a
|
||||
)
|
||||
@ -517,10 +491,8 @@ describe("babylon-to-esprima", () => {
|
||||
;
|
||||
}
|
||||
}
|
||||
`)
|
||||
);
|
||||
parseAndAssertSame(
|
||||
unpad(`
|
||||
`);
|
||||
parseAndAssertSame(`
|
||||
var B = {
|
||||
get x () {
|
||||
return this.ecks;
|
||||
@ -529,8 +501,7 @@ describe("babylon-to-esprima", () => {
|
||||
this.ecks = ecks;
|
||||
}
|
||||
};
|
||||
`)
|
||||
);
|
||||
`);
|
||||
});
|
||||
|
||||
it("RestOperator", () => {
|
||||
@ -546,13 +517,11 @@ describe("babylon-to-esprima", () => {
|
||||
});
|
||||
|
||||
it("Async/Await", () => {
|
||||
parseAndAssertSame(
|
||||
unpad(`
|
||||
parseAndAssertSame(`
|
||||
async function a() {
|
||||
await 1;
|
||||
}
|
||||
`)
|
||||
);
|
||||
`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user