Rome v12.1.0

Stage 3 decorators, VCS support, new lint rules and more.
Emanuele Stoppa & Rome Team

Rome v12.1.0 brings support for the new Stage 3 decorators, VCS support and new lint rules!

You can upgrade Rome by running the following command:

npm install --save-dev --save-exact rome@12.1.0
pnpm update --save-exact rome@12.1.0
yarn upgrade --exact rome@12.1.0

Or install the VS Code extension to integrate Rome into your editor.

Stage 3 decorators

The new version of decorators was promoted to Stage 3, and now Rome is able to parse them and format them.

Now you’ll be able to use most of your frameworks, and all lint rules will work out of the box.

Before

@Column(

)
class name {
    id: something
}

Formatted

@Column()
class name {
    id: something;
}

Huge thank you to Denis Bezrukov for his amazing work! He alone implemented the parsing and the formatting.

Built in VCS support

With this release, Rome is now able to integrate itself with your VCS! The set of features and clients available is very small, but with time we will be able to ship more features.

In this release, only git is supported, and you’ll be able to ignore files and directories inside the .gitignore file:

{
  "vcs": {
    "enabled": true,
    "clientKind": "git",
    "useIgnoreFile": true
  }
}

With this configuration, will import the paths specified in the .gitignore file and won’t process them.

More rules!

Many new rules have been stabilised and promoted:

Huge thanks to:

  • Conaclos for writing many of these new and promoted rules, and driving the majority of the efforts in the linter;
  • nissy-dev for refactoring many rules, making them more clear with better diagnostics;
  • unvalley for implementing most of the accessibility rules;

rome check via stdin

You can now check your code via standard input. This was feature available to the command rome format, and you can now use this very feature via rome check!

A code like this

echo "a == 3" | cargo rome-cli-dev check --stdin-file-path=file.js

Will result in following output in stderr:

file.js lint/suspicious/noDoubleEquals  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ✖ Use === instead of ==

  ℹ == is only allowed when comparing against null

  ℹ Using === may be unsafe if you are relying on type coercion

  ℹ Suggested fix: Use ===

    1 │ a·===·3
      │     +

file.js format ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ℹ Formatter would have printed the following content:

    1 │ a·==·3;
      │       +

Instead, we added the --apply (or --apply-unsafe), we will see a different output.

echo "a == 3" | cargo rome-cli-dev check --apply --stdin-file-path=file.js

In stdout we will have the new output

a == 3;

Notice the ; at the end, which was added by the formatter

And in stderr, we will have the following output

file.js lint/suspicious/noDoubleEquals  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ✖ Use === instead of ==

  ℹ == is only allowed when comparing against null

  ℹ Using === may be unsafe if you are relying on type coercion

  ℹ Suggested fix: Use ===

    1 │ a·===·3;
      │     +

New rome migrate command

Use this command to update your configuration file in case there are breaking changes.

For the time being, there aren’t breaking changes! But, in the future there are, use this command to migrate rome.json, without the hassle.

New help prompt

The CLI now uses a new library, which is able to generate output from the source code. This resulted in a new help prompt.

Run the formatter on a set of files.

Usage: [--write] <PATH>...

Available positional items:
    <PATH>  Single file, single path or list of paths

Available options:
        --indent-style <tab|space>  The indent style.
        --indent-size <NUMBER>  The size of the indentation, 2 by default
        --line-width <NUMBER>  What's the max width of a line. Defaults to 80.
        --quote-style <double|single>  The style for quotes. Defaults to double.
        --quote-properties <preserve|as-needed>  When properties in objects are quoted. Defaults to
                       asNeeded.
        --trailing-comma <all|es5|none>  Print trailing commas wherever possible in multi-line
                       comma-separated syntactic structures. Defaults to "all".
        --semicolons <always|as-needed>  Whether the formatter prints semicolons for all statements
                       or only in for statements where it is necessary because of ASI.
        --vcs-client-kind <git>  The kind of client.
        --vcs-enabled <true|false>  Whether Rome should integrate itself with the VCS client
        --vcs-use-ignore-file <true|false>  Whether Rome should use the VCS ignore file. When [true],
                       Rome will ignore the files specified in the ignore file.
        --vcs-root <PATH>  The folder where Rome should check for VCS files. By default, Rome will
                       use the same folder where `rome.json` was found. If Rome can't fine the
                       configuration, it will attempt to use the current working directory. If no
                       current working directory can't be found, Rome won't use the VCS integration.
        --files-max-size <NUMBER>  The maximum allowed size for source code files in bytes. Files
                       above this limit will be ignored for performance reason. Defaults to 1 MiB
        --stdin-file-path <PATH>  A file name with its extension to pass when reading from standard
                       in, e.g. echo 'let a;' | rome format --stdin-file-path=file.js"
        --colors <off|force>  Set the formatting mode for markup: "off" prints everything as plain
                       text, "force" forces the formatting of markup using ANSI even if the console
                       output is determined to be incompatible
        --use-server   Connect to a running instance of the Rome daemon server.
        --verbose      Print additional verbose advices on diagnostics
        --config-path <PATH>  Set the filesystem path to the directory of the rome.json configuration
                       file
        --max-diagnostics <NUMBER>  Cap the amount of diagnostics displayed (default: 20)
        --skip-errors  Skip over files containing syntax errors instead of emitting an error
                       diagnostic.
        --json         Reports information using the JSON format
        --write
    -h, --help         Prints help information