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

add command to check style #292

Closed
millermedeiros opened this issue Mar 26, 2015 · 5 comments
Closed

add command to check style #292

millermedeiros opened this issue Mar 26, 2015 · 5 comments
Labels
Milestone

Comments

@millermedeiros
Copy link
Owner

I was initially thinking on keeping this project as simple as possible and let other tools derive from it, but I think we should have our own check command (always be in sync with latest release). eg:

# check if file is formatted properly
esformatter check foo.js

ideally do something similar to what we do during the unit tests (highlight expected tokens as green and actual tokens as red) but displaying only the lines that have differences.

we should also add an option for unified diff (with and without color) since other tools can consume this format and some terminals don't support color.

# unified diff without color
esformatter check --unified-no-color foo.js

the diff module is a good option.

@millermedeiros
Copy link
Owner Author

the funny thing is that JSCS started as a code style checker and is adding support to automatically format code and we started as a formatter and are planning to add features to check style 😉

@millermedeiros millermedeiros modified the milestone: v0.7.0 Mar 26, 2015
@jzaefferer
Copy link
Collaborator

My initial motivation when I got involved here was to build something like the style checking that jscs does. I now use both jscs and esformatter, one for checking, one for formatting. I still like the test output of esformatter - if that gets reduced to relevant lines, with annotated line and column numbers, but keeping the red/green actual/expected output, I'd try to use this in place of jscs, still.

@millermedeiros
Copy link
Owner Author

maybe @piuccio is interested in merging his work into esformatter itself (https://github.com/piuccio/esformatter-diff)

@millermedeiros
Copy link
Owner Author

I couldn't find a tool that did what I needed (output pretty diffs keeping only lines that are useful for "context" and also displaying invisible chars) so I ended up writing my own: https://github.com/millermedeiros/disparity

screenshot char diff

now it should be easy to integrate it into esformatter

millermedeiros added a commit that referenced this issue Apr 1, 2015
also simplify the way errors are logged
millermedeiros added a commit that referenced this issue Apr 7, 2015
also simplify the way errors are logged
@millermedeiros
Copy link
Owner Author

in the end it isn't a check command, but just a --diff and --diff-unified flags:

# check if "test.js" matches style and output diff to stdout
esformatter --diff test.js
# check if "test.js" matches style and output unified diff to stdout
esformatter --diff-unified test.js
# check if "test.js" matches "options.json" style and output diff to stdout
esformatter --diff --config options.json test.js
# check all files inside "lib/" and it's subfolders
esformatter --diff lib/**/*.js

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

Successfully merging a pull request may close this issue.

2 participants