1 | const { resolve } = require('path')
|
2 |
|
3 | const {
|
4 | isMonorepo,
|
5 | isPkgAvailable,
|
6 | monorepoPkgs,
|
7 | tryRequirePkg,
|
8 | } = require('@pkgr/utils')
|
9 |
|
10 | if (isMonorepo) {
|
11 | exports.allowModules = monorepoPkgs.reduce((acc, pkg) => {
|
12 | const pkgJson = tryRequirePkg(resolve(pkg, 'package.json'))
|
13 | if (!pkgJson) {
|
14 | return acc
|
15 | }
|
16 | const { name, peerDependencies = {}, dependencies = {} } = pkgJson
|
17 | return acc.concat(
|
18 | name,
|
19 | Object.keys(peerDependencies),
|
20 | Object.keys(dependencies),
|
21 | )
|
22 | }, [])
|
23 | }
|
24 |
|
25 | exports.isWebpackAvailable = isPkgAvailable('webpack')
|
26 |
|
27 |
|
28 | exports.webpackSpecVars = [
|
29 | '__resourceQuery',
|
30 | '__non_webpack_require__',
|
31 | '__webpack_chunk_load__',
|
32 | '__webpack_hash__',
|
33 | '__webpack_modules__',
|
34 | '__webpack_public_path__',
|
35 | '__webpack_require__',
|
36 | 'DEBUG',
|
37 | ]
|
38 |
|
39 | exports.camelCaseRule = [
|
40 | 2,
|
41 | {
|
42 | properties: 'never',
|
43 | ignoreDestructuring: true,
|
44 | allow: exports.isWebpackAvailable ? exports.webpackSpecVars : undefined,
|
45 | },
|
46 | ]
|
47 |
|
48 | exports.magicNumbers = [
|
49 | -1,
|
50 | 0,
|
51 | 1,
|
52 | 2,
|
53 | 5,
|
54 | 7,
|
55 | 10,
|
56 | 12,
|
57 | 15,
|
58 | 20,
|
59 | 24,
|
60 | 30,
|
61 | 50,
|
62 | 60,
|
63 | 100,
|
64 | 365,
|
65 | 500,
|
66 | 768,
|
67 | 1000,
|
68 | 1024,
|
69 | 3600,
|
70 | 8080,
|
71 | ]
|