Giter Club home page Giter Club logo

prettier-plugin-dot's Introduction

NodeCI npm version License: MIT PRs Welcome tested with jest code style: prettier All Contributors

Prettier for Graphviz Dot

prettier-plugin-dot is a prettier plugin for Graphviz Dot.

Format your Dot using Prettier.

How it works? 🤔

A Prettier plugin must first parse the source code of the target language into a traversable data structure (Usually an Abstract Syntax Tree) and then print out that data structure in a "pretty" style.

The Graphviz Dot AST generated by ts-graphviz implemented in JavaScript using the peggy. What this means is that unlike many other prettier plugins, prettier-plugin-dot has no additional runtime pre-requisites (e.g: Python executable). It could even be used inside a browser.

Getting started ✨

If you're using the npm or yarn CLI, then add the plugin by:

NPM

# yarn
$ yarn add -D prettier prettier-plugin-dot
# or npm
$ npm install --save-dev prettier prettier-plugin-dot

The prettier executable is now installed and ready for use:

$ yarn run prettier --write '**/*.dot'
# or
$ npx prettier --write '**/*.dot'

Example 📑

Input ⬅️

digraph G {Hello->World}

Output ➡️

digraph G {
  Hello -> World;
}

Related Projects 💫

Related projects can be found at ts-graphviz GitHub Organization.

The TypeScript/JavaScript ecosystem provides a variety of OSS with the goal of making Graphviz more connected and easier to use.

Contributors 👥

Thanks goes to these wonderful people (emoji key):

Yuki Yamazaki
Yuki Yamazaki

📖 ⚠️ 💻
Chris Wilkinson
Chris Wilkinson

🐛
Irakli Safareli
Irakli Safareli

🤔
Michael Bock
Michael Bock

🐛

This project follows the all-contributors specification. Contributions of any kind welcome!

How to Contribute 💪

The easiest way to contribute is to use the library and star repository.

Questions 💭

Feel free to ask questions on GitHub Discussions.

Report bugs / request additional features 💡

Please register at GitHub Issues.

Development / Bug Fixes 🧑‍💻

See CONTRIBUTING.md.

Financial Support 💸

Please support core member kamiazya.

Note Even just a dollar is enough motivation for me to develop 😊

License ⚖️

This software is released under the MIT License, see LICENSE.

prettier-plugin-dot's People

Contributors

allcontributors[bot] avatar dependabot[bot] avatar kamiazya avatar

Stargazers

 avatar  avatar

Watchers

 avatar

prettier-plugin-dot's Issues

`[error] require() of ES Module`

Unfortunately I cannot run the plugin, I'm getting a [error] require() of ES Module error.

Here's the complete CLI session:

$ node --version
v19.1.0

$ yarn --version
1.22.19

$ yarn init -y
[..]
Done in 0.04s.

$ yarn add -D prettier prettier-plugin-dot
[...]
Done in 1.95s.

$ yarn run prettier --write '**/*.dot'
yarn run v1.22.19
$ {{PROJECT_DIR}}/node_modules/.bin/prettier --write '**/*.dot'
[error] require() of ES Module {{PROJECT_DIR}}/node_modules/prettier-plugin-dot/lib/index.js from {{PROJECT_DIR}}/node_modules/prettier/index.js not supported.
[error] Instead change the require of {{PROJECT_DIR}}/node_modules/prettier-plugin-dot/lib/index.js in {{PROJECT_DIR}}/node_modules/prettier/index.js to a dynamic import() which is available in all CommonJS modules.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Removes new line at the end of the file

Describe the bug

it's common to have a new line at the end of files to avoid a 'No newline at end of file' message when diffing; the plugin currently removes it.

To Reproduce

Run the Prettier fixer on a file that has a trailing new line:

digraph G {
  Hello -> World;
}

The trailing new line is removed, becoming:

digraph G {
  Hello -> World;
}

Expected behavior

It's left unchanged.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.