javascriptvisual-studio-codeeslintprettierjs-beautify

How to enforce exactly 1 space before blocks (space-before-blocks) with eslint?


the problem in vscode: eslint ignores extra spaces when fixing:

function() { - i need exactly 1 space here.

the same happens with object notation:

const test = { prop: true }; -> const test = {prop: true}; (doesnt work).

either there're some other rules to force proper formatting or eslint is pretty limited at formatting.

on the other hand i dont like prettier since it destroys empty lines and js-beautify is limited in options also.

any suggestions how to fix this problem?


Solution

  • Add

    'no-multi-spaces': ['error']