Skip to content

Improve report location calculations #7

@gustavnikolaj

Description

@gustavnikolaj

Given this example:

import expect from '../../../../testUtils/unexpectedReact';
import React from 'react';
import FormattedSize from '../FormattedSize';

it('should render 123 bytes as 0.1KB', () => expect(
    <FormattedSize size={123} />,
    'to render as',
    <span>0.1 KB</span>
));

it('should render 1241240 bytes as 1.2MB', () => expect(
    <FormattedSize size={1241240} />,
    'to render as',
    <span>1.2 MB</span>
));

Prettier wants it formatted as:

import expect from '../../../../testUtils/unexpectedReact';
import React from 'react';
import FormattedSize from '../FormattedSize';

it('should render 123 bytes as 0.1KB', () =>
    expect(<FormattedSize size={123} />, 'to render as', <span>0.1 KB</span>));

it('should render 1241240 bytes as 1.2MB', () =>
    expect(
        <FormattedSize size={1241240} />,
        'to render as',
        <span>1.2 MB</span>
    ));

But running eslint gives me the following report:

$ ./node_modules/.bin/eslint src/common/components/FormattedSize/__tests__/FormattedSize-test.js 

./src/common/components/FormattedSize/__tests__/FormattedSize-test.js
  5:45  error  Follow `prettier` formatting (expected '\n' but found ' ')  prettier/prettier

I expected an error to be reported on both line 5 and 11, not just line 5. If I proceed to actually run prettier, both are fixed up as expected.

Other rules continue to work as expected, but this plugin and it's rule will only report the first problem.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions