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

First working version #3

Open
Glavin001 opened this issue Jul 9, 2018 · 3 comments
Open

First working version #3

Glavin001 opened this issue Jul 9, 2018 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@Glavin001
Copy link
Member

No description provided.

@Glavin001 Glavin001 added the enhancement New feature or request label Jul 9, 2018
@Glavin001 Glavin001 self-assigned this Jul 9, 2018
@request-info
Copy link

request-info bot commented Jul 9, 2018

The maintainers of this repository would appreciate it if you could provide more information.

@Glavin001
Copy link
Member Author

Input:

  language: "JavaScript",
  beautifiers: [
    "Prettier",
    "JS-Beautify"
  ],
  originalText: `if(true){console.log({ hello: "world" });}`,
  desiredText: `if (true) {\n  console.log({hello: 'world'})\n}\n`,

Then run auto-config script:

> ts-node src/UnibeautifySolver.ts

Solution 99 { maximum: 4,
  mean: 111.24,
  minimum: 903,
  stdev: 176.70529816618404 } if (true) {
  console.log({hello: 'world'})
}
 if (true) {
  console.log({hello: 'world'})
}
 {
  "fitness": 4,
  "entity": {
    "options": {
      "beautifiers": [
        "JS-Beautify",
        "Prettier"
      ],
      "brace_style": "collapse-preserve-inline",
      "end_with_semicolon": false,
      "object_curly_spacing": false,
      "quotes": "single"
    }
  }
}

And it attempted to determine the configuration which beautifies to the best match!

Desired Output:

if (true) {
  console.log({hello: 'world'})
}

Best Output:

if (true) {
  console.log({hello: 'world'})
}

It correctly found the perfect match! :success:

Recommended configuration is:

"options": {
      "beautifiers": [
        "JS-Beautify",
        "Prettier"
      ],
      "brace_style": "collapse-preserve-inline",
      "end_with_semicolon": false,
      "object_curly_spacing": false,
      "quotes": "single"
    }

🎉

@Glavin001
Copy link
Member Author

🎉

Solution after 199 generations:
{
  "fitness": 5,
  "entity": {
    "options": {
      "beautifiers": [
        "Prettier",
        "JS-Beautify"
      ],
      "end_with_newline": true,
      "end_with_semicolon": false,
      "pragma_insert": true,
      "preserve_newlines": false,
      "quotes": "single"
    }
  }
}
{
  "maximum": 5,
  "mean": 3544.72,
  "minimum": 18002,
  "stdev": 6290.965274232565
}
--------------------
/** @format */
console.log('hello world')

--------------------
/** @format */
console.log('hello world')

--------------------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant