eslint-plugin-import doesn't work when load entire module
See original GitHub issueHello, while using this packahe found that it doesn’t work correctly when try to load entire module.
My configuration is
// .eslintrc
"extends": [
...
"plugin:import/typescript"
],
"rules": {
...
"import/order": [
"error",
{
"groups": ["builtin", "external", "internal", ["parent", "sibling", "index"]],
"pathGroupsExcludedImportTypes": ["builtin"],
"pathGroups": [
{
"pattern": "core-config/**",
"group": "internal",
"position": "before"
},
{
"pattern": "core/**",
"group": "internal",
"position": "before"
},
{
"pattern": "config/**",
"group": "internal",
"position": "before"
},
{
"pattern": "inject!*/**",
"group": "internal",
"position": "after"
},
{
"pattern": "core-test/**",
"group": "internal",
"position": "after"
},
{
"pattern": "test/**",
"group": "internal",
"position": "after"
}
],
"newlines-between": "always",
"alphabetize": {
"order": "asc",
"caseInsensitive": true
}
}
]
}
"settings": {
...
"import/resolver": {
"typescript": {
"project": [
"*/tsconfig.json"
]
}
}
},
// core/tsconfig.json, other tsconfigs are similar
{
"extends": "../tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"core-config/*": [
"../core/config/*"
],
"core/*": [
"../core/src/*"
]
}
},
"include": [
"../core/src/**/*",
"../core/config/**/*",
"../core/typings/**/*"
]
}
So my example is
import Popup from 'core/popups/Popup';
import Interceptor from 'core/routers/interceptors/Interceptor';
import Router from 'core/routers/Router';
import 'core/plan/SomeManager';
import 'core/steps/some-step/SomeStep';
import 'core/steps/another-step/AnotherStep';
import 'core/popups/Popup1';
import 'core/popups/Popup2';
import 'core/controllers/Controller1';
import 'core/controllers/popups/PopupController';
import 'core/service/SomeService';
So I wonder why eslint argues only about first 3 rows if anything wrong, other stuff just ignores. Interesting note, I tried to debug it a bit and all that modules are correctly detected as “internal” modules. It quite looks like this plugin doesn’t support such case
UPD. The example above is expected to be like below, but linter doesn’t argue it
import 'core/controllers/Controller1';
import 'core/controllers/popups/PopupController';
import 'core/plan/SomeManager';
import Popup from 'core/popups/Popup';
import 'core/popups/Popup1';
import 'core/popups/Popup2';
import Interceptor from 'core/routers/interceptors/Interceptor';
import Router from 'core/routers/Router';
import 'core/service/SomeService';
import 'core/steps/another-step/AnotherStep';
import 'core/steps/some-step/SomeStep';
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top Results From Across the Web
eslint-plugin-import doesn't work when load entire module
Hello, while using this packahe found that it doesn't work correctly when try to load entire module. My configuration is // .eslintrc ...
Read more >Failed to load plugin 'import' declared in '... » eslint-config ...
My issue turned out to be related to subdirectories. As soon as I made the project the only open project with an .eslintrc.js...
Read more >eslint-plugin-import - npm
This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, and prevent issues with misspelling of file paths and import ...
Read more >no-restricted-imports - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >eslint/eslint - Gitter
I'm trying to setup eslint-plugin-import but I can't make it work xD. I'm using parcel as a bundler, so I used eslint-import-resolver-parcel as...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
import 'x'
can have side effects, so the order can not be changed in many cases AFAIK.It’s fine to use the notation - but it’s impossible to know if changing the ordering of a side-effecting import with respect to other imports that may implicitly depend on it will break code or not.