[order] pathGroup doesn't appear to work
See original GitHub issueProblem
I am configuring pathGroups, but they do not appear to be working.
No matter the group I set for the pattern, it always requires that it appear at the top of the external imports.
I’ve manually verified that minimatch
is returning the correct output for some of the test paths that I’m working with.
tsconfig.json
"compilerOptions": {
...
"paths": {
"@/*": ["./*"]
}
}
.eslintrc.js
'import/order': [
'error',
{
groups: ['builtin', 'external', ['sibling', 'parent'], 'index', 'internal', 'object'],
pathGroups: [
{
pattern: '@/**',
group: 'internal',
},
],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
},
],
Expected
import { StatusCodes } from 'http-status-codes';
import { Route, useRouter } from 'next-router-provider';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import styled from 'styled-components';
import { useSession } from '@/client/providers/session';
import { pageRoutes } from '@/client/routes';
Actual
import { useSession } from '@/client/providers/session';
import { pageRoutes } from '@/client/routes';
import { StatusCodes } from 'http-status-codes';
import { Route, useRouter } from 'next-router-provider';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import styled from 'styled-components';
versions
eslint 7.22.0
eslint-plugin-import 2.22.1
typescript 4.2.3
minimatch outputs (both of which are correct)
> minimatch('@/client/types', '@/**')
true
> minimatch('@external-package/foo-package', '@/**')
false
Issue Analytics
- State:
- Created 3 years ago
- Reactions:8
- Comments:6 (1 by maintainers)
Top Results From Across the Web
[order] pathGroup doesn't appear to work #2008 - GitHub
I am configuring pathGroups, but they do not appear to be working. No matter the group I set for the pattern, it always...
Read more >Understanding My Bill | Pathgroup
A: PathGroup accepts check, money order and credit card payment (via mail or phone). Checks should be addressed to PathGroup and include your...
Read more >Understanding My Bill - PathGroup
A: PathGroup accepts check, money order and credit card payment (via mail or phone). Checks should be addressed to PathGroup and include your...
Read more >Pathgroup
PathGroup is privately held and physician centered, designed to work seamlessly with medical practices and provide direct consultation when needed.
Read more >Specimen Collection Manual - Pathgroup
Check specimen container for expiration date prior to use. Order from MML Histology Department at (415) 209-6076 one week in advance of intended...
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
@Jack-Barry I’ve been testing and it looks like the config can actually be a bit simpler. The external pathGroup isn’t necessary.
gets the job done.
You can also use an eslint setting in order to interpret specific path patterns as internal:
https://github.com/benmosher/eslint-plugin-import/blob/master/README.md#importinternal-regex