Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dynamic-import-chunkname does not handle webpackInclude/webpackExclude comments correctly #1407

Closed
vkrol opened this issue Jul 8, 2019 · 4 comments

Comments

@vkrol
Copy link

vkrol commented Jul 8, 2019

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

@ljharb
Copy link
Member

ljharb commented Jul 8, 2019

I suspect we didn’t know that commenting format existed when the rule was written :-)

cc @byteme980 @lencioni

@lencioni
Copy link
Contributor

lencioni commented Jul 8, 2019

This rule was originally written when the only magic comment was webpackChunkName. Sounds like it needs to be updated to include newer webpack features.

@heinzdmx
Copy link

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.

@vkrol
Copy link
Author

vkrol commented Nov 11, 2022

This was fixed in #2330.

@vkrol vkrol closed this as completed Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

4 participants