add modules common strict formatter - fixes #418
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
import { foo } from "foo";
|
||||
var foo;
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Illegal assignment of module import"
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
import { foo } from "foo";
|
||||
foo.bar = 1;
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Illegal assignment of module import"
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
import * as foo from "foo";
|
||||
foo = 1;
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Illegal assignment of module import"
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
import * as foo from "foo";
|
||||
var foo;
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Illegal assignment of module import"
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
import { foo as bar } from "foo";
|
||||
var bar;
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Illegal assignment of module import"
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
import { foo as bar } from "foo";
|
||||
bar = 1;
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Illegal assignment of module import"
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
import { foo } from "foo";
|
||||
import { foo } from "bar";
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Illegal assignment of module import"
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
import { foo as bar } from "foo";
|
||||
import { foo as bar } from "bar";
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Illegal assignment of module import"
|
||||
}
|
||||
2
test/fixtures/transformation/es6-modules-common-strict/.disallow-import-remapping/actual.js
vendored
Normal file
2
test/fixtures/transformation/es6-modules-common-strict/.disallow-import-remapping/actual.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { foo } from "foo";
|
||||
foo = 1;
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Illegal assignment of module import"
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default new Cachier()
|
||||
|
||||
export function Cachier(databaseName) {}
|
||||
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
exports.Cachier = Cachier;
|
||||
exports["default"] = new Cachier();
|
||||
function Cachier(databaseName) {}
|
||||
8
test/fixtures/transformation/es6-modules-common-strict/exports-default/actual.js
vendored
Normal file
8
test/fixtures/transformation/es6-modules-common-strict/exports-default/actual.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
export default 42;
|
||||
export default {};
|
||||
export default [];
|
||||
export default foo;
|
||||
export default function () {}
|
||||
export default class {}
|
||||
export default function foo () {}
|
||||
export default class Foo {}
|
||||
15
test/fixtures/transformation/es6-modules-common-strict/exports-default/expected.js
vendored
Normal file
15
test/fixtures/transformation/es6-modules-common-strict/exports-default/expected.js
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
|
||||
exports["default"] = foo;
|
||||
exports["default"] = 42;
|
||||
exports["default"] = {};
|
||||
exports["default"] = [];
|
||||
exports["default"] = foo;
|
||||
exports["default"] = function () {};
|
||||
|
||||
exports["default"] = function () {};
|
||||
|
||||
function foo() {}
|
||||
var Foo = function Foo() {};
|
||||
|
||||
exports["default"] = Foo;
|
||||
6
test/fixtures/transformation/es6-modules-common-strict/exports-from/actual.js
vendored
Normal file
6
test/fixtures/transformation/es6-modules-common-strict/exports-from/actual.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
export * from "foo";
|
||||
export {foo} from "foo";
|
||||
export {foo, bar} from "foo";
|
||||
export {foo as bar} from "foo";
|
||||
export {foo as default} from "foo";
|
||||
export {foo as default, bar} from "foo";
|
||||
25
test/fixtures/transformation/es6-modules-common-strict/exports-from/expected.js
vendored
Normal file
25
test/fixtures/transformation/es6-modules-common-strict/exports-from/expected.js
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireWildcard = function (obj) {
|
||||
return obj && obj.constructor === Object ? obj : {
|
||||
"default": obj
|
||||
};
|
||||
};
|
||||
|
||||
var _exportsWildcard = function (obj) {
|
||||
for (var i in obj) {
|
||||
if (exports[i] !== undefined) {
|
||||
exports[i] = obj[i];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_exportsWildcard(_interopRequireWildcard(require("foo")));
|
||||
|
||||
exports.foo = require("foo").foo;
|
||||
exports.foo = require("foo").foo;
|
||||
exports.bar = require("foo").bar;
|
||||
exports.bar = require("foo").foo;
|
||||
exports["default"] = require("foo").foo;
|
||||
exports["default"] = require("foo").foo;
|
||||
exports.bar = require("foo").bar;
|
||||
5
test/fixtures/transformation/es6-modules-common-strict/exports-named/actual.js
vendored
Normal file
5
test/fixtures/transformation/es6-modules-common-strict/exports-named/actual.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export {foo};
|
||||
export {foo, bar};
|
||||
export {foo as bar};
|
||||
export {foo as default};
|
||||
export {foo as default, bar};
|
||||
9
test/fixtures/transformation/es6-modules-common-strict/exports-named/expected.js
vendored
Normal file
9
test/fixtures/transformation/es6-modules-common-strict/exports-named/expected.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
exports.foo = foo;
|
||||
exports.foo = foo;
|
||||
exports.bar = bar;
|
||||
exports.bar = foo;
|
||||
exports["default"] = foo;
|
||||
exports["default"] = foo;
|
||||
exports.bar = bar;
|
||||
9
test/fixtures/transformation/es6-modules-common-strict/exports-variable/actual.js
vendored
Normal file
9
test/fixtures/transformation/es6-modules-common-strict/exports-variable/actual.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export var foo = 1;
|
||||
export var foo = 1, bar = 2;
|
||||
export var foo2 = function () {};
|
||||
export var foo3;
|
||||
export let foo4 = 2;
|
||||
export let foo5;
|
||||
export const foo6 = 3;
|
||||
export function foo7 () {}
|
||||
export class foo8 {}
|
||||
15
test/fixtures/transformation/es6-modules-common-strict/exports-variable/expected.js
vendored
Normal file
15
test/fixtures/transformation/es6-modules-common-strict/exports-variable/expected.js
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
|
||||
exports.foo7 = foo7;
|
||||
var foo = exports.foo = 1;
|
||||
var foo = exports.foo = 1;
|
||||
var bar = exports.bar = 2;
|
||||
var foo2 = exports.foo2 = function () {};
|
||||
var foo3 = exports.foo3 = undefined;
|
||||
var foo4 = exports.foo4 = 2;
|
||||
var foo5 = exports.foo5 = undefined;
|
||||
var foo6 = exports.foo6 = 3;
|
||||
function foo7() {}
|
||||
var foo8 = function foo8() {};
|
||||
|
||||
exports.foo8 = foo8;
|
||||
11
test/fixtures/transformation/es6-modules-common-strict/hoist-function-exports/actual.js
vendored
Normal file
11
test/fixtures/transformation/es6-modules-common-strict/hoist-function-exports/actual.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import { isEven } from "./evens";
|
||||
|
||||
export function nextOdd(n) {
|
||||
return isEven(n) ? n + 1 : n + 2;
|
||||
}
|
||||
|
||||
export var isOdd = (function (isEven) {
|
||||
return function (n) {
|
||||
return !isEven(n);
|
||||
};
|
||||
})(isEven);
|
||||
13
test/fixtures/transformation/es6-modules-common-strict/hoist-function-exports/expected.js
vendored
Normal file
13
test/fixtures/transformation/es6-modules-common-strict/hoist-function-exports/expected.js
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
|
||||
exports.nextOdd = nextOdd;
|
||||
var isEven = require("./evens").isEven;
|
||||
function nextOdd(n) {
|
||||
return isEven(n) ? n + 1 : n + 2;
|
||||
}
|
||||
|
||||
var isOdd = exports.isOdd = (function (isEven) {
|
||||
return function (n) {
|
||||
return !isEven(n);
|
||||
};
|
||||
})(isEven);
|
||||
2
test/fixtures/transformation/es6-modules-common-strict/imports-default/actual.js
vendored
Normal file
2
test/fixtures/transformation/es6-modules-common-strict/imports-default/actual.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import foo from "foo";
|
||||
import {default as foo2} from "foo";
|
||||
9
test/fixtures/transformation/es6-modules-common-strict/imports-default/expected.js
vendored
Normal file
9
test/fixtures/transformation/es6-modules-common-strict/imports-default/expected.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequire = function (obj) {
|
||||
return obj && (obj["default"] || obj);
|
||||
};
|
||||
|
||||
var foo = _interopRequire(require("foo"));
|
||||
|
||||
var foo2 = _interopRequire(require("foo"));
|
||||
1
test/fixtures/transformation/es6-modules-common-strict/imports-glob/actual.js
vendored
Normal file
1
test/fixtures/transformation/es6-modules-common-strict/imports-glob/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import * as foo from "foo";
|
||||
9
test/fixtures/transformation/es6-modules-common-strict/imports-glob/expected.js
vendored
Normal file
9
test/fixtures/transformation/es6-modules-common-strict/imports-glob/expected.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireWildcard = function (obj) {
|
||||
return obj && obj.constructor === Object ? obj : {
|
||||
"default": obj
|
||||
};
|
||||
};
|
||||
|
||||
var foo = _interopRequireWildcard(require("foo"));
|
||||
1
test/fixtures/transformation/es6-modules-common-strict/imports-mixing/actual.js
vendored
Normal file
1
test/fixtures/transformation/es6-modules-common-strict/imports-mixing/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import foo, {baz as xyz} from "foo";
|
||||
9
test/fixtures/transformation/es6-modules-common-strict/imports-mixing/expected.js
vendored
Normal file
9
test/fixtures/transformation/es6-modules-common-strict/imports-mixing/expected.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequire = function (obj) {
|
||||
return obj && (obj["default"] || obj);
|
||||
};
|
||||
|
||||
var foo = _interopRequire(require("foo"));
|
||||
|
||||
var xyz = require("foo").baz;
|
||||
4
test/fixtures/transformation/es6-modules-common-strict/imports-named/actual.js
vendored
Normal file
4
test/fixtures/transformation/es6-modules-common-strict/imports-named/actual.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import {bar} from "foo";
|
||||
import {bar2, baz} from "foo";
|
||||
import {bar as baz2} from "foo";
|
||||
import {bar as baz3, xyz} from "foo";
|
||||
8
test/fixtures/transformation/es6-modules-common-strict/imports-named/expected.js
vendored
Normal file
8
test/fixtures/transformation/es6-modules-common-strict/imports-named/expected.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
var bar = require("foo").bar;
|
||||
var bar2 = require("foo").bar2;
|
||||
var baz = require("foo").baz;
|
||||
var baz2 = require("foo").bar;
|
||||
var baz3 = require("foo").bar;
|
||||
var xyz = require("foo").xyz;
|
||||
3
test/fixtures/transformation/es6-modules-common-strict/imports/actual.js
vendored
Normal file
3
test/fixtures/transformation/es6-modules-common-strict/imports/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import "foo";
|
||||
import "foo-bar";
|
||||
import "./directory/foo-bar";
|
||||
7
test/fixtures/transformation/es6-modules-common-strict/imports/expected.js
vendored
Normal file
7
test/fixtures/transformation/es6-modules-common-strict/imports/expected.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
require("foo");
|
||||
|
||||
require("foo-bar");
|
||||
|
||||
require("./directory/foo-bar");
|
||||
3
test/fixtures/transformation/es6-modules-common-strict/options.json
vendored
Normal file
3
test/fixtures/transformation/es6-modules-common-strict/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"modules": "commonStrict"
|
||||
}
|
||||
10
test/fixtures/transformation/es6-modules-common-strict/overview/actual.js
vendored
Normal file
10
test/fixtures/transformation/es6-modules-common-strict/overview/actual.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import "foo";
|
||||
import "foo-bar";
|
||||
import "./directory/foo-bar";
|
||||
import foo from "foo";
|
||||
import * as foo2 from "foo";
|
||||
import {bar} from "foo";
|
||||
import {foo as bar2} from "foo";
|
||||
|
||||
export {test};
|
||||
export var test = 5;
|
||||
26
test/fixtures/transformation/es6-modules-common-strict/overview/expected.js
vendored
Normal file
26
test/fixtures/transformation/es6-modules-common-strict/overview/expected.js
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireWildcard = function (obj) {
|
||||
return obj && obj.constructor === Object ? obj : {
|
||||
"default": obj
|
||||
};
|
||||
};
|
||||
|
||||
var _interopRequire = function (obj) {
|
||||
return obj && (obj["default"] || obj);
|
||||
};
|
||||
|
||||
require("foo");
|
||||
|
||||
require("foo-bar");
|
||||
|
||||
require("./directory/foo-bar");
|
||||
|
||||
var foo = _interopRequire(require("foo"));
|
||||
|
||||
var foo2 = _interopRequireWildcard(require("foo"));
|
||||
|
||||
var bar = require("foo").bar;
|
||||
var bar2 = require("foo").foo;
|
||||
exports.test = test;
|
||||
var test = exports.test = 5;
|
||||
9
test/fixtures/transformation/es6-modules-common-strict/remap/actual.js
vendored
Normal file
9
test/fixtures/transformation/es6-modules-common-strict/remap/actual.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export var test = 2;
|
||||
test = 5;
|
||||
test++;
|
||||
|
||||
(function () {
|
||||
var test = 2;
|
||||
test = 3;
|
||||
test++;
|
||||
})();
|
||||
11
test/fixtures/transformation/es6-modules-common-strict/remap/expected.js
vendored
Normal file
11
test/fixtures/transformation/es6-modules-common-strict/remap/expected.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
var test = exports.test = 2;
|
||||
test = exports.test = 5;
|
||||
test = exports.test += 1;
|
||||
|
||||
(function () {
|
||||
var test = 2;
|
||||
test = 3;
|
||||
test++;
|
||||
})();
|
||||
Reference in New Issue
Block a user