Add Prettier for formatting (#5)

This commit is contained in:
Justin Fagnani
2019-12-18 13:13:30 -08:00
committed by GitHub
parent 51806b8d86
commit 07f4413342
5 changed files with 22 additions and 2 deletions

7
.prettierrc.json Normal file
View File

@@ -0,0 +1,7 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"singleQuote": true,
"bracketSpacing": false,
"arrowParens": "always"
}

View File

@@ -72,6 +72,12 @@ To lint the project run:
npm run lint
```
## Formatting
[Prettier](https://prettier.io/) is used for code formatting. It has been pre-configured according to the Polymer Project's style. You can change this in `.prettierrc.json`.
Prettier has not been configured to run when commiting files, but this can be added with Husky and and `pretty-quick`. See the [prettier.io](https://prettier.io/) site for instructions.
## More information
See [Get started](https://lit-element.polymer-project.org/guide/start) on the LitElement site for more information.

6
package-lock.json generated
View File

@@ -5462,6 +5462,12 @@
"integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=",
"dev": true
},
"prettier": {
"version": "1.19.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz",
"integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==",
"dev": true
},
"private": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz",

View File

@@ -9,6 +9,7 @@
"build": "tsc",
"build:watch": "tsc --watch",
"lint": "lit-analyzer && eslint 'src/**/*.ts'",
"format": "prettier src/* --write",
"serve": "es-dev-server --app-index demo/index.html --node-resolve --watch --open",
"test": "karma start karma.conf.cjs",
"test:watch": "karma start karma.conf.cjs --auto-watch=true --single-run=false",
@@ -41,6 +42,7 @@
"karma-mocha": "^1.3.0",
"lit-analyzer": "^1.1.9",
"mocha": "^6.2.2",
"prettier": "^1.19.1",
"typescript": "^3.7.2"
}
}

View File

@@ -16,7 +16,6 @@ import { LitElement, html, customElement, property, css } from 'lit-element';
@customElement('my-element')
export class MyElement extends LitElement {
static styles = css`
:host {
display: block;