Skip to content

Commit

Permalink
Fix dynamic-import-chunkname validation regex
Browse files Browse the repository at this point in the history
  • Loading branch information
vkrol committed Sep 2, 2019
1 parent 7ffbf03 commit ab4057a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/rules/dynamic-import-chunkname.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = {
const { webpackChunknameFormat = '[0-9a-zA-Z-_/.]+' } = config || {}

const paddedCommentRegex = /^ (\S[\s\S]+\S) $/
const commentStyleRegex = /^( \w+: ("[^"]*"|\d+|false|true),?)+ $/
const commentStyleRegex = /^( \w+: ("[^"]*"|\/.*\/|\d+|false|true),?)+ $/
const chunkSubstrFormat = ` webpackChunkName: "${webpackChunknameFormat}",? `
const chunkSubstrRegex = new RegExp(chunkSubstrFormat)

Expand Down
24 changes: 24 additions & 0 deletions tests/src/rules/dynamic-import-chunkname.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,30 @@ ruleTester.run('dynamic-import-chunkname', rule, {
)`,
options,
},
{
code: `dynamicImport(
/* webpackInclude: /some-regex/ */
/* webpackChunkName: "someModule" */
'test'
)`,
options,
},
{
code: `dynamicImport(
/* webpackChunkName: "someModule" */
/* webpackInclude: /some-regex/ */
'test'
)`,
options,
},
{
code: `dynamicImport(
/* webpackExclude: /some-regex/ */
/* webpackChunkName: "someModule" */
'test'
)`,
options,
},
{
code: `dynamicImport(
/* webpackChunkName: "Some_Other_Module" */
Expand Down

0 comments on commit ab4057a

Please sign in to comment.