-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 with .svg file patterns #1858
Comments
The "object" group isn't included by default or in your config; you have to explicitly add it to |
Hi @laysent {
rules: {
"import/order": [
"warn",
{
groups: [
["builtin", "external"],
"internal",
["parent", "index", "sibling"],
],
pathGroups: [
{
pattern: "./assets/*.svg",
group: "sibling",
position: "after",
},
{
pattern: "../assets/*.svg",
group: "sibling",
position: "after",
},
],
pathGroupsExcludedImportTypes: ["builtin"],
"newlines-between": "always",
alphabetize: {
order: "asc",
},
},
]}
settings: {
// Refer @hadeshe packages as internal for import/order rule
"import/internal-regex": "^@hadeshe/",
},
} I also notice #1632 issue (using regex for pattern matching ) and it can help in my case. |
@nirtamir2 does this mean this issue is resolved, and #1632 handles any further issues? |
Not yet. |
I don't understand why |
I tried with this "import/order": [
"warn",
{
groups: [
["builtin", "external"],
"internal",
["parent", "index", "sibling"],
],
pathGroups: [
{
pattern: "*.svg",
group: "sibling",
position: "after",
},
],
pathGroupsExcludedImportTypes: ["builtin"],
"newlines-between": "always",
alphabetize: {
order: "asc",
},
},
],
},
settings: {
// Refer @hadeshe packages as internal for import/order rule
"import/internal-regex": "^@hadeshe/",
"import/extensions": [".js", ".jsx", ".ts", ".tsx", ".svg", ".json"],
}, And it is still not working. I get the same result as before. |
I think you'd also need a resolver that can understand The most help is a PR with a failing test case; otherwise, a repro repo is great. |
I created this repository to reproduce it. |
@nirtamir2 |
I added |
@nirtamir2 that fails because it tries to lint files in node_modules; but |
@nirtamir2 there's no webpack config in that repo. How are svg files importable at all? |
Sorry for the late response. pathGroups: [
{
pattern: "./assets/*.svg",
group: "sibling",
position: "after",
},
{
pattern: "../assets/*.svg",
group: "sibling",
position: "after",
},
], works for svg with the same pattern, but this pattern does not cover all |
The repro repo would probably have to include next.js then to be helpful :-/ I'm not sure how to proceed here. |
Hi @ljharb |
I managed to solve this by using
Note: I added Also, in theory |
@FlorianWendelborn Awsome! It works! Thank you so much! "import/order": [
"warn",
{
groups: [
["builtin", "external"],
"internal",
["parent", "index", "sibling"],
],
pathGroups: [
{
pattern: "@hadeshe/**",
group: "external",
position: "after",
},
{
pattern: "*.svg",
patternOptions: {
dot: true,
nocomment: true,
matchBase: true,
},
group: "sibling",
position: "after",
},
],
pathGroupsExcludedImportTypes: ["builtin"],
"newlines-between": "always",
alphabetize: {
order: "asc",
},
},
] |
Hi,
Thank you for creating this amazing ESLint plugin.
I've configured that any files matches
@hadeshe/**
will be after the external group, and it works well.I want to order my imports so that they will have a group of files matching
.svg
in the end.Here is my config:
Expected:
Actual:
How to order .svg imports to be the last group?
The text was updated successfully, but these errors were encountered: