|
| 1 | +module.exports = { |
| 2 | + extends: "dependency-cruiser/configs/recommended-strict", |
| 3 | + /* |
| 4 | + the 'dependency-cruiser/configs/recommended-strict' preset |
| 5 | + contains these rules: |
| 6 | + no-circular - flags all circular dependencies |
| 7 | + no-orphans - flags orphan modules (except typescript .d.ts files) |
| 8 | + no-deprecated-core - flags dependencies on deprecated node 'core' modules |
| 9 | + no-deprecated-npm - flags dependencies on deprecated npm modules |
| 10 | + no-non-package-json - flags (npm) dependencies that don't occur in package.json |
| 11 | + not-to-unresolvable - flags dependencies that can't be resolved |
| 12 | + no-duplicate-dep-types - flags dependencies that occur more than once in package.json |
| 13 | +
|
| 14 | + If you need to, you can override these rules. E.g. to ignore the |
| 15 | + no-duplicate-dep-types rule, you can set its severity to "ignore" by |
| 16 | + adding this to the 'forbidden' section: |
| 17 | + { |
| 18 | + name: 'no-duplicate-dep-types', |
| 19 | + severity: 'ignore' |
| 20 | + } |
| 21 | +
|
| 22 | + Also, by default, the preset does not follow any external modules (things in |
| 23 | + node_modules or in yarn's plug'n'play magic). If you want to have that |
| 24 | + differently, just override it the options.doNotFollow key. |
| 25 | + */ |
| 26 | + forbidden: [ |
| 27 | + { |
| 28 | + name: "not-to-test", |
| 29 | + comment: |
| 30 | + "This module depends on code within a folder that should only contain tests. As tests don't " + |
| 31 | + "implement functionality this is odd. Either you're writing a test outside the test folder " + |
| 32 | + "or there's something in the test folder that isn't a test.", |
| 33 | + severity: "error", |
| 34 | + from: { |
| 35 | + pathNot: "^(test|spec)", |
| 36 | + }, |
| 37 | + to: { |
| 38 | + path: "^(test|spec)", |
| 39 | + }, |
| 40 | + }, |
| 41 | + { |
| 42 | + name: "not-to-spec", |
| 43 | + comment: |
| 44 | + "This module depends on a spec (test) file. The sole responsibility of a spec file is to test code. " + |
| 45 | + "If there's something in a spec that's of use to other modules, it doesn't have that single " + |
| 46 | + "responsibility anymore. Factor it out into (e.g.) a separate utility/ helper or a mock.", |
| 47 | + severity: "error", |
| 48 | + from: {}, |
| 49 | + to: { |
| 50 | + path: "\\.spec\\.(js|ts|ls|coffee|litcoffee|coffee\\.md)$", |
| 51 | + }, |
| 52 | + }, |
| 53 | + { |
| 54 | + name: "not-to-dev-dep", |
| 55 | + severity: "error", |
| 56 | + comment: |
| 57 | + "This module depends on an npm package from the 'devDependencies' section of your " + |
| 58 | + "package.json. It looks like something that ships to production, though. To prevent problems " + |
| 59 | + "with npm packages that aren't there on production declare it (only!) in the 'dependencies'" + |
| 60 | + "section of your package.json. If this module is development only - add it to the " + |
| 61 | + "from.pathNot re of the not-to-dev-dep rule in the dependency-cruiser configuration", |
| 62 | + from: { |
| 63 | + path: "^(src|app|lib)", |
| 64 | + pathNot: "\\.spec\\.(js|ts|ls|coffee|litcoffee|coffee\\.md)$", |
| 65 | + }, |
| 66 | + to: { |
| 67 | + dependencyTypes: ["npm-dev"], |
| 68 | + }, |
| 69 | + }, |
| 70 | + { |
| 71 | + name: "optional-deps-used", |
| 72 | + severity: "info", |
| 73 | + comment: |
| 74 | + "This module depends on an npm package that is declared as an optional dependency " + |
| 75 | + "in your package.json. As this makes sense in limited situations only, it's flagged here. " + |
| 76 | + "If you're using an optional dependency here by design - add an exception to your" + |
| 77 | + "depdency-cruiser configuration.", |
| 78 | + from: {}, |
| 79 | + to: { |
| 80 | + dependencyTypes: ["npm-optional"], |
| 81 | + }, |
| 82 | + }, |
| 83 | + { |
| 84 | + name: "peer-deps-used", |
| 85 | + comment: |
| 86 | + "This module depends on an npm package that is declared as a peer dependency " + |
| 87 | + "in your package.json. This makes sense if your package is e.g. a plugin, but in " + |
| 88 | + "other cases - maybe not so much. If the use of a peer dependency is intentional " + |
| 89 | + "add an exception to your dependency-cruiser configuration.", |
| 90 | + severity: "warn", |
| 91 | + from: {}, |
| 92 | + to: { |
| 93 | + dependencyTypes: ["npm-peer"], |
| 94 | + }, |
| 95 | + }, |
| 96 | + ], |
| 97 | + options: { |
| 98 | + /* conditions specifying which files not to follow further when encountered: |
| 99 | + - path: a regular expression to match |
| 100 | + - dependencyTypes: see https://github.com/sverweij/dependency-cruiser/blob/develop/doc/rules-reference.md#dependencytypes |
| 101 | + for a complete list |
| 102 | + */ |
| 103 | + doNotFollow: { |
| 104 | + // path: 'node_modules', |
| 105 | + dependencyTypes: ["npm", "npm-dev", "npm-optional", "npm-peer", "npm-bundled", "npm-no-pkg"], |
| 106 | + }, |
| 107 | + |
| 108 | + /* conditions specifying which dependencies to exclude |
| 109 | + - path: a regular expression to match |
| 110 | + - dynamic: a boolean indicating whether to ignore dynamic (true) or static (false) dependencies. |
| 111 | + leave out if you want to exclude neither (recommended!) |
| 112 | + */ |
| 113 | + // , exclude : { |
| 114 | + // path: '' |
| 115 | + // , dynamic: true |
| 116 | + // } |
| 117 | + |
| 118 | + /* pattern specifying which files to include (regular expression) |
| 119 | + dependency-cruiser will skip everything not matching this pattern |
| 120 | + */ |
| 121 | + // , includeOnly : '' |
| 122 | + |
| 123 | + /* list of module systems to cruise */ |
| 124 | + // , moduleSystems: ['amd', 'cjs', 'es6', 'tsd'] |
| 125 | + |
| 126 | + /* prefix for links in html and svg output (e.g. https://github.com/you/yourrepo/blob/develop/) */ |
| 127 | + // , prefix: '' |
| 128 | + |
| 129 | + /* if true detect dependencies that only exist before typescript-to-javascript compilation */ |
| 130 | + tsPreCompilationDeps: true, |
| 131 | + |
| 132 | + /* if true combines the package.jsons found from the module up to the base |
| 133 | + folder the cruise is initiated from. Useful for how (some) mono-repos |
| 134 | + manage dependencies & dependency definitions. |
| 135 | + */ |
| 136 | + // , combinedDependencies: false |
| 137 | + |
| 138 | + /* if true leave symlinks untouched, otherwise use the realpath */ |
| 139 | + // , preserveSymlinks: false |
| 140 | + |
| 141 | + /* Typescript project file ('tsconfig.json') to use for |
| 142 | + (1) compilation and |
| 143 | + (2) resolution (e.g. with the paths property) |
| 144 | +
|
| 145 | + The (optional) fileName attribute specifies which file to take (relative to |
| 146 | + dependency-cruiser's current working directory). When not provided |
| 147 | + defaults to './tsconfig.json'. |
| 148 | + */ |
| 149 | + tsConfig: { |
| 150 | + fileName: "./tsconfig.json", |
| 151 | + }, |
| 152 | + |
| 153 | + /* Webpack configuration to use to get resolve options from. |
| 154 | +
|
| 155 | + The (optional) fileName attribute specifies which file to take (relative to dependency-cruiser's |
| 156 | + current working directory. When not provided defaults to './webpack.conf.js'. |
| 157 | +
|
| 158 | + The (optional) `env` and `args` attributes contain the parameters to be passed if |
| 159 | + your webpack config is a function and takes them (see webpack documentation |
| 160 | + for details) |
| 161 | + */ |
| 162 | + // , webpackConfig: { |
| 163 | + // fileName: './webpack.conf.js' |
| 164 | + // , env: {} |
| 165 | + // , args: {} |
| 166 | + // } |
| 167 | + |
| 168 | + /* How to resolve external modules - use "yarn-pnp" if you're using yarn's Plug'n'Play. |
| 169 | + otherwise leave it out (or set to the default, which is 'node_modules') |
| 170 | + */ |
| 171 | + // , externalModuleResolutionStrategy: 'node_modules' |
| 172 | + }, |
| 173 | +}; |
| 174 | +// generated: [email protected] on 2019-11-21T01:41:12.817Z |
0 commit comments