Eslint-plugin-import: [import/order] Regression in 2.20.1

Created on 3 Feb 2020  路  15Comments  路  Source: benmosher/eslint-plugin-import

Installed 2.20.1, started getting ordering errors like the following;

image

Our rule for import/order is

'import/order': [
  'error',
  {
    groups: ['builtin', 'external', 'parent', 'sibling', 'index'],
    'newlines-between': 'never',
  },
],

Rolling back eslint-plugin-import to 2.20.0 resolves the issue.

bug help wanted imporexport ordering

Most helpful comment

Because maintainers are humans who aren鈥檛 being paid for their time, and can鈥檛 always drop everything to cut a release :-)

All 15 comments

Seems to be seen only on Windows. 馃

That makes testing for it difficult; appveyor tests are currently failing for unrelated reasons.

What I found by debugging:

  • The import type of an external module is not determined as such
  • The reason is that the path passed to isSubpath contains Windows separators (backslashes) and the function expects slashes.

https://github.com/benmosher/eslint-plugin-import/blob/45f08609e0dd79f2a061c3411a43169c20e80d3a/src/core/importType.js#L31-L41

path.normalize and path.sep might help us here?

This also seems to affect import/no-extraneous-dependencies: As the import type is reported as internal instead of external due to the path containing backslashes, the rule never reports any errors on Windows.

I tried to create a minimal reproduction for the import/order and import/no-extraneous-dependencies rules: https://github.com/kryops/eslint-plugin-import-issue1643

A PR with a failing test case would be most welcome; I can add a fix to that (altho a PR that has both is even better!)

I think the existing tests should already fail on Windows. I was unable to run the tests on that platform when I tried today, though.

I had to roll back to 2.19.1 for this issue to go away. 2.20.0 complained about the order of the following imports:

const nearley = require('nearley');
const grammar = require('./grammar');

@South-Paw can you check on latest master of this plugin and see if it's fixed?

I'll close this for now, but am happy to reopen if the issue isn't solved on latest master.

If this issue has been resolved in master, is there a reason that it has not yet been released?

Because maintainers are humans who aren鈥檛 being paid for their time, and can鈥檛 always drop everything to cut a release :-)

Hi collaborators, thanks for great plugin. I just want to say that it still happening on Windows.

@rmlevangelio thanks for the report - if you could file a new issue with more details that would be appreciated.

Was this page helpful?
0 / 5 - 0 ratings