Skip to content

Commit

Permalink
Configuring eslint and prettier
Browse files Browse the repository at this point in the history
Setting up ESLint and Prettier for this repo

At @webmasterkai's suggestion, we are mostly using the Airbnb JS Style guide
except tweaking it to use semicolons as little as possible.

I set this up using this script: https://github.com/paulolramos/eslint-prettier-airbnb-react in the hopes that it would make sure that eslint and prettier
would play nicely together. I think then manually edited the configuration
files to set semi to never/false.

I didn't run prettier or ESLint autofix over all the files in the repository
as part of this change. That could be done as separate commit if someone
wants to do it.

I also didn't setup any commit hooks or other enforcement mechanisms for
these policies. If these seem to be working well and we want to enforce
them more strongly later, we could add that. In the short term, it seems
like those could risk blocking us from pushing or editing the website and
that would be worse than having inconsistent style or formatting.
  • Loading branch information
ccheever committed Mar 16, 2020
1 parent f00f4f5 commit 7476494
Show file tree
Hide file tree
Showing 5 changed files with 1,575 additions and 1 deletion.
29 changes: 29 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module.exports = {
extends: ['airbnb', 'plugin:prettier/recommended', 'prettier/react'],
env: {
browser: true,
commonjs: true,
es6: true,
jest: true,
node: true,
},
rules: {
semi: 'never',
'jsx-a11y/href-no-hash': ['off'],
'react/jsx-filename-extension': ['warn', { extensions: ['.js', '.jsx'] }],
'max-len': [
'warn',
{
code: 80,
tabWidth: 2,
comments: 80,
ignoreComments: false,
ignoreTrailingComments: true,
ignoreUrls: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
ignoreRegExpLiterals: true,
},
],
},
}
6 changes: 6 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
printWidth: 80,
singleQuote: true,
trailingComma: 'all',
semi: false,
}
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@ Before you start developing, you may need to run `npm run prod` one time and the
`npm run dev` will spin up a local instance of the site. That usually runs at [https://localhost:8080](https://localhost:8080), unless you already have asomething running on that port—it’ll give you a URL in your terminal.

When you push a change, the CI will get kicked off at https://app.netlify.com/sites/upbeat-lovelace-3e9fff/deploys

## Formatting

The guideline for this repo is to use the [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript) [except that semicolons are set to never/false](https://covid-tracking.slack.com/archives/CUYAS1M25/p1584315172411600).

[ESLint](https://eslint.org/) is setup for linting and [Prettier](https://prettier.io/) is setup for formatting. Configure them in your editor and run prettier on JS files before committing them.

Since there are a lot of generated and legacy files, there are no commit hooks or other automated enforcement of these policies.
Loading

0 comments on commit 7476494

Please sign in to comment.