|
1 | 1 | import vm from 'vm';
|
2 | 2 | import docsUrl from '../docsUrl';
|
3 | 3 |
|
4 |
| -function generateRegexForMagicComments(magicComments) { |
5 |
| - const preparedComments = magicComments.map(([comment, value]) => { |
6 |
| - return `(${comment}: ${value})`; |
7 |
| - }); |
8 |
| - |
9 |
| - return new RegExp(`^( (${preparedComments.join('|')}),?)+ $`); |
10 |
| -} |
11 |
| - |
12 | 4 | module.exports = {
|
13 | 5 | meta: {
|
14 | 6 | type: 'suggestion',
|
@@ -36,18 +28,9 @@ module.exports = {
|
36 | 28 | const config = context.options[0];
|
37 | 29 | const { importFunctions = [] } = config || {};
|
38 | 30 | const { webpackChunknameFormat = '([0-9a-zA-Z-_/.]|\\[(request|index)\\])+' } = config || {};
|
39 |
| - const webpackMagicComments = [ |
40 |
| - ['webpackChunkName', `["']${webpackChunknameFormat}["']`], |
41 |
| - ['webpackPrefetch', '(true|false|-?[0-9]+)'], |
42 |
| - ['webpackPreload', '(true|false|-?[0-9]+)'], |
43 |
| - ['webpackIgnore', '(true|false)'], |
44 |
| - ['webpackInclude', '\\/.*\\/'], |
45 |
| - ['webpackExclude', '\\/.*\\/'], |
46 |
| - ['webpackMode', `["'](lazy|lazy-once|eager|weak)["']`], |
47 |
| - ['webpackExports', `(['"]\\w+['"]|\\[(['"]\\w+['"], *)+(['"]\\w+['"]*)\\])`], |
48 |
| - ]; |
| 31 | + |
49 | 32 | const paddedCommentRegex = /^ (\S[\s\S]+\S) $/;
|
50 |
| - const commentStyleRegex = generateRegexForMagicComments(webpackMagicComments); |
| 33 | + const commentStyleRegex = /^( ((webpackChunkName: ["']([0-9a-zA-Z-_/.]|\[(request|index)\])+["'])|((webpackPrefetch|webpackPreload): (true|false|-?[0-9]+))|(webpackIgnore: (true|false))|((webpackInclude|webpackExclude): \/.*\/)|(webpackMode: ["'](lazy|lazy-once|eager|weak)["'])|(webpackExports: (['"]\w+['"]|\[(['"]\w+['"], *)+(['"]\w+['"]*)\]))),?)+ $/; |
51 | 34 | const chunkSubstrFormat = ` webpackChunkName: ["']${webpackChunknameFormat}["'],? `;
|
52 | 35 | const chunkSubstrRegex = new RegExp(chunkSubstrFormat);
|
53 | 36 |
|
|
0 commit comments