dynamic-import-chunkname rule does not handle webpackInclude/webpackExclude comments correctly.
.eslintrc.js:
module.exports = {
parser: "babel-eslint",
parserOptions: {
ecmaVersion: 2018,
sourceType: "module",
},
plugins: ["import"],
rules: {
"import/dynamic-import-chunkname": "error",
},
};
index.js
import(
/* webpackChunkName: "foo" */
/* webpackInclude: /foo/ */
"./foo"
);
Output:
1:1 error dynamic imports require a leading comment in the form /* webpackChunkName: "[0-9a-zA-Z-_/.]+",? */ import/dynamic-import-chunkname
✖ 1 problem (1 error, 0 warnings)
Package name|Package version
-|-
eslint | 6.0.1
eslint-plugin-import | 2.18.0
Minimal reproducible example: https://github.com/vkrol/eslint-plugin-import-webpack-comment-with-regex-bug
I suspect we didn’t know that commenting format existed when the rule was written :-)
cc @byteme980 @lencioni
This rule was originally written when the only magic comment was webpackChunkName. Sounds like it needs to be updated to include newer webpack features.
I do not know if this is inside the scope of this issue, but it appears that this rules also does not allow [request] or [index] which is also supported in webpackChunkName
Currently have to disable the rule the places where my code base uses them.
Most helpful comment
I do not know if this is inside the scope of this issue, but it appears that this rules also does not allow
[request]or[index]which is also supported in webpackChunkNameCurrently have to disable the rule the places where my code base uses them.