vkadam / grunt-jsbeautifier

Beautify js, css, html and json files using Grunt and https://github.com/einars/js-beautify
MIT License
119 stars 28 forks source link

bug(config): grunt-jsbeautifier doesn't support .jsbeautifyrc #63

Closed Kristinita closed 6 years ago

Kristinita commented 6 years ago

1. Summary

Part of grunt-jsbeautifier documentation:

Recommended for version < 0.2.7, use .jsbeautifyrc for > 0.2.7

But grunt-jsbeautifier doesn't support .jsbeautifyrc.

2. Environment

3. Configuration

Example configuration in SashaGruntJsBeautify branch of my demo repository:

.jsbeautifyrc file:

{
    "indent_with_tabs": true,
    "end_with_newline": true
}

SashaJsBeautify.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Sasha title</title>
</head>
<body>
    Example body text
</body>
</html>

.editorconfig:

[*]
indent_style = tab
insert_final_newline = true

Gruntfile.coffee:

module.exports = (grunt) ->

    grunt.loadNpmTasks('grunt-jsbeautifier')
    grunt.initConfig
        jsbeautifier:
            files: ['SashaJsBeautify.html']

4. Steps to reproduce

grunt jsbeautifier

Then check tabs and final newline via eclint:

eclint check

5. Expected behavior

If Gruntfile.coffee:

module.exports = (grunt) ->

    grunt.loadNpmTasks('grunt-jsbeautifier')
    grunt.initConfig
        jsbeautifier:
            options:
                html:
                    indentWithTabs: true
                    endWithNewline: true
            files: ['SashaJsBeautify.html']

or I run js-beautify CLI

js-beautify -rn SashaJsBeautify.html

No warnings and/or errors.

6. Actual behavior

Else Gruntfile.coffee:

module.exports = (grunt) ->

    grunt.loadNpmTasks('grunt-jsbeautifier')
    grunt.initConfig
        jsbeautifier:
            files: ['SashaJsBeautify.html']
$ eclint check SashaJsBeautify.html
SashaJsBeautify.html
    05:01 ❌️ invalid indent style: space, expected: tab (EditorConfig indent_style         https://goo.gl/8Qkrbr)
    06:01 ❌️ invalid indent style: space, expected: tab (EditorConfig indent_style         https://goo.gl/8Qkrbr)
    10:01 ❌️ invalid indent style: space, expected: tab (EditorConfig indent_style         https://goo.gl/8Qkrbr)
    13:07 ❌️ expected final newline                     (EditorConfig insert_final_newline https://goo.gl/LRCZMy)

Look at this on Travis CI.

Thanks.

Kristinita commented 6 years ago

Status: :speak_no_evil: Excuse me for troubling, my mistake

grunt-jsbeautifier required .jsbeautifyrc in config. Correct configuration:

module.exports = (grunt) ->

    grunt.loadNpmTasks('grunt-jsbeautifier')
    grunt.initConfig
        jsbeautifier:
            options:
                config: ".jsbeautifyrc"
            files: ['SashaJsBeautify.html']

But it would be nice, if .jsbeautifyrc will config file by default.

Thanks.