diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..d271d1f --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,7 @@ +{ + "trailingComma": "es5", + "tabWidth": 2, + "singleQuote": true, + "bracketSpacing": false, + "arrowParens": "always" +} diff --git a/README.md b/README.md index 9159758..60e5d86 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/package-lock.json b/package-lock.json index 7edb89b..70cda38 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index c5a9cd2..7997429 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/src/my-element.ts b/src/my-element.ts index 92d91dc..d5a9ad5 100644 --- a/src/my-element.ts +++ b/src/my-element.ts @@ -12,11 +12,10 @@ * http://polymer.github.io/PATENTS.txt */ -import { LitElement, html, customElement, property, css } from 'lit-element'; +import {LitElement, html, customElement, property, css} from 'lit-element'; @customElement('my-element') export class MyElement extends LitElement { - static styles = css` :host { display: block;