import-js / eslint-plugin-import

ESLint plugin with rules that help validate proper imports.
MIT License
5.57k stars 1.57k forks source link

[import/extensions] Test code: checkTypeImports must not be part of the pattern definition #3108

Closed tobbexiv closed 3 days ago

tobbexiv commented 4 days ago

Thanks for the great project.

I had the following line in my project config:

'import/extensions': [`error`, { ts: `never`, js: `never`, json: `always`, checkTypeImports: true }]

I was wondering why I still got errors for json file imports.

When digging deeper, I found that the pattern definitions on the main object are ignored in case certain other properties like checkTypeImports are set: https://github.com/import-js/eslint-plugin-import/blob/a20d84398a7946f53f2f20a83d6ff028bebbce62/src/rules/extensions.js#L39-L42

That's totally valid handling but not covered by any test case. Moreover, there are two test cases which have the incorrect logic and still succeed: https://github.com/import-js/eslint-plugin-import/blob/a20d84398a7946f53f2f20a83d6ff028bebbce62/tests/src/rules/extensions.js#L701-L718

I would suggest to adjust these test cases to the correct configuration.

ljharb commented 4 days ago

I'm a bit confused; what's incorrect in the logic for those two test cases?

tobbexiv commented 3 days ago

I missed that the tests are part of the invalid section. So, you can discard this as mistake on my end.