Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak docs #291

Merged
merged 2 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Run [`elm-review`] from Node.js.

## Installation

```bash
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference in practice? Asking because I always do bash.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Purely semantic, as far as I can tell. I wrote this two months ago, so 🤷‍♂️
I don't think it makes a difference to syntax highlighting (on gh at least), etc, but I use zsh, Simon uses fish, etc.
I just always use sh for shell stuff unless I need a specific shell.

```sh
# Save it to your package.json, if you use npm in your project.
# This is the recommended way.
npm install elm-review --save-dev
Expand All @@ -19,7 +19,7 @@ See [below](#try-it-out) if you want to try it out without installing it.

## Usage

```bash
```sh
# Print the help
elm-review --help

Expand Down Expand Up @@ -47,7 +47,7 @@ First of all, if you have `node` installed, it comes with `npx`, which lets you
You can also run a configuration you found on GitHub, using the `--template` flag. Even if you already have a configuration, you can use this to try out the rules from a new package before adding them to your configuration.
For instance, if you want to find and remove the dead code in your project, you can use the [example configuration](https://github.com/jfmengels/elm-review-unused/tree/main/example) from the [`jfmengels/elm-review-unused` package](https://package.elm-lang.org/packages/jfmengels/elm-review-unused/latest/).

```bash
```sh
npx elm-review --template jfmengels/elm-review-unused/example

# You can even use the configuration to fix all the errors that can be auto-fixed.
Expand All @@ -56,15 +56,15 @@ npx elm-review --template jfmengels/elm-review-unused/example --fix-all

If you are happy with the configuration, you can base your own configuration off of it, and then edit it:

```bash
```sh
npx elm-review init --template jfmengels/elm-review-unused/example
```

I **highly** recommend [reading this section on when to enable rules](https://package.elm-lang.org/packages/jfmengels/elm-review/latest/#when-to-write-or-enable-a-rule) in your configuration though.
I **highly** recommend reading [this section on when to enable rules][when-to-write-or-enable-a-rule] in your configuration though.

You can use the same mechanics to try out a single rule before adding the dependency to your existing configuration and adding it to your configuration.

```bash
```sh
npx elm-review --template jfmengels/elm-review-unused/example --rules NoUnused.Variables
```

Expand Down Expand Up @@ -100,7 +100,7 @@ which will add a `review` folder to your project.
You can also use an existing configuration using `elm-review init --template <some configuration>`.
I created [some configurations](https://github.com/jfmengels/elm-review-config) that I believe can be good **starting** points.

```bash
```sh
# Start with an empty configuration
elm-review init

Expand All @@ -117,14 +117,14 @@ you can look for packages with rules on the [Elm package registry](https://packa

Once you've found a package that you like, you can install it with the `elm install` command, just like any other Elm project dependency.

```bash
```sh
cd review/ # Go inside your review configuration directory
elm install authorName/packageName
# then update your `review/src/ReviewConfig.elm` to add the rule
# as explained in the package's documentation
```

Before you start adding rules or an unfamiliar existing configuration, I suggest reading the rest of this document, especially the section on [when to enable a rule](#when-to-write-or-enable-a-rule).
Before you start adding rules or an unfamiliar existing configuration, I suggest reading the rest of this document, especially the section on [when to enable a rule][when-to-write-or-enable-a-rule].

## Run a review

Expand All @@ -134,7 +134,7 @@ You can also run `elm-review --fix`. The CLI will present you fixes for the erro

Run `elm-review --help` for more information on the available flags.

```bash
```sh
elm-review # Analyze your project
elm-review --fix # Analyze your project and potentially proposes automatic fixes
elm-review --help # for more information and the available flags
Expand All @@ -149,7 +149,7 @@ elm-review --help # for more information and the available flags

If you wish to, you can list the directories you wish to have reviewed, so as to review additional directories or to remove ignore some of directories, by adding them as arguments to the command line.

```bash
```sh
# Review `src/` if project is a package, or the "source-directories" otherwise, along with `tests/`
elm-review
# Review only the Elm files in the `src/Dashboard/`
Expand Down Expand Up @@ -181,13 +181,15 @@ The CLI need at least two pieces of information from your configuration:

Your custom rules, unless you want to share them in the Elm package registry, should be in the `review/` directory too, so as not to pollute your project's dependencies. If they are in here, we need to include these custom rules and their dependencies in the application files.

[`elm-review`]: https://github.com/jfmengels/elm-review
[`elm-format`]: https://github.com/avh4/elm-format

## Tooling integration

If you are interested in using `elm-review` inside a different environment than a terminal (like editors, CI, other Elm tools, ...), check out the documentation for [tooling integration](./documentation/tooling-integration.md).

## Thanks

Thanks to @MartinSStewart for working on reducing the file cache size (and therefore speeding up the whole execution).
Thanks to [**@MartinSStewart**][martinsstewart] for working on reducing the file cache size (and therefore speeding up the whole execution).

[`elm-review`]: https://github.com/jfmengels/elm-review
[`elm-format`]: https://github.com/avh4/elm-format
[martinsstewart]: https://github.com/MartinSStewart
[when-to-write-or-enable-a-rule]: https://package.elm-lang.org/packages/jfmengels/elm-review/latest/#when-to-write-or-enable-a-rule
10 changes: 5 additions & 5 deletions lib/anonymize.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
This module aims to make the paths and versions used in the CLI generic
so that the CLI tests (in the `test/` folder) have the same output on different
machines, and also the same output when only the CLI version changes.
*/
/**
* This module aims to make the paths and versions used in the CLI generic
* so that the CLI tests (in the `test/` folder) have the same output on different
* machines, and also the same output when only the CLI version changes.
*/

/**
* @import {Options} from './types/options';
Expand Down
21 changes: 11 additions & 10 deletions lib/options.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/**
* This file contains all the options from which elm-review derives how it will behave.
*
* Some of these options are not documented in `--help`.
* DO NOT DEPEND ON THEM!
* They might get removed at any point.
* They are not part of the user-facing public API and may be removed in a SemVer patch.
* Open an issue if you have a need for them,
* so that we can discuss what the best course of action is and how to move forward.
*/

/**
* @import {ParsedArgs} from 'minimist';
* @import {Path} from './types/path';
Expand All @@ -15,16 +26,6 @@ const exit = require('../vendor/exit');
const ErrorMessage = require('./error-message');
const Flags = require('./flags');

/*
These contain all the options that derive what and how elm-review will behave.

Some of these options are not documented in `--help`.
DO NOT DEPEND ON THEM!
They might get removed at any point.
Open an issue if you have a need for them, so that we can discuss what the best
course of action is and how to get forward.
*/

/**
* @type {Subcommand[]}
*/
Expand Down
6 changes: 4 additions & 2 deletions lib/parse-elm-worker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Code very much inspired by
// https://blog.logrocket.com/a-complete-guide-to-threads-in-node-js-4fa3898fe74f/
/**
* This code was very much inspired by
* <https://blog.logrocket.com/complete-guide-threads-node-js/>.
*/

/**
* @import {MessagePort} from 'worker_threads';
Expand Down
6 changes: 4 additions & 2 deletions lib/parse-elm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Code very much inspired by
// https://blog.logrocket.com/a-complete-guide-to-threads-in-node-js-4fa3898fe74f/
/**
* This code was very much inspired by
* <https://blog.logrocket.com/complete-guide-threads-node-js/>.
*/

/**
* @import {Source, ElmFile} from './types/content';
Expand Down
Loading