-
-
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] Aliases that start with @ get incorrectly grouped #1293
Comments
It seems like a typescript resolver (to provide to this linting plugin) would address this, by being able to read the paths. |
@ljharb i am using the typescript resolver. The paths getting sent to this plugin are correct (did a bunch of logging because i thought i did something wrong). |
for instance, if i have an alias called |
this seems like a bug since the documentation states that only folders included in the |
I am not sure if this is the right way to go about this, but changing the following things in importType.js "fixes" this issue: // isScoped now gets settings and path and also checks whether the path is external
isScoped (name, settings, path) {
return scopedRegExp.test(name) && isExternalPath(path, name, settings)
}
// isInternalModule checks to see if the (scoped OR external regexes pass) AND
// it is not an external path
function isInternalModule (name, settings, path) {
return (
(scopedRegExp.test(name) || externalModuleRegExp.test(name)) &&
!isExternalPath(path, name, settings)
)
} |
and specifically, I know that this is |
A PR with that change, and test cases would be appreciated :-) I think it'd help make clear what's needed. |
Could anyone tell me why this fix is not working for me? When importing my modules like example below. I still get the error: 'There should be at least one empty line between import groups eslint(import/order)' Could anyone tell me what i'm doing wrong here?
Using: "name": "eslint", import rule:
.eslintrc.js
|
Are you sure that’s the final rule config, and that none of the things you extend is setting it? |
I'm using the CRA. But I'm also extending my CRA with react-app-rewired. Currently I'm overwriting some CRA config by using the customize-cra. Is this what you mean by final rule config? My config-overrides file looks like this:
|
@michielmetcake excuse me, Had you solved the problem? |
Given that Typescript is going to switch over to ESLint as its main linting tool, I wanted to try to get my project at work switched over. In Typescript, you can define paths. Paths allow you to define import paths, i.e.
@my-alias/fn
could actually point tosrc/my-folder/fn.ts
.In my project, currently using TSLint, we have external, aliases, parent, sibling as our import sort order. After trying to get a test case working with ESLint, it seems like this plugin incorrectly associates aliases that start with
@
to external modules, since it thinks they are "scoped".I don't know the solution to this, however, I would be open to putting in a PR if someone can provide some insight into solving this?
I have tried to create a minimal repro, but it seems like code-sandbox won't give access to the terminal... But this example does fail, saying that you can't have newlines between groups on the lodash import. https://codesandbox.io/s/7m5zpmxo90
The text was updated successfully, but these errors were encountered: