eslint-config-globeletjs
v0.0.6
Published
A basic ESLint configuration for GlobeletJS modules
Downloads
15
Maintainers
Readme
eslint-config-globeletjs
A basic ESLint configuration for GlobeletJS modules
Installation
To use this configuration in your module, run:
npm install --save-dev eslint eslint-config-globeletjs
Then add the following in an .eslintrc.json
in the project's root directory:
{
"extends": "globeletjs"
}
Finally, add a linting script to your package.json
file:
"scripts": {
"lint": "eslint src examples/*/*.js",
"pretest": "npm run lint"
}
Usage
To see which of your code is inconsistent with the GlobeletJS coding style, you can run
npm run lint
If you are brave, you can automatically fix errors in a given file as follows:
npx eslint --fix file.js
Why double quotes?
Many popular standards, including the AirBnB, Google, and Standard style guides, require single quotes for strings.
GlobeletJS uses double quotes, except where single quotes can help avoid the need to escape a double quote within the string. There are 2 main reasons for this:
- Many strings in the GlobeletJS codebase appear in JSON-like object syntax. For example, tile-stencil's defaults.js, and the index.js of this module, eslint-config-globeletjs. JSON uses double quotes.
- Another common use of strings is for error messages. These should look like the program is talking to the user. And double quotes for speech are, overall, what most people expect.
One reason given for single quotes is that it allows HTML strings to be written without escapes. (The values of HTML attributes are typically enclosed in double quotes.) We don't accept this argument, for two reasons:
- In GlobeletJS code, we like to write HTML as HTML, and use JavaScript for Javascript. If there are long strings of HTML in our JavaScript, perhaps we should be re-considering the overall design of the module
- Our rule does allow single quotes, if there are double quotes within the string that would otherwise need to be escaped