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 2.20.1 #1652

Closed
tarsinzer opened this issue Feb 11, 2020 · 9 comments
Closed

import/order 2.20.1 #1652

tarsinzer opened this issue Feb 11, 2020 · 9 comments

Comments

@tarsinzer
Copy link

tarsinzer commented Feb 11, 2020

This package works incorrectly on v2.20.1 for import/order rule.
Previously I was working on v2.18.x and the rules worked as I expected in accordance with the documentation.
After package upgrade I got an error:
There should be no empty line within import group import/order

This error happens where it should not.
If it'd help, v2.20.0 works fine as expected and only the latest patch version produces this behavior.

.eslintrc.json

    "import/order": [
      2,
      {
        "newlines-between": "always",
        "groups": [
          ["builtin", "external"],
          ["parent", "internal", "sibling", "index", "unknown"]
        ]
      }
    ]

component.jsx

import React from 'react';
import ReactDOM from 'react-dom';

import { App } from './App/App';
import { unregister } from './serviceWorker';
import './index.css';
@ljharb
Copy link
Member

ljharb commented Feb 13, 2020

Which line is warned on?

@ljharb
Copy link
Member

ljharb commented Feb 13, 2020

I'm not sure what in v2.20.1 would have caused this; #5625 should only affect alphabetize (cc @wschurman), #1605 would only affect the external module folders setting.

What's your full eslint config?

@tarsinzer
Copy link
Author

@ljharb

affected line
image

config (I removed all rules except import/*)

{
  "parser": "@typescript-eslint/parser",
  "plugins": [
    "@typescript-eslint",
    "prettier",
    "react",
    "import",
    "react-hooks",
    "promise",
    "sonarjs"
  ],
  "extends": [
    "airbnb-typescript",
    "eslint:recommended",
    "react-app",
    "prettier",
    "prettier/react",
    "prettier/@typescript-eslint",
    "plugin:prettier/recommended",
    "plugin:react/recommended",
    "plugin:compat/recommended",
    "plugin:promise/recommended",
    "plugin:sonarjs/recommended",
    "plugin:import/errors",
    "plugin:import/warnings",
    "plugin:import/typescript",
    "plugin:@typescript-eslint/recommended"
  ],
  "settings": {
    "import/resolver": {
      "eslint-import-resolver-lerna": {
        "packages": "packages/"
      },
      "node": {
        "paths": [
          "src"
        ],
        "extensions": [
          ".js",
          ".jsx",
          ".ts",
          ".tsx"
        ]
      }
    },
    "import/parsers": {
      "@typescript-eslint/parser": [
        ".ts",
        ".tsx"
      ]
    },
    "react": {
      "version": "detect"
    }
  },
  "rules": {
    "import/no-unresolved": 2,
    "import/named": 2,
    "import/namespace": 2,
    "import/default": 2,
    "import/export": 2,
    "import/no-cycle": 2,
    "import/imports-first": [
      2,
      "absolute-first"
    ],
    "import/newline-after-import": 2,
    "import/prefer-default-export": 0,
    "import/no-useless-path-segments": 2,
    "import/no-default-export": 2,
    "import/no-mutable-exports": 2,
    "import/no-namespace": 2,
    "import/no-extraneous-dependencies": 0,
    "import/no-duplicates": 2,
    "import/order": [
      2,
      {
        "newlines-between": "always",
        "groups": [
          [
            "builtin",
            "external"
          ],
          [
            "parent",
            "internal",
            "sibling",
            "index",
            "unknown"
          ]
        ]
      }
    ]
  },
  "env": {
    "browser": true,
    "node": true,
    "jest": true
  }
}

@wschurman
Copy link
Contributor

What's the full code of component.jsx? Sometimes I get this warning when theres an errant import or require below in the body of the code.

@tarsinzer
Copy link
Author

@wschurman
I don't think if this is the same case;
be sure that the error is on the 2nd line

to make it clear I did several times the same thing:

  1. install 2.20.0
  2. run lint + check the component. Everything is fine.
  3. install 2.20.1
  4. run lint (caught errors) + check the component (eslint plugin displayed an error)

full code:

import React from 'react';
import ReactDOM from 'react-dom';

import { App } from './components/App';
import { unregister } from './serviceWorker';
import './index.css';

ReactDOM.render(<App />, document.getElementById('root'));

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
unregister();

@ljharb
Copy link
Member

ljharb commented Feb 17, 2020

@maktarsis are you on windows?

Either way, can you also try with the latest commit on master for this plugin, and see if your problem is fixed?

@tarsinzer
Copy link
Author

@ljharb yeah, I am

Ok, I'll probably try

@ljharb
Copy link
Member

ljharb commented Feb 18, 2020

I'll close this for now, but am happy to reopen if the issue isn't solved on latest master.

@ljharb ljharb closed this as completed Feb 18, 2020
@tarsinzer
Copy link
Author

@ljharb everything is fine now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants