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';
Which line is warned on?
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?
@ljharb
affected line

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
}
}
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.
@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();
@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?
@ljharb yeah, I am
Ok, I'll probably try
I'll close this for now, but am happy to reopen if the issue isn't solved on latest master.
@ljharb everything is fine now
Most helpful comment
@ljharb everything is fine now