1 | var fs = require('fs'); |
||
2 | |||
3 | fs.readFile('./src/utilities.js', 'utf8', function(err, data) { |
||
4 | if (err) { |
||
5 | return console.log(err); |
||
0 ignored issues
–
show
Debugging Code
introduced
by
![]() |
|||
6 | } |
||
7 | |||
8 | data = data.replace( |
||
9 | 'module.exports = utilities;', |
||
10 | 'export default utilities;' |
||
11 | ); |
||
12 | |||
13 | fs.writeFile('./utilities.es.js', data, 'utf8', function(err) { |
||
14 | if (err) return console.log(err); |
||
0 ignored issues
–
show
There is no return statement if
err is false . Are you sure this is correct? If so, consider adding return; explicitly.
This check looks for functions where a Consider this little piece of code function isBig(a) {
if (a > 5000) {
return "yes";
}
}
console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined
The function This behaviour may not be what you had intended. In any case, you can add a
![]() Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed. ![]() |
|||
15 | }); |
||
0 ignored issues
–
show
|
|||
16 | }); |
||
17 |