Skip to content

jsx-curly-spacing looks into functions #998

Closed
@ColCh

Description

@ColCh

It produces such warning (or error, It's not important)

/foo/src/components/Bar.js
  75:93  error  There should be no space before '}'  react/jsx-curly-spacing

On this line:

onLayout={() => { /* dummy callback to fix android bug with component measuring */ }}

I've got to debug this rule, this is what I've noticed.
for this function:

isSpaceBetweenTokens(first, second) {
        const text = this.text.slice(first.range[1], second.range[0]);

        return /\s/.test(text.replace(/\/\*.*?\*\//g, ""));
    }

these arguments are passed:
first:

{
  "type": "Block",
  "value": " dummy callback to fix android bug with component measuring ",
  "start": 1722,
  "end": 1786,
  "loc": {
    "start": {
      "line": 75,
      "column": 26
    },
    "end": {
      "line": 75,
      "column": 90
    }
  },
  "range": [
    1722,
    1786
  ]
}

second:

{
  "type": "Punctuator",
  "value": "}",
  "start": 1788,
  "end": 1789,
  "loc": {
    "start": {
      "line": 75,
      "column": 92
    },
    "end": {
      "line": 75,
      "column": 93
    }
  },
  "range": [
    1788,
    1789
  ]
}

and text becomes --> " }" ... but that space belongs to function, not for jsx curly brace

version is [email protected]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions