Reputation: 5283
I have a webpack configuration file, which is actually a factory function (react-universally
boilerplate).
I've added resolve
option and it looks like this:
resolve: {
// These extensions are tried when resolving a file.
extensions: config('bundleSrcTypes').map(ext => `.${ext}`),
// This is required for the modernizr-loader
// @see https://github.com/peerigon/modernizr-loader
alias: {
modernizr$: path.resolve(appRootDir.get(), './.modernizrrc'),
Config: path.resolve(appRootDir.get(), './config'),
},
},
With this config I'm able to access the reducers like import config from 'Config'
, but my linter is throwing me errors:
'Config' should be listed in the project's dependencies. Run 'npm i -S Config' to add it (import/no-extraneous-dependencies)
'Config' should be listed in the project's dependencies. Run 'npm i -S Config' to add it (import/no-extraneous-dependencies)
Missing file extension for "Config" (import/extensions)
How can I add aliases to my eslinter configuration? I've tried several packages listed in the top google results for this problem, but they do not work. Is it possible to add the aliases to the .eslintrc
manually?
Upvotes: 1
Views: 1625
Reputation: 5442
You can list your aliases through the import/core-modules
option under settings.
in your .eslintrc
"settings": {
"import/core-modules": [
"config-alias",
"another-alias"
]
}
Upvotes: 1
Reputation: 4775
Since the config import is a special exception, you can tell ESLint to ignore that line (for all rules or just a single rule)
https://eslint.org/docs/user-guide/configuring#disabling-rules-with-inline-comments
Upvotes: 0