Skip to content

Commit

Permalink
feature(*): reporter level filtering (sverweij#302)
Browse files Browse the repository at this point in the history
  • Loading branch information
sverweij authored May 19, 2020
1 parent 4e78a19 commit 682b195
Show file tree
Hide file tree
Showing 38 changed files with 8,155 additions and 404 deletions.
3 changes: 3 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
version: "2"
checks:
method-complexity:
config:
threshold: 7
method-lines:
config:
threshold: 32
Expand Down
20 changes: 3 additions & 17 deletions .dependency-cruiser.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@
"collapsePattern": "^(node_modules|src|test)/[^/]+|^bin/"
},
"dot": {
"filters": {
"includeOnly": { "path": "^(src|bin)" }
},
"theme": {
"replace": false,
"graph": {
Expand Down Expand Up @@ -242,30 +245,13 @@
"criteria": { "source": "^src/utl" },
"attributes": { "fillcolor": "#cccccc" }
},
{
"criteria": { "source": "\\.schema\\.mjs$" },
"attributes": {
"color": "darkgreen",
"fillcolor": "darkgreen",
"fontcolor": "#ffffcc"
}
},
{
"criteria": { "source": "\\.template\\.js$" },
"attributes": { "style": "filled" }
},
{
"criteria": { "source": "\\.json$" },
"attributes": { "shape": "cylinder" }
},
{
"criteria": { "source": "\\-type\\.mjs$" },
"attributes": {
"fillcolor": "white",
"fontcolor": "darkgrey",
"color": "darkgrey",
"shape": "underline"
}
}
],
"dependencies": [
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*.swo
*.swp
**tmp**
*.bak

# ide garbage
.project
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Dependency cruiser ![Dependency cruiser](https://raw.githubusercontent.com/sverweij/dependency-cruiser/master/doc/assets/ZKH-Dependency-recolored-160.png)

_Validate and visualize dependencies. With your rules._ JavaScript. TypeScript. CoffeeScript. ES6, CommonJS, AMD.
_Validate and visualise dependencies. With your rules._ JavaScript. TypeScript. CoffeeScript. ES6, CommonJS, AMD.

## What's this do?

Expand Down
6 changes: 3 additions & 3 deletions doc/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### Dependency graph

Below is a detailed dependency graph of dependency-cruiser, without external
dependencies. Click on it to go to a slightly more interactive version that
allows you to navigate the source by clicking the nodes.
The picture below is adetailed dependency graph of dependency-cruiser, without
external dependencies. Click on it to go to a slightly more interactive version
that allows you to navigate the source by clicking the nodes.

[!["dependency cruiser's dependency graph"](real-world-samples/dependency-cruiser-without-node_modules.svg)](https://sverweij.github.io/dependency-cruiser/dependency-cruiser-dependency-graph.html)
24 changes: 12 additions & 12 deletions doc/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,24 +122,24 @@ with _GraphViz dot_ (`-T` is the short form of `--output-type`:)
dependency-cruise -x "^node_modules" -T dot src | dot -T svg > dependencygraph.svg
```

You can customize the look of these graphs. See the
You can customise the look of these graphs. See the
[dot section in the rules reference](./rules-reference.md#dot) for details.

#### ddot - summarize on folder level
#### ddot - summarise on folder level

> This reporter is _experimental_. It's likely to stay, but the way you configure
> it or how its output looks might change without major version bumping.
The `ddot` reporter is a variant on the `dot` output. It summarizes modules on
folder level. You can customize it just as you can the dot reporter output.
The `ddot` reporter is a variant on the `dot` output. It summarises modules on
folder level. You can customise it just as you can the dot reporter output.

#### archi/ cdot

> This reporter is _experimental_. It's likely to stay, but the way you configure
> it or how its output looks might change without major version bumping.
The archi is a variant on the `dot` output. The archi reporter
can summarize (or 'collapse') dependencies to folders of your own choosing.
can summarise (or 'collapse') dependencies to folders of your own choosing.
Great if you want to have a high level overview of your app's dependencies.

By default it collapses to one folder below folders named _node_modules_, _packages_,
Expand Down Expand Up @@ -182,7 +182,7 @@ dependency-cruise -T html -f dependencies.html src

If you supply `csv` it will write the dependency matrix to a comma
separated file - so you can import it into a spreadsheet program
and analyze from there.
and analyse from there.

#### teamcity

Expand Down Expand Up @@ -210,7 +210,7 @@ dependency-cruise -v -T teamcity -- src

</details>

Just like the `err` reporter the teamcity reporter has an empty output when there's
Just like the `err` reporter the TeamCity reporter has an empty output when there's
no violations - and a non-zero exit code when there's errors.

#### text
Expand Down Expand Up @@ -341,7 +341,7 @@ so it's easier to compare than the two json's):
`src/search/dragonfly-algorithm.spec.js` -> `src/animal/announce.spec.js`).
- (You can use any array of strings here - a good one is Sindre Sorhus'
[mnemonic-words](https://www.npmjs.com/package/mnemonic-words), which
you can simply require into the option if you're using javascript as
you can simply require into the option if you're using JavaScript as
the config file format):
```javascript
...
Expand Down Expand Up @@ -450,7 +450,7 @@ preset):</summary>
| `not-to-unresolvable` | flags dependencies that can't be resolved |
| `no-duplicate-dep-types` | flags dependencies that occur more than once in package.json |
| `not-to-test` | Don't allow dependencies from outside test folders to test folders |
| `not-to-spec` | Don't allow dependencies to (typescript/ javascript/ coffeescript) spec files |
| `not-to-spec` | Don't allow dependencies to (typescript/ JavaScript/ CoffeeScript) spec files |
| `not-to-dev-dep` | Don't allow dependencies from src/app/lib to a development only package |
| `optional-deps-used` | Inform about the use of 'optional' dependencies (so you can ensure their imports a are sufficiently managed) |
| `peer-deps-used` | Warn about the use of a peer dependency (they might be OK for you, but it's not typical you have them). |
Expand Down Expand Up @@ -613,7 +613,7 @@ See [moduleSystems](./rules-reference.md#modulesystems) in the rules reference
### `--ts-pre-compilation-deps` (typescript only)

By default dependency-cruiser does not take dependencies between typescript
modules that don't exist after compilation to javascript. Pass this command
modules that don't exist after compilation to JavaScript. Pass this command
line switch to do take them into account.

For details see [tsPreCompilationDeps](./rules-reference.md#tsprecompilationdeps) in the
Expand Down Expand Up @@ -682,7 +682,7 @@ depcruise-fmt -T dot cruise_result.json | dot -T svg > dependency-graph.svg
If you want to see non-zero exit codes when there's error level dependency
violations, you can use the `--exit-code` (short: `-e`). This only works for
the output types that support non-zero exit codes (_err_, _err-long_ and
_teamcity_). Example for the default output type (_err_):
_TeamCity_). Example for the default output type (_err_):

```sh
depcruise-fmt -e cruise_result.json
Expand All @@ -709,7 +709,7 @@ Options:
## depcruise-wrap-stream-in-html

With `depcruise-wrap-stream-in-html` you can wrap the graphical output of
graphviz dot into html that is geared to make the graph easier to use. It a.o.
GraphViz dot into html that is geared to make the graph easier to use. It a.o.
adds highlight-on-hover.

Typical use:
Expand Down
16 changes: 8 additions & 8 deletions doc/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- [Troubleshooting](#troubleshooting)
- [Features](#features)
- [Expanding dependency-cruiser](#expanding-dependency-cruiser)
- [Roadmap](#roadmap)
- [Road map](#roadmap)
- [Contact](#contact)

## Troubleshooting
Expand Down Expand Up @@ -103,7 +103,7 @@ with ~100 modules to appreciate the difference)

#### Folder level dependency graph ('ddot' reporter)

For a birds-eye view, you can use the `ddot` reporter that summarizes dependencies
For a birds-eye view, you can use the `ddot` reporter that summarises dependencies
on a folder level:

```sh
Expand Down Expand Up @@ -261,7 +261,7 @@ your dependencies. This includes any `alias` you might have in there.
Currently dependency-cruiser supports a reasonable subset of webpack
config file formats:

- nodejs parsable javascript only
- nodejs parsable JavaScript only
- webpack 4 compatible and up (although earlier ones _might_ work
there's no guarantee)
- exporting either:
Expand Down Expand Up @@ -325,7 +325,7 @@ _teamcity_ reporters (he _dot_ and _ddot_ reporters already did before).
### Q: I'm using window.require or a require wrapper - how do I make sure dependencies I declared like that are included?

**A**: From version 5.4.0 or higher you can add an _exoticRequireStrings_ key in
your configuration with the wrapper(s) and/ or redefinitions of require:
your configuration with the wrapper(s) and/ or re-definitions of require:

```json
"exoticRequireStrings": ["window.require", "need", "tryRequire"]
Expand Down Expand Up @@ -353,12 +353,12 @@ your configuration with the wrapper(s) and/ or redefinitions of require:
- In `test/report` add unit tests that prove your reporter does what it
intends.

### Q: How do I add support for my favorite alt-js language?
### Q: How do I add support for my favourite alt-js language?

**A**: Ask me nicely or make a PR.

Dependency-cruiser already supports TypeScript, CoffeeScript and LiveScript. If
there's another language (that transpiles to javascript) you'd like to see
there's another language (that transpiles to JavaScript) you'd like to see
support for, let me know.

Recipe for PR's to add an alt-js language:
Expand All @@ -371,7 +371,7 @@ Recipe for PR's to add an alt-js language:
correctly later on).
- In `src/transpile`
- add a `yourLanguageWrap.js` that invokes the transpiler transforming
your language into javascript (preferably ES6 or better, but lower versions
your language into JavaScript (preferably ES6 or better, but lower versions
should work as well). [`typeScriptWrap.js`](../src/extract/transpile/typeScriptWrap.js)
as an example on how to do this.
- in [`meta.js`](../src/extract/transpile/meta.js)
Expand All @@ -380,7 +380,7 @@ Recipe for PR's to add an alt-js language:
language.
- In `test/extract/transpile` add unit tests for `yourLanguageWrap`

## Roadmap
## Road map

[Here](https://github.com/sverweij/dependency-cruiser/projects/1)

Expand Down
6 changes: 3 additions & 3 deletions doc/real-world-samples.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
### Chalk

[chalk/chalk](https://github.com/chalk/chalk) -
For coloring strings in the terminal. A typical _Sorhus style_ micro module that uses other micro modules to accomplish its goals.
For colouring strings in the terminal. A typical _Sorhus style_ micro module that uses other micro modules to accomplish its goals.

<img width="704" alt="chalk" src="real-world-samples/chalk.png">

Expand All @@ -21,7 +21,7 @@ For coloring strings in the terminal. A typical _Sorhus style_ micro module that

When your app becomes big, dependency graphs on module level will become
impractical. Dependency-cruiser can consolidate modules (+ their dependencies)
and color them. Consolidation works out of the box for many repositories,
and colour them. Consolidation works out of the box for many repositories,
but can be [configured](./rules-reference.md#archi) to your [own liking](./rules-reference.md#reporteroptions).

Here's the resulting get high level dependency graph for berry:
Expand Down Expand Up @@ -136,7 +136,7 @@ transpiled JavaScript.)
Dependency cruiser used on itself, focusing on internal dependencies only, on three
levels of abstraction - high level, folder and modules. A small
[custom theme](rules-reference.md#dot) in its [configuration](../.dependency-cruiser.json#L196)
colors the various main parts (extract, validate, report) and the dependencies to
colours the various main parts (extract, validate, report) and the dependencies to
them. Click for slightly more interactive versions.

#### high level overview ('archi')
Expand Down
Loading

0 comments on commit 682b195

Please sign in to comment.