diff --git a/index.js b/index.js index 03964750..80c03e6a 100644 --- a/index.js +++ b/index.js @@ -185,6 +185,16 @@ function isSourceElement(node) { case "VariableDeclaration": case "WhileStatement": case "WithStatement": + case "ClassDeclaration": // ES 2015 + case "ImportDeclaration": // Module + case "ExportDefaultDeclaration": // Module + case "ExportNamedDeclaration": // Module + case "ExportAllDeclaration": // Module + case "TypeAlias": // Flow + case "InterfaceDeclaration": // Flow, Typescript + case "TypeAliasDeclaration": // Typescript + case "ExportAssignment": // Typescript + case "ExportDeclaration": // Typescript return true; } return false; diff --git a/tests/range/__snapshots__/jsfmt.spec.js.snap b/tests/range/__snapshots__/jsfmt.spec.js.snap index ecf11f21..46dece52 100644 --- a/tests/range/__snapshots__/jsfmt.spec.js.snap +++ b/tests/range/__snapshots__/jsfmt.spec.js.snap @@ -1,5 +1,22 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`class-declaration.js 1`] = ` + + +class a { + b( ) {} +} + +let x~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +class a { + b() {} +} + +let x +`; + exports[`different-levels.js 1`] = ` call(1,2,3) call(1,2,3) @@ -41,6 +58,97 @@ function ugly ( {a=1, b = 2 } ) { } } +`; + +exports[`module-export1.js 1`] = ` +import def , {named} from 'x' + +export * from 'd' + +export const x + = 42 + +export default 42 + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +import def , {named} from 'x' + +export * from "d"; + +export const x + = 42 + +export default 42 + + +`; + +exports[`module-export2.js 1`] = ` +import def , {named} from 'x' + +export * from 'd' + +export const x + = 42 + +export default 42 + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +import def , {named} from 'x' + +export * from 'd' + +export const x = 42; + +export default 42 + + +`; + +exports[`module-export3.js 1`] = ` +import def , {named} from 'x' + +export * from 'd' + +export const x + = 42 + +export default 42 + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +import def , {named} from 'x' + +export * from 'd' + +export const x + = 42 + +export default 42; + + +`; + +exports[`module-import.js 1`] = ` +import def , {named} from 'x' + +export * from 'd' + +export const x + = 42 + +export default 42 + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +import def, { named } from "x"; + +export * from 'd' + +export const x + = 42 + +export default 42 + + `; exports[`multiple-statements.js 1`] = ` diff --git a/tests/range/class-declaration.js b/tests/range/class-declaration.js new file mode 100644 index 00000000..58eeb834 --- /dev/null +++ b/tests/range/class-declaration.js @@ -0,0 +1,7 @@ + + +class <<>> a { + b( ) {}<<>> +} + +let x \ No newline at end of file diff --git a/tests/range/module-export1.js b/tests/range/module-export1.js new file mode 100644 index 00000000..62cf4856 --- /dev/null +++ b/tests/range/module-export1.js @@ -0,0 +1,9 @@ +import def , {named} from 'x' + +export * <<>> from 'd'<<>> + +export const x + = 42 + +export default 42 + diff --git a/tests/range/module-export2.js b/tests/range/module-export2.js new file mode 100644 index 00000000..d7a464f4 --- /dev/null +++ b/tests/range/module-export2.js @@ -0,0 +1,9 @@ +import def , {named} from 'x' + +export * from 'd' +<<>> +export const x + <<>>= 42 + +export default 42 + diff --git a/tests/range/module-export3.js b/tests/range/module-export3.js new file mode 100644 index 00000000..b536ff17 --- /dev/null +++ b/tests/range/module-export3.js @@ -0,0 +1,9 @@ +import def , {named} from 'x' + +export * from 'd' + +export const x + = 42 + +export default <<>> 42<<>> + diff --git a/tests/range/module-import.js b/tests/range/module-import.js new file mode 100644 index 00000000..c72e78c0 --- /dev/null +++ b/tests/range/module-import.js @@ -0,0 +1,9 @@ +import <<>> def , {named} <<>> from 'x' + +export * from 'd' + +export const x + = 42 + +export default 42 +