eslint rule for empty line before the closing bracket
Asked Answered
P

1

7

Hi I'm trying to find an eslint rule for empty lines before closing bracket: I'm using react, here there is the example:

const test = () => (
 <div>
  Hello
 </div>
// This should show an error
)

eslint config: package.json

"eslint": "^4.19.1",
"eslint-config-airbnb": "^16.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.1",
"eslint-plugin-react": "^7.11.1",

.eslintrc

{
  "extends": "airbnb",
  "parser": "babel-eslint",
  "rules": {
    "max-len": ["error", { "code": 80, "ignoreUrls": true }],
    "no-console": [2]
  },
  "env": {
    "browser": true
  }
}
Precise answered 15/10, 2018 at 22:38 Comment(1)
Maybe https://eslint.org/docs/rules/space-in-parens?Tetragon
B
2

This is specialized enough that there I could not find a standard rule handling it. The closest is padded-blocks for handling empty lines at both the beginning and end of a block. padded-blocks: ["error", "never"] is a default for airbnb and triggers for empty lines. Unfortunately, it applies to braces, not parentheses.

spaces-in-parens does handle the beginnings and ends of parens, but only enforces/bars spaces, not whitespace such as newlines. padding-lines-between-statements would help if there was any way to define the two components as statements - but they are not.

I did not spot a plugin with this functionality, though there are [plenty to look through]. The easiest solution would be to make a custom rule (package) based on padded-blocks, with braces replaced by parens.

Built answered 15/10, 2018 at 22:50 Comment(2)
Hi MBerka, thanks for the answer but unfortunalty didn't work :(Precise
is there solution for paranthesis?Aware

© 2022 - 2024 — McMap. All rights reserved.