millermedeiros / esformatter

ECMAScript code beautifier/formatter
MIT License
970 stars 91 forks source link

Incorrect indentation if preceded by negation operator #443

Closed Faleij closed 8 years ago

Faleij commented 8 years ago

esformatter@0.9.4 >$ esformatter testIndent.js

// works as expected
function test(arr) {
    return arr.some(v => {
        return v;
    });
}

// does not work as expected; should have same level of indentation as above
function test(arr) {
    return !arr.some(v => {
            return v;
        });
}

let hasSome;

// works as expected
hasSome = arr.some(v => {
    return v;
});

// does not work as expected; should have same level of indentation as above
hasSome = !arr.some(v => {
        return v;
    });
$ eslint testIndent.js

\testIndent.js
  11:13  error  Expected indentation of 8 space characters but found 12  indent
  12:9   error  Expected indentation of 4 space characters but found 8   indent
  24:9   error  Expected indentation of 4 space characters but found 8   indent
  25:5   error  Expected indentation of 0 space characters but found 4   indent

✖ 4 problems (4 errors, 0 warnings)

.esformatter

{
    "indent": {
        "value": "    "
    }
}

.eslintrc

{
  "env": {
    "es6": true
  },
  "rules": {
    "indent": ["error", 4],
  }
}