import-js / import-js/eslint-plugin-import
Problems with import/ignore + import/imports-first
- Dominant language
- JavaScript
- Stars
- 5.9k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
Hi there! I’m using eslint-plugin-import 2.0.1 on eslint 3.9.0 with this `.eslintrc.js`:
```js
module.exports = {
env: { es6: true },
parserOptions: { ecmaVersion: 6, sourceType: 'module' },
plugins: [ 'import' ],
settings: {
'import/ignore': [
// None of these have any effect
'\\.sass$',
'^!!',
'sass-variables'
]
},
rules: {
'import/no-unresolved': [ 'error', { ignore: [ '^!!' ] } ], // this works fine
'import/imports-first': ['error', 'absolute-first'],
}
};
```
Due to my webpack setup I have funky imports like this (test.js):
```js
import f from './test2';
import sassVariables from '!!sass-variables!../stylesheets/variables.sass';
f(sassVariables);
```
test2.js: `export default () => {}`
The `!!…` import should be ignored completely. The ignore setting for `import/no-unresolved` seems to work fine. I want to disable `import/imports-first` for these imports as well. So I tried to use the general `import/ignore` setting, but that did not work. I still get an error from `imports-first`:
```
2:27 error Absolute imports should come before relative imports import/imports-first
```
How can I configure eslint-plugin-import to ignore these types of imports? Am I using the right `settings` syntax? Are there any alternative solutions?
Thank you very much. :)
Contributor guide
Research direction
Start with the import/imports-first rule and the settings configuration shown in .eslintrc.js, using test.js and test2.js as the reproduction. Check how the rule handles webpack-style `!!` imports and whether it consults `import/ignore`. Done means those imports no longer trigger imports-first while the existing no-unresolved ignore behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100