amatiasq / vsc-sort-imports

Sort ES6 imports automatically.
ISC License
57 stars 24 forks source link

eslint configuration is not being picked up - case-insensitive rule in esLintConfig is being ignored (eslint version issue?) #71

Open codefactor opened 4 years ago

codefactor commented 4 years ago

All of my projects have the following settings for eslint:

    "sort-imports": [2, {"ignoreCase": true}],

Is there already a way to allow this?

For example:

import "A";
import "B";
import "a";
import "b";

Would need to be sorted like this:

import "A";
import "a";
import "B";
import "b";

Otherwise I can't use the auto-imports extension because it always breaks this lint rule.

codefactor commented 4 years ago

I think I found the reason why it is not doing the case-insensitive sorting - it looks like the code is configured to do so here: https://github.com/renke/import-sort/blob/master/packages/import-sort-style-eslint/src/index.ts#L28

But it's not effective because of the way my package.json is setup like this:

  "eslintConfig": {
    "extends": "@xweb/eslint-config"
  },

I think we might be relying on an eslint feature that was introduced in a newer version of eslint, I see that we are using version 6.8.0 and the @xweb/eslint-config/index.js uses a module.exports to expose the before mentioned rule in the description. But that is not being picked up by this import-sort-style-eslint because that code relies on eslint version 5.x -- at least this is my best guess at this point without knowing too much about this style of extending the eslintConfig from a different project.

amatiasq commented 4 years ago

Yes, the algorithm to sort is provided by the sort style. You probably want to create an issue on https://github.com/renke/import-sort then.