ArnaudBarre / eslint-plugin-react-refresh

Validate that your components can safely be updated with Fast Refresh
MIT License
206 stars 13 forks source link

Test files to ignore list #2

Closed alexandermukhin closed 1 year ago

alexandermukhin commented 1 year ago

Hello! Could you add test files (*.test.*, *.spec.*) to ignore list?

ArnaudBarre commented 1 year ago

Yes that would be possible but I'm curious about what pattern is reported by the rule in your test files? Maybe this could be an issue with the rule

alexandermukhin commented 1 year ago

Something like this

import { render } from '@testing-library/react';
import MyComponent from './MyComponent';

// here I got an error
// ESLint: Fast refresh only works when a file has exports. Move your component(s) to a separate file.(react-refresh/only-export-components)
const TestChildComponent = ({ children }) => {
  return <div>{children}</div>;
};

describe('...', () => {
  it('...', async () => {
    const { getByText } = render(
      <MyComponent>
        <TestChildComponent>Demo component</TestChildComponent>
      </MyComponent>
    );

    expect(getByText('Demo component')).toBeInTheDocument();
  });
});
ArnaudBarre commented 1 year ago

Oh yeah I see. Yeah this warning makes sense for App entrypoints, but not for test entrypoints. I will skip the linter for those files