Skip to content

Commit 5a77aac

Browse files
committed
Enable prettier integration
1 parent 4ee21bf commit 5a77aac

File tree

133 files changed

+9475
-4533
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+9475
-4533
lines changed

examples/node.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919

2020
var neo4j = require('neo4j')
2121

22-
var statement = ['MERGE (alice:Person {name:{name_a},age:{age_a}})',
22+
var statement = [
23+
'MERGE (alice:Person {name:{name_a},age:{age_a}})',
2324
'MERGE (bob:Person {name:{name_b},age:{age_b}})',
2425
'CREATE UNIQUE (alice)-[alice_knows_bob:KNOWS]->(bob)',
2526
'RETURN alice, bob, alice_knows_bob'
@@ -58,18 +59,19 @@ streamResult.subscribe({
5859

5960
var promiseSession = driver.session()
6061
var promiseResult = promiseSession.run(statement.join(' '), params)
61-
promiseResult.then(function (records) {
62-
records.forEach(function (record) {
63-
for (var i in record) {
64-
console.log(i)
65-
console.log(record[i])
66-
}
62+
promiseResult
63+
.then(function (records) {
64+
records.forEach(function (record) {
65+
for (var i in record) {
66+
console.log(i)
67+
console.log(record[i])
68+
}
69+
})
70+
var summary = promiseResult.summarize()
71+
// Print number of nodes created
72+
console.log('')
73+
console.log(summary.updateStatistics.nodesCreated())
6774
})
68-
var summary = promiseResult.summarize()
69-
// Print number of nodes created
70-
console.log('')
71-
console.log(summary.updateStatistics.nodesCreated())
72-
})
7375
.catch(function (error) {
7476
console.log(error)
7577
})

gulpfile.babel.js

Lines changed: 122 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ gulp.task('build-browser', function () {
6363
cache: {},
6464
standalone: 'neo4j',
6565
packageCache: {}
66-
}).transform(babelifyTransform())
66+
})
67+
.transform(babelifyTransform())
6768
.transform(browserifyTransformNodeToBrowserRequire())
6869
.bundle()
6970

@@ -84,39 +85,50 @@ gulp.task('build-browser', function () {
8485
gulp.task('build-browser-test', function () {
8586
var browserOutput = 'build/browser/'
8687
var testFiles = []
87-
return gulp.src(['./test/**/*.test.js', '!./test/**/node/*.js'])
88-
.pipe(through.obj(function (file, enc, cb) {
89-
if (file.path.indexOf('examples.test.js') < 0) {
90-
testFiles.push(file.path)
91-
}
92-
cb()
93-
}, function (cb) {
94-
// At end-of-stream, push the list of files to the next step
95-
this.push(testFiles)
96-
cb()
97-
}))
98-
.pipe(through.obj(function (testFiles, enc, cb) {
99-
browserify({
100-
entries: testFiles,
101-
cache: {},
102-
debug: true
103-
}).transform(babelifyTransform())
104-
.transform(browserifyTransformNodeToBrowserRequire())
105-
.bundle(function () {
88+
return gulp
89+
.src(['./test/**/*.test.js', '!./test/**/node/*.js'])
90+
.pipe(
91+
through.obj(
92+
function (file, enc, cb) {
93+
if (file.path.indexOf('examples.test.js') < 0) {
94+
testFiles.push(file.path)
95+
}
10696
cb()
107-
})
108-
.on('error', gutil.log)
109-
.pipe(source('neo4j-web.test.js'))
110-
.pipe(gulp.dest(browserOutput))
111-
},
112-
function (cb) {
113-
cb()
114-
}
115-
))
97+
},
98+
function (cb) {
99+
// At end-of-stream, push the list of files to the next step
100+
this.push(testFiles)
101+
cb()
102+
}
103+
)
104+
)
105+
.pipe(
106+
through.obj(
107+
function (testFiles, enc, cb) {
108+
browserify({
109+
entries: testFiles,
110+
cache: {},
111+
debug: true
112+
})
113+
.transform(babelifyTransform())
114+
.transform(browserifyTransformNodeToBrowserRequire())
115+
.bundle(function () {
116+
cb()
117+
})
118+
.on('error', gutil.log)
119+
.pipe(source('neo4j-web.test.js'))
120+
.pipe(gulp.dest(browserOutput))
121+
},
122+
function (cb) {
123+
cb()
124+
}
125+
)
126+
)
116127
})
117128

118129
var buildNode = function (options) {
119-
return gulp.src(options.src)
130+
return gulp
131+
.src(options.src)
120132
.pipe(babel(babelConfig()))
121133
.pipe(gulp.dest(options.dest))
122134
}
@@ -138,8 +150,8 @@ gulp.task('install-driver-into-sandbox', ['nodejs'], function () {
138150
fs.emptyDirSync(testDir)
139151

140152
var packageJsonContent = JSON.stringify({
141-
'private': true,
142-
'dependencies': {
153+
private: true,
154+
dependencies: {
143155
'neo4j-driver': __dirname
144156
}
145157
})
@@ -150,22 +162,31 @@ gulp.task('install-driver-into-sandbox', ['nodejs'], function () {
150162
})
151163

152164
gulp.task('test', function (cb) {
153-
runSequence('run-ts-declaration-tests', 'test-nodejs', 'test-browser', function (err) {
154-
if (err) {
155-
var exitCode = 2
156-
console.log('[FAIL] test task failed - exiting with code ' + exitCode)
157-
return process.exit(exitCode)
165+
runSequence(
166+
'run-ts-declaration-tests',
167+
'test-nodejs',
168+
'test-browser',
169+
function (err) {
170+
if (err) {
171+
var exitCode = 2
172+
console.log('[FAIL] test task failed - exiting with code ' + exitCode)
173+
return process.exit(exitCode)
174+
}
175+
return cb()
158176
}
159-
return cb()
160-
})
177+
)
161178
})
162179

163180
gulp.task('test-nodejs', ['install-driver-into-sandbox'], function () {
164-
return gulp.src(['./test/**/*.test.js', '!./test/**/browser/*.js'])
165-
.pipe(jasmine({
166-
includeStackTrace: true,
167-
reporter: newJasmineConsoleReporter()
168-
})).on('end', logActiveNodeHandles)
181+
return gulp
182+
.src(['./test/**/*.test.js', '!./test/**/browser/*.js'])
183+
.pipe(
184+
jasmine({
185+
includeStackTrace: true,
186+
reporter: newJasmineConsoleReporter()
187+
})
188+
)
189+
.on('end', logActiveNodeHandles)
169190
})
170191

171192
gulp.task('test-browser', function (cb) {
@@ -193,9 +214,12 @@ gulp.task('run-browser-test-ie', function (cb) {
193214
})
194215

195216
gulp.task('watch', function () {
196-
return watch('src/**/*.js', batch(function (events, done) {
197-
gulp.start('all', done)
198-
}))
217+
return watch(
218+
'src/**/*.js',
219+
batch(function (events, done) {
220+
gulp.start('all', done)
221+
})
222+
)
199223
})
200224

201225
gulp.task('watch-n-test', ['test-nodejs'], function () {
@@ -213,7 +237,8 @@ gulp.task('set', function () {
213237

214238
// Change the version in relevant files
215239
var versionFile = path.join('src', 'version.js')
216-
return gulp.src([versionFile], { base: './' })
240+
return gulp
241+
.src([versionFile], { base: './' })
217242
.pipe(replace('0.0.0-dev', version))
218243
.pipe(gulp.dest('./'))
219244
})
@@ -231,30 +256,39 @@ gulp.task('stop-neo4j', function (done) {
231256
})
232257

233258
gulp.task('run-stress-tests', function () {
234-
return gulp.src('test/**/stress.test.js')
235-
.pipe(jasmine({
236-
includeStackTrace: true,
237-
reporter: newJasmineConsoleReporter()
238-
})).on('end', logActiveNodeHandles)
259+
return gulp
260+
.src('test/**/stress.test.js')
261+
.pipe(
262+
jasmine({
263+
includeStackTrace: true,
264+
reporter: newJasmineConsoleReporter()
265+
})
266+
)
267+
.on('end', logActiveNodeHandles)
239268
})
240269

241270
gulp.task('run-ts-declaration-tests', function () {
242271
var failed = false
243272

244-
return gulp.src(['test/types/**/*', 'types/**/*'], { base: '.' })
245-
.pipe(ts({
246-
module: 'es6',
247-
target: 'es6',
248-
noImplicitAny: true,
249-
noImplicitReturns: true,
250-
strictNullChecks: true
251-
}))
273+
return gulp
274+
.src(['test/types/**/*', 'types/**/*'], { base: '.' })
275+
.pipe(
276+
ts({
277+
module: 'es6',
278+
target: 'es6',
279+
noImplicitAny: true,
280+
noImplicitReturns: true,
281+
strictNullChecks: true
282+
})
283+
)
252284
.on('error', function () {
253285
failed = true
254286
})
255287
.on('finish', function () {
256288
if (failed) {
257-
console.log('[ERROR] TypeScript declarations contain errors. Exiting...')
289+
console.log(
290+
'[ERROR] TypeScript declarations contain errors. Exiting...'
291+
)
258292
process.exit(1)
259293
}
260294
})
@@ -263,7 +297,11 @@ gulp.task('run-ts-declaration-tests', function () {
263297

264298
function logActiveNodeHandles () {
265299
if (enableActiveNodeHandlesLogging) {
266-
console.log('-- Active NodeJS handles START\n', process._getActiveHandles(), '\n-- Active NodeJS handles END')
300+
console.log(
301+
'-- Active NodeJS handles START\n',
302+
process._getActiveHandles(),
303+
'\n-- Active NodeJS handles END'
304+
)
267305
}
268306
}
269307

@@ -283,33 +321,43 @@ function babelifyTransform () {
283321

284322
function babelConfig () {
285323
return {
286-
presets: ['env'], plugins: ['transform-runtime']
324+
presets: ['env'],
325+
plugins: ['transform-runtime']
287326
}
288327
}
289328

290329
function browserifyTransformNodeToBrowserRequire () {
291330
var nodeRequire = '/node'
292331
var browserRequire = '/browser'
293332

294-
return transformTools.makeRequireTransform('bodeToBrowserRequireTransform',
333+
return transformTools.makeRequireTransform(
334+
'bodeToBrowserRequireTransform',
295335
{ evaluateArguments: true },
296336
function (args, opts, cb) {
297337
var requireArg = args[0]
298-
var endsWithNodeRequire = requireArg.slice(-nodeRequire.length) === nodeRequire
338+
var endsWithNodeRequire =
339+
requireArg.slice(-nodeRequire.length) === nodeRequire
299340
if (endsWithNodeRequire) {
300341
var newRequireArg = requireArg.replace(nodeRequire, browserRequire)
301-
return cb(null, 'require(\'' + newRequireArg + '\')')
342+
return cb(null, "require('" + newRequireArg + "')")
302343
} else {
303344
return cb()
304345
}
305-
})
346+
}
347+
)
306348
}
307349

308350
function runKarma (browser, cb) {
309-
new karma.Server({
310-
configFile: path.join(__dirname, `/test/browser/karma-${browser}.conf.js`),
311-
singleRun: true
312-
}, function (exitCode) {
313-
exitCode ? process.exit(exitCode) : cb()
314-
}).start()
351+
new karma.Server(
352+
{
353+
configFile: path.join(
354+
__dirname,
355+
`/test/browser/karma-${browser}.conf.js`
356+
),
357+
singleRun: true
358+
},
359+
function (exitCode) {
360+
exitCode ? process.exit(exitCode) : cb()
361+
}
362+
).start()
315363
}

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"scripts": {
1212
"lint": "eslint --fix --ext .js ./",
13+
"format": "prettier-eslint '**/*.js' '**/*.ts' --write",
1314
"test": "gulp test",
1415
"build": "gulp all",
1516
"start-neo4j": "gulp start-neo4j",
@@ -73,6 +74,8 @@
7374
"lolex": "^1.5.2",
7475
"minimist": "^1.2.0",
7576
"mustache": "^2.3.0",
77+
"prettier-eslint": "^8.8.2",
78+
"prettier-eslint-cli": "^4.7.1",
7679
"run-sequence": "^1.1.4",
7780
"semver": "^5.3.0",
7881
"through2": "~2.0.0",

0 commit comments

Comments
 (0)