feat: Test running overhaul, switch to Prettier & reformat everything (#1407)

* chore: Switch to Node 20 + Vitest

* chore: migrate to vitest mock functions

* chore: code style (switch to prettier)

* test: re-enable long-running test

Seems the switch to Node 20 and Vitest has vastly improved the code's and / or the test's runtime!

see #1193

* chore: code style

* chore: fix failing tests

* Updated Documentation in README.md

* Update contribution guidelines to state usage of Prettier

* fix: set prettier printWidth back to 80

* chore: apply updated code style automatically

* fix: set prettier line endings to lf again

* chore: apply updated code style automatically

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Lars Müller <34514239+appgurueu@users.noreply.github.com>
This commit is contained in:
Roland Hummel
2023-10-03 23:08:19 +02:00
committed by GitHub
parent 0ca18c2b2c
commit 86d333ee94
392 changed files with 5849 additions and 16622 deletions

View File

@@ -21,7 +21,7 @@ const volCuboid = (width, length, height) => {
isNumber(width, 'Width')
isNumber(length, 'Length')
isNumber(height, 'Height')
return (width * length * height)
return width * length * height
}
/*
@@ -31,7 +31,7 @@ const volCuboid = (width, length, height) => {
*/
const volCube = (length) => {
isNumber(length, 'Length')
return (length ** 3)
return length ** 3
}
/*
@@ -42,7 +42,7 @@ const volCube = (length) => {
const volCone = (radius, height) => {
isNumber(radius, 'Radius')
isNumber(height, 'Height')
return (Math.PI * radius ** 2 * height / 3.0)
return (Math.PI * radius ** 2 * height) / 3.0
}
/*
@@ -65,7 +65,7 @@ const volPyramid = (baseLength, baseWidth, height) => {
const volCylinder = (radius, height) => {
isNumber(radius, 'Radius')
isNumber(height, 'Height')
return (Math.PI * radius ** 2 * height)
return Math.PI * radius ** 2 * height
}
/*
@@ -77,7 +77,7 @@ const volTriangularPrism = (baseLengthTriangle, heightTriangle, height) => {
isNumber(baseLengthTriangle, 'BaseLengthTriangle')
isNumber(heightTriangle, 'HeightTriangle')
isNumber(height, 'Height')
return (1 / 2 * baseLengthTriangle * heightTriangle * height)
return (1 / 2) * baseLengthTriangle * heightTriangle * height
}
/*
@@ -89,7 +89,7 @@ const volPentagonalPrism = (pentagonalLength, pentagonalBaseLength, height) => {
isNumber(pentagonalLength, 'PentagonalLength')
isNumber(pentagonalBaseLength, 'PentagonalBaseLength')
isNumber(height, 'Height')
return (5 / 2 * pentagonalLength * pentagonalBaseLength * height)
return (5 / 2) * pentagonalLength * pentagonalBaseLength * height
}
/*
@@ -99,7 +99,7 @@ const volPentagonalPrism = (pentagonalLength, pentagonalBaseLength, height) => {
*/
const volSphere = (radius) => {
isNumber(radius, 'Radius')
return (4 / 3 * Math.PI * radius ** 3)
return (4 / 3) * Math.PI * radius ** 3
}
/*
@@ -115,9 +115,19 @@ const volHemisphere = (radius) => {
const isNumber = (number, noName = 'number') => {
if (typeof number !== 'number') {
throw new TypeError('The ' + noName + ' should be Number type')
} else if (number < 0 || (!Number.isFinite(number))) {
} else if (number < 0 || !Number.isFinite(number)) {
throw new Error('The ' + noName + ' only accepts positive values')
}
}
export { volCuboid, volCube, volCone, volPyramid, volCylinder, volTriangularPrism, volPentagonalPrism, volSphere, volHemisphere }
export {
volCuboid,
volCube,
volCone,
volPyramid,
volCylinder,
volTriangularPrism,
volPentagonalPrism,
volSphere,
volHemisphere
}