Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import/order complains about inline requires #1936

Closed
mAAdhaTTah opened this issue Nov 4, 2020 · 3 comments · Fixed by #1940
Closed

import/order complains about inline requires #1936

mAAdhaTTah opened this issue Nov 4, 2020 · 3 comments · Fixed by #1940

Comments

@mAAdhaTTah
Copy link

Rule config:

    'import/order': [
      'error',
      {
        groups: ['builtin', 'external', 'parent', 'sibling', 'index'],
        'newlines-between': 'never',
      },
    ],

Code:

import React from 'react';
import PropTypes from 'prop-types';
import { createGlobalStyle, ThemeProvider } from 'styled-components';

export const GlobalStyle = createGlobalStyle`
  @font-face {
    font-display: swap;
    font-family: 'font-name';
    src: url(${require('../fonts/font-name.eot')});
    src: url(${require('../fonts/font-name.woff2')}) format('woff2'),
      url(${require('../fonts/font-name.woff')}) format('woff'),
      url(${require('../fonts/font-name.ttf')}) format('truetype');
  }
`

It complains about the newline after the styled-components import as well as a newline after the last inline require. Not 100% sure this is a bug, admittedly, but I thought it would excuse inline requires that aren't assigned based on this. Happy to just disable this rule on this file if needed.

@ljharb
Copy link
Member

ljharb commented Nov 4, 2020

Although all of those requires should be non-inline, i agree it's a bug that the rule considers them.

@golopot
Copy link
Contributor

golopot commented Nov 10, 2020

I noticed another false positive:

const foo = [
  require('fs'),
  require('./a'),
]

In this case elements order is likely intentional. The rule should not complain about it.

@ljharb
Copy link
Member

ljharb commented Nov 10, 2020

given that it’s inline, i think that alone means the rule shouldn’t complain.

@ljharb ljharb closed this as completed in 957092a Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants