Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to avoid "Octal literals are not allowed in strict mode" with createWriteStream

Tags:

node.js

lint

I have the following code

fs.createWriteStream( fileName, {
  flags: 'a',
  encoding: 'utf8',
  mode: 0644
});

I get a lint error

Octal literals are not allowed in strict mode.

What is the correct way to do this code so I won't get a lint error?

like image 207
guy mograbi Avatar asked Sep 29 '22 04:09

guy mograbi


People also ask

Are octal literals allowed in strict mode?

Octal literals are not allowed in strict mode. What is the correct way to do this code so I won't get a lint error? Show activity on this post. Show activity on this post. In node and in modern browsers (see compatibility ), you can use octal literals:

What went wrong with octal literals?

SyntaxError in strict mode only. What went wrong? Octal literals and octal escape sequences are deprecated and will throw a SyntaxError in strict mode. With ECMAScript 2015 and later, the standardized syntax uses a leading zero followed by a lowercase or uppercase Latin letter "O" ( 0o or 0O) .

What does the JavaScript strict mode-only exception 0o mean?

The JavaScript strict mode -only exception "0-prefixed octal literals and octal escape sequences are deprecated; for octal literals use the "0o" prefix instead" occurs when deprecated octal literals and octal escape sequences are used. SyntaxError in strict mode only. What went wrong?

Are octal literals deprecated in ECMAScript?

Octal literals and octal escape sequences are deprecated and will throw a SyntaxError in strict mode. With ECMAScript 2015 and later, the standardized syntax uses a leading zero followed by a lowercase or uppercase Latin letter "O" ( 0o or 0O).


1 Answers

I came through this problem while using it in a scape squence:

console.log('\033c'); // Clear screen

All i had to do was convert it to Hex

console.log('\x1Bc'); // Clear screen
like image 70
ariel Avatar answered Oct 10 '22 20:10

ariel