Plone style guide and JavaScript quotes

Continuing the discussion from Using GitHub's Marketplace tools to check add-ons code quality:

I see a lot of JavaScript code style warnings on some of our add-ons and I'm specially annoyed by the ones related to quotes.

according to ESLint:

JavaScript allows you to define strings in one of three ways: double quotes, single quotes, and backticks (as of ECMAScript 6). Each of these lines creates a string and, in some cases, can be used interchangeably. The choice of how to define strings in a codebase is a stylistic one outside of template literals (which allow embedded of expressions to be interpreted). Many codebases require strings to be defined in a consistent manner. This rule takes as parameter the style you prefer ("double", "single" or "backtick") default is double.

I double checked Plone's JavaScript styleguide and found nothing about it.

I want to ask what's our choice? can we stick to single quotes like we do in Python code?

to stick on single quotes I have added the following configuration file for the linter:

I'm +1 for this.
I'm starting using this eslint config and also a prettier config to force the use of single quotes in new projects.

1 Like

Just some food for thought:

  1. The JSON standard requires double quotes and does not allow single quotes
  2. Prettier uses double quotes by default: https://prettier.io/docs/en/options.html#quotes
  3. plone-react uses single quotes: https://github.com/plone/plone-react/blob/master/package.json#L308

No opinion either way. It is complicated...

IMO, we should use single quotes as that's what we're used to in Python.

Double quotes for JSON.

sure, double quotes in JSON files and single quotes in JavaScript files.

Just wondering if any final decision was made on this.
I found a plip that is requesting to use black as our python formatter, which means double quotes instead of single quotes for python code.

I looked at the styleguides, but that seems to not specifically talk about this: https://docs.plone.org/develop/styleguide/
except for here: https://docs.plone.org/develop/styleguide/python.html#quoting
which is not black consistent

Would it then not be more consistent to use double quotes everywhere at this point in time?
Or are the js developers all in favor of single quotes.
I would like this to see the quotes used consistently across plone and js, but that's just my personal opinion.