Eslint-plugin-react: 7.18.2 regression: react/jsx-indent lots of false positives

Created on 2 Feb 2020  路  6Comments  路  Source: yannickcr/eslint-plugin-react

Since the last version 7.18.2, eslinting cockpit gets tons of false positives like these:

/var/home/martin/upstream/cockpit/pkg/systemd/init.js
  1326:20  error  Expected indentation of 12 space characters but found 0  react/jsx-indent
  1327:23  error  Expected indentation of 12 space characters but found 0  react/jsx-indent
  1327:23  error  Expected indentation of 12 space characters but found 0  react/jsx-indent
  1328:21  error  Expected indentation of 12 space characters but found 0  react/jsx-indent
  1329:23  error  Expected indentation of 12 space characters but found 0  react/jsx-indent

on this code, which seems perfectly well indented:

    function create_timer_file() {
        var unit = "[Unit]\nDescription=";
        var service = "\n[Service]\nExecStart=";
        var timer = "\n[Timer]\n";
        var install = "[Install]\nWantedBy=timers.target\n";
        var service_file = unit + timer_unit.Description + service + timer_unit.Command + "\n";

The dozens of other errors are also wrong. Things were fine until 7.18.0, I haven't tested 7.18.1 yet.

bug

Most helpful comment

@toshi-toma : Many thanks for the super-fast fix!

All 6 comments

More direct reproducer:

curl -O https://raw.githubusercontent.com/cockpit-project/cockpit/master/pkg/systemd/init.js
node_modules/.bin/eslint ./init.js

works fine with 7.18.0, fails with 7.18.2.

This file isn't that special, it affects a lot of other files in our tree. This smells like a rather generic parsing regression.

cc @toshi-toma

It should definitely only be matching jsxtext/literals inside jsx.

What version of eslint are you using?

We currently use 6.8.0, matching package.json's "eslint": "^6.2.2".

That is the current version AFAICS.

I copied the complete package-lock.json here: https://piware.de/tmp/package-lock.json

@ljharb @martinpitt

I'm really sorry...
This bug is caused by my mistake.

Anyway, I created PR.(#2564 )
I'll under investigation for other cases.

@toshi-toma : Many thanks for the super-fast fix!

Was this page helpful?
0 / 5 - 0 ratings