question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

linting broken when adding resolve.alias to webpack

See original GitHub issue

I added resolve.alias:

// webpack.config.base.js
resolve: {
  extensions: ['.js', '.jsx', '.json'],
  modules: [
    path.join(__dirname, 'app'),
    'node_modules',
  ],
  alias: {
    '@fortawesome': path.join(__dirname, 'app', 'vendor', '@fortawesome'),
  },
},

The alias is working, and app is working fine, but the eslint is broken:

$ npm run lint

> @zen/zen-wallet@0.2.15 lint /Users/goldy/apps/zenwallet
> cross-env NODE_ENV=development eslint --cache --format=node_modules/eslint-formatter-pretty .

Cannot find module '/Users/goldy/apps/zenwallet/app/webpack.config.eslint.js'
Error: Cannot find module '/Users/goldy/apps/zenwallet/app/webpack.config.eslint.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
    at Function.Module._load (internal/modules/cjs/loader.js:475:25)
    at Module.require (internal/modules/cjs/loader.js:598:17)
    at require (internal/modules/cjs/helpers.js:11:18)
    at Object.exports.resolve (/Users/goldy/apps/zenwallet/node_modules/eslint-import-resolver-webpack/index.js:68:25)
    at v2 (/Users/goldy/apps/zenwallet/node_modules/eslint-module-utils/resolve.js:94:23)
    at withResolver (/Users/goldy/apps/zenwallet/node_modules/eslint-module-utils/resolve.js:99:16)
    at fullResolve (/Users/goldy/apps/zenwallet/node_modules/eslint-module-utils/resolve.js:116:22)
    at Function.relative (/Users/goldy/apps/zenwallet/node_modules/eslint-module-utils/resolve.js:61:10)
    at remotePath (/Users/goldy/apps/zenwallet/node_modules/eslint-plugin-import/lib/ExportMap.js:379:30)

on Atom, linting on files that import ‘@fortawesome’ are broken as well.

Any ideas why is that happening, and how can I fix that? Do you have an example of a project that uses this boilerplate and has resolve.alias in webpack.config.base.js?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
Mati365commented, Apr 19, 2018

If you use .eslintrc or .eslintrc.yml please rename it to .eslintrc.js and change webpack resolve function to something like it: webpack: { config: resolve('./webpack.config.eslint.js'), }, In my case it fixed the problem

5reactions
goldyluckscommented, Apr 16, 2018

@Slapbox really appreciate your time on this!

I prefer to explicitly import it wherever I’m using it, and not have <FontAwesomeIcon /> out of nowhere in my app.

Thank you for the attempt, I suspected it might be a weback or eslint thing, and not related to this boilerplate.

So if this is the case, do we have a use in .eslintrc for settings.import/resolver.webpack.config.webpack.config.eslint.js ?

this is the sole reason of it being there right?

I had to comment it out, and add the following as well:

    "import/no-unresolved": [ "error", { "ignore": [ '@fortawesome/' ] } ], # hack until resolving import properly
    "import/extensions": [ "error", { "ignore": [ '@fortawesome/' ] } ], # hack until resolving import properly
Read more comments on GitHub >

github_iconTop Results From Across the Web

eslint error showing with webpack alias - Stack Overflow
In the Webpack config (in my case, it was Vue config, which is merged with Webpack config by Vue-cli), I added a few...
Read more >
webpack module resolution broken after updated to 2022.1
Probably a bug in supporting .eslintrc aliases in 2022 version - dont you think?
Read more >
Creating a React App from scratch - Webpack5, TypeScript4+ ...
You can't use import aliases for paths, like import { ITruck, ICar, IVehicle } from '@models' easily. It's possible to use a tsconfig's...
Read more >
How to set up import aliases for Gatsby.js - Mrozilla
A step-by-step guide to use import aliases with Webpack, ESlint, ... setup—ESlint's import linting and VS Code's import autocomplete.
Read more >
Module Resolution or Import Alias: The Final Guide - Raul Melo
How can I add aliases to my imports? ... add Storybook, you'll need to add an alias in both `webpack.config.js` and also customize...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found