Questions tagged [eslint-plugin-import]
16 questions
18
votes
2 answers
eslint import/order breaks down when using typescript aliases
I am using typescript path aliases in a large react project. So for example, in my tsconfig.json, I specify some path aliases:
{
"baseUrl": "./src",
"paths": {
"@common/*": ["common/*"],
"@settings/*": ["settings/*"],
//…

Seth Lutske
- 9,154
- 5
- 29
- 78
9
votes
2 answers
Cannot find module node:fs when using eslint-typescript-import + eslint-import-resolver-typescript + CRA
Problem
I tried to setup path alias in my TS project, but failed to get it run. I encountered two errors when npm start:
Module not found: Error: Can't resolve '~/App' in 'D:\work\workbench\templates\template-fe-pure\src' (even though VSC can still…

Sonny
- 166
- 1
- 4
- 12
8
votes
0 answers
Is there a way to prevent npm from creating symlinks of workspace packages inside node_modules?
We are working on a monorepo that uses npm workspaces. One of the directories in this project is special in the sense that we don't want to allow packages within this directory to create imports to each other. We are currently using eslint with…

Buzzy
- 2,905
- 3
- 22
- 31
6
votes
1 answer
Adding multiple paths to eslint-plugin-import pattern
I am looking to use eslint to force my imports to be in a standard order.
I have got this working, however it leads to a long eslint file as I have many different paths I have TypeScript aliases set up with that I want the eslint rules to exclude…

user3284707
- 3,033
- 3
- 35
- 69
4
votes
1 answer
ESLint plugin import not sorting properly
I am trying to sort my imports in my Angular application. I installed and configured eslint-plugin-import but it seems not working or I'm doing something incorrectly
I want to sort my imports like this:
All angular imports
All RxJS imports
All…

neme
- 121
- 1
- 8
3
votes
2 answers
Can I force anonymous default export?
If you have a file named same as default export, why do you need to name this export? I am not DRY there.
We have a rule to prevent the anonymous default export, but how can I do the opposite and force an error when somebody is not using an…

T_DaMER
- 31
- 5
2
votes
0 answers
structuring imports - eslint-plugin-import
this is more of a question as I have tried multiple ways to get the below structure working. Any tips?
.eslint.js
"import/order": [
"error",
{
"groups": ["builtin", "external", "internal", "sibling"],
…

boogiehsows
- 143
- 1
- 9
2
votes
0 answers
Glob minimatch pattern to get React and Meteor imports in a single group
I'm trying to setup eslint-plugin-import package to order my imports as I want to.
Here is an unordered example:
@chakra-ui/react
meteor/meteor
meteor/react-meteor-data
api/templates/collection
react
react-i18next
ui/state/useCsvMappingObject
The…

Nikolay Aleshkovskiy
- 717
- 2
- 7
- 20
2
votes
0 answers
Failed to load config "prettier" to extend from.(Previous reference of this question didn't help)
npx create-react-app react-dapp
npm install ethers hardhat @nomiclabs/hardhat-waffle ethereum-waffle chai @nomiclabs/hardhat-ethers
npx hardhat
After excuting the above command I faced the followings
Failed to load plugin 'prettier' declared in…

Blockchain Kid
- 315
- 2
- 9
1
vote
1 answer
ESLint not able to detect certain modules while using `webpack` as `import/resolver`
I'm using Webpack in my project as well as ESLint. I've installed eslint-plugin-import and eslint-import-resolver-webpack to help ESLint understand some resolve.aliases used in the project (As is alluded to [here][1]). I'm also using react-hook-form…

Kanishk Kaushik
- 21
- 4
1
vote
1 answer
Using eslint-plugin-import in a monorepo not reporting errors when it should?
If I have the following monorepo set up
packages/app1 has is-even in it's package.json
packages/app2 does not have is-even in its package.json
packages/app2 tries to use is-even
Then currently, I don't get any warning from something like…

Colin D
- 2,822
- 1
- 31
- 38
0
votes
0 answers
Why does eslint-import-resolver-typescript not work correctly in my turborepo setup
I am using a turborepo setup for my frontend nextJS applications and have this folder…

Philipp Schöler
- 3
- 1
- 3
0
votes
0 answers
eslint-plugin-import package is failing to recognise difference between external and internal directories
In my .eslintrc I have:
"import/order": [
"error",
{
"alphabetize": {
"caseInsensitive": true,
"order": "asc"
},
"groups": [
"builtin",
"external",
…

Red Baron
- 7,181
- 10
- 39
- 86
0
votes
1 answer
setting global vars in eslint-plugin-import
How can I in my .eslintrc.js file set what global variables are uesed, eslint-plugin-import is returning an error -> 3:30 error Unable to resolve path to module 'config' import/no-unresolved. Another way would be to ignore 'config' I guess?
Kind…
0
votes
0 answers
eslint import aliases not working eslint-plugin-import
my .eslintrc.json file located at ./
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings"
],
"overrides": [
…

Alex Mortez
- 156
- 1
- 8