0.8.3 • Published 3 months ago

prettier-plugin-motoko v0.8.3

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 months ago

Motoko Formatter · npm version GitHub license PRs Welcome

A Prettier plugin for the Motoko programming language.


Setup

After making sure Node.js is installed on your local machine, run the following command in your Motoko project directory:

npm install --save-dev prettier prettier-plugin-motoko

Command-line usage

Format your Motoko files using the Prettier CLI:

npx prettier --write --plugin=prettier-plugin-motoko **/*.mo

Check if your Motoko files are correctly formatted:

npx prettier --check --plugin=prettier-plugin-motoko **/*.mo

Alternatively, check out mo-fmt for a standalone Motoko formatter CLI:

mo-fmt **/*
mo-fmt -c **/*

VS Code support

Customization

Configure the formatter by creating a .prettierrc file in your project directory (full documentation).

Add the following line to your config file:

{
    "plugins": ["prettier-plugin-motoko"],
}

Example .prettierrc configuration with default values:

{
    "plugins": ["prettier-plugin-motoko"],
    "bracketSpacing": true,
    "printWidth": 80,
    "semi": true,
    "tabWidth": 2,
    "trailingComma": "es5",
    "useTabs": false
}

Multiple languages

Prettier will apply the same configuration to Motoko, JavaScript, CSS, HTML, and any other supported languages.

You can specifically configure Motoko files using a configuration override in your .prettierrc file:

{
    "overrides": [{
        "files": "*.mo",
        "options": {
            "bracketSpacing": true
        }
    }]
}

Ignoring code

Skip formatting a statement using a prettier-ignore comment:

// prettier-ignore
func ignored<A>(a:A){a};

func formatted<B>(b : B) { b };

Contributing

Feel free to submit a GitHub issue to report a bug or suggest a feature.

If you're interested in becoming an open-source contributor, be sure to check out the open issues in case anything catches your eye.

0.8.3

3 months ago

0.8.2

4 months ago

0.7.1

10 months ago

0.7.0

10 months ago

0.8.1

9 months ago

0.8.0

9 months ago

0.6.1

11 months ago

0.6.0

11 months ago

0.5.3

12 months ago

0.5.0

1 year ago

0.5.2

1 year ago

0.5.1

1 year ago

0.3.6

1 year ago

0.3.5

1 year ago

0.4.1

1 year ago

0.3.2

1 year ago

0.4.0

1 year ago

0.3.1

1 year ago

0.4.3

1 year ago

0.3.4

1 year ago

0.4.2

1 year ago

0.3.3

1 year ago

0.3.0

1 year ago

0.2.7

1 year ago

0.2.6

1 year ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.5

1 year ago

0.2.4

1 year ago

0.1.10

2 years ago

0.1.11

2 years ago

0.1.0

2 years ago

0.2.1

2 years ago

0.1.2

2 years ago

0.0.3

2 years ago

0.2.0

2 years ago

0.1.1

2 years ago

0.0.2

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.9

2 years ago

0.1.4

2 years ago

0.0.5

2 years ago

0.1.3

2 years ago

0.0.4

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.0.6

2 years ago

0.0.1

2 years ago