sheerun / prettier-standard

Formats with Prettier and lints with ESLint+Standard! (✿◠‿◠)
MIT License
868 stars 44 forks source link

space-before-function-paren not working #12

Closed simply-innovative closed 7 years ago

simply-innovative commented 7 years ago

based on steps provided, I have configured prettier-standard but when I do git add space-before-function-paren eslint rule seems not working:

Source: function a () { if (true) { } }

After Git Add: function a() { if (true) { } }

It is removing the space before function parentheses. I have also tried to put the same in .eslintrc but then also it is not working.

{ "rules": { "object-curly-spacing": ["error", "always"], "space-before-function-paren": ["error", { "anonymous": "always", "named": "always", "asyncArrow": "always" }] } }

Can you please guide me how to enable this feature. Please find below software stack:

"prettier": "1.2.2", "prettier-standard": "4.1.0"

sheerun commented 7 years ago

could you paste the source?

simply-innovative commented 7 years ago

Please find below our class entire source:

` /* @flow /

class Offline { constructor (config: any) {}

save (event: any) { function a () { if (true) { } } } }

export { Offline } ` Please let me know in case any other information required too

simply-innovative commented 7 years ago

I suspected may be due to flow, but after removing flow then also it is not working :(

sheerun commented 7 years ago

in my case prettier-standard formats to following:

/** @flow */

class Offline {
  constructor (config: any) {}

  save (event: any) {
    function a () {
      if (true) {
      }
    }
  }
}

export {Offline}

what version are you using?

sheerun commented 7 years ago

ok, I see 4.1.0.. please make sure you also use have the newest eslint and prettier in node_modules

simply-innovative commented 7 years ago

Verified I have the latest version of both eslint and prettier in node_modules: eslint: 3.19.0 prettier: 1.2.2

sheerun commented 7 years ago

I guess you'd need to prepare repository to reproduce as I'm unable to do so with just this file

simply-innovative commented 7 years ago

Sure Sheerun. I will do the needful and will share the path of repo.

Thanks a lot for looking into the same

Gryff commented 7 years ago

I also see this issue. Just installed today v5.0.0, not used prettier or standard before. $ yarn global add prettier-standard $ prettier-standard --version 5.0.0 $ echo "function hello () {}" | prettier-standard function hello() {}

sheerun commented 7 years ago

@Gryff @simply-innovative Could you try 5.1.0?

yarn global add prettier-standard
prettier-standard --version
5.1.0
echo "function hello () {}" | prettier-standard
function hello () {}

Also, please note that .eslintrc might be interfering in proper formatting, as prettier-standard allows for customizing its behavior

Gryff commented 7 years ago

I see what you mean. Doing echo "function hello () {}" | prettier-standard outside of the project I was working on produces the expected function hello () {}, inside it does as above. This is both for 5.0.0 and 5.1.0.

Thanks for pointing that out :) Do you happen to have a list of files that will affect prettier-standard? I don't have an .eslintrc, I'm guessing it's .editorconfig that is customising it.

sheerun commented 7 years ago

there are few but .editorconfig doesn't seem one of them: http://eslint.org/docs/user-guide/configuring#configuration-file-formats