-
Notifications
You must be signed in to change notification settings - Fork 1
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
Implement the beautifier #1
Open
lassik
wants to merge
11
commits into
Unibeautify:master
Choose a base branch
from
lassik:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c6c80fa
Update to match beautifier-template
lassik 168b505
Commit first draft of elm-format beautifier
lassik 0c69896
:art: Fix formatting of 2 files for commit 168b505
4599ab1
Install elm-format on Travis
lassik 963e0df
Show elm-format version in Travis log
lassik d455ee8
Add .vscode/launch.json
stevenzeck e0cba27
Reformat
lassik f69894c
Add CodeClimate ID for Travis
stevenzeck a94710b
Reformat
lassik e2b99bc
Refactor Travis script
lassik bbda22a
Fill in LICENSE
lassik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
version: "2" | ||
checks: | ||
argument-count: | ||
enabled: true | ||
config: | ||
threshold: 3 | ||
complex-logic: | ||
enabled: true | ||
config: | ||
threshold: 4 | ||
file-lines: | ||
enabled: false | ||
config: | ||
threshold: 250 | ||
method-complexity: | ||
enabled: true | ||
config: | ||
threshold: 5 | ||
method-count: | ||
enabled: true | ||
config: | ||
threshold: 20 | ||
method-lines: | ||
enabled: true | ||
config: | ||
threshold: 50 | ||
nested-control-flow: | ||
enabled: true | ||
config: | ||
threshold: 4 | ||
return-statements: | ||
enabled: true | ||
config: | ||
threshold: 4 | ||
similar-code: | ||
enabled: true | ||
config: | ||
threshold: #language-specific defaults. overrides affect all languages. | ||
identical-code: | ||
enabled: true | ||
config: | ||
threshold: #language-specific defaults. overrides affect all languages. | ||
exclude_patterns: | ||
- "dist/" | ||
- "**/node_modules/" | ||
- "/test/" | ||
- "**/*.d.ts" | ||
plugins: | ||
fixme: | ||
enabled: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
!dist/**/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
env: | ||
global: | ||
- CC_TEST_REPORTER_ID=0288dbd5e8a04d83f7e4e86710d77c540968fc4e791afe95e5d3aa79e20b90f9 | ||
language: node_js | ||
node_js: | ||
- "8" | ||
- "10" | ||
os: | ||
- linux | ||
- osx | ||
cache: | ||
directories: | ||
- node_modules | ||
before_script: | ||
- npm install -g elm-format | ||
- which elm-format | ||
- elm-format --help | ||
- OS_NAME=$(uname | tr A-Z a-z) | ||
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-${OS_NAME}-amd64 > ./cc-test-reporter | ||
- chmod +x ./cc-test-reporter | ||
- ./cc-test-reporter before-build | ||
script: | ||
- npm test | ||
after_script: | ||
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT | ||
notifications: | ||
email: | ||
on_success: never | ||
on_failure: change |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
TypeScript: | ||
beautifiers: ["Prettier"] | ||
align_assignments: false | ||
arrow_parens: "as-needed" | ||
break_chained_methods: true | ||
end_with_comma: true | ||
end_with_semicolon: true | ||
indent_char: " " | ||
indent_size: 2 | ||
jsx_brackets: false | ||
multiline_ternary: true | ||
object_curly_spacing: true | ||
quotes: "double" | ||
space_after_anon_function: false | ||
wrap_line_length: 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
|
||
{ | ||
"type": "node", | ||
"name": "Jest Tests", | ||
"request": "launch", | ||
"args": [ | ||
"--config", | ||
"jest.config.js", | ||
"--runInBand", | ||
"--coverage", | ||
"false" | ||
], | ||
"runtimeArgs": [ | ||
"--nolazy" | ||
], | ||
"sourceMaps": true, | ||
"cwd": "${workspaceFolder}", | ||
"protocol": "inspector", | ||
"program": "${workspaceFolder}/node_modules/jest/bin/jest", | ||
"outFiles": ["${workspaceRoot}/dist/"] | ||
} | ||
] | ||
} |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,19 @@ | ||
# beautifier-elm-format | ||
Elm-format beautifier for Unibeautify | ||
|
||
[![Build Status](https://travis-ci.com/Unibeautify/beautifier-elm-format.svg?branch=master)](https://travis-ci.com/Unibeautify/beautifier-elm-format) [![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovateapp.com/) | ||
|
||
> [elm-format](https://github.com/avh4/elm-format) beautifier for [Unibeautify](https://github.com/Unibeautify) | ||
|
||
## Installation | ||
|
||
```bash | ||
npm install --global @unibeautify/beautifier-elm-format | ||
``` | ||
|
||
## Contributing | ||
|
||
See [CONTRIBUTING.md](CONTRIBUTING.md) | ||
|
||
## Usage | ||
|
||
See [`unibeautify-cli`](https://github.com/Unibeautify/unibeautify-cli) for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
"use strict"; | ||
|
||
module.exports = { | ||
transform: { | ||
"^.+\\.tsx?$": "ts-jest" | ||
}, | ||
testRegex: "test/.+\\.(test|spec)\\.ts$", | ||
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"], | ||
collectCoverage: true, | ||
coverageReporters: ["json", "lcov", "text", "html"] | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to install elm as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the Travis build log, at least
elm-format --help
is running fine when we have only elm-format installed without the rest of the Elm toolchain. Does it show an error somewhere?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the error is being written to stdout for some reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome that you noticed that, I didn't notice at all and still can't find it :-D Tried grepping the raw logs of the latest build. Anyway, I think it's saying we need an Elm project file or a command line option to let it know the Elm version. Probably we don't actually need to have that version of Elm installed. I'll try adding
--elm-version=
to the unit test.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's reporting an error to stdout when you try to format stdin->stdout, we need to file a bug report about that..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would send the projectPath into the beautify method, then include
cwd: projectPath
in the optionsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That might work. The latest version of elm-format supports both Elm 0.18 and Elm 0.19. It determines the version based on the presence of
elm-package.json
(0.18) orelm.json
(0.19) in the current directory. That means strictly the current directory only - it doesn't look in parent directories. There's also a command line flag to control the Elm version but that seems like a more difficult solution for end users.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been debating whether elm-format should check the elm version for each file starting at the file and traversing up directories until it finds elm.json or elm-package.json, instead of looking in the current directory. It seems like that would probably be more correct for more cases. What do you think? (In any case, that would be in elm-format 0.8.2 at the earliest)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to see you here @avh4. You really care about your project! You already seem to have an issue about this at avh4/elm-format#561 so let's continue discussion there to make sure everyone can find it :) For this plugin, the most useful missing elm-format feature would be using
isatty()
(in Haskell,queryTerminal
) to disable ANSI output when stderr is not going a terminal.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussion about Elm version number is ongoing in #2