HookyQR / VSCodeBeautify

Enable js-beautify (https://github.com/beautify-web/js-beautify) in VS Code
MIT License
606 stars 180 forks source link

Cannot get space before function paren in JS/TS "class"es #292

Closed favna closed 5 years ago

favna commented 5 years ago

Provide the settings you use:

.jsbeautifyrc

{
    "end_with_newline": false,
    "indent_size": 4,
    "indent_char": " ",
    "eol": "\n",
    "brace_style": "collapse,preserve-inline",
    "space_after_anon_function":true,
    "space_after_named_function": true,
    "comma_first": false,
    "break_chained_methods": false,
    "keep_array_indentation": true,
    "keep_function_indentation": true,
    "space_before_conditional": true,
    "max_preserve_newlines": 2
}

Action performed

Format typescript file with HookyQR.beautifyFile command - TypeScript configured to be handled by the JavaScript parser

import { Argument, ArgumentType, CommandoClient, CommandoMessage } from 'awesome-commando';

export default class StringArrayType extends ArgumentType {
    constructor (client: CommandoClient) {
        super(client, 'stringarray');
    }

    public validate (value: string, msg: CommandoMessage, arg: Argument) {
        if (/([\S ]*,[\S ]*)*/i.test(value) && value.split(',').filter(Boolean).length >= 1) {
            return true;
        }

        return 'This command requires a command any word or set of words comma separated. For example `one` or `one,two,three`';
    }

    public parse (value: string) {
        return value.split(',').filter(Boolean);
    }
}

Expected results

Expected spaces before the parens in constructor, validate and parse to remain expected result

    constructor (client: CommandoClient) {
        super(client, 'stringarray');
    }

Actual results

Spaces before aforementioned functions are removed causing a stylistic (and TSLint) issue as I prefer there to be spaces. actual output

    constructor(client: CommandoClient) {
        super(client, 'stringarray');
    }
HookyQR commented 5 years ago

Nope, it's not something js-beautify is capable of.

favna commented 5 years ago

So... This cannot even be considered a future request?

HookyQR commented 5 years ago

You can log it over at https://github.com/beautify-web/js-beautify which is the code that does the actual work. We just wrap that functionality for VS Code.