-
-
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: "type" group is not enough #2441
Comments
That's a combinatorial explosion of categories, unfortunately. I can see some kind of object form of each category that includes |
I came to mention a similar thing however I think customizing the type imports might be a bit too much. Type imports are really their own thing, while every other import group is based on the import source, the Type imports are all categorized based on the |
That's what it does currently, ftr. |
It sorts based on the order of the import groups? That's not what I'm seeing. These are my settings for the rule: "import/order": [
"warn",
{
"groups": [
"builtin",
"external",
"internal",
"parent",
"sibling",
"object",
"type"
],
"newlines-between": "never",
"alphabetize": {
"order": "asc",
"caseInsensitive": false
}
}
], And this is how its sorting my types on a run of import { Box } from "@chakra-ui/layout";
import React from "react";
import type { Size, SizeProps } from "../types";
import type { SystemStyleObject } from "@chakra-ui/system";
import type { ReactElement } from "react";
import type {
ContainerProps,
GroupBase,
IndicatorsContainerProps,
ValueContainerProps,
} from "react-select"; I would expect the type import from import { Box } from "@chakra-ui/layout";
import React from "react";
import type { SystemStyleObject } from "@chakra-ui/system";
import type { ReactElement } from "react";
import type {
ContainerProps,
GroupBase,
IndicatorsContainerProps,
ValueContainerProps,
} from "react-select";
import type { Size, SizeProps } from "../types"; |
That's what it should do, then :-) a PR with failing test cases is appreciated. |
It looks like type imports get sorted in reverse order of groups. import type { Paginator } from "../../utils/NMApi";
import type NM from "../../utils/NMTypes";
import type { Actors } from "../TradeWindow.svelte";
import type { Writable } from "svelte/store";
import { onDestroy, createEventDispatcher, getContext } from "svelte";
import { writable } from "svelte/store";
import NMApi from "../../utils/NMApi";
import tip from "../actions/tip";
import Avatar from "../elements/Avatar.svelte";
import Button from "../elements/Button.svelte";
import Icon from "../elements/Icon.svelte";
import FiltersMenu from "./FiltersMenu.svelte";
import PrintDetails from "./PrintDetails.svelte"; with the following rule options "import/order": [
"error",
{
groups: [
"type",
"builtin",
"external",
"internal",
"parent",
"sibling",
"index",
"object",
],
alphabetize: {
order: "asc",
caseInsensitive: true,
},
warnOnUnassignedImports: false,
},
], |
@7nik would you be able to make a PR with a failing test case? |
add test cases to https://github.com/import-js/eslint-plugin-import/blob/main/tests/src/rules/order.js ? |
Yep, thanks! Much obliged; I can much more easily add a fix onto a failing PR :-) |
…a `sortTypesAmongThemselves` Closes import-js#2912 import-js#2347 import-js#2441 Subsumes import-js#2615
…a `sortTypesAmongThemselves` Closes import-js#2912 import-js#2347 import-js#2441 Subsumes import-js#2615
Currently, the rule offers the following groups:
"builtin", "external", "internal", "unknown", "parent", "sibling", "index", "object", "type"
To me, having single "type" group for all type imports is not enough.
I can import types from "builtin" modules, from "external" module and so on.
So, it would be logical to have type counterpart for each group, i.e.:
"build" -> "built-type"
"external" -> "external-type"
and so on
The text was updated successfully, but these errors were encountered: