Skip to content

Commit 6159ac1

Browse files
committed
chore: upgrade prettier to v2
1 parent 1ca00d1 commit 6159ac1

File tree

6 files changed

+31
-31
lines changed

6 files changed

+31
-31
lines changed

package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"lodash": "4.17.20",
6969
"markdown-link-check": "3.8.4",
7070
"parcel-bundler": "1.12.4",
71-
"prettier": "1.19.1",
71+
"prettier": "2.2.1",
7272
"semantic-release": "17.3.0",
7373
"serve": "11.3.2",
7474
"start-server-and-test": "1.11.6",

support-utils.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ const filterSpecsFromCoverage = (totalCoverage, config = Cypress.config) => {
2222

2323
const isUsingDefaultTestPattern = testFilePattern === '**/*.*'
2424

25-
const isTestFile = filename => {
26-
const matchedPattern = testFilePatterns.some(specPattern =>
25+
const isTestFile = (filename) => {
26+
const matchedPattern = testFilePatterns.some((specPattern) =>
2727
Cypress.minimatch(filename, specPattern)
2828
)
29-
const matchedEndOfPath = testFilePatterns.some(specPattern =>
29+
const matchedEndOfPath = testFilePatterns.some((specPattern) =>
3030
filename.endsWith(specPattern)
3131
)
3232
return matchedPattern || matchedEndOfPath
3333
}
3434

35-
const isInIntegrationFolder = filename =>
35+
const isInIntegrationFolder = (filename) =>
3636
filename.startsWith(integrationFolder)
3737

3838
const isA = (fileCoverge, filename) => isInIntegrationFolder(filename)
@@ -50,13 +50,13 @@ const filterSpecsFromCoverage = (totalCoverage, config = Cypress.config) => {
5050
* or containing Webpack loaders and query parameters)
5151
*/
5252
function fixSourcePaths(coverage) {
53-
Object.values(coverage).forEach(file => {
53+
Object.values(coverage).forEach((file) => {
5454
const { path: absolutePath, inputSourceMap } = file
5555
const fileName = /([^\/\\]+)$/.exec(absolutePath)[1]
5656
if (!inputSourceMap || !fileName) return
5757

5858
if (inputSourceMap.sourceRoot) inputSourceMap.sourceRoot = ''
59-
inputSourceMap.sources = inputSourceMap.sources.map(source =>
59+
inputSourceMap.sources = inputSourceMap.sources.map((source) =>
6060
source.includes(fileName) ? absolutePath : source
6161
)
6262
})

support.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,23 @@ const sendCoverage = (coverage, pathname = '/') => {
2424
* so the user knows the log message is coming from this plugin.
2525
* @param {string} s Message to log.
2626
*/
27-
const logMessage = s => {
27+
const logMessage = (s) => {
2828
cy.log(`${s} \`[@cypress/code-coverage]\``)
2929
}
3030

3131
/**
3232
* Removes support file from the coverage object.
3333
* If there are more files loaded from support folder, also removes them
3434
*/
35-
const filterSupportFilesFromCoverage = totalCoverage => {
35+
const filterSupportFilesFromCoverage = (totalCoverage) => {
3636
const integrationFolder = Cypress.config('integrationFolder')
3737
const supportFile = Cypress.config('supportFile')
3838

3939
/** @type {string} Cypress run-time config has the support folder string */
4040
// @ts-ignore
4141
const supportFolder = Cypress.config('supportFolder')
4242

43-
const isSupportFile = filename => filename === supportFile
43+
const isSupportFile = (filename) => filename === supportFile
4444

4545
let coverage = Cypress._.omitBy(totalCoverage, (fileCoverage, filename) =>
4646
isSupportFile(filename)
@@ -93,7 +93,7 @@ const registerHooks = () => {
9393
// to let the user know the coverage has been collected
9494
windowCoverageObjects = []
9595

96-
const saveCoverageObject = win => {
96+
const saveCoverageObject = (win) => {
9797
// if application code has been instrumented, the app iframe "window" has an object
9898
const applicationSourceCoverage = win.__coverage__
9999
if (!applicationSourceCoverage) {
@@ -126,7 +126,7 @@ const registerHooks = () => {
126126
afterEach(() => {
127127
// save coverage after the test
128128
// because now the window coverage objects have been updated
129-
windowCoverageObjects.forEach(cover => {
129+
windowCoverageObjects.forEach((cover) => {
130130
sendCoverage(cover.coverage, cover.pathname)
131131
})
132132

@@ -172,10 +172,10 @@ const registerHooks = () => {
172172
log: false,
173173
failOnStatusCode: false
174174
})
175-
.then(r => {
175+
.then((r) => {
176176
return Cypress._.get(r, 'body.coverage', null)
177177
})
178-
.then(coverage => {
178+
.then((coverage) => {
179179
if (!coverage) {
180180
// we did not get code coverage - this is the
181181
// original failed request
@@ -209,7 +209,7 @@ const registerHooks = () => {
209209
cy.task('coverageReport', null, {
210210
timeout: Cypress.moment.duration(3, 'minutes').asMilliseconds(),
211211
log: false
212-
}).then(coverageReportFolder => {
212+
}).then((coverageReportFolder) => {
213213
logInstance.set('consoleProps', () => ({
214214
'coverage report folder': coverageReportFolder
215215
}))

task-utils.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ function findCommonRoot(filepaths) {
192192
}
193193

194194
// assuming / as file separator
195-
const splitParts = filepaths.map(name => name.split('/'))
196-
const lengths = splitParts.map(arr => arr.length)
195+
const splitParts = filepaths.map((name) => name.split('/'))
196+
const lengths = splitParts.map((arr) => arr.length)
197197
const shortestLength = Math.min.apply(null, lengths)
198198
debug('shorted file path has %d parts', shortestLength)
199199

@@ -205,19 +205,19 @@ function findCommonRoot(filepaths) {
205205
const part = splitParts[0][k]
206206
const prefix = commonPrefix.concat(part).join('/')
207207
debug('testing prefix %o', prefix)
208-
const allFilesStart = filepaths.every(name => name.startsWith(prefix))
208+
const allFilesStart = filepaths.every((name) => name.startsWith(prefix))
209209
if (!allFilesStart) {
210210
debug('stopped at non-common prefix %s', prefix)
211211
break
212212
}
213213

214214
commonPrefix.push(part)
215215

216-
const removedPrefixNames = filepaths.map(filepath =>
216+
const removedPrefixNames = filepaths.map((filepath) =>
217217
filepath.slice(prefix.length)
218218
)
219219
debug('removedPrefix %o', removedPrefixNames)
220-
const foundAllPaths = removedPrefixNames.every(filepath =>
220+
const foundAllPaths = removedPrefixNames.every((filepath) =>
221221
existsSync(join(cwd, filepath))
222222
)
223223
debug('all files found at %s? %o', prefix, foundAllPaths)
@@ -234,7 +234,7 @@ function findCommonRoot(filepaths) {
234234
function tryFindingLocalFiles(nycFilename) {
235235
const nycCoverage = JSON.parse(readFileSync(nycFilename, 'utf8'))
236236
const coverageKeys = Object.keys(nycCoverage)
237-
const filenames = coverageKeys.map(key => nycCoverage[key].path)
237+
const filenames = coverageKeys.map((key) => nycCoverage[key].path)
238238
const commonFolder = findCommonRoot(filenames)
239239
if (!commonFolder) {
240240
debug('could not find common folder %s', commonFolder)
@@ -249,7 +249,7 @@ function tryFindingLocalFiles(nycFilename) {
249249
const length = commonFolder.length
250250
let changed
251251

252-
coverageKeys.forEach(key => {
252+
coverageKeys.forEach((key) => {
253253
const from = nycCoverage[key].path
254254
if (from.startsWith(commonFolder)) {
255255
const to = join(cwd, from.slice(length))
@@ -298,13 +298,13 @@ function findSourceFiles(nycOptions) {
298298
patterns.push(nycOptions.include)
299299
} else {
300300
debug('using default list of extensions')
301-
nycOptions.extension.forEach(extension => {
301+
nycOptions.extension.forEach((extension) => {
302302
patterns.push('**/*' + extension)
303303
})
304304
}
305305

306306
if (Array.isArray(nycOptions.exclude)) {
307-
const negated = nycOptions.exclude.map(s => '!' + s)
307+
const negated = nycOptions.exclude.map((s) => '!' + s)
308308
patterns = patterns.concat(negated)
309309
} else if (typeof nycOptions.exclude === 'string') {
310310
patterns.push('!' + nycOptions.exclude)
@@ -343,7 +343,7 @@ function includeAllFiles(nycFilename, nycOptions) {
343343

344344
const nycCoverage = JSON.parse(readFileSync(nycFilename, 'utf8'))
345345
const coverageKeys = Object.keys(nycCoverage)
346-
const coveredPaths = coverageKeys.map(key => nycCoverage[key].path)
346+
const coveredPaths = coverageKeys.map((key) => nycCoverage[key].path)
347347

348348
debug('coverage has %d record(s)', coveredPaths.length)
349349
// report on first couple of entries
@@ -353,7 +353,7 @@ function includeAllFiles(nycFilename, nycOptions) {
353353
}
354354

355355
let changed
356-
allFiles.forEach(fullPath => {
356+
allFiles.forEach((fullPath) => {
357357
if (coveredPaths.includes(fullPath)) {
358358
// all good, this file exists in coverage object
359359
return

task.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ function maybePrintFinalCoverageFiles(folder) {
8383
jsonReportFilename
8484
)
8585

86-
finalCoverageKeys.forEach(key => {
86+
finalCoverageKeys.forEach((key) => {
8787
const s = finalCoverage[key].s || {}
8888
const statements = Object.keys(s)
8989
const totalStatements = statements.length
9090
let coveredStatements = 0
91-
statements.forEach(statementKey => {
91+
statements.forEach((statementKey) => {
9292
if (s[statementKey]) {
9393
coveredStatements += 1
9494
}

0 commit comments

Comments
 (0)