Skip to content

Commit 9d8dff7

Browse files
committed
Install ESLint and cleanup tests.
1 parent dd22d16 commit 9d8dff7

4 files changed

Lines changed: 1267 additions & 14 deletions

File tree

.eslintrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"env": {
3+
"es6": true,
4+
"jest": true,
5+
"node": true
6+
},
7+
"extends": "eslint:recommended"
8+
}

lib/__tests__/index.js

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,44 @@
1-
const babel = require('@babel/core')
2-
const plugin = require('../index.js')
1+
const babel = require('@babel/core');
2+
const plugin = require('../index.js');
33

44
const options = {
55
presets: [
6-
["@babel/env", {
7-
"modules": false
6+
['@babel/env', {
7+
modules: false
88
}]
99
],
1010
plugins: [
1111
plugin
1212
]
13-
}
13+
};
1414

1515
it('Module imports are stripped', () => {
16-
var example = `
17-
import fs from 'fs'
18-
import path from 'path'
19-
`
20-
21-
const {code} = babel.transform(example, options)
22-
expect(code.length).toBe(0)
23-
})
16+
const example = `
17+
import path from 'path';
18+
`;
19+
20+
const { code } = babel.transformSync(example, options);
21+
expect(code.length).toBe(0);
22+
});
23+
24+
it('Module exports are stripped', () => {
25+
const example = `
26+
export default 42;
27+
`;
28+
29+
const { code } = babel.transformSync(example, options);
30+
expect(code.length).toBe(0);
31+
});
32+
33+
it('Other code is retained', () => {
34+
const example = `
35+
import path from 'path';
36+
37+
console.log(path.sep);
38+
39+
export default 42;
40+
`;
41+
42+
const { code } = babel.transformSync(example, options);
43+
expect(code).toBe('console.log(path.sep);');
44+
});

0 commit comments

Comments
 (0)