v2.20.2 break ` no-extraneous-dependencies` with webpack alias
See original GitHub issueOS: Microsoft Windows [Version 10.0.18362.720]
Node: v10.14.2
ESLINT: v5.16.0
In my webpack config, I set a alias name for one of our scoped package for short
alias: {
'fish': '@sdp.nd/fish'
}
In eslint-plugin-import@2.20.1, it works well while I got no-extraneous-dependencies
in eslint-plugin-import@2.20.2.
import { Button } from 'fish'
After debug, I found these code make things different
// src/core/importType.js
// Line 31
// v2.20.2
// subPath = 'node_modules'
// path = 'C:\Users\yj\Desktop\test-collection\demo-base\node_modules\@sdp.nd\fish\es\index.js'
function isSubpath(subpath, path) {
const normPath = path.replace(/\\/g, '/')
const normSubpath = subpath.replace(/\\/g, '/').replace(/\/$/, '')
if (normSubpath.length === 0) {
return false
}
const left = normPath.indexOf(normSubpath)
const right = left + normSubpath.length
return left !== -1 &&
(left === 0 || normSubpath[0] !== '/' && normPath[left - 1] === '/') &&
(right >= normPath.length || normPath[right] === '/')
}
isSubpath
return true
in v2.20.2 while return false
in v2.20.1.
I found both v2.20.1 and v2.20.2 will report no-extraneous-dependencies
on ubuntu and I think v2.20.2 is right, it just fix path error in Window.
I found that
// lib\rules\no-extraneous-dependencies.js
// line 124
const resolved = resolve(name, context) // name == 'fish'
if (!resolved) { return } // resolve = 'C:\Users\yj\Desktop\base-demo-0317\node_modules\@sdp.nd\fish\es\index.js'
const splitName = name.split('/')
const packageName = splitName[0][0] === '@'
? splitName.slice(0, 2).join('/')
: splitName[0]
packageName should be @sdp.nd\fish
not fish
in this case.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:7 (2 by maintainers)
Top Results From Across the Web
v2.20.2 break ` no-extraneous-dependencies` with webpack ...
OS: Microsoft Windows [Version 10.0.18362.720] Node: v10.14.2 ESLINT: v5.16.0 In my webpack config, I set a alias name for one of our scoped ......
Read more >Resolve | webpack
Resolve. These options change how modules are resolved. Webpack provides reasonable defaults, but it is possible to change the resolving in detail.
Read more >eslint-plugin-import - Bountysource
20.2 break ` no-extraneous-dependencies` with webpack alias $ 0. Created 2 years ago in benmosher/eslint-plugin-import with 5 comments. OS: Microsoft Windows [ ...
Read more >eslint error showing with webpack alias - Stack Overflow
I have installed eslint-import-resolver-webpack plugin and put below code into .eslintrc.js or .eslintrc file :
Read more >Module aliasing in Webpack. Problem, Solution, Complications
This will break all the module references and you will be forced to change all ... Webpack allows you to create aliases to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve had this plugin pinned at v2.20.0 for a long time due to this bug, but tried upgrading to v2.23.2 and that appears to fix it. @githoniel could you confirm whether this bug is still reproducible with the latest version? Otherwise I think we can close this.
@IShotTheSheriff 2.20.0 will always skip
alias
detect in window and will report error on other platform. hope this will be fix soon~~~