Skip to content
This repository was archived by the owner on Jan 31, 2023. It is now read-only.

Commit 86f0a33

Browse files
Merge pull request #3 from cypress-io/prettier-eslint
using prettier-eslint
2 parents 46f2200 + a91aba0 commit 86f0a33

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

index.js

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ const defaultOptions = {
1717
browserifyOptions: {
1818
extensions: ['.js', '.jsx', '.coffee', '.cjsx'],
1919
transform: [
20-
[
21-
require.resolve('./cjsxify'),
22-
{},
23-
],
20+
[require.resolve('./cjsxify'), {}],
2421
[
2522
require.resolve('babelify'),
2623
{
@@ -30,7 +27,9 @@ const defaultOptions = {
3027
plugins: ['babel-plugin-add-module-exports'].map(require.resolve),
3128
// babel-preset-env supports any JS that's stage-4, meaning it's
3229
// completely finalized in the ECMA standard
33-
presets: ['babel-preset-env', 'babel-preset-react'].map(require.resolve),
30+
presets: ['babel-preset-env', 'babel-preset-react'].map(
31+
require.resolve
32+
),
3433
},
3534
],
3635
],
@@ -61,8 +60,16 @@ const preprocessor = (options = {}) => {
6160
log('received user options', options)
6261

6362
// allow user to override default options
64-
const browserifyOptions = Object.assign({}, defaultOptions.browserifyOptions, options.browserifyOptions)
65-
const watchifyOptions = Object.assign({}, defaultOptions.watchifyOptions, options.watchifyOptions)
63+
const browserifyOptions = Object.assign(
64+
{},
65+
defaultOptions.browserifyOptions,
66+
options.browserifyOptions
67+
)
68+
const watchifyOptions = Object.assign(
69+
{},
70+
defaultOptions.watchifyOptions,
71+
options.watchifyOptions
72+
)
6673

6774
// we return function that accepts the arguments provided by
6875
// the event 'file:preprocessor'
@@ -152,18 +159,20 @@ const preprocessor = (options = {}) => {
152159
log(`update ${filePath}`)
153160
// we overwrite the cached bundle promise, so on subsequent invocations
154161
// it gets the latest bundle
155-
const bundlePromise = bundles[filePath] = bundle()
156-
.finally(() => {
162+
const bundlePromise = bundle().finally(() => {
157163
log(`- update finished for ${filePath}`)
158164
file.emit('rerun')
159165
})
166+
bundles[filePath] = bundlePromise
160167
// we suppress unhandled rejections so they don't bubble up to the
161168
// unhandledRejection handler and crash the app. Cypress will eventually
162169
// take care of the rejection when the file is requested
163170
bundlePromise.suppressUnhandledRejections()
164171
})
165172

166-
const bundlePromise = fs.ensureDirAsync(path.dirname(outputPath)).then(bundle)
173+
const bundlePromise = fs
174+
.ensureDirAsync(path.dirname(outputPath))
175+
.then(bundle)
167176

168177
// cache the bundle promise, so it can be returned if this function
169178
// is invoked again with the same filePath

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@
2626
"ban": "ban",
2727
"deps": "deps-ok && dependency-check --no-dev .",
2828
"license": "license-checker --production --onlyunknown --csv",
29-
"lint": "eslint --fix *.js",
29+
"lint": "prettier-eslint --write '*.js'",
3030
"secure": "nsp check",
3131
"size": "t=\"$(npm pack .)\"; wc -c \"${t}\"; tar tvf \"${t}\"; rm \"${t}\";",
32+
"pretest": "npm run lint",
3233
"test": "mocha",
3334
"test-debug": "node --inspect --debug-brk ./node_modules/.bin/_mocha",
3435
"test-watch": "chokidar '*.js' 'test/*.js' -c 'npm test'",
@@ -43,13 +44,14 @@
4344
"deps-ok": "1.2.1",
4445
"dont-crack": "1.2.1",
4546
"eslint": "4.6.1",
46-
"eslint-plugin-cypress-dev": "1.0.0",
47+
"eslint-plugin-cypress-dev": "1.0.2",
4748
"eslint-plugin-mocha": "4.11.0",
4849
"github-post-release": "1.13.1",
4950
"license-checker": "13.0.3",
5051
"mocha": "3.5.0",
5152
"mockery": "2.1.0",
5253
"nsp": "2.7.0",
54+
"prettier-eslint-cli": "4.4.0",
5355
"semantic-release": "8.2.0",
5456
"simple-commit-message": "3.3.1",
5557
"sinon": "3.2.1",

0 commit comments

Comments
 (0)