Skip to content

Commit 9cb7ab3

Browse files
author
Kent C. Dodds
committed
add transpilation 👻
1 parent 9f04f9f commit 9cb7ab3

File tree

4 files changed

+29
-10
lines changed

4 files changed

+29
-10
lines changed

‎.eslintrc‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
"extends": [
77
"kentcdodds/best-practices",
88
"kentcdodds/possible-errors",
9+
"kentcdodds/es6/best-practices",
10+
"kentcdodds/es6/possible-errors",
11+
"kentcdodds/import/best-practices",
12+
"kentcdodds/import/possible-errors",
913
"kentcdodds/mocha"
1014
],
1115
"rules": {},

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules/
22
.nyc_output/
33
coverage/
4+
dist/

‎package.json‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
"name": "starwars-names",
33
"version": "1.0.0",
44
"description": "Get random Star Wars names",
5-
"main": "src/index.js",
5+
"main": "dist/index.js",
66
"scripts": {
7+
"prebuild": "rimraf dist",
8+
"build": "babel --copy-files --out-dir dist --ignore *.test.js src",
79
"test": "nyc mocha",
810
"watch:test": "mocha --watch",
911
"lint": "eslint src",
10-
"validate": "npm-run-all --parallel test lint"
12+
"validate": "npm-run-all --parallel test lint build"
1113
},
1214
"repository": {
1315
"type": "git",
@@ -17,6 +19,9 @@
1719
"random",
1820
"star wars"
1921
],
22+
"files": [
23+
"dist"
24+
],
2025
"author": "Kent C. Dodds <[email protected]> (http://kentcdodds.com/)",
2126
"license": "MIT",
2227
"bugs": {
@@ -27,13 +32,16 @@
2732
"unique-random-array": "1.0.0"
2833
},
2934
"devDependencies": {
35+
"babel-cli": "6.11.4",
36+
"babel-preset-es2015": "6.9.0",
3037
"chai": "3.5.0",
3138
"eslint": "3.2.0",
3239
"eslint-config-kentcdodds": "^9.0.0",
3340
"ghooks": "1.3.2",
3441
"mocha": "3.0.0",
3542
"npm-run-all": "2.3.0",
36-
"nyc": "7.1.0"
43+
"nyc": "7.1.0",
44+
"rimraf": "2.5.4"
3745
},
3846
"nyc": {
3947
"all": true,
@@ -50,6 +58,11 @@
5058
"src"
5159
]
5260
},
61+
"babel": {
62+
"presets": [
63+
"es2015"
64+
]
65+
},
5366
"config": {
5467
"ghooks": {
5568
"pre-commit": "npm run validate"

‎src/index.js‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
'use strict';
1+
import uniqueRandomArray from 'unique-random-array'
2+
const starWarsNames = require('./starwars-names.json')
23

3-
var uniqueRandomArray = require('unique-random-array');
4-
var starWarsNames = require('./starwars-names.json');
5-
6-
module.exports = {
4+
const mainExport = {
75
all: starWarsNames,
8-
random: uniqueRandomArray(starWarsNames)
9-
};
6+
random: uniqueRandomArray(starWarsNames),
7+
}
8+
9+
export default mainExport
10+
module.exports = mainExport // for CommonJS compatibility

0 commit comments

Comments
 (0)