/
_config.js
72 lines (70 loc) · 1.56 KB
/
_config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const assert = require('assert');
const path = require('path');
const { assertIncludes } = require('../../../utils.js');
const ID_MAIN = path.join(__dirname, 'main.js');
const ID_FOO = path.join(__dirname, 'foo.js');
module.exports = {
description: 'warns for reassignments to namespace exports',
code(code) {
assertIncludes(code, 'foo = 2');
assertIncludes(code, 'undefined = 3');
},
warnings: [
{
binding: 'bar',
code: 'MISSING_EXPORT',
exporter: ID_FOO,
id: ID_MAIN,
message: '"bar" is not exported by "foo.js", imported by "main.js".',
url: 'https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module',
pos: 48,
loc: {
column: 4,
file: ID_MAIN,
line: 4
},
frame: `
2:
3: exp.foo = 2;
4: exp.bar = 3;
^`
},
{
code: 'ILLEGAL_REASSIGNMENT',
message: 'Illegal reassignment of import "exp" in "main.js".',
id: ID_MAIN,
pos: 31,
loc: {
column: 0,
file: ID_MAIN,
line: 3
},
frame: `
1: import * as exp from './foo';
2:
3: exp.foo = 2;
^
4: exp.bar = 3;`
},
{
code: 'ILLEGAL_REASSIGNMENT',
message: 'Illegal reassignment of import "exp" in "main.js".',
id: ID_MAIN,
pos: 44,
loc: {
column: 0,
file: ID_MAIN,
line: 4
},
frame: `
2:
3: exp.foo = 2;
4: exp.bar = 3;
^`
}
],
runtimeError(error) {
assert.strictEqual(error.message, 'Assignment to constant variable.');
}
};
// test copied from https://github.com/esnext/es6-module-transpiler/tree/master/test/examples/namespace-reassign-import-fails