Gutenberg: ESLint plugin: Use the default WordPress Prettier config when no config found

Created on 27 Feb 2020  路  9Comments  路  Source: WordPress/gutenberg

Describe the bug
Hi, I have recently upgraded @wordpress/eslint-plugin to version 4.0.0. After the update, eslint is telling me to remove spaces from inside parens, and replace ' with ". AFAIK this goes against WPC. I tried raising the issue at Automattic/wp-prettier#16 since I thought this was an issue with wp-prettier. From what I've been told, it's just that prettier isn't configured correctly for WPCS.

I haven't been using prettier before, so I would consider this a bug - using eslint-plugin, I would expect to get either no "stylistic" linting or linting in accordance with WPCS.

To reproduce
Steps to reproduce the behavior:
The exact build environment and result can be seen at https://circleci.com/gh/skaut/skaut-google-drive-gallery/3579

Expected behavior
I would expect to get either no "stylistic" linting or linting in accordance with WPCS.

Desktop (please complete the following information):

  • OS: Debian testing

Additional context

[Package] ESLint plugin [Status] In Progress [Type] Bug

Most helpful comment

Noting that #20026 was merged so we have @wordpress/prettier-config that can be conditionally integrated with ESLint plugin.

All 9 comments

Have you tried to follow my comment in your project: https://github.com/skaut/skaut-google-drive-gallery/pull/391#issuecomment-592173756?

Hi,
thanks, I noticed it on the phone, will try and report.

It seems like everything works as intended. It was an issue with configuration, the full discussion can be found in https://github.com/skaut/skaut-google-drive-gallery/pull/391.

Hi,
well, if eslint-plugin isn't configuring prettier to lint according to WPCS, why is it using it in the first place?

I understand the current state as "We don't care how you style your code, but you have to use prettier to do it and configure it yourself" - if that isn't a misunderstanding on my part, I don't get why the plugin would do that? I would like it to either give me a style that is according to WPCS or not lint style at all and leave it up to me....

@marekdedic, I see your point. I'm sure we can add a fallback to use the default WordPress Prettier config once https://github.com/WordPress/gutenberg/pull/20026 is in place. @ntwb, any plans to finish your PR or should I take it over?

In fact, when you use @wordpress/scripts, it's all handled properly. See:

https://github.com/WordPress/gutenberg/blob/79a80169f27875b20fe6cda8ec27dfdbd97b4821/packages/scripts/config/.eslintrc.js#L20-L30

Hi,
yeah, that seems like a great idea :+1: That way, we get WPCS by default, with an option to change it if one desires to.

Thanks

Noting that #20026 was merged so we have @wordpress/prettier-config that can be conditionally integrated with ESLint plugin.

21503 tries to fix the issue.

21602 is another try :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

youknowriad picture youknowriad  路  3Comments

nylen picture nylen  路  3Comments

aaronjorbin picture aaronjorbin  路  3Comments

pfefferle picture pfefferle  路  3Comments

moorscode picture moorscode  路  3Comments