lib/core-common/src/utils/load-custom-babel-config.ts
Function loadFromPath
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function loadFromPath(babelConfigPath: string): TransformOptions {
let config: TransformOptions;
const error: {
js?: Error;
json?: Error;
Function loadFromPath
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
function loadFromPath(babelConfigPath: string): TransformOptions {
let config: TransformOptions;
const error: {
js?: Error;
json?: Error;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
non-arrow functions are forbidden Open
Open
export const loadCustomBabelConfig = async function (
- Read upRead up
- Exclude checks
Rule: only-arrow-functions
Disallows traditional (non-arrow) function expressions.
Note that non-arrow functions are allowed if 'this' appears somewhere in its body (as such functions cannot be converted to arrow functions).
Rationale
Traditional functions don't bind lexical scope, which can lead to unexpected behavior when accessing 'this'.
Config
Two arguments may be optionally provided:
-
"allow-declarations"
allows standalone function declarations. -
"allow-named-functions"
allows the expressionfunction foo() {}
but notfunction() {}
.
Examples
"only-arrow-functions": true
"only-arrow-functions": true,allow-declarations,allow-named-functions
Schema
{
"type": "array",
"items": {
"type": "string",
"enum": [
"allow-declarations",
"allow-named-functions"
]
},
"minLength": 0,
"maxLength": 1
}
For more information see this page.