othree / eslint-plugin-pep8-blank-lines

An ESLint blank line rule supports rule for different level. Inspired by PEP8.
https://www.npmjs.com/package/eslint-plugin-pep8-blank-lines
MIT License
2 stars 0 forks source link

Enforce blank lines between 'case' statements in switches #6

Open deb0ch opened 5 years ago

deb0ch commented 5 years ago

I would like to enforce the following syntax:

function yoloooo(toto: string) {
  let lol;
  switch (toto) {
    case 'foo': {
      const tata = 'blah';
      lol = `${toto} ${tata}`;
    }
      break;

    case 'bar':
      lol = 'baz';
      break;

    case 'baz':
      lol = '42';
      break;

    default:
      lol = 'prout';
  }

  return `Hello ${lol}`;
}

and I did so using

    "padding-line-between-statements": [
      "error",
      { "blankLine": "never", "prev": "block", "next": "*" },
      { "blankLine": "always", "prev": "*", "next": "case" },
      { "blankLine": "always", "prev": "*", "next": "return" }
    ],

in my .eslintrc.json, but pep8-blank-lines complains that newlines are forbidden here. I saw that setting this line to maxone makes it work for me, is there a way of setting that from the .eslintrc.json ?

Or, how can we make it work ?

Thanks in advance.