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

Does not put spaces inside parens #16

Closed
marekdedic opened this issue Feb 20, 2020 · 5 comments
Closed

Does not put spaces inside parens #16

marekdedic opened this issue Feb 20, 2020 · 5 comments

Comments

@marekdedic
Copy link

Hi,
I'm using wp-prettier through @wordpress/eslint-plugin version 4.0.0.

However, the tool is telling me to remove spaces inside parens - see skaut/skaut-google-drive-gallery#391

I opened https://wordpress.org/support/topic/spaces-and-wordpress-eslint-plugin/ and was redirected to submit a bug report here.

@samouri
Copy link

samouri commented Feb 21, 2020

I'm no longer associated with wp-prettier, but this seems more likely either a linter issue or an issue with your specific setup.

If you click into the CircleCi lint failure in your linked PR, the associated error looks like this:

[09:54:22] 'lint:eslint' errored after 4.08 s
[09:54:22] Error in plugin "gulp-eslint"
Message:
    Cannot find module 'prettier'

You should have prettier as a transitive dependency (because its a direct dep of the lint rules), but for some reason it isn't present in your package-lock.json. I'd recommend updating your package lock or making a dev dependency on wp-prettier.

w.r.t the spaces issue, thats actually the whole purpose of this repo, to put spaces in where the real prettier repo won't. My guess is that your local linter is pointed at an installation of prettier instead of wp-prettier, which would give you that error.

Hope that helps!

@marekdedic
Copy link
Author

Oh, sorry, I put the wrong link there. I will put in the correct one on Monday...

@marekdedic
Copy link
Author

Hi, the build was updated in the CI as well, sorry, I got two repos confused previously.

For posterity, here's the link to the exact build I've got an issue with: https://circleci.com/gh/skaut/skaut-google-drive-gallery/3579

Thanks

@samouri
Copy link

samouri commented Feb 25, 2020

Thanks for the updated link. The PR you point to shows this as the changelog for the eslint plugin that is being updated:

> > ## 4.0.0 (2020-02-10)
> > ### Breaking Changes
> > 
> > * The `recommended` ruleset checks again code formatting (whitespace, indenting, etc.). These rules are now enforced by Prettier itself through a plugin that diffs the code with its formatted output and reports the differences as lint errors. `eslint-plugin-prettier` was chosen over options like `prettier-eslint` because we don't run `eslint --fix` in hooks as we'd rather leave certain linting errors to be resolved or ignored at the author's discretion. We also don't apply any additional formatting with `eslint` over `prettier`, so the overhead would be unnecessary. `eslint-plugin-prettier` was chosen over options like `prettier --check` because it's nice to see format errors as you type as it leads you to write code with a more optimal auto-formatted output and it avoids issues like comment directives being moved out of place by `prettier` and the author not realizing it.

Your project doesn't use prettier, so of course it isn't following default conventions enforced by prettier (and therefore the linter).

Also, this package does not by default add in the parens spacing. You have to include the options parensSpacing: true, see an example here.

You have two options:

  1. Start using prettier in your project. Or if you are already using it in your IDE, you need to at least provide configuration for it so the linter doesn't error out.
  2. Don't upgrade the package

@marekdedic
Copy link
Author

marekdedic commented Feb 27, 2020

Hi,
thanks for the explanation.

I understand your comment so that the eslint-plugin has been upgraded to lint styles using prettier (or wp-prettier to be precise), but hasn't configured it properly to lint according to WPCS. Is that correct?

Thanks,
Marek

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

No branches or pull requests

2 participants